From 6f3400ca521e84b1b627f2b5a53835d73e3ed2ea Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 May 2012 17:33:48 +0000 Subject: [PATCH 01/88] Clip editor: cleanup of View menu - do not show operators which doesn't make sense in dopesheet/curve view --- release/scripts/startup/bl_ui/space_clip.py | 33 ++++++++++--------- source/blender/editors/include/ED_clip.h | 3 ++ .../blender/editors/space_clip/clip_editor.c | 11 +++++++ .../editors/space_clip/clip_graph_ops.c | 6 +--- source/blender/editors/space_clip/clip_ops.c | 14 ++++---- 5 files changed, 39 insertions(+), 28 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 0b96ec772c8..e2fa67e3873 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -776,27 +776,28 @@ class CLIP_MT_view(Menu): layout = self.layout sc = context.space_data - layout.prop(sc, "show_seconds") - layout.separator() + if sc.view == 'CLIP': + layout.operator("clip.properties", icon='MENU_PANEL') + layout.operator("clip.tools", icon='MENU_PANEL') + layout.separator() - layout.operator("clip.properties", icon='MENU_PANEL') - layout.operator("clip.tools", icon='MENU_PANEL') - layout.separator() + layout.operator("clip.view_selected") + layout.operator("clip.view_all") - layout.operator("clip.view_selected") - layout.operator("clip.view_all") + layout.separator() + layout.operator("clip.view_zoom_in") + layout.operator("clip.view_zoom_out") - layout.separator() - layout.operator("clip.view_zoom_in") - layout.operator("clip.view_zoom_out") + layout.separator() - layout.separator() + ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) - ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1)) - - for a, b in ratios: - text = "Zoom %d:%d" % (a, b) - layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b + for a, b in ratios: + text = "Zoom %d:%d" % (a, b) + layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b + else: + layout.prop(sc, "show_seconds") + layout.separator() layout.separator() layout.operator("screen.area_dupli") diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index db6d9bbd013..03e7bd62a2c 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -42,6 +42,9 @@ struct wmEvent; /* clip_editor.c */ int ED_space_clip_poll(struct bContext *C); + +int ED_space_clip_view_clip_poll(struct bContext *C); + int ED_space_clip_tracking_poll(struct bContext *C); int ED_space_clip_tracking_size_poll(struct bContext *C); int ED_space_clip_tracking_frame_poll(struct bContext *C); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 443cb8f7ef4..c5c5628abb9 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -73,6 +73,17 @@ int ED_space_clip_poll(bContext *C) return FALSE; } +int ED_space_clip_view_clip_poll(bContext *C) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + + if (sc && sc->clip) { + return sc->view == SC_VIEW_CLIP; + } + + return FALSE; +} + int ED_space_clip_tracking_poll(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 03557a0b264..905aa2d11d4 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -66,11 +66,7 @@ static int ED_space_clip_graph_poll(bContext *C) if (ED_space_clip_tracking_poll(C)) { SpaceClip *sc = CTX_wm_space_clip(C); - if (sc->view == SC_VIEW_GRAPH) { - ARegion *ar = CTX_wm_region(C); - - return ar->regiontype == RGN_TYPE_PREVIEW; - } + return sc->view == SC_VIEW_GRAPH; } return FALSE; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 2bfc7a1dec8..133c807a7ff 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -408,7 +408,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot) ot->invoke = view_pan_invoke; ot->modal = view_pan_modal; ot->cancel = view_pan_cancel; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; /* flags */ ot->flag = OPTYPE_BLOCKING; @@ -534,7 +534,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) ot->invoke = view_zoom_invoke; ot->modal = view_zoom_modal; ot->cancel = view_zoom_cancel; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; /* flags */ ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; @@ -580,7 +580,7 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) /* api callbacks */ ot->exec = view_zoom_in_exec; ot->invoke = view_zoom_in_invoke; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in screen coordinates", -10.0f, 10.0f); @@ -620,7 +620,7 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) /* api callbacks */ ot->exec = view_zoom_out_exec; ot->invoke = view_zoom_out_invoke; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); @@ -652,7 +652,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot) /* api callbacks */ ot->exec = view_zoom_ratio_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; /* properties */ RNA_def_float(ot->srna, "ratio", 0.0f, 0.0f, FLT_MAX, @@ -719,7 +719,7 @@ void CLIP_OT_view_all(wmOperatorType *ot) /* api callbacks */ ot->exec = view_all_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; /* properties */ RNA_def_boolean(ot->srna, "fit_view", 0, "Fit View", "Fit frame to the viewport"); @@ -749,7 +749,7 @@ void CLIP_OT_view_selected(wmOperatorType *ot) /* api callbacks */ ot->exec = view_selected_exec; - ot->poll = ED_space_clip_poll; + ot->poll = ED_space_clip_view_clip_poll; } /********************** change frame operator *********************/ From a1f4be4577776add4a71ac3446aceb4195234fc7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 2 May 2012 17:37:39 +0000 Subject: [PATCH 02/88] Style cleanup: spaces around operators --- source/blender/editors/space_clip/clip_ops.c | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 133c807a7ff..c8a5b487b65 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -287,14 +287,14 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) vpd->y = event->y; if (sc->flag & SC_LOCK_SELECTION) - vpd->vec= &sc->xlockof; + vpd->vec = &sc->xlockof; else - vpd->vec= &sc->xof; + vpd->vec = &sc->xof; copy_v2_v2(&vpd->xof, vpd->vec); copy_v2_v2(&vpd->xorig, &vpd->xof); - vpd->event_type= event->type; + vpd->event_type = event->type; WM_event_add_modal_handler(C, op); } @@ -636,8 +636,8 @@ static int view_zoom_ratio_exec(bContext *C, wmOperator *op) sclip_zoom_set(sc, ar, RNA_float_get(op->ptr, "ratio"), NULL); /* ensure pixel exact locations for draw */ - sc->xof= (int) sc->xof; - sc->yof= (int) sc->yof; + sc->xof = (int) sc->xof; + sc->yof = (int) sc->yof; ED_region_tag_redraw(CTX_wm_region(C)); @@ -687,18 +687,18 @@ static int view_all_exec(bContext *C, wmOperator *op) if (fit_view) { const int margin = 5; /* margin from border */ - zoomx= (float) width / (w + 2 * margin); - zoomy= (float) height / (h + 2 * margin); + zoomx = (float) width / (w + 2 * margin); + zoomy = (float) height / (h + 2 * margin); sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { - zoomx= (float) width / w; - zoomy= (float) height / h; + zoomx = (float) width / w; + zoomy = (float) height / h; /* find the zoom value that will fit the image in the image space */ - sclip_zoom_set(sc, ar, 1.0f/power_of_2(1/MIN2(zoomx, zoomy)), NULL); + sclip_zoom_set(sc, ar, 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)), NULL); } else sclip_zoom_set(sc, ar, 1.0f, NULL); @@ -800,7 +800,7 @@ static int frame_from_event(bContext *C, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); - framenr= (int) floor(viewx + 0.5f); + framenr = (int) floor(viewx + 0.5f); } return framenr; From 203a4d42ca9f8a6e41c60c9d7a4e855b0c6cf635 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 May 2012 18:11:09 +0000 Subject: [PATCH 03/88] Fix #31089: collada file crashing on importing file with unknown/unsupported animation data. --- source/blender/collada/AnimationImporter.cpp | 17 +++++++++++++++++ source/blender/collada/AnimationImporter.h | 1 + 2 files changed, 18 insertions(+) diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 6a66f1fb817..cf815920b57 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -438,6 +438,16 @@ void AnimationImporter::modify_fcurve(std::vector* curves, const char* } } +void AnimationImporter::unused_fcurve(std::vector* curves) +{ + // when an error happens and we can't actually use curve remove it from unused_curves + std::vector::iterator it; + for (it = curves->begin(); it != curves->end(); it++) { + FCurve *fcu = *it; + unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end()); + } +} + void AnimationImporter::find_frames( std::vector* frames, std::vector* curves) { std::vector::iterator iter; @@ -499,6 +509,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * modify_fcurve(curves, rna_path, -1 ); break; default: + unused_fcurve(curves); fprintf(stderr, "AnimationClass %d is not supported for %s.\n", binding->animationClass, loc ? "TRANSLATE" : "SCALE"); } @@ -534,10 +545,13 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { modify_fcurve(curves, rna_path, 2 ); } + else + unused_fcurve(curves); break; case COLLADAFW::AnimationList::AXISANGLE: // TODO convert axis-angle to quat? or XYZ? default: + unused_fcurve(curves); fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", binding->animationClass); } @@ -553,9 +567,11 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * } }*/ + unused_fcurve(curves); break; case COLLADAFW::Transformation::SKEW: case COLLADAFW::Transformation::LOOKAT: + unused_fcurve(curves); fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n"); break; } @@ -591,6 +607,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list break; default: + unused_fcurve(&animcurves); fprintf(stderr, "AnimationClass %d is not supported for %s.\n", bindings[j].animationClass, "COLOR" ); } diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 362b288dbb4..6324853d91c 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -165,6 +165,7 @@ public: int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition); void modify_fcurve(std::vector* curves, const char* rna_path, int array_index ); + void unused_fcurve(std::vector* curves ); // prerequisites: // animlist_map - map animlist id -> animlist // curve_map - map anim id -> curve(s) From f87682f631c38970736aee0dd5b66bc5b3d2fbb9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 May 2012 18:14:59 +0000 Subject: [PATCH 04/88] Fix #31247: cycles crash after recent bugfix. --- intern/cycles/kernel/kernel_shader.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index af821bad868..2138038e49d 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -180,7 +180,8 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, } sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2); - sd->flag |= kernel_tex_fetch(__object_flag, sd->object); + if(sd->object != -1) + sd->flag |= kernel_tex_fetch(__object_flag, sd->object); #ifdef __DPDU__ /* dPdu/dPdv */ From 6f0cb140b0af6c7af6d2bce61db596975ad967c5 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 2 May 2012 23:29:52 +0000 Subject: [PATCH 05/88] Initialize an input in bmo_hull. --- source/blender/bmesh/operators/bmo_hull.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index f2ef777c952..700480be01c 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -414,6 +414,7 @@ static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op, float widest_axis_len, largest_dist, plane_normal[3]; int i, j, widest_axis; + tetra[0] = tetra[1] = tetra[2] = tetra[3] = NULL; hull_get_min_max(bm, op, min, max); /* Check for flat axis */ @@ -442,7 +443,6 @@ static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op, /* Choose third vertex farthest from existing line segment */ largest_dist = 0; - tetra[2] = NULL; for (i = 0; i < 3; i++) { BMVert *v; float dist; From 893cd1b4fd13b3324f383363bebd466ba04b376e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 May 2012 23:36:31 +0000 Subject: [PATCH 06/88] Fix #31253: collada export default file name now is no longer always untitled.dae, but rather uses .blend file name like other exporters. Patch by Gaia Clary. --- source/blender/windowmanager/intern/wm_operators.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1de8c95fcce..a38ee5afe15 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2132,7 +2132,12 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + + if (G.main->name[0] == 0) + BLI_strncpy(filepath, "untitled", sizeof(filepath)); + else + BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + BLI_replace_extension(filepath, sizeof(filepath), ".dae"); RNA_string_set(op->ptr, "filepath", filepath); } From 959a717d914c27d9b3f3030730bf4360ac3dcf1a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 May 2012 23:36:34 +0000 Subject: [PATCH 07/88] Fix #31250, #31248: wrong vertex normals after transform apply, collada import, sculpt shape key switch. All cases that called this function needed parameter only_face_normals set to false, so changed it now. Also fixed wrong user count for imported mesh from collada and simplified previous fix for tesselated faces to polygons conversion. --- source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/collada/DocumentImporter.cpp | 2 -- source/blender/collada/MeshImporter.cpp | 14 ++++---------- source/blender/collada/MeshImporter.h | 2 -- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index c7f6bf93831..fdeb212b561 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1783,7 +1783,7 @@ void mesh_calc_normals_mapping(MVert *mverts, int numVerts, { mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, numLoops, numPolys, polyNors_r, mfaces, numFaces, - origIndexFace, faceNors_r, TRUE); + origIndexFace, faceNors_r, FALSE); } void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 947bedc2ff7..a1f69ef16bd 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -144,8 +144,6 @@ bool DocumentImporter::import() delete ehandler; - mesh_importer.bmeshConversion(); - return true; } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index d6cc35deca7..3fbd33bdd0b 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -727,16 +727,6 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {} -void MeshImporter::bmeshConversion() -{ - for (std::map::iterator m = uid_mesh_map.begin(); - m != uid_mesh_map.end(); ++m) - { - if ((*m).second) BKE_mesh_convert_mfaces_to_mpolys((*m).second); - } -} - - Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid) { if (uid_object_map.find(geom_uid) != uid_object_map.end()) @@ -958,6 +948,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId(); Mesh *me = add_mesh((char*)str_geom_id.c_str()); + me->id.us--; // is already 1 here, but will be set later in set_mesh // store the Mesh pointer to link it later with an Object this->uid_mesh_map[mesh->getUniqueId()] = me; @@ -972,6 +963,9 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) make_edges(me, 0); + BKE_mesh_convert_mfaces_to_mpolys(me); + BKE_mesh_tessface_clear(me); + mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); return true; diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 97ae4d99ad7..0c2e600121f 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -129,8 +129,6 @@ public: MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce); - void bmeshConversion(); - virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid); MTex *assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, From bfcee9addb0cb2510d42ba030286e1e318a17e02 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 May 2012 23:48:16 +0000 Subject: [PATCH 08/88] Fix #31256: collada export while in edit mode does not export edit mode changes, now uses same call as render to flush mesh without leaving edit mode. --- source/blender/windowmanager/intern/wm_operators.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a38ee5afe15..6fab4ff45e1 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2161,6 +2161,10 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", filename); selected = RNA_boolean_get(op->ptr, "selected"); second_life = RNA_boolean_get(op->ptr, "second_life"); + + /* get editmode results */ + ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + if (collada_export(CTX_data_scene(C), filename, selected, second_life)) { return OPERATOR_FINISHED; } From af1720bc77532b2eea999ccd4aa8dfeff69efb62 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 3 May 2012 01:07:16 +0000 Subject: [PATCH 09/88] ED_object_exit_editmode needs ED_object.h --- source/blender/windowmanager/intern/wm_operators.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6fab4ff45e1..cc4cf030988 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -84,6 +84,7 @@ #include "ED_screen.h" #include "ED_util.h" +#include "ED_object.h" #include "RNA_access.h" #include "RNA_define.h" From 2a6217859e818fb9a791ed066ef05cf6f9cb02b2 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 3 May 2012 03:51:30 +0000 Subject: [PATCH 10/88] Patch [#30255] Center Last Stroke Enables the NUMPERIOD view centering operator to work in sculpt mode. Hitting NUMPERIOD while in sculpt mode will center the view on the end of the last sculpting stroke made by the user. This is useful for quickly refocusing on the current work area without fussing with the view controls. It does not zoom into the stroke (slide only). It does nothing if there have been no strokes. --- source/blender/blenkernel/BKE_paint.h | 4 +++ source/blender/editors/include/ED_sculpt.h | 2 ++ source/blender/editors/sculpt_paint/sculpt.c | 25 +++++++++++++ .../editors/space_view3d/view3d_edit.c | 35 ++++++++++++------- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index acf39d83370..bd31a62abf9 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -103,6 +103,10 @@ typedef struct SculptSession { struct SculptStroke *stroke; struct StrokeCache *cache; + + /* last paint/sculpt stroke location */ + int last_stroke_valid; + float last_stroke[3]; } SculptSession; void free_sculptsession(struct Object *ob); diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index 9cb32c31f5b..2df699255be 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -42,6 +42,8 @@ void ED_operatortypes_sculpt(void); void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob); void ED_sculpt_force_update(struct bContext *C); +float *ED_sculpt_get_last_stroke(struct Object *ob); +int ED_sculpt_minmax(struct bContext *C, float *min, float *max); /* paint_ops.c */ void ED_operatortypes_paint(void); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 8d2dfc8dbfa..51fe73bb527 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -101,6 +101,26 @@ void ED_sculpt_force_update(bContext *C) multires_force_update(ob); } +float *ED_sculpt_get_last_stroke(struct Object *ob) +{ + return (ob && ob->sculpt && ob->sculpt->last_stroke_valid) ? ob->sculpt->last_stroke : NULL; +} + +int ED_sculpt_minmax(bContext *C, float *min, float *max) +{ + Object *ob= CTX_data_active_object(C); + + if (ob && ob->sculpt && ob->sculpt->last_stroke_valid) { + copy_v3_v3(min, ob->sculpt->last_stroke); + copy_v3_v3(max, ob->sculpt->last_stroke); + + return 1; + } + else { + return 0; + } +} + /* Sculpt mode handles multires differently from regular meshes, but only if * it's the last modifier on the stack and it is not on the first level */ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) @@ -3482,6 +3502,11 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) } } + /* update last stroke position */ + ob->sculpt->last_stroke_valid= 1; + copy_v3_v3(ob->sculpt->last_stroke, ss->cache->true_location); + mul_m4_v3(ob->obmat, ob->sculpt->last_stroke); + sculpt_cache_free(ss->cache); ss->cache = NULL; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 2f66fdf8cd4..44fee7d663d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -73,6 +73,7 @@ #include "ED_transform.h" #include "ED_mesh.h" #include "ED_view3d.h" +#include "ED_sculpt.h" #include "PIL_time.h" /* smoothview */ @@ -2199,6 +2200,10 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) { ok = PE_minmax(scene, min, max); } + else if (ob && (ob->mode & OB_MODE_SCULPT)) { + ok = ED_sculpt_minmax(C, min, max); + ok_dist = 0; /* don't zoom */ + } else { Base *base; for (base = FIRSTBASE; base; base = base->next) { @@ -2222,18 +2227,24 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) sub_v3_v3v3(afm, max, min); size = MAX3(afm[0], afm[1], afm[2]); - if (!rv3d->is_persp) { - if (size < 0.0001f) { /* if its a sinble point. don't even re-scale */ - ok_dist = 0; + if (ok_dist) { + /* fix up zoom distance if needed */ + + if (rv3d->is_persp) { + if (size <= v3d->near * 1.5f) { + /* do not zoom closer than the near clipping plane */ + size = v3d->near * 1.5f; + } } - else { - /* perspective should be a bit farther away to look nice */ - size *= 0.7f; - } - } - else { - if (size <= v3d->near * 1.5f) { - size = v3d->near * 1.5f; + else /* ortho */ { + if (size < 0.0001f) { + /* bounding box was a single point so do not zoom */ + ok_dist = 0; + } + else { + /* adjust zoom so it looks nicer */ + size *= 0.7f; + } } } @@ -2251,7 +2262,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) { rv3d->persp = RV3D_PERSP; - smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); } else { smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); From 90b0be522c2145d642d77ebfc8f852bd93d2a720 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 3 May 2012 04:11:53 +0000 Subject: [PATCH 11/88] Patch [#30965] Cancel Sculpt Stroke w/ ESCAPE If the RMB has not been released after starting a sculpt stroke, then hitting escape will cancel the stroke in progress and undo any changes to the mesh. This is a slightly faster work-flow than using undo, is a feature available in other paint programs, and also puts in place the infrastructure to add other keys later that could tweak strokes in different ways. --- .../editors/sculpt_paint/paint_intern.h | 3 +- .../blender/editors/sculpt_paint/paint_ops.c | 3 + .../editors/sculpt_paint/paint_stroke.c | 86 +++++++++++++----- .../editors/sculpt_paint/paint_vertex.c | 4 +- source/blender/editors/sculpt_paint/sculpt.c | 90 +++++++++++-------- 5 files changed, 121 insertions(+), 65 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 200fd8e65c7..267dc043676 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -58,10 +58,11 @@ typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, StrokeDone done, int event_type); -void paint_stroke_free(struct PaintStroke *stroke); +void paint_stroke_data_free(struct wmOperator *op); int paint_space_stroke_enabled(struct Brush *br); +struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf); int paint_stroke_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int paint_stroke_exec(struct bContext *C, struct wmOperator *op); int paint_stroke_cancel(struct bContext *C, struct wmOperator *op); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 6860b551556..e218cfe8fd2 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -712,4 +712,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_uv_sculpt_tool_set", PKEY, KM_PRESS, 0, 0)->ptr, "tool", UV_SCULPT_TOOL_PINCH); RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_uv_sculpt_tool_set", GKEY, KM_PRESS, 0, 0)->ptr, "tool", UV_SCULPT_TOOL_GRAB); + /* paint stroke */ + keymap = paint_stroke_modal_keymap(keyconf); + WM_modalkeymap_assign(keymap, "SCULPT_OT_brush_stroke"); } diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 448fb37ef54..010278e8621 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -276,9 +276,30 @@ PaintStroke *paint_stroke_new(bContext *C, return stroke; } -void paint_stroke_free(PaintStroke *stroke) +void paint_stroke_data_free(struct wmOperator *op) { - MEM_freeN(stroke); + MEM_freeN(op->customdata); + op->customdata= NULL; +} + +static void stroke_done(struct bContext *C, struct wmOperator *op) +{ + struct PaintStroke *stroke = op->customdata; + + if (stroke->stroke_started && stroke->done) + stroke->done(C, stroke); + + if (stroke->timer) { + WM_event_remove_timer( + CTX_wm_manager(C), + CTX_wm_window(C), + stroke->timer); + } + + if (stroke->smooth_stroke_cursor) + WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); + + paint_stroke_data_free(op); } /* Returns zero if the stroke dots should not be spaced, non-zero otherwise */ @@ -289,6 +310,35 @@ int paint_space_stroke_enabled(Brush *br) !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK); } +#define PAINT_STROKE_MODAL_CANCEL 1 + +/* called in paint_ops.c, on each regeneration of keymaps */ +struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf) +{ + static struct EnumPropertyItem modal_items[] = { + {PAINT_STROKE_MODAL_CANCEL, "CANCEL", 0, + "Cancel", + "Cancel and undo a stroke in progress"}, + + { 0 } + }; + + static const char *name= "Paint Stroke Modal"; + + struct wmKeyMap *keymap= WM_modalkeymap_get(keyconf, name); + + /* this function is called for each spacetype, only needs to add map once */ + if (!keymap) { + keymap= WM_modalkeymap_add(keyconf, name, modal_items); + + /* items for modal map */ + WM_modalkeymap_add_item( + keymap, ESCKEY, KM_PRESS, KM_ANY, 0, PAINT_STROKE_MODAL_CANCEL); + } + + return keymap; +} + int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) { PaintStroke *stroke = op->customdata; @@ -319,16 +369,16 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) //ED_region_tag_redraw(ar); } + /* Cancel */ + if (event->type == EVT_MODAL_MAP && event->val == PAINT_STROKE_MODAL_CANCEL) { + if (op->type->cancel) + return op->type->cancel(C, op); + else + return paint_stroke_cancel(C, op); + } + if (event->type == stroke->event_type && event->val == KM_RELEASE) { - /* exit stroke, free data */ - if (stroke->smooth_stroke_cursor) - WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); - - if (stroke->timer) - WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer); - - stroke->done(C, stroke); - MEM_freeN(stroke); + stroke_done(C, op); return OPERATOR_FINISHED; } else if ((first) || @@ -383,24 +433,14 @@ int paint_stroke_exec(bContext *C, wmOperator *op) } RNA_END; - stroke->done(C, stroke); - - MEM_freeN(stroke); - op->customdata = NULL; + stroke_done(C, op); return OPERATOR_FINISHED; } int paint_stroke_cancel(bContext *C, wmOperator *op) { - PaintStroke *stroke = op->customdata; - - if (stroke->done) - stroke->done(C, stroke); - - MEM_freeN(stroke); - op->customdata = NULL; - + stroke_done(C, op); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 18ddc965976..9c89eb7c573 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2421,7 +2421,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P ED_region_tag_redraw(vc->ar); } -static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) +static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) { ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = CTX_data_active_object(C); @@ -2945,7 +2945,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } } -static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke) +static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) { ToolSettings *ts = CTX_data_tool_settings(C); struct VPaintData *vpd = paint_stroke_mode_data(stroke); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 51fe73bb527..ca9bb51aaef 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -264,6 +264,50 @@ typedef struct StrokeCache { rcti previous_r; /* previous redraw rectangle */ } StrokeCache; + +/*** paint mesh ***/ + +static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss) +{ + StrokeCache *cache = ss->cache; + int i; + + PBVHNode **nodes; + int n, totnode; + + BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); + + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + SculptUndoNode *unode; + + unode = sculpt_undo_get_node(nodes[n]); + if (unode) { + PBVHVertexIter vd; + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + copy_v3_v3(vd.co, unode->co[vd.i]); + if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); + else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); + + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + BLI_pbvh_vertex_iter_end; + + BLI_pbvh_node_mark_update(nodes[n]); + } + } + + if (ss->face_normals) { + float *fn = ss->face_normals; + for (i = 0; i < ss->totpoly; ++i, fn += 3) + copy_v3_v3(fn, cache->face_norms[i]); + } + + if (nodes) + MEM_freeN(nodes); +} + /*** BVH Tree ***/ /* Get a screen-space rectangle of the modified area */ @@ -3193,7 +3237,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, sd->special_rotation = cache->special_rotation; } -static void sculpt_stroke_modifiers_check(bContext *C, Object *ob) +static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob) { SculptSession *ss = ob->sculpt; @@ -3329,43 +3373,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) brush_use_size_pressure(ss->cache->vc->scene, brush)) || (brush->flag & BRUSH_RESTORE_MESH)) { - StrokeCache *cache = ss->cache; - int i; - - PBVHNode **nodes; - int n, totnode; - - BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); - - #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for (n = 0; n < totnode; n++) { - SculptUndoNode *unode; - - unode = sculpt_undo_get_node(nodes[n]); - if (unode) { - PBVHVertexIter vd; - - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - copy_v3_v3(vd.co, unode->co[vd.i]); - if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); - else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); - - if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; - } - BLI_pbvh_vertex_iter_end; - - BLI_pbvh_node_mark_update(nodes[n]); - } - } - - if (ss->face_normals) { - float *fn = ss->face_normals; - for (i = 0; i < ss->totpoly; ++i, fn += 3) - copy_v3_v3(fn, cache->face_norms[i]); - } - - if (nodes) - MEM_freeN(nodes); + paint_mesh_restore_co(sd, ss); } } @@ -3551,7 +3559,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even "ignore_background_click"); if (ignore_background_click && !over_mesh(C, op, event->x, event->y)) { - paint_stroke_free(stroke); + paint_stroke_data_free(op); return OPERATOR_PASS_THROUGH; } @@ -3583,6 +3591,10 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + if (ss->cache) { + paint_mesh_restore_co(sd, ss); + } + paint_stroke_cancel(C, op); if (ss->cache) { From aecddee333bd7763c091e4fec75d5d0889c0f0d0 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 3 May 2012 05:39:30 +0000 Subject: [PATCH 12/88] Grr! Fix for own error in r46193. --- source/blender/nodes/composite/nodes/node_composite_blur.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index 5675acbe084..77b62938d94 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -609,7 +609,6 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN new = pass_on_compbuf(img); } else { - CompBuf *new, *img = in[0]->data; // TODO: can this be mapped with reference, too? const float sx = ((float)nbd->sizex*in[1]->vec[0])/2.0f, sy = ((float)nbd->sizey*in[1]->vec[0])/2.0f; int c; From d3a5fd55089cf76bcec8d8512566046b9d72b659 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 3 May 2012 06:57:30 +0000 Subject: [PATCH 13/88] Enum property items were missing a terminator item. --- source/blender/editors/space_node/node_edit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 4bbba419613..68bebde030f 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -3713,7 +3713,8 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) { static EnumPropertyItem direction_items[] = { {1, "UP", 0, "Up", ""}, - {2, "DOWN", 0, "Down", ""}}; + {2, "DOWN", 0, "Down", ""}, + { 0, NULL, 0, NULL, NULL }}; /* identifiers */ ot->name = "Move File Node Socket"; From dcdf768147d81551864cbc415dfd69176a3fc173 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 09:31:59 +0000 Subject: [PATCH 14/88] Fix #31108: entering local view with glsl shows objects black. Now keeps lamps affecting the material even if they are not part of the local view. --- source/blender/gpu/intern/gpu_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 09ed3c6f5fb..1c1cf8017f6 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1087,7 +1087,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O GMS.gob = ob; GMS.gscene = scene; GMS.totmat= ob->totcol+1; /* materials start from 1, default material is 0 */ - GMS.glay= v3d->lay; + GMS.glay= (v3d->localvd)? v3d->localvd->lay: v3d->lay; /* keep lamps visible in local view */ GMS.gviewmat= rv3d->viewmat; GMS.gviewinv= rv3d->viewinv; From 949de4688d0626578ac4f0521117a0582de5de9b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 09:51:12 +0000 Subject: [PATCH 15/88] Fix #31257: tiff reader not reading 16 bit grayscale images correctly. --- source/blender/imbuf/intern/tiff.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 2fd259d2816..2a7ba2cae26 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -317,8 +317,8 @@ static void scanline_contig_16bit(float *rectf, unsigned short *sbuf, int scanli int i; for (i=0; i < scanline_w; i++) { rectf[i*4 + 0] = sbuf[i*spp + 0] / 65535.0; - rectf[i*4 + 1] = sbuf[i*spp + 1] / 65535.0; - rectf[i*4 + 2] = sbuf[i*spp + 2] / 65535.0; + rectf[i*4 + 1] = (spp>=3)? sbuf[i*spp + 1] / 65535.0: sbuf[i*spp + 0] / 65535.0; + rectf[i*4 + 2] = (spp>=3)? sbuf[i*spp + 2] / 65535.0: sbuf[i*spp + 0] / 65535.0; rectf[i*4 + 3] = (spp==4)?(sbuf[i*spp + 3] / 65535.0):1.0; } } @@ -328,8 +328,8 @@ static void scanline_contig_32bit(float *rectf, float *fbuf, int scanline_w, int int i; for (i=0; i < scanline_w; i++) { rectf[i*4 + 0] = fbuf[i*spp + 0]; - rectf[i*4 + 1] = fbuf[i*spp + 1]; - rectf[i*4 + 2] = fbuf[i*spp + 2]; + rectf[i*4 + 1] = (spp>=3)? fbuf[i*spp + 1]: fbuf[i*spp + 0]; + rectf[i*4 + 2] = (spp>=3)? fbuf[i*spp + 2]: fbuf[i*spp + 0]; rectf[i*4 + 3] = (spp==4)?fbuf[i*spp + 3]:1.0f; } } @@ -437,6 +437,8 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) if (bitspersample == 32) { if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */ fill_vn_fl(fbuf, ibuf->x, 1.0f); + else if (chan >= spp) /* for grayscale, duplicate first channel into G and B */ + success |= TIFFReadScanline(image, fbuf, row, 0); else success |= TIFFReadScanline(image, fbuf, row, chan); scanline_separate_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, chan); @@ -445,6 +447,8 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) else if (bitspersample == 16) { if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */ fill_vn_ushort(sbuf, ibuf->x, 65535); + else if (chan >= spp) /* for grayscale, duplicate first channel into G and B */ + success |= TIFFReadScanline(image, fbuf, row, 0); else success |= TIFFReadScanline(image, sbuf, row, chan); scanline_separate_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, chan); From 3ee4be913bbf475ae7ae3af0df7e47568efbadbe Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 10:14:08 +0000 Subject: [PATCH 16/88] Fix #31139: fractal mesh subdivide was only working along normal where previously it would displace in all directions. Now there's an operator option to control this. --- source/blender/bmesh/intern/bmesh_opdefines.c | 1 + source/blender/bmesh/intern/bmesh_operators.h | 2 +- .../blender/bmesh/operators/bmo_subdivide.c | 29 ++++++++++--------- .../blender/bmesh/operators/bmo_subdivide.h | 1 + .../blender/editors/mesh/editmesh_loopcut.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 4 ++- 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 2ff28aee191..b5e6d7e1f68 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -696,6 +696,7 @@ static BMOpDefine bmo_esubd_def = { {{BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {BMO_OP_SLOT_FLT, "smooth"}, {BMO_OP_SLOT_FLT, "fractal"}, + {BMO_OP_SLOT_FLT, "along_normal"}, {BMO_OP_SLOT_INT, "numcuts"}, {BMO_OP_SLOT_INT, "seed"}, {BMO_OP_SLOT_MAPPING, "custompatterns"}, diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index f4db13e2777..b0a647b7009 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -98,7 +98,7 @@ extern int bmesh_total_ops; struct Object; void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, - float smooth, float fractal, + float smooth, float fractal, float along_normal, int numcuts, int seltype, int cornertype, const short use_singleedge, const short use_gridfill, diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index d96d0f6c74d..736ce3bc033 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -141,23 +141,24 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar if (params->use_fractal) { float len = len_v3v3(vsta->co, vend->co); - float vec2[3] = {0.0f, 0.0f, 0.0f}, co2[3]; + float normal[3] = {0.0f, 0.0f, 0.0f}, co2[3], base1[3], base2[3]; fac = params->fractal * len; - add_v3_v3(vec2, vsta->no); - add_v3_v3(vec2, vend->no); - mul_v3_fl(vec2, 0.5f); + mid_v3_v3v3(normal, vsta->no, vend->no); + ortho_basis_v3v3_v3(base1, base2, normal); add_v3_v3v3(co2, v->co, params->off); - tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f); - tvec[1] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f); - tvec[2] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f); + mul_v3_fl(co2, 10.0f); - mul_v3_v3(vec2, tvec); + tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 2) - 0.5f); + tvec[1] = fac * (BLI_gTurbulence(1.0, co2[1], co2[0], co2[2], 15, 0, 2) - 0.5f); + tvec[2] = fac * (BLI_gTurbulence(1.0, co2[1], co2[2], co2[0], 15, 0, 2) - 0.5f); /* add displacement */ - add_v3_v3v3(co, co, vec2); + madd_v3_v3fl(co, normal, tvec[0]); + madd_v3_v3fl(co, base1, tvec[1] * (1.0f - params->along_normal)); + madd_v3_v3fl(co, base2, tvec[2] * (1.0f - params->along_normal)); } /* apply the new difference to the rest of the shape keys, @@ -687,7 +688,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) BLI_array_declare(facedata); BLI_array_declare(edges); BLI_array_declare(verts); - float smooth, fractal; + float smooth, fractal, along_normal; int use_sphere, cornertype, use_singleedge, use_gridfill; int skey, seed, i, j, matched, a, b, numcuts, totesel; @@ -697,6 +698,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) seed = BMO_slot_int_get(op, "seed"); smooth = BMO_slot_float_get(op, "smooth"); fractal = BMO_slot_float_get(op, "fractal"); + along_normal = BMO_slot_float_get(op, "along_normal"); cornertype = BMO_slot_int_get(op, "quadcornertype"); use_singleedge = BMO_slot_bool_get(op, "use_singleedge"); @@ -754,6 +756,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) params.smooth = smooth; params.seed = seed; params.fractal = fractal; + params.along_normal = along_normal; params.use_smooth = (smooth != 0.0f); params.use_fractal = (fractal != 0.0f); params.use_sphere = use_sphere; @@ -1025,7 +1028,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) /* editmesh-emulating function */ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, - float smooth, float fractal, + float smooth, float fractal, float along_normal, int numcuts, int seltype, int cornertype, const short use_singleedge, const short use_gridfill, @@ -1036,13 +1039,13 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag, /* use_sphere isnt exposed here since its only used for new primitives */ BMO_op_initf(bm, &op, "esubd edges=%he " - "smooth=%f fractal=%f " + "smooth=%f fractal=%f along_normal=%f " "numcuts=%i " "quadcornertype=%i " "use_singleedge=%b use_gridfill=%b " "seed=%i", edge_hflag, - smooth, fractal, + smooth, fractal, along_normal, numcuts, cornertype, use_singleedge, use_gridfill, diff --git a/source/blender/bmesh/operators/bmo_subdivide.h b/source/blender/bmesh/operators/bmo_subdivide.h index cc6ced8bfaa..d4b926b9275 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.h +++ b/source/blender/bmesh/operators/bmo_subdivide.h @@ -31,6 +31,7 @@ typedef struct SubDParams { int numcuts; float smooth; float fractal; + float along_normal; //int beauty; short use_smooth; short use_sphere; diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index beb5345ca9b..0b65cce20d7 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -314,7 +314,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) if (lcd->do_cut) { BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, - 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, cuts, SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, FALSE, 0); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 92f4d6f01d5..c6b899bfd37 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -87,6 +87,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) int cuts = RNA_int_get(op->ptr, "number_cuts"); float smooth = 0.292f * RNA_float_get(op->ptr, "smoothness"); float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f; + float along_normal = RNA_float_get(op->ptr, "fractal_along_normal"); if (RNA_boolean_get(op->ptr, "quadtri") && RNA_enum_get(op->ptr, "quadcorner") == SUBD_STRAIGHT_CUT) @@ -95,7 +96,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) } BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, - smooth, fractal, + smooth, fractal, along_normal, cuts, SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"), RNA_boolean_get(op->ptr, "quadtri"), TRUE, @@ -143,6 +144,7 @@ void MESH_OT_subdivide(wmOperatorType *ot) "Quad Corner Type", "How to subdivide quad corners (anything other than Straight Cut will prevent ngons)"); RNA_def_float(ot->srna, "fractal", 0.0f, 0.0f, FLT_MAX, "Fractal", "Fractal randomness factor", 0.0f, 1000.0f); + RNA_def_float(ot->srna, "fractal_along_normal", 0.0f, 0.0f, 1.0f, "Along Normal", "Apply fractal displacement along normal only", 0.0f, 1.0f); RNA_def_int(ot->srna, "seed", 0, 0, 10000, "Random Seed", "Seed for the random number generator", 0, 50); } From 56d22457e320df0bdcdcfd8d7af5e1958ddb201f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 10:40:04 +0000 Subject: [PATCH 17/88] Fix #31266: Track preview is shifted by half a pixel --- source/blender/editors/interface/interface_draw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 91d3c890df3..d90d8286db9 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1469,8 +1469,11 @@ static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width ImBuf *scaleibuf; const float scalex = ((float)ibuf->x - 2 * margin) / width; const float scaley = ((float)ibuf->y - 2 * margin) / height; - float off_x = (int)track_pos[0] - track_pos[0] + 0.5f; - float off_y = (int)track_pos[1] - track_pos[1] + 0.5f; + /* NOTE: 1.0f = 0.5f for integer coordinate coorrection (center of pixel vs. left bottom corner of bixel) + * and 0.5f for centering image in preview (cross is draving at exact center of widget so image + * should be shifted by half of pixel for correct centering) - sergey */ + float off_x = (int)track_pos[0] - track_pos[0] + 1.0f; + float off_y = (int)track_pos[1] - track_pos[1] + 1.0f; int x, y; scaleibuf = IMB_allocImBuf(width, height, 32, IB_rect); From 3509daa1c1910bf1b2ce8fcbee2e5644b2b3d607 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 3 May 2012 10:56:35 +0000 Subject: [PATCH 18/88] Fix #31178, the cause is hidden and selected faces would return NULL as UVElements. To avoid checking the whole contingency of UV synch selection + face selection + face hidden, added a NULL check. --- source/blender/editors/uvedit/uvedit_smart_stitch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 183f75c6b42..9474ae95c34 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1179,13 +1179,13 @@ static int stitch_init(bContext *C, wmOperator *op) } else { BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - i = 0; - BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { + BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { if (uvedit_uv_select_test(em, scene, l)) { UvElement *element = ED_uv_element_get(state->element_map, efa, l); - stitch_select_uv(element, state, 1); + if (element) { + stitch_select_uv(element, state, 1); + } } - i++; } } } From eec8de9469a7da0d86832358678029c11e7452be Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 11:54:12 +0000 Subject: [PATCH 19/88] Fix #31254: OpenGL-Rendering dark without Effect-Strip Issue was caused by the fact, that sequencer is working in sRGB space, but when there's only image input strips we need to make sure conversion from byte to float buffer would keep float buffer in sRGB space and wouldn't make it linear as it's supposed to be in other areas. --- source/blender/editors/render/render_opengl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index a46e3c69456..cfc7ba0537f 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -146,6 +146,13 @@ static void screen_opengl_render_apply(OGLRender *oglrender) BLI_assert((oglrender->sizex == ibuf->x) && (oglrender->sizey == ibuf->y)); if (ibuf->rect_float == NULL) { + /* internally sequencer working in sRGB space and stores both bytes and float + * buffers in sRGB space, but if byte->float onversion doesn't happen in sequencer + * (e.g. when adding image sequence/movie into sequencer) there'll be only + * byte buffer and profile will still indicate sRGB->linear space conversion is needed + * here we're ensure there'll be no conversion happen and float buffer would store + * linear frame (sergey) */ + ibuf->profile = IB_PROFILE_NONE; IMB_float_from_rect(ibuf); } From d10da0fbd2a3edc4a35bd6695d1caa234f4e78f0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 12:55:18 +0000 Subject: [PATCH 20/88] Fix #31272: Blender Crashes when press render Issue was caused by missed libraries. Seems compositor nodes already does check in such cases, added the same check to texture and shader nodes. --- source/blender/nodes/shader/nodes/node_shader_common.c | 3 +++ source/blender/nodes/texture/nodes/node_texture_common.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index f75cecfe83b..bd31f20b18c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -73,6 +73,9 @@ static void *group_initexec(bNode *node) bNodeTree *ngroup= (bNodeTree*)node->id; bNodeTreeExec *exec; + if (!ngroup) + return NULL; + /* initialize the internal node tree execution */ exec = ntreeShaderBeginExecTree(ngroup, 0); diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index 9a66ecb5ffb..2a9107f9498 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -58,6 +58,9 @@ static void *group_initexec(bNode *node) bNodeTree *ngroup= (bNodeTree*)node->id; void *exec; + if (!ngroup) + return NULL; + /* initialize the internal node tree execution */ exec = ntreeTexBeginExecTree(ngroup, 0); From 13e97f86d0c64f6ce18902e564761cd212214d28 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 13:56:15 +0000 Subject: [PATCH 21/88] Fix #31259: particle grid distribution not working. --- source/blender/blenkernel/intern/particle_system.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index daa7f847df6..a4d61cea3fb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1064,6 +1064,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D if (part->distr==PART_DISTR_GRID && from != PART_FROM_VERT) { BLI_srandom(31415926 + psys->seed); dm= CDDM_from_mesh((Mesh*)ob->data, ob); + DM_ensure_tessface(dm); distribute_grid(dm, psys); dm->release(dm); return 0; From 885c4a6e78326097d7e41eac4e73405001eac015 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 14:59:42 +0000 Subject: [PATCH 22/88] Fix #31273: videotexture ImageRender not working in blenderplayer. --- source/gameengine/GamePlayer/common/GPC_Canvas.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index eccfefedd4d..f4224b9e255 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -88,6 +88,12 @@ void GPC_Canvas::Resize(int width, int height) { m_width = width; m_height = height; + + // initialize area so that it's available for game logic on frame 1 (ImageViewport) + m_displayarea.m_x1 = 0; + m_displayarea.m_y1 = 0; + m_displayarea.m_x2 = width; + m_displayarea.m_y2 = height; } void GPC_Canvas::EndFrame() From 763dee290490126c164b2af9c742b8719b165459 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 16:24:27 +0000 Subject: [PATCH 23/88] Fix #31275: mesh draw issues after adding hook to mesh in edit mode. --- source/blender/editors/object/object_hook.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 0aec83610b8..2cfefa61a18 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -313,6 +313,9 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int * em = me->edit_btmesh; + EDBM_mesh_normals_update(em); + BMEdit_RecalcTessellation(em); + /* check selected vertices first */ if (return_editmesh_indexar(em, tot, indexar, cent_r)) { return 1; From 4965f3d022171ced97ad6aea7d90453ab2c56c96 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 16:35:51 +0000 Subject: [PATCH 24/88] Fix #31234: vertex normals not update after knife cut. --- source/blender/editors/mesh/editmesh_knife.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 6f33fcd05b7..2208d96ca46 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2684,6 +2684,7 @@ static void knifetool_finish(bContext *C, wmOperator *op) knife_make_cuts(kcd); #endif + EDBM_mesh_normals_update(kcd->em); EDBM_update_generic(C, kcd->em, TRUE); } From ca10d0d18703cd0eed5b5f2ce9efea1123c82148 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 17:00:08 +0000 Subject: [PATCH 25/88] Camera tracking: apparently one of tracking presets was never merged from tomato --- .../scripts/presets/tracking_settings/blurry_movie.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 release/scripts/presets/tracking_settings/blurry_movie.py diff --git a/release/scripts/presets/tracking_settings/blurry_movie.py b/release/scripts/presets/tracking_settings/blurry_movie.py new file mode 100644 index 00000000000..8a503bec9bd --- /dev/null +++ b/release/scripts/presets/tracking_settings/blurry_movie.py @@ -0,0 +1,11 @@ +import bpy +settings = bpy.context.edit_movieclip.tracking.settings + +settings.default_tracker = 'KLT' +settings.default_pyramid_levels = 4 +settings.default_correlation_min = 0.75 +settings.default_pattern_size = 11 +settings.default_search_size = 202 +settings.default_frames_limit = 25 +settings.default_pattern_match = 'KEYFRAME' +settings.default_margin = 0 From 96693d37e602d045a5b2c196a5a3b55174bae1cb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 17:02:33 +0000 Subject: [PATCH 26/88] Camera tracking: clear clipboard path before copying tracks to it. --- source/blender/blenkernel/intern/tracking.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 316cb4b6159..25c985b391a 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -688,6 +688,8 @@ void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingOb ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); MovieTrackingTrack *track = tracksbase->first; + BKE_tracking_free_clipboard(); + while (track) { if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) { MovieTrackingTrack *new_track = duplicate_track(track); From 5821c2973ec6a7cc6abc25ac75e85e84dc176411 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 17:52:34 +0000 Subject: [PATCH 27/88] Camera tracking: pre-calculate tracked segments for dopesheet channels --- source/blender/blenkernel/intern/tracking.c | 108 +++++++++++++++--- source/blender/blenloader/intern/readfile.c | 1 + source/blender/blenloader/intern/writefile.c | 1 + .../editors/space_clip/clip_dopesheet_draw.c | 54 +++------ source/blender/makesdna/DNA_tracking_types.h | 9 +- 5 files changed, 117 insertions(+), 56 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 25c985b391a..216e3b19672 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -634,7 +634,20 @@ static void tracking_objects_free(ListBase *objects) static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet) { + MovieTrackingDopesheetChannel *channel; + + channel = dopesheet->channels.first; + while (channel) { + if (channel->segments) { + MEM_freeN(channel->segments); + } + + channel = channel->next; + } + BLI_freelistN(&dopesheet->channels); + + dopesheet->channels.first = dopesheet->channels.last = NULL; dopesheet->tot_channel = 0; } @@ -3059,32 +3072,101 @@ static int channels_alpha_sort(void *a, void *b) return 0; } +static void channels_segments_calc(MovieTrackingDopesheetChannel *channel) +{ + MovieTrackingTrack *track = channel->track; + int i, segment; + + channel->tot_segment = 0; + channel->max_segment = 0; + channel->total_frames = 0; + + /* count */ + i = 0; + while (i < track->markersnr) { + MovieTrackingMarker *marker = &track->markers[i]; + + if ((marker->flag & MARKER_DISABLED) == 0) { + int prev_fra = marker->framenr, len = 0; + + i++; + while (i < track->markersnr) { + marker = &track->markers[i]; + + if (marker->framenr != prev_fra + 1) + break; + if (marker->flag & MARKER_DISABLED) + break; + + prev_fra = marker->framenr; + len++; + i++; + } + + channel->tot_segment++; + } + + i++; + } + + if (!channel->tot_segment) + return; + + channel->segments = MEM_callocN(2 * sizeof(int) * channel->tot_segment, "tracking channel segments"); + + /* create segments */ + i = 0; + segment = 0; + while (i < track->markersnr) { + MovieTrackingMarker *marker = &track->markers[i]; + + if ((marker->flag & MARKER_DISABLED) == 0) { + MovieTrackingMarker *start_marker = marker; + int prev_fra = marker->framenr, len = 0; + + i++; + while (i < track->markersnr) { + marker = &track->markers[i]; + + if (marker->framenr != prev_fra + 1) + break; + if (marker->flag & MARKER_DISABLED) + break; + + prev_fra = marker->framenr; + channel->total_frames++; + len++; + i++; + } + + channel->segments[2 * segment] = start_marker->framenr; + channel->segments[2 * segment + 1] = start_marker->framenr + len; + + channel->max_segment = MAX2(channel->max_segment, len); + segment++; + } + + i++; + } +} + void BKE_tracking_update_dopesheet(MovieTracking *tracking) { MovieTrackingObject *object = BKE_tracking_active_object(tracking); MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); - ListBase old_channels; - old_channels = dopesheet->channels; - dopesheet->channels.first = dopesheet->channels.last = NULL; - dopesheet->tot_channel = 0; + tracking_dopesheet_free(dopesheet); for (track = tracksbase->first; track; track = track->next) { if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) { - MovieTrackingDopesheetChannel *channel, *old_channel; + MovieTrackingDopesheetChannel *channel; channel = MEM_callocN(sizeof(MovieTrackingDopesheetChannel), "tracking dopesheet channel"); channel->track = track; - /* copy flags from current dopsheet information to new one */ - for (old_channel = old_channels.first; old_channel; old_channel = old_channel->next) { - if (old_channel->track == track) { - channel->flag = old_channel->flag; - break; - } - } + channels_segments_calc(channel); BLI_addtail(&dopesheet->channels, channel); dopesheet->tot_channel++; @@ -3092,6 +3174,4 @@ void BKE_tracking_update_dopesheet(MovieTracking *tracking) } BLI_sortlist(&dopesheet->channels, channels_alpha_sort); - - BLI_freelistN(&old_channels); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6c0ac651f13..afc4989f620 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6179,6 +6179,7 @@ static void direct_link_movieDopesheet(FileData *fd, MovieTrackingDopesheet *dop channel = dopesheet->channels.first; while (channel) { channel->track = newdataadr(fd, channel->track); + channel->segments = newdataadr(fd, channel->segments); channel = channel->next; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 7947d6f8f71..eb697aad17c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2686,6 +2686,7 @@ static void write_movieDopesheet(WriteData *wd, MovieTrackingDopesheet *dopeshee channel = dopesheet->channels.first; while (channel) { writestruct(wd, DATA, "MovieTrackingDopesheetChannel", 1, channel); + writedata(wd, DATA, 2 * channel->tot_segment, channel->segments); channel = channel->next; } diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index d1733cf322b..1814b253def 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -87,7 +87,7 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh {1.0f, 0.0f}, /* mid-right */ {0.0f, -1.0f}, /* bottom vert */ {-1.0f, 0.0f} /* mid-left */ - }; + }; static GLuint displist1 = 0; static GLuint displist2 = 0; int hsize = STRIP_HEIGHT_HALF; @@ -199,45 +199,19 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f; /* tracked segments */ - i = 0; - while (i < track->markersnr) { - MovieTrackingMarker *marker = &track->markers[i]; + for (i = 0; i < channel->tot_segment; i++) { + int start_frame = channel->segments[2 * i]; + int end_frame = channel->segments[2 * i + 1]; - if ((marker->flag & MARKER_DISABLED) == 0) { - MovieTrackingMarker *start_marker = marker; - int prev_fra = marker->framenr, len = 0; - - i++; - while (i < track->markersnr) { - marker = &track->markers[i]; - - if (marker->framenr != prev_fra + 1) - break; - if (marker->flag & MARKER_DISABLED) - break; - - prev_fra = marker->framenr; - len++; - i++; - } - - if (sel) - glColor4fv(selected_strip); - else - glColor4fv(strip); - - if (len) { - glRectf(start_marker->framenr, (float) y - STRIP_HEIGHT_HALF, - start_marker->framenr + len, (float) y + STRIP_HEIGHT_HALF); - draw_keyframe_shape(start_marker->framenr, y, xscale, yscale, sel, alpha); - draw_keyframe_shape(start_marker->framenr + len, y, xscale, yscale, sel, alpha); - } - else { - draw_keyframe_shape(start_marker->framenr, y, xscale, yscale, sel, alpha); - } + if (start_frame != end_frame) { + glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF, + end_frame, (float) y + STRIP_HEIGHT_HALF); + draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); + draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha); + } + else { + draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); } - - i++; } /* keyframes */ @@ -286,8 +260,8 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2); if (height > (v2d->mask.ymax - v2d->mask.ymin)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); } diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index e8abee36716..db1899ab31b 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -195,8 +195,13 @@ typedef struct MovieTrackingStats { typedef struct MovieTrackingDopesheetChannel { struct MovieTrackingDopesheetChannel *next, *prev; - MovieTrackingTrack *track; - int flag, pad; + + MovieTrackingTrack *track; /* motion track for which channel is created */ + int pad; + + int tot_segment; /* total number of segments */ + int *segments; /* tracked segments */ + int max_segment, total_frames; /* longest segment length and total number of tracked frames */ } MovieTrackingDopesheetChannel; typedef struct MovieTrackingDopesheet { From b1006fb949d5b437f7ab0514ee779ba24fcfc1f8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 19:28:41 +0000 Subject: [PATCH 28/88] Clip editor: sort order for dopesheet channels Supported sorting by name, longest tracked segment and total tracked frames. Internally tracks are stored in Tracking datablock, but sort order is a clip editor space property and sorting happens on clip editor draw. If there's no dopesheet opened with different sort orders it's not a problem due to re-sorting wouldn't happen. Also fixed draw issue of tracked segments introduced in previous commit. --- release/scripts/startup/bl_ui/space_clip.py | 5 ++ source/blender/blenkernel/BKE_tracking.h | 6 ++ source/blender/blenkernel/intern/tracking.c | 83 ++++++++++++++++++- source/blender/blenloader/intern/writefile.c | 2 +- .../editors/space_clip/clip_dopesheet_draw.c | 5 ++ .../blender/editors/space_clip/space_clip.c | 7 ++ source/blender/makesdna/DNA_space_types.h | 15 +++- source/blender/makesdna/DNA_tracking_types.h | 5 +- source/blender/makesrna/intern/rna_space.c | 21 +++++ 9 files changed, 144 insertions(+), 5 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index e2fa67e3873..f7ad69a046c 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -84,6 +84,11 @@ class CLIP_HT_header(Header): layout.label(text="Average solve error: %.4f" % (r.average_error)) + if sc.view == 'DOPESHEET': + layout.label(text="Sort by:") + layout.prop(sc, "dopesheet_sort_order", text="") + layout.prop(sc, "invert_dopesheet_sort", text="Invert") + layout.template_running_jobs() diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 3b1a5dbfc8a..1432dc151d0 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -166,6 +166,7 @@ void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area); /* Dopesheet */ void BKE_tracking_update_dopesheet(struct MovieTracking *tracking); +void BKE_tracking_dopesheet_sort(struct MovieTracking *tracking, int sort_order, int inverse); #define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT) @@ -197,4 +198,9 @@ void BKE_tracking_update_dopesheet(struct MovieTracking *tracking); #define TRACK_AREA_ALL (TRACK_AREA_POINT|TRACK_AREA_PAT|TRACK_AREA_SEARCH) +#define TRACK_SORT_NONE -1 +#define TRACK_SORT_NAME 0 +#define TRACK_SORT_LONGEST 1 +#define TRACK_SORT_TOTAL 2 + #endif diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 216e3b19672..bb4a7783c82 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -3072,6 +3072,52 @@ static int channels_alpha_sort(void *a, void *b) return 0; } +static int channels_total_track_sort(void *a, void *b) +{ + MovieTrackingDopesheetChannel *channel_a = a; + MovieTrackingDopesheetChannel *channel_b = b; + + if (channel_a->total_frames > channel_b->total_frames) + return 1; + else + return 0; +} + +static int channels_longest_segment_sort(void *a, void *b) +{ + MovieTrackingDopesheetChannel *channel_a = a; + MovieTrackingDopesheetChannel *channel_b = b; + + if (channel_a->max_segment > channel_b->max_segment) + return 1; + else + return 0; +} + +static int channels_alpha_inverse_sort(void *a, void *b) +{ + if (channels_alpha_sort(a, b)) + return 0; + else + return 1; +} + +static int channels_total_track_inverse_sort(void *a, void *b) +{ + if (channels_total_track_sort(a, b)) + return 0; + else + return 1; +} + +static int channels_longest_segment_inverse_sort(void *a, void *b) +{ + if (channels_longest_segment_sort(a, b)) + return 0; + else + return 1; +} + static void channels_segments_calc(MovieTrackingDopesheetChannel *channel) { MovieTrackingTrack *track = channel->track; @@ -3173,5 +3219,40 @@ void BKE_tracking_update_dopesheet(MovieTracking *tracking) } } - BLI_sortlist(&dopesheet->channels, channels_alpha_sort); + dopesheet->sort_order = TRACK_SORT_NONE; + dopesheet->sort_inverse = -1; +} + +void BKE_tracking_dopesheet_sort(MovieTracking *tracking, int sort_order, int inverse) +{ + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + + if (dopesheet->sort_order == sort_order && dopesheet->sort_inverse == inverse) + return; + + if (inverse) { + if (sort_order == TRACK_SORT_NAME) { + BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort); + } + else if (sort_order == TRACK_SORT_LONGEST) { + BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort); + } + else if (sort_order == TRACK_SORT_TOTAL) { + BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort); + } + } + else { + if (sort_order == TRACK_SORT_NAME) { + BLI_sortlist(&dopesheet->channels, channels_alpha_sort); + } + else if (sort_order == TRACK_SORT_LONGEST) { + BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort); + } + else if (sort_order == TRACK_SORT_TOTAL) { + BLI_sortlist(&dopesheet->channels, channels_total_track_sort); + } + } + + dopesheet->sort_order = sort_order; + dopesheet->sort_inverse = inverse; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index eb697aad17c..2199259a322 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2686,7 +2686,7 @@ static void write_movieDopesheet(WriteData *wd, MovieTrackingDopesheet *dopeshee channel = dopesheet->channels.first; while (channel) { writestruct(wd, DATA, "MovieTrackingDopesheetChannel", 1, channel); - writedata(wd, DATA, 2 * channel->tot_segment, channel->segments); + writedata(wd, DATA, 2 * channel->tot_segment * sizeof(int), channel->segments); channel = channel->next; } diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 1814b253def..574eb5b2570 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -203,6 +203,11 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) int start_frame = channel->segments[2 * i]; int end_frame = channel->segments[2 * i + 1]; + if (sel) + glColor4fv(selected_strip); + else + glColor4fv(strip); + if (start_frame != end_frame) { glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF, end_frame, (float) y + STRIP_HEIGHT_HALF); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4543876ffe5..82f76efacaa 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1129,11 +1129,14 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; short unit = 0; + BKE_tracking_dopesheet_sort(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); @@ -1186,9 +1189,13 @@ static void clip_channels_area_init(wmWindowManager *wm, ARegion *ar) static void clip_channels_area_draw(const bContext *C, ARegion *ar) { + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); View2D *v2d = &ar->v2d; View2DScrollers *scrollers; + BKE_tracking_dopesheet_sort(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index c2fbc611bc3..0bc91907d6e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -523,6 +523,12 @@ typedef struct SpaceClip { int postproc_flag, pad2; void *draw_context; + + /* dopesheet */ + short dope_sort; /* sort order in dopesheet view */ + short dope_flag; /* dopsheet view flags */ + + int pad3; } SpaceClip; /* view3d Now in DNA_view3d_types.h */ @@ -916,8 +922,13 @@ enum { #define SC_VIEW_GRAPH 1 #define SC_VIEW_DOPESHEET 2 -/* SpaceClip->runtime_flag */ -#define SC_GRAPH_BOTTOM (1<<0) +/* SpaceClip->dope_sort */ +#define SC_DOPE_SORT_NAME 0 +#define SC_DOPE_SORT_LONGEST 1 +#define SC_DOPE_SORT_TOTAL 2 + +/* SpaceClip->dope_flag */ +#define SC_DOPE_SORT_INVERSE 1 /* space types, moved from DNA_screen_types.h */ /* Do NOT change order, append on end. types are hardcoded needed */ diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index db1899ab31b..4e2b3c46aa4 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -206,7 +206,10 @@ typedef struct MovieTrackingDopesheetChannel { typedef struct MovieTrackingDopesheet { ListBase channels; - int tot_channel, pad; + int tot_channel; + + short sort_order; /* order in which tracks are stored */ + short sort_inverse; /* order of tracks is inverted */ } MovieTrackingDopesheet; typedef struct MovieTracking { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 47bad8f31e5..bc2e1b7e1f3 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2934,6 +2934,12 @@ static void rna_def_space_clip(BlenderRNA *brna) {SC_VIEW_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dopesheet", "Dopesheet view for tracking data"}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem dope_sort_items[] = { + {SC_DOPE_SORT_NAME, "NAME", 0, "Name", "Sort channels by their names"}, + {SC_DOPE_SORT_LONGEST, "LONGEST", 0, "Longest", "Sort channels by longest tracked segment"}, + {SC_DOPE_SORT_TOTAL, "TOTAL", 0, "Total", "Sort channels by overall amount of tracked segments"}, + {0, NULL, 0, NULL, NULL}}; + srna = RNA_def_struct(brna, "SpaceClipEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceClip"); RNA_def_struct_ui_text(srna, "Space Clip Editor", "Clip editor space data"); @@ -3112,6 +3118,21 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_SECONDS); RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL); + + /* ** dopesheet ** */ + + /* dopesheet sort */ + prop = RNA_def_property(srna, "dopesheet_sort_order", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "dope_sort"); + RNA_def_property_enum_items(prop, dope_sort_items); + RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Field used to sort channels in dopesheet view"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); + + /* invert_dopesheet_sort */ + prop = RNA_def_property(srna, "invert_dopesheet_sort", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dope_flag", SC_DOPE_SORT_INVERSE); + RNA_def_property_ui_text(prop, "Invert Dopesheet Sort", "Invert sort order of dopesheet channels"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); } From dfb3e41cf91cce23a1d42efbfc2846de2db10000 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 May 2012 19:47:16 +0000 Subject: [PATCH 29/88] code cleanup: minor changes to get trunk compiling with strict warnings. --- source/blender/editors/sculpt_paint/paint_intern.h | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 267dc043676..65fb65c1553 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -53,7 +53,7 @@ struct wmOperatorType; typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], float mouse[2]); typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, struct wmEvent *event); typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr); -typedef void (*StrokeDone)(struct bContext *C, struct PaintStroke *stroke); +typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index ca9bb51aaef..509cde16e3e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -267,7 +267,7 @@ typedef struct StrokeCache { /*** paint mesh ***/ -static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss) +static void paint_mesh_restore_co(SculptSession *ss) { StrokeCache *cache = ss->cache; int i; @@ -3373,7 +3373,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) brush_use_size_pressure(ss->cache->vc->scene, brush)) || (brush->flag & BRUSH_RESTORE_MESH)) { - paint_mesh_restore_co(sd, ss); + paint_mesh_restore_co(ss); } } @@ -3483,7 +3483,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd) ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1); } -static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) +static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke)) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -3592,7 +3592,7 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) Sculpt *sd = CTX_data_tool_settings(C)->sculpt; if (ss->cache) { - paint_mesh_restore_co(sd, ss); + paint_mesh_restore_co(ss); } paint_stroke_cancel(C, op); From 2a1ba8c85bd21d0eac3d348b162347da3b2171e2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 May 2012 19:57:24 +0000 Subject: [PATCH 30/88] style cleanup: formatting and some float/double promotion --- source/blender/bmesh/intern/bmesh_construct.c | 2 +- source/blender/bmesh/intern/bmesh_interp.c | 35 +++++++------------ source/blender/bmesh/intern/bmesh_mesh.c | 12 ++++--- .../bmesh/intern/bmesh_mesh_validate.c | 6 ++-- source/blender/bmesh/intern/bmesh_mods.c | 2 +- source/blender/bmesh/intern/bmesh_operators.c | 6 ++-- source/blender/bmesh/intern/bmesh_queries.c | 2 +- source/blender/bmesh/operators/bmo_bevel.c | 18 +++++----- source/blender/bmesh/operators/bmo_create.c | 2 +- source/blender/bmesh/operators/bmo_extrude.c | 2 +- source/blender/bmesh/operators/bmo_hull.c | 4 +-- source/blender/bmesh/operators/bmo_inset.c | 3 +- .../bmesh/operators/bmo_removedoubles.c | 2 +- .../blender/bmesh/operators/bmo_subdivide.c | 6 ++-- .../blender/bmesh/operators/bmo_triangulate.c | 10 +++--- .../blender/bmesh/operators/bmo_wireframe.c | 12 +++---- source/blender/bmesh/tools/BME_bevel.c | 30 +++++++++------- 17 files changed, 79 insertions(+), 75 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index c2d5d93cbc3..0169caa8f61 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -384,7 +384,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n /* more of a weight then a distance */ far_cross_dist = (/* first we want to have a value close to zero mapped to 1 */ - 1.0 - fabsf(dot_v3v3(far_vec, far_cross_vec)) * + 1.0f - fabsf(dot_v3v3(far_vec, far_cross_vec)) * /* second we multiply by the distance * so points close to the center are not preferred */ diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index c774880332b..f64b55193c5 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -78,7 +78,7 @@ void BM_data_interp_from_verts(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, con src[0] = v1->head.data; src[1] = v2->head.data; - w[0] = 1.0f-fac; + w[0] = 1.0f - fac; w[1] = fac; CustomData_bmesh_interp(&bm->vdata, src, w, NULL, 2, v->head.data); } @@ -198,20 +198,11 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source) static int compute_mdisp_quad(BMLoop *l, float v1[3], float v2[3], float v3[3], float v4[3], float e1[3], float e2[3]) { - float cent[3] = {0.0f, 0.0f, 0.0f}, n[3], p[3]; - BMLoop *l_first; - BMLoop *l_iter; - + float cent[3], n[3], p[3]; + /* computer center */ - l_iter = l_first = BM_FACE_FIRST_LOOP(l->f); - do { - cent[0] += (float)l_iter->v->co[0]; - cent[1] += (float)l_iter->v->co[1]; - cent[2] += (float)l_iter->v->co[2]; - } while ((l_iter = l_iter->next) != l_first); - - mul_v3_fl(cent, (1.0 / (float)l->f->len)); - + BM_face_calc_center_mean(l->f, cent); + add_v3_v3v3(p, l->prev->v->co, l->v->co); mul_v3_fl(p, 0.5); add_v3_v3v3(n, l->next->v->co, l->v->co); @@ -240,8 +231,8 @@ static float quad_coord(float aa[3], float bb[3], float cc[3], float dd[3], int if (fabsf(2.0f * (x - y + z)) > FLT_EPSILON * 10.0f) { float f2; - f1 = (sqrt(y * y - 4.0 * x * z) - y + 2.0 * z) / (2.0 * (x - y + z)); - f2 = (-sqrt(y * y - 4.0 * x * z) - y + 2.0 * z) / (2.0 * (x - y + z)); + f1 = ( sqrtf(y * y - 4.0f * x * z) - y + 2.0f * z) / (2.0f * (x - y + z)); + f2 = (-sqrtf(y * y - 4.0f * x * z) - y + 2.0f * z) / (2.0f * (x - y + z)); f1 = fabsf(f1); f2 = fabsf(f2); @@ -252,7 +243,7 @@ static float quad_coord(float aa[3], float bb[3], float cc[3], float dd[3], int f1 = -z / (y - 2 * z); CLAMP(f1, 0.0f, 1.0f + FLT_EPSILON); - if (isnan(f1) || f1 > 1.0 || f1 < 0.0f) { + if (isnan(f1) || f1 > 1.0f || f1 < 0.0f) { int i; for (i = 0; i < 2; i++) { @@ -345,8 +336,8 @@ static int mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, float sub_v3_v3(v1, c); sub_v3_v3(v2, c); sub_v3_v3(v3, c); sub_v3_v3(v4, c); - mul_v3_fl(v1, 1.0 + eps); mul_v3_fl(v2, 1.0 + eps); - mul_v3_fl(v3, 1.0 + eps); mul_v3_fl(v4, 1.0 + eps); + mul_v3_fl(v1, 1.0f + eps); mul_v3_fl(v2, 1.0f + eps); + mul_v3_fl(v3, 1.0f + eps); mul_v3_fl(v4, 1.0f + eps); add_v3_v3(v1, c); add_v3_v3(v2, c); add_v3_v3(v3, c); add_v3_v3(v4, c); @@ -392,9 +383,9 @@ static void bm_loop_flip_disp(float source_axis_x[3], float source_axis_y[3], d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 0, 1); - if (fabsf(d) < 1e-4) { + if (fabsf(d) < 1e-4f) { d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 0, 2); - if (fabsf(d) < 1e-4) + if (fabsf(d) < 1e-4f) d = bm_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 1, 2); } @@ -439,7 +430,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) mdisp_axis_from_quad(v1, v2, v3, v4, axis_x, axis_y); res = (int)sqrt(mdisps->totdisp); - d = 1.0 / (float)(res - 1); + d = 1.0f / (float)(res - 1); for (x = 0.0f, ix = 0; ix < res; x += d, ix++) { for (y = 0.0f, iy = 0; iy < res; y += d, iy++) { float co1[3], co2[3], co[3]; diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index cb66486cd9e..fe94983dc88 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -47,10 +47,14 @@ BMAllocTemplate bm_mesh_chunksize_default = {512, 1024, 2048, 512}; static void bm_mempool_init(BMesh *bm, const BMAllocTemplate *allocsize) { - bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize->totvert, bm_mesh_chunksize_default.totvert, BLI_MEMPOOL_ALLOW_ITER); - bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize->totedge, bm_mesh_chunksize_default.totedge, BLI_MEMPOOL_ALLOW_ITER); - bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize->totloop, bm_mesh_chunksize_default.totloop, 0); - bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize->totface, bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER); + bm->vpool = BLI_mempool_create(sizeof(BMVert), allocsize->totvert, + bm_mesh_chunksize_default.totvert, BLI_MEMPOOL_ALLOW_ITER); + bm->epool = BLI_mempool_create(sizeof(BMEdge), allocsize->totedge, + bm_mesh_chunksize_default.totedge, BLI_MEMPOOL_ALLOW_ITER); + bm->lpool = BLI_mempool_create(sizeof(BMLoop), allocsize->totloop, + bm_mesh_chunksize_default.totloop, 0); + bm->fpool = BLI_mempool_create(sizeof(BMFace), allocsize->totface, + bm_mesh_chunksize_default.totface, BLI_MEMPOOL_ALLOW_ITER); #ifdef USE_BMESH_HOLES bm->looplistpool = BLI_mempool_create(sizeof(BMLoopList), allocsize[3], allocsize[3], FALSE, FALSE); diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c index 3ec3b84c120..8ab5f10361f 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_validate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c @@ -107,10 +107,12 @@ int BM_mesh_validate(BMesh *bm) ERRMSG("edge %d: has invalid loop, loop is of face %d", i, BM_elem_index_get(l_iter->f)); } else if (BM_vert_in_edge(e, l_iter->v) == FALSE) { - ERRMSG("edge %d: has invalid loop with vert not in edge, loop is of face %d", i, BM_elem_index_get(l_iter->f)); + ERRMSG("edge %d: has invalid loop with vert not in edge, loop is of face %d", + i, BM_elem_index_get(l_iter->f)); } else if (BM_vert_in_edge(e, l_iter->next->v) == FALSE) { - ERRMSG("edge %d: has invalid loop with next vert not in edge, loop is of face %d", i, BM_elem_index_get(l_iter->f)); + ERRMSG("edge %d: has invalid loop with next vert not in edge, loop is of face %d", + i, BM_elem_index_get(l_iter->f)); } } while ((l_iter = l_iter->radial_next) != l_first); } diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 5f3836cc413..c4cbb19eef7 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -1053,7 +1053,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_ /* first create the new edge, this is so we can copy the customdata from the old one * if splice if disabled, always add in a new edge even if theres one there. */ - e_new = BM_edge_create(bm, v1, v2, e, (check_flag & BM_EDGEROT_CHECK_SPLICE)!=0); + e_new = BM_edge_create(bm, v1, v2, e, (check_flag & BM_EDGEROT_CHECK_SPLICE) != 0); f_hflag_prev_1 = l1->f->head.hflag; f_hflag_prev_2 = l2->f->head.hflag; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index dce491efe72..97347f841c8 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1054,7 +1054,7 @@ static void bmo_flag_layer_alloc(BMesh *bm) BM_elem_index_set(ele, i); /* set_inline */ } - bm->elem_index_dirty &= ~(BM_VERT|BM_EDGE|BM_FACE); + bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); BLI_mempool_destroy(oldpool); } @@ -1099,7 +1099,7 @@ static void bmo_flag_layer_free(BMesh *bm) BM_elem_index_set(ele, i); /* set_inline */ } - bm->elem_index_dirty &= ~(BM_VERT|BM_EDGE|BM_FACE); + bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); BLI_mempool_destroy(oldpool); } @@ -1128,7 +1128,7 @@ static void bmo_flag_layer_clear(BMesh *bm) BM_elem_index_set(ele, i); /* set_inline */ } - bm->elem_index_dirty &= ~(BM_VERT|BM_EDGE|BM_FACE); + bm->elem_index_dirty &= ~(BM_VERT | BM_EDGE | BM_FACE); } void *BMO_slot_buffer_elem_first(BMOperator *op, const char *slotname) diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index e9a35ff70a2..8628ed7f9a1 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -900,7 +900,7 @@ float BM_vert_calc_edge_angle(BMVert *v) BMVert *v1 = BM_edge_other_vert(e1, v); BMVert *v2 = BM_edge_other_vert(e2, v); - return M_PI - angle_v3v3v3(v1->co, v->co, v2->co); + return (float)M_PI - angle_v3v3v3(v1->co, v->co, v2->co); } else { return DEG2RADF(90.0f); diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index b6b54b82f3d..f02b88c5b05 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -151,10 +151,10 @@ static void calc_corner_co(BMLoop *l, const float fac, float r_co[3], /* done */ if (do_even) { - mul_v3_fl(co_ofs, (fac * 0.5) * shell_angle_to_dist(0.5f * angle)); + mul_v3_fl(co_ofs, (fac * 0.5f) * shell_angle_to_dist(0.5f * angle)); } else { - mul_v3_fl(co_ofs, fac * 0.5); + mul_v3_fl(co_ofs, fac * 0.5f); } } @@ -208,9 +208,9 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BLI_smallhash_init(&hash); BMO_ITER (e, &siter, bm, op, "geom", BM_EDGE) { - BMO_elem_flag_enable(bm, e, BEVEL_FLAG|BEVEL_DEL); - BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG|BEVEL_DEL); - BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG|BEVEL_DEL); + BMO_elem_flag_enable(bm, e, BEVEL_FLAG | BEVEL_DEL); + BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG | BEVEL_DEL); + BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG | BEVEL_DEL); if (BM_edge_face_count(e) < 2) { BMO_elem_flag_disable(bm, e, BEVEL_DEL); @@ -281,8 +281,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BMLoop *l; BMIter liter; - BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG|BEVEL_DEL); - BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG|BEVEL_DEL); + BMO_elem_flag_enable(bm, e->v1, BEVEL_FLAG | BEVEL_DEL); + BMO_elem_flag_enable(bm, e->v2, BEVEL_FLAG | BEVEL_DEL); if (BM_edge_face_count(e) < 2) { BMO_elem_flag_disable(bm, e, BEVEL_DEL); @@ -597,7 +597,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) continue; } - BMO_elem_flag_enable(bm, f, FACE_NEW|FACE_SPAN); + BMO_elem_flag_enable(bm, f, FACE_NEW | FACE_SPAN); /* un-tag edges in f for deletio */ BM_ITER_ELEM (l2, &liter2, f, BM_LOOPS_OF_FACE) { @@ -775,7 +775,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) fprintf(stderr, "%s: in bevel vert fill! (bmesh internal error)\n", __func__); } else { - BMO_elem_flag_enable(bm, f, FACE_NEW|FACE_HOLE); + BMO_elem_flag_enable(bm, f, FACE_NEW | FACE_HOLE); } } BLI_smallhash_release(&tmphash); diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 6f08ab421f3..85aed6141bb 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -1285,7 +1285,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op) const short use_smooth = BMO_slot_bool_get(op, "use_smooth"); /* count number of each element type we were passe */ - BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT|BM_EDGE|BM_FACE) { + BMO_ITER (h, &oiter, bm, op, "geom", BM_VERT | BM_EDGE | BM_FACE) { switch (h->htype) { case BM_VERT: totv++; break; case BM_EDGE: tote++; break; diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 4fced09c588..4bac54794bf 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -251,7 +251,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) /* initialize our sub-operators */ BMO_op_init(bm, &dupeop, "dupe"); - BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE|BM_FACE, EXT_INPUT); + BMO_slot_buffer_flag_enable(bm, op, "edgefacein", BM_EDGE | BM_FACE, EXT_INPUT); /* if one flagged face is bordered by an un-flagged face, then we delete * original geometry unless caller explicitly asked to keep it. */ diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 700480be01c..741ec1fe2d0 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -470,7 +470,7 @@ static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op, } /* Check for colinear vertices */ - if (largest_dist < 0.0001) + if (largest_dist < 0.0001f) return TRUE; /* Choose fourth point farthest from existing plane */ @@ -493,7 +493,7 @@ static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op, return TRUE; } - if (largest_dist < 0.0001) + if (largest_dist < 0.0001f) return TRUE; return FALSE; diff --git a/source/blender/bmesh/operators/bmo_inset.c b/source/blender/bmesh/operators/bmo_inset.c index e08f08baacd..26197c43bd0 100644 --- a/source/blender/bmesh/operators/bmo_inset.c +++ b/source/blender/bmesh/operators/bmo_inset.c @@ -313,7 +313,8 @@ void bmo_inset_exec(BMesh *bm, BMOperator *op) /* scale by edge angle */ if (use_even_offset) { - mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(e_info_a->no, e_info_b->no) / 2.0f)); + mul_v3_fl(tvec, shell_angle_to_dist(angle_normalized_v3v3(e_info_a->no, + e_info_b->no) / 2.0f)); } /* scale relative to edge lengths */ diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 70dcc6fa3ae..8060c3b5142 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -147,7 +147,7 @@ void bmo_weldverts_exec(BMesh *bm, BMOperator *op) BM_elem_index_set(f, 0); /* set_dirty! */ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { if (BMO_elem_flag_test(bm, l->v, ELE_DEL)) { - BMO_elem_flag_enable(bm, f, FACE_MARK|ELE_DEL); + BMO_elem_flag_enable(bm, f, FACE_MARK | ELE_DEL); } if (BMO_elem_flag_test(bm, l->e, EDGE_COL)) { BM_elem_index_set(f, BM_elem_index_get(f) + 1); /* set_dirty! */ diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 736ce3bc033..03a691e3e9c 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -132,7 +132,7 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar madd_v3_v3fl(tvec, nor2, fac); /* falloff for multi subdivide */ - smooth *= sqrtf(fabsf(1.0f - 2.0f * fabsf(0.5f-perc))); + smooth *= sqrtf(fabsf(1.0f - 2.0f * fabsf(0.5f - perc))); mul_v3_fl(tvec, smooth * len); @@ -225,7 +225,7 @@ static BMVert *subdivideedgenum(BMesh *bm, BMEdge *edge, BMEdge *oedge, if (BMO_elem_flag_test(bm, edge, EDGE_PERCENT) && totpoint == 1) percent = BMO_slot_map_float_get(bm, params->op, "edgepercents", edge); else { - percent = 1.0f / (float)(totpoint + 1-curpoint); + percent = 1.0f / (float)(totpoint + 1 - curpoint); percent2 = (float)(curpoint + 1) / (float)(totpoint + 1); } @@ -1023,7 +1023,7 @@ void bmo_esubd_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_from_enabled_flag(bm, op, "outinner", BM_ALL, ELE_INNER); BMO_slot_buffer_from_enabled_flag(bm, op, "outsplit", BM_ALL, ELE_SPLIT); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, ELE_INNER|ELE_SPLIT|SUBD_SPLIT); + BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, ELE_INNER | ELE_SPLIT | SUBD_SPLIT); } /* editmesh-emulating function */ diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index 9632a79b7dd..755dceefdc5 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -143,8 +143,8 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) if (e) { BMO_elem_flag_enable(bm, e, ELE_NEW); - BMO_elem_flag_enable(bm, e->l->f, FACE_MARK|ELE_NEW); - BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK|ELE_NEW); + BMO_elem_flag_enable(bm, e->l->f, FACE_MARK | ELE_NEW); + BMO_elem_flag_enable(bm, e->l->radial_next->f, FACE_MARK | ELE_NEW); stop = 0; } } @@ -152,7 +152,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op) } } - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE|BM_FACE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE | BM_FACE, ELE_NEW); } void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) @@ -214,8 +214,8 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) /* clean up fill */ BMO_op_initf(bm, &bmop, "beautify_fill faces=%ff constrain_edges=%fe", ELE_NEW, EDGE_MARK); BMO_op_exec(bm, &bmop); - BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_FACE|BM_EDGE, ELE_NEW); + BMO_slot_buffer_flag_enable(bm, &bmop, "geomout", BM_FACE | BM_EDGE, ELE_NEW); BMO_op_finish(bm, &bmop); - BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE|BM_FACE, ELE_NEW); + BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_EDGE | BM_FACE, ELE_NEW); } diff --git a/source/blender/bmesh/operators/bmo_wireframe.c b/source/blender/bmesh/operators/bmo_wireframe.c index 7cb8ac0b66d..e0dc5cf48c7 100644 --- a/source/blender/bmesh/operators/bmo_wireframe.c +++ b/source/blender/bmesh/operators/bmo_wireframe.c @@ -103,7 +103,7 @@ static void bm_vert_boundary_tangent(BMVert *v, float r_no[3], float r_no_face[3 BM_edge_calc_face_tangent(e_b, l_b, tvec_b); add_v3_v3(tvec_a, tvec_b); - if (dot_v3v3(r_no, tvec_a) > 0.0) { + if (dot_v3v3(r_no, tvec_a) > 0.0f) { negate_v3(r_no); } @@ -239,7 +239,7 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) /* create offset vert */ fac = inset; if (use_even_offset) { - fac *= shell_angle_to_dist((M_PI - BM_loop_calc_face_angle(l)) * 0.5f); + fac *= shell_angle_to_dist(((float)M_PI - BM_loop_calc_face_angle(l)) * 0.5f); } if (use_relative_offset) { fac *= verts_relfac[BM_elem_index_get(l->v)]; @@ -269,10 +269,10 @@ void bmo_wireframe_exec(BMesh *bm, BMOperator *op) /* similar to code above but different angle calc */ fac = inset; if (use_even_offset) { - fac *= shell_angle_to_dist((M_PI - angle_on_axis_v3v3v3_v3(va_other->co, - l_pair[i]->v->co, - vb_other->co, - no_face)) * 0.5f); + fac *= shell_angle_to_dist(((float)M_PI - angle_on_axis_v3v3v3_v3(va_other->co, + l_pair[i]->v->co, + vb_other->co, + no_face)) * 0.5f); } if (use_relative_offset) { fac *= verts_relfac[BM_elem_index_get(l_pair[i]->v)]; diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index a357767e1d8..e03df77a290 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -234,7 +234,8 @@ static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_H * vec2 is the direction of projection (pointing away from vec1) * up_vec is used for orientation (expected to be normalized) * returns the length of the projected vector that lies along vec1 */ -static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td)) +static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, + int is_forward, BME_TransData_Head *UNUSED(td)) { float factor, vec3[3], tmp[3], c1, c2; @@ -264,7 +265,8 @@ static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int * using the vert and the loop passed, get or make the split vert, set its coordinates * and transform properties, and set the max limits. * Finally, return the split vert. */ -static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, float *up_vec, float value, BME_TransData_Head *td) +static BMVert *BME_bevel_split_edge(BMesh *bm, BMVert *v, BMVert *v1, BMLoop *l, + float *up_vec, float value, BME_TransData_Head *td) { BME_TransData *vtd, *vtd1, *vtd2; BMVert *sv, *v2, *v3, *ov; @@ -496,7 +498,8 @@ static BMVert *BME_bevel_wire(BMesh *bm, BMVert *v, float value, int res, int UN } #endif -static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td) +static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(options), + float *up_vec, BME_TransData_Head *td) { BMVert *v1, *v2, *kv; BMLoop *kl = NULL, *nl; @@ -617,7 +620,8 @@ static BMLoop *BME_bevel_edge(BMesh *bm, BMLoop *l, float value, int UNUSED(opti return l; } -static BMLoop *BME_bevel_vert(BMesh *bm, BMLoop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td) +static BMLoop *BME_bevel_vert(BMesh *bm, BMLoop *l, float value, int UNUSED(options), + float up_vec[3], BME_TransData_Head *td) { BMVert *v1, *v2; /* BMFace *f; */ /* UNUSED */ @@ -810,7 +814,7 @@ static float BME_bevel_get_angle_vert(BMVert *v) } /* return cosf(angle_diff + 0.001f); */ /* compare with dot product */ - return (angle_diff / tot_angle) * (M_PI / 2); + return (angle_diff / tot_angle) * (float)(M_PI / 2.0); } static void BME_bevel_add_vweight(BME_TransData_Head *td, BMesh *bm, BMVert *v, float weight, float factor, int options) @@ -894,7 +898,7 @@ static void bevel_init_edges(BMesh *bm, int options, float angle, BME_TransData_ int count; float weight; BMIter iter; - const float threshold = (options & BME_BEVEL_ANGLE) ? cosf(angle + 0.001) : 0.0f; + const float threshold = (options & BME_BEVEL_ANGLE) ? cosf(angle + 0.001f) : 0.0f; BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { weight = 0.0f; @@ -945,7 +949,8 @@ static void bevel_init_edges(BMesh *bm, int options, float angle, BME_TransData_ } } -static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_index), float angle, BME_TransData_Head *td) +static BMesh *BME_bevel_initialize(BMesh *bm, int options, + int UNUSED(defgrp_index), float angle, BME_TransData_Head *td) { BMVert *v /*, *v2 */; BMEdge *e /*, *curedg */; @@ -1037,7 +1042,8 @@ static BMesh *BME_bevel_reinitialize(BMesh *bm) * A BMesh pointer to the BM passed as a parameter. */ -static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int options, int UNUSED(defgrp_index), BME_TransData_Head *td) +static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int options, + int UNUSED(defgrp_index), BME_TransData_Head *td) { BMVert *v; BMEdge *e, *curedge; @@ -1102,14 +1108,14 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i BME_TransData_Head *td; BME_TransData *vtd; int i; - double fac = 1, d; + double fac = 1.0, d; td = BME_init_transdata(BLI_MEMARENA_STD_BUFSIZE); /* recursion math courtesy of Martin Poirier (theeth) */ for (i = 0; i < res - 1; i++) { - if (i == 0) fac += 1.0f / 3.0f; else fac += 1.0f / (3 * i * 2.0f); + if (i == 0) fac += 1.0 / 3.0; else fac += 1.0 / (3.0 * i * 2.0); } - d = 1.0f / fac; + d = 1.0 / fac; for (i = 0; i < res || (res == 0 && i == 0); i++) { BMO_push(bm, NULL); @@ -1143,7 +1149,7 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i else { d = value; } - madd_v3_v3v3fl(v->co, vtd->org, vtd->vec, vtd->factor * d); + madd_v3_v3v3fl(v->co, vtd->org, vtd->vec, vtd->factor * (float)d); } } From d0017e1813787a17548ce4a99007a61dbc0ca67f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 20:06:25 +0000 Subject: [PATCH 31/88] Fix strand render + instancing render bug, gave tile artifacts. --- source/blender/render/intern/include/strand.h | 2 +- source/blender/render/intern/source/strand.c | 52 ++++++++++++------- source/blender/render/intern/source/zbuf.c | 4 +- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/source/blender/render/intern/include/strand.h b/source/blender/render/intern/include/strand.h index 5094b646807..a343278c0ab 100644 --- a/source/blender/render/intern/include/strand.h +++ b/source/blender/render/intern/include/strand.h @@ -101,7 +101,7 @@ void free_strand_surface(struct Render *re); struct StrandShadeCache *strand_shade_cache_create(void); void strand_shade_cache_free(struct StrandShadeCache *cache); void strand_shade_segment(struct Render *re, struct StrandShadeCache *cache, struct StrandSegment *sseg, struct ShadeSample *ssamp, float t, float s, int addpassflag); -void strand_shade_unref(struct StrandShadeCache *cache, struct StrandVert *svert); +void strand_shade_unref(struct StrandShadeCache *cache, struct ObjectInstanceRen *obi, struct StrandRen *strand, struct StrandVert *svert); #endif diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index b68525c7150..7aa114a64dc 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -328,8 +328,8 @@ StrandShadeCache *strand_shade_cache_create(void) StrandShadeCache *cache; cache= MEM_callocN(sizeof(StrandShadeCache), "StrandShadeCache"); - cache->resulthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "strand_shade_cache_create1 gh"); - cache->refcounthash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "strand_shade_cache_create2 gh"); + cache->resulthash= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "strand_shade_cache_create1 gh"); + cache->refcounthash= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "strand_shade_cache_create2 gh"); cache->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand shade cache arena"); return cache; @@ -337,20 +337,26 @@ StrandShadeCache *strand_shade_cache_create(void) void strand_shade_cache_free(StrandShadeCache *cache) { - BLI_ghash_free(cache->refcounthash, NULL, NULL); - BLI_ghash_free(cache->resulthash, NULL, (GHashValFreeFP)MEM_freeN); + BLI_ghash_free(cache->refcounthash, (GHashKeyFreeFP)BLI_ghashutil_pairfree, NULL); + BLI_ghash_free(cache->resulthash, (GHashKeyFreeFP)BLI_ghashutil_pairfree, (GHashValFreeFP)MEM_freeN); BLI_memarena_free(cache->memarena); MEM_freeN(cache); } +static GHashPair *strand_shade_hash_pair(ObjectInstanceRen *obi, StrandRen *strand, StrandVert *svert) +{ + return BLI_ghashutil_pairalloc(obi, strand->index + (svert - strand->vert)); +} + static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert) { ShadeResult *hashshr; StrandPoint p; int *refcount; + GHashPair *pair = strand_shade_hash_pair(sseg->obi, sseg->strand, svert); - hashshr= BLI_ghash_lookup(cache->resulthash, svert); - refcount= BLI_ghash_lookup(cache->refcounthash, svert); + hashshr= BLI_ghash_lookup(cache->resulthash, pair); + refcount= BLI_ghash_lookup(cache->refcounthash, pair); if (!hashshr) { /* not shaded yet, shade and insert into hash */ @@ -360,7 +366,7 @@ static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *s hashshr= MEM_callocN(sizeof(ShadeResult), "HashShadeResult"); *hashshr= ssamp->shr[0]; - BLI_ghash_insert(cache->resulthash, svert, hashshr); + BLI_ghash_insert(cache->resulthash, strand_shade_hash_pair(sseg->obi, sseg->strand, svert), hashshr); } else /* already shaded, just copy previous result from hash */ @@ -369,9 +375,11 @@ static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *s /* lower reference count and remove if not needed anymore by any samples */ (*refcount)--; if (*refcount == 0) { - BLI_ghash_remove(cache->resulthash, svert, NULL, (GHashValFreeFP)MEM_freeN); - BLI_ghash_remove(cache->refcounthash, svert, NULL, NULL); + BLI_ghash_remove(cache->resulthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, (GHashValFreeFP)MEM_freeN); + BLI_ghash_remove(cache->refcounthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, NULL); } + + BLI_ghashutil_pairfree(pair); } void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *sseg, ShadeSample *ssamp, float t, float s, int addpassflag) @@ -394,31 +402,37 @@ void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *ss } } -void strand_shade_unref(StrandShadeCache *cache, StrandVert *svert) +void strand_shade_unref(StrandShadeCache *cache, ObjectInstanceRen *obi, StrandRen *strand, StrandVert *svert) { + GHashPair *pair = strand_shade_hash_pair(obi, strand, svert); int *refcount; /* lower reference count and remove if not needed anymore by any samples */ - refcount= BLI_ghash_lookup(cache->refcounthash, svert); + refcount= BLI_ghash_lookup(cache->refcounthash, pair); (*refcount)--; if (*refcount == 0) { - BLI_ghash_remove(cache->resulthash, svert, NULL, (GHashValFreeFP)MEM_freeN); - BLI_ghash_remove(cache->refcounthash, svert, NULL, NULL); + BLI_ghash_remove(cache->resulthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, (GHashValFreeFP)MEM_freeN); + BLI_ghash_remove(cache->refcounthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, NULL); } + + BLI_ghashutil_pairfree(pair); } -static void strand_shade_refcount(StrandShadeCache *cache, StrandVert *svert) +static void strand_shade_refcount(StrandShadeCache *cache, StrandSegment *sseg, StrandVert *svert) { - int *refcount= BLI_ghash_lookup(cache->refcounthash, svert); + GHashPair *pair = strand_shade_hash_pair(sseg->obi, sseg->strand, svert); + int *refcount= BLI_ghash_lookup(cache->refcounthash, pair); if (!refcount) { refcount= BLI_memarena_alloc(cache->memarena, sizeof(int)); *refcount= 1; - BLI_ghash_insert(cache->refcounthash, svert, refcount); + BLI_ghash_insert(cache->refcounthash, pair, refcount); } - else + else { (*refcount)++; + BLI_ghashutil_pairfree(pair); + } } /* *************** */ @@ -580,8 +594,8 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float } if (cache) { - strand_shade_refcount(cache, sseg->v[1]); - strand_shade_refcount(cache, sseg->v[2]); + strand_shade_refcount(cache, sseg, sseg->v[1]); + strand_shade_refcount(cache, sseg, sseg->v[2]); } spart->totapixbuf[offset]++; } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 50fb9211995..84c5f822b53 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3748,8 +3748,8 @@ static void unref_strand_samples(StrandShadeCache *cache, ZTranspRow *row, int t strand= RE_findOrAddStrand(obr, row[totface].p-1); svert= strand->vert + row[totface].segment; - strand_shade_unref(cache, svert); - strand_shade_unref(cache, svert+1); + strand_shade_unref(cache, obi, strand, svert); + strand_shade_unref(cache, obi, strand, svert+1); } } } From ae585d59697b076e3c7e5492328a45defac03d86 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 May 2012 20:26:05 +0000 Subject: [PATCH 32/88] fix for last commit, (warning was without openmp only) --- source/blender/editors/sculpt_paint/sculpt.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 509cde16e3e..32ed55854b6 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -267,7 +267,7 @@ typedef struct StrokeCache { /*** paint mesh ***/ -static void paint_mesh_restore_co(SculptSession *ss) +static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss) { StrokeCache *cache = ss->cache; int i; @@ -275,6 +275,10 @@ static void paint_mesh_restore_co(SculptSession *ss) PBVHNode **nodes; int n, totnode; +#ifndef _OPENMP + (void)sd; /* quied unused warning */ +#endif + BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) @@ -421,11 +425,11 @@ static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float loca local_co[2] = fabs(local_co[2]); if (local_co[0] <= side && local_co[1] <= side && local_co[2] <= side) { - float p = 4; + float p = 4.0f; test->dist = ((powf(local_co[0], p) + powf(local_co[1], p) + - powf(local_co[2], p)) / pow(side, p)); + powf(local_co[2], p)) / powf(side, p)); return 1; } @@ -3373,7 +3377,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) brush_use_size_pressure(ss->cache->vc->scene, brush)) || (brush->flag & BRUSH_RESTORE_MESH)) { - paint_mesh_restore_co(ss); + paint_mesh_restore_co(sd, ss); } } @@ -3592,7 +3596,7 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) Sculpt *sd = CTX_data_tool_settings(C)->sculpt; if (ss->cache) { - paint_mesh_restore_co(ss); + paint_mesh_restore_co(sd, ss); } paint_stroke_cancel(C, op); From 552a70f1774dcb197739281968aab58cf887fd83 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 May 2012 21:19:31 +0000 Subject: [PATCH 33/88] code cleanup: - replace iterators with macros - move vertexCos checks outside the for loops (use 2 for loops). - style cleanup --- .../blenkernel/intern/editderivedmesh.c | 209 +++++++++--------- 1 file changed, 102 insertions(+), 107 deletions(-) diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 5e3f886c762..9fd6a4e9ba4 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -150,8 +150,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) #endif - f = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); - for ( ; f; f=BM_iter_step(&iter)) { + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { /*don't consider two-edged faces*/ if (f->len < 3) { /* do nothing */ @@ -357,17 +356,18 @@ static void emDM_foreachMappedVert( void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMVert *eve; BMIter iter; int i; - eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; i++, eve=BM_iter_step(&iter)) { - if (bmdm->vertexCos) { + if (bmdm->vertexCos) { + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { func(userData, i, bmdm->vertexCos[i], bmdm->vertexNos[i], NULL); } - else { + } + else { + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { func(userData, i, eve->co, eve->no, NULL); } } @@ -377,7 +377,7 @@ static void emDM_foreachMappedEdge( void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEdge *eed; BMIter iter; int i; @@ -404,7 +404,7 @@ static void emDM_drawMappedEdges( DMSetDrawOptions setDrawOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEdge *eed; BMIter iter; int i; @@ -449,7 +449,7 @@ static void emDM_drawMappedEdgesInterp( DMSetDrawInterpOptions setDrawInterpOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEdge *eed; BMIter iter; int i; @@ -487,7 +487,7 @@ static void emDM_drawMappedEdgesInterp( static void emDM_drawUVEdges(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; BMEditMesh *em = bmdm->tc; BMFace *efa; BMIter iter; @@ -557,7 +557,7 @@ static void emDM_foreachMappedFaceCenter( void (*func)(void *userData, int index, const float co[3], const float no[3]), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; float (*polyNos)[3] = NULL; BMFace *efa; BMIter iter; @@ -572,8 +572,7 @@ static void emDM_foreachMappedFaceCenter( BLI_assert(polyNos != NULL); } - efa = BM_iter_new(&iter, bmdm->tc->bm, BM_FACES_OF_MESH, NULL); - for (i=0; efa; efa=BM_iter_step(&iter), i++) { + BM_ITER_MESH_INDEX (efa, &iter, bmdm->tc->bm, BM_FACES_OF_MESH, i) { emDM__calcFaceCent(bmdm->tc->bm, efa, cent, bmdm->vertexCos); func(userData, i, cent, polyNos ? polyNos[i] : efa->no); } @@ -587,18 +586,18 @@ static void emDM_drawMappedFaces( void *userData, DMDrawFlag flag) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; BMFace *efa; - struct BMLoop *(*looptris)[3]= bmdm->tc->looptris; - const int tottri= bmdm->tc->tottri; - const int lasttri= tottri - 1; /* compare agasint this a lot */ + struct BMLoop *(*looptris)[3] = bmdm->tc->looptris; + const int tottri = bmdm->tc->tottri; + const int lasttri = tottri - 1; /* compare agasint this a lot */ DMDrawOption draw_option; int i, flush; - const int skip_normals= !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */ + const int skip_normals = !glIsEnabled(GL_LIGHTING); /* could be passed as an arg */ /* GL_ZERO is used to detect if drawing has started or not */ - GLenum poly_prev= GL_ZERO; - GLenum shade_prev= GL_ZERO; + GLenum poly_prev = GL_ZERO; + GLenum shade_prev = GL_ZERO; (void)setMaterial; /* UNUSED */ @@ -607,29 +606,29 @@ static void emDM_drawMappedFaces( if (bmdm->vertexCos) { /* add direct access */ - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; - float (*polyNos)[3]= bmdm->polyNos; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; + float (*polyNos)[3] = bmdm->polyNos; // int *triPolyMap= bmdm->triPolyMap; BM_mesh_elem_index_ensure(bmdm->tc->bm, BM_VERT | BM_FACE); - for (i=0; i < tottri; i++) { + for (i = 0; i < tottri; i++) { BMLoop **l = looptris[i]; int drawSmooth; efa = l[0]->f; - drawSmooth= (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH); + drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : BM_elem_flag_test(efa, BM_ELEM_SMOOTH); draw_option = (!setDrawOptions ? DM_DRAW_OPTION_NORMAL : setDrawOptions(userData, BM_elem_index_get(efa))); if (draw_option != DM_DRAW_OPTION_SKIP) { - const GLenum poly_type= GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ + const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); - poly_prev= GL_ZERO; /* force glBegin */ + poly_prev = GL_ZERO; /* force glBegin */ glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple_quarttone); @@ -638,22 +637,22 @@ static void emDM_drawMappedFaces( if (skip_normals) { if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } glVertex3fv(vertexCos[BM_elem_index_get(l[0]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(l[1]->v)]); glVertex3fv(vertexCos[BM_elem_index_get(l[2]->v)]); } else { - const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT; + const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; if (shade_type != shade_prev) { if (poly_prev != GL_ZERO) glEnd(); - glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */ - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (!drawSmooth) { @@ -672,13 +671,13 @@ static void emDM_drawMappedFaces( } } - flush= (draw_option == DM_DRAW_OPTION_STIPPLE); + flush = (draw_option == DM_DRAW_OPTION_STIPPLE); if (!skip_normals && !flush && (i != lasttri)) - flush|= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ + flush |= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ if (flush) { glEnd(); - poly_prev= GL_ZERO; /* force glBegin */ + poly_prev = GL_ZERO; /* force glBegin */ glDisable(GL_POLYGON_STIPPLE); } @@ -699,11 +698,11 @@ static void emDM_drawMappedFaces( DM_DRAW_OPTION_NORMAL : setDrawOptions(userData, BM_elem_index_get(efa))); if (draw_option != DM_DRAW_OPTION_SKIP) { - const GLenum poly_type= GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ + const GLenum poly_type = GL_TRIANGLES; /* BMESH NOTE, this is odd but keep it for now to match trunk */ if (draw_option == DM_DRAW_OPTION_STIPPLE) { /* enabled with stipple */ if (poly_prev != GL_ZERO) glEnd(); - poly_prev= GL_ZERO; /* force glBegin */ + poly_prev = GL_ZERO; /* force glBegin */ glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple_quarttone); @@ -712,22 +711,22 @@ static void emDM_drawMappedFaces( if (skip_normals) { if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } glVertex3fv(l[0]->v->co); glVertex3fv(l[1]->v->co); glVertex3fv(l[2]->v->co); } else { - const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT; + const GLenum shade_type = drawSmooth ? GL_SMOOTH : GL_FLAT; if (shade_type != shade_prev) { if (poly_prev != GL_ZERO) glEnd(); - glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */ - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glShadeModel((shade_prev = shade_type)); /* same as below but switch shading */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (poly_type != poly_prev) { if (poly_prev != GL_ZERO) glEnd(); - glBegin((poly_prev= poly_type)); /* BMesh: will always be GL_TRIANGLES */ + glBegin((poly_prev = poly_type)); /* BMesh: will always be GL_TRIANGLES */ } if (!drawSmooth) { @@ -746,9 +745,9 @@ static void emDM_drawMappedFaces( } } - flush= (draw_option == DM_DRAW_OPTION_STIPPLE); + flush = (draw_option == DM_DRAW_OPTION_STIPPLE); if (!skip_normals && !flush && (i != lasttri)) { - flush|= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ + flush |= efa->mat_nr != looptris[i + 1][0]->f->mat_nr; /* TODO, make this neater */ } if (flush) { @@ -766,7 +765,7 @@ static void emDM_drawMappedFaces( } static void bmdm_get_tri_tex(BMesh *bm, BMLoop **ls, MLoopUV *luv[3], MLoopCol *lcol[3], - int has_uv, int has_col) + int has_uv, int has_col) { if (has_uv) { luv[0] = CustomData_bmesh_get(&bm->ldata, ls[0]->head.data, CD_MLOOPUV); @@ -790,11 +789,11 @@ static void emDM_drawFacesTex_common( DMCompareDrawOptions compareDrawOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; BMEditMesh *em = bmdm->tc; - BMesh *bm= bmdm->tc->bm; - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; + BMesh *bm = bmdm->tc->bm; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; BMFace *efa; MLoopUV *luv[3], dummyluv = {{0}}; MLoopCol *lcol[3] = {NULL}, dummylcol = {0}; @@ -815,12 +814,12 @@ static void emDM_drawFacesTex_common( if (vertexCos) { BM_mesh_elem_index_ensure(bm, BM_VERT); - for (i=0; itottri; i++) { + for (i = 0; i < em->tottri; i++) { BMLoop **ls = em->looptris[i]; - MTexPoly *tp= has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; + MTexPoly *tp = has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; MTFace mtf = {{{0}}}; /*unsigned char *cp= NULL;*/ /*UNUSED*/ - int drawSmooth= BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); + int drawSmooth = BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); DMDrawOption draw_option; efa = ls[0]->f; @@ -830,11 +829,11 @@ static void emDM_drawFacesTex_common( } if (drawParams) - draw_option= drawParams(&mtf, has_vcol, efa->mat_nr); + draw_option = drawParams(&mtf, has_vcol, efa->mat_nr); else if (drawParamsMapped) - draw_option= drawParamsMapped(userData, BM_elem_index_get(efa)); + draw_option = drawParamsMapped(userData, BM_elem_index_get(efa)); else - draw_option= DM_DRAW_OPTION_NORMAL; + draw_option = DM_DRAW_OPTION_NORMAL; if (draw_option != DM_DRAW_OPTION_SKIP) { @@ -887,12 +886,12 @@ static void emDM_drawFacesTex_common( else { BM_mesh_elem_index_ensure(bm, BM_VERT); - for (i=0; itottri; i++) { + for (i = 0; i < em->tottri; i++) { BMLoop **ls = em->looptris[i]; - MTexPoly *tp= has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; + MTexPoly *tp = has_uv ? CustomData_bmesh_get(&bm->pdata, ls[0]->f->head.data, CD_MTEXPOLY) : NULL; MTFace mtf = {{{0}}}; /*unsigned char *cp= NULL;*/ /*UNUSED*/ - int drawSmooth= BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); + int drawSmooth = BM_elem_flag_test(ls[0]->f, BM_ELEM_SMOOTH); DMDrawOption draw_option; efa = ls[0]->f; @@ -902,11 +901,11 @@ static void emDM_drawFacesTex_common( } if (drawParams) - draw_option= drawParams(&mtf, has_vcol, efa->mat_nr); + draw_option = drawParams(&mtf, has_vcol, efa->mat_nr); else if (drawParamsMapped) - draw_option= drawParamsMapped(userData, BM_elem_index_get(efa)); + draw_option = drawParamsMapped(userData, BM_elem_index_get(efa)); else - draw_option= DM_DRAW_OPTION_NORMAL; + draw_option = DM_DRAW_OPTION_NORMAL; if (draw_option != DM_DRAW_OPTION_SKIP) { @@ -990,11 +989,11 @@ static void emDM_drawMappedFacesGLSL( DMSetDrawOptions setDrawOptions, void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - BMesh *bm= bmdm->tc->bm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMesh *bm = bmdm->tc->bm; BMEditMesh *em = bmdm->tc; - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; BMFace *efa; BMLoop **ltri; DMVertexAttribs attribs; @@ -1033,11 +1032,11 @@ static void emDM_drawMappedFacesGLSL( } - for (i=0, ltri=em->looptris[0]; itottri; i++, ltri += 3) { + for (i = 0, ltri = em->looptris[0]; i < em->tottri; i++, ltri += 3) { int drawSmooth; efa = ltri[0]->f; - drawSmooth= BM_elem_flag_test(efa, BM_ELEM_SMOOTH); + drawSmooth = BM_elem_flag_test(efa, BM_ELEM_SMOOTH); if (setDrawOptions && (setDrawOptions(userData, BM_elem_index_get(efa)) == DM_DRAW_OPTION_SKIP)) continue; @@ -1116,14 +1115,14 @@ static void emDM_drawMappedFacesMat( void (*setMaterial)(void *userData, int, void *attribs), int (*setFace)(void *userData, int index), void *userData) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - BMesh *bm= bmdm->tc->bm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMesh *bm = bmdm->tc->bm; BMEditMesh *em = bmdm->tc; - float (*vertexCos)[3]= bmdm->vertexCos; - float (*vertexNos)[3]= bmdm->vertexNos; + float (*vertexCos)[3] = bmdm->vertexCos; + float (*vertexNos)[3] = bmdm->vertexNos; BMFace *efa; BMLoop **ltri; - DMVertexAttribs attribs= {{{0}}}; + DMVertexAttribs attribs = {{{0}}}; GPUVertexAttribs gattribs; int i, b, matnr, new_matnr; @@ -1132,7 +1131,7 @@ static void emDM_drawMappedFacesMat( /* always use smooth shading even for flat faces, else vertex colors wont interpolate */ glShadeModel(GL_SMOOTH); - BM_mesh_elem_index_ensure(bm, BM_VERT|BM_FACE); + BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE); #define PASSATTRIB(loop, eve, vert) { \ if (attribs.totorco) { \ @@ -1161,7 +1160,7 @@ static void emDM_drawMappedFacesMat( } \ } - for (i=0, ltri=em->looptris[0]; itottri; i++, ltri += 3) { + for (i = 0, ltri = em->looptris[0]; i < em->tottri; i++, ltri += 3) { int drawSmooth; efa = ltri[0]->f; @@ -1235,18 +1234,19 @@ static void emDM_drawMappedFacesMat( static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; BMVert *eve; BMIter iter; int i; if (bmdm->tc->bm->totvert) { - eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&iter), i++) { - if (bmdm->vertexCos) { + if (bmdm->vertexCos) { + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { DO_MINMAX(bmdm->vertexCos[i], min_r, max_r); } - else { + } + else { + BM_ITER_MESH (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH) { DO_MINMAX(eve->co, min_r, max_r); } } @@ -1258,35 +1258,35 @@ static void emDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) } static int emDM_getNumVerts(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totvert; } static int emDM_getNumEdges(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totedge; } static int emDM_getNumTessFaces(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->tottri; } static int emDM_getNumLoops(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totloop; } static int emDM_getNumPolys(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; return bmdm->tc->bm->totface; } @@ -1413,8 +1413,7 @@ static void emDM_copyEdgeArray(DerivedMesh *dm, MEdge *edge_r) BM_mesh_elem_index_ensure(bm, BM_VERT); - ee = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); - for ( ; ee; ee=BM_iter_step(&iter), edge_r++) { + for (ee = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); ee; ee = BM_iter_step(&iter), edge_r++) { if (has_bweight) { edge_r->bweight = (unsigned char) (BM_elem_float_data_get(&bm->edata, ee, CD_BWEIGHT)*255.0f); } @@ -1440,7 +1439,7 @@ static void emDM_copyTessFaceArray(DerivedMesh *dm, MFace *face_r) BM_mesh_elem_index_ensure(bm, BM_VERT); - for (i=0; itc->tottri; i++, face_r++) { + for (i = 0; i < bmdm->tc->tottri; i++, face_r++) { l = bmdm->tc->looptris[i]; ef = l[0]->f; @@ -1499,8 +1498,8 @@ static void emDM_copyPolyArray(DerivedMesh *dm, MPoly *poly_r) static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh*) dm; - BMesh *bm= bmdm->tc->bm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; + BMesh *bm = bmdm->tc->bm; void *datalayer; datalayer = DM_get_tessface_data_layer(dm, type); @@ -1553,27 +1552,26 @@ static void *emDM_getTessFaceDataArray(DerivedMesh *dm, int type) static void emDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3]) { - EditDerivedBMesh *emdm= (EditDerivedBMesh*) dm; + EditDerivedBMesh *emdm = (EditDerivedBMesh *)dm; BMVert *eve; BMIter iter; int i; - i= 0; - BM_ITER_MESH (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH) { - if (emdm->vertexCos) { + if (emdm->vertexCos) { + BM_ITER_MESH_INDEX (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(cos_r[i], emdm->vertexCos[i]); } - else { + } + else { + BM_ITER_MESH_INDEX (eve, &iter, emdm->tc->bm, BM_VERTS_OF_MESH, i) { copy_v3_v3(cos_r[i], eve->co); } - - i++; } } static void emDM_release(DerivedMesh *dm) { - EditDerivedBMesh *bmdm= (EditDerivedBMesh *)dm; + EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm; if (DM_release(dm)) { if (bmdm->vertexCos) { @@ -1690,10 +1688,10 @@ DerivedMesh *getEditDerivedBMesh( DM_add_vert_layer(&bmdm->dm, CD_MDEFORMVERT, CD_CALLOC, NULL); - eve = BM_iter_new(&iter, bmdm->tc->bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&iter), i++) + BM_ITER_MESH_INDEX (eve, &iter, bmdm->tc->bm, BM_VERTS_OF_MESH, i) { DM_set_vert_data(&bmdm->dm, i, CD_MDEFORMVERT, CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT)); + } } if (vertexCos) { @@ -1708,16 +1706,13 @@ DerivedMesh *getEditDerivedBMesh( bmdm->vertexNos = MEM_callocN(sizeof(*bmdm->vertexNos) * bm->totvert, "bmdm_vno"); bmdm->polyNos = MEM_mallocN(sizeof(*bmdm->polyNos)*bm->totface, "bmdm_pno"); - i = 0; - BM_ITER_MESH (efa, &fiter, bm, BM_FACES_OF_MESH) { + BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) { BM_elem_index_set(efa, i); /* set_inline */ BM_face_normal_update_vcos(bm, efa, bmdm->polyNos[i], (float const (*)[3])vertexCos); - i++; } bm->elem_index_dirty &= ~BM_FACE; - eve=BM_iter_new(&viter, bm, BM_VERTS_OF_MESH, NULL); - for (i=0; eve; eve=BM_iter_step(&viter), i++) { + BM_ITER_MESH_INDEX (eve, &viter, bm, BM_VERTS_OF_MESH, i) { float *no = bmdm->vertexNos[i]; BM_ITER_ELEM (efa, &fiter, eve, BM_FACES_OF_VERT) { add_v3_v3(no, bmdm->polyNos[BM_elem_index_get(efa)]); @@ -1725,14 +1720,14 @@ DerivedMesh *getEditDerivedBMesh( /* following Mesh convention; we use vertex coordinate itself * for normal in this case */ - if (normalize_v3(no)==0.0) { + if (normalize_v3(no) == 0.0f) { copy_v3_v3(no, vertexCos[i]); normalize_v3(no); } } } - return (DerivedMesh*) bmdm; + return (DerivedMesh *)bmdm; } /** From b075765edd9e8f18b088faf1a55358d0f8a289cd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 21:32:49 +0000 Subject: [PATCH 34/88] Fix #31258: collada now selects newly added objects after import. --- source/blender/blenkernel/BKE_object.h | 1 + source/blender/blenkernel/intern/object.c | 6 ++- source/blender/blenkernel/intern/scene.c | 2 - source/blender/collada/AnimationImporter.cpp | 4 +- source/blender/collada/ArmatureImporter.cpp | 4 +- source/blender/collada/DocumentImporter.cpp | 19 ++++++--- source/blender/collada/MeshImporter.cpp | 42 ++++++++++++-------- source/blender/collada/MeshImporter.h | 2 + source/blender/collada/SkinInfo.cpp | 2 +- source/blender/collada/collada_utils.cpp | 15 +++++++ source/blender/collada/collada_utils.h | 2 + source/blender/editors/mesh/mesh_navmesh.c | 1 + 12 files changed, 70 insertions(+), 30 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 4fced71d7f2..2e334c4abc9 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -80,6 +80,7 @@ int exist_object(struct Object *obtest); struct Object *add_only_object(int type, const char *name); struct Object *add_object(struct Scene *scene, int type); +void *add_obdata_from_type(int type); struct Object *copy_object(struct Object *ob); void make_local_object(struct Object *ob); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 2cfacbcf034..280a8fdc2b2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -747,7 +747,7 @@ int exist_object(Object *obtest) /* *************************************************** */ -static void *add_obdata_from_type(int type) +void *add_obdata_from_type(int type) { switch (type) { case OB_MESH: return add_mesh("Mesh"); @@ -792,6 +792,9 @@ Object *add_only_object(int type, const char *name) { Object *ob; + if(!name) + name = get_obdata_defname(type); + ob= alloc_libblock(&G.main->object, ID_OB, name); /* default object vars */ @@ -880,6 +883,7 @@ Object *add_object(struct Scene *scene, int type) ob->lay= scene->lay; base= scene_add_base(scene, ob); + scene_deselect_all(scene); scene_select_base(scene, base); ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 864260833a6..c8f41f26c9b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -888,8 +888,6 @@ void scene_deselect_all(Scene *sce) void scene_select_base(Scene *sce, Base *selbase) { - scene_deselect_all(sce); - selbase->flag |= SELECT; selbase->object->flag= selbase->flag; diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index cf815920b57..a72d51721ce 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -1770,9 +1770,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4] Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::Node *node, Object *par_job) { if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) { - Object *job = add_object(scene, OB_EMPTY); - - rename_id((ID*)&job->id, (char*)get_joint_name(node)); + Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node)); job->lay = object_in_scene(job, scene)->lay = 2; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 833904e20c2..4316edf1e67 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -367,7 +367,7 @@ Object *ArmatureImporter::get_empty_for_leaves() { if (empty) return empty; - empty = add_object(scene, OB_EMPTY); + empty = bc_add_object(scene, OB_EMPTY, NULL); empty->empty_drawtype = OB_EMPTY_SPHERE; return empty; @@ -412,7 +412,7 @@ void ArmatureImporter::create_armature_bones( ) if ( get_armature_for_joint(*ri) != NULL ) continue; //add armature object for current joint - //Object *ob_arm = add_object(scene, OB_ARMATURE); + //Object *ob_arm = bc_add_object(scene, OB_ARMATURE, NULL); Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()]; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index a1f69ef16bd..c793453227a 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -121,6 +121,9 @@ bool DocumentImporter::import() loader.registerExtraDataCallbackHandler(ehandler); + // deselect all to select new objects + scene_deselect_all(CTX_data_scene(mContext)); + if (!root.loadDocument(mFilename)) { fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n"); return false; @@ -144,6 +147,8 @@ bool DocumentImporter::import() delete ehandler; + mesh_importer.bmeshConversion(); + return true; } @@ -157,7 +162,9 @@ void DocumentImporter::cancel(const COLLADAFW::String& errorMessage) // The latter sounds better. } -void DocumentImporter::start() {} +void DocumentImporter::start() +{ +} void DocumentImporter::finish() { @@ -298,7 +305,8 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera fprintf(stderr, "Couldn't find camera by UID.\n"); return NULL; } - Object *ob = add_object(sce, OB_CAMERA); + + Object *ob = bc_add_object(sce, OB_CAMERA, NULL); Camera *cam = uid_camera_map[cam_uid]; Camera *old_cam = (Camera*)ob->data; ob->data = cam; @@ -315,7 +323,8 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce fprintf(stderr, "Couldn't find lamp by UID.\n"); return NULL; } - Object *ob = add_object(sce, OB_LAMP); + + Object *ob = bc_add_object(sce, OB_LAMP, NULL); Lamp *la = uid_lamp_map[lamp_uid]; Lamp *old_lamp = (Lamp*)ob->data; ob->data = la; @@ -398,7 +407,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren if (is_joint) { if ( par ) { Object * empty = par; - par = add_object(sce, OB_ARMATURE); + par = bc_add_object(sce, OB_ARMATURE, NULL); bc_set_parent(par, empty->parent, mContext); //remove empty : todo object_map.insert(std::make_pair(parent_node->getUniqueId(), par)); @@ -465,7 +474,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren // if node is empty - create empty object // XXX empty node may not mean it is empty object, not sure about this if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) { - ob = add_object(sce, OB_EMPTY); + ob = bc_add_object(sce, OB_EMPTY, NULL); objects_done->push_back(ob); } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 3fbd33bdd0b..ba6be75e051 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -727,6 +727,22 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {} +void MeshImporter::bmeshConversion() +{ + for (std::map::iterator m = uid_mesh_map.begin(); + m != uid_mesh_map.end(); ++m) + { + if ((*m).second) { + Mesh *me = (*m).second; + BKE_mesh_convert_mfaces_to_mpolys(me); + BKE_mesh_tessface_clear(me); + + mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + } + } +} + + Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid) { if (uid_object_map.find(geom_uid) != uid_object_map.end()) @@ -839,10 +855,10 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri for (it = prims.begin(); it != prims.end(); it++) { Primitive& prim = *it; - i = 0; - while (i++ < prim.totface) { - prim.mface->mat_nr = mat_index; - prim.mface++; + MFace *mface = prim.mface; + + for (i = 0; i < prim.totface; i++, mface++) { + mface->mat_nr = mat_index; // bind texture images to faces if (texture_face && (*color_texture)) { texture_face->tpage = (Image*)(*color_texture)->tex->ima; @@ -855,7 +871,6 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri return texture_face; } - Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, std::map& uid_material_map, @@ -884,16 +899,16 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta } if (!uid_mesh_map[*geom_uid]) return NULL; - Object *ob = add_object(scene, OB_MESH); + // name Object + const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId(); + const char *name = (id.length())? id.c_str(): NULL; + + // add object + Object *ob = bc_add_object(scene, OB_MESH, name); // store object pointer for ArmatureImporter uid_object_map[*geom_uid] = ob; - // name Object - const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId(); - if (id.length()) - rename_id(&ob->id, (char*)id.c_str()); - // replace ob->data freeing the old one Mesh *old_mesh = (Mesh*)ob->data; @@ -963,10 +978,5 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) make_edges(me, 0); - BKE_mesh_convert_mfaces_to_mpolys(me); - BKE_mesh_tessface_clear(me); - - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); - return true; } diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 0c2e600121f..97ae4d99ad7 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -129,6 +129,8 @@ public: MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce); + void bmeshConversion(); + virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid); MTex *assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 99a4f024f77..0727ec21682 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -151,7 +151,7 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController* co) // called from write_controller Object *SkinInfo::create_armature(Scene *scene) { - ob_arm = add_object(scene, OB_ARMATURE); + ob_arm = bc_add_object(scene, OB_ARMATURE, NULL); return ob_arm; } diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 4aed29defbc..bd0f82fb0ac 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -34,6 +34,7 @@ #include "DNA_customdata_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "BLI_math.h" @@ -41,6 +42,7 @@ #include "BKE_customdata.h" #include "BKE_depsgraph.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "WM_api.h" // XXX hrm, see if we can do without this #include "WM_types.h" @@ -110,3 +112,16 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) return true; } +Object *bc_add_object(Scene *scene, int type, const char *name) +{ + Object *ob = add_only_object(type, name); + + ob->data= add_obdata_from_type(type); + ob->lay= scene->lay; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + + scene_select_base(scene, scene_add_base(scene, ob)); + + return ob; +} + diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index b0c24152652..1f5d2b1d8da 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -39,6 +39,7 @@ #include "DNA_customdata_types.h" #include "DNA_texture_types.h" #include "BKE_context.h" +#include "DNA_scene_types.h" typedef std::map > TexIndexTextureArrayMap; @@ -48,5 +49,6 @@ extern int bc_test_parent_loop(Object *par, Object *ob); extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space=true); extern char *bc_CustomData_get_layer_name(const CustomData *data, int type, int n); extern char *bc_CustomData_get_active_layer_name(const CustomData *data, int type); +extern Object *bc_add_object(Scene *scene, int type, const char *name); #endif diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index c234cf44aec..cc640e38fc2 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -316,6 +316,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, } else { obedit = base->object; + scene_deselect_all(scene); scene_select_base(scene, base); copy_v3_v3(obedit->loc, co); copy_v3_v3(obedit->rot, rot); From 5da2135eef39ac042a8c4babcac7be375e6903d2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 May 2012 21:35:04 +0000 Subject: [PATCH 35/88] code cleanup: double promotion & some style cleanup --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/mesh.c | 2 +- .../blender/editors/armature/editarmature.c | 2 +- source/blender/editors/mesh/editmesh_add.c | 2 +- source/blender/editors/mesh/editmesh_knife.c | 4 +-- source/blender/editors/mesh/editmesh_select.c | 4 +-- source/blender/editors/mesh/editmesh_slide.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 18 +++++----- source/blender/editors/mesh/editmesh_utils.c | 2 +- source/blender/editors/mesh/mesh_data.c | 6 ++-- source/blender/editors/object/object_vgroup.c | 2 +- source/blender/editors/screen/area.c | 4 +-- .../blender/editors/sculpt_paint/sculpt_uv.c | 12 +++---- .../editors/space_view3d/view3d_draw.c | 10 +++--- .../editors/space_view3d/view3d_edit.c | 2 +- .../editors/space_view3d/view3d_select.c | 4 +-- .../editors/transform/transform_conversions.c | 4 +-- .../editors/transform/transform_generics.c | 16 ++++----- .../editors/transform/transform_input.c | 6 ++-- source/blender/editors/uvedit/uvedit_draw.c | 2 +- source/blender/editors/uvedit/uvedit_ops.c | 4 +-- .../editors/uvedit/uvedit_smart_stitch.c | 22 ++++++------ .../editors/uvedit/uvedit_unwrap_ops.c | 4 +-- source/blender/makesdna/DNA_ID.h | 6 ++-- source/blender/makesdna/DNA_image_types.h | 5 ++- source/blender/makesrna/intern/rna_tracking.c | 2 +- .../modifiers/intern/MOD_boolean_util.c | 10 +++--- source/blender/modifiers/intern/MOD_cloth.c | 2 +- .../blender/modifiers/intern/MOD_collision.c | 6 ++-- .../blender/modifiers/intern/MOD_decimate.c | 4 +-- .../blender/modifiers/intern/MOD_displace.c | 2 +- .../blender/modifiers/intern/MOD_edgesplit.c | 2 +- source/blender/modifiers/intern/MOD_hook.c | 16 ++++----- source/blender/modifiers/intern/MOD_mask.c | 4 ++- .../blender/modifiers/intern/MOD_meshdeform.c | 36 +++++++++---------- source/blender/modifiers/intern/MOD_mirror.c | 6 ++-- .../blender/modifiers/intern/MOD_solidify.c | 21 ++++++----- source/blender/modifiers/intern/MOD_warp.c | 9 ++--- .../modifiers/intern/MOD_weightvgproximity.c | 14 ++++---- 39 files changed, 142 insertions(+), 139 deletions(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index a6666bf4fae..bd079238b12 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -586,7 +586,7 @@ static int layerEqual_mloopcol(void *data1, void *data2) b = m1->b - m2->b; a = m1->a - m2->a; - return r*r + g*g + b*b + a*a < 0.001; + return r * r + g * g + b * b + a * a < 0.001f; } static void layerMultiply_mloopcol(void *data, float fac) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index fdeb212b561..40c04a170ca 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2014,7 +2014,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, for (i=0; itotdisp = side*side; - ld->level = (int)(logf(side - 1.0f) / M_LN2) + 1; + ld->level = (int)(logf(side - 1.0f) / (float)M_LN2) + 1; if (ld->disps) MEM_freeN(ld->disps); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index eb821ffc147..a2e95622bcf 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -4096,7 +4096,7 @@ static void select_similar_direction(bArmature *arm, EditBone *ebone_act, const float dir[3]; sub_v3_v3v3(dir, ebone->head, ebone->tail); - if (angle_v3v3(dir_act, dir) / M_PI < thresh) { + if (angle_v3v3(dir_act, dir) / (float)M_PI < thresh) { ED_armature_edit_bone_select(ebone); } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index c2a97b3ea70..60c0ebbc7b3 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -475,7 +475,7 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &view_aligned); if (!view_aligned) - rot[0] += M_PI / 2.0f; + rot[0] += (float)M_PI / 2.0f; make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 2208d96ca46..b215f0ac345 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1412,7 +1412,7 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo float co[3], cageco[3], sco[3], maxdist = knife_snap_size(kcd, kcd->ethresh); if (kcd->ignore_vert_snapping) - maxdist *= 0.5; + maxdist *= 0.5f; f = knife_find_closest_face(kcd, co, cageco, NULL); *is_space = !f; @@ -1502,7 +1502,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo float co[3], cageco[3], sco[3], maxdist = knife_snap_size(kcd, kcd->vthresh); if (kcd->ignore_vert_snapping) - maxdist *= 0.5; + maxdist *= 0.5f; f = knife_find_closest_face(kcd, co, cageco, is_space); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 32e70e798fe..d38ec6436b9 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1129,7 +1129,7 @@ static float edgetag_cut_cost(BMEditMesh *UNUSED(em), BMEdge *e1, BMEdge *e2, BM /* but is biased to give higher values to sharp turns, so that it will take * paths with fewer "turns" when selecting between equal-weighted paths between * the two edges */ - cost = cost + 0.5f * cost * (2.0f - sqrt(fabs(dot_v3v3(d1, d2)))); + cost = cost + 0.5f * cost * (2.0f - sqrtf(fabsf(dot_v3v3(d1, d2)))); return cost; } @@ -2294,7 +2294,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) float sharp = RNA_float_get(op->ptr, "sharpness"); int i; - sharp = (sharp * M_PI) / 180.0; + sharp = (sharp * (float)M_PI) / 180.0f; BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { BM_elem_flag_disable(f, BM_ELEM_TAG); diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index 36ce610c64b..a86a274eb70 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -279,7 +279,7 @@ static void vtx_slide_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) /* Get 3d view */ View3D *view3d = CTX_wm_view3d(C); const float outline_w = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.8f; - const float pt_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5; + const float pt_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f; int i = 0; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index c6b899bfd37..524ee029339 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2346,7 +2346,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) if (!BM_elem_flag_test(ev, BM_ELEM_HIDDEN)) { switch (mode) { case -1: /* aligned */ - if (fabs(ev->co[axis] - value) < limit) + if (fabsf(ev->co[axis] - value) < limit) BM_vert_select_set(em->bm, ev, TRUE); break; case 0: /* neg */ @@ -2593,21 +2593,21 @@ static float bm_edge_seg_isect(BMEdge *e, CutCurve *c, int len, char mode, m1 = MAXSLOPE; b1 = x12; } - x2max = MAX2(x21, x22) + 0.001; /* prevent missed edges */ - x2min = MIN2(x21, x22) - 0.001; /* due to round off error */ - y2max = MAX2(y21, y22) + 0.001; - y2min = MIN2(y21, y22) - 0.001; + x2max = MAX2(x21, x22) + 0.001f; /* prevent missed edges */ + x2min = MIN2(x21, x22) - 0.001f; /* due to round off error */ + y2max = MAX2(y21, y22) + 0.001f; + y2min = MIN2(y21, y22) - 0.001f; /* Found an intersect, calc intersect point */ if (m1 == m2) { /* co-incident lines */ /* cut at 50% of overlap area */ x1max = MAX2(x11, x12); x1min = MIN2(x11, x12); - xi = (MIN2(x2max, x1max) + MAX2(x2min, x1min)) / 2.0; + xi = (MIN2(x2max, x1max) + MAX2(x2min, x1min)) / 2.0f; y1max = MAX2(y11, y12); y1min = MIN2(y11, y12); - yi = (MIN2(y2max, y1max) + MAX2(y2min, y1min)) / 2.0; + yi = (MIN2(y2max, y1max) + MAX2(y2min, y1min)) / 2.0f; } else if (m2 == MAXSLOPE) { xi = x22; @@ -4034,7 +4034,7 @@ static int edbm_noise_exec(bContext *C, wmOperator *op) if (tex->type == TEX_STUCCI) { float b2, vec[3]; - float ofs = tex->turbul / 200.0; + float ofs = tex->turbul / 200.0f; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { b2 = BLI_hnoise(tex->noisesize, eve->co[0], eve->co[1], eve->co[2]); @@ -4121,7 +4121,7 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op) w[i] = s; ftot += s; - df *= 2.0; + df *= 2.0f; } mul_vn_fl(w, recursion, 1.0f / (float)ftot); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 2ebeb9ca224..a17f335091b 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -671,7 +671,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, int do_face_idx sub_v2_v2v2(uvdiff, uv2, uv); - if (fabs(uvdiff[0]) < limit[0] && fabs(uvdiff[1]) < limit[1]) { + if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1]) { if (lastv) lastv->next = next; else vlist = next; iterv->next = newvlist; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index fb9b012a31a..f611a985797 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -275,11 +275,11 @@ int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int laye else if (len > 2) { float fac = 0.0f, dfac = 1.0f / (float)len; - dfac *= M_PI * 2; + dfac *= (float)M_PI * 2.0f; for (i = 0; i < len; i++) { - fuvs[i][0] = 0.5f * sin(fac) + 0.5f; - fuvs[i][1] = 0.5f * cos(fac) + 0.5f; + fuvs[i][0] = 0.5f * sinf(fac) + 0.5f; + fuvs[i][1] = 0.5f * cosf(fac) + 0.5f; fac += dfac; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b4d5d2c1c79..acafe62150f 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1257,7 +1257,7 @@ static void vgroup_blend(Object *ob, const float fac) int i, dvert_tot = 0; const int def_nr = ob->actdef - 1; - BLI_assert(fac >= 0.0 && fac <= 1.0f); + BLI_assert(fac >= 0.0f && fac <= 1.0f); if (ob->type != OB_MESH) { return; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 772c114e6d6..2fa1e759e21 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -172,8 +172,8 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) int dx = x2 - x1; int dy = y2 - y1; - dx= copysign(ceil(0.3f*fabs(dx)), dx); - dy= copysign(ceil(0.3f*fabs(dy)), dy); + dx = copysign(ceilf(0.3f * fabsf(dx)), dx); + dy = copysign(ceilf(0.3f * fabsf(dy)), dy); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 4545c498fed..707d5b2aa7c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -207,8 +207,8 @@ void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float float strength; strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); - sculptdata->uv[i].uv[0] = (1.0 - strength) * sculptdata->uv[i].uv[0] + strength * (tmp_uvdata[i].p[0] - 0.5f * (tmp_uvdata[i].b[0] + tmp_uvdata[i].sum_b[0] / tmp_uvdata[i].ncounter)); - sculptdata->uv[i].uv[1] = (1.0 - strength) * sculptdata->uv[i].uv[1] + strength * (tmp_uvdata[i].p[1] - 0.5f * (tmp_uvdata[i].b[1] + tmp_uvdata[i].sum_b[1] / tmp_uvdata[i].ncounter)); + sculptdata->uv[i].uv[0] = (1.0f - strength) * sculptdata->uv[i].uv[0] + strength * (tmp_uvdata[i].p[0] - 0.5f * (tmp_uvdata[i].b[0] + tmp_uvdata[i].sum_b[0] / tmp_uvdata[i].ncounter)); + sculptdata->uv[i].uv[1] = (1.0f - strength) * sculptdata->uv[i].uv[1] + strength * (tmp_uvdata[i].p[1] - 0.5f * (tmp_uvdata[i].b[1] + tmp_uvdata[i].sum_b[1] / tmp_uvdata[i].ncounter)); for (element = sculptdata->uv[i].element; element; element = element->next) { MLoopUV *luv; @@ -271,8 +271,8 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul float strength; strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); - sculptdata->uv[i].uv[0] = (1.0 - strength) * sculptdata->uv[i].uv[0] + strength * tmp_uvdata[i].p[0]; - sculptdata->uv[i].uv[1] = (1.0 - strength) * sculptdata->uv[i].uv[1] + strength * tmp_uvdata[i].p[1]; + sculptdata->uv[i].uv[0] = (1.0f - strength) * sculptdata->uv[i].uv[0] + strength * tmp_uvdata[i].p[0]; + sculptdata->uv[i].uv[1] = (1.0f - strength) * sculptdata->uv[i].uv[1] + strength * tmp_uvdata[i].p[1]; for (element = sculptdata->uv[i].element; element; element = element->next) { MLoopUV *luv; @@ -347,8 +347,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event, strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); normalize_v2(diff); - sculptdata->uv[i].uv[0] -= strength * diff[0] * 0.001; - sculptdata->uv[i].uv[1] -= strength * diff[1] * 0.001; + sculptdata->uv[i].uv[0] -= strength * diff[0] * 0.001f; + sculptdata->uv[i].uv[1] -= strength * diff[1] * 0.001f; for (element = sculptdata->uv[i].element; element; element = element->next) { MLoopUV *luv; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ec383e1dbdb..e1828bbef32 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -313,15 +313,15 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** double scalar = bUnit_GetScaler(usys, i); dx_scalar = dx * scalar / unit->scale_length; - if (dx_scalar < (GRID_MIN_PX * 2)) + if (dx_scalar < (GRID_MIN_PX * 2.0)) continue; /* Store the smallest drawn grid size units name so users know how big each grid cell is */ if (*grid_unit == NULL) { *grid_unit = bUnit_GetNameDisplay(usys, i); - rv3d->gridview = (scalar * v3d->grid) / unit->scale_length; + rv3d->gridview = (float)((scalar * v3d->grid) / (double)unit->scale_length); } - blend_fac = 1 - ((GRID_MIN_PX * 2) / dx_scalar); + blend_fac = 1.0f - ((GRID_MIN_PX * 2.0f) / (float)dx_scalar); /* tweak to have the fade a bit nicer */ blend_fac = (blend_fac * blend_fac) * 2.0f; @@ -355,7 +355,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } else { // start blending out - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6.0f)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); @@ -363,7 +363,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) - UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6)); + UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX * 6.0f)); drawgrid_draw(ar, wx, wy, x, y, dx); UI_ThemeColor(TH_GRID); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 44fee7d663d..39cda3efd93 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -696,7 +696,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) if (dot_v3v3(xaxis, m_inv[0]) < 0) { negate_v3(xaxis); } - fac = angle_normalized_v3v3(zvec_global, m_inv[2]) / M_PI; + fac = angle_normalized_v3v3(zvec_global, m_inv[2]) / (float)M_PI; fac = fabsf(fac - 0.5f) * 2; fac = fac * fac; interp_v3_v3v3(xaxis, xaxis, m_inv[0], fac); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 8a211c6a22e..f106fcc268e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -2199,7 +2199,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f int bbsel; CircleSelectUserData data; - bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0)); + bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ vc->em = BMEdit_FromObject(vc->obedit); @@ -2250,7 +2250,7 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, const int m if (me) { bm_vertoffs = me->totpoly + 1; /* max index array */ - /* bbsel= */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0)); + /* bbsel= */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); edbm_backbuf_check_and_select_tfaces(me, select == LEFTMOUSE); EDBM_backbuf_free(); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5ee3e4bb96d..599d4a559ed 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3694,9 +3694,9 @@ void flushTransGraphData(TransInfo *t) switch (sipo->autosnap) { case SACTSNAP_FRAME: /* snap to nearest frame (or second if drawing seconds) */ if (sipo->flag & SIPO_DRAWTIME) - td2d->loc[0]= (float)(floor((td2d->loc[0]/secf) + 0.5f) * secf); + td2d->loc[0] = (float)(floorf((td2d->loc[0]/secf) + 0.5f) * secf); else - td2d->loc[0]= (float)(floor(td2d->loc[0]+0.5f)); + td2d->loc[0] = (float)(floorf(td2d->loc[0]+0.5f)); break; case SACTSNAP_MARKER: /* snap to nearest marker */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 0bf02d1a2bf..bea1002b5c6 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -204,16 +204,16 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) } if (axis & 2) { - if (fabs(iloc[1])<=tolerance[1] || - loc[1]*iloc[1]<0.0f) + if (fabsf(iloc[1]) <= tolerance[1] || + loc[1] * iloc[1]<0.0f) { loc[1]= 0.0f; clip = 1; } } if (axis & 4) { - if (fabs(iloc[2])<=tolerance[2] || - loc[2]*iloc[2]<0.0f) + if (fabsf(iloc[2]) <= tolerance[2] || + loc[2] * iloc[2] < 0.0f) { loc[2]= 0.0f; clip = 1; @@ -541,12 +541,12 @@ static void recalcData_nla(TransInfo *t) switch (snla->autosnap) { case SACTSNAP_FRAME: /* snap to nearest frame/time */ if (snla->flag & SNLA_DRAWTIME) { - tdn->h1[0]= (float)( floor((tdn->h1[0]/secf) + 0.5f) * secf ); - tdn->h2[0]= (float)( floor((tdn->h2[0]/secf) + 0.5f) * secf ); + tdn->h1[0] = (float)(floor(((double)tdn->h1[0] / secf) + 0.5) * secf); + tdn->h2[0] = (float)(floor(((double)tdn->h2[0] / secf) + 0.5) * secf); } else { - tdn->h1[0]= (float)( floor(tdn->h1[0]+0.5f) ); - tdn->h2[0]= (float)( floor(tdn->h2[0]+0.5f) ); + tdn->h1[0] = floorf(tdn->h1[0] + 0.5f); + tdn->h2[0] = floorf(tdn->h2[0] + 0.5f); } break; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 467e3dc600e..0f0d1cc8344 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -199,17 +199,17 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2]; mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3]; - distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; + distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length: 0.0; } else { int mdx, mdy; mdx = mval[0] - data[2]; mdy = mval[1] - data[3]; - distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f; + distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length: 0.0; } - output[0] = (float)((length != 0.0f)? distance / length: 0.0f); + output[0] = (length != 0.0) ? (double)(distance / length) : 0.0f; } } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index fb7e2254e45..a90f8253654 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -855,7 +855,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glDisable(GL_BLEND); /* draw vert preview */ - glPointSize(pointsize * 2.0); + glPointSize(pointsize * 2.0f); UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE); glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_stitchable); glDrawArrays(GL_POINTS, 0, stitch_preview->num_stitchable); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 1073369a36d..b515f30e150 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -799,9 +799,9 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); if (penalty && uvedit_uv_select_test(em, scene, l)) - dist = fabs(co[0] - luv->uv[0]) + penalty[0] + fabs(co[1] - luv->uv[1]) + penalty[1]; + dist = fabsf(co[0] - luv->uv[0]) + penalty[0] + fabsf(co[1] - luv->uv[1]) + penalty[1]; else - dist = fabs(co[0] - luv->uv[0]) + fabs(co[1] - luv->uv[1]); + dist = fabsf(co[0] - luv->uv[0]) + fabsf(co[1] - luv->uv[1]); if (dist <= mindist) { if (dist == mindist) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 9474ae95c34..b30821dc56a 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -257,8 +257,8 @@ static void stitch_uv_rotate(float rotation, float medianPoint[2], float uv[2]) uv[0] -= medianPoint[0]; uv[1] -= medianPoint[1]; - uv_rotation_result[0] = cos(rotation) * uv[0] - sin(rotation) * uv[1]; - uv_rotation_result[1] = sin(rotation) * uv[0] + cos(rotation) * uv[1]; + uv_rotation_result[0] = cosf(rotation) * uv[0] - sinf(rotation) * uv[1]; + uv_rotation_result[1] = sinf(rotation) * uv[0] + cosf(rotation) * uv[1]; uv[0] = uv_rotation_result[0] + medianPoint[0]; uv[1] = uv_rotation_result[1] + medianPoint[1]; @@ -286,8 +286,8 @@ static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_it l_iter = element_iter->l; luv_iter = CustomData_bmesh_get(&state->em->bm->ldata, l_iter->head.data, CD_MLOOPUV); - if (fabs(luv_orig->uv[0] - luv_iter->uv[0]) < limit && - fabs(luv_orig->uv[1] - luv_iter->uv[1]) < limit) + if (fabsf(luv_orig->uv[0] - luv_iter->uv[0]) < limit && + fabsf(luv_orig->uv[1] - luv_iter->uv[1]) < limit) { return 1; } @@ -403,7 +403,7 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta edgecos = uv1[0] * uv2[0] + uv1[1] * uv2[1]; edgesin = uv1[0] * uv2[1] - uv2[0] * uv1[1]; - rotation = (edgesin > 0) ? acos(MAX2(-1.0, MIN2(1.0, edgecos))) : -acos(MAX2(-1.0, MIN2(1.0, edgecos))); + rotation = (edgesin > 0.0f) ? acosf(MAX2(-1.0f, MIN2(1.0f, edgecos))) : -acosf(MAX2(-1.0f, MIN2(1.0f, edgecos))); island_stitch_data[element1->island].num_rot_elements++; island_stitch_data[element1->island].rotation += rotation; @@ -412,7 +412,7 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta static void stitch_island_calculate_vert_rotation(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data) { - float edgecos = 1, edgesin = 0; + float edgecos = 1.0f, edgesin = 0.0f; int index; UvElement *element_iter; float rotation = 0; @@ -441,12 +441,12 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat negate_v2_v2(normal, state->normals + index_tmp2 * 2); edgecos = dot_v2v2(normal, state->normals + index_tmp1 * 2); edgesin = cross_v2v2(normal, state->normals + index_tmp1 * 2); - rotation += (edgesin > 0) ? acos(edgecos) : -acos(edgecos); + rotation += (edgesin > 0.0f) ? acosf(edgecos) : -acosf(edgecos); } } if (state->midpoints) - rotation /= 2.0; + rotation /= 2.0f; island_stitch_data[element->island].num_rot_elements++; island_stitch_data[element->island].rotation += rotation; } @@ -1364,7 +1364,7 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) case PADPLUSKEY: case WHEELUPMOUSE: if (event->alt) { - stitch_state->limit_dist += 0.01; + stitch_state->limit_dist += 0.01f; if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } @@ -1377,8 +1377,8 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) case PADMINUS: case WHEELDOWNMOUSE: if (event->alt) { - stitch_state->limit_dist -= 0.01; - stitch_state->limit_dist = MAX2(0.01, stitch_state->limit_dist); + stitch_state->limit_dist -= 0.01f; + stitch_state->limit_dist = MAX2(0.01f, stitch_state->limit_dist); if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 743869e82cc..b2c7dd59f1d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1027,7 +1027,7 @@ static void correct_uv_aspect(BMEditMesh *em) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - luv->uv[0] = ((luv->uv[0] - 0.5) * scale) + 0.5; + luv->uv[0] = ((luv->uv[0] - 0.5f) * scale) + 0.5f; } } } @@ -1040,7 +1040,7 @@ static void correct_uv_aspect(BMEditMesh *em) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - luv->uv[1] = ((luv->uv[1] - 0.5) * scale) + 0.5; + luv->uv[1] = ((luv->uv[1] - 0.5f) * scale) + 0.5f; } } } diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 1737f3b79e6..06eefc36723 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -133,9 +133,8 @@ typedef struct Library { * some cases its useful to access the absolute one, * This is set on file read. * Use BKE_library_filepath_set() rather than - * setting 'name' directly and it will be kepk in + * setting 'name' directly and it will be kept in * sync - campbell */ - int tot, pad; /* tot, idblock and filedata are only fo read and write */ struct Library *parent; /* set for indirectly linked libs, used in the outliner and while reading */ } Library; @@ -151,7 +150,7 @@ typedef struct PreviewImage { unsigned int h[2]; short changed[2]; short changed_timestamp[2]; - unsigned int * rect[2]; + unsigned int *rect[2]; } PreviewImage; /** @@ -255,4 +254,3 @@ typedef struct PreviewImage { #endif #endif - diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index de2c9919df0..dfc70e5bd66 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -92,8 +92,8 @@ typedef struct Image { unsigned int bindcode; /* only for current image... */ unsigned int *repbind; /* for repeat of parts of images */ - struct PackedFile * packedfile; - struct PreviewImage * preview; + struct PackedFile *packedfile; + struct PreviewImage *preview; /* game engine tile animation */ float lastupdate; @@ -141,4 +141,3 @@ typedef struct Image { #define IMA_GEN_FLOAT 1 #endif - diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 85adf524717..5eb4e2190e4 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -265,7 +265,7 @@ static void rna_trackingCamera_focal_mm_set(PointerRNA *ptr, float value) if (clip->lastsize[0]) value = clip->lastsize[0]*value/camera->sensor_width; - if (value >= 0.0001) + if (value >= 0.0001f) camera->focal = value; } diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 711c7e6e4ff..8d6295ee6d4 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -113,7 +113,7 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) static void VertexIt_Step(CSG_IteratorPtr it) { VertexIt * iterator = (VertexIt *)it; - iterator->pos ++; + iterator->pos++; } static void VertexIt_Reset(CSG_IteratorPtr it) @@ -207,7 +207,7 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) static void FaceIt_Step(CSG_IteratorPtr it) { FaceIt * face_it = (FaceIt *)it; - face_it->pos ++; + face_it->pos++; } static void FaceIt_Reset(CSG_IteratorPtr it) @@ -441,7 +441,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mat_nr = 0; for (a = 0; a < ob1->totcol; a++) { - if (give_current_material(ob1, a+1) == orig_mat) { + if (give_current_material(ob1, a + 1) == orig_mat) { mat_nr = a; break; } @@ -601,7 +601,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) dm_select = mesh_create_derived_view(scene, ob_select, 0); // no modifiers in editmode ?? maxmat= ob->totcol + ob_select->totcol; - mat= (Material**)MEM_mallocN(sizeof(Material*)*maxmat, "NewBooleanMeshMat"); + mat = (Material **)MEM_mallocN(sizeof(Material *) * maxmat, "NewBooleanMeshMat"); /* put some checks in for nice user feedback */ if (dm == NULL || dm_select == NULL) { @@ -632,7 +632,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) /* add materials to object */ for (a = 0; a < totmat; a++) - assign_material(ob_new, mat[a], a+1); + assign_material(ob_new, mat[a], a + 1); MEM_freeN(mat); diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index d5d8439c749..1bc23ab5040 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -113,7 +113,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Ob CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); if (coll_clmd) { DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Cloth Collision"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Cloth Collision"); } } } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 83a366815de..9636104cb06 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -117,7 +117,7 @@ static void deformVerts(ModifierData *md, Object *ob, /* if possible use/create DerivedMesh */ if (derivedData) dm = CDDM_copy(derivedData); - else if (ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob); + else if (ob->type == OB_MESH) dm = CDDM_from_mesh(ob->data, ob); if (!ob->pd) { printf("CollisionModifier deformVerts: Should not happen!\n"); @@ -138,7 +138,7 @@ static void deformVerts(ModifierData *md, Object *ob, numverts = dm->getNumVerts (dm); - if ((current_time > collmd->time_xnew)|| (BKE_ptcache_get_continue_physics())) { + if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; // check if mesh has changed @@ -148,7 +148,7 @@ static void deformVerts(ModifierData *md, Object *ob, if (collmd->time_xnew == -1000) { /* first time */ collmd->x = dm->dupVertArray(dm); // frame start position - for ( i = 0; i < numverts; i++ ) { + for (i = 0; i < numverts; i++) { // we save global positions mul_m4_v3(ob->obmat, collmd->x[i].co); } diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index f55faf9c183..e1a8e221476 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -140,7 +140,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), /* we assume the decim_faces tells how much to reduce */ while (lod.face_num > numTris*dmd->percent) { - if ( LOD_CollapseEdge(&lod)==0) break; + if ( LOD_CollapseEdge(&lod) == 0) break; } if (lod.vertex_num>2) { @@ -160,7 +160,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), if (lod.vertex_num>2) { mface = CDDM_get_tessfaces(result); - for (a=0; av1 = tri[0]; diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 70294588fd4..4d9b8de061e 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -189,7 +189,7 @@ static void displaceModifier_do( modifier_init_texture(dmd->modifier.scene, dmd->texture); - for (i = 0; i < numVerts; ++i) { + for (i = 0; i < numVerts; i++) { TexResult texres; float delta = 0, strength = dmd->strength; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index def02081be8..3e399707040 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -64,7 +64,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj BMEditMesh *em; BMIter iter; BMEdge *e; - float threshold = cos((emd->split_angle + 0.00001) * M_PI / 180.0); + float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f); em = DM_to_editbmesh(dm, NULL, FALSE); bm = em->bm; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index b115e5bb244..ef3a6d8217e 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -122,7 +122,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, DagNode *curNode = dag_get_node(forest, hmd->object); if (hmd->subtarget[0]) - dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, "Hook Modifier"); + dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Hook Modifier"); else dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, "Hook Modifier"); } @@ -195,9 +195,9 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, for (j = 0; j < numVerts; j++) { if (origindex_ar[j] == *index_pt) { float *co = vertexCos[j]; - if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { + if ((fac = hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if (dvert) - fac *= defvert_find_weight(dvert+j, defgrp_index); + fac *= defvert_find_weight(dvert + j, defgrp_index); if (fac) { mul_v3_m4v3(vec, mat, co); @@ -210,12 +210,12 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } } else { /* missing dm or ORIGINDEX */ - for (i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) { + for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { if (*index_pt < numVerts) { float *co = vertexCos[*index_pt]; - if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { + if ((fac = hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { if (dvert) - fac *= defvert_find_weight(dvert+(*index_pt), defgrp_index); + fac *= defvert_find_weight(dvert + (*index_pt), defgrp_index); if (fac) { mul_v3_m4v3(vec, mat, co); @@ -227,13 +227,13 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } } else if (dvert) { /* vertex group hook */ - const float fac_orig= hmd->force; + const float fac_orig = hmd->force; for (i = 0; i < max_dvert; i++, dvert++) { float fac; float *co = vertexCos[i]; - if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { + if ((fac = hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) { fac *= defvert_find_weight(dvert, defgrp_index); if (fac) { mul_v3_m4v3(vec, mat, co); diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 32376acc553..a8f5f008e0c 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -407,7 +407,9 @@ ModifierTypeInfo modifierType_Mask = { /* structName */ "MaskModifierData", /* structSize */ sizeof(MaskModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh|eModifierTypeFlag_SupportsMapping|eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index aee8dd21903..1bcafc2918e 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -142,24 +142,24 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 size= mmd->dyngridsize; for (i=0; i<3; i++) { - gridvec[i]= (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; - ivec[i]= (int)gridvec[i]; - dvec[i]= gridvec[i] - ivec[i]; + gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; + ivec[i] = (int)gridvec[i]; + dvec[i] = gridvec[i] - ivec[i]; } for (i=0; i<8; i++) { - if (i & 1) { x= ivec[0]+1; wx= dvec[0]; } - else { x= ivec[0]; wx= 1.0f-dvec[0]; } + if (i & 1) { x = ivec[0] + 1; wx = dvec[0]; } + else { x = ivec[0]; wx = 1.0f - dvec[0]; } - if (i & 2) { y= ivec[1]+1; wy= dvec[1]; } - else { y= ivec[1]; wy= 1.0f-dvec[1]; } + if (i & 2) { y = ivec[1] + 1; wy = dvec[1]; } + else { y = ivec[1]; wy = 1.0f - dvec[1]; } - if (i & 4) { z= ivec[2]+1; wz= dvec[2]; } - else { z= ivec[2]; wz= 1.0f-dvec[2]; } + if (i & 4) { z = ivec[2] + 1; wz = dvec[2]; } + else { z = ivec[2]; wz = 1.0f - dvec[2]; } - CLAMP(x, 0, size-1); - CLAMP(y, 0, size-1); - CLAMP(z, 0, size-1); + CLAMP(x, 0, size - 1); + CLAMP(y, 0, size - 1); + CLAMP(z, 0, size - 1); a= x + y*size + z*size*size; weight= wx*wy*wz; @@ -314,7 +314,7 @@ static void meshdeformModifier_do( totweight= 0.0f; zero_v3(co); - for (a=offsets[b]; a 0.0f) { - mul_v3_fl(co, fac/totweight); + mul_v3_fl(co, fac / totweight); mul_m3_v3(icagemat, co); if (G.rt != 527) add_v3_v3(vertexCos[b], co); @@ -394,8 +394,8 @@ void modifier_mdef_compact_influences(ModifierData *md) } /* allocate bind influences */ - mmd->bindinfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefBindInfluence"); - mmd->bindoffsets= MEM_callocN(sizeof(int)*(totvert+1), "MDefBindOffset"); + mmd->bindinfluences = MEM_callocN(sizeof(MDefInfluence) * mmd->totinfluence, "MDefBindInfluence"); + mmd->bindoffsets = MEM_callocN(sizeof(int) * (totvert + 1), "MDefBindOffset"); /* write influences */ totinfluence= 0; @@ -417,8 +417,8 @@ void modifier_mdef_compact_influences(ModifierData *md) weight= weights[a + b*totcagevert]; if (weight > MESHDEFORM_MIN_INFLUENCE) { - mmd->bindinfluences[totinfluence].weight= weight/totweight; - mmd->bindinfluences[totinfluence].vertex= a; + mmd->bindinfluences[totinfluence].weight = weight / totweight; + mmd->bindinfluences[totinfluence].vertex = a; totinfluence++; } } diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 09924b5b0a4..2df0bd17eaf 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -231,10 +231,10 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, ml2 = ml + mp->loopstart + maxLoops; e = ml2[0].e; - for (j = 0; j < mp->totloop-1; j++) { - ml2[j].e = ml2[j+1].e; + for (j = 0; j < mp->totloop - 1; j++) { + ml2[j].e = ml2[j + 1].e; } - ml2[mp->totloop-1].e = e; + ml2[mp->totloop - 1].e = e; mp->loopstart += maxLoops; } diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index d3e54651eea..71839312cf5 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -478,7 +478,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, sub_v3_v3v3(e1, mvert[ml_next->v].co, mvert[ml->v].co); sub_v3_v3v3(e2, mvert[ml_prev->v].co, mvert[ml->v].co); - angle = M_PI - angle_normalized_v3v3(e1, e2); + angle = (float)M_PI - angle_normalized_v3v3(e1, e2); BLI_array_append(face_angles, angle); } @@ -644,13 +644,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, ml[j].v = ed->v1+numVerts; ml[j++].e = eidx+numEdges; - ml[j].v = ed->v2+numVerts; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v2]; + ml[j].v = ed->v2 + numVerts; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2]; } if (edge_origIndex) { - edge_origIndex[ml[j-3].e] = ORIGINDEX_NONE; - edge_origIndex[ml[j-1].e] = ORIGINDEX_NONE; + edge_origIndex[ml[j - 3].e] = ORIGINDEX_NONE; + edge_origIndex[ml[j - 1].e] = ORIGINDEX_NONE; } /* use the next material index if option enabled */ @@ -667,13 +667,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (crease_inner) { /* crease += crease_inner; without wrapping */ - unsigned char *cr= (unsigned char *)&(medge[numEdges + eidx].crease); - int tcr= *cr + crease_inner; - *cr= tcr > 255 ? 255 : tcr; + unsigned char *cr = (unsigned char *)&(medge[numEdges + eidx].crease); + int tcr = *cr + crease_inner; + *cr = tcr > 255 ? 255 : tcr; } #ifdef SOLIDIFY_SIDE_NORMALS - normal_quad_v3(nor, mvert[ml[j-4].v].co, mvert[ml[j-3].v].co, mvert[ml[j-2].v].co, mvert[ml[j-1].v].co); + normal_quad_v3(nor, mvert[ml[j - 4].v].co, + mvert[ml[j - 3].v].co, + mvert[ml[j - 2].v].co, + mvert[ml[j - 1].v].co); add_v3_v3(edge_vert_nos[ed->v1], nor); add_v3_v3(edge_vert_nos[ed->v2], nor); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 38a93091700..5ee8103630d 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -192,7 +192,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index); - if (wmd->curfalloff==NULL) /* should never happen, but bad lib linking could cause it */ + if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */ wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); invert_m4_m4(obinv, ob->obmat); @@ -229,9 +229,10 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, for (i = 0; i < numVerts; i++) { float *co = vertexCos[i]; - if (wmd->falloff_type==eWarp_Falloff_None || - ((fac=len_v3v3(co, mat_from[3])) < wmd->falloff_radius && (fac=(wmd->falloff_radius-fac)/wmd->falloff_radius)) ) { - + if (wmd->falloff_type == eWarp_Falloff_None || + ((fac = len_v3v3(co, mat_from[3])) < wmd->falloff_radius && + (fac = (wmd->falloff_radius-fac) / wmd->falloff_radius))) + { /* skip if no vert group found */ if (dvert && defgrp_index >= 0) { dv = &dvert[i]; diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index bcfdced4ffd..31cd20e7f97 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -112,7 +112,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3], dist_f,loc2trgt) \ schedule(static) #endif - for (i = 0; i < numVerts; ++i) { + for (i = 0; i < numVerts; i++) { float tmp_co[3]; /* Convert the vertex to tree coordinates. */ @@ -319,12 +319,12 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) { curNode = dag_get_node(forest, wmd->mask_tex_map_obj); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGProximity Modifier"); } if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) - dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGProximity Modifier"); } @@ -546,10 +546,10 @@ ModifierTypeInfo modifierType_WeightVGProximity = { /* structName */ "WeightVGProximityModifierData", /* structSize */ sizeof(WeightVGProximityModifierData), /* type */ eModifierTypeType_NonGeometrical, - /* flags */ eModifierTypeFlag_AcceptsMesh - |eModifierTypeFlag_SupportsMapping - |eModifierTypeFlag_SupportsEditmode - |eModifierTypeFlag_UsesPreview, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, From 48ead2736643cf0327b9472cfd05042a58f9d9b0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 23:15:01 +0000 Subject: [PATCH 36/88] Camera tracking: switch dopesheet information to lazy calculation All operators which changes tracking data now just tags dopsheet as outdated, actual re-calculaiton of happens only when this information is actually needed (like on dopesheet draw). This makes things a bit faster when there's no dopesheet visible in current screen and also makes it much easier to update dopesheet using dependency graph. Also renamed dopesheet_sort_order to dopesheet_sort_method in rna and internal stuff which makes much more sense and also correlated with naming in file browser. --- release/scripts/startup/bl_ui/space_clip.py | 2 +- source/blender/blenkernel/BKE_tracking.h | 4 +- source/blender/blenkernel/intern/depsgraph.c | 5 + source/blender/blenkernel/intern/tracking.c | 91 +++++++++++-------- source/blender/blenloader/intern/readfile.c | 20 +--- source/blender/blenloader/intern/writefile.c | 15 --- source/blender/editors/include/ED_clip.h | 2 - .../blender/editors/space_clip/clip_editor.c | 8 -- .../blender/editors/space_clip/clip_utils.c | 4 +- .../blender/editors/space_clip/space_clip.c | 4 +- .../blender/editors/space_clip/tracking_ops.c | 33 +++---- source/blender/makesdna/DNA_tracking_types.h | 4 +- source/blender/makesrna/intern/rna_space.c | 4 +- 13 files changed, 90 insertions(+), 106 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index f7ad69a046c..bd3f087e38a 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -86,7 +86,7 @@ class CLIP_HT_header(Header): if sc.view == 'DOPESHEET': layout.label(text="Sort by:") - layout.prop(sc, "dopesheet_sort_order", text="") + layout.prop(sc, "dopesheet_sort_method", text="") layout.prop(sc, "invert_dopesheet_sort", text="Invert") layout.template_running_jobs() diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 1432dc151d0..0782396dbae 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -165,8 +165,8 @@ void BKE_tracking_select_track(struct ListBase *tracksbase, struct MovieTracking void BKE_tracking_deselect_track(struct MovieTrackingTrack *track, int area); /* Dopesheet */ -void BKE_tracking_update_dopesheet(struct MovieTracking *tracking); -void BKE_tracking_dopesheet_sort(struct MovieTracking *tracking, int sort_order, int inverse); +void BKE_tracking_dopesheet_tag_update(struct MovieTracking *tracking); +void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_method, int inverse); #define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index d8cdd728c16..75e22195c6a 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -72,6 +72,7 @@ #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_tracking.h" #include "BKE_utildefines.h" #include "depsgraph_private.h" @@ -2580,6 +2581,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) } if (idtype == ID_MC) { + MovieClip *clip = (MovieClip *) id; + + BKE_tracking_dopesheet_tag_update(&clip->tracking); + for (obt=bmain->object.first; obt; obt= obt->id.next) { bConstraint *con; for (con = obt->constraints.first; con; con=con->next) { diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index bb4a7783c82..be3bda4b625 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1376,7 +1376,7 @@ void BKE_tracking_sync(MovieTrackingContext *context) context->sync_frame = newframe; - BKE_tracking_update_dopesheet(tracking); + tracking->dopesheet.ok = FALSE; } void BKE_tracking_sync_user(MovieClipUser *user, MovieTrackingContext *context) @@ -3196,13 +3196,59 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel) } } -void BKE_tracking_update_dopesheet(MovieTracking *tracking) +static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse) +{ + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + + if (dopesheet->sort_method == sort_method && dopesheet->sort_inverse == inverse) + return; + + if (inverse) { + if (sort_method == TRACK_SORT_NAME) { + BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort); + } + else if (sort_method == TRACK_SORT_LONGEST) { + BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort); + } + else if (sort_method == TRACK_SORT_TOTAL) { + BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort); + } + } + else { + if (sort_method == TRACK_SORT_NAME) { + BLI_sortlist(&dopesheet->channels, channels_alpha_sort); + } + else if (sort_method == TRACK_SORT_LONGEST) { + BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort); + } + else if (sort_method == TRACK_SORT_TOTAL) { + BLI_sortlist(&dopesheet->channels, channels_total_track_sort); + } + } + + dopesheet->sort_method = sort_method; + dopesheet->sort_inverse = inverse; +} + +void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking) +{ + MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; + + dopesheet->ok = FALSE; +} + +void BKE_tracking_dopesheet_update(MovieTracking *tracking, int sort_method, int inverse) { MovieTrackingObject *object = BKE_tracking_active_object(tracking); MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; MovieTrackingTrack *track; ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object); + if (dopesheet->ok) { + tracking_dopesheet_sort(tracking, sort_method, inverse); + return; + } + tracking_dopesheet_free(dopesheet); for (track = tracksbase->first; track; track = track->next) { @@ -3219,40 +3265,9 @@ void BKE_tracking_update_dopesheet(MovieTracking *tracking) } } - dopesheet->sort_order = TRACK_SORT_NONE; - dopesheet->sort_inverse = -1; -} - -void BKE_tracking_dopesheet_sort(MovieTracking *tracking, int sort_order, int inverse) -{ - MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; - - if (dopesheet->sort_order == sort_order && dopesheet->sort_inverse == inverse) - return; - - if (inverse) { - if (sort_order == TRACK_SORT_NAME) { - BLI_sortlist(&dopesheet->channels, channels_alpha_inverse_sort); - } - else if (sort_order == TRACK_SORT_LONGEST) { - BLI_sortlist(&dopesheet->channels, channels_longest_segment_inverse_sort); - } - else if (sort_order == TRACK_SORT_TOTAL) { - BLI_sortlist(&dopesheet->channels, channels_total_track_inverse_sort); - } - } - else { - if (sort_order == TRACK_SORT_NAME) { - BLI_sortlist(&dopesheet->channels, channels_alpha_sort); - } - else if (sort_order == TRACK_SORT_LONGEST) { - BLI_sortlist(&dopesheet->channels, channels_longest_segment_sort); - } - else if (sort_order == TRACK_SORT_TOTAL) { - BLI_sortlist(&dopesheet->channels, channels_total_track_sort); - } - } - - dopesheet->sort_order = sort_order; - dopesheet->sort_inverse = inverse; + dopesheet->sort_method = TRACK_SORT_NONE; + + tracking_dopesheet_sort(tracking, sort_method, inverse); + + dopesheet->ok = TRUE; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index afc4989f620..df71a9f6494 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6170,21 +6170,6 @@ static void direct_link_movieTracks(FileData *fd, ListBase *tracksbase) } } -static void direct_link_movieDopesheet(FileData *fd, MovieTrackingDopesheet *dopesheet) -{ - MovieTrackingDopesheetChannel *channel; - - link_list(fd, &dopesheet->channels); - - channel = dopesheet->channels.first; - while (channel) { - channel->track = newdataadr(fd, channel->track); - channel->segments = newdataadr(fd, channel->segments); - - channel = channel->next; - } -} - static void direct_link_movieclip(FileData *fd, MovieClip *clip) { MovieTracking *tracking= &clip->tracking; @@ -6211,6 +6196,9 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip) clip->tracking.stabilization.scaleibuf= NULL; clip->tracking.stabilization.rot_track= newdataadr(fd, clip->tracking.stabilization.rot_track); + clip->tracking.dopesheet.ok = 0; + clip->tracking.dopesheet.channels.first = clip->tracking.dopesheet.channels.last = NULL; + link_list(fd, &tracking->objects); object= tracking->objects.first; @@ -6220,8 +6208,6 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip) object= object->next; } - - direct_link_movieDopesheet(fd, &clip->tracking.dopesheet); } static void lib_link_movieclip(FileData *fd, Main *main) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2199259a322..14c8d42654c 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2679,19 +2679,6 @@ static void write_movieTracks(WriteData *wd, ListBase *tracks) } } -static void write_movieDopesheet(WriteData *wd, MovieTrackingDopesheet *dopesheet) -{ - MovieTrackingDopesheetChannel *channel; - - channel = dopesheet->channels.first; - while (channel) { - writestruct(wd, DATA, "MovieTrackingDopesheetChannel", 1, channel); - writedata(wd, DATA, 2 * channel->tot_segment * sizeof(int), channel->segments); - - channel = channel->next; - } -} - static void write_movieReconstruction(WriteData *wd, MovieTrackingReconstruction *reconstruction) { if (reconstruction->camnr) @@ -2724,8 +2711,6 @@ static void write_movieclips(WriteData *wd, ListBase *idbase) object= object->next; } - - write_movieDopesheet(wd, &tracking->dopesheet); } clip= clip->id.next; diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h index 03e7bd62a2c..302c2940fef 100644 --- a/source/blender/editors/include/ED_clip.h +++ b/source/blender/editors/include/ED_clip.h @@ -72,8 +72,6 @@ void ED_space_clip_free_texture_buffer(struct SpaceClip *sc); int ED_space_clip_show_trackedit(struct SpaceClip *sc); -void ED_space_clip_update_dopesheet(struct SpaceClip *sc); - /* clip_ops.c */ void ED_operatormacros_clip(void); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index c5c5628abb9..a5575cd125e 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -552,11 +552,3 @@ int ED_space_clip_show_trackedit(SpaceClip *sc) return FALSE; } - -void ED_space_clip_update_dopesheet(SpaceClip *sc) -{ - MovieClip *clip = sc->clip; - MovieTracking *tracking = &clip->tracking; - - BKE_tracking_update_dopesheet(tracking); -} diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index c8ba8be7eae..d45fe834fac 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -194,11 +194,11 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie if (update_stab) { tracking->stabilization.ok = FALSE; - - DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); } + DAG_id_tag_update(&clip->id, 0); + if (has_bundle) WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 82f76efacaa..b92b45752ef 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1135,7 +1135,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) View2DScrollers *scrollers; short unit = 0; - BKE_tracking_dopesheet_sort(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -1194,7 +1194,7 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - BKE_tracking_dopesheet_sort(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 2c9b61ed1ef..2c1a6ade70a 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -95,8 +95,6 @@ static void add_marker(SpaceClip *sc, float x, float y) BKE_tracking_select_track(tracksbase, track, TRACK_AREA_ALL, 0); clip->tracking.act_track = track; - - ED_space_clip_update_dopesheet(sc); } static int add_marker_exec(bContext *C, wmOperator *op) @@ -176,8 +174,6 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) /* nothing selected now, unlock view so it can be scrolled nice again */ sc->flag &= ~SC_LOCK_SELECTION; - ED_space_clip_update_dopesheet(sc); - return OPERATOR_FINISHED; } @@ -229,8 +225,6 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) sc->flag &= ~SC_LOCK_SELECTION; } - ED_space_clip_update_dopesheet(sc); - return OPERATOR_FINISHED; } @@ -795,8 +789,9 @@ static int mouse_select(bContext *C, float co[2], int extend) sc->ylockof = 0.0f; } + BKE_tracking_dopesheet_tag_update(tracking); + WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); - ED_space_clip_update_dopesheet(sc); return OPERATOR_FINISHED; } @@ -868,8 +863,9 @@ static int border_select_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; - ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); rcti rect; rctf rectf; int change = FALSE, mode, extend; @@ -908,7 +904,7 @@ static int border_select_exec(bContext *C, wmOperator *op) } if (change) { - ED_space_clip_update_dopesheet(sc); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -956,8 +952,9 @@ static int circle_select_exec(bContext *C, wmOperator *op) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); ARegion *ar = CTX_wm_region(C); + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; - ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); int x, y, radius, width, height, mode, change = FALSE; float zoomx, zoomy, offset[2], ellipse[2]; @@ -994,7 +991,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) } if (change) { - ED_space_clip_update_dopesheet(sc); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -1033,9 +1030,10 @@ static int select_all_exec(bContext *C, wmOperator *op) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track = NULL; /* selected track */ MovieTrackingMarker *marker; - ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); int action = RNA_enum_get(op->ptr, "action"); int framenr = sc->user.framenr; int has_selection = FALSE; @@ -1092,7 +1090,7 @@ static int select_all_exec(bContext *C, wmOperator *op) if (!has_selection) sc->flag &= ~SC_LOCK_SELECTION; - ED_space_clip_update_dopesheet(sc); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -1174,7 +1172,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) track = track->next; } - ED_space_clip_update_dopesheet(sc); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); @@ -2745,7 +2743,7 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) sc->flag &= ~SC_LOCK_SELECTION; } - BKE_tracking_update_dopesheet(tracking); + BKE_tracking_dopesheet_tag_update(tracking); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); @@ -2776,7 +2774,8 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip(sc); - ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); + MovieTracking *tracking = &clip->tracking; + ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track; track = tracksbase->first; @@ -2786,6 +2785,8 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) track = track->next; } + BKE_tracking_dopesheet_tag_update(tracking); + WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 4e2b3c46aa4..6bf059c7ecb 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -205,10 +205,12 @@ typedef struct MovieTrackingDopesheetChannel { } MovieTrackingDopesheetChannel; typedef struct MovieTrackingDopesheet { + int ok, pad; /* flag if dopesheet information is still relevant */ + ListBase channels; int tot_channel; - short sort_order; /* order in which tracks are stored */ + short sort_method; /* method to be used to sort tracks */ short sort_inverse; /* order of tracks is inverted */ } MovieTrackingDopesheet; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index bc2e1b7e1f3..51f5cdcda85 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3122,10 +3122,10 @@ static void rna_def_space_clip(BlenderRNA *brna) /* ** dopesheet ** */ /* dopesheet sort */ - prop = RNA_def_property(srna, "dopesheet_sort_order", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "dopesheet_sort_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dope_sort"); RNA_def_property_enum_items(prop, dope_sort_items); - RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Field used to sort channels in dopesheet view"); + RNA_def_property_ui_text(prop, "Dopesheet Sort Field", "Method to be used to sort channels in dopesheet view"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); /* invert_dopesheet_sort */ From 0fcf17fc72319bc52b793b2f6156a60aed31dc62 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 3 May 2012 23:39:42 +0000 Subject: [PATCH 37/88] Possible fix for #31054: cycles viewport rendering not working with CUDA for computation and ATI card for OpenGL. --- intern/cycles/device/device_cuda.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 0c08baae3ff..4bead82fe5a 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -172,10 +172,15 @@ public: CUresult result; - if(background) + if(background) { result = cuCtxCreate(&cuContext, 0, cuDevice); - else - result = cuGLCtxCreate(&cuContext, 0, cuDevice); + } + else { + if(cuGLCtxCreate(&cuContext, 0, cuDevice) != CUDA_SUCCESS) { + result = cuCtxCreate(&cuContext, 0, cuDevice); + background = true; + } + } if(cuda_error(result)) return; From 9a9924c79c71de6207e11145a4e360a2c91876f5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 23:41:28 +0000 Subject: [PATCH 38/88] Camera tracking: show disabled active track even if Show Disabled is switched off --- source/blender/blenkernel/BKE_tracking.h | 2 +- source/blender/editors/space_clip/clip_draw.c | 14 +++++++------- source/blender/editors/space_clip/tracking_ops.c | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 0782396dbae..817cb477aba 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -179,7 +179,7 @@ void BKE_tracking_dopesheet_update(struct MovieTracking *tracking, int sort_meth (((sc)->flag & SC_SHOW_MARKER_PATTERN) && TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) || \ (((sc)->flag & SC_SHOW_MARKER_SEARCH) && TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)))) -#define MARKER_VISIBLE(sc, marker) (((marker)->flag & MARKER_DISABLED)==0 || ((sc)->flag & SC_HIDE_DISABLED)==0) +#define MARKER_VISIBLE(sc, track, marker) (((marker)->flag & MARKER_DISABLED)==0 || ((sc)->flag & SC_HIDE_DISABLED)==0 || (sc->clip->tracking.act_track == track)) #define TRACK_CLEAR_UPTO 0 #define TRACK_CLEAR_REMAINED 1 diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 0d519f36ba3..6759743fabe 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -974,7 +974,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((track->flag & TRACK_HIDDEN)==0) { marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) + if (MARKER_VISIBLE(sc, track, marker)) count++; } @@ -991,7 +991,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((track->flag & TRACK_HIDDEN)==0) { marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { ED_clip_point_undistorted_pos(sc, marker->pos, fp); if (track == act_track) @@ -1023,7 +1023,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((track->flag & TRACK_HIDDEN)==0) { marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_outline(sc, track, marker, cur_pos, width, height); @@ -1048,7 +1048,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, int act = track == act_track; marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { if (!act) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); @@ -1069,7 +1069,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((act_track->flag & TRACK_HIDDEN)==0) { marker = BKE_tracking_get_marker(act_track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, act_track, marker)) { copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos); draw_marker_areas(sc, act_track, marker, cur_pos, width, height, 1, 1); @@ -1093,7 +1093,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((track->flag & TRACK_HIDDEN) == 0 && track->flag & TRACK_HAS_BUNDLE) { marker= BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { float npos[2]; copy_v4_v4(vec, track->bundle_pos); vec[3]=1; @@ -1143,7 +1143,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { int act = track == act_track; copy_v2_v2(cur_pos, fp ? fp : marker->pos); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 2c1a6ade70a..ff0e88a506e 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -723,7 +723,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas while (cur) { MovieTrackingMarker *marker = BKE_tracking_get_marker(cur, sc->user.framenr); - if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, marker)) { + if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) { float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX; d1= sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ @@ -888,7 +888,7 @@ static int border_select_exec(bContext *C, wmOperator *op) if ((track->flag & TRACK_HIDDEN) == 0) { MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); } @@ -980,7 +980,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) if ((track->flag & TRACK_HIDDEN) == 0) { MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); - if (MARKER_VISIBLE(sc, marker) && marker_inside_ellipse(marker, offset, ellipse)) { + if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); change = TRUE; @@ -1045,7 +1045,7 @@ static int select_all_exec(bContext *C, wmOperator *op) if (TRACK_VIEW_SELECTED(sc, track)) { marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { action = SEL_DESELECT; break; } @@ -1060,7 +1060,7 @@ static int select_all_exec(bContext *C, wmOperator *op) if ((track->flag & TRACK_HIDDEN)==0) { marker = BKE_tracking_get_marker(track, framenr); - if (MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, track, marker)) { switch (action) { case SEL_SELECT: track->flag |= SELECT; From e3535e884a08b631ee31964e0d3d62c976a004e4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 3 May 2012 23:47:39 +0000 Subject: [PATCH 39/88] Style cleanup: spaces around operators --- source/blender/blenkernel/intern/movieclip.c | 30 +++++----- source/blender/blenkernel/intern/tracking.c | 58 +++++++++---------- .../blender/editors/space_clip/clip_buttons.c | 14 ++--- source/blender/editors/space_clip/clip_draw.c | 26 ++++----- .../blender/editors/space_clip/clip_editor.c | 6 +- .../editors/space_clip/clip_graph_draw.c | 8 +-- .../editors/space_clip/clip_graph_ops.c | 10 ++-- source/blender/editors/space_clip/clip_ops.c | 10 ++-- .../blender/editors/space_clip/clip_utils.c | 2 +- .../blender/editors/space_clip/space_clip.c | 10 ++-- .../blender/editors/space_clip/tracking_ops.c | 8 +-- source/blender/imbuf/intern/moviecache.c | 8 +-- .../nodes/node_composite_moviedistortion.c | 6 +- 13 files changed, 98 insertions(+), 98 deletions(-) diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index d2219484ff4..7a279572738 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -155,7 +155,7 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name) /* movieclips always points to first image from sequence, * autoguess offset for now. could be something smarter in the future */ - offset= sequence_guess_offset(clip->name, strlen(head), numlen); + offset = sequence_guess_offset(clip->name, strlen(head), numlen); if (numlen) BLI_stringenc(name, head, tail, numlen, offset + framenr - 1); @@ -195,7 +195,7 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, { struct ImBuf *ibuf; char name[FILE_MAX]; - int loadflag, use_proxy= 0; + int loadflag, use_proxy = 0; use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL; if (use_proxy) { @@ -432,7 +432,7 @@ static MovieClip *movieclip_alloc(const char *name) clip = alloc_libblock(&G.main->movieclip, ID_MC, name); - clip->aspx = clip->aspy= 1.0f; + clip->aspx = clip->aspy = 1.0f; BKE_tracking_init_settings(&clip->tracking); @@ -660,7 +660,7 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u copy_v2_v2(cache->postprocessed.principal, camera->principal); copy_v3_v3(&cache->postprocessed.k1, &camera->k1); cache->postprocessed.undistoriton_used = TRUE; - postproc_ibuf= get_undistorted_ibuf(clip, NULL, ibuf); + postproc_ibuf = get_undistorted_ibuf(clip, NULL, ibuf); } else { cache->postprocessed.undistoriton_used = FALSE; @@ -704,14 +704,14 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *u /* try to obtain cached postprocessed frame first */ if (need_postprocessed_frame(user, flag, postprocess_flag)) { - ibuf= get_postprocessed_cached_frame(clip, user, flag, postprocess_flag); + ibuf = get_postprocessed_cached_frame(clip, user, flag, postprocess_flag); if (!ibuf) need_postprocess = TRUE; } if (!ibuf) - ibuf= get_imbuf_cache(clip, user, flag); + ibuf = get_imbuf_cache(clip, user, flag); if (!ibuf) { int use_sequence = FALSE; @@ -825,7 +825,7 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user stableibuf = BKE_tracking_stabilize(&clip->tracking, framenr, ibuf, tloc, &tscale, &tangle); - cache->stabilized.ibuf= stableibuf; + cache->stabilized.ibuf = stableibuf; copy_v2_v2(cache->stabilized.loc, tloc); @@ -862,7 +862,7 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float return NULL; if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { - MovieClipCache *cache= clip->cache; + MovieClipCache *cache = clip->cache; stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag); @@ -873,20 +873,20 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float copy_v2_v2(loc, cache->stabilized.loc); if (scale) - *scale= cache->stabilized.scale; + *scale = cache->stabilized.scale; if (angle) - *angle= cache->stabilized.angle; + *angle = cache->stabilized.angle; } else { if (loc) zero_v2(loc); if (scale) - *scale= 1.0f; + *scale = 1.0f; if (angle) - *angle= 0.0f; + *angle = 0.0f; stableibuf = ibuf; } @@ -1044,7 +1044,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip if (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) { int width, height; - float aspy= 1.0f / clip->tracking.camera.pixel_aspect; + float aspy = 1.0f / clip->tracking.camera.pixel_aspect; BKE_movieclip_get_size(clip, user, &width, &height); @@ -1058,14 +1058,14 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip } /* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */ - tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */, + tmpibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */, 1 /* anchor */, scopes->track_pos, NULL); if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); if (tmpibuf->rect) - scopes->track_preview= tmpibuf; + scopes->track_preview = tmpibuf; else IMB_freeImBuf(tmpibuf); } diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index be3bda4b625..f4335862629 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -107,7 +107,7 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) float max_pyramid_level_factor = 1.0; if (track->tracker == TRACKER_KLT) { - max_pyramid_level_factor= 1 << (track->pyramid_levels - 1); + max_pyramid_level_factor = 1 << (track->pyramid_levels - 1); } /* sort */ @@ -277,7 +277,7 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, MovieTrackingMarker *marker) { - MovieTrackingMarker *old_marker= NULL; + MovieTrackingMarker *old_marker = NULL; if (track->markersnr) old_marker = BKE_tracking_exact_marker(track, marker->framenr); @@ -313,7 +313,7 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) { - int a= 0; + int a = 0; while (amarkersnr) { if (track->markers[a].framenr == framenr) { @@ -464,7 +464,7 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio put_disabled_marker(track, &track->markers[track->markersnr-1], 0, 1); } else if (action == TRACK_CLEAR_UPTO) { - a= track->markersnr-1; + a = track->markersnr-1; while (a >= 0) { if (track->markers[a].framenr <= ref_frame) { @@ -786,7 +786,7 @@ static void tracks_map_get(TracksMap *map, int index, MovieTrackingTrack **track static void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customdata) { - MovieTrackingTrack new_track= *track; + MovieTrackingTrack new_track = *track; new_track.markers = MEM_dupallocN(new_track.markers); @@ -866,10 +866,10 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking) BLI_ghash_insert(map->hash, track, new_track); if (replace_sel) /* update current selection in clip */ - tracking->act_track= new_track; + tracking->act_track = new_track; if (replace_rot) /* update track used for rotation stabilization */ - tracking->stabilization.rot_track= new_track; + tracking->stabilization.rot_track = new_track; BLI_addtail(&tracks, new_track); } @@ -882,7 +882,7 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking) track->next = track->prev = NULL; BLI_addtail(&new_tracks, track); - track= next; + track = next; } /* now move all tracks which are currently operating and keep their names unique */ @@ -897,15 +897,15 @@ static void tracks_map_merge(TracksMap *map, MovieTracking *tracking) BLI_uniquename(&new_tracks, track, "Track", '.', offsetof(MovieTrackingTrack, name), sizeof(track->name)); - track= next; + track = next; } - *old_tracks= new_tracks; + *old_tracks = new_tracks; } static void tracks_map_free(TracksMap *map, void (*customdata_free) (void *customdata)) { - int i= 0; + int i = 0; BLI_ghash_free(map->hash, NULL, NULL); @@ -1021,7 +1021,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u * than the search size */ int level = MIN2(track->pyramid_levels, max_pyramid_levels); - if (track->tracker==TRACKER_KLT) { + if (track->tracker == TRACKER_KLT) { track_context.region_tracker = libmv_pyramidRegionTrackerNew(100, level, half_wnd, track->minimum_correlation); } @@ -1030,7 +1030,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u libmv_hybridRegionTrackerNew(100, half_wnd, track->minimum_correlation); } else if (track->tracker == TRACKER_SAD) { - track_context.region_tracker= libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); + track_context.region_tracker = libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); } } #endif @@ -1053,7 +1053,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u * - MCLIP_USE_PROXY_CUSTOM_DIR is needed because proxy/timecode files might * be stored in a different location * ignore all the rest possible flags for now */ - context->clip_flag = clip->flag&MCLIP_TIMECODE_FLAGS; + context->clip_flag = clip->flag & MCLIP_TIMECODE_FLAGS; context->user = *user; context->user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL; @@ -1321,7 +1321,7 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra MovieTrackingMarker *next_marker = NULL; if (next>=0 && nextmarkersnr) - next_marker= &track->markers[next]; + next_marker = &track->markers[next]; /* if next mrker is disabled, stop searching keyframe and use current frame as keyframe */ if (next_marker && next_marker->flag & MARKER_DISABLED) @@ -1498,7 +1498,7 @@ int BKE_tracking_next(MovieTrackingContext *context) } marker_new.flag |= MARKER_TRACKED; - marker_new.framenr= nextfra; + marker_new.framenr = nextfra; #pragma omp critical { @@ -1757,7 +1757,7 @@ static int get_refine_intrinsics_flags(MovieTracking *tracking, MovieTrackingObj static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase) { int tot = 0; - int frame1 = tracking->settings.keyframe1, frame2= tracking->settings.keyframe2; + int frame1 = tracking->settings.keyframe1, frame2 = tracking->settings.keyframe2; MovieTrackingTrack *track; track = tracksbase->first; @@ -1888,7 +1888,7 @@ void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context) #ifdef WITH_LIBMV static void solve_reconstruction_update_cb(void *customdata, double progress, const char *message) { - ReconstructProgressData *progressdata= customdata; + ReconstructProgressData *progressdata = customdata; if (progressdata->progress) { *progressdata->progress = progress; @@ -2004,7 +2004,7 @@ MovieTrackingTrack *BKE_tracking_named_track(MovieTracking *tracking, MovieTrack static int reconstruction_camera_index(MovieTrackingReconstruction *reconstruction, int framenr, int nearest) { - MovieReconstructedCamera *cameras= reconstruction->cameras; + MovieReconstructedCamera *cameras = reconstruction->cameras; int a = 0, d = 1; if (!reconstruction->camnr) @@ -2241,7 +2241,7 @@ MovieTrackingObject *BKE_tracking_get_camera_object(MovieTracking *tracking) if (object->flag & TRACKING_OBJECT_CAMERA) return object; - object= object->next; + object = object->next; } return NULL; @@ -2274,7 +2274,7 @@ MovieTrackingReconstruction *BKE_tracking_get_reconstruction(MovieTracking *trac void BKE_tracking_apply_intrinsics(MovieTracking *tracking, float co[2], float nco[2]) { - MovieTrackingCamera *camera= &tracking->camera; + MovieTrackingCamera *camera = &tracking->camera; #ifdef WITH_LIBMV double x, y; @@ -2334,7 +2334,7 @@ static int point_in_stroke(bGPDstroke *stroke, float x, float y) count++; } - prev= i; + prev = i; } return count % 2; @@ -2443,10 +2443,10 @@ MovieTrackingTrack *BKE_tracking_indexed_track(MovieTracking *tracking, int trac track = track->next; } - object= object->next; + object = object->next; } - *tracksbase_r= NULL; + *tracksbase_r = NULL; return NULL; } @@ -2670,8 +2670,8 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w if ((stab->flag & TRACKING_2D_STABILIZATION) == 0) { zero_v2(loc); - *scale= 1.0f; - *angle= 0.0f; + *scale = 1.0f; + *angle = 0.0f; return; } @@ -2790,10 +2790,10 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, copy_v2_v2(loc, tloc); if (scale) - *scale= tscale; + *scale = tscale; if (angle) - *angle= tangle; + *angle = tangle; return tmpibuf; } @@ -3026,7 +3026,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob if (track == tracking->act_track) tracking->act_track = NULL; - track= track->next; + track = track->next; } tracking_object_free(object); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index df6d713d82d..5761a285d72 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -371,9 +371,9 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P block = uiLayoutGetBlock(layout); if (cb->marker_flag & MARKER_DISABLED) - tip= "Marker is disabled at current frame"; + tip = "Marker is disabled at current frame"; else - tip= "Marker is enabled at current frame"; + tip = "Marker is enabled at current frame"; bt = uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip); uiButSetNFunc(bt, marker_update_cb, cb, NULL); @@ -393,7 +393,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P return; } - step= 100; + step = 100; digits = 2; sub_v2_v2v2(pat_dim, track->pat_max, track->pat_min); @@ -413,20 +413,20 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P cb->marker_flag = marker->flag; - block= uiLayoutAbsoluteBlock(layout); + block = uiLayoutAbsoluteBlock(layout); uiBlockSetHandleFunc(block, marker_block_handler, cb); uiBlockSetNFunc(block, marker_update_cb, cb, NULL); if (cb->marker_flag & MARKER_DISABLED) - tip= "Marker is disabled at current frame"; + tip = "Marker is disabled at current frame"; else - tip= "Marker is enabled at current frame"; + tip = "Marker is enabled at current frame"; uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &cb->marker_flag, 0, 0, 0, 0, tip); col = uiLayoutColumn(layout, 1); - uiLayoutSetActive(col, (cb->marker_flag&MARKER_DISABLED)==0); + uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0); block = uiLayoutAbsoluteBlock(col); uiBlockBeginAlign(block); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 6759743fabe..33bc67db8e4 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -310,7 +310,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin int count = sc->path_length; int i, a, b, curindex = -1; float path[102][2]; - int tiny = sc->flag&SC_SHOW_TINY_MARKER, framenr; + int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr; MovieTrackingMarker *marker; if (count == 0) @@ -354,7 +354,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin if (marker->framenr == i) { if (marker->framenr == sc->user.framenr) - curindex= b; + curindex = b; add_v2_v2v2(path[b++], marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]); @@ -416,7 +416,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height) { - int tiny = sc->flag&SC_SHOW_TINY_MARKER; + int tiny = sc->flag & SC_SHOW_TINY_MARKER; int show_search = FALSE; float px[2]; @@ -515,8 +515,8 @@ static void track_colors(MovieTrackingTrack *track, int act, float col[3], float static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height, int act, int sel) { - int tiny= sc->flag&SC_SHOW_TINY_MARKER; - int show_search= 0; + int tiny = sc->flag & SC_SHOW_TINY_MARKER; + int show_search = 0; float col[3], scol[3], px[2]; track_colors(track, act, col, scol); @@ -525,7 +525,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra px[1]= 1.0f / height / sc->zoom; /* marker position and offset position */ - if ((track->flag&SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) { + if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) { float pos[2]; rctf r; @@ -716,7 +716,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo float marker_pos[2], int outline, int sel, int act, int width, int height) { float x, y, dx, dy, patdx, patdy, searchdx, searchdy, tdx, tdy; - int tiny = sc->flag&SC_SHOW_TINY_MARKER; + int tiny = sc->flag & SC_SHOW_TINY_MARKER; float col[3], scol[3], px[2]; if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) @@ -849,7 +849,7 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra int width, int height, float zoomx, float zoomy) { char str[128] = {0}, state[64] = {0}; - float dx= 0.0f, dy = 0.0f, fontsize, pos[3]; + float dx = 0.0f, dy = 0.0f, fontsize, pos[3]; uiStyle *style = U.uistyles.first; int fontid = style->widget.uifont_id; @@ -1091,7 +1091,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; while (track) { if ((track->flag & TRACK_HIDDEN) == 0 && track->flag & TRACK_HAS_BUNDLE) { - marker= BKE_tracking_get_marker(track, framenr); + marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { float npos[2]; @@ -1216,7 +1216,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid if (a<2) ok = tpos[a%2] < val[a][a%2]; else - ok= tpos[a%2] > val[a][a%2]; + ok = tpos[a%2] > val[a][a%2]; if (ok) { copy_v2_v2(val[a], tpos); @@ -1282,7 +1282,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } if (sc->flag & SC_MANUAL_CALIBRATION && clip->gpd) { - bGPDlayer *layer= clip->gpd->layers.first; + bGPDlayer *layer = clip->gpd->layers.first; while (layer) { bGPDframe *frame = layer->frames.first; @@ -1314,7 +1314,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid npos[1] = stroke->points[i+1].y * height * aspy; len = len_v2v2(pos, npos); - steps= ceil(len/5.0f); + steps = ceil(len/5.0f); /* we want to distort only long straight lines */ if (stroke->totpoints == 2) { @@ -1359,7 +1359,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) { - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); ImBuf *ibuf; int width, height; float zoomx, zoomy; diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index a5575cd125e..bd34a51819c 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -86,7 +86,7 @@ int ED_space_clip_view_clip_poll(bContext *C) int ED_space_clip_tracking_poll(bContext *C) { - SpaceClip *sc= CTX_wm_space_clip(C); + SpaceClip *sc = CTX_wm_space_clip(C); if (sc && sc->clip) return ED_space_clip_show_trackedit(sc); @@ -139,7 +139,7 @@ void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *c old_clip = sc->clip; sc->clip = clip; - if (sc->clip && sc->clip->id.us==0) + if (sc->clip && sc->clip->id.us == 0) sc->clip->id.us = 1; if (screen) { @@ -262,7 +262,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) MovieClip *clip = ED_space_clip(sc); MovieTrackingTrack *track; int width, height, ok = FALSE; - ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); INIT_MINMAX2(min, max); diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 4825403fb4a..9f9bdcb6cd2 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -61,7 +61,7 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float hsize) { - static GLuint displist=0; + static GLuint displist = 0; /* initialize round circle shape */ if (displist == 0) { @@ -101,7 +101,7 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co copy_v3_v3(col, colors[coord]); - if (track==userdata) { + if (track == userdata) { col[3] = 1.0f; glLineWidth(2.0f); } @@ -126,7 +126,7 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, float val) { struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } *data = userdata; - int sel= 0, sel_flag; + int sel = 0, sel_flag; if (track != data->act_track) return; @@ -170,7 +170,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) glDisable(GL_BLEND); /* selected knot handles on top of curves */ - userdata.sel= TRUE; + userdata.sel = TRUE; clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL); } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 905aa2d11d4..efe48cd4b36 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -165,7 +165,7 @@ static void mouse_select_init_data(MouseSelectUserData *userdata, float *co) static int mouse_select_knot(bContext *C, float co[2], int extend) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; MovieTracking *tracking = &clip->tracking; @@ -328,7 +328,7 @@ static void border_select_cb(void *userdata, MovieTrackingTrack *UNUSED(track), data->change = TRUE; } else if (!data->extend) { - marker->flag&= ~MARKER_GRAPH_SEL; + marker->flag &= ~MARKER_GRAPH_SEL; } } @@ -489,7 +489,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceClip *sc = CTX_wm_space_clip(C); - MovieClip *clip= ED_space_clip(sc); + MovieClip *clip = ED_space_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_tracks(tracking); MovieTrackingTrack *act_track = BKE_tracking_active_track(tracking); @@ -651,9 +651,9 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) marker = &act_track->markers[a]; if (marker->flag & MARKER_GRAPH_SEL) { - if (action==0) + if (action == 0) marker->flag |= MARKER_DISABLED; - else if (action==1) + else if (action == 1) marker->flag &= ~MARKER_DISABLED; else marker->flag ^= MARKER_DISABLED; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index c8a5b487b65..06573136205 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -432,7 +432,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event) SpaceClip *sc = CTX_wm_space_clip(C); ViewZoomData *vpd; - op->customdata= vpd= MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); + op->customdata = vpd = MEM_callocN(sizeof(ViewZoomData), "ClipViewZoomData"); WM_cursor_modal(CTX_wm_window(C), BC_NSEW_SCROLLCURSOR); vpd->x = event->x; @@ -667,7 +667,7 @@ static int view_all_exec(bContext *C, wmOperator *op) ARegion *ar; int w, h, width, height; float aspx, aspy; - int fit_view= RNA_boolean_get(op->ptr, "fit_view"); + int fit_view = RNA_boolean_get(op->ptr, "fit_view"); float zoomx, zoomy; /* retrieve state */ @@ -680,7 +680,7 @@ static int view_all_exec(bContext *C, wmOperator *op) w = w * aspx; h = h * aspy; - /* check if the image will fit in the image with zoom==1 */ + /* check if the image will fit in the image with zoom == 1 */ width = ar->winrct.xmax - ar->winrct.xmin + 1; height = ar->winrct.ymax - ar->winrct.ymin + 1; @@ -878,7 +878,7 @@ typedef struct ProxyBuildJob { static void proxy_freejob(void *pjv) { - ProxyJob *pj= pjv; + ProxyJob *pj = pjv; MEM_freeN(pj); } @@ -957,7 +957,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog break; *do_update = TRUE; - *progress= ((float) cfra) / (efra - sfra); + *progress = ((float) cfra) / (efra - sfra); } if (distortion) diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index d45fe834fac..2545106d132 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -174,7 +174,7 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie int has_bundle = FALSE, update_stab = FALSE; - if (track==act_track) + if (track == act_track) tracking->act_track = NULL; if (track == stab->rot_track) { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index b92b45752ef..32a4a7d1f83 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -984,11 +984,11 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) ar->v2d.mask.ymax = winy; /* which part of the image space do we see? */ - x1= ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f; - y1= ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f; + x1 = ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f; + y1 = ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f; - x1-= sc->zoom * sc->xof; - y1-= sc->zoom * sc->yof; + x1 -= sc->zoom * sc->xof; + y1 -= sc->zoom * sc->yof; /* relative display right */ ar->v2d.cur.xmin = (ar->winrct.xmin - (float)x1) / sc->zoom; @@ -1156,7 +1156,7 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index ff0e88a506e..825415764f1 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -726,16 +726,16 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) { float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX; - d1= sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ + d1 = sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */ /* distance to pattern boundbox */ if (sc->flag & SC_SHOW_MARKER_PATTERN) - d2= dist_to_rect(co, marker->pos, cur->pat_min, cur->pat_max); + d2 = dist_to_rect(co, marker->pos, cur->pat_min, cur->pat_max); /* distance to search boundbox */ if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) - d3= dist_to_rect(co, marker->pos, cur->search_min, cur->search_max); + d3 = dist_to_rect(co, marker->pos, cur->search_min, cur->search_max); /* choose minimal distance. useful for cases of overlapped markers. */ dist = MIN3(d1, d2, d3); @@ -1553,7 +1553,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running tracking, remove handler and pass through */ - if (0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; /* running tracking */ diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 8b18be87b3c..485f593a8fb 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -44,7 +44,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -static MEM_CacheLimiterC *limitor= NULL; +static MEM_CacheLimiterC *limitor = NULL; typedef struct MovieCache { GHash *hash; @@ -113,7 +113,7 @@ static void check_unused_keys(MovieCache *cache) { GHashIterator *iter; - iter= BLI_ghashIterator_new(cache->hash); + iter = BLI_ghashIterator_new(cache->hash); while (!BLI_ghashIterator_isDone(iter)) { MovieCacheKey *key = BLI_ghashIterator_getKey(iter); MovieCacheItem *item = BLI_ghashIterator_getValue(iter); @@ -253,7 +253,7 @@ void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf) if (cache->points) { MEM_freeN(cache->points); - cache->points= NULL; + cache->points = NULL; } } @@ -321,7 +321,7 @@ void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_ GHashIterator *iter; iter = BLI_ghashIterator_new(cache->hash); - a= 0; + a = 0; while (!BLI_ghashIterator_isDone(iter)) { MovieCacheKey *key = BLI_ghashIterator_getKey(iter); MovieCacheItem *item = BLI_ghashIterator_getValue(iter); diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index f6ffc783b08..7a28eabec34 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -76,9 +76,9 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) node->storage = BKE_tracking_distortion_create(); if (node->custom1 == 0) - obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 1); + obuf = BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 1); else - obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 0); + obuf = BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 0); stackbuf->rect = obuf->rect_float; stackbuf->malloc = TRUE; @@ -118,7 +118,7 @@ static void storage_free(bNode *node) if (node->storage) BKE_tracking_distortion_destroy(node->storage); - node->storage= NULL; + node->storage = NULL; } static void storage_copy(bNode *orig_node, bNode *new_node) From 4ea8c9ab38bc045dcd6ecb01104be18f119580d8 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 4 May 2012 03:25:46 +0000 Subject: [PATCH 40/88] Small hull bmop fix, distance check from plane needs absolute value. --- source/blender/bmesh/operators/bmo_hull.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index 741ec1fe2d0..1cd095f72e4 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -478,7 +478,7 @@ static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op, normal_tri_v3(plane_normal, tetra[0]->co, tetra[1]->co, tetra[2]->co); BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) { - float dist = dist_to_plane_v3(v->co, tetra[0]->co, plane_normal); + float dist = fabsf(dist_to_plane_v3(v->co, tetra[0]->co, plane_normal)); if (dist > largest_dist) { largest_dist = dist; tetra[3] = v; From 0fcb7d813e4e043095a1d221f1d2c56759c28795 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Fri, 4 May 2012 07:23:50 +0000 Subject: [PATCH 41/88] There is no GLenum called LIGHT_POSITION There is an FAQ that mentions a mythical GL_LIGHT_POSITION, and lots of programmers speak of it, but this mythical creature does not exist! The correct symbol is GL_POSITION --- source/blender/editors/space_view3d/drawmesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 524b66c852c..530b26d566a 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -387,7 +387,7 @@ static void draw_textured_end(void) glDisable(GL_CULL_FACE); /* XXX, bad patch - GPU_default_lights() calls - * glLightfv(GL_LIGHT_POSITION, ...) which + * glLightfv(GL_POSITION, ...) which * is transformed by the current matrix... we * need to make sure that matrix is identity. * From 621245c6cdfe00353113e55f0cc719477ecb10b7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 May 2012 08:00:55 +0000 Subject: [PATCH 42/88] Fix related to #31118: ensure tesselated faces are available when exporting to fluid sim. Is not actually the cause of the bug. --- source/blender/blenkernel/intern/fluidsim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 9f7d76d251d..9be599ac66c 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -78,7 +78,8 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, int *tris; dm = mesh_create_derived_index_render(scene, ob, CD_MASK_BAREMESH, modifierIndex); - //dm = mesh_create_derived_no_deform(ob,NULL); + + DM_ensure_tessface(dm); mvert = dm->getVertArray(dm); mface = dm->getTessFaceArray(dm); @@ -122,3 +123,4 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, dm->release(dm); } + From a899ce19d0a59278e793f303e9ee6056d189f151 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 May 2012 08:00:58 +0000 Subject: [PATCH 43/88] Cycles: tweak ATI OpenGL/CUDA fix more with extra error check. --- intern/cycles/device/device_cuda.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 4bead82fe5a..0a780e5f576 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -176,7 +176,9 @@ public: result = cuCtxCreate(&cuContext, 0, cuDevice); } else { - if(cuGLCtxCreate(&cuContext, 0, cuDevice) != CUDA_SUCCESS) { + result = cuGLCtxCreate(&cuContext, 0, cuDevice); + + if(result != CUDA_SUCCESS) { result = cuCtxCreate(&cuContext, 0, cuDevice); background = true; } @@ -691,14 +693,25 @@ public: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); - cuda_assert(cuGraphicsGLRegisterBuffer(&pmem.cuPBOresource, pmem.cuPBO, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)) + CUresult result = cuGraphicsGLRegisterBuffer(&pmem.cuPBOresource, pmem.cuPBO, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE); - cuda_pop_context(); + if(!cuda_error(result)) { + cuda_pop_context(); - mem.device_pointer = pmem.cuTexId; - pixel_mem_map[mem.device_pointer] = pmem; + mem.device_pointer = pmem.cuTexId; + pixel_mem_map[mem.device_pointer] = pmem; - return; + return; + } + else { + /* failed to register buffer, fallback to no interop */ + glDeleteBuffers(1, &pmem.cuPBO); + glDeleteTextures(1, &pmem.cuTexId); + + cuda_pop_context(); + + background = true; + } } Device::pixels_alloc(mem); From 549b3ccba1da9d5b106f7c4699c9cf63fb609662 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 May 2012 08:18:47 +0000 Subject: [PATCH 44/88] Throw an error and prevent compilation if there're unknown structures detected by DNA --- source/blender/makesdna/intern/makesdna.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index adcdf5df106..5ce5827fac3 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -874,6 +874,8 @@ static int calculate_structlens(int firststruct) printf(" %s\n", types[structtype]); } } + + dna_error = 1; } return(dna_error); From 2823a9a8090c9d063b0d35412266bac2e6cba7c8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 May 2012 09:25:09 +0000 Subject: [PATCH 45/88] Fix #31286: saving 16 bit BW tiff could crash due to invalid memory access. Also found that 16 bit RGBA saving was not working, fixed as well. --- source/blender/imbuf/intern/tiff.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 2a7ba2cae26..a9396a5824d 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -778,22 +778,17 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) if (pixels16) { /* convert from float source */ - float rgb[3]; + float rgb[4]; if (ibuf->profile == IB_PROFILE_LINEAR_RGB) linearrgb_to_srgb_v3_v3(rgb, &fromf[from_i]); else copy_v3_v3(rgb, &fromf[from_i]); - to16[to_i+0] = FTOUSHORT(rgb[0]); - to16[to_i+1] = FTOUSHORT(rgb[1]); - to16[to_i+2] = FTOUSHORT(rgb[2]); - to_i += 3; from_i+=3; - - if (samplesperpixel == 4) { - to16[to_i+3] = FTOUSHORT(fromf[from_i+3]); - /*to_i++; from_i++;*/ /*unused, set on each loop */ - } + rgb[3] = fromf[from_i+3]; + + for (i = 0; i < samplesperpixel; i++, to_i++) + to16[to_i] = FTOUSHORT(rgb[i]); } else { for (i = 0; i < samplesperpixel; i++, to_i++, from_i++) From c01aa64247357570e4f469185240a416075bd971 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 May 2012 09:58:35 +0000 Subject: [PATCH 46/88] Fix: issue in strand render + instancing bugfix, also optimized it a bit to avoid unnecessary memory allocations. --- source/blender/render/intern/include/strand.h | 2 +- source/blender/render/intern/source/strand.c | 64 ++++++++++--------- source/blender/render/intern/source/zbuf.c | 4 +- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/source/blender/render/intern/include/strand.h b/source/blender/render/intern/include/strand.h index a343278c0ab..7482b4d10ee 100644 --- a/source/blender/render/intern/include/strand.h +++ b/source/blender/render/intern/include/strand.h @@ -101,7 +101,7 @@ void free_strand_surface(struct Render *re); struct StrandShadeCache *strand_shade_cache_create(void); void strand_shade_cache_free(struct StrandShadeCache *cache); void strand_shade_segment(struct Render *re, struct StrandShadeCache *cache, struct StrandSegment *sseg, struct ShadeSample *ssamp, float t, float s, int addpassflag); -void strand_shade_unref(struct StrandShadeCache *cache, struct ObjectInstanceRen *obi, struct StrandRen *strand, struct StrandVert *svert); +void strand_shade_unref(struct StrandShadeCache *cache, struct ObjectInstanceRen *obi, struct StrandVert *svert); #endif diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 7aa114a64dc..29931e16056 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -323,6 +323,11 @@ struct StrandShadeCache { MemArena *memarena; }; +typedef struct StrandCacheEntry { + GHashPair pair; + ShadeResult shr; +} StrandCacheEntry; + StrandShadeCache *strand_shade_cache_create(void) { StrandShadeCache *cache; @@ -337,49 +342,49 @@ StrandShadeCache *strand_shade_cache_create(void) void strand_shade_cache_free(StrandShadeCache *cache) { - BLI_ghash_free(cache->refcounthash, (GHashKeyFreeFP)BLI_ghashutil_pairfree, NULL); - BLI_ghash_free(cache->resulthash, (GHashKeyFreeFP)BLI_ghashutil_pairfree, (GHashValFreeFP)MEM_freeN); + BLI_ghash_free(cache->refcounthash, NULL, NULL); + BLI_ghash_free(cache->resulthash, (GHashKeyFreeFP)MEM_freeN, NULL); BLI_memarena_free(cache->memarena); MEM_freeN(cache); } -static GHashPair *strand_shade_hash_pair(ObjectInstanceRen *obi, StrandRen *strand, StrandVert *svert) +static GHashPair strand_shade_hash_pair(ObjectInstanceRen *obi, StrandVert *svert) { - return BLI_ghashutil_pairalloc(obi, strand->index + (svert - strand->vert)); + GHashPair pair = {obi, svert}; + return pair; } static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert) { - ShadeResult *hashshr; + StrandCacheEntry *entry; StrandPoint p; int *refcount; - GHashPair *pair = strand_shade_hash_pair(sseg->obi, sseg->strand, svert); + GHashPair pair = strand_shade_hash_pair(sseg->obi, svert); - hashshr= BLI_ghash_lookup(cache->resulthash, pair); - refcount= BLI_ghash_lookup(cache->refcounthash, pair); + entry= BLI_ghash_lookup(cache->resulthash, &pair); + refcount= BLI_ghash_lookup(cache->refcounthash, &pair); - if (!hashshr) { + if (!entry) { /* not shaded yet, shade and insert into hash */ p.t= (sseg->v[1] == svert)? 0.0f: 1.0f; strand_eval_point(sseg, &p); strand_shade_point(re, ssamp, sseg, svert, &p); - hashshr= MEM_callocN(sizeof(ShadeResult), "HashShadeResult"); - *hashshr= ssamp->shr[0]; - BLI_ghash_insert(cache->resulthash, strand_shade_hash_pair(sseg->obi, sseg->strand, svert), hashshr); + entry= MEM_callocN(sizeof(StrandCacheEntry), "StrandCacheEntry"); + entry->pair = pair; + entry->shr = ssamp->shr[0]; + BLI_ghash_insert(cache->resulthash, entry, entry); } else /* already shaded, just copy previous result from hash */ - ssamp->shr[0]= *hashshr; + ssamp->shr[0]= entry->shr; /* lower reference count and remove if not needed anymore by any samples */ (*refcount)--; if (*refcount == 0) { - BLI_ghash_remove(cache->resulthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, (GHashValFreeFP)MEM_freeN); - BLI_ghash_remove(cache->refcounthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, NULL); + BLI_ghash_remove(cache->resulthash, &pair, (GHashKeyFreeFP)MEM_freeN, NULL); + BLI_ghash_remove(cache->refcounthash, &pair, NULL, NULL); } - - BLI_ghashutil_pairfree(pair); } void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *sseg, ShadeSample *ssamp, float t, float s, int addpassflag) @@ -402,37 +407,36 @@ void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *ss } } -void strand_shade_unref(StrandShadeCache *cache, ObjectInstanceRen *obi, StrandRen *strand, StrandVert *svert) +void strand_shade_unref(StrandShadeCache *cache, ObjectInstanceRen *obi, StrandVert *svert) { - GHashPair *pair = strand_shade_hash_pair(obi, strand, svert); + GHashPair pair = strand_shade_hash_pair(obi, svert); int *refcount; /* lower reference count and remove if not needed anymore by any samples */ - refcount= BLI_ghash_lookup(cache->refcounthash, pair); + refcount= BLI_ghash_lookup(cache->refcounthash, &pair); (*refcount)--; if (*refcount == 0) { - BLI_ghash_remove(cache->resulthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, (GHashValFreeFP)MEM_freeN); - BLI_ghash_remove(cache->refcounthash, pair, (GHashKeyFreeFP)BLI_ghashutil_pairfree, NULL); + BLI_ghash_remove(cache->resulthash, &pair, (GHashKeyFreeFP)MEM_freeN, NULL); + BLI_ghash_remove(cache->refcounthash, &pair, NULL, NULL); } - - BLI_ghashutil_pairfree(pair); } static void strand_shade_refcount(StrandShadeCache *cache, StrandSegment *sseg, StrandVert *svert) { - GHashPair *pair = strand_shade_hash_pair(sseg->obi, sseg->strand, svert); - int *refcount= BLI_ghash_lookup(cache->refcounthash, pair); + GHashPair pair = strand_shade_hash_pair(sseg->obi, svert); + GHashPair *key; + int *refcount= BLI_ghash_lookup(cache->refcounthash, &pair); if (!refcount) { + key= BLI_memarena_alloc(cache->memarena, sizeof(GHashPair)); + *key = pair; refcount= BLI_memarena_alloc(cache->memarena, sizeof(int)); *refcount= 1; - BLI_ghash_insert(cache->refcounthash, pair, refcount); + BLI_ghash_insert(cache->refcounthash, key, refcount); } - else { + else (*refcount)++; - BLI_ghashutil_pairfree(pair); - } } /* *************** */ diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 84c5f822b53..b9e69743995 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3748,8 +3748,8 @@ static void unref_strand_samples(StrandShadeCache *cache, ZTranspRow *row, int t strand= RE_findOrAddStrand(obr, row[totface].p-1); svert= strand->vert + row[totface].segment; - strand_shade_unref(cache, obi, strand, svert); - strand_shade_unref(cache, obi, strand, svert+1); + strand_shade_unref(cache, obi, svert); + strand_shade_unref(cache, obi, svert+1); } } } From df553582e96569e49a4d28c167c5dd334be5f216 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 May 2012 11:49:58 +0000 Subject: [PATCH 47/88] Fix #31288: Blender crash when select a material Quite the same issue as render crash on missed shader groups, needed a NULL-check in node exec function as well. --- source/blender/nodes/shader/nodes/node_shader_common.c | 3 +++ source/blender/nodes/texture/nodes/node_texture_common.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index bd31f20b18c..df369482a2e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -124,6 +124,9 @@ static void group_execute(void *data, int thread, struct bNode *node, void *node bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; bNodeThreadStack *nts; + if (!exec) + return; + /* XXX same behavior as trunk: all nodes inside group are executed. * it's stupid, but just makes it work. compo redesign will do this better. */ diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index 2a9107f9498..1eaf9b2b0fe 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -110,6 +110,9 @@ static void group_execute(void *data, int thread, struct bNode *node, void *node bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; bNodeThreadStack *nts; + if (!exec) + return; + /* XXX same behavior as trunk: all nodes inside group are executed. * it's stupid, but just makes it work. compo redesign will do this better. */ From a0ce240de94521b6caf55b0738b70f2dc2ad3353 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Fri, 4 May 2012 11:50:11 +0000 Subject: [PATCH 48/88] Renamed "fake" OpenGL identifiers. Any identifier that looks like an OpenGL identifier, but isn't, causes a false alarm by the glreport.py tool. Most of these were in comments so I just rephrased the comments. There were a couple of static functions/macros that were easy enough to rename. Only the glTexco and glIndex fields of the DMVertexAttribs struct was public and had non-local uses. --- intern/ghost/intern/GHOST_WindowWin32.cpp | 2 +- .../blenfont/intern/blf_internal_types.h | 2 +- source/blender/blenkernel/BKE_DerivedMesh.h | 8 ++--- .../blender/blenkernel/intern/DerivedMesh.c | 30 +++++++++---------- .../blender/blenkernel/intern/cdderivedmesh.c | 20 ++++++------- .../blenkernel/intern/editderivedmesh.c | 20 ++++++------- .../blender/blenkernel/intern/subsurf_ccg.c | 20 ++++++------- source/blender/editors/include/BIF_glutil.h | 23 +++++++------- .../editors/interface/interface_draw.c | 12 ++++---- source/blender/editors/screen/glutil.c | 8 ++--- .../editors/space_view3d/drawarmature.c | 6 ++-- .../blender/editors/space_view3d/drawobject.c | 2 +- source/blender/gpu/intern/gpu_draw.c | 2 +- source/blender/windowmanager/intern/wm_draw.c | 2 +- .../windowmanager/intern/wm_subwindow.c | 2 +- 15 files changed, 78 insertions(+), 81 deletions(-) diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 9d105748095..3715da12cd6 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -55,7 +55,7 @@ #endif // Some more multisample defines -#define WGL_SAMPLE_BUFERS_ARB 0x2041 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 // win64 doesn't define GWL_USERDATA diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index cbe7975fdd6..bf9b9858348 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -180,7 +180,7 @@ typedef struct FontBLF { /* max texture size. */ int max_tex_size; - /* current opengl texture bind, avoids calling glGet */ + /* cache current OpenGL texture to save calls into the API */ int tex_bind_state; /* font options. */ diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 3a28af97166..a15192f156a 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -664,22 +664,22 @@ void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const typedef struct DMVertexAttribs { struct { struct MTFace *array; - int emOffset, glIndex, glTexco; + int em_offset, gl_index, gl_texco; } tface[MAX_MTFACE]; struct { struct MCol *array; - int emOffset, glIndex; + int em_offset, gl_index; } mcol[MAX_MCOL]; struct { float (*array)[4]; - int emOffset, glIndex; + int em_offset, gl_index; } tang; struct { float (*array)[3]; - int emOffset, glIndex, glTexco; + int em_offset, gl_index, gl_texco; } orco; int tottface, totmcol, tottang, totorco; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 74373d28c14..f648a9e297c 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2786,9 +2786,9 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->tottface++; attribs->tface[a].array = tfdata->layers[layer].data; - attribs->tface[a].emOffset = tfdata->layers[layer].offset; - attribs->tface[a].glIndex = gattribs->layer[b].glindex; - attribs->tface[a].glTexco = gattribs->layer[b].gltexco; + attribs->tface[a].em_offset = tfdata->layers[layer].offset; + attribs->tface[a].gl_index = gattribs->layer[b].glindex; + attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } } else { @@ -2802,9 +2802,9 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->tottface++; attribs->tface[a].array = tfdata->layers[layer].data; - attribs->tface[a].emOffset = tfdata->layers[layer].offset; - attribs->tface[a].glIndex = gattribs->layer[b].glindex; - attribs->tface[a].glTexco = gattribs->layer[b].gltexco; + attribs->tface[a].em_offset = tfdata->layers[layer].offset; + attribs->tface[a].gl_index = gattribs->layer[b].glindex; + attribs->tface[a].gl_texco = gattribs->layer[b].gltexco; } } } @@ -2823,8 +2823,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->totmcol++; attribs->mcol[a].array = tfdata->layers[layer].data; - attribs->mcol[a].emOffset = tfdata->layers[layer].offset; - attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + attribs->mcol[a].em_offset = tfdata->layers[layer].offset; + attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } } else { @@ -2839,8 +2839,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, a = attribs->totmcol++; attribs->mcol[a].array = tfdata->layers[layer].data; - attribs->mcol[a].emOffset = tfdata->layers[layer].offset; - attribs->mcol[a].glIndex = gattribs->layer[b].glindex; + attribs->mcol[a].em_offset = tfdata->layers[layer].offset; + attribs->mcol[a].gl_index = gattribs->layer[b].glindex; } } } @@ -2852,8 +2852,8 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->tottang = 1; attribs->tang.array = fdata->layers[layer].data; - attribs->tang.emOffset = fdata->layers[layer].offset; - attribs->tang.glIndex = gattribs->layer[b].glindex; + attribs->tang.em_offset = fdata->layers[layer].offset; + attribs->tang.gl_index = gattribs->layer[b].glindex; } } else if (gattribs->layer[b].type == CD_ORCO) { @@ -2864,9 +2864,9 @@ void DM_vertex_attributes_from_gpu(DerivedMesh *dm, GPUVertexAttribs *gattribs, attribs->totorco = 1; attribs->orco.array = vdata->layers[layer].data; - attribs->orco.emOffset = vdata->layers[layer].offset; - attribs->orco.glIndex = gattribs->layer[b].glindex; - attribs->orco.glTexco = gattribs->layer[b].gltexco; + attribs->orco.em_offset = vdata->layers[layer].offset; + attribs->orco.gl_index = gattribs->layer[b].glindex; + attribs->orco.gl_texco = gattribs->layer[b].gltexco; } } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 19e66b957eb..78a8b975b85 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -989,20 +989,20 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int /* orco texture coordinates */ if (attribs->totorco) { - if (attribs->orco.glTexco) + if (attribs->orco.gl_texco) glTexCoord3fv(attribs->orco.array[index]); else - glVertexAttrib3fvARB(attribs->orco.glIndex, attribs->orco.array[index]); + glVertexAttrib3fvARB(attribs->orco.gl_index, attribs->orco.array[index]); } /* uv texture coordinates */ for (b = 0; b < attribs->tottface; b++) { MTFace *tf = &attribs->tface[b].array[a]; - if (attribs->tface[b].glTexco) + if (attribs->tface[b].gl_texco) glTexCoord2fv(tf->uv[vert]); else - glVertexAttrib2fvARB(attribs->tface[b].glIndex, tf->uv[vert]); + glVertexAttrib2fvARB(attribs->tface[b].gl_index, tf->uv[vert]); } /* vertex colors */ @@ -1010,13 +1010,13 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int MCol *cp = &attribs->mcol[b].array[a*4 + vert]; GLubyte col[4]; col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - glVertexAttrib4ubvARB(attribs->mcol[b].glIndex, col); + glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col); } /* tangent for normal mapping */ if (attribs->tottang) { float *tang = attribs->tang.array[a*4 + vert]; - glVertexAttrib4fvARB(attribs->tang.glIndex, tang); + glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } /* vertex normal */ @@ -1167,25 +1167,25 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); if (attribs.totorco) { - datatypes[numdata].index = attribs.orco.glIndex; + datatypes[numdata].index = attribs.orco.gl_index; datatypes[numdata].size = 3; datatypes[numdata].type = GL_FLOAT; numdata++; } for (b = 0; b < attribs.tottface; b++) { - datatypes[numdata].index = attribs.tface[b].glIndex; + datatypes[numdata].index = attribs.tface[b].gl_index; datatypes[numdata].size = 2; datatypes[numdata].type = GL_FLOAT; numdata++; } for (b = 0; b < attribs.totmcol; b++) { - datatypes[numdata].index = attribs.mcol[b].glIndex; + datatypes[numdata].index = attribs.mcol[b].gl_index; datatypes[numdata].size = 4; datatypes[numdata].type = GL_UNSIGNED_BYTE; numdata++; } if (attribs.tottang) { - datatypes[numdata].index = attribs.tang.glIndex; + datatypes[numdata].index = attribs.tang.gl_index; datatypes[numdata].size = 4; datatypes[numdata].type = GL_FLOAT; numdata++; diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 9fd6a4e9ba4..8d7ac99e2a3 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1013,21 +1013,21 @@ static void emDM_drawMappedFacesGLSL( #define PASSATTRIB(loop, eve, vert) { \ if (attribs.totorco) { \ float *orco = attribs.orco.array[BM_elem_index_get(eve)]; \ - glVertexAttrib3fvARB(attribs.orco.glIndex, orco); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, orco); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MLoopUV *_luv = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPUV, b);\ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, _luv->uv); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, _luv->uv); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MLoopCol *_cp = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPCOL, b);\ GLubyte _col[4]; \ _col[0]= _cp->b; _col[1]= _cp->g; _col[2]= _cp->r; _col[3]= _cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, _col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, _col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[i*4 + vert]; \ - glVertexAttrib3fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib3fvARB(attribs.tang.gl_index, tang); \ } \ } @@ -1136,27 +1136,27 @@ static void emDM_drawMappedFacesMat( #define PASSATTRIB(loop, eve, vert) { \ if (attribs.totorco) { \ float *orco = attribs.orco.array[BM_elem_index_get(eve)]; \ - if (attribs.orco.glTexco) \ + if (attribs.orco.gl_texco) \ glTexCoord3fv(orco); \ else \ - glVertexAttrib3fvARB(attribs.orco.glIndex, orco); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, orco); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MLoopUV *_luv = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPUV, b);\ - if (attribs.tface[b].glTexco) \ + if (attribs.tface[b].gl_texco) \ glTexCoord2fv(_luv->uv); \ else \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, _luv->uv); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, _luv->uv); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MLoopCol *_cp = CustomData_bmesh_get_n(&bm->ldata, loop->head.data, CD_MLOOPCOL, b);\ GLubyte _col[4]; \ _col[0]= _cp->b; _col[1]= _cp->g; _col[2]= _cp->r; _col[3]= _cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, _col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, _col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[i*4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index ddc605eb3e0..b3b704bf2a2 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1718,21 +1718,21 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, #define PASSATTRIB(dx, dy, vert) { \ if (attribs.totorco) { \ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ - glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, attribs.orco.array[index]); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MTFace *tf = &attribs.tface[b].array[a]; \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \ GLubyte col[4]; \ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[a * 4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ } @@ -1863,27 +1863,27 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * #define PASSATTRIB(dx, dy, vert) { \ if (attribs.totorco) { \ index = getFaceIndex(ss, f, S, x + dx, y + dy, edgeSize, gridSize); \ - if (attribs.orco.glTexco) \ + if (attribs.orco.gl_texco) \ glTexCoord3fv(attribs.orco.array[index]); \ else \ - glVertexAttrib3fvARB(attribs.orco.glIndex, attribs.orco.array[index]); \ + glVertexAttrib3fvARB(attribs.orco.gl_index, attribs.orco.array[index]); \ } \ for (b = 0; b < attribs.tottface; b++) { \ MTFace *tf = &attribs.tface[b].array[a]; \ - if (attribs.tface[b].glTexco) \ + if (attribs.tface[b].gl_texco) \ glTexCoord2fv(tf->uv[vert]); \ else \ - glVertexAttrib2fvARB(attribs.tface[b].glIndex, tf->uv[vert]); \ + glVertexAttrib2fvARB(attribs.tface[b].gl_index, tf->uv[vert]); \ } \ for (b = 0; b < attribs.totmcol; b++) { \ MCol *cp = &attribs.mcol[b].array[a * 4 + vert]; \ GLubyte col[4]; \ col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; \ - glVertexAttrib4ubvARB(attribs.mcol[b].glIndex, col); \ + glVertexAttrib4ubvARB(attribs.mcol[b].gl_index, col); \ } \ if (attribs.tottang) { \ float *tang = attribs.tang.array[a * 4 + vert]; \ - glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.gl_index, tang); \ } \ } diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 44195988c40..2172aa82acf 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -49,7 +49,8 @@ void fdrawXORcirc(float xofs, float yofs, float rad); void fdrawcheckerboard(float x1, float y1, float x2, float y2); -/* glStipple defines */ +/* OpenGL stipple defines */ +/* OpenGL stipple defines */ extern unsigned char stipple_halftone[128]; extern unsigned char stipple_quarttone[128]; extern unsigned char stipple_diag_stripes_pos[128]; @@ -147,13 +148,14 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, /* 2D Drawing Assistance */ /** Define a 2D area (viewport, scissor, matrices) for OpenGL rendering. - * This routine sets up an OpenGL state appropriate for drawing using - * both vertice (glVertex, etc) and raster (glRasterPos, glRect) commands. - * All coordinates should be at integer positions. There is little to - * no reason to use glVertex2f etc. functions during 2D rendering, and + * + * glwDefine2DArea and glaBegin2DDraw set up an OpenGL state appropriate + * for drawing using both vertice (Vertex, etc) and raster (RasterPos, Rect) + * commands. All coordinates should be at integer positions. There is little + * to no reason to use glVertex2f etc. functions during 2D rendering, and * thus no reason to +-0.5 the coordinates or perform other silly * tricks. - * + * * \param screen_rect The screen rectangle to be defined for 2D drawing. */ void glaDefine2DArea (struct rcti *screen_rect); @@ -165,13 +167,8 @@ typedef struct gla2DDrawInfo gla2DDrawInfo; * to free it and to return OpenGL to its previous state. The * scissor rectangle is set to match the viewport. * - * This routine sets up an OpenGL state appropriate for drawing using - * both vertice (glVertex, etc) and raster (glRasterPos, glRect) commands. - * All coordinates should be at integer positions. There is little to - * no reason to use glVertex2f etc. functions during 2D rendering, and - * thus no reason to +-0.5 the coordinates or perform other silly - * tricks. - * + * See glaDefine2DArea for an explanation of why this function uses integers. + * * \param screen_rect The screen rectangle to be used for 2D drawing. * \param world_rect The world rectangle that the 2D area represented * by \a screen_rect is supposed to represent. If NULL it is assumed the diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index d90d8286db9..8c5913e23fb 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1196,7 +1196,7 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) ui_get_but_vectorf(but, dir); - dir[3] = 0.0f; /* glLight needs 4 args, 0.0 is sun */ + dir[3] = 0.0f; /* glLightfv needs 4 args, 0.0 is sun */ glLightfv(GL_LIGHT7, GL_POSITION, dir); glLightfv(GL_LIGHT7, GL_DIFFUSE, diffn); glLightfv(GL_LIGHT7, GL_SPECULAR, vec0); @@ -1281,7 +1281,7 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o } -static void glColor3ubvShade(unsigned char *col, int shade) +static void gl_shaded_color(unsigned char *col, int shade) { glColor3ub(col[0] - shade > 0 ? col[0] - shade : 0, col[1] - shade > 0 ? col[1] - shade : 0, @@ -1318,7 +1318,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect /* backdrop */ if (cumap->flag & CUMA_DO_CLIP) { - glColor3ubvShade((unsigned char *)wcol->inner, -20); + gl_shaded_color((unsigned char *)wcol->inner, -20); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glColor3ubv((unsigned char *)wcol->inner); glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx), @@ -1332,13 +1332,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect } /* grid, every .25 step */ - glColor3ubvShade((unsigned char *)wcol->inner, -16); + gl_shaded_color((unsigned char *)wcol->inner, -16); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ - glColor3ubvShade((unsigned char *)wcol->inner, -24); + gl_shaded_color((unsigned char *)wcol->inner, -24); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ - glColor3ubvShade((unsigned char *)wcol->inner, -50); + gl_shaded_color((unsigned char *)wcol->inner, -50); glBegin(GL_LINES); glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy)); glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy)); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 50430399f09..69db65fda1c 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -297,13 +297,13 @@ void setlinestyle(int nr) /* Invert line handling */ -#define glToggle(mode, onoff) (((onoff)?glEnable:glDisable)(mode)) +#define gl_toggle(mode, onoff) (((onoff)?glEnable:glDisable)(mode)) void set_inverted_drawing(int enable) { glLogicOp(enable?GL_INVERT:GL_COPY); - glToggle(GL_COLOR_LOGIC_OP, enable); - glToggle(GL_DITHER, !enable); + gl_toggle(GL_COLOR_LOGIC_OP, enable); + gl_toggle(GL_DITHER, !enable); } void sdrawXORline(int x0, int y0, int x1, int y1) @@ -781,7 +781,7 @@ void glaEnd2DDraw(gla2DDrawInfo *di) } #endif -/* **************** glPoint hack ************************ */ +/* **************** GL_POINT hack ************************ */ static int curmode=0; static int pointhack=0; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index fec93b3b9aa..15e6994dfe4 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1297,7 +1297,7 @@ static void draw_bone(int dt, int armflag, int boneflag, short constflag, unsign { /* Draw a 3d octahedral bone, we use normalized space based on length, - * for glDisplayLists */ + * for display-lists */ glScalef(length, length, length); @@ -1996,7 +1996,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* finally names and axes */ if ((arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) && (is_outline == 0)) { - /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */ + /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; @@ -2208,7 +2208,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* finally names and axes */ if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) { - // patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing + // patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing if ((G.f & G_PICKSEL) == 0) { float vec[3]; unsigned char col[4]; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 585fc43e5c2..36b11b2c28b 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6990,7 +6990,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) drawtexspace(ob); } if (dtx & OB_DRAWNAME) { - /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */ + /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ /* but, we also don't draw names for sets or duplicators */ if (flag == 0) { float zero[3] = {0, 0, 0}; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 1c1cf8017f6..b2c2bc092b2 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1304,7 +1304,7 @@ void GPU_end_object_materials(void) GMS.gmatbuf= NULL; GMS.alphablend= NULL; - /* resetting the texture matrix after the glScale needed for tiled textures */ + /* resetting the texture matrix after the scaling needed for tiled textures */ if (GTS.tilemode) { glMatrixMode(GL_TEXTURE); glLoadIdentity(); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 66cadf1e76a..2b83a55d7bb 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -475,7 +475,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple) glTexImage2D(triple->target, 0, GL_RGB8, triple->x[x], triple->y[y], 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexParameteri(triple->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(triple->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - // glColor still used with this enabled? + // The current color is ignored if the GL_REPLACE texture environment is used. // glTexEnvi(triple->target, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBindTexture(triple->target, 0); diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 6ffb28ba013..563eef8304c 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -237,7 +237,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct) } } -/* ---------------- WM versions of OpenGL calls, using glBlah() syntax ------------------------ */ +/* ---------------- WM versions of OpenGL style API calls ------------------------ */ /* ----------------- exported in WM_api.h ------------------------------------------------------ */ /* internal state, no threaded opengl! XXX */ From 68d9e73ecd81186fe6934c48f6c26d89d788d343 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 May 2012 12:46:51 +0000 Subject: [PATCH 49/88] Fix: forgot to commit these files as part of strand bugfix. --- source/blender/blenlib/BLI_ghash.h | 4 ++-- source/blender/blenlib/intern/BLI_ghash.c | 6 +++--- source/blender/editors/object/object_add.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 02042fbfb95..b178538edf2 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -149,10 +149,10 @@ int BLI_ghashutil_intcmp (const void *a, const void *b); typedef struct GHashPair { const void *first; - int second; + const void *second; } GHashPair; -GHashPair* BLI_ghashutil_pairalloc (const void *first, int second); +GHashPair* BLI_ghashutil_pairalloc (const void *first, const void *second); unsigned int BLI_ghashutil_pairhash (const void *ptr); int BLI_ghashutil_paircmp (const void *a, const void *b); void BLI_ghashutil_pairfree (void *ptr); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 28b4794ed1b..4dba726cb61 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -305,7 +305,7 @@ int BLI_ghashutil_strcmp(const void *a, const void *b) return strcmp(a, b); } -GHashPair *BLI_ghashutil_pairalloc(const void *first, int second) +GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second) { GHashPair *pair = MEM_mallocN(sizeof(GHashPair), "GHashPair"); pair->first = first; @@ -317,7 +317,7 @@ unsigned int BLI_ghashutil_pairhash(const void *ptr) { const GHashPair *pair = ptr; unsigned int hash = BLI_ghashutil_ptrhash(pair->first); - return hash ^ BLI_ghashutil_inthash(SET_INT_IN_POINTER(pair->second)); + return hash ^ BLI_ghashutil_ptrhash(pair->second); } int BLI_ghashutil_paircmp(const void *a, const void *b) @@ -327,7 +327,7 @@ int BLI_ghashutil_paircmp(const void *a, const void *b) int cmp = BLI_ghashutil_ptrcmp(A->first, B->first); if (cmp == 0) - return BLI_ghashutil_intcmp(SET_INT_IN_POINTER(A->second), SET_INT_IN_POINTER(B->second)); + return BLI_ghashutil_ptrcmp(A->second, B->second); return cmp; } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 52d14b9d374..85735c1ac1c 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1102,7 +1102,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, if (dupli_gh) BLI_ghash_insert(dupli_gh, dob, ob); if (parent_gh) - BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, dob->index), ob); + BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, SET_INT_IN_POINTER(dob->index)), ob); } if (use_hierarchy) { @@ -1116,7 +1116,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* find parent that was also made real */ if (ob_src_par) { - GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, dob->index); + GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, SET_INT_IN_POINTER(dob->index)); ob_dst_par = BLI_ghash_lookup(parent_gh, pair); BLI_ghashutil_pairfree(pair); } From d6ae78322e6f56d5778fd28ef12bc672674fb4d0 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Fri, 4 May 2012 13:12:09 +0000 Subject: [PATCH 50/88] Removed the automatic socket selection in the modal node linking operator. This was originally reimplemented as part of the socket selection feature, but since selecting a socket necessarily also selected the owning node, it messes with the manual user selection of nodes too much (and doesn't add any additional usability). --- source/blender/editors/space_node/node_edit.c | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 68bebde030f..5166387d6f4 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2324,9 +2324,6 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) case MOUSEMOVE: if (in_out==SOCK_OUT) { - /* only target socket becomes hilighted */ - node_deselect_all_input_sockets(snode, 0); - if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_IN)) { if (nodeFindLink(snode->edittree, sock, tsock)==NULL) { if ( link->tosock!= tsock && (!tnode || (tnode!=node && link->tonode!=tnode)) ) { @@ -2340,9 +2337,6 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) ntreeUpdateTree(snode->edittree); } } - - /* hilight target socket */ - node_socket_select(tnode, tsock); } else { if (link->tonode || link->tosock) { @@ -2357,9 +2351,6 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } } else { - /* only target socket becomes hilighted */ - node_deselect_all_output_sockets(snode, 0); - if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_OUT)) { if (nodeFindLink(snode->edittree, sock, tsock)==NULL) { if (nodeCountSocketLinks(snode->edittree, tsock) < tsock->limit) { @@ -2375,9 +2366,6 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } } } - - /* hilight target socket */ - node_socket_select(tnode, tsock); } else { if (link->tonode || link->tosock) { @@ -2405,10 +2393,6 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) if (in_out==SOCK_OUT) node_remove_extra_links(snode, link->tosock, link); - /* deselect sockets after successful linking */ - node_deselect_all_input_sockets(snode, 0); - node_deselect_all_output_sockets(snode, 0); - /* when linking to group outputs, update the socket type */ /* XXX this should all be part of a generic update system */ if (!link->tonode) { @@ -2434,10 +2418,6 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) } snode->edittree->update |= NTREE_UPDATE_GROUP_OUT | NTREE_UPDATE_LINKS; } - - /* deselect sockets after successful linking */ - node_deselect_all_input_sockets(snode, 0); - node_deselect_all_output_sockets(snode, 0); } else nodeRemLink(snode->edittree, link); @@ -2478,10 +2458,6 @@ static int node_link_init(SpaceNode *snode, bNodeLinkDrag *nldrag) in_out = SOCK_IN; } } - - /* hilight source socket only */ - node_deselect_all_output_sockets(snode, 0); - node_socket_select(nldrag->node, nldrag->sock); } /* or an input? */ else if (node_find_indicated_socket(snode, &nldrag->node, &nldrag->sock, SOCK_IN)) { @@ -2504,10 +2480,6 @@ static int node_link_init(SpaceNode *snode, bNodeLinkDrag *nldrag) in_out = SOCK_OUT; } } - - /* hilight source socket only */ - node_deselect_all_input_sockets(snode, 0); - node_socket_select(nldrag->node, nldrag->sock); } return in_out; From 8b1c1e9f61425ec17670fbc343c0eb5ca998e865 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2012 13:13:45 +0000 Subject: [PATCH 51/88] code cleanup: use much simpler (and likely faster) polygon normal calculation in object mode. --- source/blender/blenkernel/intern/mesh.c | 114 +++--------------- .../blender/editors/space_view3d/drawobject.c | 5 +- source/blender/render/intern/source/strand.c | 2 +- 3 files changed, 22 insertions(+), 99 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 40c04a170ca..6dd5923a803 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2766,64 +2766,20 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, static void mesh_calc_ngon_normal(MPoly *mpoly, MLoop *loopstart, MVert *mvert, float normal[3]) { - - MVert *v1, *v2, *v3; - double u[3], v[3], w[3]; - double n[3] = {0.0, 0.0, 0.0}, l; + const int nverts = mpoly->totloop; + float const *v_prev = mvert[loopstart[nverts - 1].v].co; + float const *v_curr = mvert[loopstart->v].co; + float n[3] = {0.0f}; int i; - for (i = 0; i < mpoly->totloop; i++) { - v1 = mvert + loopstart[i].v; - v2 = mvert + loopstart[(i+1)%mpoly->totloop].v; - v3 = mvert + loopstart[(i+2)%mpoly->totloop].v; - - copy_v3db_v3fl(u, v1->co); - copy_v3db_v3fl(v, v2->co); - copy_v3db_v3fl(w, v3->co); - - /*this fixes some weird numerical error*/ - if (i==0) { - u[0] += 0.0001f; - u[1] += 0.0001f; - u[2] += 0.0001f; - } - - /* newell's method - * - * so thats?: - * (a[1] - b[1]) * (a[2] + b[2]); - * a[1]*b[2] - b[1]*a[2] - b[1]*b[2] + a[1]*a[2] - * - * odd. half of that is the cross product. . .what's the - * other half? - * - * also could be like a[1]*(b[2] + a[2]) - b[1]*(a[2] - b[2]) - */ - - n[0] += (u[1] - v[1]) * (u[2] + v[2]); - n[1] += (u[2] - v[2]) * (u[0] + v[0]); - n[2] += (u[0] - v[0]) * (u[1] + v[1]); + /* Newell's Method */ + for (i = 0; i < nverts; v_prev = v_curr, v_curr = mvert[loopstart[++i].v].co) { + add_newell_cross_v3_v3v3(n, v_prev, v_curr); } - - l = n[0]*n[0]+n[1]*n[1]+n[2]*n[2]; - l = sqrt(l); - if (l == 0.0) { - normal[0] = 0.0f; - normal[1] = 0.0f; - normal[2] = 1.0f; - - return; + if (UNLIKELY(normalize_v3_v3(normal, n) == 0.0f)) { + normal[2] = 1.0f; /* other axis set to 0.0 */ } - else l = 1.0f / l; - - n[0] *= l; - n[1] *= l; - n[2] *= l; - - normal[0] = (float) n[0]; - normal[1] = (float) n[1]; - normal[2] = (float) n[2]; } void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart, @@ -2857,54 +2813,20 @@ void mesh_calc_poly_normal(MPoly *mpoly, MLoop *loopstart, static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart, const float (*vertex_coords)[3], float normal[3]) { - - const float *v1, *v2, *v3; - double u[3], v[3], w[3]; - double n[3] = {0.0, 0.0, 0.0}, l; + const int nverts = mpoly->totloop; + float const *v_prev = vertex_coords[loopstart[nverts - 1].v]; + float const *v_curr = vertex_coords[loopstart->v]; + float n[3] = {0.0f}; int i; - for (i = 0; i < mpoly->totloop; i++) { - v1 = (const float *)(vertex_coords + loopstart[i].v); - v2 = (const float *)(vertex_coords + loopstart[(i+1)%mpoly->totloop].v); - v3 = (const float *)(vertex_coords + loopstart[(i+2)%mpoly->totloop].v); - - copy_v3db_v3fl(u, v1); - copy_v3db_v3fl(v, v2); - copy_v3db_v3fl(w, v3); - - /*this fixes some weird numerical error*/ - if (i==0) { - u[0] += 0.0001f; - u[1] += 0.0001f; - u[2] += 0.0001f; - } - - n[0] += (u[1] - v[1]) * (u[2] + v[2]); - n[1] += (u[2] - v[2]) * (u[0] + v[0]); - n[2] += (u[0] - v[0]) * (u[1] + v[1]); + /* Newell's Method */ + for (i = 0; i < nverts; v_prev = v_curr, v_curr = vertex_coords[loopstart[++i].v]) { + add_newell_cross_v3_v3v3(n, v_prev, v_curr); } - l = n[0]*n[0]+n[1]*n[1]+n[2]*n[2]; - l = sqrt(l); - - if (l == 0.0) { - normal[0] = 0.0f; - normal[1] = 0.0f; - normal[2] = 1.0f; - - return; + if (UNLIKELY(normalize_v3_v3(normal, n) == 0.0f)) { + normal[2] = 1.0f; /* other axis set to 0.0 */ } - else { - l = 1.0f / l; - } - - n[0] *= l; - n[1] *= l; - n[2] *= l; - - normal[0] = (float) n[0]; - normal[1] = (float) n[1]; - normal[2] = (float) n[2]; } void mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 36b11b2c28b..c8754681e41 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2902,9 +2902,10 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS #define DRAW_EM_MEASURE_STATS_FACEAREA() \ if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \ - mul_v3_fl(vmid, 1.0 / n); \ + mul_v3_fl(vmid, 1.0f / (float)n); \ if (unit->system) \ - bUnit_AsString(numstr, sizeof(numstr), area * unit->scale_length, \ + bUnit_AsString(numstr, sizeof(numstr), \ + (double)(area * unit->scale_length), \ 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ else \ BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 29931e16056..f986be5eaeb 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -401,7 +401,7 @@ void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *ss /* apply alpha along width */ if (sseg->buffer->widthfade != 0.0f) { - s = 1.0f - pow(fabs(s), sseg->buffer->widthfade); + s = 1.0f - powf(fabsf(s), sseg->buffer->widthfade); strand_apply_shaderesult_alpha(ssamp->shr, s); } From e62f13ac311eec269abb6a9429b29279dc642cec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2012 13:28:02 +0000 Subject: [PATCH 52/88] own mistake in recent commit CustomData_layertype_is_singleton() was stopping bmesh python api adding multiple layers. --- source/blender/blenkernel/intern/customdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index bd079238b12..e32182ed36e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2610,7 +2610,7 @@ const char *CustomData_layertype_name(int type) int CustomData_layertype_is_singleton(int type) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); - return typeInfo->defaultname != NULL; + return typeInfo->defaultname == NULL; } static int CustomData_is_property_layer(int type) From 2bc29ff4260e28dd89409255997858ca447ad51f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 4 May 2012 14:27:13 +0000 Subject: [PATCH 53/88] Patch [#30654] Wiki Quick Hack: Text editor move lines up/down Submitted by: Justin Dailey (dail) Patch allows the current line (or selected lines) to be moved up and down with Ctrl+Shift+Up and Ctrl+Shift+Down. Has undo/redo support and operators in python menu. --- release/scripts/startup/bl_ui/space_text.py | 5 ++ source/blender/blenkernel/BKE_text.h | 5 ++ source/blender/blenkernel/intern/text.c | 75 +++++++++++++++++-- .../blender/editors/space_text/space_text.c | 7 +- .../blender/editors/space_text/text_intern.h | 3 + source/blender/editors/space_text/text_ops.c | 58 ++++++++++++++ 6 files changed, 144 insertions(+), 9 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index a40e08c2e5c..dd752431df9 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -277,6 +277,11 @@ class TEXT_MT_edit(Menu): layout.separator() + layout.operator("text.move_lines_up") + layout.operator("text.move_lines_down") + + layout.separator() + layout.menu("TEXT_MT_edit_select") layout.menu("TEXT_MT_edit_markers") diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index b1902c75afb..393663456d5 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -96,6 +96,8 @@ void txt_unindent (struct Text *text); void txt_comment (struct Text *text); void txt_indent (struct Text *text); void txt_uncomment (struct Text *text); +void txt_move_lines_up (struct Text *text); +void txt_move_lines_down (struct Text *text); void txt_duplicate_line (struct Text *text); int setcurr_tab_spaces (struct Text *text, int space); @@ -170,6 +172,9 @@ int text_check_whitespace(const char ch); #define UNDO_COMMENT 034 #define UNDO_UNCOMMENT 035 +#define UNDO_MOVE_LINES_UP 036 +#define UNDO_MOVE_LINES_DOWN 037 + #define UNDO_DUPLICATE 040 /* Marker flags */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 85ecc7c204d..db0ff6eeca6 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2129,7 +2129,7 @@ void txt_do_undo(Text *text) case UNDO_IBLOCK: linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); txt_delete_sel(text); - + /* txt_backspace_char removes utf8-characters, not bytes */ buf= MEM_mallocN(linep+1, "iblock buffer"); for (i=0; i < linep; i++) { @@ -2139,19 +2139,19 @@ void txt_do_undo(Text *text) buf[i]= 0; linep= txt_utf8_len(buf); MEM_freeN(buf); - + while (linep>0) { txt_backspace_char(text); linep--; } - + text->undo_pos--; text->undo_pos--; text->undo_pos--; text->undo_pos--; text->undo_pos--; - + break; case UNDO_INDENT: case UNDO_UNINDENT: @@ -2169,7 +2169,7 @@ void txt_do_undo(Text *text) for (i= 0; i < linep; i++) { text->sell = text->sell->next; } - + linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); //first line to be selected @@ -2180,7 +2180,7 @@ void txt_do_undo(Text *text) for (i = 0; i < linep; i++) { text->curl = text->curl->next; } - + if (op==UNDO_INDENT) { txt_unindent(text); @@ -2194,12 +2194,18 @@ void txt_do_undo(Text *text) else if (op == UNDO_UNCOMMENT) { txt_comment(text); } - + text->undo_pos--; break; case UNDO_DUPLICATE: txt_delete_line(text, text->curl->next); break; + case UNDO_MOVE_LINES_UP: + txt_move_lines_down(text); + break; + case UNDO_MOVE_LINES_DOWN: + txt_move_lines_up(text); + break; default: //XXX error("Undo buffer error - resetting"); text->undo_pos= -1; @@ -2400,10 +2406,16 @@ void txt_do_redo(Text *text) case UNDO_DUPLICATE: txt_duplicate_line(text); break; + case UNDO_MOVE_LINES_UP: + txt_move_lines_up(text); + break; + case UNDO_MOVE_LINES_DOWN: + txt_move_lines_down(text); + break; default: //XXX error("Undo buffer error - resetting"); text->undo_pos= -1; - + break; } @@ -3033,6 +3045,53 @@ void txt_uncomment(Text *text) } } + +void txt_move_lines_up(struct Text *text) +{ + TextLine *prev_line; + + if (!text || !text->curl || !text->sell) return; + + txt_order_cursors(text); + + prev_line= text->curl->prev; + + if (!prev_line) return; + + BLI_remlink(&text->lines, prev_line); + BLI_insertlinkafter(&text->lines, text->sell, prev_line); + + txt_make_dirty(text); + txt_clean_text(text); + + if (!undoing) { + txt_undo_add_op(text, UNDO_MOVE_LINES_UP); + } +} + +void txt_move_lines_down(struct Text *text) +{ + TextLine *next_line; + + if (!text || !text->curl || !text->sell) return; + + txt_order_cursors(text); + + next_line= text->sell->next; + + if (!next_line) return; + + BLI_remlink(&text->lines, next_line); + BLI_insertlinkbefore(&text->lines, text->curl, next_line); + + txt_make_dirty(text); + txt_clean_text(text); + + if (!undoing) { + txt_undo_add_op(text, UNDO_MOVE_LINES_DOWN); + } +} + int setcurr_tab_spaces(Text *text, int space) { int i = 0; diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 032cc4ecbf2..ddff1fe603f 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -202,6 +202,9 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_select_line); WM_operatortype_append(TEXT_OT_select_all); WM_operatortype_append(TEXT_OT_select_word); + + WM_operatortype_append(TEXT_OT_move_lines_up); + WM_operatortype_append(TEXT_OT_move_lines_down); WM_operatortype_append(TEXT_OT_jump); WM_operatortype_append(TEXT_OT_move); @@ -321,7 +324,9 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_word", LEFTMOUSE, KM_DBL_CLICK, 0, 0); - + WM_keymap_add_item(keymap, "TEXT_OT_move_lines_up", UPARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_move_lines_down", DOWNARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_unindent", TABKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "TEXT_OT_uncomment", DKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 07d2dffb95b..be6287a939c 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -137,6 +137,9 @@ void TEXT_OT_select_line(struct wmOperatorType *ot); void TEXT_OT_select_all(struct wmOperatorType *ot); void TEXT_OT_select_word(struct wmOperatorType *ot); +void TEXT_OT_move_lines_up(struct wmOperatorType *ot); +void TEXT_OT_move_lines_down(struct wmOperatorType *ot); + void TEXT_OT_jump(struct wmOperatorType *ot); void TEXT_OT_move(struct wmOperatorType *ot); void TEXT_OT_move_select(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index f60217ba8ac..cb8daa0f03e 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1331,6 +1331,64 @@ void TEXT_OT_select_word(wmOperatorType *ot) ot->poll = text_edit_poll; } +/********************* move lines operators ***********************/ + +static int move_lines_up_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Text *text = CTX_data_edit_text(C); + + txt_move_lines_up(text); + + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + + /* run the script while editing, evil but useful */ + if (CTX_wm_space_text(C)->live_edit) + text_run_script(C, NULL); + + return OPERATOR_FINISHED; +} + +void TEXT_OT_move_lines_up(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Move Lines Up"; + ot->idname = "TEXT_OT_move_lines_up"; + ot->description = "Moves the currently selected line(s) up."; + + /* api callbacks */ + ot->exec = move_lines_up_exec; + ot->poll = text_edit_poll; +} + +static int move_lines_down_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Text *text = CTX_data_edit_text(C); + + txt_move_lines_down(text); + + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + + /* run the script while editing, evil but useful */ + if (CTX_wm_space_text(C)->live_edit) + text_run_script(C, NULL); + + return OPERATOR_FINISHED; +} + +void TEXT_OT_move_lines_down(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Move Lines Down"; + ot->idname = "TEXT_OT_move_lines_down"; + ot->description = "Moves the currently selected line(s) down."; + + /* api callbacks */ + ot->exec = move_lines_down_exec; + ot->poll = text_edit_poll; +} + /******************* previous marker operator *********************/ static int text_previous_marker_exec(bContext *C, wmOperator *UNUSED(op)) From 133bdac1d0cfe92084361f59bbd44b2ecd8127eb Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 4 May 2012 14:34:10 +0000 Subject: [PATCH 54/88] Patch [#31279] clarifiy a python error-string (when incorrectly specifying enum items from python) Thanks Philipp Oeser (lichtwerk) --- source/blender/python/intern/bpy_props.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 4d0c05f6582..dbb25eb854b 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1071,8 +1071,8 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i else { MEM_freeN(items); PyErr_SetString(PyExc_TypeError, - "EnumProperty(...): expected an tuple containing " - "(identifier, name description) and optionally a " + "EnumProperty(...): expected a tuple containing " + "(identifier, name, description) and optionally a " "unique number"); return NULL; } From b178ee5cd0cca580d000475ad95f64148faa7479 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 4 May 2012 15:00:36 +0000 Subject: [PATCH 55/88] First part of fix for [#31157]: Some (actually, 172) operators have no tooltip. Notes: * This commit adds about a third of missing tips (a few are rather dummy, as name already says everything, but better that than "(undocumented operator)" showing in UI! * There is a problem with macros, their tips are not registered in RNA. Got a patch for this, will submit it to campbo asap. --- source/blender/editors/animation/keyframing.c | 2 ++ source/blender/editors/animation/keyingsets.c | 3 +++ source/blender/editors/curve/editcurve.c | 20 +++++++++++++++++++ source/blender/editors/curve/editfont.c | 1 + .../blender/editors/physics/particle_boids.c | 2 ++ source/blender/editors/space_clip/clip_ops.c | 7 +++++++ .../blender/editors/space_image/image_ops.c | 18 +++++++++++++++++ source/blender/editors/space_info/info_ops.c | 7 +++++++ 8 files changed, 60 insertions(+) diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4dd3406dafc..9d51b42f1a2 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1479,6 +1479,7 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) /* identifiers */ ot->name = "Insert Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_insert_button"; + ot->description = "Insert a keyframe keyframe for current UI-active property"; /* callbacks */ ot->exec = insert_key_button_exec; @@ -1551,6 +1552,7 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) /* identifiers */ ot->name = "Delete Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_delete_button"; + ot->description = "Delete current keyframe of current UI-active property"; /* callbacks */ ot->exec = delete_key_button_exec; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index f9c4082e429..925cffca288 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -373,6 +373,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add to Keying Set"; ot->idname = "ANIM_OT_keyingset_button_add"; + ot->description = "Add current UI-active property to current keying set"; /* callbacks */ ot->exec = add_keyingset_button_exec; @@ -452,6 +453,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove from Keying Set"; ot->idname = "ANIM_OT_keyingset_button_remove"; + ot->description = "Remove current UI-active property from current keying set"; /* callbacks */ ot->exec = remove_keyingset_button_exec; @@ -501,6 +503,7 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Active Keying Set"; ot->idname = "ANIM_OT_keying_set_active_set"; + ot->description = "Select a new keying set as the active one"; /* callbacks */ ot->invoke = keyingset_active_menu_invoke; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 58c091dec11..09c01c2bf8c 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1416,6 +1416,7 @@ void CURVE_OT_separate(wmOperatorType *ot) /* identifiers */ ot->name = "Separate"; ot->idname = "CURVE_OT_separate"; + ot->description = "Separate (partly) selected curves or surfaces into a new object"; /* api callbacks */ ot->exec = separate_exec; @@ -2532,6 +2533,7 @@ void CURVE_OT_de_select_first(wmOperatorType *ot) /* identifiers */ ot->name = "(De)select First"; ot->idname = "CURVE_OT_de_select_first"; + ot->description = "(De)select first of visible part of each Nurb"; /* api cfirstbacks */ ot->exec = de_select_first_exec; @@ -2556,6 +2558,7 @@ void CURVE_OT_de_select_last(wmOperatorType *ot) /* identifiers */ ot->name = "(De)select Last"; ot->idname = "CURVE_OT_de_select_last"; + ot->description = "(De)select last of visible part of each Nurb"; /* api clastbacks */ ot->exec = de_select_last_exec; @@ -2637,6 +2640,7 @@ void CURVE_OT_select_all(wmOperatorType *ot) /* identifiers */ ot->name = "(De)select All"; ot->idname = "CURVE_OT_select_all"; + ot->description = "(De)select all control points"; /* api callbacks */ ot->exec = de_select_all_exec; @@ -2711,6 +2715,7 @@ void CURVE_OT_hide(wmOperatorType *ot) /* identifiers */ ot->name = "Hide Selected"; ot->idname = "CURVE_OT_hide"; + ot->description = "Hide (un)selected control points"; /* api callbacks */ ot->exec = hide_exec; @@ -2771,6 +2776,7 @@ void CURVE_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name = "Reveal Hidden"; ot->idname = "CURVE_OT_reveal"; + ot->description = "Show again hidden control points"; /* api callbacks */ ot->exec = reveal_exec; @@ -4118,6 +4124,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /* identifiers */ ot->name = "Make Segment"; ot->idname = "CURVE_OT_make_segment"; + ot->description = "Join two curves by their selected ends"; /* api callbacks */ ot->exec = make_segment_exec; @@ -4353,6 +4360,7 @@ void CURVE_OT_spin(wmOperatorType *ot) /* identifiers */ ot->name = "Spin"; ot->idname = "CURVE_OT_spin"; + ot->description = "Extrude selected boundary row around pivot point and current view axis"; /* api callbacks */ ot->exec = spin_exec; @@ -4687,6 +4695,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Vertex"; ot->idname = "CURVE_OT_vertex_add"; + ot->description = "Add a new control point (linked to only selected end-curve one, if any)"; /* api callbacks */ ot->exec = add_vertex_exec; @@ -4940,6 +4949,7 @@ void CURVE_OT_select_linked(wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked All"; ot->idname = "CURVE_OT_select_linked"; + ot->description = "Select all control points linked to active one"; /* api callbacks */ ot->exec = select_linked_exec; @@ -5000,6 +5010,7 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked"; ot->idname = "CURVE_OT_select_linked_pick"; + ot->description = "Select all control points linked to already selected ones"; /* api callbacks */ ot->invoke = select_linked_pick_invoke; @@ -5078,6 +5089,7 @@ void CURVE_OT_select_row(wmOperatorType *ot) /* identifiers */ ot->name = "Select Control Point Row"; ot->idname = "CURVE_OT_select_row"; + ot->description = "Select a row of control points including active one"; /* api callbacks */ ot->exec = select_row_exec; @@ -5105,6 +5117,7 @@ void CURVE_OT_select_next(wmOperatorType *ot) /* identifiers */ ot->name = "Select Next"; ot->idname = "CURVE_OT_select_next"; + ot->description = "Select control points following already selected ones along the curves"; /* api callbacks */ ot->exec = select_next_exec; @@ -5132,6 +5145,7 @@ void CURVE_OT_select_previous(wmOperatorType *ot) /* identifiers */ ot->name = "Select Previous"; ot->idname = "CURVE_OT_select_previous"; + ot->description = "Select control points preceding already selected ones along the curves"; /* api callbacks */ ot->exec = select_previous_exec; @@ -5219,6 +5233,7 @@ void CURVE_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name = "Select More"; ot->idname = "CURVE_OT_select_more"; + ot->description = "Select control points linked to already selected ones"; /* api callbacks */ ot->exec = select_more_exec; @@ -5380,6 +5395,7 @@ void CURVE_OT_select_less(wmOperatorType *ot) /* identifiers */ ot->name = "Select Less"; ot->idname = "CURVE_OT_select_less"; + ot->description = "Reduce current selection by deselecting boundary elements"; /* api callbacks */ ot->exec = select_less_exec; @@ -5443,6 +5459,7 @@ void CURVE_OT_select_random(wmOperatorType *ot) /* identifiers */ ot->name = "Select Random"; ot->idname = "CURVE_OT_select_random"; + ot->description = "Randomly select some control points"; /* api callbacks */ ot->exec = select_random_exec; @@ -6028,6 +6045,7 @@ void CURVE_OT_shade_smooth(wmOperatorType *ot) /* identifiers */ ot->name = "Shade Smooth"; ot->idname = "CURVE_OT_shade_smooth"; + ot->description = "Set shading to smooth"; /* api callbacks */ ot->exec = shade_smooth_exec; @@ -6042,6 +6060,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) /* identifiers */ ot->name = "Shade Flat"; ot->idname = "CURVE_OT_shade_flat"; + ot->description = "Set shading to flat"; /* api callbacks */ ot->exec = shade_smooth_exec; @@ -6914,6 +6933,7 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Tilt"; ot->idname = "CURVE_OT_tilt_clear"; + ot->description = "Clear the tilt of selected control points"; /* api callbacks */ ot->exec = clear_tilt_exec; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index cca5dd7a37b..0a976e6ed6b 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1696,6 +1696,7 @@ void FONT_OT_open(wmOperatorType *ot) /* identifiers */ ot->name = "Open Font"; ot->idname = "FONT_OT_open"; + ot->description = "Load a new font from a file"; /* api callbacks */ ot->exec = font_open_exec; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 7a7c16b23ff..23ce4776b73 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -145,6 +145,7 @@ void BOID_OT_rule_del(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Boid Rule"; ot->idname = "BOID_OT_rule_del"; + ot->description = "Delete current boid rule"; /* api callbacks */ ot->exec = rule_del_exec; @@ -318,6 +319,7 @@ void BOID_OT_state_del(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Boid State"; ot->idname = "BOID_OT_state_del"; + ot->description = "Delete current boid state"; /* api callbacks */ ot->exec = state_del_exec; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 06573136205..b05d204b07b 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -402,6 +402,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot) /* identifiers */ ot->name = "View Pan"; ot->idname = "CLIP_OT_view_pan"; + ot->description = "Pan the view"; /* api callbacks */ ot->exec = view_pan_exec; @@ -528,6 +529,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom"; ot->idname = "CLIP_OT_view_zoom"; + ot->description = "Zoom on/out the view"; /* api callbacks */ ot->exec = view_zoom_exec; @@ -576,6 +578,7 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom In"; ot->idname = "CLIP_OT_view_zoom_in"; + ot->description = "Zoom in the view"; /* api callbacks */ ot->exec = view_zoom_in_exec; @@ -616,6 +619,7 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom Out"; ot->idname = "CLIP_OT_view_zoom_out"; + ot->description = "Zoom out the view"; /* api callbacks */ ot->exec = view_zoom_out_exec; @@ -649,6 +653,7 @@ void CLIP_OT_view_zoom_ratio(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom Ratio"; ot->idname = "CLIP_OT_view_zoom_ratio"; + ot->description = "Set the zoom ratio (based on clip size)"; /* api callbacks */ ot->exec = view_zoom_ratio_exec; @@ -716,6 +721,7 @@ void CLIP_OT_view_all(wmOperatorType *ot) /* identifiers */ ot->name = "View All"; ot->idname = "CLIP_OT_view_all"; + ot->description = "View whole image with markers"; /* api callbacks */ ot->exec = view_all_exec; @@ -746,6 +752,7 @@ void CLIP_OT_view_selected(wmOperatorType *ot) /* identifiers */ ot->name = "View Selected"; ot->idname = "CLIP_OT_view_selected"; + ot->description = "View all selected elements"; /* api callbacks */ ot->exec = view_selected_exec; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d9f3ffafb14..bbc12520978 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -334,6 +334,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) /* identifiers */ ot->name = "View Pan"; ot->idname = "IMAGE_OT_view_pan"; + ot->description = "Pan the view"; /* api callbacks */ ot->exec = image_view_pan_exec; @@ -471,6 +472,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom"; ot->idname = "IMAGE_OT_view_zoom"; + ot->description = "Zoom in/out the image"; /* api callbacks */ ot->exec = image_view_zoom_exec; @@ -539,6 +541,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot) /* identifiers */ ot->name = "NDOF Pan/Zoom"; ot->idname = "IMAGE_OT_view_ndof"; + ot->description = "Use a 3D mouse device to pan/zoom the view"; /* api callbacks */ ot->invoke = image_view_ndof_invoke; @@ -592,6 +595,7 @@ void IMAGE_OT_view_all(wmOperatorType *ot) /* identifiers */ ot->name = "View All"; ot->idname = "IMAGE_OT_view_all"; + ot->description = "View the whole picture"; /* api callbacks */ ot->exec = image_view_all_exec; @@ -653,6 +657,7 @@ void IMAGE_OT_view_selected(wmOperatorType *ot) /* identifiers */ ot->name = "View Center"; ot->idname = "IMAGE_OT_view_selected"; + ot->description = "View all selected UVs"; /* api callbacks */ ot->exec = image_view_selected_exec; @@ -692,6 +697,7 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom In"; ot->idname = "IMAGE_OT_view_zoom_in"; + ot->description = "Zoom in the image (centered around 2D cursor)"; /* api callbacks */ ot->invoke = image_view_zoom_in_invoke; @@ -733,6 +739,7 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom Out"; ot->idname = "IMAGE_OT_view_zoom_out"; + ot->description = "Zoom out the image (centered around 2D cursor)"; /* api callbacks */ ot->invoke = image_view_zoom_out_invoke; @@ -775,6 +782,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom Ratio"; ot->idname = "IMAGE_OT_view_zoom_ratio"; + ot->description = "Set zoom ration of the view"; /* api callbacks */ ot->exec = image_view_zoom_ratio_exec; @@ -978,6 +986,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) /* identifiers */ ot->name = "Replace Image"; ot->idname = "IMAGE_OT_replace"; + ot->description = "Replace current image by another one from disk"; /* api callbacks */ ot->exec = image_replace_exec; @@ -1316,6 +1325,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) /* identifiers */ ot->name = "Save As Image"; ot->idname = "IMAGE_OT_save_as"; + ot->description = "Save the image with another name and/or settings"; /* api callbacks */ ot->exec = image_save_as_exec; @@ -1362,6 +1372,7 @@ void IMAGE_OT_save(wmOperatorType *ot) /* identifiers */ ot->name = "Save Image"; ot->idname = "IMAGE_OT_save"; + ot->description = "Save the image with current name and settings"; /* api callbacks */ ot->exec = image_save_exec; @@ -1439,6 +1450,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot) /* identifiers */ ot->name = "Save Sequence"; ot->idname = "IMAGE_OT_save_sequence"; + ot->description = "Save a sequence of images"; /* api callbacks */ ot->exec = image_save_sequence_exec; @@ -1474,6 +1486,7 @@ void IMAGE_OT_reload(wmOperatorType *ot) /* identifiers */ ot->name = "Reload Image"; ot->idname = "IMAGE_OT_reload"; + ot->description = "Reload current image from disk"; /* api callbacks */ ot->exec = image_reload_exec; @@ -1646,6 +1659,7 @@ void IMAGE_OT_invert(wmOperatorType *ot) /* identifiers */ ot->name = "Invert Channels"; ot->idname = "IMAGE_OT_invert"; + ot->description = "Invert image's channels"; /* api callbacks */ ot->exec = image_invert_exec; @@ -2021,6 +2035,7 @@ void IMAGE_OT_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Sample Color"; ot->idname = "IMAGE_OT_sample"; + ot->description = "Use mouse to sample a color in current image"; /* api callbacks */ ot->invoke = image_sample_invoke; @@ -2130,6 +2145,7 @@ void IMAGE_OT_sample_line(wmOperatorType *ot) /* identifiers */ ot->name = "Sample Line"; ot->idname = "IMAGE_OT_sample_line"; + ot->description = "Sample a line and show it in Scope panels"; /* api callbacks */ ot->invoke = image_sample_line_invoke; @@ -2157,6 +2173,7 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Curves Point"; ot->idname = "IMAGE_OT_curves_point_set"; + ot->description = "Set black or white point for curves"; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2362,6 +2379,7 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot) /* identifiers */ ot->name = "Cycle Render Slot"; ot->idname = "IMAGE_OT_cycle_render_slot"; + ot->description = "Cycle through all non-void render slots"; /* api callbacks */ ot->exec = image_cycle_render_slot_exec; diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 5256fc8f044..4698c734f8e 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -107,6 +107,7 @@ void FILE_OT_pack_all(wmOperatorType *ot) /* identifiers */ ot->name = "Pack All"; ot->idname = "FILE_OT_pack_all"; + ot->description = "Pack all used external files into the .blend"; /* api callbacks */ ot->exec = pack_all_exec; @@ -175,6 +176,7 @@ void FILE_OT_unpack_all(wmOperatorType *ot) /* identifiers */ ot->name = "Unpack All"; ot->idname = "FILE_OT_unpack_all"; + ot->description = "Unpack all files packed into this .blend to external ones"; /* api callbacks */ ot->exec = unpack_all_exec; @@ -211,6 +213,7 @@ void FILE_OT_make_paths_relative(wmOperatorType *ot) /* identifiers */ ot->name = "Make All Paths Relative"; ot->idname = "FILE_OT_make_paths_relative"; + ot->description = "Make all paths to external files relative to current .blend"; /* api callbacks */ ot->exec = make_paths_relative_exec; @@ -243,6 +246,7 @@ void FILE_OT_make_paths_absolute(wmOperatorType *ot) /* identifiers */ ot->name = "Make All Paths Absolute"; ot->idname = "FILE_OT_make_paths_absolute"; + ot->description = "Make all paths to external files absolute"; /* api callbacks */ ot->exec = make_paths_absolute_exec; @@ -268,6 +272,7 @@ void FILE_OT_report_missing_files(wmOperatorType *ot) /* identifiers */ ot->name = "Report Missing Files"; ot->idname = "FILE_OT_report_missing_files"; + ot->description = "Report all missing external files"; /* api callbacks */ ot->exec = report_missing_files_exec; @@ -300,6 +305,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) /* identifiers */ ot->name = "Find Missing Files"; ot->idname = "FILE_OT_find_missing_files"; + ot->description = "Try to find missing external files"; /* api callbacks */ ot->exec = find_missing_files_exec; @@ -414,6 +420,7 @@ void INFO_OT_reports_display_update(wmOperatorType *ot) /* identifiers */ ot->name = "Update Reports Display"; ot->idname = "INFO_OT_reports_display_update"; + ot->description = "Update the display of reports in Blender UI (internal use)"; /* api callbacks */ ot->invoke = update_reports_display_invoke; From 65b5362c74acbba58c3098715660e441ab25141b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2012 15:02:02 +0000 Subject: [PATCH 56/88] fix [#31235] Limited Dissolve problems this is in fact 2 bugs. - unselected edges between 2 faces that were joined didnt get removed. - in face mode, edges and verts at the boundary of the selection would get incorrectly dissolved. also quiet float/double promotion warning. --- source/blender/bmesh/operators/bmo_dissolve.c | 46 +++++++++++++------ source/blender/editors/mesh/editmesh_tools.c | 36 ++++++++++++++- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 8e7723fefdd..ae1773af05e 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -478,8 +478,8 @@ void dummy_exec(BMesh *bm, BMOperator *op) /* Limited Dissolve */ -#define UNIT_TO_ANGLE DEG2RADF(90.0) -#define ANGLE_TO_UNIT (1.0 / UNIT_TO_ANGLE) +#define UNIT_TO_ANGLE DEG2RADF(90.0f) +#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE) /* multiply vertex edge angle by face angle * this means we are not left with sharp corners between _almost_ planer faces @@ -523,8 +523,17 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) sizeof(DissolveElemWeight), __func__); int i, tot_found; + BMIter iter; + BMEdge *e_iter; + BMEdge **earray; + /* --- first edges --- */ + /* wire -> tag */ + BM_ITER_MESH(e_iter, &iter, bm, BM_EDGES_OF_MESH) { + BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter)); + } + /* go through and split edge */ for (i = 0, tot_found = 0; i < einput->len; i++) { BMEdge *e = ((BMEdge **)einput->data.p)[i]; @@ -562,18 +571,6 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) } } } - - /* remove all edges/verts left behind from dissolving */ - for (i = 0; i < einput->len; i++) { - BMEdge *e = (BMEdge *)weight_elems[i].ele; - if (BM_edge_is_wire(e)) { - BMVert *v1 = e->v1; - BMVert *v2 = e->v2; - BM_edge_kill(bm, e); - if (v1->e == NULL) BM_vert_kill(bm, v1); - if (v2->e == NULL) BM_vert_kill(bm, v2); - } - } } /* --- second verts --- */ @@ -612,4 +609,25 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) } MEM_freeN(weight_elems); + + /* --- cleanup --- */ + earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__); + BM_ITER_MESH_INDEX(e_iter, &iter, bm, BM_EDGES_OF_MESH, i) { + earray[i] = e_iter; + } + /* remove all edges/verts left behind from dissolving */ + for (i = bm->totedge - 1; i != -1; i--) { + e_iter = earray[i]; + + if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) { + /* edge has become wire */ + BMVert *v1 = e_iter->v1; + BMVert *v2 = e_iter->v2; + BM_edge_kill(bm, e_iter); + if (v1->e == NULL) BM_vert_kill(bm, v1); + if (v2->e == NULL) BM_vert_kill(bm, v2); + } + } + + MEM_freeN(earray); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 524ee029339..96cfd95b96a 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3205,11 +3205,45 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); + BMesh *bm = em->bm; float angle_limit = RNA_float_get(op->ptr, "angle_limit"); + char dissolve_flag; + + if (em->selectmode == SCE_SELECT_FACE) { + /* flush selection to tags and untag edges/verts with partially selected faces */ + BMIter iter; + BMIter liter; + + BMElem *ele; + BMFace *f; + BMLoop *l; + + BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { + BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT)); + } + BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { + BM_elem_flag_set(ele, BM_ELEM_TAG, BM_elem_flag_test(ele, BM_ELEM_SELECT)); + } + + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) { + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + BM_elem_flag_disable(l->v, BM_ELEM_TAG); + BM_elem_flag_disable(l->e, BM_ELEM_TAG); + } + } + } + + dissolve_flag = BM_ELEM_TAG; + } + else { + dissolve_flag = BM_ELEM_SELECT; + } + if (!EDBM_op_callf(em, op, "dissolve_limit edges=%he verts=%hv angle_limit=%f", - BM_ELEM_SELECT, BM_ELEM_SELECT, angle_limit)) + dissolve_flag, dissolve_flag, angle_limit)) { return OPERATOR_CANCELLED; } From 1fd397d2d6ce5f9036c606963060eaf5f49d72c4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 May 2012 15:42:49 +0000 Subject: [PATCH 57/88] Split do_versions into separate files for pre-2.50 versions and 2.5x versions This should make it easier to navigate through readfile.c and also hopefully will prevent corereview to fail parsing this file. --- source/blender/blenloader/CMakeLists.txt | 2 + source/blender/blenloader/intern/readfile.c | 6017 +---------------- source/blender/blenloader/intern/readfile.h | 18 + .../blenloader/intern/versioning_250.c | 2677 ++++++++ .../blenloader/intern/versioning_legacy.c | 3570 ++++++++++ 5 files changed, 6290 insertions(+), 5994 deletions(-) create mode 100644 source/blender/blenloader/intern/versioning_250.c create mode 100644 source/blender/blenloader/intern/versioning_legacy.c diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 35271f7b873..a0fe042e7fb 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -44,6 +44,8 @@ set(SRC intern/readfile.c intern/runtime.c intern/undofile.c + intern/versioning_250.c + intern/versioning_legacy.c intern/writefile.c BLO_readfile.h diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index df71a9f6494..cab45f58e2e 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -328,6 +328,11 @@ static void oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int n entry->nr= nr; } +void blo_do_versions_oldnewmap_insert(OldNewMap *onm, void *oldaddr, void *newaddr, int nr) +{ + oldnewmap_insert(onm, oldaddr, newaddr, nr); +} + static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr) { int i; @@ -1177,6 +1182,11 @@ static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */ return oldnewmap_liblookup(fd->libmap, adr, lib); } +void *blo_do_versions_newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */ +{ + return newlibadr(fd, lib, adr); +} + static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */ { ID *id= newlibadr(fd, lib, adr); @@ -1187,6 +1197,11 @@ static void *newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user return id; } +void *blo_do_versions_newlibadr_us(FileData *fd, void *lib, void *adr) /* increases user number */ +{ + return newlibadr_us(fd, lib, adr); +} + static void change_idid_adr_fd(FileData *fd, void *old, void *new) { int i; @@ -2202,7 +2217,7 @@ static void do_versions_socket_default_value(bNodeSocket *sock) } } -static void do_versions_nodetree_default_value(bNodeTree *ntree) +void blo_do_versions_nodetree_default_value(bNodeTree *ntree) { bNode *node; bNodeSocket *sock; @@ -2225,7 +2240,7 @@ static void lib_nodetree_init_types_cb(void *UNUSED(data), ID *UNUSED(id), bNode ntreeInitTypes(ntree); /* need to do this here instead of in do_versions, otherwise next function can crash */ - do_versions_nodetree_default_value(ntree); + blo_do_versions_nodetree_default_value(ntree); /* XXX could be replaced by do_versions for new nodes */ for (node=ntree->nodes.first; node; node=node->next) @@ -5713,7 +5728,7 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype) /* for the saved 2.50 files without regiondata */ /* and as patch for 2.48 and older */ -static void view3d_split_250(View3D *v3d, ListBase *regions) +void blo_do_versions_view3d_split_250(View3D *v3d, ListBase *regions) { ARegion *ar; @@ -5799,7 +5814,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } /* add local view3d too */ else if (sa->spacetype==SPACE_VIEW3D) - view3d_split_250(sa->spacedata.first, &sa->regionbase); + blo_do_versions_view3d_split_250(sa->spacedata.first, &sa->regionbase); for (sl= sa->spacedata.first; sl; sl= sl->next) { link_list(fd, &(sl->regionbase)); @@ -5839,7 +5854,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc) if (v3d->drawtype == OB_RENDER) v3d->drawtype = OB_WIRE; - view3d_split_250(v3d, &sl->regionbase); + blo_do_versions_view3d_split_250(v3d, &sl->regionbase); } else if (sl->spacetype==SPACE_IPO) { SpaceIpo *sipo= (SpaceIpo*)sl; @@ -6494,1012 +6509,7 @@ static void link_global(FileData *fd, BlendFileData *bfd) } } -static void vcol_to_fcol(Mesh *me) -{ - MFace *mface; - unsigned int *mcol, *mcoln, *mcolmain; - int a; - - if (me->totface==0 || me->mcol==NULL) return; - - mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln"); - mcol = (unsigned int *)me->mcol; - mface= me->mface; - for (a=me->totface; a>0; a--, mface++) { - mcoln[0]= mcol[mface->v1]; - mcoln[1]= mcol[mface->v2]; - mcoln[2]= mcol[mface->v3]; - mcoln[3]= mcol[mface->v4]; - mcoln+= 4; - } - - MEM_freeN(me->mcol); - me->mcol= (MCol *)mcolmain; -} - -static int map_223_keybd_code_to_224_keybd_code(int code) -{ - switch (code) { - case 312: return 311; /* F12KEY */ - case 159: return 161; /* PADSLASHKEY */ - case 161: return 150; /* PAD0 */ - case 154: return 151; /* PAD1 */ - case 150: return 152; /* PAD2 */ - case 155: return 153; /* PAD3 */ - case 151: return 154; /* PAD4 */ - case 156: return 155; /* PAD5 */ - case 152: return 156; /* PAD6 */ - case 157: return 157; /* PAD7 */ - case 153: return 158; /* PAD8 */ - case 158: return 159; /* PAD9 */ - default: return code; - } -} - -static void do_version_bone_head_tail_237(Bone *bone) -{ - Bone *child; - float vec[3]; - - /* head */ - copy_v3_v3(bone->arm_head, bone->arm_mat[3]); - - /* tail is in current local coord system */ - copy_v3_v3(vec, bone->arm_mat[1]); - mul_v3_fl(vec, bone->length); - add_v3_v3v3(bone->arm_tail, bone->arm_head, vec); - - for (child= bone->childbase.first; child; child= child->next) - do_version_bone_head_tail_237(child); -} - -static void bone_version_238(ListBase *lb) -{ - Bone *bone; - - for (bone= lb->first; bone; bone= bone->next) { - if (bone->rad_tail==0.0f && bone->rad_head==0.0f) { - bone->rad_head= 0.25f*bone->length; - bone->rad_tail= 0.1f*bone->length; - - bone->dist-= bone->rad_head; - if (bone->dist<=0.0f) bone->dist= 0.0f; - } - bone_version_238(&bone->childbase); - } -} - -static void bone_version_239(ListBase *lb) -{ - Bone *bone; - - for (bone= lb->first; bone; bone= bone->next) { - if (bone->layer==0) - bone->layer= 1; - bone_version_239(&bone->childbase); - } -} - -static void ntree_version_241(bNodeTree *ntree) -{ - bNode *node; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_BLUR) { - if (node->storage==NULL) { - NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch"); - nbd->sizex= node->custom1; - nbd->sizey= node->custom2; - nbd->filtertype= R_FILTER_QUAD; - node->storage= nbd; - } - } - else if (node->type==CMP_NODE_VECBLUR) { - if (node->storage==NULL) { - NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch"); - nbd->samples= node->custom1; - nbd->maxspeed= node->custom2; - nbd->fac= 1.0f; - node->storage= nbd; - } - } - } - } -} - -static void ntree_version_242(bNodeTree *ntree) -{ - bNode *node; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_HUE_SAT) { - if (node->storage) { - NodeHueSat *nhs= node->storage; - if (nhs->val==0.0f) nhs->val= 1.0f; - } - } - } - } - else if (ntree->type==NTREE_SHADER) { - for (node= ntree->nodes.first; node; node= node->next) - if (node->type == SH_NODE_GEOMETRY && node->storage == NULL) - node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); - } - -} - -static void customdata_version_242(Mesh *me) -{ - CustomDataLayer *layer; - MTFace *mtf; - MCol *mcol; - TFace *tf; - int a, mtfacen, mcoln; - - if (!me->vdata.totlayer) { - CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert); - - if (me->msticky) - CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_ASSIGN, me->msticky, me->totvert); - if (me->dvert) - CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert); - } - - if (!me->edata.totlayer) - CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge); - - if (!me->fdata.totlayer) { - CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface); - - if (me->tface) { - if (me->mcol) - MEM_freeN(me->mcol); - - me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface); - me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface); - - mtf= me->mtface; - mcol= me->mcol; - tf= me->tface; - - for (a=0; a < me->totface; a++, mtf++, tf++, mcol+=4) { - memcpy(mcol, tf->col, sizeof(tf->col)); - memcpy(mtf->uv, tf->uv, sizeof(tf->uv)); - - mtf->flag= tf->flag; - mtf->unwrap= tf->unwrap; - mtf->mode= tf->mode; - mtf->tile= tf->tile; - mtf->tpage= tf->tpage; - mtf->transp= tf->transp; - } - - MEM_freeN(me->tface); - me->tface= NULL; - } - else if (me->mcol) { - me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface); - } - } - - if (me->tface) { - MEM_freeN(me->tface); - me->tface= NULL; - } - - for (a=0, mtfacen=0, mcoln=0; a < me->fdata.totlayer; a++) { - layer= &me->fdata.layers[a]; - - if (layer->type == CD_MTFACE) { - if (layer->name[0] == 0) { - if (mtfacen == 0) strcpy(layer->name, "UVMap"); - else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen); - } - mtfacen++; - } - else if (layer->type == CD_MCOL) { - if (layer->name[0] == 0) { - if (mcoln == 0) strcpy(layer->name, "Col"); - else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); - } - mcoln++; - } - } - - mesh_update_customdata_pointers(me, TRUE); -} - -/*only copy render texface layer from active*/ -static void customdata_version_243(Mesh *me) -{ - CustomDataLayer *layer; - int a; - - for (a=0; a < me->fdata.totlayer; a++) { - layer= &me->fdata.layers[a]; - layer->active_rnd = layer->active; - } -} - -/* struct NodeImageAnim moved to ImageUser, and we make it default available */ -static void do_version_ntree_242_2(bNodeTree *ntree) -{ - bNode *node; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { - if (ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { - /* only image had storage */ - if (node->storage) { - NodeImageAnim *nia= node->storage; - ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "ima user node"); - - iuser->frames= nia->frames; - iuser->sfra= nia->sfra; - iuser->offset= nia->nr-1; - iuser->cycl= nia->cyclic; - iuser->fie_ima= 2; - iuser->ok= 1; - - node->storage= iuser; - MEM_freeN(nia); - } - else { - ImageUser *iuser= node->storage= MEM_callocN(sizeof(ImageUser), "node image user"); - iuser->sfra= 1; - iuser->fie_ima= 2; - iuser->ok= 1; - } - } - } - } -} - -static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) -{ - bNode *node; - NodeTwoFloats *ntf; - ID *nodeid; - Image *image; - ImageUser *iuser; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { - if (node->type == CMP_NODE_ALPHAOVER) { - if (!node->storage) { - ntf= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); - node->storage= ntf; - if (node->custom1) - ntf->x= 1.0f; - } - } - - /* fix for temporary flag changes during 245 cycle */ - nodeid= newlibadr(fd, lib, node->id); - if (node->storage && nodeid && GS(nodeid->name) == ID_IM) { - image= (Image*)nodeid; - iuser= node->storage; - if (iuser->flag & IMA_OLD_PREMUL) { - iuser->flag &= ~IMA_OLD_PREMUL; - iuser->flag |= IMA_DO_PREMUL; - } - if (iuser->flag & IMA_DO_PREMUL) { - image->flag &= ~IMA_OLD_PREMUL; - image->flag |= IMA_DO_PREMUL; - } - } - } - } -} - -static void idproperties_fix_groups_lengths_recurse(IDProperty *prop) -{ - IDProperty *loop; - int i; - - for (loop=prop->data.group.first, i=0; loop; loop=loop->next, i++) { - if (loop->type == IDP_GROUP) idproperties_fix_groups_lengths_recurse(loop); - } - - if (prop->len != i) { - printf("Found and fixed bad id property group length.\n"); - prop->len = i; - } -} - -static void idproperties_fix_group_lengths(ListBase idlist) -{ - ID *id; - - for (id=idlist.first; id; id=id->next) { - if (id->properties) { - idproperties_fix_groups_lengths_recurse(id->properties); - } - } -} - -static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) -{ - Material *ma; - MFace *mf; - MTFace *tf; - int a, b, texalpha; - - /* verify we have a tface layer */ - for (b=0; bfdata.totlayer; b++) - if (me->fdata.layers[b].type == CD_MTFACE) - break; - - if (b == me->fdata.totlayer) - return; - - /* if we do, set alpha sort if the game engine did it before */ - for (a=0, mf=me->mface; atotface; a++, mf++) { - if (mf->mat_nr < me->totcol) { - ma= newlibadr(fd, lib, me->mat[mf->mat_nr]); - texalpha = 0; - - /* we can't read from this if it comes from a library, - * because direct_link might not have happened on it, - * so ma->mtex is not pointing to valid memory yet */ - if (ma && ma->id.lib) - ma= NULL; - - for (b=0; ma && bmtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA) - texalpha = 1; - } - else { - ma= NULL; - texalpha = 0; - } - - for (b=0; bfdata.totlayer; b++) { - if (me->fdata.layers[b].type == CD_MTFACE) { - tf = ((MTFace*)me->fdata.layers[b].data) + a; - - tf->mode &= ~TF_ALPHASORT; - if (ma && (ma->mode & MA_ZTRANSP)) - if (ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP))) - tf->mode |= TF_ALPHASORT; - } - } - } -} - -/* 2.50 patch */ -static void area_add_header_region(ScrArea *sa, ListBase *lb) -{ - ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_HEADER; - if (sa->headertype==HEADERDOWN) - ar->alignment= RGN_ALIGN_BOTTOM; - else - ar->alignment= RGN_ALIGN_TOP; - - /* initialize view2d data for header region, to allow panning */ - /* is copy from ui_view2d.c */ - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keepofs = V2D_LOCKOFS_Y; - ar->v2d.keeptot = V2D_KEEPTOT_STRICT; - ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; - ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); -} - -static void sequencer_init_preview_region(ARegion* ar) -{ - // XXX a bit ugly still, copied from space_sequencer - /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */ - ar->regiontype= RGN_TYPE_PREVIEW; - ar->alignment= RGN_ALIGN_TOP; - ar->flag |= RGN_FLAG_HIDDEN; - ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM; - ar->v2d.minzoom= 0.00001f; - ar->v2d.maxzoom= 100000.0f; - ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */ - ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */ - ar->v2d.tot.xmax = 960.0f; - ar->v2d.tot.ymax = 540.0f; - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; - ar->v2d.max[0]= 12000.0f; - ar->v2d.max[1]= 12000.0f; - ar->v2d.cur= ar->v2d.tot; - ar->v2d.align= V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y); - ar->v2d.keeptot= V2D_KEEPTOT_FREE; -} - -/* 2.50 patch */ -static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) -{ - ARegion *ar; - ARegion *ar_main; - - if (sl) { - /* first channels for ipo action nla... */ - switch (sl->spacetype) { - case SPACE_IPO: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - - // for some reason, this doesn't seem to go auto like for NLA... - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - ar->v2d.scroll= V2D_SCROLL_RIGHT; - ar->v2d.flag = RGN_FLAG_HIDDEN; - break; - - case SPACE_ACTION: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll= V2D_SCROLL_BOTTOM; - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - break; - - case SPACE_NLA: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll= V2D_SCROLL_BOTTOM; - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - - // for some reason, some files still don't get this auto - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - ar->v2d.scroll= V2D_SCROLL_RIGHT; - ar->v2d.flag = RGN_FLAG_HIDDEN; - break; - - case SPACE_NODE: - ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - /* temporarily hide it */ - ar->flag = RGN_FLAG_HIDDEN; - break; - case SPACE_FILE: - ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - - ar= MEM_callocN(sizeof(ARegion), "ui area for file"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_TOP; - break; - case SPACE_SEQ: - ar_main = (ARegion*)lb->first; - for (; ar_main; ar_main = ar_main->next) { - if (ar_main->regiontype == RGN_TYPE_WINDOW) - break; - } - ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); - BLI_insertlinkbefore(lb, ar_main, ar); - sequencer_init_preview_region(ar); - break; - case SPACE_VIEW3D: - /* toolbar */ - ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d"); - - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_TOOLS; - ar->alignment= RGN_ALIGN_LEFT; - ar->flag = RGN_FLAG_HIDDEN; - - /* tool properties */ - ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d"); - - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_TOOL_PROPS; - ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; - ar->flag = RGN_FLAG_HIDDEN; - - /* buttons/list view */ - ar= MEM_callocN(sizeof(ARegion), "buttons for view3d"); - - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - ar->flag = RGN_FLAG_HIDDEN; -#if 0 - case SPACE_BUTS: - /* context UI region */ - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - - break; -#endif - } - } - - /* main region */ - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - - BLI_addtail(lb, ar); - ar->winrct= sa->totrct; - - ar->regiontype= RGN_TYPE_WINDOW; - - if (sl) { - /* if active spacetype has view2d data, copy that over to main region */ - /* and we split view3d */ - switch (sl->spacetype) { - case SPACE_VIEW3D: - view3d_split_250((View3D *)sl, lb); - break; - - case SPACE_OUTLINER: - { - SpaceOops *soops= (SpaceOops *)sl; - - memcpy(&ar->v2d, &soops->v2d, sizeof(View2D)); - - ar->v2d.scroll &= ~V2D_SCROLL_LEFT; - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); - ar->v2d.keeptot = V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; - //ar->v2d.flag |= V2D_IS_INITIALISED; - } - break; - case SPACE_TIME: - { - SpaceTime *stime= (SpaceTime *)sl; - memcpy(&ar->v2d, &stime->v2d, sizeof(View2D)); - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; - ar->v2d.keepofs |= V2D_LOCKOFS_Y; - ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; - ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0; - ar->v2d.min[1]= ar->v2d.max[1]= 20.0; - } - break; - case SPACE_IPO: - { - SpaceIpo *sipo= (SpaceIpo *)sl; - memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D)); - - /* init mainarea view2d */ - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); - - ar->v2d.min[0]= FLT_MIN; - ar->v2d.min[1]= FLT_MIN; - - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; - - //ar->v2d.flag |= V2D_IS_INITIALISED; - break; - } - case SPACE_NLA: - { - SpaceNla *snla= (SpaceNla *)sl; - memcpy(&ar->v2d, &snla->v2d, sizeof(View2D)); - - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; - ar->v2d.tot.ymax = 0.0f; - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.align = V2D_ALIGN_NO_POS_Y; - ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; - break; - } - case SPACE_ACTION: - { - SpaceAction *saction= (SpaceAction *)sl; - - /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */ - ar->v2d.tot.xmin = -20.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; - ar->v2d.tot.xmax = (float)((sa->winx > 120)? (sa->winx) : 120); - ar->v2d.tot.ymax = 0.0f; - - ar->v2d.cur= ar->v2d.tot; - - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; - - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; - - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.keepzoom= V2D_LOCKZOOM_Y; - ar->v2d.align= V2D_ALIGN_NO_POS_Y; - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - - /* for old files with ShapeKey editors open + an action set, clear the action as - * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit - * only shows ShapeKey-rooted actions only) - */ - if (saction->mode == SACTCONT_SHAPEKEY) - saction->action = NULL; - break; - } - case SPACE_SEQ: - { - SpaceSeq *sseq= (SpaceSeq *)sl; - memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D)); - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); - ar->v2d.align= V2D_ALIGN_NO_NEG_Y; - ar->v2d.flag |= V2D_IS_INITIALISED; - break; - } - case SPACE_NODE: - { - SpaceNode *snode= (SpaceNode *)sl; - memcpy(&ar->v2d, &snode->v2d, sizeof(View2D)); - - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; - break; - } - case SPACE_BUTS: - { - SpaceButs *sbuts= (SpaceButs *)sl; - memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D)); - - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - break; - } - case SPACE_FILE: - { - // SpaceFile *sfile= (SpaceFile *)sl; - ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0; - ar->v2d.tot.xmax = ar->winx; - ar->v2d.tot.ymax = ar->winy; - ar->v2d.cur = ar->v2d.tot; - ar->regiontype= RGN_TYPE_WINDOW; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - break; - } - case SPACE_TEXT: - { - SpaceText *st= (SpaceText *)sl; - st->flags |= ST_FIND_WRAP; - } - //case SPACE_XXX: // FIXME... add other ones - // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D)); - // break; - } - } -} - -static void do_versions_windowmanager_2_50(bScreen *screen) -{ - ScrArea *sa; - SpaceLink *sl; - - /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - - /* we keep headertype variable to convert old files only */ - if (sa->headertype) - area_add_header_region(sa, &sa->regionbase); - - area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase); - - /* space imageselect is deprecated */ - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMASEL) - sl->spacetype= SPACE_EMPTY; /* spacedata then matches */ - } - - /* space sound is deprecated */ - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SOUND) - sl->spacetype= SPACE_EMPTY; /* spacedata then matches */ - } - - /* it seems to be possible in 2.5 to have this saved, filewindow probably */ - sa->butspacetype= sa->spacetype; - - /* pushed back spaces also need regions! */ - if (sa->spacedata.first) { - sl= sa->spacedata.first; - for (sl= sl->next; sl; sl= sl->next) { - if (sa->headertype) - area_add_header_region(sa, &sl->regionbase); - area_add_window_regions(sa, sl, &sl->regionbase); - } - } - } -} - -static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name) -{ - - BLI_addtail(lb, id); - id->us= 1; - id->flag= LIB_FAKEUSER; - *( (short *)id->name )= ID_GD; - - new_id(lb, id, name); - /* alphabetic insterion: is in new_id */ - - if (G.debug & G_DEBUG) - printf("Converted GPencil to ID: %s\n", id->name+2); -} - -static void do_versions_gpencil_2_50(Main *main, bScreen *screen) -{ - ScrArea *sa; - SpaceLink *sl; - - /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - if (v3d->gpd) { - versions_gpencil_add_main(&main->gpencil, (ID *)v3d->gpd, "GPencil View3D"); - v3d->gpd= NULL; - } - } - else if (sl->spacetype==SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; - if (snode->gpd) { - versions_gpencil_add_main(&main->gpencil, (ID *)snode->gpd, "GPencil Node"); - snode->gpd= NULL; - } - } - else if (sl->spacetype==SPACE_SEQ) { - SpaceSeq *sseq= (SpaceSeq *)sl; - if (sseq->gpd) { - versions_gpencil_add_main(&main->gpencil, (ID *)sseq->gpd, "GPencil Node"); - sseq->gpd= NULL; - } - } - else if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; -#if 0 /* see comment on r28002 */ - if (sima->gpd) { - versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image"); - sima->gpd= NULL; - } -#else - sima->gpd= NULL; -#endif - } - } - } -} - /* deprecated, only keep this for readfile.c */ -static PartEff *do_version_give_parteff_245(Object *ob) -{ - PartEff *paf; - - paf= ob->effect.first; - while (paf) { - if (paf->type==EFF_PARTICLE) return paf; - paf= paf->next; - } - return NULL; -} -static void do_version_free_effect_245(Effect *eff) -{ - PartEff *paf; - - if (eff->type==EFF_PARTICLE) { - paf= (PartEff *)eff; - if (paf->keys) MEM_freeN(paf->keys); - } - MEM_freeN(eff); -} -static void do_version_free_effects_245(ListBase *lb) -{ - Effect *eff; - - eff= lb->first; - while (eff) { - BLI_remlink(lb, eff); - do_version_free_effect_245(eff); - eff= lb->first; - } -} - -static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) -{ - MTex *mtex; - float varfac, colfac; - int a, neg; - - if (!mtex_array) - return; - - for (a=0; amaptoneg; - varfac= mtex->varfac; - colfac= mtex->colfac; - - if (neg & MAP_DISP) mtex->dispfac= -mtex->dispfac; - if (neg & MAP_NORM) mtex->norfac= -mtex->norfac; - if (neg & MAP_WARP) mtex->warpfac= -mtex->warpfac; - - mtex->colspecfac= (neg & MAP_COLSPEC)? -colfac: colfac; - mtex->mirrfac= (neg & MAP_COLMIR)? -colfac: colfac; - mtex->alphafac= (neg & MAP_ALPHA)? -varfac: varfac; - mtex->difffac= (neg & MAP_REF)? -varfac: varfac; - mtex->specfac= (neg & MAP_SPEC)? -varfac: varfac; - mtex->emitfac= (neg & MAP_EMIT)? -varfac: varfac; - mtex->hardfac= (neg & MAP_HAR)? -varfac: varfac; - mtex->raymirrfac= (neg & MAP_RAYMIRR)? -varfac: varfac; - mtex->translfac= (neg & MAP_TRANSLU)? -varfac: varfac; - mtex->ambfac= (neg & MAP_AMB)? -varfac: varfac; - mtex->colemitfac= (neg & MAP_EMISSION_COL)? -colfac: colfac; - mtex->colreflfac= (neg & MAP_REFLECTION_COL)? -colfac: colfac; - mtex->coltransfac= (neg & MAP_TRANSMISSION_COL)? -colfac: colfac; - mtex->densfac= (neg & MAP_DENSITY)? -varfac: varfac; - mtex->scatterfac= (neg & MAP_SCATTERING)? -varfac: varfac; - mtex->reflfac= (neg & MAP_REFLECTION)? -varfac: varfac; - - mtex->timefac= (neg & MAP_PA_TIME)? -varfac: varfac; - mtex->lengthfac= (neg & MAP_PA_LENGTH)? -varfac: varfac; - mtex->clumpfac= (neg & MAP_PA_CLUMP)? -varfac: varfac; - mtex->kinkfac= (neg & MAP_PA_KINK)? -varfac: varfac; - mtex->roughfac= (neg & MAP_PA_ROUGH)? -varfac: varfac; - mtex->padensfac= (neg & MAP_PA_DENS)? -varfac: varfac; - mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac; - mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac; - mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac; - - mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac; - - mtex->zenupfac= (neg & WOMAP_ZENUP)? -colfac: colfac; - mtex->zendownfac= (neg & WOMAP_ZENDOWN)? -colfac: colfac; - mtex->blendfac= (neg & WOMAP_BLEND)? -varfac: varfac; - - if (idtype == ID_MA) - mtex->colfac= (neg & MAP_COL)? -colfac: colfac; - else if (idtype == ID_LA) - mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac; - else if (idtype == ID_WO) - mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac; - } - } -} - -static void do_version_mdef_250(Main *main) -{ - Object *ob; - ModifierData *md; - MeshDeformModifierData *mmd; - - for (ob= main->object.first; ob; ob=ob->id.next) { - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type == eModifierType_MeshDeform) { - mmd= (MeshDeformModifierData*)md; - - if (mmd->bindcos) { - /* make bindcos NULL in order to trick older versions - * into thinking that the mesh was not bound yet */ - mmd->bindcagecos= mmd->bindcos; - mmd->bindcos= NULL; - - modifier_mdef_compact_influences(md); - } - } - } - } -} - -static void do_version_constraints_radians_degrees_250(ListBase *lb) -{ - bConstraint *con; - - for (con=lb->first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) { - bRigidBodyJointConstraint *data = con->data; - data->axX *= (float)(M_PI/180.0); - data->axY *= (float)(M_PI/180.0); - data->axZ *= (float)(M_PI/180.0); - } - else if (con->type==CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data = con->data; - data->poleangle *= (float)(M_PI/180.0); - } - else if (con->type==CONSTRAINT_TYPE_ROTLIMIT) { - bRotLimitConstraint *data = con->data; - - data->xmin *= (float)(M_PI/180.0); - data->xmax *= (float)(M_PI/180.0); - data->ymin *= (float)(M_PI/180.0); - data->ymax *= (float)(M_PI/180.0); - data->zmin *= (float)(M_PI/180.0); - data->zmax *= (float)(M_PI/180.0); - } - } -} - -/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */ -static void do_version_old_trackto_to_constraints(Object *ob) -{ - /* create new trackto constraint from the relationship */ - if (ob->track) { - bConstraint *con= add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); - bTrackToConstraint *data = con->data; - - /* copy tracking settings from the object */ - data->tar = ob->track; - data->reserved1 = ob->trackflag; - data->reserved2 = ob->upflag; - } - - /* clear old track setting */ - ob->track = NULL; -} - -static void do_versions_seq_unique_name_all_strips( - Scene * sce, ListBase *seqbasep) -{ - Sequence * seq = seqbasep->first; - - while (seq) { - seqbase_unique_name_recursive(&sce->ed->seqbase, seq); - if (seq->seqbase.first) { - do_versions_seq_unique_name_all_strips( - sce, &seq->seqbase); - } - seq=seq->next; - } -} - - -static void do_version_bone_roll_256(Bone *bone) -{ - Bone *child; - float submat[3][3]; - - copy_m3_m4(submat, bone->arm_mat); - mat3_to_vec_roll(submat, NULL, &bone->arm_roll); - - for (child = bone->childbase.first; child; child = child->next) - do_version_bone_roll_256(child); -} - -static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree) -{ - bNodeSocket *sock; - for (sock=ntree->inputs.first; sock; sock=sock->next) - sock->flag |= SOCK_DYNAMIC; - for (sock=ntree->outputs.first; sock; sock=sock->next) - sock->flag |= SOCK_DYNAMIC; -} - void convert_tface_mt(FileData *fd, Main *main) { Main *gmain; @@ -7796,4990 +6806,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (G.debug & G_DEBUG) printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); - - if (main->versionfile == 100) { - /* tex->extend and tex->imageflag have changed: */ - Tex *tex = main->tex.first; - while (tex) { - if (tex->id.flag & LIB_NEEDLINK) { - if (tex->extend==0) { - if (tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT; - else { - tex->extend= TEX_EXTEND; - tex->xrepeat= tex->yrepeat= 1; - } - } - - } - tex= tex->id.next; - } - } - if (main->versionfile <= 101) { - /* frame mapping */ - Scene *sce = main->scene.first; - while (sce) { - sce->r.framapto= 100; - sce->r.images= 100; - sce->r.framelen= 1.0; - sce= sce->id.next; - } - } - if (main->versionfile <= 102) { - /* init halo's at 1.0 */ - Material *ma = main->mat.first; - while (ma) { - ma->add= 1.0; - ma= ma->id.next; - } - } - if (main->versionfile <= 103) { - /* new variable in object: colbits */ - Object *ob = main->object.first; - int a; - while (ob) { - ob->colbits= 0; - if (ob->totcol) { - for (a=0; atotcol; a++) { - if (ob->mat[a]) ob->colbits |= (1<id.next; - } - } - if (main->versionfile <= 104) { - /* timeoffs moved */ - Object *ob = main->object.first; - while (ob) { - if (ob->transflag & 1) { - ob->transflag -= 1; - //ob->ipoflag |= OB_OFFS_OB; - } - ob= ob->id.next; - } - } - if (main->versionfile <= 105) { - Object *ob = main->object.first; - while (ob) { - ob->dupon= 1; ob->dupoff= 0; - ob->dupsta= 1; ob->dupend= 100; - ob= ob->id.next; - } - } - if (main->versionfile <= 106) { - /* mcol changed */ - Mesh *me = main->mesh.first; - while (me) { - if (me->mcol) vcol_to_fcol(me); - me= me->id.next; - } - - } - if (main->versionfile <= 107) { - Object *ob; - Scene *sce = main->scene.first; - while (sce) { - sce->r.mode |= R_GAMMA; - sce= sce->id.next; - } - ob= main->object.first; - while (ob) { - //ob->ipoflag |= OB_OFFS_PARENT; - if (ob->dt==0) ob->dt= OB_SOLID; - ob= ob->id.next; - } - - } - if (main->versionfile <= 109) { - /* new variable: gridlines */ - bScreen *sc = main->screen.first; - while (sc) { - ScrArea *sa= sc->areabase.first; - while (sa) { - SpaceLink *sl= sa->spacedata.first; - while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - - if (v3d->gridlines==0) v3d->gridlines= 20; - } - sl= sl->next; - } - sa= sa->next; - } - sc= sc->id.next; - } - } - if (main->versionfile <= 113) { - Material *ma = main->mat.first; - while (ma) { - if (ma->flaresize==0.0f) ma->flaresize= 1.0f; - ma->subsize= 1.0f; - ma->flareboost= 1.0f; - ma= ma->id.next; - } - } - - if (main->versionfile <= 134) { - Tex *tex = main->tex.first; - while (tex) { - if ((tex->rfac == 0.0f) && - (tex->gfac == 0.0f) && - (tex->bfac == 0.0f)) { - tex->rfac = 1.0f; - tex->gfac = 1.0f; - tex->bfac = 1.0f; - tex->filtersize = 1.0f; - } - tex = tex->id.next; - } - } - if (main->versionfile <= 140) { - /* r-g-b-fac in texture */ - Tex *tex = main->tex.first; - while (tex) { - if ((tex->rfac == 0.0f) && - (tex->gfac == 0.0f) && - (tex->bfac == 0.0f)) { - tex->rfac = 1.0f; - tex->gfac = 1.0f; - tex->bfac = 1.0f; - tex->filtersize = 1.0f; - } - tex = tex->id.next; - } - } - if (main->versionfile <= 153) { - Scene *sce = main->scene.first; - while (sce) { - if (sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f; - sce= sce->id.next; - } - } - if (main->versionfile <= 163) { - Scene *sce = main->scene.first; - while (sce) { - if (sce->r.frs_sec==0) sce->r.frs_sec= 25; - sce= sce->id.next; - } - } - if (main->versionfile <= 164) { - Mesh *me= main->mesh.first; - while (me) { - me->smoothresh= 30; - me= me->id.next; - } - } - if (main->versionfile <= 165) { - Mesh *me= main->mesh.first; - TFace *tface; - int nr; - char *cp; - - while (me) { - if (me->tface) { - nr= me->totface; - tface= me->tface; - while (nr--) { - cp= (char *)&tface->col[0]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - cp= (char *)&tface->col[1]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - cp= (char *)&tface->col[2]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - cp= (char *)&tface->col[3]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - - tface++; - } - } - me= me->id.next; - } - } - - if (main->versionfile <= 169) { - Mesh *me= main->mesh.first; - while (me) { - if (me->subdiv==0) me->subdiv= 1; - me= me->id.next; - } - } - - if (main->versionfile <= 169) { - bScreen *sc= main->screen.first; - while (sc) { - ScrArea *sa= sc->areabase.first; - while (sa) { - SpaceLink *sl= sa->spacedata.first; - while (sl) { - if (sl->spacetype==SPACE_IPO) { - SpaceIpo *sipo= (SpaceIpo*) sl; - sipo->v2d.max[0]= 15000.0; - } - sl= sl->next; - } - sa= sa->next; - } - sc= sc->id.next; - } - } - - if (main->versionfile <= 170) { - Object *ob = main->object.first; - PartEff *paf; - while (ob) { - paf = do_version_give_parteff_245(ob); - if (paf) { - if (paf->staticstep == 0) { - paf->staticstep= 5; - } - } - ob = ob->id.next; - } - } - - if (main->versionfile <= 171) { - bScreen *sc= main->screen.first; - while (sc) { - ScrArea *sa= sc->areabase.first; - while (sa) { - SpaceLink *sl= sa->spacedata.first; - while (sl) { - if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText*) sl; - st->lheight= 12; - } - sl= sl->next; - } - sa= sa->next; - } - sc= sc->id.next; - } - } - - if (main->versionfile <= 173) { - int a, b; - Mesh *me= main->mesh.first; - while (me) { - if (me->tface) { - TFace *tface= me->tface; - for (a=0; atotface; a++, tface++) { - for (b=0; b<4; b++) { - tface->uv[b][0]/= 32767.0f; - tface->uv[b][1]/= 32767.0f; - } - } - } - me= me->id.next; - } - } - - if (main->versionfile <= 191) { - Object *ob= main->object.first; - Material *ma = main->mat.first; - - /* let faces have default add factor of 0.0 */ - while (ma) { - if (!(ma->mode & MA_HALO)) ma->add = 0.0; - ma = ma->id.next; - } - - while (ob) { - ob->mass= 1.0f; - ob->damping= 0.1f; - /*ob->quat[1]= 1.0f;*/ /* quats arnt used yet */ - ob= ob->id.next; - } - } - - if (main->versionfile <= 193) { - Object *ob= main->object.first; - while (ob) { - ob->inertia= 1.0f; - ob->rdamping= 0.1f; - ob= ob->id.next; - } - } - - if (main->versionfile <= 196) { - Mesh *me= main->mesh.first; - int a, b; - while (me) { - if (me->tface) { - TFace *tface= me->tface; - for (a=0; atotface; a++, tface++) { - for (b=0; b<4; b++) { - tface->mode |= TF_DYNAMIC; - tface->mode &= ~TF_INVISIBLE; - } - } - } - me= me->id.next; - } - } - - if (main->versionfile <= 200) { - Object *ob= main->object.first; - while (ob) { - ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); - /* 64 is do_fh */ - ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); - ob = ob->id.next; - } - } - - if (main->versionfile <= 201) { - /* add-object + end-object are joined to edit-object actuator */ - Object *ob = main->object.first; - bProperty *prop; - bActuator *act; - bIpoActuator *ia; - bEditObjectActuator *eoa; - bAddObjectActuator *aoa; - while (ob) { - act = ob->actuators.first; - while (act) { - if (act->type==ACT_IPO) { - ia= act->data; - prop= get_ob_property(ob, ia->name); - if (prop) { - ia->type= ACT_IPO_FROM_PROP; - } - } - else if (act->type==ACT_ADD_OBJECT) { - aoa= act->data; - eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); - eoa->type= ACT_EDOB_ADD_OBJECT; - eoa->ob= aoa->ob; - eoa->time= aoa->time; - MEM_freeN(aoa); - act->data= eoa; - act->type= act->otype= ACT_EDIT_OBJECT; - } - else if (act->type==ACT_END_OBJECT) { - eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); - eoa->type= ACT_EDOB_END_OBJECT; - act->data= eoa; - act->type= act->otype= ACT_EDIT_OBJECT; - } - act= act->next; - } - ob = ob->id.next; - } - } - - if (main->versionfile <= 202) { - /* add-object and end-object are joined to edit-object - * actuator */ - Object *ob= main->object.first; - bActuator *act; - bObjectActuator *oa; - while (ob) { - act= ob->actuators.first; - while (act) { - if (act->type==ACT_OBJECT) { - oa= act->data; - oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL); /* this actuator didn't do local/glob rot before */ - } - act= act->next; - } - ob= ob->id.next; - } - } - - if (main->versionfile <= 204) { - /* patches for new physics */ - Object *ob= main->object.first; - bActuator *act; - bObjectActuator *oa; - bSound *sound; - while (ob) { - - /* please check this for demo20 files like - * original Egypt levels etc. converted - * rotation factor of 50 is not workable */ - act= ob->actuators.first; - while (act) { - if (act->type==ACT_OBJECT) { - oa= act->data; - - oa->forceloc[0]*= 25.0f; - oa->forceloc[1]*= 25.0f; - oa->forceloc[2]*= 25.0f; - - oa->forcerot[0]*= 10.0f; - oa->forcerot[1]*= 10.0f; - oa->forcerot[2]*= 10.0f; - } - act= act->next; - } - ob= ob->id.next; - } - - sound = main->sound.first; - while (sound) { - if (sound->volume < 0.01f) { - sound->volume = 1.0f; - } - sound = sound->id.next; - } - } - - if (main->versionfile <= 205) { - /* patches for new physics */ - Object *ob= main->object.first; - bActuator *act; - bSensor *sens; - bEditObjectActuator *oa; - bRaySensor *rs; - bCollisionSensor *cs; - while (ob) { - /* Set anisotropic friction off for old objects, - * values to 1.0. */ - ob->gameflag &= ~OB_ANISOTROPIC_FRICTION; - ob->anisotropicFriction[0] = 1.0; - ob->anisotropicFriction[1] = 1.0; - ob->anisotropicFriction[2] = 1.0; - - act= ob->actuators.first; - while (act) { - if (act->type==ACT_EDIT_OBJECT) { - /* Zero initial velocity for newly - * added objects */ - oa= act->data; - oa->linVelocity[0] = 0.0; - oa->linVelocity[1] = 0.0; - oa->linVelocity[2] = 0.0; - oa->localflag = 0; - } - act= act->next; - } - - sens= ob->sensors.first; - while (sens) { - /* Extra fields for radar sensors. */ - if (sens->type == SENS_RADAR) { - bRadarSensor *s = sens->data; - s->range = 10000.0; - } - - /* Pulsing: defaults for new sensors. */ - if (sens->type != SENS_ALWAYS) { - sens->pulse = 0; - sens->freq = 0; - } - else { - sens->pulse = 1; - } - - /* Invert: off. */ - sens->invert = 0; - - /* Collision and ray: default = trigger - * on property. The material field can - * remain empty. */ - if (sens->type == SENS_COLLISION) { - cs = (bCollisionSensor*) sens->data; - cs->mode = 0; - } - if (sens->type == SENS_RAY) { - rs = (bRaySensor*) sens->data; - rs->mode = 0; - } - sens = sens->next; - } - ob= ob->id.next; - } - /* have to check the exact multiplier */ - } - - if (main->versionfile <= 211) { - /* Render setting: per scene, the applicable gamma value - * can be set. Default is 1.0, which means no - * correction. */ - bActuator *act; - bObjectActuator *oa; - Object *ob; - - /* added alpha in obcolor */ - ob= main->object.first; - while (ob) { - ob->col[3]= 1.0; - ob= ob->id.next; - } - - /* added alpha in obcolor */ - ob= main->object.first; - while (ob) { - act= ob->actuators.first; - while (act) { - if (act->type==ACT_OBJECT) { - /* multiply velocity with 50 in old files */ - oa= act->data; - if (fabsf(oa->linearvelocity[0]) >= 0.01f) - oa->linearvelocity[0] *= 50.0f; - if (fabsf(oa->linearvelocity[1]) >= 0.01f) - oa->linearvelocity[1] *= 50.0f; - if (fabsf(oa->linearvelocity[2]) >= 0.01f) - oa->linearvelocity[2] *= 50.0f; - if (fabsf(oa->angularvelocity[0])>=0.01f) - oa->angularvelocity[0] *= 50.0f; - if (fabsf(oa->angularvelocity[1])>=0.01f) - oa->angularvelocity[1] *= 50.0f; - if (fabsf(oa->angularvelocity[2])>=0.01f) - oa->angularvelocity[2] *= 50.0f; - } - act= act->next; - } - ob= ob->id.next; - } - } - - if (main->versionfile <= 212) { - - bSound* sound; - bProperty *prop; - Object *ob; - Mesh *me; - - sound = main->sound.first; - while (sound) { - sound->max_gain = 1.0; - sound->min_gain = 0.0; - sound->distance = 1.0; - - if (sound->attenuation > 0.0f) - sound->flags |= SOUND_FLAGS_3D; - else - sound->flags &= ~SOUND_FLAGS_3D; - - sound = sound->id.next; - } - - ob = main->object.first; - - while (ob) { - prop= ob->prop.first; - while (prop) { - if (prop->type == GPROP_TIME) { - // convert old GPROP_TIME values from int to float - *((float *)&prop->data) = (float) prop->data; - } - - prop= prop->next; - } - ob = ob->id.next; - } - - /* me->subdiv changed to reflect the actual reparametization - * better, and smeshes were removed - if it was a smesh make - * it a subsurf, and reset the subdiv level because subsurf - * takes a lot more work to calculate. - */ - for (me= main->mesh.first; me; me= me->id.next) { - if (me->flag&ME_SMESH) { - me->flag&= ~ME_SMESH; - me->flag|= ME_SUBSURF; - - me->subdiv= 1; - } - else { - if (me->subdiv<2) - me->subdiv= 1; - else - me->subdiv--; - } - } - } - - if (main->versionfile <= 220) { - Object *ob; - Mesh *me; - - ob = main->object.first; - - /* adapt form factor in order to get the 'old' physics - * behavior back...*/ - - while (ob) { - /* in future, distinguish between different - * object bounding shapes */ - ob->formfactor = 0.4f; - /* patch form factor, note that inertia equiv radius - * of a rotation symmetrical obj */ - if (ob->inertia != 1.0f) { - ob->formfactor /= ob->inertia * ob->inertia; - } - ob = ob->id.next; - } - - /* Began using alpha component of vertex colors, but - * old file vertex colors are undefined, reset them - * to be fully opaque. -zr - */ - for (me= main->mesh.first; me; me= me->id.next) { - if (me->mcol) { - int i; - - for (i=0; itotface*4; i++) { - MCol *mcol= &me->mcol[i]; - mcol->a= 255; - } - } - if (me->tface) { - int i, j; - - for (i=0; itotface; i++) { - TFace *tf= &((TFace*) me->tface)[i]; - - for (j=0; j<4; j++) { - char *col= (char*) &tf->col[j]; - - col[0]= 255; - } - } - } - } - } - if (main->versionfile <= 221) { - Scene *sce= main->scene.first; - - // new variables for std-alone player and runtime - while (sce) { - - sce->r.xplay= 640; - sce->r.yplay= 480; - sce->r.freqplay= 60; - - sce= sce->id.next; - } - - } - if (main->versionfile <= 222) { - Scene *sce= main->scene.first; - - // new variables for std-alone player and runtime - while (sce) { - - sce->r.depth= 32; - - sce= sce->id.next; - } - } - - - if (main->versionfile <= 223) { - VFont *vf; - Image *ima; - Object *ob; - - for (vf= main->vfont.first; vf; vf= vf->id.next) { - if (strcmp(vf->name+strlen(vf->name)-6, ".Bfont")==0) { - strcpy(vf->name, FO_BUILTIN_NAME); - } - } - - /* Old textures animate at 25 FPS */ - for (ima = main->image.first; ima; ima=ima->id.next) { - ima->animspeed = 25; - } - - /* Zr remapped some keyboard codes to be linear (stupid zr) */ - for (ob= main->object.first; ob; ob= ob->id.next) { - bSensor *sens; - - for (sens= ob->sensors.first; sens; sens= sens->next) { - if (sens->type==SENS_KEYBOARD) { - bKeyboardSensor *ks= sens->data; - - ks->key= map_223_keybd_code_to_224_keybd_code(ks->key); - ks->qual= map_223_keybd_code_to_224_keybd_code(ks->qual); - ks->qual2= map_223_keybd_code_to_224_keybd_code(ks->qual2); - } - } - } - } - if (main->versionfile <= 224) { - bSound* sound; - Scene *sce; - Mesh *me; - bScreen *sc; - - for (sound=main->sound.first; sound; sound=sound->id.next) { - if (sound->packedfile) { - if (sound->newpackedfile == NULL) { - sound->newpackedfile = sound->packedfile; - } - sound->packedfile = NULL; - } - } - /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */ - for (me=main->mesh.first; me; me=me->id.next) { - if ((me->flag & ME_SUBSURF) && (me->subdivr==0)) - me->subdivr=me->subdiv; - } - - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->r.stereomode = 1; // no stereo - } - - /* some oldfile patch, moved from set_func_space */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IPO) { - SpaceSeq *sseq= (SpaceSeq*) sl; - sseq->v2d.keeptot= 0; - } - } - } - } - - } - - - if (main->versionfile <= 225) { - World *wo; - /* Use Sumo for old games */ - for (wo = main->world.first; wo; wo= wo->id.next) { - wo->physicsEngine = 2; - } - } - - if (main->versionfile <= 227) { - Scene *sce; - Material *ma; - bScreen *sc; - Object *ob; - - /* As of now, this insures that the transition from the old Track system - * to the new full constraint Track is painless for everyone. - theeth - */ - ob = main->object.first; - - while (ob) { - ListBase *list; - list = &ob->constraints; - - /* check for already existing TrackTo constraint - * set their track and up flag correctly */ - - if (list) { - bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { - if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { - bTrackToConstraint *data = curcon->data; - data->reserved1 = ob->trackflag; - data->reserved2 = ob->upflag; - } - } - } - - if (ob->type == OB_ARMATURE) { - if (ob->pose) { - bConstraint *curcon; - bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; - pchan; pchan=pchan->next) { - for (curcon = pchan->constraints.first; - curcon; curcon=curcon->next) { - if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { - bTrackToConstraint *data = curcon->data; - data->reserved1 = ob->trackflag; - data->reserved2 = ob->upflag; - } - } - } - } - } - - /* Change Ob->Track in real TrackTo constraint */ - do_version_old_trackto_to_constraints(ob); - - ob = ob->id.next; - } - - - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->audio.mixrate = 44100; - sce->audio.flag |= AUDIO_SCRUB; - sce->r.mode |= R_ENVMAP; - } - // init new shader vars - for (ma= main->mat.first; ma; ma= ma->id.next) { - ma->refrac= 4.0f; - ma->roughness= 0.5f; - ma->param[0]= 0.5f; - ma->param[1]= 0.1f; - ma->param[2]= 0.1f; - ma->param[3]= 0.05f; - } - // patch for old wrong max view2d settings, allows zooming out more - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_ACTION) { - SpaceAction *sac= (SpaceAction *) sl; - sac->v2d.max[0]= 32000; - } - else if (sl->spacetype==SPACE_NLA) { - SpaceNla *sla= (SpaceNla *) sl; - sla->v2d.max[0]= 32000; - } - } - } - } - } - if (main->versionfile <= 228) { - Scene *sce; - bScreen *sc; - Object *ob; - - - /* As of now, this insures that the transition from the old Track system - * to the new full constraint Track is painless for everyone.*/ - ob = main->object.first; - - while (ob) { - ListBase *list; - list = &ob->constraints; - - /* check for already existing TrackTo constraint - * set their track and up flag correctly */ - - if (list) { - bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { - if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { - bTrackToConstraint *data = curcon->data; - data->reserved1 = ob->trackflag; - data->reserved2 = ob->upflag; - } - } - } - - if (ob->type == OB_ARMATURE) { - if (ob->pose) { - bConstraint *curcon; - bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; - pchan; pchan=pchan->next) { - for (curcon = pchan->constraints.first; - curcon; curcon=curcon->next) { - if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { - bTrackToConstraint *data = curcon->data; - data->reserved1 = ob->trackflag; - data->reserved2 = ob->upflag; - } - } - } - } - } - - ob = ob->id.next; - } - - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->r.mode |= R_ENVMAP; - } - - // convert old mainb values for new button panels - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_BUTS) { - SpaceButs *sbuts= (SpaceButs *) sl; - - sbuts->v2d.maxzoom= 1.2f; - sbuts->align= 1; /* horizontal default */ - - if (sbuts->mainb==BUTS_LAMP) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP; - } - else if (sbuts->mainb==BUTS_MAT) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT; - } - else if (sbuts->mainb==BUTS_TEX) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX; - } - else if (sbuts->mainb==BUTS_ANIM) { - sbuts->mainb= CONTEXT_OBJECT; - } - else if (sbuts->mainb==BUTS_WORLD) { - sbuts->mainb= CONTEXT_SCENE; - //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD; - } - else if (sbuts->mainb==BUTS_RENDER) { - sbuts->mainb= CONTEXT_SCENE; - //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER; - } - else if (sbuts->mainb==BUTS_GAME) { - sbuts->mainb= CONTEXT_LOGIC; - } - else if (sbuts->mainb==BUTS_FPAINT) { - sbuts->mainb= CONTEXT_EDITING; - } - else if (sbuts->mainb==BUTS_RADIO) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD; - } - else if (sbuts->mainb==BUTS_CONSTRAINT) { - sbuts->mainb= CONTEXT_OBJECT; - } - else if (sbuts->mainb==BUTS_SCRIPT) { - sbuts->mainb= CONTEXT_OBJECT; - } - else if (sbuts->mainb==BUTS_EDIT) { - sbuts->mainb= CONTEXT_EDITING; - } - else sbuts->mainb= CONTEXT_SCENE; - } - } - } - } - } - /* ton: made this 230 instead of 229, - * to be sure (tuho files) and this is a reliable check anyway - * nevertheless, we might need to think over a fitness (initialize) - * check apart from the do_versions() */ - - if (main->versionfile <= 230) { - bScreen *sc; - - // new variable blockscale, for panels in any area - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->blockscale==0.0f) sl->blockscale= 0.7f; - /* added: 5x better zoom in for action */ - if (sl->spacetype==SPACE_ACTION) { - SpaceAction *sac= (SpaceAction *)sl; - sac->v2d.maxzoom= 50; - } - } - } - } - } - if (main->versionfile <= 231) { - /* new bit flags for showing/hiding grid floor and axes */ - bScreen *sc = main->screen.first; - while (sc) { - ScrArea *sa= sc->areabase.first; - while (sa) { - SpaceLink *sl= sa->spacedata.first; - while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - - if (v3d->gridflag==0) { - v3d->gridflag |= V3D_SHOW_X; - v3d->gridflag |= V3D_SHOW_Y; - v3d->gridflag |= V3D_SHOW_FLOOR; - v3d->gridflag &= ~V3D_SHOW_Z; - } - } - sl= sl->next; - } - sa= sa->next; - } - sc= sc->id.next; - } - } - if (main->versionfile <= 231) { - Material *ma= main->mat.first; - bScreen *sc = main->screen.first; - Scene *sce; - Lamp *la; - World *wrld; - - /* introduction of raytrace */ - while (ma) { - if (ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f; - if (ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f; - - ma->ang= 1.0; - ma->ray_depth= 2; - ma->ray_depth_tra= 2; - ma->fresnel_tra= 0.0; - ma->fresnel_mir= 0.0; - - ma= ma->id.next; - } - sce= main->scene.first; - while (sce) { - if (sce->r.gauss==0.0f) sce->r.gauss= 1.0f; - sce= sce->id.next; - } - la= main->lamp.first; - while (la) { - if (la->k==0.0f) la->k= 1.0; - if (la->ray_samp==0) la->ray_samp= 1; - if (la->ray_sampy==0) la->ray_sampy= 1; - if (la->ray_sampz==0) la->ray_sampz= 1; - if (la->area_size==0.0f) la->area_size= 1.0f; - if (la->area_sizey==0.0f) la->area_sizey= 1.0f; - if (la->area_sizez==0.0f) la->area_sizez= 1.0f; - la= la->id.next; - } - wrld= main->world.first; - while (wrld) { - if (wrld->range==0.0f) { - wrld->range= 1.0f/wrld->exposure; - } - wrld= wrld->id.next; - } - - /* new bit flags for showing/hiding grid floor and axes */ - - while (sc) { - ScrArea *sa= sc->areabase.first; - while (sa) { - SpaceLink *sl= sa->spacedata.first; - while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - - if (v3d->gridflag==0) { - v3d->gridflag |= V3D_SHOW_X; - v3d->gridflag |= V3D_SHOW_Y; - v3d->gridflag |= V3D_SHOW_FLOOR; - v3d->gridflag &= ~V3D_SHOW_Z; - } - } - sl= sl->next; - } - sa= sa->next; - } - sc= sc->id.next; - } - } - if (main->versionfile <= 232) { - Tex *tex= main->tex.first; - World *wrld= main->world.first; - bScreen *sc; - Scene *sce; - - while (tex) { - if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) { - tex->flag |= TEX_CHECKER_ODD; - } - /* copied from kernel texture.c */ - if (tex->ns_outscale==0.0f) { - /* musgrave */ - tex->mg_H = 1.0f; - tex->mg_lacunarity = 2.0f; - tex->mg_octaves = 2.0f; - tex->mg_offset = 1.0f; - tex->mg_gain = 1.0f; - tex->ns_outscale = 1.0f; - /* distnoise */ - tex->dist_amount = 1.0f; - /* voronoi */ - tex->vn_w1 = 1.0f; - tex->vn_mexp = 2.5f; - } - tex= tex->id.next; - } - - while (wrld) { - if (wrld->aodist==0.0f) { - wrld->aodist= 10.0f; - wrld->aobias= 0.05f; - } - if (wrld->aosamp==0) wrld->aosamp= 5; - if (wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f; - wrld= wrld->id.next; - } - - - // new variable blockscale, for panels in any area, do again because new - // areas didnt initialize it to 0.7 yet - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->blockscale==0.0f) sl->blockscale= 0.7f; - - /* added: 5x better zoom in for nla */ - if (sl->spacetype==SPACE_NLA) { - SpaceNla *snla= (SpaceNla *)sl; - snla->v2d.maxzoom= 50; - } - } - } - } - sce= main->scene.first; - while (sce) { - if (sce->r.ocres==0) sce->r.ocres= 64; - sce= sce->id.next; - } - - } - if (main->versionfile <= 233) { - bScreen *sc; - Material *ma= main->mat.first; - /* Object *ob= main->object.first; */ - - while (ma) { - if (ma->rampfac_col==0.0f) ma->rampfac_col= 1.0; - if (ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0; - if (ma->pr_lamp==0) ma->pr_lamp= 3; - ma= ma->id.next; - } - - /* this should have been done loooong before! */ -#if 0 /* deprecated in 2.5+ */ - while (ob) { - if (ob->ipowin==0) ob->ipowin= ID_OB; - ob= ob->id.next; - } -#endif - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; - v3d->flag |= V3D_SELECT_OUTLINE; - } - } - } - } - } - - - - - if (main->versionfile <= 234) { - World *wo; - bScreen *sc; - - // force sumo engine to be active - for (wo = main->world.first; wo; wo= wo->id.next) { - if (wo->physicsEngine==0) wo->physicsEngine = 2; - } - - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; - v3d->flag |= V3D_ZBUF_SELECT; - } - else if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText *)sl; - if (st->tabnumber==0) st->tabnumber= 2; - } - } - } - } - } - if (main->versionfile <= 235) { - Tex *tex= main->tex.first; - Scene *sce= main->scene.first; - Sequence *seq; - Editing *ed; - - while (tex) { - if (tex->nabla==0.0f) tex->nabla= 0.025f; - tex= tex->id.next; - } - while (sce) { - ed= sce->ed; - if (ed) { - SEQ_BEGIN (sce->ed, seq) - { - if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE) - seq->flag |= SEQ_MAKE_PREMUL; - } - SEQ_END - } - - sce= sce->id.next; - } - } - if (main->versionfile <= 236) { - Object *ob; - Camera *cam= main->camera.first; - Material *ma; - bScreen *sc; - - while (cam) { - if (cam->ortho_scale==0.0f) { - cam->ortho_scale= 256.0f/cam->lens; - if (cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n"); - } - cam= cam->id.next; - } - /* set manipulator type */ - /* force oops draw if depgraph was set*/ - /* set time line var */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; - if (v3d->twtype==0) v3d->twtype= V3D_MANIP_TRANSLATE; - } - } - } - } - // init new shader vars - for (ma= main->mat.first; ma; ma= ma->id.next) { - if (ma->darkness==0.0f) { - ma->rms=0.1f; - ma->darkness=1.0f; - } - } - - /* softbody init new vars */ - for (ob= main->object.first; ob; ob= ob->id.next) { - if (ob->soft) { - if (ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f; - if (ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f; - - if (ob->soft->interval==0) { - ob->soft->interval= 2; - ob->soft->sfra= 1; - ob->soft->efra= 100; - } - } - if (ob->soft && ob->soft->vertgroup==0) { - bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL"); - if (locGroup) { - /* retrieve index for that group */ - ob->soft->vertgroup = 1 + BLI_findindex(&ob->defbase, locGroup); - } - } - } - } - if (main->versionfile <= 237) { - bArmature *arm; - bConstraint *con; - Object *ob; - Bone *bone; - - // armature recode checks - for (arm= main->armature.first; arm; arm= arm->id.next) { - where_is_armature(arm); - - for (bone= arm->bonebase.first; bone; bone= bone->next) - do_version_bone_head_tail_237(bone); - } - for (ob= main->object.first; ob; ob= ob->id.next) { - if (ob->parent) { - Object *parent= newlibadr(fd, lib, ob->parent); - if (parent && parent->type==OB_LATTICE) - ob->partype = PARSKEL; - } - - // btw. armature_rebuild_pose is further only called on leave editmode - if (ob->type==OB_ARMATURE) { - if (ob->pose) - ob->pose->flag |= POSE_RECALC; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // cannot call stuff now (pointers!), done in setup_app_data - - /* new generic xray option */ - arm= newlibadr(fd, lib, ob->data); - if (arm->flag & ARM_DRAWXRAY) { - ob->dtx |= OB_DRAWXRAY; - } - } - else if (ob->type==OB_MESH) { - Mesh *me = newlibadr(fd, lib, ob->data); - - if ((me->flag&ME_SUBSURF)) { - SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); - - smd->levels = MAX2(1, me->subdiv); - smd->renderLevels = MAX2(1, me->subdivr); - smd->subdivType = me->subsurftype; - - smd->modifier.mode = 0; - if (me->subdiv!=0) - smd->modifier.mode |= 1; - if (me->subdivr!=0) - smd->modifier.mode |= 2; - if (me->flag&ME_OPT_EDGES) - smd->flags |= eSubsurfModifierFlag_ControlEdges; - - BLI_addtail(&ob->modifiers, smd); - - modifier_unique_name(&ob->modifiers, (ModifierData*)smd); - } - } - - // follow path constraint needs to set the 'path' option in curves... - for (con=ob->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) { - bFollowPathConstraint *data = con->data; - Object *obc= newlibadr(fd, lib, data->tar); - - if (obc && obc->type==OB_CURVE) { - Curve *cu= newlibadr(fd, lib, obc->data); - if (cu) cu->flag |= CU_PATH; - } - } - } - } - } - if (main->versionfile <= 238) { - Lattice *lt; - Object *ob; - bArmature *arm; - Mesh *me; - Key *key; - Scene *sce= main->scene.first; - - while (sce) { - if (sce->toolsettings == NULL) { - sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); - sce->toolsettings->cornertype=0; - sce->toolsettings->degr = 90; - sce->toolsettings->step = 9; - sce->toolsettings->turn = 1; - sce->toolsettings->extr_offs = 1; - sce->toolsettings->doublimit = 0.001f; - sce->toolsettings->segments = 32; - sce->toolsettings->rings = 32; - sce->toolsettings->vertices = 32; - } - sce= sce->id.next; - } - - for (lt=main->latt.first; lt; lt=lt->id.next) { - if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) { - calc_lat_fudu(lt->flag, lt->pntsu, <->fu, <->du); - calc_lat_fudu(lt->flag, lt->pntsv, <->fv, <->dv); - calc_lat_fudu(lt->flag, lt->pntsw, <->fw, <->dw); - } - } - - for (ob=main->object.first; ob; ob= ob->id.next) { - ModifierData *md; - PartEff *paf; - - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Subsurf) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - - smd->flags &= ~(eSubsurfModifierFlag_Incremental|eSubsurfModifierFlag_DebugIncr); - } - } - - if ((ob->softflag&OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) { - if (ob->softflag&OB_SB_POSTDEF) { - md = ob->modifiers.first; - - while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { - md = md->next; - } - - BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(eModifierType_Softbody)); - } - else { - BLI_addhead(&ob->modifiers, modifier_new(eModifierType_Softbody)); - } - - ob->softflag &= ~OB_SB_ENABLE; - } - if (ob->pose) { - bPoseChannel *pchan; - bConstraint *con; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - // note, pchan->bone is also lib-link stuff - if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) { - pchan->limitmin[0]= pchan->limitmin[1]= pchan->limitmin[2]= -180.0f; - pchan->limitmax[0]= pchan->limitmax[1]= pchan->limitmax[2]= 180.0f; - - for (con= pchan->constraints.first; con; con= con->next) { - if (con->type == CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data = (bKinematicConstraint*)con->data; - data->weight = 1.0f; - data->orientweight = 1.0f; - data->flag &= ~CONSTRAINT_IK_ROT; - - /* enforce conversion from old IK_TOPARENT to rootbone index */ - data->rootbone= -1; - - /* update_pose_etc handles rootbone==-1 */ - ob->pose->flag |= POSE_RECALC; - } - } - } - } - } - - paf = do_version_give_parteff_245(ob); - if (paf) { - if (paf->disp == 0) - paf->disp = 100; - if (paf->speedtex == 0) - paf->speedtex = 8; - if (paf->omat == 0) - paf->omat = 1; - } - } - - for (arm=main->armature.first; arm; arm= arm->id.next) { - bone_version_238(&arm->bonebase); - arm->deformflag |= ARM_DEF_VGROUP; - } - - for (me=main->mesh.first; me; me= me->id.next) { - if (!me->medge) { - make_edges(me, 1); /* 1 = use mface->edcode */ - } - else { - mesh_strip_loose_faces(me); - } - } - - for (key= main->key.first; key; key= key->id.next) { - KeyBlock *kb; - int index = 1; - - for (kb= key->block.first; kb; kb= kb->next) { - if (kb==key->refkey) { - if (kb->name[0]==0) - strcpy(kb->name, "Basis"); - } - else { - if (kb->name[0]==0) { - BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index); - } - index++; - } - } - } - } - if (main->versionfile <= 239) { - bArmature *arm; - Object *ob; - Scene *sce= main->scene.first; - Camera *cam= main->camera.first; - Material *ma= main->mat.first; - int set_passepartout= 0; - - /* deformflag is local in modifier now */ - for (ob=main->object.first; ob; ob= ob->id.next) { - ModifierData *md; - - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if (amd->object && amd->deformflag==0) { - Object *oba= newlibadr(fd, lib, amd->object); - arm= newlibadr(fd, lib, oba->data); - amd->deformflag= arm->deformflag; - } - } - } - } - - /* updating stepsize for ghost drawing */ - for (arm= main->armature.first; arm; arm= arm->id.next) { - if (arm->ghostsize==0) arm->ghostsize=1; - bone_version_239(&arm->bonebase); - if (arm->layer==0) arm->layer= 1; - } - - for (;sce;sce= sce->id.next) { - /* make 'innervert' the default subdivide type, for backwards compat */ - sce->toolsettings->cornertype=1; - - if (sce->r.scemode & R_PASSEPARTOUT) { - set_passepartout= 1; - sce->r.scemode &= ~R_PASSEPARTOUT; - } - /* gauss is filter variable now */ - if (sce->r.mode & R_GAUSS) { - sce->r.filtertype= R_FILTER_GAUSS; - sce->r.mode &= ~R_GAUSS; - } - } - - for (;cam; cam= cam->id.next) { - if (set_passepartout) - cam->flag |= CAM_SHOWPASSEPARTOUT; - - /* make sure old cameras have title safe on */ - if (!(cam->flag & CAM_SHOWTITLESAFE)) - cam->flag |= CAM_SHOWTITLESAFE; - - /* set an appropriate camera passepartout alpha */ - if (!(cam->passepartalpha)) cam->passepartalpha = 0.2f; - } - - for (; ma; ma= ma->id.next) { - if (ma->strand_sta==0.0f) { - ma->strand_sta= ma->strand_end= 1.0f; - ma->mode |= MA_TANGENT_STR; - } - if (ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF; - } - } - - if (main->versionfile <= 241) { - Object *ob; - Tex *tex; - Scene *sce; - World *wo; - Lamp *la; - Material *ma; - bArmature *arm; - bNodeTree *ntree; - - for (wo = main->world.first; wo; wo= wo->id.next) { - /* Migrate to Bullet for games, except for the NaN versions */ - /* People can still explicitly choose for Sumo (after 2.42 is out) */ - if (main->versionfile > 225) - wo->physicsEngine = WOPHY_BULLET; - if (WO_AODIST == wo->aomode) - wo->aocolor= WO_AOPLAIN; - } - - /* updating layers still */ - for (arm= main->armature.first; arm; arm= arm->id.next) { - bone_version_239(&arm->bonebase); - if (arm->layer==0) arm->layer= 1; - } - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->audio.mixrate==0) sce->audio.mixrate= 44100; - - if (sce->r.xparts<2) sce->r.xparts= 4; - if (sce->r.yparts<2) sce->r.yparts= 4; - /* adds default layer */ - if (sce->r.layers.first==NULL) - scene_add_render_layer(sce, NULL); - else { - SceneRenderLayer *srl; - /* new layer flag for sky, was default for solid */ - for (srl= sce->r.layers.first; srl; srl= srl->next) { - if (srl->layflag & SCE_LAY_SOLID) - srl->layflag |= SCE_LAY_SKY; - srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR); - } - } - - /* node version changes */ - if (sce->nodetree) - ntree_version_241(sce->nodetree); - - /* uv calculation options moved to toolsettings */ - if (sce->toolsettings->uvcalc_radius == 0.0f) { - sce->toolsettings->uvcalc_radius = 1.0f; - sce->toolsettings->uvcalc_cubesize = 1.0f; - sce->toolsettings->uvcalc_mapdir = 1; - sce->toolsettings->uvcalc_mapalign = 1; - sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES; - sce->toolsettings->unwrapper = 1; - } - - if (sce->r.mode & R_PANORAMA) { - /* all these checks to ensure saved files with svn version keep working... */ - if (sce->r.xsch < sce->r.ysch) { - Object *obc= newlibadr(fd, lib, sce->camera); - if (obc && obc->type==OB_CAMERA) { - Camera *cam= newlibadr(fd, lib, obc->data); - if (cam->lens>=10.0f) { - sce->r.xsch*= sce->r.xparts; - cam->lens*= (float)sce->r.ysch/(float)sce->r.xsch; - } - } - } - } - } - - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) - ntree_version_241(ntree); - - for (la= main->lamp.first; la; la= la->id.next) - if (la->buffers==0) - la->buffers= 1; - - for (tex= main->tex.first; tex; tex= tex->id.next) { - if (tex->env && tex->env->viewscale==0.0f) - tex->env->viewscale= 1.0f; -// tex->imaflag |= TEX_GAUSS_MIP; - } - - /* for empty drawsize and drawtype */ - for (ob=main->object.first; ob; ob= ob->id.next) { - if (ob->empty_drawsize==0.0f) { - ob->empty_drawtype = OB_ARROWS; - ob->empty_drawsize = 1.0; - } - } - - for (ma= main->mat.first; ma; ma= ma->id.next) { - /* stucci returns intensity from now on */ - int a; - for (a=0; amtex[a] && ma->mtex[a]->tex) { - tex= newlibadr(fd, lib, ma->mtex[a]->tex); - if (tex && tex->type==TEX_STUCCI) - ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF); - } - } - /* transmissivity defaults */ - if (ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f; - } - - /* during 2.41 images with this name were used for viewer node output, lets fix that */ - if (main->versionfile == 241) { - Image *ima; - for (ima= main->image.first; ima; ima= ima->id.next) - if (strcmp(ima->name, "Compositor")==0) { - strcpy(ima->id.name+2, "Viewer Node"); - strcpy(ima->name, "Viewer Node"); - } - } - } - - if (main->versionfile <= 242) { - Scene *sce; - bScreen *sc; - Object *ob; - Curve *cu; - Material *ma; - Mesh *me; - Group *group; - Nurb *nu; - BezTriple *bezt; - BPoint *bp; - bNodeTree *ntree; - int a; - - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - sa= sc->areabase.first; - while (sa) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - if (v3d->gridsubdiv == 0) - v3d->gridsubdiv = 10; - } - } - sa = sa->next; - } - } - - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->toolsettings->select_thresh == 0.0f) - sce->toolsettings->select_thresh= 0.01f; - if (sce->toolsettings->clean_thresh == 0.0f) - sce->toolsettings->clean_thresh = 0.1f; - - if (sce->r.threads==0) { - if (sce->r.mode & R_THREADS) - sce->r.threads= 2; - else - sce->r.threads= 1; - } - if (sce->nodetree) - ntree_version_242(sce->nodetree); - } - - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) - ntree_version_242(ntree); - - /* add default radius values to old curve points */ - for (cu= main->curve.first; cu; cu= cu->id.next) { - for (nu= cu->nurb.first; nu; nu= nu->next) { - if (nu) { - if (nu->bezt) { - for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { - if (!bezt->radius) bezt->radius= 1.0; - } - } - else if (nu->bp) { - for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { - if (!bp->radius) bp->radius= 1.0; - } - } - } - } - } - - for (ob = main->object.first; ob; ob= ob->id.next) { - ModifierData *md; - ListBase *list; - list = &ob->constraints; - - /* check for already existing MinMax (floor) constraint - * and update the sticky flagging */ - - if (list) { - bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { - switch (curcon->type) { - case CONSTRAINT_TYPE_MINMAX: - { - bMinMaxConstraint *data = curcon->data; - if (data->sticky==1) - data->flag |= MINMAX_STICKY; - else - data->flag &= ~MINMAX_STICKY; - } - break; - case CONSTRAINT_TYPE_ROTLIKE: - { - bRotateLikeConstraint *data = curcon->data; - - /* version patch from buttons_object.c */ - if (data->flag==0) - data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; - } - break; - } - } - } - - if (ob->type == OB_ARMATURE) { - if (ob->pose) { - bConstraint *curcon; - bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) { - switch (curcon->type) { - case CONSTRAINT_TYPE_MINMAX: - { - bMinMaxConstraint *data = curcon->data; - if (data->sticky==1) - data->flag |= MINMAX_STICKY; - else - data->flag &= ~MINMAX_STICKY; - } - break; - case CONSTRAINT_TYPE_KINEMATIC: - { - bKinematicConstraint *data = curcon->data; - if (!(data->flag & CONSTRAINT_IK_POS)) { - data->flag |= CONSTRAINT_IK_POS; - data->flag |= CONSTRAINT_IK_STRETCH; - } - } - break; - case CONSTRAINT_TYPE_ROTLIKE: - { - bRotateLikeConstraint *data = curcon->data; - - /* version patch from buttons_object.c */ - if (data->flag==0) - data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; - } - break; - } - } - } - } - } - - /* copy old object level track settings to curve modifers */ - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Curve) { - CurveModifierData *cmd = (CurveModifierData*) md; - - if (cmd->defaxis == 0) cmd->defaxis = ob->trackflag+1; - } - } - - } - - for (ma = main->mat.first; ma; ma= ma->id.next) { - if (ma->shad_alpha==0.0f) - ma->shad_alpha= 1.0f; - if (ma->nodetree) - ntree_version_242(ma->nodetree); - } - - for (me=main->mesh.first; me; me=me->id.next) - customdata_version_242(me); - - for (group= main->group.first; group; group= group->id.next) - if (group->layer==0) - group->layer= (1<<20)-1; - - /* now, subversion control! */ - if (main->subversionfile < 3) { - Image *ima; - Tex *tex; - - /* Image refactor initialize */ - for (ima= main->image.first; ima; ima= ima->id.next) { - ima->source= IMA_SRC_FILE; - ima->type= IMA_TYPE_IMAGE; - - ima->gen_x= 256; ima->gen_y= 256; - ima->gen_type= 1; - - if (0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) { - ima->source= IMA_SRC_VIEWER; - ima->type= IMA_TYPE_COMPOSITE; - } - if (0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) { - ima->source= IMA_SRC_VIEWER; - ima->type= IMA_TYPE_R_RESULT; - } - - } - for (tex= main->tex.first; tex; tex= tex->id.next) { - if (tex->type==TEX_IMAGE && tex->ima) { - ima= newlibadr(fd, lib, tex->ima); - if (tex->imaflag & TEX_ANIM5_) - ima->source= IMA_SRC_MOVIE; - if (tex->imaflag & TEX_FIELDS_) - ima->flag |= IMA_FIELDS; - if (tex->imaflag & TEX_STD_FIELD_) - ima->flag |= IMA_STD_FIELD; - } - tex->iuser.frames= tex->frames; - tex->iuser.fie_ima= (char)tex->fie_ima; - tex->iuser.offset= tex->offset; - tex->iuser.sfra= tex->sfra; - tex->iuser.cycl= (tex->imaflag & TEX_ANIMCYCLIC_)!=0; - } - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->nodetree) - do_version_ntree_242_2(sce->nodetree); - } - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) - do_version_ntree_242_2(ntree); - for (ma = main->mat.first; ma; ma= ma->id.next) - if (ma->nodetree) - do_version_ntree_242_2(ma->nodetree); - - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) - ((SpaceImage *)sl)->iuser.fie_ima= 2; - else if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; - BGpic *bgpic; - for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) - bgpic->iuser.fie_ima= 2; - } - } - } - } - } - - if (main->subversionfile < 4) { - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->r.bake_mode= 1; /* prevent to include render stuff here */ - sce->r.bake_filter= 2; - sce->r.bake_osa= 5; - sce->r.bake_flag= R_BAKE_CLEAR; - } - } - - if (main->subversionfile < 5) { - for (sce= main->scene.first; sce; sce= sce->id.next) { - /* improved triangle to quad conversion settings */ - if (sce->toolsettings->jointrilimit==0.0f) - sce->toolsettings->jointrilimit= 0.8f; - } - } - } - if (main->versionfile <= 243) { - Object *ob= main->object.first; - Material *ma; - - for (ma=main->mat.first; ma; ma= ma->id.next) { - if (ma->sss_scale==0.0f) { - ma->sss_radius[0]= 1.0f; - ma->sss_radius[1]= 1.0f; - ma->sss_radius[2]= 1.0f; - ma->sss_col[0]= 0.8f; - ma->sss_col[1]= 0.8f; - ma->sss_col[2]= 0.8f; - ma->sss_error= 0.05f; - ma->sss_scale= 0.1f; - ma->sss_ior= 1.3f; - ma->sss_colfac= 1.0f; - ma->sss_texfac= 0.0f; - } - if (ma->sss_front==0 && ma->sss_back==0) { - ma->sss_front= 1.0f; - ma->sss_back= 1.0f; - } - if (ma->sss_col[0]==0 && ma->sss_col[1]==0 && ma->sss_col[2]==0) { - ma->sss_col[0]= ma->r; - ma->sss_col[1]= ma->g; - ma->sss_col[2]= ma->b; - } - } - - for (; ob; ob= ob->id.next) { - bDeformGroup *curdef; - - for (curdef= ob->defbase.first; curdef; curdef=curdef->next) { - /* replace an empty-string name with unique name */ - if (curdef->name[0] == '\0') { - defgroup_unique_name(curdef, ob); - } - } - - if (main->versionfile < 243 || main->subversionfile < 1) { - ModifierData *md; - - /* translate old mirror modifier axis values to new flags */ - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Mirror) { - MirrorModifierData *mmd = (MirrorModifierData*) md; - - switch (mmd->axis) { - case 0: - mmd->flag |= MOD_MIR_AXIS_X; - break; - case 1: - mmd->flag |= MOD_MIR_AXIS_Y; - break; - case 2: - mmd->flag |= MOD_MIR_AXIS_Z; - break; - } - - mmd->axis = 0; - } - } - } - } - - /* render layer added, this is not the active layer */ - if (main->versionfile <= 243 || main->subversionfile < 2) { - Mesh *me; - for (me=main->mesh.first; me; me=me->id.next) - customdata_version_243(me); - } - - } - - if (main->versionfile <= 244) { - Scene *sce; - bScreen *sc; - Lamp *la; - World *wrld; - - if (main->versionfile != 244 || main->subversionfile < 2) { - for (sce= main->scene.first; sce; sce= sce->id.next) - sce->r.mode |= R_SSS; - - /* correct older action editors - incorrect scrolling */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - sa= sc->areabase.first; - while (sa) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_ACTION) { - SpaceAction *saction= (SpaceAction*) sl; - - saction->v2d.tot.ymin = -1000.0; - saction->v2d.tot.ymax = 0.0; - - saction->v2d.cur.ymin = -75.0; - saction->v2d.cur.ymax = 5.0; - } - } - sa = sa->next; - } - } - } - if (main->versionfile != 244 || main->subversionfile < 3) { - /* constraints recode version patch used to be here. Moved to 245 now... */ - - - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { - if (wrld->mode & WO_AMB_OCC) - wrld->ao_samp_method = WO_AOSAMP_CONSTANT; - else - wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; - - wrld->ao_adapt_thresh = 0.005f; - } - - for (la=main->lamp.first; la; la= la->id.next) { - if (la->type == LA_AREA) - la->ray_samp_method = LA_SAMP_CONSTANT; - else - la->ray_samp_method = LA_SAMP_HALTON; - - la->adapt_thresh = 0.001f; - } - } - } - if (main->versionfile <= 245) { - Scene *sce; - Object *ob; - Image *ima; - Lamp *la; - Material *ma; - ParticleSettings *part; - World *wrld; - Mesh *me; - bNodeTree *ntree; - Tex *tex; - ModifierData *md; - ParticleSystem *psys; - - /* unless the file was created 2.44.3 but not 2.45, update the constraints */ - if ( !(main->versionfile==244 && main->subversionfile==3) && - ((main->versionfile<245) || (main->versionfile==245 && main->subversionfile==0)) ) - { - for (ob = main->object.first; ob; ob= ob->id.next) { - ListBase *list; - list = &ob->constraints; - - /* fix up constraints due to constraint recode changes (originally at 2.44.3) */ - if (list) { - bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { - /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */ - if (curcon->flag & 0x20) { - curcon->ownspace = CONSTRAINT_SPACE_LOCAL; - curcon->tarspace = CONSTRAINT_SPACE_LOCAL; - } - - switch (curcon->type) { - case CONSTRAINT_TYPE_LOCLIMIT: - { - bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data; - - /* old limit without parent option for objects */ - if (data->flag2) - curcon->ownspace = CONSTRAINT_SPACE_LOCAL; - } - break; - } - } - } - - /* correctly initialize constinv matrix */ - unit_m4(ob->constinv); - - if (ob->type == OB_ARMATURE) { - if (ob->pose) { - bConstraint *curcon; - bPoseChannel *pchan; - - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { - /* make sure constraints are all up to date */ - for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) { - /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */ - if (curcon->flag & 0x20) { - curcon->ownspace = CONSTRAINT_SPACE_LOCAL; - curcon->tarspace = CONSTRAINT_SPACE_LOCAL; - } - - switch (curcon->type) { - case CONSTRAINT_TYPE_ACTION: - { - bActionConstraint *data= (bActionConstraint *)curcon->data; - - /* 'data->local' used to mean that target was in local-space */ - if (data->local) - curcon->tarspace = CONSTRAINT_SPACE_LOCAL; - } - break; - } - } - - /* correctly initialize constinv matrix */ - unit_m4(pchan->constinv); - } - } - } - } - } - - /* fix all versions before 2.45 */ - if (main->versionfile != 245) { - - /* repair preview from 242 - 244*/ - for (ima= main->image.first; ima; ima= ima->id.next) { - ima->preview = NULL; - } - } - - /* add point caches */ - for (ob=main->object.first; ob; ob=ob->id.next) { - if (ob->soft && !ob->soft->pointcache) - ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); - - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - if (psys->pointcache) { - if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) { - printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n"); - psys->pointcache->flag &= ~PTCACHE_BAKED; - } - } - else - psys->pointcache= BKE_ptcache_add(&psys->ptcaches); - } - - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Cloth) { - ClothModifierData *clmd = (ClothModifierData*) md; - if (!clmd->point_cache) - clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches); - } - } - } - - /* Copy over old per-level multires vertex data - * into a single vertex array in struct Multires */ - for (me = main->mesh.first; me; me=me->id.next) { - if (me->mr && !me->mr->verts) { - MultiresLevel *lvl = me->mr->levels.last; - if (lvl) { - me->mr->verts = lvl->verts; - lvl->verts = NULL; - /* Don't need the other vert arrays */ - for (lvl = lvl->prev; lvl; lvl = lvl->prev) { - MEM_freeN(lvl->verts); - lvl->verts = NULL; - } - } - } - } - - if (main->versionfile != 245 || main->subversionfile < 1) { - for (la=main->lamp.first; la; la= la->id.next) { - if (la->mode & LA_QUAD) la->falloff_type = LA_FALLOFF_SLIDERS; - else la->falloff_type = LA_FALLOFF_INVLINEAR; - - if (la->curfalloff == NULL) { - la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); - curvemapping_initialize(la->curfalloff); - } - } - } - - for (ma=main->mat.first; ma; ma= ma->id.next) { - if (ma->samp_gloss_mir == 0) { - ma->gloss_mir = ma->gloss_tra= 1.0f; - ma->aniso_gloss_mir = 1.0f; - ma->samp_gloss_mir = ma->samp_gloss_tra= 18; - ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f; - ma->dist_mir = 0.0f; - ma->fadeto_mir = MA_RAYMIR_FADETOSKY; - } - - if (ma->strand_min == 0.0f) - ma->strand_min= 1.0f; - } - - for (part=main->particle.first; part; part=part->id.next) { - if (part->ren_child_nbr==0) - part->ren_child_nbr= part->child_nbr; - - if (part->simplify_refsize==0) { - part->simplify_refsize= 1920; - part->simplify_rate= 1.0f; - part->simplify_transition= 0.1f; - part->simplify_viewport= 0.8f; - } - } - - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { - if (wrld->ao_approx_error == 0.0f) - wrld->ao_approx_error= 0.25f; - } - - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->nodetree) - ntree_version_245(fd, lib, sce->nodetree); - - if (sce->r.simplify_shadowsamples == 0) { - sce->r.simplify_subsurf= 6; - sce->r.simplify_particles= 1.0f; - sce->r.simplify_shadowsamples= 16; - sce->r.simplify_aosss= 1.0f; - } - - if (sce->r.cineongamma == 0) { - sce->r.cineonblack= 95; - sce->r.cineonwhite= 685; - sce->r.cineongamma= 1.7f; - } - } - - for (ntree=main->nodetree.first; ntree; ntree= ntree->id.next) - ntree_version_245(fd, lib, ntree); - - /* fix for temporary flag changes during 245 cycle */ - for (ima= main->image.first; ima; ima= ima->id.next) { - if (ima->flag & IMA_OLD_PREMUL) { - ima->flag &= ~IMA_OLD_PREMUL; - ima->flag |= IMA_DO_PREMUL; - } - } - - for (tex=main->tex.first; tex; tex=tex->id.next) { - if (tex->iuser.flag & IMA_OLD_PREMUL) { - tex->iuser.flag &= ~IMA_OLD_PREMUL; - tex->iuser.flag |= IMA_DO_PREMUL; - - } - - ima= newlibadr(fd, lib, tex->ima); - if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) { - ima->flag &= ~IMA_OLD_PREMUL; - ima->flag |= IMA_DO_PREMUL; - } - } - } - - /* sanity check for skgen - * */ - { - Scene *sce; - for (sce=main->scene.first; sce; sce = sce->id.next) { - if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] || - sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] || - sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2]) - { - sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; - sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; - sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; - } - } - } - - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) { - Image *ima; - - /* initialize 1:1 Aspect */ - for (ima= main->image.first; ima; ima= ima->id.next) { - ima->aspx = ima->aspy = 1.0f; - } - - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) { - bArmature *arm; - ModifierData *md; - Object *ob; - - for (arm= main->armature.first; arm; arm= arm->id.next) - arm->deformflag |= ARM_DEF_B_BONE_REST; - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Armature) - ((ArmatureModifierData*)md)->deformflag |= ARM_DEF_B_BONE_REST; - } - } - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) { - /* foreground color needs to be something other then black */ - Scene *sce; - for (sce= main->scene.first; sce; sce=sce->id.next) { - sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; - sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */ - sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */ - } - } - - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) { - Scene *sce; - /* fix frs_sec_base */ - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->r.frs_sec_base == 0) { - sce->r.frs_sec_base = 1; - } - } - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) { - Object *ob; - bPoseChannel *pchan; - bConstraint *con; - bConstraintTarget *ct; - - for (ob = main->object.first; ob; ob= ob->id.next) { - if (ob->pose) { - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (con=pchan->constraints.first; con; con=con->next) { - if (con->type == CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data= (bPythonConstraint *)con->data; - if (data->tar) { - /* version patching needs to be done */ - ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - - ct->tar = data->tar; - BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); - ct->space = con->tarspace; - - BLI_addtail(&data->targets, ct); - data->tarnum++; - - /* clear old targets to avoid problems */ - data->tar = NULL; - data->subtarget[0]= '\0'; - } - } - else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; - - /* new headtail functionality makes Bone-Tip function obsolete */ - if (data->flag & LOCLIKE_TIP) - con->headtail = 1.0f; - } - } - } - } - - for (con=ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data= (bPythonConstraint *)con->data; - if (data->tar) { - /* version patching needs to be done */ - ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - - ct->tar = data->tar; - BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); - ct->space = con->tarspace; - - BLI_addtail(&data->targets, ct); - data->tarnum++; - - /* clear old targets to avoid problems */ - data->tar = NULL; - data->subtarget[0]= '\0'; - } - } - else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; - - /* new headtail functionality makes Bone-Tip function obsolete */ - if (data->flag & LOCLIKE_TIP) - con->headtail = 1.0f; - } - } - - if (ob->soft && ob->soft->keys) { - SoftBody *sb = ob->soft; - int k; - - for (k=0; ktotkey; k++) { - if (sb->keys[k]) - MEM_freeN(sb->keys[k]); - } - - MEM_freeN(sb->keys); - - sb->keys = NULL; - sb->totkey = 0; - } - } - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) { - Scene *sce; - Object *ob; - PartEff *paf=NULL; - - for (ob = main->object.first; ob; ob= ob->id.next) { - if (ob->soft && ob->soft->keys) { - SoftBody *sb = ob->soft; - int k; - - for (k=0; ktotkey; k++) { - if (sb->keys[k]) - MEM_freeN(sb->keys[k]); - } - - MEM_freeN(sb->keys); - - sb->keys = NULL; - sb->totkey = 0; - } - - /* convert old particles to new system */ - if ((paf = do_version_give_parteff_245(ob))) { - ParticleSystem *psys; - ModifierData *md; - ParticleSystemModifierData *psmd; - ParticleSettings *part; - - /* create new particle system */ - psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); - psys->pointcache = BKE_ptcache_add(&psys->ptcaches); - - part = psys->part = psys_new_settings("ParticleSettings", main); - - /* needed for proper libdata lookup */ - oldnewmap_insert(fd->libmap, psys->part, psys->part, 0); - part->id.lib= ob->id.lib; - - part->id.us--; - part->id.flag |= (ob->id.flag & LIB_NEEDLINK); - - psys->totpart=0; - psys->flag= PSYS_ENABLED|PSYS_CURRENT; - - BLI_addtail(&ob->particlesystem, psys); - - md= modifier_new(eModifierType_ParticleSystem); - BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); - psmd= (ParticleSystemModifierData*) md; - psmd->psys=psys; - BLI_addtail(&ob->modifiers, md); - - /* convert settings from old particle system */ - /* general settings */ - part->totpart = MIN2(paf->totpart, 100000); - part->sta = paf->sta; - part->end = paf->end; - part->lifetime = paf->lifetime; - part->randlife = paf->randlife; - psys->seed = paf->seed; - part->disp = paf->disp; - part->omat = paf->mat[0]; - part->hair_step = paf->totkey; - - part->eff_group = paf->group; - - /* old system didn't interpolate between keypoints at render time */ - part->draw_step = part->ren_step = 0; - - /* physics */ - part->normfac = paf->normfac * 25.0f; - part->obfac = paf->obfac; - part->randfac = paf->randfac * 25.0f; - part->dampfac = paf->damp; - copy_v3_v3(part->acc, paf->force); - - /* flags */ - if (paf->stype & PAF_VECT) { - if (paf->flag & PAF_STATIC) { - /* new hair lifetime is always 100.0f */ - float fac = paf->lifetime / 100.0f; - - part->draw_as = PART_DRAW_PATH; - part->type = PART_HAIR; - psys->recalc |= PSYS_RECALC_REDO; - - part->normfac *= fac; - part->randfac *= fac; - } - else { - part->draw_as = PART_DRAW_LINE; - part->draw |= PART_DRAW_VEL_LENGTH; - part->draw_line[1] = 0.04f; - } - } - - part->rotmode = PART_ROT_VEL; - - part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0; - part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0; - part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0; - part->flag |= (paf->flag & PAF_UNBORN) ? PART_UNBORN : 0; - part->flag |= (paf->flag & PAF_DIED) ? PART_DIED : 0; - part->from |= (paf->flag & PAF_FACE) ? PART_FROM_FACE : 0; - part->draw |= (paf->flag & PAF_SHOWE) ? PART_DRAW_EMITTER : 0; - - psys->vgroup[PSYS_VG_DENSITY] = paf->vertgroup; - psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v; - psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v; - - /* dupliobjects */ - if (ob->transflag & OB_DUPLIVERTS) { - Object *dup = main->object.first; - - for (; dup; dup= dup->id.next) { - if (ob == newlibadr(fd, lib, dup->parent)) { - part->dup_ob = dup; - ob->transflag |= OB_DUPLIPARTS; - ob->transflag &= ~OB_DUPLIVERTS; - - part->draw_as = PART_DRAW_OB; - - /* needed for proper libdata lookup */ - oldnewmap_insert(fd->libmap, dup, dup, 0); - } - } - } - - - { - FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE) - part->type = PART_FLUID; - } - - do_version_free_effects_245(&ob->effect); - - printf("Old particle system converted to new system.\n"); - } - } - - for (sce= main->scene.first; sce; sce=sce->id.next) { - ParticleEditSettings *pset= &sce->toolsettings->particle; - int a; - - if (pset->brush[0].size == 0) { - pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; - pset->emitterdist= 0.25f; - pset->totrekey= 5; - pset->totaddkey= 5; - pset->brushtype= PE_BRUSH_NONE; - - for (a=0; abrush[a].strength= 50; - pset->brush[a].size= 50; - pset->brush[a].step= 10; - } - - pset->brush[PE_BRUSH_CUT].strength= 100; - } - } - } - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) { - Material *ma; - int a; - - for (ma=main->mat.first; ma; ma= ma->id.next) - if (ma->mode & MA_NORMAP_TANG) - for (a=0; amtex[a] && ma->mtex[a]->tex) - ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT; - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) { - Object *ob; - - /* dupliface scale */ - for (ob= main->object.first; ob; ob= ob->id.next) - ob->dupfacesca = 1.0f; - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) { - Object *ob; - bActionStrip *strip; - - /* nla-strips - scale */ - for (ob= main->object.first; ob; ob= ob->id.next) { - for (strip= ob->nlastrips.first; strip; strip= strip->next) { - float length, actlength, repeat; - - if (strip->flag & ACTSTRIP_USESTRIDE) - repeat= 1.0f; - else - repeat= strip->repeat; - - length = strip->end-strip->start; - if (length == 0.0f) length= 1.0f; - actlength = strip->actend-strip->actstart; - - strip->scale = length / (repeat * actlength); - if (strip->scale == 0.0f) strip->scale= 1.0f; - } - if (ob->soft) { - ob->soft->inpush = ob->soft->inspring; - ob->soft->shearstiff = 1.0f; - } - } - } - - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) { - Scene *sce; - Sequence *seq; - - for (sce=main->scene.first; sce; sce=sce->id.next) { - SEQ_BEGIN (sce->ed, seq) - { - if (seq->blend_mode == 0) - seq->blend_opacity = 100.0f; - } - SEQ_END - } - } - - /*fix broken group lengths in id properties*/ - if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) { - idproperties_fix_group_lengths(main->scene); - idproperties_fix_group_lengths(main->library); - idproperties_fix_group_lengths(main->object); - idproperties_fix_group_lengths(main->mesh); - idproperties_fix_group_lengths(main->curve); - idproperties_fix_group_lengths(main->mball); - idproperties_fix_group_lengths(main->mat); - idproperties_fix_group_lengths(main->tex); - idproperties_fix_group_lengths(main->image); - idproperties_fix_group_lengths(main->latt); - idproperties_fix_group_lengths(main->lamp); - idproperties_fix_group_lengths(main->camera); - idproperties_fix_group_lengths(main->ipo); - idproperties_fix_group_lengths(main->key); - idproperties_fix_group_lengths(main->world); - idproperties_fix_group_lengths(main->screen); - idproperties_fix_group_lengths(main->script); - idproperties_fix_group_lengths(main->vfont); - idproperties_fix_group_lengths(main->text); - idproperties_fix_group_lengths(main->sound); - idproperties_fix_group_lengths(main->group); - idproperties_fix_group_lengths(main->armature); - idproperties_fix_group_lengths(main->action); - idproperties_fix_group_lengths(main->nodetree); - idproperties_fix_group_lengths(main->brush); - idproperties_fix_group_lengths(main->particle); - } - - /* sun/sky */ - if (main->versionfile < 246) { - Object *ob; - bActuator *act; - - /* dRot actuator change direction in 2.46 */ - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_OBJECT) { - bObjectActuator *ba= act->data; - - ba->drot[0] = -ba->drot[0]; - ba->drot[1] = -ba->drot[1]; - ba->drot[2] = -ba->drot[2]; - } - } - } - } - - // convert fluids to modifier - if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { - Object *ob; - - for (ob = main->object.first; ob; ob= ob->id.next) { - if (ob->fluidsimSettings) { - FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim); - BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd); - - MEM_freeN(fluidmd->fss); - fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings); - fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo); - MEM_freeN(ob->fluidsimSettings); - - fluidmd->fss->lastgoodframe = INT_MAX; - fluidmd->fss->flag = 0; - fluidmd->fss->meshVelocities = NULL; - } - } - } - - - if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { - Mesh *me; - - for (me=main->mesh.first; me; me= me->id.next) - alphasort_version_246(fd, lib, me); - } - - if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { - Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { - if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) - ob->pd->f_noise = 0.0f; - } - } - - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) { - Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { - ob->gameflag |= OB_COLLISION; - ob->margin = 0.06f; - } - } - - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) { - Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { - // Starting from subversion 3, ACTOR is a separate feature. - // Before it was conditioning all the other dynamic flags - if (!(ob->gameflag & OB_ACTOR)) - ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE); - /* suitable default for older files */ - } - } - - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) { - Lamp *la= main->lamp.first; - for (; la; la= la->id.next) { - la->skyblendtype= MA_RAMP_ADD; - la->skyblendfac= 1.0f; - } - } - - /* set the curve radius interpolation to 2.47 default - easy */ - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) { - Curve *cu; - Nurb *nu; - - for (cu= main->curve.first; cu; cu= cu->id.next) { - for (nu= cu->nurb.first; nu; nu= nu->next) { - if (nu) { - nu->radius_interp = 3; - - /* resolu and resolv are now used differently for surfaces - * rather than using the resolution to define the entire number of divisions, - * use it for the number of divisions per segment - */ - if (nu->pntsv > 1) { - nu->resolu = MAX2( 1, (int)(((float)nu->resolu / (float)nu->pntsu)+0.5f) ); - nu->resolv = MAX2( 1, (int)(((float)nu->resolv / (float)nu->pntsv)+0.5f) ); - } - } - } - } - } - /* direction constraint actuators were always local in previous version */ - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) { - bActuator *act; - Object *ob; - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_CONSTRAINT) { - bConstraintActuator *coa = act->data; - if (coa->type == ACT_CONST_TYPE_DIST) { - coa->flag |= ACT_CONST_LOCAL; - } - } - } - } - } - - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) { - Lamp *la= main->lamp.first; - for (; la; la= la->id.next) { - la->sky_exposure= 1.0f; - } - } - - /* BGE message actuators needed OB prefix, very confusing */ - if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) { - bActuator *act; - Object *ob; - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_MESSAGE) { - bMessageActuator *msgAct = (bMessageActuator *) act->data; - if (BLI_strnlen(msgAct->toPropName, 3) > 2) { - /* strip first 2 chars, would have only worked if these were OB anyway */ - memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2); - } - else { - msgAct->toPropName[0] = '\0'; - } - } - } - } - } - - if (main->versionfile < 248) { - Lamp *la; - - for (la=main->lamp.first; la; la= la->id.next) { - if (la->atm_turbidity == 0.0f) { - la->sun_effect_type = 0; - la->horizon_brightness = 1.0f; - la->spread = 1.0f; - la->sun_brightness = 1.0f; - la->sun_size = 1.0f; - la->backscattered_light = 1.0f; - la->atm_turbidity = 2.0f; - la->atm_inscattering_factor = 1.0f; - la->atm_extinction_factor = 1.0f; - la->atm_distance_factor = 1.0f; - la->sun_intensity = 1.0f; - } - } - } - - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) { - Scene *sce; - - /* Note, these will need to be added for painting */ - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->toolsettings->imapaint.seam_bleed = 2; - sce->toolsettings->imapaint.normal_angle = 80; - - /* initialize skeleton generation toolsettings */ - sce->toolsettings->skgen_resolution = 250; - sce->toolsettings->skgen_threshold_internal = 0.1f; - sce->toolsettings->skgen_threshold_external = 0.1f; - sce->toolsettings->skgen_angle_limit = 30.0f; - sce->toolsettings->skgen_length_ratio = 1.3f; - sce->toolsettings->skgen_length_limit = 1.5f; - sce->toolsettings->skgen_correlation_limit = 0.98f; - sce->toolsettings->skgen_symmetry_limit = 0.1f; - sce->toolsettings->skgen_postpro = SKGEN_SMOOTH; - sce->toolsettings->skgen_postpro_passes = 3; - sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC; - sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; - sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; - sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; - - - sce->toolsettings->skgen_retarget_angle_weight = 1.0f; - sce->toolsettings->skgen_retarget_length_weight = 1.0f; - sce->toolsettings->skgen_retarget_distance_weight = 1.0f; - - /* Skeleton Sketching */ - sce->toolsettings->bone_sketching = 0; - sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW; - } - } - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { - bScreen *sc; - - /* adjust default settings for Animation Editors */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { - switch (sl->spacetype) { - case SPACE_ACTION: - { - SpaceAction *sact= (SpaceAction *)sl; - - sact->mode= SACTCONT_DOPESHEET; - sact->autosnap= SACTSNAP_FRAME; - } - break; - case SPACE_IPO: - { - SpaceIpo *sipo= (SpaceIpo *)sl; - sipo->autosnap= SACTSNAP_FRAME; - } - break; - case SPACE_NLA: - { - SpaceNla *snla= (SpaceNla *)sl; - snla->autosnap= SACTSNAP_FRAME; - } - break; - } - } - } - } - } - - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { - Object *ob; - - /* Adjustments needed after Bullets update */ - for (ob = main->object.first; ob; ob= ob->id.next) { - ob->damping *= 0.635f; - ob->rdamping = 0.1f + (0.8f * ob->rdamping); - } - } - - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) { - Scene *sce; - World *wrld; - - /* Dome (Fisheye) default parameters */ - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->r.domeangle = 180; - sce->r.domemode = 1; - sce->r.domeres = 4; - sce->r.domeresbuf = 1.0f; - sce->r.dometilt = 0; - } - /* DBVT culling by default */ - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { - wrld->mode |= WO_DBVT_CULLING; - wrld->occlusionRes = 128; - } - } - - if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) { - Object *ob; - World *wrld; - for (ob = main->object.first; ob; ob= ob->id.next) { - ob->m_contactProcessingThreshold = 1.0f; //pad3 is used for m_contactProcessingThreshold - if (ob->parent) { - /* check if top parent has compound shape set and if yes, set this object - * to compound shaper as well (was the behavior before, now it's optional) */ - Object *parent= newlibadr(fd, lib, ob->parent); - while (parent && parent != ob && parent->parent != NULL) { - parent = newlibadr(fd, lib, parent->parent); - } - if (parent) { - if (parent->gameflag & OB_CHILD) - ob->gameflag |= OB_CHILD; - } - } - } - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { - wrld->ticrate = 60; - wrld->maxlogicstep = 5; - wrld->physubstep = 1; - wrld->maxphystep = 5; - } - } - - // correct introduce of seed for wind force - if (main->versionfile < 249 && main->subversionfile < 1) { - Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { - if (ob->pd) - ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; - } - - } - - if (main->versionfile < 249 && main->subversionfile < 2) { - Scene *sce= main->scene.first; - Sequence *seq; - Editing *ed; - - while (sce) { - ed= sce->ed; - if (ed) { - SEQP_BEGIN (ed, seq) - { - if (seq->strip && seq->strip->proxy) { - seq->strip->proxy->quality =90; - } - } - SEQ_END - } - - sce= sce->id.next; - } - - } - - if (main->versionfile < 250) { - bScreen *screen; - Scene *scene; - Base *base; - Material *ma; - Camera *cam; - Mesh *me; - Curve *cu; - Scene *sce; - Tex *tx; - ParticleSettings *part; - Object *ob; - //PTCacheID *pid; - //ListBase pidlist; - - bSound *sound; - Sequence *seq; - bActuator *act; - int a; - - for (sound = main->sound.first; sound; sound = sound->id.next) { - if (sound->newpackedfile) { - sound->packedfile = sound->newpackedfile; - sound->newpackedfile = NULL; - } - } - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_SOUND) { - bSoundActuator *sAct = (bSoundActuator*) act->data; - if (sAct->sound) { - sound = newlibadr(fd, lib, sAct->sound); - sAct->flag = sound->flags & SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0; - sAct->pitch = sound->pitch; - sAct->volume = sound->volume; - sAct->sound3D.reference_distance = sound->distance; - sAct->sound3D.max_gain = sound->max_gain; - sAct->sound3D.min_gain = sound->min_gain; - sAct->sound3D.rolloff_factor = sound->attenuation; - } - else { - sAct->sound3D.reference_distance = 1.0f; - sAct->volume = 1.0f; - sAct->sound3D.max_gain = 1.0f; - sAct->sound3D.rolloff_factor = 1.0f; - } - sAct->sound3D.cone_inner_angle = 360.0f; - sAct->sound3D.cone_outer_angle = 360.0f; - sAct->sound3D.max_distance = FLT_MAX; - } - } - } - - for (scene = main->scene.first; scene; scene = scene->id.next) { - if (scene->ed && scene->ed->seqbasep) { - SEQ_BEGIN (scene->ed, seq) - { - if (seq->type == SEQ_HD_SOUND) { - char str[FILE_MAX]; - BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(str, main->name); - seq->sound = sound_new_file(main, str); - } - /* don't know, if anybody used that - * this way, but just in case, upgrade - * to new way... */ - if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && - !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) - { - - BLI_snprintf(seq->strip->proxy->dir, - FILE_MAXDIR, "%s/BL_proxy", - seq->strip->dir); - } - } - SEQ_END - } - } - - for (screen= main->screen.first; screen; screen= screen->id.next) { - do_versions_windowmanager_2_50(screen); - do_versions_gpencil_2_50(main, screen); - } - - /* shader, composite and texture node trees have id.name empty, put something in - * to have them show in RNA viewer and accessible otherwise. - */ - for (ma= main->mat.first; ma; ma= ma->id.next) { - if (ma->nodetree && ma->nodetree->id.name[0] == '\0') - strcpy(ma->nodetree->id.name, "NTShader Nodetree"); - - /* which_output 0 is now "not specified" */ - for (a=0; amtex[a]) { - tx= newlibadr(fd, lib, ma->mtex[a]->tex); - if (tx && tx->use_nodes) - ma->mtex[a]->which_output++; - } - } - } - /* and composite trees */ - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->nodetree && sce->nodetree->id.name[0] == '\0') - strcpy(sce->nodetree->id.name, "NTCompositing Nodetree"); - - /* move to cameras */ - if (sce->r.mode & R_PANORAMA) { - for (base=sce->base.first; base; base=base->next) { - ob= newlibadr(fd, lib, base->object); - - if (ob->type == OB_CAMERA && !ob->id.lib) { - cam= newlibadr(fd, lib, ob->data); - cam->flag |= CAM_PANORAMA; - } - } - - sce->r.mode &= ~R_PANORAMA; - } - } - /* and texture trees */ - for (tx= main->tex.first; tx; tx= tx->id.next) { - bNode *node; - - if (tx->nodetree) { - if (tx->nodetree->id.name[0] == '\0') - strcpy(tx->nodetree->id.name, "NTTexture Nodetree"); - - /* which_output 0 is now "not specified" */ - for (node=tx->nodetree->nodes.first; node; node=node->next) - if (node->type == TEX_NODE_OUTPUT) - node->custom1++; - } - } - - /* copy standard draw flag to meshes(used to be global, is not available here) */ - for (me= main->mesh.first; me; me= me->id.next) { - me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; - } - - /* particle draw and render types */ - for (part= main->particle.first; part; part= part->id.next) { - if (part->draw_as) { - if (part->draw_as == PART_DRAW_DOT) { - part->ren_as = PART_DRAW_HALO; - part->draw_as = PART_DRAW_REND; - } - else if (part->draw_as <= PART_DRAW_AXIS) { - part->ren_as = PART_DRAW_HALO; - } - else { - part->ren_as = part->draw_as; - part->draw_as = PART_DRAW_REND; - } - } - part->path_end = 1.0f; - part->clength = 1.0f; - } - /* set old pointcaches to have disk cache flag */ - for (ob = main->object.first; ob; ob= ob->id.next) { - - //BKE_ptcache_ids_from_object(&pidlist, ob); - - //for (pid=pidlist.first; pid; pid=pid->next) - // pid->cache->flag |= PTCACHE_DISK_CACHE; - - //BLI_freelistN(&pidlist); - } - - /* type was a mixed flag & enum. move the 2d flag elsewhere */ - for (cu = main->curve.first; cu; cu= cu->id.next) { - Nurb *nu; - - for (nu= cu->nurb.first; nu; nu= nu->next) { - nu->flag |= (nu->type & CU_2D); - nu->type &= CU_TYPE; - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) { - Object *ob; - Material *ma; - Tex *tex; - Scene *sce; - ToolSettings *ts; - //PTCacheID *pid; - //ListBase pidlist; - - for (ob = main->object.first; ob; ob = ob->id.next) { - //BKE_ptcache_ids_from_object(&pidlist, ob); - - //for (pid=pidlist.first; pid; pid=pid->next) { - // if (pid->ptcaches->first == NULL) - // pid->ptcaches->first = pid->ptcaches->last = pid->cache; - //} - - //BLI_freelistN(&pidlist); - - if (ob->type == OB_MESH) { - Mesh *me = newlibadr(fd, lib, ob->data); - void *olddata = ob->data; - ob->data = me; - - /* XXX - library meshes crash on loading most yoFrankie levels, - * the multires pointer gets invalid - Campbell */ - if (me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) { - multires_load_old(ob, me); - } - - ob->data = olddata; - } - - if (ob->totcol && ob->matbits == NULL) { - int a; - - ob->matbits= MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits"); - for (a=0; atotcol; a++) - ob->matbits[a]= ob->colbits & (1<tex.first; tex; tex = tex->id.next) { - if (tex->afmax == 0) - tex->afmax= 8; - } - - for (ma = main->mat.first; ma; ma = ma->id.next) { - int a; - if (ma->mode & MA_WIRE) { - ma->material_type= MA_TYPE_WIRE; - ma->mode &= ~MA_WIRE; - } - if (ma->mode & MA_HALO) { - ma->material_type= MA_TYPE_HALO; - ma->mode &= ~MA_HALO; - } - - if (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) { - ma->mode |= MA_TRANSP; - } - else { - /* ma->mode |= MA_ZTRANSP; */ /* leave ztransp as is even if its not used [#28113] */ - ma->mode &= ~MA_TRANSP; - } - - /* set new bump for unused slots */ - for (a=0; amtex[a]) { - tex= ma->mtex[a]->tex; - if (!tex) { - ma->mtex[a]->texflag |= MTEX_3TAP_BUMP; - ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE; - } - else { - tex= (Tex*)newlibadr(fd, ma->id.lib, tex); - if (tex && tex->type == 0) { /* invalid type */ - ma->mtex[a]->texflag |= MTEX_3TAP_BUMP; - ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE; - } - } - } - } - - /* volume rendering settings */ - if (ma->vol.stepsize < 0.0001f) { - ma->vol.density = 1.0f; - ma->vol.emission = 0.0f; - ma->vol.scattering = 1.0f; - ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f; - ma->vol.density_scale = 1.0f; - ma->vol.depth_cutoff = 0.01f; - ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED; - ma->vol.stepsize = 0.2f; - ma->vol.shade_type = MA_VOL_SHADE_SHADED; - ma->vol.shadeflag |= MA_VOL_PRECACHESHADING; - ma->vol.precache_resolution = 50; - } - } - - for (sce = main->scene.first; sce; sce = sce->id.next) { - ts= sce->toolsettings; - if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) { - ts->normalsize= 0.1f; - ts->selectmode= SCE_SELECT_VERTEX; - - /* autokeying - setting should be taken from the user-prefs - * but the userprefs version may not have correct flags set - * (i.e. will result in blank box when enabled) - */ - ts->autokey_mode= U.autokey_mode; - if (ts->autokey_mode == 0) - ts->autokey_mode= 2; /* 'add/replace' but not on */ - ts->uv_selectmode= UV_SELECT_VERTEX; - ts->vgroup_weight= 1.0f; - } - - /* Game Settings */ - //Dome - sce->gm.dome.angle = sce->r.domeangle; - sce->gm.dome.mode = sce->r.domemode; - sce->gm.dome.res = sce->r.domeres; - sce->gm.dome.resbuf = sce->r.domeresbuf; - sce->gm.dome.tilt = sce->r.dometilt; - sce->gm.dome.warptext = sce->r.dometext; - - //Stand Alone - sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0); - sce->gm.xplay = sce->r.xplay; - sce->gm.yplay = sce->r.yplay; - sce->gm.freqplay = sce->r.freqplay; - sce->gm.depth = sce->r.depth; - sce->gm.attrib = sce->r.attrib; - - //Stereo - sce->gm.stereomode = sce->r.stereomode; - /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/ - if (sce->gm.stereomode == 1) { //1 = STEREO_NOSTEREO - sce->gm.stereoflag = STEREO_NOSTEREO; - sce->gm.stereomode = STEREO_ANAGLYPH; - } - else if (sce->gm.stereomode == 8) { //8 = STEREO_DOME - sce->gm.stereoflag = STEREO_DOME; - sce->gm.stereomode = STEREO_ANAGLYPH; - } - else - sce->gm.stereoflag = STEREO_ENABLED; - - //Framing - sce->gm.framing = sce->framing; - sce->gm.xplay = sce->r.xplay; - sce->gm.yplay = sce->r.yplay; - sce->gm.freqplay= sce->r.freqplay; - sce->gm.depth= sce->r.depth; - - //Physic (previously stored in world) - sce->gm.gravity =9.8f; - sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default - sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default - sce->gm.occlusionRes = 128; - sce->gm.ticrate = 60; - sce->gm.maxlogicstep = 5; - sce->gm.physubstep = 1; - sce->gm.maxphystep = 5; - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) { - Scene *sce; - Object *ob; - - for (sce = main->scene.first; sce; sce = sce->id.next) { - if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES) - sce->gm.flag |= GAME_ENABLE_ALL_FRAMES; - if (fd->fileflags & G_FILE_SHOW_DEBUG_PROPS) - sce->gm.flag |= GAME_SHOW_DEBUG_PROPS; - if (fd->fileflags & G_FILE_SHOW_FRAMERATE) - sce->gm.flag |= GAME_SHOW_FRAMERATE; - if (fd->fileflags & G_FILE_SHOW_PHYSICS) - sce->gm.flag |= GAME_SHOW_PHYSICS; - if (fd->fileflags & G_FILE_GLSL_NO_SHADOWS) - sce->gm.flag |= GAME_GLSL_NO_SHADOWS; - if (fd->fileflags & G_FILE_GLSL_NO_SHADERS) - sce->gm.flag |= GAME_GLSL_NO_SHADERS; - if (fd->fileflags & G_FILE_GLSL_NO_RAMPS) - sce->gm.flag |= GAME_GLSL_NO_RAMPS; - if (fd->fileflags & G_FILE_GLSL_NO_NODES) - sce->gm.flag |= GAME_GLSL_NO_NODES; - if (fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX) - sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX; - if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS) - sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; - - if (fd->fileflags & G_FILE_GAME_MAT_GLSL) - sce->gm.matmode= GAME_MAT_GLSL; - else if (fd->fileflags & G_FILE_GAME_MAT) - sce->gm.matmode= GAME_MAT_MULTITEX; - else - sce->gm.matmode= GAME_MAT_TEXFACE; - - sce->gm.flag |= GAME_DISPLAY_LISTS; - } - - for (ob = main->object.first; ob; ob = ob->id.next) { - if (ob->flag & 8192) // OB_POSEMODE = 8192 - ob->mode |= OB_MODE_POSE; - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) { - Scene *sce; - Object *ob; - Material *ma; - Lamp *la; - World *wo; - Tex *tex; - ParticleSettings *part; - int do_gravity = 0; - - for (sce = main->scene.first; sce; sce = sce->id.next) - if (sce->unit.scale_length == 0.0f) - sce->unit.scale_length= 1.0f; - - for (ob = main->object.first; ob; ob = ob->id.next) { - /* fluid-sim stuff */ - FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - if (fluidmd) fluidmd->fss->fmd = fluidmd; - - /* rotation modes were added, but old objects would now default to being 'quaternion based' */ - ob->rotmode= ROT_MODE_EUL; - } - - for (ma = main->mat.first; ma; ma=ma->id.next) { - if (ma->vol.reflection == 0.f) { - ma->vol.reflection = 1.f; - ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f; - ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f; - } - - do_version_mtex_factor_2_50(ma->mtex, ID_MA); - } - - for (la = main->lamp.first; la; la=la->id.next) - do_version_mtex_factor_2_50(la->mtex, ID_LA); - - for (wo = main->world.first; wo; wo=wo->id.next) - do_version_mtex_factor_2_50(wo->mtex, ID_WO); - - for (tex = main->tex.first; tex; tex=tex->id.next) - if (tex->vd) - if (tex->vd->extend == 0) - tex->vd->extend = TEX_CLIP; - - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->audio.main == 0.0f) - sce->audio.main = 1.0f; - - sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate; - sce->r.ffcodecdata.audio_volume = sce->audio.main; - sce->audio.distance_model = 2; - sce->audio.doppler_factor = 1.0f; - sce->audio.speed_of_sound = 343.3f; - } - - /* Add default gravity to scenes */ - for (sce= main->scene.first; sce; sce= sce->id.next) { - if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && - len_v3(sce->physics_settings.gravity) == 0.0f) - { - sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f; - sce->physics_settings.gravity[2] = -9.81f; - sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY; - do_gravity = 1; - } - } - - /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */ - if (do_gravity) for (part= main->particle.first; part; part= part->id.next) - part->effector_weights->global_gravity = part->acc[2]/-9.81f; - - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - - if (do_gravity) { - for (md= ob->modifiers.first; md; md= md->next) { - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); - if (clmd) - clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f; - } - - if (ob->soft) - ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81f; - } - - /* Normal wind shape is plane */ - if (ob->pd) { - if (ob->pd->forcefield == PFIELD_WIND) - ob->pd->shape = PFIELD_SHAPE_PLANE; - - if (ob->pd->flag & PFIELD_PLANAR) - ob->pd->shape = PFIELD_SHAPE_PLANE; - else if (ob->pd->flag & PFIELD_SURFACE) - ob->pd->shape = PFIELD_SHAPE_SURFACE; - - ob->pd->flag |= PFIELD_DO_LOCATION; - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) { - Object *ob; - Lamp *la; - - /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */ - for (ob= main->object.first; ob; ob= ob->id.next) { - /* new variables for all objects */ - ob->quat[0]= 1.0f; - ob->rotAxis[1]= 1.0f; - - /* bones */ - if (ob->pose) { - bPoseChannel *pchan; - - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - /* just need to initalise rotation axis properly... */ - pchan->rotAxis[1]= 1.0f; - } - } - } - - for (la = main->lamp.first; la; la=la->id.next) - la->compressthresh= 0.05f; - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) { - Mesh *me; - Nurb *nu; - Lattice *lt; - Curve *cu; - Key *key; - float *data; - int a, tot; - - /* shape keys are no longer applied to the mesh itself, but rather - * to the derivedmesh/displist, so here we ensure that the basis - * shape key is always set in the mesh coordinates. */ - - for (me= main->mesh.first; me; me= me->id.next) { - if ((key = newlibadr(fd, lib, me->key)) && key->refkey) { - data= key->refkey->data; - tot= MIN2(me->totvert, key->refkey->totelem); - - for (a=0; amvert[a].co, data); - } - } - - for (lt= main->latt.first; lt; lt= lt->id.next) { - if ((key = newlibadr(fd, lib, lt->key)) && key->refkey) { - data= key->refkey->data; - tot= MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem); - - for (a=0; adef[a].vec, data); - } - } - - for (cu= main->curve.first; cu; cu= cu->id.next) { - if ((key = newlibadr(fd, lib, cu->key)) && key->refkey) { - data= key->refkey->data; - - for (nu=cu->nurb.first; nu; nu=nu->next) { - if (nu->bezt) { - BezTriple *bezt = nu->bezt; - - for (a=0; apntsu; a++, bezt++) { - copy_v3_v3(bezt->vec[0], data); data+=3; - copy_v3_v3(bezt->vec[1], data); data+=3; - copy_v3_v3(bezt->vec[2], data); data+=3; - bezt->alfa= *data; data++; - } - } - else if (nu->bp) { - BPoint *bp = nu->bp; - - for (a=0; apntsu*nu->pntsv; a++, bp++) { - copy_v3_v3(bp->vec, data); data+=3; - bp->alfa= *data; data++; - } - } - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) { - { - Scene *sce= main->scene.first; - while (sce) { - if (sce->r.frame_step==0) - sce->r.frame_step= 1; - if (sce->r.mblur_samples==0) - sce->r.mblur_samples = sce->r.osa; - - if (sce->ed && sce->ed->seqbase.first) { - do_versions_seq_unique_name_all_strips( - sce, &sce->ed->seqbase); - } - - sce= sce->id.next; - } - } - { - /* ensure all nodes have unique names */ - bNodeTree *ntree= main->nodetree.first; - while (ntree) { - bNode *node=ntree->nodes.first; - - while (node) { - nodeUniqueName(ntree, node); - node= node->next; - } - - ntree= ntree->id.next; - } - } - { - Object *ob=main->object.first; - while (ob) { - /* shaded mode disabled for now */ - if (ob->dt == OB_MATERIAL) ob->dt = OB_TEXTURE; - ob=ob->id.next; - } - } - - { - bScreen *screen; - ScrArea *sa; - SpaceLink *sl; - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - if (v3d->drawtype == OB_MATERIAL) v3d->drawtype = OB_SOLID; - } - } - } - } - } - - /* only convert old 2.50 files with color management */ - if (main->versionfile == 250) { - Scene *sce=main->scene.first; - Material *ma=main->mat.first; - World *wo=main->world.first; - Tex *tex=main->tex.first; - int i, convert=0; - - /* convert to new color management system: - * while previously colors were stored as srgb, - * now they are stored as linear internally, - * with screen gamma correction in certain places in the UI. */ - - /* don't know what scene is active, so we'll convert if any scene has it enabled... */ - while (sce) { - if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT) - convert=1; - sce=sce->id.next; - } - - if (convert) { - while (ma) { - if (ma->ramp_col) { - ColorBand *band = (ColorBand *)ma->ramp_col; - for (i=0; itot; i++) { - CBData *data = band->data + i; - srgb_to_linearrgb_v3_v3(&data->r, &data->r); - } - } - if (ma->ramp_spec) { - ColorBand *band = (ColorBand *)ma->ramp_spec; - for (i=0; itot; i++) { - CBData *data = band->data + i; - srgb_to_linearrgb_v3_v3(&data->r, &data->r); - } - } - - srgb_to_linearrgb_v3_v3(&ma->r, &ma->r); - srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr); - srgb_to_linearrgb_v3_v3(&ma->mirr, &ma->mirr); - srgb_to_linearrgb_v3_v3(ma->sss_col, ma->sss_col); - ma=ma->id.next; - } - - while (tex) { - if (tex->coba) { - ColorBand *band = (ColorBand *)tex->coba; - for (i=0; itot; i++) { - CBData *data = band->data + i; - srgb_to_linearrgb_v3_v3(&data->r, &data->r); - } - } - tex=tex->id.next; - } - - while (wo) { - srgb_to_linearrgb_v3_v3(&wo->ambr, &wo->ambr); - srgb_to_linearrgb_v3_v3(&wo->horr, &wo->horr); - srgb_to_linearrgb_v3_v3(&wo->zenr, &wo->zenr); - wo=wo->id.next; - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) { - Scene *sce; - Mesh *me; - Object *ob; - - for (sce=main->scene.first; sce; sce=sce->id.next) - if (!sce->toolsettings->particle.selectmode) - sce->toolsettings->particle.selectmode= SCE_SELECT_PATH; - - if (main->versionfile == 250 && main->subversionfile > 1) { - for (me=main->mesh.first; me; me=me->id.next) - multires_load_old_250(me); - - for (ob=main->object.first; ob; ob=ob->id.next) { - MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires); - - if (mmd) { - mmd->totlvl--; - mmd->lvl--; - mmd->sculptlvl= mmd->lvl; - mmd->renderlvl= mmd->lvl; - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) { - Object *ob; - - /* properly initialize hair clothsim data on old files */ - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { - if (md->type == eModifierType_Cloth) { - ClothModifierData *clmd = (ClothModifierData *)md; - if (clmd->sim_parms->velocity_smooth < 0.01f) - clmd->sim_parms->velocity_smooth = 0.f; - } - } - } - } - - /* fix bad area setup in subversion 10 */ - if (main->versionfile == 250 && main->subversionfile == 10) { - /* fix for new view type in sequencer */ - bScreen *screen; - ScrArea *sa; - SpaceLink *sl; - - - /* remove all preview window in wrong spaces */ - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype!=SPACE_SEQ) { - ARegion *ar; - ListBase *regionbase; - - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; - } - else { - regionbase = &sl->regionbase; - } - - - for ( ar = regionbase->first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_PREVIEW) - break; - } - - if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) { - SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ); - BKE_area_region_free(st, ar); - BLI_freelinkN(regionbase, ar); - } - } - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) { - { - /* fix for new view type in sequencer */ - bScreen *screen; - ScrArea *sa; - SpaceLink *sl; - - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { - ARegion *ar; - ARegion *ar_main; - ListBase *regionbase; - SpaceSeq *sseq = (SpaceSeq *)sl; - - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; - } - else { - regionbase = &sl->regionbase; - } - - if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE; - if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF; - - ar_main = (ARegion*)regionbase->first; - for (; ar_main; ar_main = ar_main->next) { - if (ar_main->regiontype == RGN_TYPE_WINDOW) - break; - } - ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); - BLI_insertlinkbefore(regionbase, ar_main, ar); - sequencer_init_preview_region(ar); - } - } - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) { - Scene *sce; - Object *ob; - Brush *brush; - Material *ma; - - /* game engine changes */ - for (sce = main->scene.first; sce; sce = sce->id.next) { - sce->gm.eyeseparation = 0.10f; - } - - /* anim viz changes */ - for (ob= main->object.first; ob; ob= ob->id.next) { - /* initialize object defaults */ - animviz_settings_init(&ob->avs); - - /* if armature, copy settings for pose from armature data - * performing initialization where appropriate - */ - if (ob->pose && ob->data) { - bArmature *arm= newlibadr(fd, lib, ob->data); - if (arm) { /* XXX - why does this fail in some cases? */ - bAnimVizSettings *avs= &ob->pose->avs; - - /* ghosting settings ---------------- */ - /* ranges */ - avs->ghost_bc= avs->ghost_ac= arm->ghostep; - - avs->ghost_sf= arm->ghostsf; - avs->ghost_ef= arm->ghostef; - if ((avs->ghost_sf == avs->ghost_ef) && (avs->ghost_sf == 0)) { - avs->ghost_sf= 1; - avs->ghost_ef= 100; - } - - /* type */ - if (arm->ghostep == 0) - avs->ghost_type= GHOST_TYPE_NONE; - else - avs->ghost_type= arm->ghosttype + 1; - - /* stepsize */ - avs->ghost_step= arm->ghostsize; - if (avs->ghost_step == 0) - avs->ghost_step= 1; - - /* path settings --------------------- */ - /* ranges */ - avs->path_bc= arm->pathbc; - avs->path_ac= arm->pathac; - if ((avs->path_bc == avs->path_ac) && (avs->path_bc == 0)) - avs->path_bc= avs->path_ac= 10; - - avs->path_sf= arm->pathsf; - avs->path_ef= arm->pathef; - if ((avs->path_sf == avs->path_ef) && (avs->path_sf == 0)) { - avs->path_sf= 1; - avs->path_ef= 250; - } - - /* flags */ - if (arm->pathflag & ARM_PATH_FNUMS) - avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS; - if (arm->pathflag & ARM_PATH_KFRAS) - avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS; - if (arm->pathflag & ARM_PATH_KFNOS) - avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS; - - /* bake flags */ - if (arm->pathflag & ARM_PATH_HEADS) - avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS; - - /* type */ - if (arm->pathflag & ARM_PATH_ACFRA) - avs->path_type = MOTIONPATH_TYPE_ACFRA; - - /* stepsize */ - avs->path_step= arm->pathsize; - if (avs->path_step == 0) - avs->path_step= 1; - } - else - animviz_settings_init(&ob->pose->avs); - } - } - - /* brush texture changes */ - for (brush= main->brush.first; brush; brush= brush->id.next) { - default_mtex(&brush->mtex); - } - - for (ma= main->mat.first; ma; ma= ma->id.next) { - if (ma->vol.ms_spread < 0.0001f) { - ma->vol.ms_spread = 0.2f; - ma->vol.ms_diff = 1.f; - ma->vol.ms_intensity = 1.f; - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) { - /* NOTE: if you do more conversion, be sure to do it outside of this and - * increase subversion again, otherwise it will not be correct */ - Object *ob; - - /* convert degrees to radians for internal use */ - for (ob=main->object.first; ob; ob=ob->id.next) { - bPoseChannel *pchan; - - do_version_constraints_radians_degrees_250(&ob->constraints); - - if (ob->pose) { - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { - pchan->limitmin[0] *= (float)(M_PI/180.0); - pchan->limitmin[1] *= (float)(M_PI/180.0); - pchan->limitmin[2] *= (float)(M_PI/180.0); - pchan->limitmax[0] *= (float)(M_PI/180.0); - pchan->limitmax[1] *= (float)(M_PI/180.0); - pchan->limitmax[2] *= (float)(M_PI/180.0); - - do_version_constraints_radians_degrees_250(&pchan->constraints); - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) { - /* fix for bad View2D extents for Animation Editors */ - bScreen *screen; - ScrArea *sa; - SpaceLink *sl; - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - ListBase *regionbase; - ARegion *ar; - - if (sl == sa->spacedata.first) - regionbase = &sa->regionbase; - else - regionbase = &sl->regionbase; - - if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) { - for (ar = (ARegion*)regionbase->first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f; - ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; - } - } - } - } - } - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) { - World *wo; - Material *ma; - - /* ambient default from 0.5f to 1.0f */ - for (ma= main->mat.first; ma; ma=ma->id.next) - ma->amb *= 2.0f; - - for (wo= main->world.first; wo; wo=wo->id.next) { - /* ao splitting into ao/env/indirect */ - wo->ao_env_energy= wo->aoenergy; - wo->aoenergy= 1.0f; - - if (wo->ao_indirect_bounces == 0) - wo->ao_indirect_bounces= 1; - else - wo->mode |= WO_INDIRECT_LIGHT; - - if (wo->aomix == WO_AOSUB) - wo->ao_env_energy= -wo->ao_env_energy; - else if (wo->aomix == WO_AOADDSUB) - wo->mode |= WO_AMB_OCC; - - wo->aomix= WO_AOMUL; - - /* ambient default from 0.5f to 1.0f */ - mul_v3_fl(&wo->ambr, 0.5f); - wo->ao_env_energy *= 0.5f; - } - } - - if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) { - Scene *sce; - Sequence *seq; - Material *ma; - - /* initialize to sane default so toggling on border shows something */ - for (sce = main->scene.first; sce; sce = sce->id.next) { - if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && - sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f) { - sce->r.border.xmin = 0.0f; - sce->r.border.ymin = 0.0f; - sce->r.border.xmax = 1.0f; - sce->r.border.ymax = 1.0f; - } - - if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) - sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE - - SEQ_BEGIN (sce->ed, seq) - { - seq->volume = 1.0f; - } - SEQ_END - } - - /* particle brush strength factor was changed from int to float */ - for (sce= main->scene.first; sce; sce=sce->id.next) { - ParticleEditSettings *pset= &sce->toolsettings->particle; - int a; - - for (a=0; abrush[a].strength /= 100.0f; - } - - for (ma = main->mat.first; ma; ma=ma->id.next) - if (ma->mode & MA_TRACEBLE) - ma->shade_flag |= MA_APPROX_OCCLUSION; - - /* sequencer changes */ - { - bScreen *screen; - ScrArea *sa; - SpaceLink *sl; - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { - ARegion *ar_preview; - ListBase *regionbase; - - if (sl == sa->spacedata.first) { - regionbase = &sa->regionbase; - } - else { - regionbase = &sl->regionbase; - } - - ar_preview = (ARegion*)regionbase->first; - for (; ar_preview; ar_preview = ar_preview->next) { - if (ar_preview->regiontype == RGN_TYPE_PREVIEW) - break; - } - if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) { - sequencer_init_preview_region(ar_preview); - } - } - } - } - } - } /* sequencer changes */ - } - - if (main->versionfile <= 251) { /* 2.5.1 had no subversions */ - bScreen *sc; - - /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE. - * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated. - * Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set, - * which would cause cameras, lamps, etc to become invisible */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D* v3d = (View3D *)sl; - v3d->flag2 &= ~V3D_RENDER_OVERRIDE; - } - } - } - } - } - - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) { - Brush *brush; - Object *ob; - Scene *scene; - bNodeTree *ntree; - - for (brush= main->brush.first; brush; brush= brush->id.next) { - if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH; - } - - /* properly initialize active flag for fluidsim modifiers */ - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { - if (md->type == eModifierType_Fluidsim) { - FluidsimModifierData *fmd = (FluidsimModifierData *)md; - fmd->fss->flag |= OB_FLUIDSIM_ACTIVE; - fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME; - } - } - } - - /* adjustment to color balance node values */ - for (scene= main->scene.first; scene; scene= scene->id.next) { - if (scene->nodetree) { - bNode *node=scene->nodetree->nodes.first; - - while (node) { - if (node->type == CMP_NODE_COLORBALANCE) { - NodeColorBalance *n= (NodeColorBalance *)node->storage; - n->lift[0] += 1.f; - n->lift[1] += 1.f; - n->lift[2] += 1.f; - } - node= node->next; - } - } - } - /* check inside node groups too */ - for (ntree= main->nodetree.first; ntree; ntree=ntree->id.next) { - bNode *node=ntree->nodes.first; - - while (node) { - if (node->type == CMP_NODE_COLORBALANCE) { - NodeColorBalance *n= (NodeColorBalance *)node->storage; - n->lift[0] += 1.f; - n->lift[1] += 1.f; - n->lift[2] += 1.f; - } - node= node->next; - } - } - } - - /* old-track -> constraints (this time we're really doing it!) */ - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) { - Object *ob; - - for (ob = main->object.first; ob; ob = ob->id.next) - do_version_old_trackto_to_constraints(ob); - } - - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { - bScreen *sc; - - /* Image editor scopes */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)sl; - scopes_new(&sima->scopes); - } - } - } - } - } - - - if (main->versionfile < 253) { - Object *ob; - Scene *scene; - bScreen *sc; - Tex *tex; - Brush *brush; - - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype == SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; - ListBase *regionbase; - ARegion *ar; - - if (sl == sa->spacedata.first) - regionbase = &sa->regionbase; - else - regionbase = &sl->regionbase; - - if (snode->v2d.minzoom > 0.09f) - snode->v2d.minzoom= 0.09f; - if (snode->v2d.maxzoom < 2.31f) - snode->v2d.maxzoom= 2.31f; - - for (ar= regionbase->first; ar; ar= ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - if (ar->v2d.minzoom > 0.09f) - ar->v2d.minzoom= 0.09f; - if (ar->v2d.maxzoom < 2.31f) - ar->v2d.maxzoom= 2.31f; - } - } - } - else if (sl->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)sl; - - /* enable all cache display */ - stime->cache_display |= TIME_CACHE_DISPLAY; - stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); - stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT); - } - } - } - } - - do_version_mdef_250(main); - - /* parent type to modifier */ - for (ob = main->object.first; ob; ob = ob->id.next) { - if (ob->parent) { - Object *parent= (Object *)newlibadr(fd, lib, ob->parent); - if (parent) { /* parent may not be in group */ - if (parent->type==OB_ARMATURE && ob->partype==PARSKEL) { - ArmatureModifierData *amd; - bArmature *arm= (bArmature *)newlibadr(fd, lib, parent->data); - - amd = (ArmatureModifierData*) modifier_new(eModifierType_Armature); - amd->object = ob->parent; - BLI_addtail((ListBase*)&ob->modifiers, amd); - amd->deformflag= arm->deformflag; - ob->partype = PAROBJECT; - } - else if (parent->type==OB_LATTICE && ob->partype==PARSKEL) { - LatticeModifierData *lmd; - - lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice); - lmd->object = ob->parent; - BLI_addtail((ListBase*)&ob->modifiers, lmd); - ob->partype = PAROBJECT; - } - else if (parent->type==OB_CURVE && ob->partype==PARCURVE) { - CurveModifierData *cmd; - - cmd = (CurveModifierData*) modifier_new(eModifierType_Curve); - cmd->object = ob->parent; - BLI_addtail((ListBase*)&ob->modifiers, cmd); - ob->partype = PAROBJECT; - } - } - } - } - - /* initialize scene active layer */ - for (scene= main->scene.first; scene; scene=scene->id.next) { - int i; - for (i=0; i<20; i++) { - if (scene->lay & (1<layact= 1<tex.first; tex; tex= tex->id.next) { - /* if youre picky, this isn't correct until we do a version bump - * since you could set saturation to be 0.0*/ - if (tex->saturation==0.0f) - tex->saturation= 1.0f; - } - - { - Curve *cu; - for (cu= main->curve.first; cu; cu= cu->id.next) { - cu->smallcaps_scale= 0.75f; - } - } - - for (scene= main->scene.first; scene; scene=scene->id.next) { - if (scene) { - Sequence *seq; - SEQ_BEGIN (scene->ed, seq) - { - if (seq->sat==0.0f) { - seq->sat= 1.0f; - } - } - SEQ_END - } - } - - /* GSOC 2010 Sculpt - New settings for Brush */ - - for (brush= main->brush.first; brush; brush= brush->id.next) { - /* Sanity Check */ - - // infinite number of dabs - if (brush->spacing == 0) - brush->spacing = 10; - - // will have no effect - if (brush->alpha == 0) - brush->alpha = 0.5f; - - // bad radius - if (brush->unprojected_radius == 0) - brush->unprojected_radius = 0.125f; - - // unusable size - if (brush->size == 0) - brush->size = 35; - - // can't see overlay - if (brush->texture_overlay_alpha == 0) - brush->texture_overlay_alpha = 33; - - // same as draw brush - if (brush->crease_pinch_factor == 0) - brush->crease_pinch_factor = 0.5f; - - // will sculpt no vertexes - if (brush->plane_trim == 0) - brush->plane_trim = 0.5f; - - // same as smooth stroke off - if (brush->smooth_stroke_radius == 0) - brush->smooth_stroke_radius= 75; - - // will keep cursor in one spot - if (brush->smooth_stroke_radius == 1) - brush->smooth_stroke_factor= 0.9f; - - // same as dots - if (brush->rate == 0) - brush->rate = 0.1f; - - /* New Settings */ - if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { - brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space - - // spacing was originally in pixels, convert it to percentage for new version - // size should not be zero due to sanity check above - brush->spacing = (int)(100*((float)brush->spacing) / ((float)brush->size)); - - if (brush->add_col[0] == 0 && - brush->add_col[1] == 0 && - brush->add_col[2] == 0) - { - brush->add_col[0] = 1.00f; - brush->add_col[1] = 0.39f; - brush->add_col[2] = 0.39f; - } - - if (brush->sub_col[0] == 0 && - brush->sub_col[1] == 0 && - brush->sub_col[2] == 0) - { - brush->sub_col[0] = 0.39f; - brush->sub_col[1] = 0.39f; - brush->sub_col[2] = 1.00f; - } - } - } - } - - /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */ - if (main->versionfile < 253) { - Scene *sce; - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->toolsettings->sculpt_paint_unified_alpha == 0) - sce->toolsettings->sculpt_paint_unified_alpha = 0.5f; - - if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) - sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f; - - if (sce->toolsettings->sculpt_paint_unified_size == 0) - sce->toolsettings->sculpt_paint_unified_size = 35; - } - } - - if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) { - Object *ob; - - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { - if (md->type == eModifierType_Smoke) { - SmokeModifierData *smd = (SmokeModifierData *)md; - - if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - smd->domain->vorticity = 2.0f; - smd->domain->time_scale = 1.0f; - - if (!(smd->domain->flags & (1<<4))) - continue; - - /* delete old MOD_SMOKE_INITVELOCITY flag */ - smd->domain->flags &= ~(1<<4); - - /* for now just add it to all flow objects in the scene */ - { - Object *ob2; - for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) { - ModifierData *md2; - for (md2= ob2->modifiers.first; md2; md2= md2->next) { - if (md2->type == eModifierType_Smoke) { - SmokeModifierData *smd2 = (SmokeModifierData *)md2; - - if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { - smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY; - } - } - } - } - } - - } - else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) { - smd->flow->vel_multi = 1.0f; - } - - } - } - } - } - - if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) { - Brush *br; - ParticleSettings *part; - bScreen *sc; - Object *ob; - - for (br= main->brush.first; br; br= br->id.next) { - if (br->ob_mode==0) - br->ob_mode= OB_MODE_ALL_PAINT; - } - - for (part = main->particle.first; part; part = part->id.next) { - if (part->boids) - part->boids->pitch = 1.0f; - - part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */ - part->kink_amp_clump = 1.f; /* keep old files looking similar */ - } - - for (sc= main->screen.first; sc; sc= sc->id.next) { - ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype == SPACE_INFO) { - SpaceInfo *sinfo= (SpaceInfo *)sl; - ARegion *ar; - - sinfo->rpt_mask= INFO_RPT_OP; - - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - ar->v2d.scroll = (V2D_SCROLL_RIGHT); - ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ - ar->v2d.keepofs = V2D_LOCKOFS_X; - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; - } - } - } - } - } - } - - /* fix rotation actuators for objects so they use real angles (radians) - * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */ - for (ob= main->object.first; ob; ob= ob->id.next) { - bActuator *act= ob->actuators.first; - while (act) { - if (act->type==ACT_OBJECT) { - /* multiply velocity with 50 in old files */ - bObjectActuator *oa= act->data; - mul_v3_fl(oa->drot, 0.8726646259971648f); - } - act= act->next; - } - } - } - - // init facing axis property of steering actuators - { - Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { - bActuator *act; - for (act= ob->actuators.first; act; act= act->next) { - if (act->type==ACT_STEERING) { - bSteeringActuator* stact = act->data; - if (stact->facingaxis==0) { - stact->facingaxis=1; - } - } - } - } - } - - if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) { - Object *ob; - - /* ocean res is now squared, reset old ones - will be massive */ - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { - if (md->type == eModifierType_Ocean) { - OceanModifierData *omd = (OceanModifierData *)md; - omd->resolution = 7; - omd->oceancache = NULL; - } - } - } - } - - if (main->versionfile < 256) { - bScreen *sc; - ScrArea *sa; - Key *key; - - /* Fix for sample line scope initializing with no height */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - sa= sc->areabase.first; - while (sa) { - SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; - if (sima->sample_line_hist.height == 0 ) - sima->sample_line_hist.height = 100; - } - } - sa= sa->next; - } - } - - /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in - * 2.4x would never reveal this to users as a dummy value always ended up getting used - * instead - */ - for (key = main->key.first; key; key = key->id.next) { - KeyBlock *kb; - - for (kb = key->block.first; kb; kb = kb->next) { - if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) - kb->slidermax = kb->slidermin + 1.0f; - } - } - } - - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) { - /* fix for bones that didn't have arm_roll before */ - bArmature* arm; - Bone* bone; - Object *ob; - - for (arm = main->armature.first; arm; arm = arm->id.next) - for (bone = arm->bonebase.first; bone; bone = bone->next) - do_version_bone_roll_256(bone); - - /* fix for objects which have zero dquat's - * since this is multiplied with the quat rather than added */ - for (ob= main->object.first; ob; ob= ob->id.next) { - if (is_zero_v4(ob->dquat)) { - unit_qt(ob->dquat); - } - if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) { - unit_axis_angle(ob->drotAxis, &ob->drotAngle); - } - } - } - - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { - bNodeTree *ntree; - - /* node sockets are not exposed automatically any more, - * this mimics the old behavior by adding all unlinked sockets to groups. - */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { - /* XXX Only setting a flag here. Actual adding of group sockets - * is done in lib_verify_nodetree, because at this point the internal - * nodes may not be up-to-date! (missing lib-link) - */ - ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE; - } - } - - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)) { - bScreen *sc; - Brush *brush; - Object *ob; - ParticleSettings *part; - Material *mat; - int tex_nr, transp_tex; - - for (mat = main->mat.first; mat; mat = mat->id.next) { - if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) { - - transp_tex= 0; - - for (tex_nr=0; tex_nrmtex[tex_nr]) continue; - if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) transp_tex= 1; - } - - /* weak! material alpha could be animated */ - if (mat->alpha < 1.0f || mat->fresnel_tra > 0.0f || transp_tex) { - mat->mode |= MA_TRANSP; - mat->mode &= ~(MA_ZTRANSP|MA_RAYTRANSP); - } - } - } - - /* redraws flag in SpaceTime has been moved to Screen level */ - for (sc = main->screen.first; sc; sc= sc->id.next) { - if (sc->redraws_flag == 0) { - /* just initialize to default? */ - // XXX: we could also have iterated through areas, and taken them from the first timeline available... - sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; - } - } - - for (brush= main->brush.first; brush; brush= brush->id.next) { - if (brush->height == 0) - brush->height= 0.4f; - } - - /* replace 'rim material' option for in offset*/ - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { - if (md->type == eModifierType_Solidify) { - SolidifyModifierData *smd = (SolidifyModifierData *)md; - if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) { - smd->mat_ofs_rim= 1; - smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL; - } - } - } - } - - /* particle draw color from material */ - for (part = main->particle.first; part; part = part->id.next) { - if (part->draw & PART_DRAW_MAT_COL) - part->draw_col = PART_DRAW_COL_MAT; - } - } - - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) { - Mesh *me; - - for (me= main->mesh.first; me; me= me->id.next) - mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); - } - - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { - /* update blur area sizes from 0..1 range to 0..100 percentage */ - Scene *scene; - bNode *node; - for (scene=main->scene.first; scene; scene=scene->id.next) - if (scene->nodetree) - for (node=scene->nodetree->nodes.first; node; node=node->next) - if (node->type==CMP_NODE_BLUR) { - NodeBlurData *nbd= node->storage; - nbd->percentx *= 100.0f; - nbd->percenty *= 100.0f; - } - } - - if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)) { - /* screen view2d settings were not properly initialized [#27164] - * v2d->scroll caused the bug but best reset other values too which are in old blend files only. - * need to make less ugly - possibly an iterator? */ - bScreen *screen; - for (screen= main->screen.first; screen; screen= screen->id.next) { - ScrArea *sa; - /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - SpaceLink *sl= sa->spacedata.first; - if (sl->spacetype==SPACE_IMAGE) { - ARegion *ar; - for (ar=sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - View2D *v2d= &ar->v2d; - v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; - } - } - } - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) { - ARegion *ar; - for (ar=sl->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - View2D *v2d= &ar->v2d; - v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; - } - } - } - } - } - } - - { - /* Initialize texture point density curve falloff */ - Tex *tex; - for (tex= main->tex.first; tex; tex= tex->id.next) { - if (tex->pd) { - if (tex->pd->falloff_speed_scale == 0.0f) - tex->pd->falloff_speed_scale = 100.0f; - - if (!tex->pd->falloff_curve) { - tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); - - tex->pd->falloff_curve->preset = CURVE_PRESET_LINE; - tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); - curvemapping_changed(tex->pd->falloff_curve, 0); - } - } - } - } - - { - /* add default value for behind strength of camera actuator */ - Object *ob; - bActuator *act; - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_CAMERA) { - bCameraActuator *ba= act->data; - - ba->damping = 1.0/32.0; - } - } - } - } - - { - ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { - /* Initialize particle billboard scale */ - part->bb_size[0] = part->bb_size[1] = 1.0f; - } - } - } - - if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)) { - { - Scene *scene; - Sequence *seq; - - for (scene=main->scene.first; scene; scene=scene->id.next) { - scene->r.ffcodecdata.audio_channels = 2; - scene->audio.volume = 1.0f; - SEQ_BEGIN (scene->ed, seq) - { - seq->pitch = 1.0f; - } - SEQ_END - } - } - { - bScreen *screen; - for (screen= main->screen.first; screen; screen= screen->id.next) { - ScrArea *sa; - /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - SpaceLink *sl= sa->spacedata.first; - if (sl->spacetype==SPACE_SEQ) { - ARegion *ar; - for (ar=sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - if (ar->v2d.min[1] == 4.0f) - ar->v2d.min[1]= 0.5f; - } - } - } - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { - ARegion *ar; - for (ar=sl->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - if (ar->v2d.min[1] == 4.0f) - ar->v2d.min[1]= 0.5f; - } - } - } - } - } - } - } - { - /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve - * - * We're only patching F-Curves in Actions here, since it is assumed that most - * drivers out there won't be using this (and if they are, they're in the minority). - * While we should aim to fix everything ideally, in practice it's far too hard - * to get to every animdata block, not to mention the performance hit that'd have - */ - bAction *act; - FCurve *fcu; - - for (act = main->action.first; act; act = act->id.next) { - for (fcu = act->curves.first; fcu; fcu = fcu->next) { - BezTriple *bezt; - unsigned int i = 0; - - /* only need to touch curves that had this flag set */ - if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) - continue; - if ((fcu->totvert == 0) || (fcu->bezt == NULL)) - continue; - - /* only change auto-handles to auto-clamped */ - for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { - if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM; - if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM; - } - - fcu->flag &= ~FCURVE_AUTO_HANDLES; - } - } - } - { - /* convert fcurve and shape action actuators to action actuators */ - Object *ob; - bActuator *act; - bIpoActuator *ia; - bActionActuator *aa; - - for (ob= main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_IPO) { - // Create the new actuator - ia= act->data; - aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); - - // Copy values - aa->type = ia->type; - aa->flag = ia->flag; - aa->sta = ia->sta; - aa->end = ia->end; - BLI_strncpy(aa->name, ia->name, sizeof(aa->name)); - BLI_strncpy(aa->frameProp, ia->frameProp, sizeof(aa->frameProp)); - if (ob->adt) - aa->act = ob->adt->action; - - // Get rid of the old actuator - MEM_freeN(ia); - - // Assign the new actuator - act->data = aa; - act->type= act->otype= ACT_ACTION; - - } - else if (act->type == ACT_SHAPEACTION) { - act->type = act->otype = ACT_ACTION; - } - } - } - } - } - - if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) { - { - /* Convert default socket values from bNodeStack */ - Scene *sce; - Material *mat; - Tex *tex; - bNodeTree *ntree; - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { - do_versions_nodetree_default_value(ntree); - ntree->update |= NTREE_UPDATE; - } - for (sce=main->scene.first; sce; sce=sce->id.next) - if (sce->nodetree) { - do_versions_nodetree_default_value(sce->nodetree); - sce->nodetree->update |= NTREE_UPDATE; - } - for (mat=main->mat.first; mat; mat=mat->id.next) - if (mat->nodetree) { - do_versions_nodetree_default_value(mat->nodetree); - mat->nodetree->update |= NTREE_UPDATE; - } - for (tex=main->tex.first; tex; tex=tex->id.next) - if (tex->nodetree) { - do_versions_nodetree_default_value(tex->nodetree); - tex->nodetree->update |= NTREE_UPDATE; - } - } - - /* add SOCK_DYNAMIC flag to existing group sockets */ - { - bNodeTree *ntree; - /* only need to do this for trees in main, local trees are not used as groups */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { - do_versions_nodetree_dynamic_sockets(ntree); - ntree->update |= NTREE_UPDATE; - } - } - - { - /* Initialize group tree nodetypes. - * These are used to distinguish tree types and - * associate them with specific node types for polling. - */ - bNodeTree *ntree; - /* all node trees in main->nodetree are considered groups */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) - ntree->nodetype = NODE_GROUP; - } - } - - if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 4)) { - { - /* Adaptive time step for particle systems */ - ParticleSettings *part; - for (part = main->particle.first; part; part = part->id.next) { - part->courant_target = 0.2f; - part->time_flag &= ~PART_TIME_AUTOSF; - } - } - - { - /* set defaults for obstacle avoidance, recast data */ - Scene *sce; - for (sce = main->scene.first; sce; sce = sce->id.next) { - if (sce->gm.levelHeight == 0.f) - sce->gm.levelHeight = 2.f; - - if (sce->gm.recastData.cellsize == 0.0f) - sce->gm.recastData.cellsize = 0.3f; - if (sce->gm.recastData.cellheight == 0.0f) - sce->gm.recastData.cellheight = 0.2f; - if (sce->gm.recastData.agentmaxslope == 0.0f) - sce->gm.recastData.agentmaxslope = (float)M_PI/4; - if (sce->gm.recastData.agentmaxclimb == 0.0f) - sce->gm.recastData.agentmaxclimb = 0.9f; - if (sce->gm.recastData.agentheight == 0.0f) - sce->gm.recastData.agentheight = 2.0f; - if (sce->gm.recastData.agentradius == 0.0f) - sce->gm.recastData.agentradius = 0.6f; - if (sce->gm.recastData.edgemaxlen == 0.0f) - sce->gm.recastData.edgemaxlen = 12.0f; - if (sce->gm.recastData.edgemaxerror == 0.0f) - sce->gm.recastData.edgemaxerror = 1.3f; - if (sce->gm.recastData.regionminsize == 0.0f) - sce->gm.recastData.regionminsize = 8.f; - if (sce->gm.recastData.regionmergesize == 0.0f) - sce->gm.recastData.regionmergesize = 20.f; - if (sce->gm.recastData.vertsperpoly<3) - sce->gm.recastData.vertsperpoly = 6; - if (sce->gm.recastData.detailsampledist == 0.0f) - sce->gm.recastData.detailsampledist = 6.0f; - if (sce->gm.recastData.detailsamplemaxerror == 0.0f) - sce->gm.recastData.detailsamplemaxerror = 1.0f; - } - } - } + blo_do_versions_pre250(fd, lib, main); + blo_do_versions_250(fd, lib, main); if (main->versionfile < 260) { { @@ -14185,7 +8214,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, ob->mat[a]); } - paf = do_version_give_parteff_245(ob); + paf = blo_do_version_give_parteff_245(ob); if (paf && paf->group) expand_doit(fd, mainvar, paf->group); diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 511ded0ecdc..9be375977e9 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -39,6 +39,10 @@ struct OldNewMap; struct MemFile; struct bheadsort; struct ReportList; +struct Object; +struct PartEff; +struct View3D; +struct bNodeTree; typedef struct FileData { // linked list of BHeadN's @@ -133,5 +137,19 @@ BHead *blo_prevbhead(FileData *fd, BHead *thisblock); char *bhead_id_name(FileData *fd, BHead *bhead); +/* do versions stuff */ + +void blo_do_versions_oldnewmap_insert(struct OldNewMap *onm, void *oldaddr, void *newaddr, int nr); +void *blo_do_versions_newlibadr(struct FileData *fd, void *lib, void *adr); +void *blo_do_versions_newlibadr_us(struct FileData *fd, void *lib, void *adr); + +struct PartEff *blo_do_version_give_parteff_245(struct Object *ob); +void blo_do_version_old_trackto_to_constraints(struct Object *ob); +void blo_do_versions_view3d_split_250(struct View3D *v3d, struct ListBase *regions); +void blo_do_versions_nodetree_default_value(struct bNodeTree *ntree); + +void blo_do_versions_pre250(struct FileData *fd, struct Library *lib, struct Main *main); +void blo_do_versions_250(struct FileData *fd, struct Library *lib, struct Main *main); + #endif diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c new file mode 100644 index 00000000000..c6bab33f364 --- /dev/null +++ b/source/blender/blenloader/intern/versioning_250.c @@ -0,0 +1,2677 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/blenloader/intern/readfile_250.c + * \ingroup blenloader + */ + +#ifndef WIN32 +# include // for read close +#else +# include // for open close read +# include "winsock2.h" +# include "BLI_winstuff.h" +#endif + +/* allow readfile to use deprecated functionality */ +#define DNA_DEPRECATED_ALLOW + +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_actuator_types.h" +#include "DNA_brush_types.h" +#include "DNA_camera_types.h" +#include "DNA_cloth_types.h" +#include "DNA_constraint_types.h" +#include "DNA_ipo_types.h" +#include "DNA_key_types.h" +#include "DNA_lattice_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_node_types.h" +#include "DNA_object_fluidsim.h" // NT +#include "DNA_object_types.h" +#include "DNA_view3d_types.h" +#include "DNA_screen_types.h" +#include "DNA_sdna_types.h" +#include "DNA_sequence_types.h" +#include "DNA_smoke_types.h" +#include "DNA_sound_types.h" +#include "DNA_space_types.h" +#include "DNA_world_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_edgehash.h" + +#include "BKE_anim.h" +#include "BKE_armature.h" +#include "BKE_colortools.h" +#include "BKE_global.h" // for G +#include "BKE_library.h" // for which_libbase +#include "BKE_main.h" // for Main +#include "BKE_mesh.h" // for ME_ defines (patching) +#include "BKE_modifier.h" +#include "BKE_multires.h" +#include "BKE_particle.h" +#include "BKE_pointcache.h" +#include "BKE_screen.h" +#include "BKE_sequencer.h" +#include "BKE_texture.h" // for open_plugin_tex +#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND +#include "BKE_sound.h" + +#include "NOD_socket.h" + +//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes +//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie +//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo +#include "BLO_readfile.h" +#include "BLO_undofile.h" + +#include "RE_engine.h" + +#include "readfile.h" + +#include "PIL_time.h" + +#include + +/* 2.50 patch */ +static void area_add_header_region(ScrArea *sa, ListBase *lb) +{ + ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_HEADER; + if (sa->headertype==HEADERDOWN) + ar->alignment= RGN_ALIGN_BOTTOM; + else + ar->alignment= RGN_ALIGN_TOP; + + /* initialize view2d data for header region, to allow panning */ + /* is copy from ui_view2d.c */ + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); + ar->v2d.keepofs = V2D_LOCKOFS_Y; + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; + ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); +} + +static void sequencer_init_preview_region(ARegion* ar) +{ + // XXX a bit ugly still, copied from space_sequencer + /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */ + ar->regiontype= RGN_TYPE_PREVIEW; + ar->alignment= RGN_ALIGN_TOP; + ar->flag |= RGN_FLAG_HIDDEN; + ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM; + ar->v2d.minzoom= 0.00001f; + ar->v2d.maxzoom= 100000.0f; + ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */ + ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */ + ar->v2d.tot.xmax = 960.0f; + ar->v2d.tot.ymax = 540.0f; + ar->v2d.min[0]= 0.0f; + ar->v2d.min[1]= 0.0f; + ar->v2d.max[0]= 12000.0f; + ar->v2d.max[1]= 12000.0f; + ar->v2d.cur= ar->v2d.tot; + ar->v2d.align= V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y); + ar->v2d.keeptot= V2D_KEEPTOT_FREE; +} + +static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) +{ + ARegion *ar; + ARegion *ar_main; + + if (sl) { + /* first channels for ipo action nla... */ + switch (sl->spacetype) { + case SPACE_IPO: + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_CHANNELS; + ar->alignment= RGN_ALIGN_LEFT; + ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + + // for some reason, this doesn't seem to go auto like for NLA... + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_RIGHT; + ar->v2d.scroll= V2D_SCROLL_RIGHT; + ar->v2d.flag = RGN_FLAG_HIDDEN; + break; + + case SPACE_ACTION: + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_CHANNELS; + ar->alignment= RGN_ALIGN_LEFT; + ar->v2d.scroll= V2D_SCROLL_BOTTOM; + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + break; + + case SPACE_NLA: + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_CHANNELS; + ar->alignment= RGN_ALIGN_LEFT; + ar->v2d.scroll= V2D_SCROLL_BOTTOM; + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + + // for some reason, some files still don't get this auto + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_RIGHT; + ar->v2d.scroll= V2D_SCROLL_RIGHT; + ar->v2d.flag = RGN_FLAG_HIDDEN; + break; + + case SPACE_NODE: + ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_LEFT; + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + /* temporarily hide it */ + ar->flag = RGN_FLAG_HIDDEN; + break; + case SPACE_FILE: + ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_CHANNELS; + ar->alignment= RGN_ALIGN_LEFT; + + ar= MEM_callocN(sizeof(ARegion), "ui area for file"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_TOP; + break; + case SPACE_SEQ: + ar_main = (ARegion*)lb->first; + for (; ar_main; ar_main = ar_main->next) { + if (ar_main->regiontype == RGN_TYPE_WINDOW) + break; + } + ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); + BLI_insertlinkbefore(lb, ar_main, ar); + sequencer_init_preview_region(ar); + break; + case SPACE_VIEW3D: + /* toolbar */ + ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d"); + + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_TOOLS; + ar->alignment= RGN_ALIGN_LEFT; + ar->flag = RGN_FLAG_HIDDEN; + + /* tool properties */ + ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d"); + + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_TOOL_PROPS; + ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->flag = RGN_FLAG_HIDDEN; + + /* buttons/list view */ + ar= MEM_callocN(sizeof(ARegion), "buttons for view3d"); + + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_RIGHT; + ar->flag = RGN_FLAG_HIDDEN; +#if 0 + case SPACE_BUTS: + /* context UI region */ + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_RIGHT; + + break; +#endif + } + } + + /* main region */ + ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + + BLI_addtail(lb, ar); + ar->winrct= sa->totrct; + + ar->regiontype= RGN_TYPE_WINDOW; + + if (sl) { + /* if active spacetype has view2d data, copy that over to main region */ + /* and we split view3d */ + switch (sl->spacetype) { + case SPACE_VIEW3D: + blo_do_versions_view3d_split_250((View3D *)sl, lb); + break; + + case SPACE_OUTLINER: + { + SpaceOops *soops= (SpaceOops *)sl; + + memcpy(&ar->v2d, &soops->v2d, sizeof(View2D)); + + ar->v2d.scroll &= ~V2D_SCROLL_LEFT; + ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + //ar->v2d.flag |= V2D_IS_INITIALISED; + } + break; + case SPACE_TIME: + { + SpaceTime *stime= (SpaceTime *)sl; + memcpy(&ar->v2d, &stime->v2d, sizeof(View2D)); + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; + ar->v2d.keepofs |= V2D_LOCKOFS_Y; + ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; + ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0; + ar->v2d.min[1]= ar->v2d.max[1]= 20.0; + } + break; + case SPACE_IPO: + { + SpaceIpo *sipo= (SpaceIpo *)sl; + memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D)); + + /* init mainarea view2d */ + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + + ar->v2d.min[0]= FLT_MIN; + ar->v2d.min[1]= FLT_MIN; + + ar->v2d.max[0]= MAXFRAMEF; + ar->v2d.max[1]= FLT_MAX; + + //ar->v2d.flag |= V2D_IS_INITIALISED; + break; + } + case SPACE_NLA: + { + SpaceNla *snla= (SpaceNla *)sl; + memcpy(&ar->v2d, &snla->v2d, sizeof(View2D)); + + ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymax = 0.0f; + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.align = V2D_ALIGN_NO_POS_Y; + ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; + break; + } + case SPACE_ACTION: + { + SpaceAction *saction= (SpaceAction *)sl; + + /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */ + ar->v2d.tot.xmin = -20.0f; + ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.xmax = (float)((sa->winx > 120)? (sa->winx) : 120); + ar->v2d.tot.ymax = 0.0f; + + ar->v2d.cur= ar->v2d.tot; + + ar->v2d.min[0]= 0.0f; + ar->v2d.min[1]= 0.0f; + + ar->v2d.max[0]= MAXFRAMEF; + ar->v2d.max[1]= FLT_MAX; + + ar->v2d.minzoom= 0.01f; + ar->v2d.maxzoom= 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.keepzoom= V2D_LOCKZOOM_Y; + ar->v2d.align= V2D_ALIGN_NO_POS_Y; + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + + /* for old files with ShapeKey editors open + an action set, clear the action as + * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit + * only shows ShapeKey-rooted actions only) + */ + if (saction->mode == SACTCONT_SHAPEKEY) + saction->action = NULL; + break; + } + case SPACE_SEQ: + { + SpaceSeq *sseq= (SpaceSeq *)sl; + memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D)); + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.align= V2D_ALIGN_NO_NEG_Y; + ar->v2d.flag |= V2D_IS_INITIALISED; + break; + } + case SPACE_NODE: + { + SpaceNode *snode= (SpaceNode *)sl; + memcpy(&ar->v2d, &snode->v2d, sizeof(View2D)); + + ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; + break; + } + case SPACE_BUTS: + { + SpaceButs *sbuts= (SpaceButs *)sl; + memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D)); + + ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + break; + } + case SPACE_FILE: + { + // SpaceFile *sfile= (SpaceFile *)sl; + ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0; + ar->v2d.tot.xmax = ar->winx; + ar->v2d.tot.ymax = ar->winy; + ar->v2d.cur = ar->v2d.tot; + ar->regiontype= RGN_TYPE_WINDOW; + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); + break; + } + case SPACE_TEXT: + { + SpaceText *st= (SpaceText *)sl; + st->flags |= ST_FIND_WRAP; + } + //case SPACE_XXX: // FIXME... add other ones + // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D)); + // break; + } + } +} + +static void do_versions_windowmanager_2_50(bScreen *screen) +{ + ScrArea *sa; + SpaceLink *sl; + + /* add regions */ + for (sa= screen->areabase.first; sa; sa= sa->next) { + + /* we keep headertype variable to convert old files only */ + if (sa->headertype) + area_add_header_region(sa, &sa->regionbase); + + area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase); + + /* space imageselect is deprecated */ + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_IMASEL) + sl->spacetype= SPACE_EMPTY; /* spacedata then matches */ + } + + /* space sound is deprecated */ + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_SOUND) + sl->spacetype= SPACE_EMPTY; /* spacedata then matches */ + } + + /* it seems to be possible in 2.5 to have this saved, filewindow probably */ + sa->butspacetype= sa->spacetype; + + /* pushed back spaces also need regions! */ + if (sa->spacedata.first) { + sl= sa->spacedata.first; + for (sl= sl->next; sl; sl= sl->next) { + if (sa->headertype) + area_add_header_region(sa, &sl->regionbase); + area_add_window_regions(sa, sl, &sl->regionbase); + } + } + } +} + +static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name) +{ + + BLI_addtail(lb, id); + id->us= 1; + id->flag= LIB_FAKEUSER; + *( (short *)id->name )= ID_GD; + + new_id(lb, id, name); + /* alphabetic insterion: is in new_id */ + + if (G.debug & G_DEBUG) + printf("Converted GPencil to ID: %s\n", id->name+2); +} + +static void do_versions_gpencil_2_50(Main *main, bScreen *screen) +{ + ScrArea *sa; + SpaceLink *sl; + + /* add regions */ + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D*) sl; + if (v3d->gpd) { + versions_gpencil_add_main(&main->gpencil, (ID *)v3d->gpd, "GPencil View3D"); + v3d->gpd= NULL; + } + } + else if (sl->spacetype==SPACE_NODE) { + SpaceNode *snode= (SpaceNode *)sl; + if (snode->gpd) { + versions_gpencil_add_main(&main->gpencil, (ID *)snode->gpd, "GPencil Node"); + snode->gpd= NULL; + } + } + else if (sl->spacetype==SPACE_SEQ) { + SpaceSeq *sseq= (SpaceSeq *)sl; + if (sseq->gpd) { + versions_gpencil_add_main(&main->gpencil, (ID *)sseq->gpd, "GPencil Node"); + sseq->gpd= NULL; + } + } + else if (sl->spacetype==SPACE_IMAGE) { + SpaceImage *sima= (SpaceImage *)sl; +#if 0 /* see comment on r28002 */ + if (sima->gpd) { + versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image"); + sima->gpd= NULL; + } +#else + sima->gpd= NULL; +#endif + } + } + } +} + +static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) +{ + MTex *mtex; + float varfac, colfac; + int a, neg; + + if (!mtex_array) + return; + + for (a=0; amaptoneg; + varfac= mtex->varfac; + colfac= mtex->colfac; + + if (neg & MAP_DISP) mtex->dispfac= -mtex->dispfac; + if (neg & MAP_NORM) mtex->norfac= -mtex->norfac; + if (neg & MAP_WARP) mtex->warpfac= -mtex->warpfac; + + mtex->colspecfac= (neg & MAP_COLSPEC)? -colfac: colfac; + mtex->mirrfac= (neg & MAP_COLMIR)? -colfac: colfac; + mtex->alphafac= (neg & MAP_ALPHA)? -varfac: varfac; + mtex->difffac= (neg & MAP_REF)? -varfac: varfac; + mtex->specfac= (neg & MAP_SPEC)? -varfac: varfac; + mtex->emitfac= (neg & MAP_EMIT)? -varfac: varfac; + mtex->hardfac= (neg & MAP_HAR)? -varfac: varfac; + mtex->raymirrfac= (neg & MAP_RAYMIRR)? -varfac: varfac; + mtex->translfac= (neg & MAP_TRANSLU)? -varfac: varfac; + mtex->ambfac= (neg & MAP_AMB)? -varfac: varfac; + mtex->colemitfac= (neg & MAP_EMISSION_COL)? -colfac: colfac; + mtex->colreflfac= (neg & MAP_REFLECTION_COL)? -colfac: colfac; + mtex->coltransfac= (neg & MAP_TRANSMISSION_COL)? -colfac: colfac; + mtex->densfac= (neg & MAP_DENSITY)? -varfac: varfac; + mtex->scatterfac= (neg & MAP_SCATTERING)? -varfac: varfac; + mtex->reflfac= (neg & MAP_REFLECTION)? -varfac: varfac; + + mtex->timefac= (neg & MAP_PA_TIME)? -varfac: varfac; + mtex->lengthfac= (neg & MAP_PA_LENGTH)? -varfac: varfac; + mtex->clumpfac= (neg & MAP_PA_CLUMP)? -varfac: varfac; + mtex->kinkfac= (neg & MAP_PA_KINK)? -varfac: varfac; + mtex->roughfac= (neg & MAP_PA_ROUGH)? -varfac: varfac; + mtex->padensfac= (neg & MAP_PA_DENS)? -varfac: varfac; + mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac; + mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac; + mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac; + + mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac; + + mtex->zenupfac= (neg & WOMAP_ZENUP)? -colfac: colfac; + mtex->zendownfac= (neg & WOMAP_ZENDOWN)? -colfac: colfac; + mtex->blendfac= (neg & WOMAP_BLEND)? -varfac: varfac; + + if (idtype == ID_MA) + mtex->colfac= (neg & MAP_COL)? -colfac: colfac; + else if (idtype == ID_LA) + mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac; + else if (idtype == ID_WO) + mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac; + } + } +} + +static void do_version_mdef_250(Main *main) +{ + Object *ob; + ModifierData *md; + MeshDeformModifierData *mmd; + + for (ob= main->object.first; ob; ob=ob->id.next) { + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type == eModifierType_MeshDeform) { + mmd= (MeshDeformModifierData*)md; + + if (mmd->bindcos) { + /* make bindcos NULL in order to trick older versions + * into thinking that the mesh was not bound yet */ + mmd->bindcagecos= mmd->bindcos; + mmd->bindcos= NULL; + + modifier_mdef_compact_influences(md); + } + } + } + } +} + +static void do_version_constraints_radians_degrees_250(ListBase *lb) +{ + bConstraint *con; + + for (con=lb->first; con; con=con->next) { + if (con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) { + bRigidBodyJointConstraint *data = con->data; + data->axX *= (float)(M_PI/180.0); + data->axY *= (float)(M_PI/180.0); + data->axZ *= (float)(M_PI/180.0); + } + else if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = con->data; + data->poleangle *= (float)(M_PI/180.0); + } + else if (con->type==CONSTRAINT_TYPE_ROTLIMIT) { + bRotLimitConstraint *data = con->data; + + data->xmin *= (float)(M_PI/180.0); + data->xmax *= (float)(M_PI/180.0); + data->ymin *= (float)(M_PI/180.0); + data->ymax *= (float)(M_PI/180.0); + data->zmin *= (float)(M_PI/180.0); + data->zmax *= (float)(M_PI/180.0); + } + } +} + +/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */ +static void do_versions_seq_unique_name_all_strips( + Scene * sce, ListBase *seqbasep) +{ + Sequence * seq = seqbasep->first; + + while (seq) { + seqbase_unique_name_recursive(&sce->ed->seqbase, seq); + if (seq->seqbase.first) { + do_versions_seq_unique_name_all_strips( + sce, &seq->seqbase); + } + seq=seq->next; + } +} + +static void do_version_bone_roll_256(Bone *bone) +{ + Bone *child; + float submat[3][3]; + + copy_m3_m4(submat, bone->arm_mat); + mat3_to_vec_roll(submat, NULL, &bone->arm_roll); + + for (child = bone->childbase.first; child; child = child->next) + do_version_bone_roll_256(child); +} + +static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree) +{ + bNodeSocket *sock; + for (sock=ntree->inputs.first; sock; sock=sock->next) + sock->flag |= SOCK_DYNAMIC; + for (sock=ntree->outputs.first; sock; sock=sock->next) + sock->flag |= SOCK_DYNAMIC; +} + +void blo_do_versions_250(FileData *fd, Library *lib, Main *main) +{ + /* WATCH IT!!!: pointers from libdata have not been converted */ + + if (G.debug & G_DEBUG) + printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); + + if (main->versionfile < 250) { + bScreen *screen; + Scene *scene; + Base *base; + Material *ma; + Camera *cam; + Mesh *me; + Curve *cu; + Scene *sce; + Tex *tx; + ParticleSettings *part; + Object *ob; + //PTCacheID *pid; + //ListBase pidlist; + + bSound *sound; + Sequence *seq; + bActuator *act; + int a; + + for (sound = main->sound.first; sound; sound = sound->id.next) { + if (sound->newpackedfile) { + sound->packedfile = sound->newpackedfile; + sound->newpackedfile = NULL; + } + } + + for (ob = main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_SOUND) { + bSoundActuator *sAct = (bSoundActuator*) act->data; + if (sAct->sound) { + sound = blo_do_versions_newlibadr(fd, lib, sAct->sound); + sAct->flag = sound->flags & SOUND_FLAGS_3D ? ACT_SND_3D_SOUND : 0; + sAct->pitch = sound->pitch; + sAct->volume = sound->volume; + sAct->sound3D.reference_distance = sound->distance; + sAct->sound3D.max_gain = sound->max_gain; + sAct->sound3D.min_gain = sound->min_gain; + sAct->sound3D.rolloff_factor = sound->attenuation; + } + else { + sAct->sound3D.reference_distance = 1.0f; + sAct->volume = 1.0f; + sAct->sound3D.max_gain = 1.0f; + sAct->sound3D.rolloff_factor = 1.0f; + } + sAct->sound3D.cone_inner_angle = 360.0f; + sAct->sound3D.cone_outer_angle = 360.0f; + sAct->sound3D.max_distance = FLT_MAX; + } + } + } + + for (scene = main->scene.first; scene; scene = scene->id.next) { + if (scene->ed && scene->ed->seqbasep) { + SEQ_BEGIN (scene->ed, seq) + { + if (seq->type == SEQ_HD_SOUND) { + char str[FILE_MAX]; + BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_abs(str, main->name); + seq->sound = sound_new_file(main, str); + } + /* don't know, if anybody used that + * this way, but just in case, upgrade + * to new way... */ + if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && + !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) + { + + BLI_snprintf(seq->strip->proxy->dir, + FILE_MAXDIR, "%s/BL_proxy", + seq->strip->dir); + } + } + SEQ_END + } + } + + for (screen= main->screen.first; screen; screen= screen->id.next) { + do_versions_windowmanager_2_50(screen); + do_versions_gpencil_2_50(main, screen); + } + + /* shader, composite and texture node trees have id.name empty, put something in + * to have them show in RNA viewer and accessible otherwise. + */ + for (ma= main->mat.first; ma; ma= ma->id.next) { + if (ma->nodetree && ma->nodetree->id.name[0] == '\0') + strcpy(ma->nodetree->id.name, "NTShader Nodetree"); + + /* which_output 0 is now "not specified" */ + for (a=0; amtex[a]) { + tx= blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex); + if (tx && tx->use_nodes) + ma->mtex[a]->which_output++; + } + } + } + /* and composite trees */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->nodetree && sce->nodetree->id.name[0] == '\0') + strcpy(sce->nodetree->id.name, "NTCompositing Nodetree"); + + /* move to cameras */ + if (sce->r.mode & R_PANORAMA) { + for (base=sce->base.first; base; base=base->next) { + ob= blo_do_versions_newlibadr(fd, lib, base->object); + + if (ob->type == OB_CAMERA && !ob->id.lib) { + cam= blo_do_versions_newlibadr(fd, lib, ob->data); + cam->flag |= CAM_PANORAMA; + } + } + + sce->r.mode &= ~R_PANORAMA; + } + } + /* and texture trees */ + for (tx= main->tex.first; tx; tx= tx->id.next) { + bNode *node; + + if (tx->nodetree) { + if (tx->nodetree->id.name[0] == '\0') + strcpy(tx->nodetree->id.name, "NTTexture Nodetree"); + + /* which_output 0 is now "not specified" */ + for (node=tx->nodetree->nodes.first; node; node=node->next) + if (node->type == TEX_NODE_OUTPUT) + node->custom1++; + } + } + + /* copy standard draw flag to meshes(used to be global, is not available here) */ + for (me= main->mesh.first; me; me= me->id.next) { + me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; + } + + /* particle draw and render types */ + for (part= main->particle.first; part; part= part->id.next) { + if (part->draw_as) { + if (part->draw_as == PART_DRAW_DOT) { + part->ren_as = PART_DRAW_HALO; + part->draw_as = PART_DRAW_REND; + } + else if (part->draw_as <= PART_DRAW_AXIS) { + part->ren_as = PART_DRAW_HALO; + } + else { + part->ren_as = part->draw_as; + part->draw_as = PART_DRAW_REND; + } + } + part->path_end = 1.0f; + part->clength = 1.0f; + } + /* set old pointcaches to have disk cache flag */ + for (ob = main->object.first; ob; ob= ob->id.next) { + + //BKE_ptcache_ids_from_object(&pidlist, ob); + + //for (pid=pidlist.first; pid; pid=pid->next) + // pid->cache->flag |= PTCACHE_DISK_CACHE; + + //BLI_freelistN(&pidlist); + } + + /* type was a mixed flag & enum. move the 2d flag elsewhere */ + for (cu = main->curve.first; cu; cu= cu->id.next) { + Nurb *nu; + + for (nu= cu->nurb.first; nu; nu= nu->next) { + nu->flag |= (nu->type & CU_2D); + nu->type &= CU_TYPE; + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) { + Object *ob; + Material *ma; + Tex *tex; + Scene *sce; + ToolSettings *ts; + //PTCacheID *pid; + //ListBase pidlist; + + for (ob = main->object.first; ob; ob = ob->id.next) { + //BKE_ptcache_ids_from_object(&pidlist, ob); + + //for (pid=pidlist.first; pid; pid=pid->next) { + // if (pid->ptcaches->first == NULL) + // pid->ptcaches->first = pid->ptcaches->last = pid->cache; + //} + + //BLI_freelistN(&pidlist); + + if (ob->type == OB_MESH) { + Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data); + void *olddata = ob->data; + ob->data = me; + + /* XXX - library meshes crash on loading most yoFrankie levels, + * the multires pointer gets invalid - Campbell */ + if (me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) { + multires_load_old(ob, me); + } + + ob->data = olddata; + } + + if (ob->totcol && ob->matbits == NULL) { + int a; + + ob->matbits= MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits"); + for (a=0; atotcol; a++) + ob->matbits[a]= ob->colbits & (1<tex.first; tex; tex = tex->id.next) { + if (tex->afmax == 0) + tex->afmax= 8; + } + + for (ma = main->mat.first; ma; ma = ma->id.next) { + int a; + if (ma->mode & MA_WIRE) { + ma->material_type= MA_TYPE_WIRE; + ma->mode &= ~MA_WIRE; + } + if (ma->mode & MA_HALO) { + ma->material_type= MA_TYPE_HALO; + ma->mode &= ~MA_HALO; + } + + if (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP)) { + ma->mode |= MA_TRANSP; + } + else { + /* ma->mode |= MA_ZTRANSP; */ /* leave ztransp as is even if its not used [#28113] */ + ma->mode &= ~MA_TRANSP; + } + + /* set new bump for unused slots */ + for (a=0; amtex[a]) { + tex= ma->mtex[a]->tex; + if (!tex) { + ma->mtex[a]->texflag |= MTEX_3TAP_BUMP; + ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE; + } + else { + tex= (Tex*)blo_do_versions_newlibadr(fd, ma->id.lib, tex); + if (tex && tex->type == 0) { /* invalid type */ + ma->mtex[a]->texflag |= MTEX_3TAP_BUMP; + ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE; + } + } + } + } + + /* volume rendering settings */ + if (ma->vol.stepsize < 0.0001f) { + ma->vol.density = 1.0f; + ma->vol.emission = 0.0f; + ma->vol.scattering = 1.0f; + ma->vol.emission_col[0] = ma->vol.emission_col[1] = ma->vol.emission_col[2] = 1.0f; + ma->vol.density_scale = 1.0f; + ma->vol.depth_cutoff = 0.01f; + ma->vol.stepsize_type = MA_VOL_STEP_RANDOMIZED; + ma->vol.stepsize = 0.2f; + ma->vol.shade_type = MA_VOL_SHADE_SHADED; + ma->vol.shadeflag |= MA_VOL_PRECACHESHADING; + ma->vol.precache_resolution = 50; + } + } + + for (sce = main->scene.first; sce; sce = sce->id.next) { + ts= sce->toolsettings; + if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) { + ts->normalsize= 0.1f; + ts->selectmode= SCE_SELECT_VERTEX; + + /* autokeying - setting should be taken from the user-prefs + * but the userprefs version may not have correct flags set + * (i.e. will result in blank box when enabled) + */ + ts->autokey_mode= U.autokey_mode; + if (ts->autokey_mode == 0) + ts->autokey_mode= 2; /* 'add/replace' but not on */ + ts->uv_selectmode= UV_SELECT_VERTEX; + ts->vgroup_weight= 1.0f; + } + + /* Game Settings */ + //Dome + sce->gm.dome.angle = sce->r.domeangle; + sce->gm.dome.mode = sce->r.domemode; + sce->gm.dome.res = sce->r.domeres; + sce->gm.dome.resbuf = sce->r.domeresbuf; + sce->gm.dome.tilt = sce->r.dometilt; + sce->gm.dome.warptext = sce->r.dometext; + + //Stand Alone + sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0); + sce->gm.xplay = sce->r.xplay; + sce->gm.yplay = sce->r.yplay; + sce->gm.freqplay = sce->r.freqplay; + sce->gm.depth = sce->r.depth; + sce->gm.attrib = sce->r.attrib; + + //Stereo + sce->gm.stereomode = sce->r.stereomode; + /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/ + if (sce->gm.stereomode == 1) { //1 = STEREO_NOSTEREO + sce->gm.stereoflag = STEREO_NOSTEREO; + sce->gm.stereomode = STEREO_ANAGLYPH; + } + else if (sce->gm.stereomode == 8) { //8 = STEREO_DOME + sce->gm.stereoflag = STEREO_DOME; + sce->gm.stereomode = STEREO_ANAGLYPH; + } + else + sce->gm.stereoflag = STEREO_ENABLED; + + //Framing + sce->gm.framing = sce->framing; + sce->gm.xplay = sce->r.xplay; + sce->gm.yplay = sce->r.yplay; + sce->gm.freqplay= sce->r.freqplay; + sce->gm.depth= sce->r.depth; + + //Physic (previously stored in world) + sce->gm.gravity =9.8f; + sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default + sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default + sce->gm.occlusionRes = 128; + sce->gm.ticrate = 60; + sce->gm.maxlogicstep = 5; + sce->gm.physubstep = 1; + sce->gm.maxphystep = 5; + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 2)) { + Scene *sce; + Object *ob; + + for (sce = main->scene.first; sce; sce = sce->id.next) { + if (fd->fileflags & G_FILE_ENABLE_ALL_FRAMES) + sce->gm.flag |= GAME_ENABLE_ALL_FRAMES; + if (fd->fileflags & G_FILE_SHOW_DEBUG_PROPS) + sce->gm.flag |= GAME_SHOW_DEBUG_PROPS; + if (fd->fileflags & G_FILE_SHOW_FRAMERATE) + sce->gm.flag |= GAME_SHOW_FRAMERATE; + if (fd->fileflags & G_FILE_SHOW_PHYSICS) + sce->gm.flag |= GAME_SHOW_PHYSICS; + if (fd->fileflags & G_FILE_GLSL_NO_SHADOWS) + sce->gm.flag |= GAME_GLSL_NO_SHADOWS; + if (fd->fileflags & G_FILE_GLSL_NO_SHADERS) + sce->gm.flag |= GAME_GLSL_NO_SHADERS; + if (fd->fileflags & G_FILE_GLSL_NO_RAMPS) + sce->gm.flag |= GAME_GLSL_NO_RAMPS; + if (fd->fileflags & G_FILE_GLSL_NO_NODES) + sce->gm.flag |= GAME_GLSL_NO_NODES; + if (fd->fileflags & G_FILE_GLSL_NO_EXTRA_TEX) + sce->gm.flag |= GAME_GLSL_NO_EXTRA_TEX; + if (fd->fileflags & G_FILE_IGNORE_DEPRECATION_WARNINGS) + sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; + + if (fd->fileflags & G_FILE_GAME_MAT_GLSL) + sce->gm.matmode= GAME_MAT_GLSL; + else if (fd->fileflags & G_FILE_GAME_MAT) + sce->gm.matmode= GAME_MAT_MULTITEX; + else + sce->gm.matmode= GAME_MAT_TEXFACE; + + sce->gm.flag |= GAME_DISPLAY_LISTS; + } + + for (ob = main->object.first; ob; ob = ob->id.next) { + if (ob->flag & 8192) // OB_POSEMODE = 8192 + ob->mode |= OB_MODE_POSE; + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 4)) { + Scene *sce; + Object *ob; + Material *ma; + Lamp *la; + World *wo; + Tex *tex; + ParticleSettings *part; + int do_gravity = 0; + + for (sce = main->scene.first; sce; sce = sce->id.next) + if (sce->unit.scale_length == 0.0f) + sce->unit.scale_length= 1.0f; + + for (ob = main->object.first; ob; ob = ob->id.next) { + /* fluid-sim stuff */ + FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); + if (fluidmd) fluidmd->fss->fmd = fluidmd; + + /* rotation modes were added, but old objects would now default to being 'quaternion based' */ + ob->rotmode= ROT_MODE_EUL; + } + + for (ma = main->mat.first; ma; ma=ma->id.next) { + if (ma->vol.reflection == 0.f) { + ma->vol.reflection = 1.f; + ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f; + ma->vol.reflection_col[0] = ma->vol.reflection_col[1] = ma->vol.reflection_col[2] = 1.0f; + } + + do_version_mtex_factor_2_50(ma->mtex, ID_MA); + } + + for (la = main->lamp.first; la; la=la->id.next) + do_version_mtex_factor_2_50(la->mtex, ID_LA); + + for (wo = main->world.first; wo; wo=wo->id.next) + do_version_mtex_factor_2_50(wo->mtex, ID_WO); + + for (tex = main->tex.first; tex; tex=tex->id.next) + if (tex->vd) + if (tex->vd->extend == 0) + tex->vd->extend = TEX_CLIP; + + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->audio.main == 0.0f) + sce->audio.main = 1.0f; + + sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate; + sce->r.ffcodecdata.audio_volume = sce->audio.main; + sce->audio.distance_model = 2; + sce->audio.doppler_factor = 1.0f; + sce->audio.speed_of_sound = 343.3f; + } + + /* Add default gravity to scenes */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && + len_v3(sce->physics_settings.gravity) == 0.0f) + { + sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f; + sce->physics_settings.gravity[2] = -9.81f; + sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY; + do_gravity = 1; + } + } + + /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */ + if (do_gravity) for (part= main->particle.first; part; part= part->id.next) + part->effector_weights->global_gravity = part->acc[2]/-9.81f; + + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + + if (do_gravity) { + for (md= ob->modifiers.first; md; md= md->next) { + ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); + if (clmd) + clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f; + } + + if (ob->soft) + ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81f; + } + + /* Normal wind shape is plane */ + if (ob->pd) { + if (ob->pd->forcefield == PFIELD_WIND) + ob->pd->shape = PFIELD_SHAPE_PLANE; + + if (ob->pd->flag & PFIELD_PLANAR) + ob->pd->shape = PFIELD_SHAPE_PLANE; + else if (ob->pd->flag & PFIELD_SURFACE) + ob->pd->shape = PFIELD_SHAPE_SURFACE; + + ob->pd->flag |= PFIELD_DO_LOCATION; + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) { + Object *ob; + Lamp *la; + + /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */ + for (ob= main->object.first; ob; ob= ob->id.next) { + /* new variables for all objects */ + ob->quat[0]= 1.0f; + ob->rotAxis[1]= 1.0f; + + /* bones */ + if (ob->pose) { + bPoseChannel *pchan; + + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + /* just need to initalise rotation axis properly... */ + pchan->rotAxis[1]= 1.0f; + } + } + } + + for (la = main->lamp.first; la; la=la->id.next) + la->compressthresh= 0.05f; + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) { + Mesh *me; + Nurb *nu; + Lattice *lt; + Curve *cu; + Key *key; + float *data; + int a, tot; + + /* shape keys are no longer applied to the mesh itself, but rather + * to the derivedmesh/displist, so here we ensure that the basis + * shape key is always set in the mesh coordinates. */ + + for (me= main->mesh.first; me; me= me->id.next) { + if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) { + data= key->refkey->data; + tot= MIN2(me->totvert, key->refkey->totelem); + + for (a=0; amvert[a].co, data); + } + } + + for (lt= main->latt.first; lt; lt= lt->id.next) { + if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) { + data= key->refkey->data; + tot= MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem); + + for (a=0; adef[a].vec, data); + } + } + + for (cu= main->curve.first; cu; cu= cu->id.next) { + if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) { + data= key->refkey->data; + + for (nu=cu->nurb.first; nu; nu=nu->next) { + if (nu->bezt) { + BezTriple *bezt = nu->bezt; + + for (a=0; apntsu; a++, bezt++) { + copy_v3_v3(bezt->vec[0], data); data+=3; + copy_v3_v3(bezt->vec[1], data); data+=3; + copy_v3_v3(bezt->vec[2], data); data+=3; + bezt->alfa= *data; data++; + } + } + else if (nu->bp) { + BPoint *bp = nu->bp; + + for (a=0; apntsu*nu->pntsv; a++, bp++) { + copy_v3_v3(bp->vec, data); data+=3; + bp->alfa= *data; data++; + } + } + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) { + { + Scene *sce= main->scene.first; + while (sce) { + if (sce->r.frame_step==0) + sce->r.frame_step= 1; + if (sce->r.mblur_samples==0) + sce->r.mblur_samples = sce->r.osa; + + if (sce->ed && sce->ed->seqbase.first) { + do_versions_seq_unique_name_all_strips( + sce, &sce->ed->seqbase); + } + + sce= sce->id.next; + } + } + { + /* ensure all nodes have unique names */ + bNodeTree *ntree= main->nodetree.first; + while (ntree) { + bNode *node=ntree->nodes.first; + + while (node) { + nodeUniqueName(ntree, node); + node= node->next; + } + + ntree= ntree->id.next; + } + } + { + Object *ob=main->object.first; + while (ob) { + /* shaded mode disabled for now */ + if (ob->dt == OB_MATERIAL) ob->dt = OB_TEXTURE; + ob=ob->id.next; + } + } + + { + bScreen *screen; + ScrArea *sa; + SpaceLink *sl; + + for (screen= main->screen.first; screen; screen= screen->id.next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + if (v3d->drawtype == OB_MATERIAL) v3d->drawtype = OB_SOLID; + } + } + } + } + } + + /* only convert old 2.50 files with color management */ + if (main->versionfile == 250) { + Scene *sce=main->scene.first; + Material *ma=main->mat.first; + World *wo=main->world.first; + Tex *tex=main->tex.first; + int i, convert=0; + + /* convert to new color management system: + * while previously colors were stored as srgb, + * now they are stored as linear internally, + * with screen gamma correction in certain places in the UI. */ + + /* don't know what scene is active, so we'll convert if any scene has it enabled... */ + while (sce) { + if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT) + convert=1; + sce=sce->id.next; + } + + if (convert) { + while (ma) { + if (ma->ramp_col) { + ColorBand *band = (ColorBand *)ma->ramp_col; + for (i=0; itot; i++) { + CBData *data = band->data + i; + srgb_to_linearrgb_v3_v3(&data->r, &data->r); + } + } + if (ma->ramp_spec) { + ColorBand *band = (ColorBand *)ma->ramp_spec; + for (i=0; itot; i++) { + CBData *data = band->data + i; + srgb_to_linearrgb_v3_v3(&data->r, &data->r); + } + } + + srgb_to_linearrgb_v3_v3(&ma->r, &ma->r); + srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr); + srgb_to_linearrgb_v3_v3(&ma->mirr, &ma->mirr); + srgb_to_linearrgb_v3_v3(ma->sss_col, ma->sss_col); + ma=ma->id.next; + } + + while (tex) { + if (tex->coba) { + ColorBand *band = (ColorBand *)tex->coba; + for (i=0; itot; i++) { + CBData *data = band->data + i; + srgb_to_linearrgb_v3_v3(&data->r, &data->r); + } + } + tex=tex->id.next; + } + + while (wo) { + srgb_to_linearrgb_v3_v3(&wo->ambr, &wo->ambr); + srgb_to_linearrgb_v3_v3(&wo->horr, &wo->horr); + srgb_to_linearrgb_v3_v3(&wo->zenr, &wo->zenr); + wo=wo->id.next; + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) { + Scene *sce; + Mesh *me; + Object *ob; + + for (sce=main->scene.first; sce; sce=sce->id.next) + if (!sce->toolsettings->particle.selectmode) + sce->toolsettings->particle.selectmode= SCE_SELECT_PATH; + + if (main->versionfile == 250 && main->subversionfile > 1) { + for (me=main->mesh.first; me; me=me->id.next) + multires_load_old_250(me); + + for (ob=main->object.first; ob; ob=ob->id.next) { + MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires); + + if (mmd) { + mmd->totlvl--; + mmd->lvl--; + mmd->sculptlvl= mmd->lvl; + mmd->renderlvl= mmd->lvl; + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 10)) { + Object *ob; + + /* properly initialize hair clothsim data on old files */ + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Cloth) { + ClothModifierData *clmd = (ClothModifierData *)md; + if (clmd->sim_parms->velocity_smooth < 0.01f) + clmd->sim_parms->velocity_smooth = 0.f; + } + } + } + } + + /* fix bad area setup in subversion 10 */ + if (main->versionfile == 250 && main->subversionfile == 10) { + /* fix for new view type in sequencer */ + bScreen *screen; + ScrArea *sa; + SpaceLink *sl; + + + /* remove all preview window in wrong spaces */ + for (screen= main->screen.first; screen; screen= screen->id.next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype!=SPACE_SEQ) { + ARegion *ar; + ListBase *regionbase; + + if (sl == sa->spacedata.first) { + regionbase = &sa->regionbase; + } + else { + regionbase = &sl->regionbase; + } + + + for ( ar = regionbase->first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_PREVIEW) + break; + } + + if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) { + SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ); + BKE_area_region_free(st, ar); + BLI_freelinkN(regionbase, ar); + } + } + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 11)) { + { + /* fix for new view type in sequencer */ + bScreen *screen; + ScrArea *sa; + SpaceLink *sl; + + + for (screen= main->screen.first; screen; screen= screen->id.next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_SEQ) { + ARegion *ar; + ARegion *ar_main; + ListBase *regionbase; + SpaceSeq *sseq = (SpaceSeq *)sl; + + if (sl == sa->spacedata.first) { + regionbase = &sa->regionbase; + } + else { + regionbase = &sl->regionbase; + } + + if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE; + if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF; + + ar_main = (ARegion*)regionbase->first; + for (; ar_main; ar_main = ar_main->next) { + if (ar_main->regiontype == RGN_TYPE_WINDOW) + break; + } + ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); + BLI_insertlinkbefore(regionbase, ar_main, ar); + sequencer_init_preview_region(ar); + } + } + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 12)) { + Scene *sce; + Object *ob; + Brush *brush; + Material *ma; + + /* game engine changes */ + for (sce = main->scene.first; sce; sce = sce->id.next) { + sce->gm.eyeseparation = 0.10f; + } + + /* anim viz changes */ + for (ob= main->object.first; ob; ob= ob->id.next) { + /* initialize object defaults */ + animviz_settings_init(&ob->avs); + + /* if armature, copy settings for pose from armature data + * performing initialization where appropriate + */ + if (ob->pose && ob->data) { + bArmature *arm= blo_do_versions_newlibadr(fd, lib, ob->data); + if (arm) { /* XXX - why does this fail in some cases? */ + bAnimVizSettings *avs= &ob->pose->avs; + + /* ghosting settings ---------------- */ + /* ranges */ + avs->ghost_bc= avs->ghost_ac= arm->ghostep; + + avs->ghost_sf= arm->ghostsf; + avs->ghost_ef= arm->ghostef; + if ((avs->ghost_sf == avs->ghost_ef) && (avs->ghost_sf == 0)) { + avs->ghost_sf= 1; + avs->ghost_ef= 100; + } + + /* type */ + if (arm->ghostep == 0) + avs->ghost_type= GHOST_TYPE_NONE; + else + avs->ghost_type= arm->ghosttype + 1; + + /* stepsize */ + avs->ghost_step= arm->ghostsize; + if (avs->ghost_step == 0) + avs->ghost_step= 1; + + /* path settings --------------------- */ + /* ranges */ + avs->path_bc= arm->pathbc; + avs->path_ac= arm->pathac; + if ((avs->path_bc == avs->path_ac) && (avs->path_bc == 0)) + avs->path_bc= avs->path_ac= 10; + + avs->path_sf= arm->pathsf; + avs->path_ef= arm->pathef; + if ((avs->path_sf == avs->path_ef) && (avs->path_sf == 0)) { + avs->path_sf= 1; + avs->path_ef= 250; + } + + /* flags */ + if (arm->pathflag & ARM_PATH_FNUMS) + avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS; + if (arm->pathflag & ARM_PATH_KFRAS) + avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS; + if (arm->pathflag & ARM_PATH_KFNOS) + avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS; + + /* bake flags */ + if (arm->pathflag & ARM_PATH_HEADS) + avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS; + + /* type */ + if (arm->pathflag & ARM_PATH_ACFRA) + avs->path_type = MOTIONPATH_TYPE_ACFRA; + + /* stepsize */ + avs->path_step= arm->pathsize; + if (avs->path_step == 0) + avs->path_step= 1; + } + else + animviz_settings_init(&ob->pose->avs); + } + } + + /* brush texture changes */ + for (brush= main->brush.first; brush; brush= brush->id.next) { + default_mtex(&brush->mtex); + } + + for (ma= main->mat.first; ma; ma= ma->id.next) { + if (ma->vol.ms_spread < 0.0001f) { + ma->vol.ms_spread = 0.2f; + ma->vol.ms_diff = 1.f; + ma->vol.ms_intensity = 1.f; + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) { + /* NOTE: if you do more conversion, be sure to do it outside of this and + * increase subversion again, otherwise it will not be correct */ + Object *ob; + + /* convert degrees to radians for internal use */ + for (ob=main->object.first; ob; ob=ob->id.next) { + bPoseChannel *pchan; + + do_version_constraints_radians_degrees_250(&ob->constraints); + + if (ob->pose) { + for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { + pchan->limitmin[0] *= (float)(M_PI/180.0); + pchan->limitmin[1] *= (float)(M_PI/180.0); + pchan->limitmin[2] *= (float)(M_PI/180.0); + pchan->limitmax[0] *= (float)(M_PI/180.0); + pchan->limitmax[1] *= (float)(M_PI/180.0); + pchan->limitmax[2] *= (float)(M_PI/180.0); + + do_version_constraints_radians_degrees_250(&pchan->constraints); + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) { + /* fix for bad View2D extents for Animation Editors */ + bScreen *screen; + ScrArea *sa; + SpaceLink *sl; + + for (screen= main->screen.first; screen; screen= screen->id.next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sl= sa->spacedata.first; sl; sl= sl->next) { + ListBase *regionbase; + ARegion *ar; + + if (sl == sa->spacedata.first) + regionbase = &sa->regionbase; + else + regionbase = &sl->regionbase; + + if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) { + for (ar = (ARegion*)regionbase->first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f; + ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + } + } + } + } + } + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) { + World *wo; + Material *ma; + + /* ambient default from 0.5f to 1.0f */ + for (ma= main->mat.first; ma; ma=ma->id.next) + ma->amb *= 2.0f; + + for (wo= main->world.first; wo; wo=wo->id.next) { + /* ao splitting into ao/env/indirect */ + wo->ao_env_energy= wo->aoenergy; + wo->aoenergy= 1.0f; + + if (wo->ao_indirect_bounces == 0) + wo->ao_indirect_bounces= 1; + else + wo->mode |= WO_INDIRECT_LIGHT; + + if (wo->aomix == WO_AOSUB) + wo->ao_env_energy= -wo->ao_env_energy; + else if (wo->aomix == WO_AOADDSUB) + wo->mode |= WO_AMB_OCC; + + wo->aomix= WO_AOMUL; + + /* ambient default from 0.5f to 1.0f */ + mul_v3_fl(&wo->ambr, 0.5f); + wo->ao_env_energy *= 0.5f; + } + } + + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) { + Scene *sce; + Sequence *seq; + Material *ma; + + /* initialize to sane default so toggling on border shows something */ + for (sce = main->scene.first; sce; sce = sce->id.next) { + if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && + sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f) { + sce->r.border.xmin = 0.0f; + sce->r.border.ymin = 0.0f; + sce->r.border.xmax = 1.0f; + sce->r.border.ymax = 1.0f; + } + + if ((sce->r.ffcodecdata.flags & FFMPEG_MULTIPLEX_AUDIO) == 0) + sce->r.ffcodecdata.audio_codec = 0x0; // CODEC_ID_NONE + + SEQ_BEGIN (sce->ed, seq) + { + seq->volume = 1.0f; + } + SEQ_END + } + + /* particle brush strength factor was changed from int to float */ + for (sce= main->scene.first; sce; sce=sce->id.next) { + ParticleEditSettings *pset= &sce->toolsettings->particle; + int a; + + for (a=0; abrush[a].strength /= 100.0f; + } + + for (ma = main->mat.first; ma; ma=ma->id.next) + if (ma->mode & MA_TRACEBLE) + ma->shade_flag |= MA_APPROX_OCCLUSION; + + /* sequencer changes */ + { + bScreen *screen; + ScrArea *sa; + SpaceLink *sl; + + for (screen= main->screen.first; screen; screen= screen->id.next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_SEQ) { + ARegion *ar_preview; + ListBase *regionbase; + + if (sl == sa->spacedata.first) { + regionbase = &sa->regionbase; + } + else { + regionbase = &sl->regionbase; + } + + ar_preview = (ARegion*)regionbase->first; + for (; ar_preview; ar_preview = ar_preview->next) { + if (ar_preview->regiontype == RGN_TYPE_PREVIEW) + break; + } + if (ar_preview && (ar_preview->regiontype == RGN_TYPE_PREVIEW)) { + sequencer_init_preview_region(ar_preview); + } + } + } + } + } + } /* sequencer changes */ + } + + if (main->versionfile <= 251) { /* 2.5.1 had no subversions */ + bScreen *sc; + + /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE. + * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated. + * Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set, + * which would cause cameras, lamps, etc to become invisible */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D* v3d = (View3D *)sl; + v3d->flag2 &= ~V3D_RENDER_OVERRIDE; + } + } + } + } + } + + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 1)) { + Brush *brush; + Object *ob; + Scene *scene; + bNodeTree *ntree; + + for (brush= main->brush.first; brush; brush= brush->id.next) { + if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH; + } + + /* properly initialize active flag for fluidsim modifiers */ + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Fluidsim) { + FluidsimModifierData *fmd = (FluidsimModifierData *)md; + fmd->fss->flag |= OB_FLUIDSIM_ACTIVE; + fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME; + } + } + } + + /* adjustment to color balance node values */ + for (scene= main->scene.first; scene; scene= scene->id.next) { + if (scene->nodetree) { + bNode *node=scene->nodetree->nodes.first; + + while (node) { + if (node->type == CMP_NODE_COLORBALANCE) { + NodeColorBalance *n= (NodeColorBalance *)node->storage; + n->lift[0] += 1.f; + n->lift[1] += 1.f; + n->lift[2] += 1.f; + } + node= node->next; + } + } + } + /* check inside node groups too */ + for (ntree= main->nodetree.first; ntree; ntree=ntree->id.next) { + bNode *node=ntree->nodes.first; + + while (node) { + if (node->type == CMP_NODE_COLORBALANCE) { + NodeColorBalance *n= (NodeColorBalance *)node->storage; + n->lift[0] += 1.f; + n->lift[1] += 1.f; + n->lift[2] += 1.f; + } + node= node->next; + } + } + } + + /* old-track -> constraints (this time we're really doing it!) */ + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) { + Object *ob; + + for (ob = main->object.first; ob; ob = ob->id.next) + blo_do_version_old_trackto_to_constraints(ob); + } + + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { + bScreen *sc; + + /* Image editor scopes */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *)sl; + scopes_new(&sima->scopes); + } + } + } + } + } + + + if (main->versionfile < 253) { + Object *ob; + Scene *scene; + bScreen *sc; + Tex *tex; + Brush *brush; + + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype == SPACE_NODE) { + SpaceNode *snode= (SpaceNode *)sl; + ListBase *regionbase; + ARegion *ar; + + if (sl == sa->spacedata.first) + regionbase = &sa->regionbase; + else + regionbase = &sl->regionbase; + + if (snode->v2d.minzoom > 0.09f) + snode->v2d.minzoom= 0.09f; + if (snode->v2d.maxzoom < 2.31f) + snode->v2d.maxzoom= 2.31f; + + for (ar= regionbase->first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + if (ar->v2d.minzoom > 0.09f) + ar->v2d.minzoom= 0.09f; + if (ar->v2d.maxzoom < 2.31f) + ar->v2d.maxzoom= 2.31f; + } + } + } + else if (sl->spacetype == SPACE_TIME) { + SpaceTime *stime= (SpaceTime *)sl; + + /* enable all cache display */ + stime->cache_display |= TIME_CACHE_DISPLAY; + stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT); + } + } + } + } + + do_version_mdef_250(main); + + /* parent type to modifier */ + for (ob = main->object.first; ob; ob = ob->id.next) { + if (ob->parent) { + Object *parent= (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent); + if (parent) { /* parent may not be in group */ + if (parent->type==OB_ARMATURE && ob->partype==PARSKEL) { + ArmatureModifierData *amd; + bArmature *arm= (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data); + + amd = (ArmatureModifierData*) modifier_new(eModifierType_Armature); + amd->object = ob->parent; + BLI_addtail((ListBase*)&ob->modifiers, amd); + amd->deformflag= arm->deformflag; + ob->partype = PAROBJECT; + } + else if (parent->type==OB_LATTICE && ob->partype==PARSKEL) { + LatticeModifierData *lmd; + + lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice); + lmd->object = ob->parent; + BLI_addtail((ListBase*)&ob->modifiers, lmd); + ob->partype = PAROBJECT; + } + else if (parent->type==OB_CURVE && ob->partype==PARCURVE) { + CurveModifierData *cmd; + + cmd = (CurveModifierData*) modifier_new(eModifierType_Curve); + cmd->object = ob->parent; + BLI_addtail((ListBase*)&ob->modifiers, cmd); + ob->partype = PAROBJECT; + } + } + } + } + + /* initialize scene active layer */ + for (scene= main->scene.first; scene; scene=scene->id.next) { + int i; + for (i=0; i<20; i++) { + if (scene->lay & (1<layact= 1<tex.first; tex; tex= tex->id.next) { + /* if youre picky, this isn't correct until we do a version bump + * since you could set saturation to be 0.0*/ + if (tex->saturation==0.0f) + tex->saturation= 1.0f; + } + + { + Curve *cu; + for (cu= main->curve.first; cu; cu= cu->id.next) { + cu->smallcaps_scale= 0.75f; + } + } + + for (scene= main->scene.first; scene; scene=scene->id.next) { + if (scene) { + Sequence *seq; + SEQ_BEGIN (scene->ed, seq) + { + if (seq->sat==0.0f) { + seq->sat= 1.0f; + } + } + SEQ_END + } + } + + /* GSOC 2010 Sculpt - New settings for Brush */ + + for (brush= main->brush.first; brush; brush= brush->id.next) { + /* Sanity Check */ + + // infinite number of dabs + if (brush->spacing == 0) + brush->spacing = 10; + + // will have no effect + if (brush->alpha == 0) + brush->alpha = 0.5f; + + // bad radius + if (brush->unprojected_radius == 0) + brush->unprojected_radius = 0.125f; + + // unusable size + if (brush->size == 0) + brush->size = 35; + + // can't see overlay + if (brush->texture_overlay_alpha == 0) + brush->texture_overlay_alpha = 33; + + // same as draw brush + if (brush->crease_pinch_factor == 0) + brush->crease_pinch_factor = 0.5f; + + // will sculpt no vertexes + if (brush->plane_trim == 0) + brush->plane_trim = 0.5f; + + // same as smooth stroke off + if (brush->smooth_stroke_radius == 0) + brush->smooth_stroke_radius= 75; + + // will keep cursor in one spot + if (brush->smooth_stroke_radius == 1) + brush->smooth_stroke_factor= 0.9f; + + // same as dots + if (brush->rate == 0) + brush->rate = 0.1f; + + /* New Settings */ + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { + brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space + + // spacing was originally in pixels, convert it to percentage for new version + // size should not be zero due to sanity check above + brush->spacing = (int)(100*((float)brush->spacing) / ((float)brush->size)); + + if (brush->add_col[0] == 0 && + brush->add_col[1] == 0 && + brush->add_col[2] == 0) + { + brush->add_col[0] = 1.00f; + brush->add_col[1] = 0.39f; + brush->add_col[2] = 0.39f; + } + + if (brush->sub_col[0] == 0 && + brush->sub_col[1] == 0 && + brush->sub_col[2] == 0) + { + brush->sub_col[0] = 0.39f; + brush->sub_col[1] = 0.39f; + brush->sub_col[2] = 1.00f; + } + } + } + } + + /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */ + if (main->versionfile < 253) { + Scene *sce; + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings->sculpt_paint_unified_alpha == 0) + sce->toolsettings->sculpt_paint_unified_alpha = 0.5f; + + if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) + sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f; + + if (sce->toolsettings->sculpt_paint_unified_size == 0) + sce->toolsettings->sculpt_paint_unified_size = 35; + } + } + + if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) { + Object *ob; + + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; + + if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { + smd->domain->vorticity = 2.0f; + smd->domain->time_scale = 1.0f; + + if (!(smd->domain->flags & (1<<4))) + continue; + + /* delete old MOD_SMOKE_INITVELOCITY flag */ + smd->domain->flags &= ~(1<<4); + + /* for now just add it to all flow objects in the scene */ + { + Object *ob2; + for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) { + ModifierData *md2; + for (md2= ob2->modifiers.first; md2; md2= md2->next) { + if (md2->type == eModifierType_Smoke) { + SmokeModifierData *smd2 = (SmokeModifierData *)md2; + + if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { + smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY; + } + } + } + } + } + + } + else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) { + smd->flow->vel_multi = 1.0f; + } + + } + } + } + } + + if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) { + Brush *br; + ParticleSettings *part; + bScreen *sc; + Object *ob; + + for (br= main->brush.first; br; br= br->id.next) { + if (br->ob_mode==0) + br->ob_mode= OB_MODE_ALL_PAINT; + } + + for (part = main->particle.first; part; part = part->id.next) { + if (part->boids) + part->boids->pitch = 1.0f; + + part->flag &= ~PART_HAIR_REGROW; /* this was a deprecated flag before */ + part->kink_amp_clump = 1.f; /* keep old files looking similar */ + } + + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype == SPACE_INFO) { + SpaceInfo *sinfo= (SpaceInfo *)sl; + ARegion *ar; + + sinfo->rpt_mask= INFO_RPT_OP; + + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.scroll = (V2D_SCROLL_RIGHT); + ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ + ar->v2d.keepofs = V2D_LOCKOFS_X; + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); + ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS; + ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + } + } + } + } + } + } + + /* fix rotation actuators for objects so they use real angles (radians) + * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */ + for (ob= main->object.first; ob; ob= ob->id.next) { + bActuator *act= ob->actuators.first; + while (act) { + if (act->type==ACT_OBJECT) { + /* multiply velocity with 50 in old files */ + bObjectActuator *oa= act->data; + mul_v3_fl(oa->drot, 0.8726646259971648f); + } + act= act->next; + } + } + } + + // init facing axis property of steering actuators + { + Object *ob; + for (ob = main->object.first; ob; ob = ob->id.next) { + bActuator *act; + for (act= ob->actuators.first; act; act= act->next) { + if (act->type==ACT_STEERING) { + bSteeringActuator* stact = act->data; + if (stact->facingaxis==0) { + stact->facingaxis=1; + } + } + } + } + } + + if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) { + Object *ob; + + /* ocean res is now squared, reset old ones - will be massive */ + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Ocean) { + OceanModifierData *omd = (OceanModifierData *)md; + omd->resolution = 7; + omd->oceancache = NULL; + } + } + } + } + + if (main->versionfile < 256) { + bScreen *sc; + ScrArea *sa; + Key *key; + + /* Fix for sample line scope initializing with no height */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + sa= sc->areabase.first; + while (sa) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_IMAGE) { + SpaceImage *sima= (SpaceImage *)sl; + if (sima->sample_line_hist.height == 0 ) + sima->sample_line_hist.height = 100; + } + } + sa= sa->next; + } + } + + /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in + * 2.4x would never reveal this to users as a dummy value always ended up getting used + * instead + */ + for (key = main->key.first; key; key = key->id.next) { + KeyBlock *kb; + + for (kb = key->block.first; kb; kb = kb->next) { + if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) + kb->slidermax = kb->slidermin + 1.0f; + } + } + } + + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) { + /* fix for bones that didn't have arm_roll before */ + bArmature* arm; + Bone* bone; + Object *ob; + + for (arm = main->armature.first; arm; arm = arm->id.next) + for (bone = arm->bonebase.first; bone; bone = bone->next) + do_version_bone_roll_256(bone); + + /* fix for objects which have zero dquat's + * since this is multiplied with the quat rather than added */ + for (ob= main->object.first; ob; ob= ob->id.next) { + if (is_zero_v4(ob->dquat)) { + unit_qt(ob->dquat); + } + if (is_zero_v3(ob->drotAxis) && ob->drotAngle == 0.0f) { + unit_axis_angle(ob->drotAxis, &ob->drotAngle); + } + } + } + + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { + bNodeTree *ntree; + + /* node sockets are not exposed automatically any more, + * this mimics the old behavior by adding all unlinked sockets to groups. + */ + for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + /* XXX Only setting a flag here. Actual adding of group sockets + * is done in lib_verify_nodetree, because at this point the internal + * nodes may not be up-to-date! (missing lib-link) + */ + ntree->flag |= NTREE_DO_VERSIONS_GROUP_EXPOSE; + } + } + + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)) { + bScreen *sc; + Brush *brush; + Object *ob; + ParticleSettings *part; + Material *mat; + int tex_nr, transp_tex; + + for (mat = main->mat.first; mat; mat = mat->id.next) { + if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) { + + transp_tex= 0; + + for (tex_nr=0; tex_nrmtex[tex_nr]) continue; + if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) transp_tex= 1; + } + + /* weak! material alpha could be animated */ + if (mat->alpha < 1.0f || mat->fresnel_tra > 0.0f || transp_tex) { + mat->mode |= MA_TRANSP; + mat->mode &= ~(MA_ZTRANSP|MA_RAYTRANSP); + } + } + } + + /* redraws flag in SpaceTime has been moved to Screen level */ + for (sc = main->screen.first; sc; sc= sc->id.next) { + if (sc->redraws_flag == 0) { + /* just initialize to default? */ + // XXX: we could also have iterated through areas, and taken them from the first timeline available... + sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; + } + } + + for (brush= main->brush.first; brush; brush= brush->id.next) { + if (brush->height == 0) + brush->height= 0.4f; + } + + /* replace 'rim material' option for in offset*/ + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type == eModifierType_Solidify) { + SolidifyModifierData *smd = (SolidifyModifierData *)md; + if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) { + smd->mat_ofs_rim= 1; + smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL; + } + } + } + } + + /* particle draw color from material */ + for (part = main->particle.first; part; part = part->id.next) { + if (part->draw & PART_DRAW_MAT_COL) + part->draw_col = PART_DRAW_COL_MAT; + } + } + + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) { + Mesh *me; + + for (me= main->mesh.first; me; me= me->id.next) + mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); + } + + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { + /* update blur area sizes from 0..1 range to 0..100 percentage */ + Scene *scene; + bNode *node; + for (scene=main->scene.first; scene; scene=scene->id.next) + if (scene->nodetree) + for (node=scene->nodetree->nodes.first; node; node=node->next) + if (node->type==CMP_NODE_BLUR) { + NodeBlurData *nbd= node->storage; + nbd->percentx *= 100.0f; + nbd->percenty *= 100.0f; + } + } + + if (main->versionfile < 258 || (main->versionfile == 258 && main->subversionfile < 1)) { + /* screen view2d settings were not properly initialized [#27164] + * v2d->scroll caused the bug but best reset other values too which are in old blend files only. + * need to make less ugly - possibly an iterator? */ + bScreen *screen; + for (screen= main->screen.first; screen; screen= screen->id.next) { + ScrArea *sa; + /* add regions */ + for (sa= screen->areabase.first; sa; sa= sa->next) { + SpaceLink *sl= sa->spacedata.first; + if (sl->spacetype==SPACE_IMAGE) { + ARegion *ar; + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + View2D *v2d= &ar->v2d; + v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; + } + } + } + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_IMAGE) { + ARegion *ar; + for (ar=sl->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + View2D *v2d= &ar->v2d; + v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; + } + } + } + } + } + } + + { + /* Initialize texture point density curve falloff */ + Tex *tex; + for (tex= main->tex.first; tex; tex= tex->id.next) { + if (tex->pd) { + if (tex->pd->falloff_speed_scale == 0.0f) + tex->pd->falloff_speed_scale = 100.0f; + + if (!tex->pd->falloff_curve) { + tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); + + tex->pd->falloff_curve->preset = CURVE_PRESET_LINE; + tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; + curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); + curvemapping_changed(tex->pd->falloff_curve, 0); + } + } + } + } + + { + /* add default value for behind strength of camera actuator */ + Object *ob; + bActuator *act; + for (ob = main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_CAMERA) { + bCameraActuator *ba= act->data; + + ba->damping = 1.0/32.0; + } + } + } + } + + { + ParticleSettings *part; + for (part = main->particle.first; part; part = part->id.next) { + /* Initialize particle billboard scale */ + part->bb_size[0] = part->bb_size[1] = 1.0f; + } + } + } + + if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 1)) { + { + Scene *scene; + Sequence *seq; + + for (scene=main->scene.first; scene; scene=scene->id.next) { + scene->r.ffcodecdata.audio_channels = 2; + scene->audio.volume = 1.0f; + SEQ_BEGIN (scene->ed, seq) + { + seq->pitch = 1.0f; + } + SEQ_END + } + } + { + bScreen *screen; + for (screen= main->screen.first; screen; screen= screen->id.next) { + ScrArea *sa; + /* add regions */ + for (sa= screen->areabase.first; sa; sa= sa->next) { + SpaceLink *sl= sa->spacedata.first; + if (sl->spacetype==SPACE_SEQ) { + ARegion *ar; + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + if (ar->v2d.min[1] == 4.0f) + ar->v2d.min[1]= 0.5f; + } + } + } + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_SEQ) { + ARegion *ar; + for (ar=sl->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + if (ar->v2d.min[1] == 4.0f) + ar->v2d.min[1]= 0.5f; + } + } + } + } + } + } + } + { + /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve + * + * We're only patching F-Curves in Actions here, since it is assumed that most + * drivers out there won't be using this (and if they are, they're in the minority). + * While we should aim to fix everything ideally, in practice it's far too hard + * to get to every animdata block, not to mention the performance hit that'd have + */ + bAction *act; + FCurve *fcu; + + for (act = main->action.first; act; act = act->id.next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { + BezTriple *bezt; + unsigned int i = 0; + + /* only need to touch curves that had this flag set */ + if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) + continue; + if ((fcu->totvert == 0) || (fcu->bezt == NULL)) + continue; + + /* only change auto-handles to auto-clamped */ + for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM; + if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM; + } + + fcu->flag &= ~FCURVE_AUTO_HANDLES; + } + } + } + { + /* convert fcurve and shape action actuators to action actuators */ + Object *ob; + bActuator *act; + bIpoActuator *ia; + bActionActuator *aa; + + for (ob= main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_IPO) { + // Create the new actuator + ia= act->data; + aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); + + // Copy values + aa->type = ia->type; + aa->flag = ia->flag; + aa->sta = ia->sta; + aa->end = ia->end; + BLI_strncpy(aa->name, ia->name, sizeof(aa->name)); + BLI_strncpy(aa->frameProp, ia->frameProp, sizeof(aa->frameProp)); + if (ob->adt) + aa->act = ob->adt->action; + + // Get rid of the old actuator + MEM_freeN(ia); + + // Assign the new actuator + act->data = aa; + act->type= act->otype= ACT_ACTION; + + } + else if (act->type == ACT_SHAPEACTION) { + act->type = act->otype = ACT_ACTION; + } + } + } + } + } + + if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 2)) { + { + /* Convert default socket values from bNodeStack */ + Scene *sce; + Material *mat; + Tex *tex; + bNodeTree *ntree; + for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + blo_do_versions_nodetree_default_value(ntree); + ntree->update |= NTREE_UPDATE; + } + for (sce=main->scene.first; sce; sce=sce->id.next) + if (sce->nodetree) { + blo_do_versions_nodetree_default_value(sce->nodetree); + sce->nodetree->update |= NTREE_UPDATE; + } + for (mat=main->mat.first; mat; mat=mat->id.next) + if (mat->nodetree) { + blo_do_versions_nodetree_default_value(mat->nodetree); + mat->nodetree->update |= NTREE_UPDATE; + } + for (tex=main->tex.first; tex; tex=tex->id.next) + if (tex->nodetree) { + blo_do_versions_nodetree_default_value(tex->nodetree); + tex->nodetree->update |= NTREE_UPDATE; + } + } + + /* add SOCK_DYNAMIC flag to existing group sockets */ + { + bNodeTree *ntree; + /* only need to do this for trees in main, local trees are not used as groups */ + for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + do_versions_nodetree_dynamic_sockets(ntree); + ntree->update |= NTREE_UPDATE; + } + } + + { + /* Initialize group tree nodetypes. + * These are used to distinguish tree types and + * associate them with specific node types for polling. + */ + bNodeTree *ntree; + /* all node trees in main->nodetree are considered groups */ + for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) + ntree->nodetype = NODE_GROUP; + } + } + + if (main->versionfile < 259 || (main->versionfile == 259 && main->subversionfile < 4)) { + { + /* Adaptive time step for particle systems */ + ParticleSettings *part; + for (part = main->particle.first; part; part = part->id.next) { + part->courant_target = 0.2f; + part->time_flag &= ~PART_TIME_AUTOSF; + } + } + + { + /* set defaults for obstacle avoidance, recast data */ + Scene *sce; + for (sce = main->scene.first; sce; sce = sce->id.next) { + if (sce->gm.levelHeight == 0.f) + sce->gm.levelHeight = 2.f; + + if (sce->gm.recastData.cellsize == 0.0f) + sce->gm.recastData.cellsize = 0.3f; + if (sce->gm.recastData.cellheight == 0.0f) + sce->gm.recastData.cellheight = 0.2f; + if (sce->gm.recastData.agentmaxslope == 0.0f) + sce->gm.recastData.agentmaxslope = (float)M_PI/4; + if (sce->gm.recastData.agentmaxclimb == 0.0f) + sce->gm.recastData.agentmaxclimb = 0.9f; + if (sce->gm.recastData.agentheight == 0.0f) + sce->gm.recastData.agentheight = 2.0f; + if (sce->gm.recastData.agentradius == 0.0f) + sce->gm.recastData.agentradius = 0.6f; + if (sce->gm.recastData.edgemaxlen == 0.0f) + sce->gm.recastData.edgemaxlen = 12.0f; + if (sce->gm.recastData.edgemaxerror == 0.0f) + sce->gm.recastData.edgemaxerror = 1.3f; + if (sce->gm.recastData.regionminsize == 0.0f) + sce->gm.recastData.regionminsize = 8.f; + if (sce->gm.recastData.regionmergesize == 0.0f) + sce->gm.recastData.regionmergesize = 20.f; + if (sce->gm.recastData.vertsperpoly<3) + sce->gm.recastData.vertsperpoly = 6; + if (sce->gm.recastData.detailsampledist == 0.0f) + sce->gm.recastData.detailsampledist = 6.0f; + if (sce->gm.recastData.detailsamplemaxerror == 0.0f) + sce->gm.recastData.detailsamplemaxerror = 1.0f; + } + } + } + + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ + /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ + + /* don't forget to set version number in blender.c! */ +} diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c new file mode 100644 index 00000000000..fc238204251 --- /dev/null +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -0,0 +1,3570 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/blenloader/intern/readfile_pre250.c + * \ingroup blenloader + */ + + +//#include "zlib.h" + +#include +//#include // for printf fopen fwrite fclose sprintf FILE +//#include // for getenv atoi +//#include // for offsetof +//#include // for open +//#include // for strrchr strncmp strstr +//#include // for fabs +//#include /* for va_start/end */ + +#ifndef WIN32 +# include // for read close +#else +# include // for open close read +# include "winsock2.h" +# include "BLI_winstuff.h" +#endif + +/* allow readfile to use deprecated functionality */ +#define DNA_DEPRECATED_ALLOW + +#include "DNA_armature_types.h" +#include "DNA_actuator_types.h" +#include "DNA_camera_types.h" +#include "DNA_constraint_types.h" +#include "DNA_effect_types.h" +#include "DNA_group_types.h" +#include "DNA_key_types.h" +#include "DNA_lattice_types.h" +#include "DNA_lamp_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_nla_types.h" +#include "DNA_node_types.h" +#include "DNA_object_fluidsim.h" // NT +#include "DNA_object_types.h" +#include "DNA_property_types.h" +#include "DNA_view3d_types.h" +#include "DNA_screen_types.h" +#include "DNA_sensor_types.h" +#include "DNA_sdna_types.h" +#include "DNA_sequence_types.h" +#include "DNA_sound_types.h" +#include "DNA_space_types.h" +#include "DNA_vfont_types.h" +#include "DNA_world_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_edgehash.h" + +#include "BKE_armature.h" +#include "BKE_colortools.h" +#include "BKE_constraint.h" +#include "BKE_deform.h" +#include "BKE_fcurve.h" +#include "BKE_global.h" // for G +#include "BKE_image.h" +#include "BKE_lattice.h" +#include "BKE_main.h" // for Main +#include "BKE_mesh.h" // for ME_ defines (patching) +#include "BKE_modifier.h" +#include "BKE_particle.h" +#include "BKE_pointcache.h" +#include "BKE_property.h" // for get_ob_property +#include "BKE_scene.h" +#include "BKE_sequencer.h" +#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND + +#include "IMB_imbuf.h" // for proxy / timecode versioning stuff + +#include "NOD_socket.h" + +//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes +//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie +//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo +#include "BLO_readfile.h" +#include "BLO_undofile.h" + +#include "RE_engine.h" + +#include "readfile.h" + +#include "PIL_time.h" + +#include + +static void vcol_to_fcol(Mesh *me) +{ + MFace *mface; + unsigned int *mcol, *mcoln, *mcolmain; + int a; + + if (me->totface==0 || me->mcol==NULL) return; + + mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln"); + mcol = (unsigned int *)me->mcol; + mface= me->mface; + for (a=me->totface; a>0; a--, mface++) { + mcoln[0]= mcol[mface->v1]; + mcoln[1]= mcol[mface->v2]; + mcoln[2]= mcol[mface->v3]; + mcoln[3]= mcol[mface->v4]; + mcoln+= 4; + } + + MEM_freeN(me->mcol); + me->mcol= (MCol *)mcolmain; +} + +static int map_223_keybd_code_to_224_keybd_code(int code) +{ + switch (code) { + case 312: return 311; /* F12KEY */ + case 159: return 161; /* PADSLASHKEY */ + case 161: return 150; /* PAD0 */ + case 154: return 151; /* PAD1 */ + case 150: return 152; /* PAD2 */ + case 155: return 153; /* PAD3 */ + case 151: return 154; /* PAD4 */ + case 156: return 155; /* PAD5 */ + case 152: return 156; /* PAD6 */ + case 157: return 157; /* PAD7 */ + case 153: return 158; /* PAD8 */ + case 158: return 159; /* PAD9 */ + default: return code; + } +} + +static void do_version_bone_head_tail_237(Bone *bone) +{ + Bone *child; + float vec[3]; + + /* head */ + copy_v3_v3(bone->arm_head, bone->arm_mat[3]); + + /* tail is in current local coord system */ + copy_v3_v3(vec, bone->arm_mat[1]); + mul_v3_fl(vec, bone->length); + add_v3_v3v3(bone->arm_tail, bone->arm_head, vec); + + for (child= bone->childbase.first; child; child= child->next) + do_version_bone_head_tail_237(child); +} + +static void bone_version_238(ListBase *lb) +{ + Bone *bone; + + for (bone= lb->first; bone; bone= bone->next) { + if (bone->rad_tail==0.0f && bone->rad_head==0.0f) { + bone->rad_head= 0.25f*bone->length; + bone->rad_tail= 0.1f*bone->length; + + bone->dist-= bone->rad_head; + if (bone->dist<=0.0f) bone->dist= 0.0f; + } + bone_version_238(&bone->childbase); + } +} + +static void bone_version_239(ListBase *lb) +{ + Bone *bone; + + for (bone= lb->first; bone; bone= bone->next) { + if (bone->layer==0) + bone->layer= 1; + bone_version_239(&bone->childbase); + } +} + +static void ntree_version_241(bNodeTree *ntree) +{ + bNode *node; + + if (ntree->type==NTREE_COMPOSIT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_BLUR) { + if (node->storage==NULL) { + NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch"); + nbd->sizex= node->custom1; + nbd->sizey= node->custom2; + nbd->filtertype= R_FILTER_QUAD; + node->storage= nbd; + } + } + else if (node->type==CMP_NODE_VECBLUR) { + if (node->storage==NULL) { + NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch"); + nbd->samples= node->custom1; + nbd->maxspeed= node->custom2; + nbd->fac= 1.0f; + node->storage= nbd; + } + } + } + } +} + +static void ntree_version_242(bNodeTree *ntree) +{ + bNode *node; + + if (ntree->type==NTREE_COMPOSIT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_HUE_SAT) { + if (node->storage) { + NodeHueSat *nhs= node->storage; + if (nhs->val==0.0f) nhs->val= 1.0f; + } + } + } + } + else if (ntree->type==NTREE_SHADER) { + for (node= ntree->nodes.first; node; node= node->next) + if (node->type == SH_NODE_GEOMETRY && node->storage == NULL) + node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); + } + +} + +static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) +{ + bNode *node; + NodeTwoFloats *ntf; + ID *nodeid; + Image *image; + ImageUser *iuser; + + if (ntree->type==NTREE_COMPOSIT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type == CMP_NODE_ALPHAOVER) { + if (!node->storage) { + ntf= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); + node->storage= ntf; + if (node->custom1) + ntf->x= 1.0f; + } + } + + /* fix for temporary flag changes during 245 cycle */ + nodeid= blo_do_versions_newlibadr(fd, lib, node->id); + if (node->storage && nodeid && GS(nodeid->name) == ID_IM) { + image= (Image*)nodeid; + iuser= node->storage; + if (iuser->flag & IMA_OLD_PREMUL) { + iuser->flag &= ~IMA_OLD_PREMUL; + iuser->flag |= IMA_DO_PREMUL; + } + if (iuser->flag & IMA_DO_PREMUL) { + image->flag &= ~IMA_OLD_PREMUL; + image->flag |= IMA_DO_PREMUL; + } + } + } + } +} + +static void idproperties_fix_groups_lengths_recurse(IDProperty *prop) +{ + IDProperty *loop; + int i; + + for (loop=prop->data.group.first, i=0; loop; loop=loop->next, i++) { + if (loop->type == IDP_GROUP) idproperties_fix_groups_lengths_recurse(loop); + } + + if (prop->len != i) { + printf("Found and fixed bad id property group length.\n"); + prop->len = i; + } +} + +static void idproperties_fix_group_lengths(ListBase idlist) +{ + ID *id; + + for (id=idlist.first; id; id=id->next) { + if (id->properties) { + idproperties_fix_groups_lengths_recurse(id->properties); + } + } +} + +static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) +{ + Material *ma; + MFace *mf; + MTFace *tf; + int a, b, texalpha; + + /* verify we have a tface layer */ + for (b=0; bfdata.totlayer; b++) + if (me->fdata.layers[b].type == CD_MTFACE) + break; + + if (b == me->fdata.totlayer) + return; + + /* if we do, set alpha sort if the game engine did it before */ + for (a=0, mf=me->mface; atotface; a++, mf++) { + if (mf->mat_nr < me->totcol) { + ma= blo_do_versions_newlibadr(fd, lib, me->mat[mf->mat_nr]); + texalpha = 0; + + /* we can't read from this if it comes from a library, + * because direct_link might not have happened on it, + * so ma->mtex is not pointing to valid memory yet */ + if (ma && ma->id.lib) + ma= NULL; + + for (b=0; ma && bmtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA) + texalpha = 1; + } + else { + ma= NULL; + texalpha = 0; + } + + for (b=0; bfdata.totlayer; b++) { + if (me->fdata.layers[b].type == CD_MTFACE) { + tf = ((MTFace*)me->fdata.layers[b].data) + a; + + tf->mode &= ~TF_ALPHASORT; + if (ma && (ma->mode & MA_ZTRANSP)) + if (ELEM(tf->transp, TF_ALPHA, TF_ADD) || (texalpha && (tf->transp != TF_CLIP))) + tf->mode |= TF_ALPHASORT; + } + } + } +} + +static void customdata_version_242(Mesh *me) +{ + CustomDataLayer *layer; + MTFace *mtf; + MCol *mcol; + TFace *tf; + int a, mtfacen, mcoln; + + if (!me->vdata.totlayer) { + CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, me->mvert, me->totvert); + + if (me->msticky) + CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_ASSIGN, me->msticky, me->totvert); + if (me->dvert) + CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_ASSIGN, me->dvert, me->totvert); + } + + if (!me->edata.totlayer) + CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge); + + if (!me->fdata.totlayer) { + CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface); + + if (me->tface) { + if (me->mcol) + MEM_freeN(me->mcol); + + me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface); + me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface); + + mtf= me->mtface; + mcol= me->mcol; + tf= me->tface; + + for (a=0; a < me->totface; a++, mtf++, tf++, mcol+=4) { + memcpy(mcol, tf->col, sizeof(tf->col)); + memcpy(mtf->uv, tf->uv, sizeof(tf->uv)); + + mtf->flag= tf->flag; + mtf->unwrap= tf->unwrap; + mtf->mode= tf->mode; + mtf->tile= tf->tile; + mtf->tpage= tf->tpage; + mtf->transp= tf->transp; + } + + MEM_freeN(me->tface); + me->tface= NULL; + } + else if (me->mcol) { + me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface); + } + } + + if (me->tface) { + MEM_freeN(me->tface); + me->tface= NULL; + } + + for (a=0, mtfacen=0, mcoln=0; a < me->fdata.totlayer; a++) { + layer= &me->fdata.layers[a]; + + if (layer->type == CD_MTFACE) { + if (layer->name[0] == 0) { + if (mtfacen == 0) strcpy(layer->name, "UVMap"); + else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen); + } + mtfacen++; + } + else if (layer->type == CD_MCOL) { + if (layer->name[0] == 0) { + if (mcoln == 0) strcpy(layer->name, "Col"); + else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); + } + mcoln++; + } + } + + mesh_update_customdata_pointers(me, TRUE); +} + +/*only copy render texface layer from active*/ +static void customdata_version_243(Mesh *me) +{ + CustomDataLayer *layer; + int a; + + for (a=0; a < me->fdata.totlayer; a++) { + layer= &me->fdata.layers[a]; + layer->active_rnd = layer->active; + } +} + +/* struct NodeImageAnim moved to ImageUser, and we make it default available */ +static void do_version_ntree_242_2(bNodeTree *ntree) +{ + bNode *node; + + if (ntree->type==NTREE_COMPOSIT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + /* only image had storage */ + if (node->storage) { + NodeImageAnim *nia= node->storage; + ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "ima user node"); + + iuser->frames= nia->frames; + iuser->sfra= nia->sfra; + iuser->offset= nia->nr-1; + iuser->cycl= nia->cyclic; + iuser->fie_ima= 2; + iuser->ok= 1; + + node->storage= iuser; + MEM_freeN(nia); + } + else { + ImageUser *iuser= node->storage= MEM_callocN(sizeof(ImageUser), "node image user"); + iuser->sfra= 1; + iuser->fie_ima= 2; + iuser->ok= 1; + } + } + } + } +} + +static void do_version_free_effect_245(Effect *eff) +{ + PartEff *paf; + + if (eff->type==EFF_PARTICLE) { + paf= (PartEff *)eff; + if (paf->keys) MEM_freeN(paf->keys); + } + MEM_freeN(eff); +} + +static void do_version_free_effects_245(ListBase *lb) +{ + Effect *eff; + + eff= lb->first; + while (eff) { + BLI_remlink(lb, eff); + do_version_free_effect_245(eff); + eff= lb->first; + } +} + +PartEff *blo_do_version_give_parteff_245(Object *ob) +{ + PartEff *paf; + + paf= ob->effect.first; + while (paf) { + if (paf->type==EFF_PARTICLE) return paf; + paf= paf->next; + } + return NULL; +} + +/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */ +void blo_do_version_old_trackto_to_constraints(Object *ob) +{ + /* create new trackto constraint from the relationship */ + if (ob->track) { + bConstraint *con= add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); + bTrackToConstraint *data = con->data; + + /* copy tracking settings from the object */ + data->tar = ob->track; + data->reserved1 = ob->trackflag; + data->reserved2 = ob->upflag; + } + + /* clear old track setting */ + ob->track = NULL; +} + +void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) +{ + /* WATCH IT!!!: pointers from libdata have not been converted */ + + if (G.debug & G_DEBUG) + printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); + + if (main->versionfile == 100) { + /* tex->extend and tex->imageflag have changed: */ + Tex *tex = main->tex.first; + while (tex) { + if (tex->id.flag & LIB_NEEDLINK) { + + if (tex->extend==0) { + if (tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT; + else { + tex->extend= TEX_EXTEND; + tex->xrepeat= tex->yrepeat= 1; + } + } + + } + tex= tex->id.next; + } + } + if (main->versionfile <= 101) { + /* frame mapping */ + Scene *sce = main->scene.first; + while (sce) { + sce->r.framapto= 100; + sce->r.images= 100; + sce->r.framelen= 1.0; + sce= sce->id.next; + } + } + if (main->versionfile <= 102) { + /* init halo's at 1.0 */ + Material *ma = main->mat.first; + while (ma) { + ma->add= 1.0; + ma= ma->id.next; + } + } + if (main->versionfile <= 103) { + /* new variable in object: colbits */ + Object *ob = main->object.first; + int a; + while (ob) { + ob->colbits= 0; + if (ob->totcol) { + for (a=0; atotcol; a++) { + if (ob->mat[a]) ob->colbits |= (1<id.next; + } + } + if (main->versionfile <= 104) { + /* timeoffs moved */ + Object *ob = main->object.first; + while (ob) { + if (ob->transflag & 1) { + ob->transflag -= 1; + //ob->ipoflag |= OB_OFFS_OB; + } + ob= ob->id.next; + } + } + if (main->versionfile <= 105) { + Object *ob = main->object.first; + while (ob) { + ob->dupon= 1; ob->dupoff= 0; + ob->dupsta= 1; ob->dupend= 100; + ob= ob->id.next; + } + } + if (main->versionfile <= 106) { + /* mcol changed */ + Mesh *me = main->mesh.first; + while (me) { + if (me->mcol) vcol_to_fcol(me); + me= me->id.next; + } + + } + if (main->versionfile <= 107) { + Object *ob; + Scene *sce = main->scene.first; + while (sce) { + sce->r.mode |= R_GAMMA; + sce= sce->id.next; + } + ob= main->object.first; + while (ob) { + //ob->ipoflag |= OB_OFFS_PARENT; + if (ob->dt==0) ob->dt= OB_SOLID; + ob= ob->id.next; + } + + } + if (main->versionfile <= 109) { + /* new variable: gridlines */ + bScreen *sc = main->screen.first; + while (sc) { + ScrArea *sa= sc->areabase.first; + while (sa) { + SpaceLink *sl= sa->spacedata.first; + while (sl) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D*) sl; + + if (v3d->gridlines==0) v3d->gridlines= 20; + } + sl= sl->next; + } + sa= sa->next; + } + sc= sc->id.next; + } + } + if (main->versionfile <= 113) { + Material *ma = main->mat.first; + while (ma) { + if (ma->flaresize==0.0f) ma->flaresize= 1.0f; + ma->subsize= 1.0f; + ma->flareboost= 1.0f; + ma= ma->id.next; + } + } + + if (main->versionfile <= 134) { + Tex *tex = main->tex.first; + while (tex) { + if ((tex->rfac == 0.0f) && + (tex->gfac == 0.0f) && + (tex->bfac == 0.0f)) { + tex->rfac = 1.0f; + tex->gfac = 1.0f; + tex->bfac = 1.0f; + tex->filtersize = 1.0f; + } + tex = tex->id.next; + } + } + if (main->versionfile <= 140) { + /* r-g-b-fac in texture */ + Tex *tex = main->tex.first; + while (tex) { + if ((tex->rfac == 0.0f) && + (tex->gfac == 0.0f) && + (tex->bfac == 0.0f)) { + tex->rfac = 1.0f; + tex->gfac = 1.0f; + tex->bfac = 1.0f; + tex->filtersize = 1.0f; + } + tex = tex->id.next; + } + } + if (main->versionfile <= 153) { + Scene *sce = main->scene.first; + while (sce) { + if (sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f; + sce= sce->id.next; + } + } + if (main->versionfile <= 163) { + Scene *sce = main->scene.first; + while (sce) { + if (sce->r.frs_sec==0) sce->r.frs_sec= 25; + sce= sce->id.next; + } + } + if (main->versionfile <= 164) { + Mesh *me= main->mesh.first; + while (me) { + me->smoothresh= 30; + me= me->id.next; + } + } + if (main->versionfile <= 165) { + Mesh *me= main->mesh.first; + TFace *tface; + int nr; + char *cp; + + while (me) { + if (me->tface) { + nr= me->totface; + tface= me->tface; + while (nr--) { + cp= (char *)&tface->col[0]; + if (cp[1]>126) cp[1]= 255; else cp[1]*=2; + if (cp[2]>126) cp[2]= 255; else cp[2]*=2; + if (cp[3]>126) cp[3]= 255; else cp[3]*=2; + cp= (char *)&tface->col[1]; + if (cp[1]>126) cp[1]= 255; else cp[1]*=2; + if (cp[2]>126) cp[2]= 255; else cp[2]*=2; + if (cp[3]>126) cp[3]= 255; else cp[3]*=2; + cp= (char *)&tface->col[2]; + if (cp[1]>126) cp[1]= 255; else cp[1]*=2; + if (cp[2]>126) cp[2]= 255; else cp[2]*=2; + if (cp[3]>126) cp[3]= 255; else cp[3]*=2; + cp= (char *)&tface->col[3]; + if (cp[1]>126) cp[1]= 255; else cp[1]*=2; + if (cp[2]>126) cp[2]= 255; else cp[2]*=2; + if (cp[3]>126) cp[3]= 255; else cp[3]*=2; + + tface++; + } + } + me= me->id.next; + } + } + + if (main->versionfile <= 169) { + Mesh *me= main->mesh.first; + while (me) { + if (me->subdiv==0) me->subdiv= 1; + me= me->id.next; + } + } + + if (main->versionfile <= 169) { + bScreen *sc= main->screen.first; + while (sc) { + ScrArea *sa= sc->areabase.first; + while (sa) { + SpaceLink *sl= sa->spacedata.first; + while (sl) { + if (sl->spacetype==SPACE_IPO) { + SpaceIpo *sipo= (SpaceIpo*) sl; + sipo->v2d.max[0]= 15000.0; + } + sl= sl->next; + } + sa= sa->next; + } + sc= sc->id.next; + } + } + + if (main->versionfile <= 170) { + Object *ob = main->object.first; + PartEff *paf; + while (ob) { + paf = blo_do_version_give_parteff_245(ob); + if (paf) { + if (paf->staticstep == 0) { + paf->staticstep= 5; + } + } + ob = ob->id.next; + } + } + + if (main->versionfile <= 171) { + bScreen *sc= main->screen.first; + while (sc) { + ScrArea *sa= sc->areabase.first; + while (sa) { + SpaceLink *sl= sa->spacedata.first; + while (sl) { + if (sl->spacetype==SPACE_TEXT) { + SpaceText *st= (SpaceText*) sl; + st->lheight= 12; + } + sl= sl->next; + } + sa= sa->next; + } + sc= sc->id.next; + } + } + + if (main->versionfile <= 173) { + int a, b; + Mesh *me= main->mesh.first; + while (me) { + if (me->tface) { + TFace *tface= me->tface; + for (a=0; atotface; a++, tface++) { + for (b=0; b<4; b++) { + tface->uv[b][0]/= 32767.0f; + tface->uv[b][1]/= 32767.0f; + } + } + } + me= me->id.next; + } + } + + if (main->versionfile <= 191) { + Object *ob= main->object.first; + Material *ma = main->mat.first; + + /* let faces have default add factor of 0.0 */ + while (ma) { + if (!(ma->mode & MA_HALO)) ma->add = 0.0; + ma = ma->id.next; + } + + while (ob) { + ob->mass= 1.0f; + ob->damping= 0.1f; + /*ob->quat[1]= 1.0f;*/ /* quats arnt used yet */ + ob= ob->id.next; + } + } + + if (main->versionfile <= 193) { + Object *ob= main->object.first; + while (ob) { + ob->inertia= 1.0f; + ob->rdamping= 0.1f; + ob= ob->id.next; + } + } + + if (main->versionfile <= 196) { + Mesh *me= main->mesh.first; + int a, b; + while (me) { + if (me->tface) { + TFace *tface= me->tface; + for (a=0; atotface; a++, tface++) { + for (b=0; b<4; b++) { + tface->mode |= TF_DYNAMIC; + tface->mode &= ~TF_INVISIBLE; + } + } + } + me= me->id.next; + } + } + + if (main->versionfile <= 200) { + Object *ob= main->object.first; + while (ob) { + ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); + /* 64 is do_fh */ + ob->gameflag &= ~(OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); + ob = ob->id.next; + } + } + + if (main->versionfile <= 201) { + /* add-object + end-object are joined to edit-object actuator */ + Object *ob = main->object.first; + bProperty *prop; + bActuator *act; + bIpoActuator *ia; + bEditObjectActuator *eoa; + bAddObjectActuator *aoa; + while (ob) { + act = ob->actuators.first; + while (act) { + if (act->type==ACT_IPO) { + ia= act->data; + prop= get_ob_property(ob, ia->name); + if (prop) { + ia->type= ACT_IPO_FROM_PROP; + } + } + else if (act->type==ACT_ADD_OBJECT) { + aoa= act->data; + eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); + eoa->type= ACT_EDOB_ADD_OBJECT; + eoa->ob= aoa->ob; + eoa->time= aoa->time; + MEM_freeN(aoa); + act->data= eoa; + act->type= act->otype= ACT_EDIT_OBJECT; + } + else if (act->type==ACT_END_OBJECT) { + eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); + eoa->type= ACT_EDOB_END_OBJECT; + act->data= eoa; + act->type= act->otype= ACT_EDIT_OBJECT; + } + act= act->next; + } + ob = ob->id.next; + } + } + + if (main->versionfile <= 202) { + /* add-object and end-object are joined to edit-object + * actuator */ + Object *ob= main->object.first; + bActuator *act; + bObjectActuator *oa; + while (ob) { + act= ob->actuators.first; + while (act) { + if (act->type==ACT_OBJECT) { + oa= act->data; + oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL); /* this actuator didn't do local/glob rot before */ + } + act= act->next; + } + ob= ob->id.next; + } + } + + if (main->versionfile <= 204) { + /* patches for new physics */ + Object *ob= main->object.first; + bActuator *act; + bObjectActuator *oa; + bSound *sound; + while (ob) { + + /* please check this for demo20 files like + * original Egypt levels etc. converted + * rotation factor of 50 is not workable */ + act= ob->actuators.first; + while (act) { + if (act->type==ACT_OBJECT) { + oa= act->data; + + oa->forceloc[0]*= 25.0f; + oa->forceloc[1]*= 25.0f; + oa->forceloc[2]*= 25.0f; + + oa->forcerot[0]*= 10.0f; + oa->forcerot[1]*= 10.0f; + oa->forcerot[2]*= 10.0f; + } + act= act->next; + } + ob= ob->id.next; + } + + sound = main->sound.first; + while (sound) { + if (sound->volume < 0.01f) { + sound->volume = 1.0f; + } + sound = sound->id.next; + } + } + + if (main->versionfile <= 205) { + /* patches for new physics */ + Object *ob= main->object.first; + bActuator *act; + bSensor *sens; + bEditObjectActuator *oa; + bRaySensor *rs; + bCollisionSensor *cs; + while (ob) { + /* Set anisotropic friction off for old objects, + * values to 1.0. */ + ob->gameflag &= ~OB_ANISOTROPIC_FRICTION; + ob->anisotropicFriction[0] = 1.0; + ob->anisotropicFriction[1] = 1.0; + ob->anisotropicFriction[2] = 1.0; + + act= ob->actuators.first; + while (act) { + if (act->type==ACT_EDIT_OBJECT) { + /* Zero initial velocity for newly + * added objects */ + oa= act->data; + oa->linVelocity[0] = 0.0; + oa->linVelocity[1] = 0.0; + oa->linVelocity[2] = 0.0; + oa->localflag = 0; + } + act= act->next; + } + + sens= ob->sensors.first; + while (sens) { + /* Extra fields for radar sensors. */ + if (sens->type == SENS_RADAR) { + bRadarSensor *s = sens->data; + s->range = 10000.0; + } + + /* Pulsing: defaults for new sensors. */ + if (sens->type != SENS_ALWAYS) { + sens->pulse = 0; + sens->freq = 0; + } + else { + sens->pulse = 1; + } + + /* Invert: off. */ + sens->invert = 0; + + /* Collision and ray: default = trigger + * on property. The material field can + * remain empty. */ + if (sens->type == SENS_COLLISION) { + cs = (bCollisionSensor*) sens->data; + cs->mode = 0; + } + if (sens->type == SENS_RAY) { + rs = (bRaySensor*) sens->data; + rs->mode = 0; + } + sens = sens->next; + } + ob= ob->id.next; + } + /* have to check the exact multiplier */ + } + + if (main->versionfile <= 211) { + /* Render setting: per scene, the applicable gamma value + * can be set. Default is 1.0, which means no + * correction. */ + bActuator *act; + bObjectActuator *oa; + Object *ob; + + /* added alpha in obcolor */ + ob= main->object.first; + while (ob) { + ob->col[3]= 1.0; + ob= ob->id.next; + } + + /* added alpha in obcolor */ + ob= main->object.first; + while (ob) { + act= ob->actuators.first; + while (act) { + if (act->type==ACT_OBJECT) { + /* multiply velocity with 50 in old files */ + oa= act->data; + if (fabsf(oa->linearvelocity[0]) >= 0.01f) + oa->linearvelocity[0] *= 50.0f; + if (fabsf(oa->linearvelocity[1]) >= 0.01f) + oa->linearvelocity[1] *= 50.0f; + if (fabsf(oa->linearvelocity[2]) >= 0.01f) + oa->linearvelocity[2] *= 50.0f; + if (fabsf(oa->angularvelocity[0])>=0.01f) + oa->angularvelocity[0] *= 50.0f; + if (fabsf(oa->angularvelocity[1])>=0.01f) + oa->angularvelocity[1] *= 50.0f; + if (fabsf(oa->angularvelocity[2])>=0.01f) + oa->angularvelocity[2] *= 50.0f; + } + act= act->next; + } + ob= ob->id.next; + } + } + + if (main->versionfile <= 212) { + + bSound* sound; + bProperty *prop; + Object *ob; + Mesh *me; + + sound = main->sound.first; + while (sound) { + sound->max_gain = 1.0; + sound->min_gain = 0.0; + sound->distance = 1.0; + + if (sound->attenuation > 0.0f) + sound->flags |= SOUND_FLAGS_3D; + else + sound->flags &= ~SOUND_FLAGS_3D; + + sound = sound->id.next; + } + + ob = main->object.first; + + while (ob) { + prop= ob->prop.first; + while (prop) { + if (prop->type == GPROP_TIME) { + // convert old GPROP_TIME values from int to float + *((float *)&prop->data) = (float) prop->data; + } + + prop= prop->next; + } + ob = ob->id.next; + } + + /* me->subdiv changed to reflect the actual reparametization + * better, and smeshes were removed - if it was a smesh make + * it a subsurf, and reset the subdiv level because subsurf + * takes a lot more work to calculate. + */ + for (me= main->mesh.first; me; me= me->id.next) { + if (me->flag&ME_SMESH) { + me->flag&= ~ME_SMESH; + me->flag|= ME_SUBSURF; + + me->subdiv= 1; + } + else { + if (me->subdiv<2) + me->subdiv= 1; + else + me->subdiv--; + } + } + } + + if (main->versionfile <= 220) { + Object *ob; + Mesh *me; + + ob = main->object.first; + + /* adapt form factor in order to get the 'old' physics + * behavior back...*/ + + while (ob) { + /* in future, distinguish between different + * object bounding shapes */ + ob->formfactor = 0.4f; + /* patch form factor, note that inertia equiv radius + * of a rotation symmetrical obj */ + if (ob->inertia != 1.0f) { + ob->formfactor /= ob->inertia * ob->inertia; + } + ob = ob->id.next; + } + + /* Began using alpha component of vertex colors, but + * old file vertex colors are undefined, reset them + * to be fully opaque. -zr + */ + for (me= main->mesh.first; me; me= me->id.next) { + if (me->mcol) { + int i; + + for (i=0; itotface*4; i++) { + MCol *mcol= &me->mcol[i]; + mcol->a= 255; + } + } + if (me->tface) { + int i, j; + + for (i=0; itotface; i++) { + TFace *tf= &((TFace*) me->tface)[i]; + + for (j=0; j<4; j++) { + char *col= (char*) &tf->col[j]; + + col[0]= 255; + } + } + } + } + } + if (main->versionfile <= 221) { + Scene *sce= main->scene.first; + + // new variables for std-alone player and runtime + while (sce) { + + sce->r.xplay= 640; + sce->r.yplay= 480; + sce->r.freqplay= 60; + + sce= sce->id.next; + } + + } + if (main->versionfile <= 222) { + Scene *sce= main->scene.first; + + // new variables for std-alone player and runtime + while (sce) { + + sce->r.depth= 32; + + sce= sce->id.next; + } + } + + + if (main->versionfile <= 223) { + VFont *vf; + Image *ima; + Object *ob; + + for (vf= main->vfont.first; vf; vf= vf->id.next) { + if (strcmp(vf->name+strlen(vf->name)-6, ".Bfont")==0) { + strcpy(vf->name, FO_BUILTIN_NAME); + } + } + + /* Old textures animate at 25 FPS */ + for (ima = main->image.first; ima; ima=ima->id.next) { + ima->animspeed = 25; + } + + /* Zr remapped some keyboard codes to be linear (stupid zr) */ + for (ob= main->object.first; ob; ob= ob->id.next) { + bSensor *sens; + + for (sens= ob->sensors.first; sens; sens= sens->next) { + if (sens->type==SENS_KEYBOARD) { + bKeyboardSensor *ks= sens->data; + + ks->key= map_223_keybd_code_to_224_keybd_code(ks->key); + ks->qual= map_223_keybd_code_to_224_keybd_code(ks->qual); + ks->qual2= map_223_keybd_code_to_224_keybd_code(ks->qual2); + } + } + } + } + if (main->versionfile <= 224) { + bSound* sound; + Scene *sce; + Mesh *me; + bScreen *sc; + + for (sound=main->sound.first; sound; sound=sound->id.next) { + if (sound->packedfile) { + if (sound->newpackedfile == NULL) { + sound->newpackedfile = sound->packedfile; + } + sound->packedfile = NULL; + } + } + /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */ + for (me=main->mesh.first; me; me=me->id.next) { + if ((me->flag & ME_SUBSURF) && (me->subdivr==0)) + me->subdivr=me->subdiv; + } + + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->r.stereomode = 1; // no stereo + } + + /* some oldfile patch, moved from set_func_space */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_IPO) { + SpaceSeq *sseq= (SpaceSeq*) sl; + sseq->v2d.keeptot= 0; + } + } + } + } + + } + + + if (main->versionfile <= 225) { + World *wo; + /* Use Sumo for old games */ + for (wo = main->world.first; wo; wo= wo->id.next) { + wo->physicsEngine = 2; + } + } + + if (main->versionfile <= 227) { + Scene *sce; + Material *ma; + bScreen *sc; + Object *ob; + + /* As of now, this insures that the transition from the old Track system + * to the new full constraint Track is painless for everyone. - theeth + */ + ob = main->object.first; + + while (ob) { + ListBase *list; + list = &ob->constraints; + + /* check for already existing TrackTo constraint + * set their track and up flag correctly */ + + if (list) { + bConstraint *curcon; + for (curcon = list->first; curcon; curcon=curcon->next) { + if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { + bTrackToConstraint *data = curcon->data; + data->reserved1 = ob->trackflag; + data->reserved2 = ob->upflag; + } + } + } + + if (ob->type == OB_ARMATURE) { + if (ob->pose) { + bConstraint *curcon; + bPoseChannel *pchan; + for (pchan = ob->pose->chanbase.first; + pchan; pchan=pchan->next) { + for (curcon = pchan->constraints.first; + curcon; curcon=curcon->next) { + if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { + bTrackToConstraint *data = curcon->data; + data->reserved1 = ob->trackflag; + data->reserved2 = ob->upflag; + } + } + } + } + } + + /* Change Ob->Track in real TrackTo constraint */ + blo_do_version_old_trackto_to_constraints(ob); + + ob = ob->id.next; + } + + + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->audio.mixrate = 44100; + sce->audio.flag |= AUDIO_SCRUB; + sce->r.mode |= R_ENVMAP; + } + // init new shader vars + for (ma= main->mat.first; ma; ma= ma->id.next) { + ma->refrac= 4.0f; + ma->roughness= 0.5f; + ma->param[0]= 0.5f; + ma->param[1]= 0.1f; + ma->param[2]= 0.1f; + ma->param[3]= 0.05f; + } + // patch for old wrong max view2d settings, allows zooming out more + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_ACTION) { + SpaceAction *sac= (SpaceAction *) sl; + sac->v2d.max[0]= 32000; + } + else if (sl->spacetype==SPACE_NLA) { + SpaceNla *sla= (SpaceNla *) sl; + sla->v2d.max[0]= 32000; + } + } + } + } + } + if (main->versionfile <= 228) { + Scene *sce; + bScreen *sc; + Object *ob; + + + /* As of now, this insures that the transition from the old Track system + * to the new full constraint Track is painless for everyone.*/ + ob = main->object.first; + + while (ob) { + ListBase *list; + list = &ob->constraints; + + /* check for already existing TrackTo constraint + * set their track and up flag correctly */ + + if (list) { + bConstraint *curcon; + for (curcon = list->first; curcon; curcon=curcon->next) { + if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { + bTrackToConstraint *data = curcon->data; + data->reserved1 = ob->trackflag; + data->reserved2 = ob->upflag; + } + } + } + + if (ob->type == OB_ARMATURE) { + if (ob->pose) { + bConstraint *curcon; + bPoseChannel *pchan; + for (pchan = ob->pose->chanbase.first; + pchan; pchan=pchan->next) { + for (curcon = pchan->constraints.first; + curcon; curcon=curcon->next) { + if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { + bTrackToConstraint *data = curcon->data; + data->reserved1 = ob->trackflag; + data->reserved2 = ob->upflag; + } + } + } + } + } + + ob = ob->id.next; + } + + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->r.mode |= R_ENVMAP; + } + + // convert old mainb values for new button panels + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_BUTS) { + SpaceButs *sbuts= (SpaceButs *) sl; + + sbuts->v2d.maxzoom= 1.2f; + sbuts->align= 1; /* horizontal default */ + + if (sbuts->mainb==BUTS_LAMP) { + sbuts->mainb= CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP; + } + else if (sbuts->mainb==BUTS_MAT) { + sbuts->mainb= CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT; + } + else if (sbuts->mainb==BUTS_TEX) { + sbuts->mainb= CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX; + } + else if (sbuts->mainb==BUTS_ANIM) { + sbuts->mainb= CONTEXT_OBJECT; + } + else if (sbuts->mainb==BUTS_WORLD) { + sbuts->mainb= CONTEXT_SCENE; + //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD; + } + else if (sbuts->mainb==BUTS_RENDER) { + sbuts->mainb= CONTEXT_SCENE; + //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER; + } + else if (sbuts->mainb==BUTS_GAME) { + sbuts->mainb= CONTEXT_LOGIC; + } + else if (sbuts->mainb==BUTS_FPAINT) { + sbuts->mainb= CONTEXT_EDITING; + } + else if (sbuts->mainb==BUTS_RADIO) { + sbuts->mainb= CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD; + } + else if (sbuts->mainb==BUTS_CONSTRAINT) { + sbuts->mainb= CONTEXT_OBJECT; + } + else if (sbuts->mainb==BUTS_SCRIPT) { + sbuts->mainb= CONTEXT_OBJECT; + } + else if (sbuts->mainb==BUTS_EDIT) { + sbuts->mainb= CONTEXT_EDITING; + } + else sbuts->mainb= CONTEXT_SCENE; + } + } + } + } + } + /* ton: made this 230 instead of 229, + * to be sure (tuho files) and this is a reliable check anyway + * nevertheless, we might need to think over a fitness (initialize) + * check apart from the do_versions() */ + + if (main->versionfile <= 230) { + bScreen *sc; + + // new variable blockscale, for panels in any area + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->blockscale==0.0f) sl->blockscale= 0.7f; + /* added: 5x better zoom in for action */ + if (sl->spacetype==SPACE_ACTION) { + SpaceAction *sac= (SpaceAction *)sl; + sac->v2d.maxzoom= 50; + } + } + } + } + } + if (main->versionfile <= 231) { + /* new bit flags for showing/hiding grid floor and axes */ + bScreen *sc = main->screen.first; + while (sc) { + ScrArea *sa= sc->areabase.first; + while (sa) { + SpaceLink *sl= sa->spacedata.first; + while (sl) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D*) sl; + + if (v3d->gridflag==0) { + v3d->gridflag |= V3D_SHOW_X; + v3d->gridflag |= V3D_SHOW_Y; + v3d->gridflag |= V3D_SHOW_FLOOR; + v3d->gridflag &= ~V3D_SHOW_Z; + } + } + sl= sl->next; + } + sa= sa->next; + } + sc= sc->id.next; + } + } + if (main->versionfile <= 231) { + Material *ma= main->mat.first; + bScreen *sc = main->screen.first; + Scene *sce; + Lamp *la; + World *wrld; + + /* introduction of raytrace */ + while (ma) { + if (ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f; + if (ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f; + + ma->ang= 1.0; + ma->ray_depth= 2; + ma->ray_depth_tra= 2; + ma->fresnel_tra= 0.0; + ma->fresnel_mir= 0.0; + + ma= ma->id.next; + } + sce= main->scene.first; + while (sce) { + if (sce->r.gauss==0.0f) sce->r.gauss= 1.0f; + sce= sce->id.next; + } + la= main->lamp.first; + while (la) { + if (la->k==0.0f) la->k= 1.0; + if (la->ray_samp==0) la->ray_samp= 1; + if (la->ray_sampy==0) la->ray_sampy= 1; + if (la->ray_sampz==0) la->ray_sampz= 1; + if (la->area_size==0.0f) la->area_size= 1.0f; + if (la->area_sizey==0.0f) la->area_sizey= 1.0f; + if (la->area_sizez==0.0f) la->area_sizez= 1.0f; + la= la->id.next; + } + wrld= main->world.first; + while (wrld) { + if (wrld->range==0.0f) { + wrld->range= 1.0f/wrld->exposure; + } + wrld= wrld->id.next; + } + + /* new bit flags for showing/hiding grid floor and axes */ + + while (sc) { + ScrArea *sa= sc->areabase.first; + while (sa) { + SpaceLink *sl= sa->spacedata.first; + while (sl) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D*) sl; + + if (v3d->gridflag==0) { + v3d->gridflag |= V3D_SHOW_X; + v3d->gridflag |= V3D_SHOW_Y; + v3d->gridflag |= V3D_SHOW_FLOOR; + v3d->gridflag &= ~V3D_SHOW_Z; + } + } + sl= sl->next; + } + sa= sa->next; + } + sc= sc->id.next; + } + } + if (main->versionfile <= 232) { + Tex *tex= main->tex.first; + World *wrld= main->world.first; + bScreen *sc; + Scene *sce; + + while (tex) { + if ((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) { + tex->flag |= TEX_CHECKER_ODD; + } + /* copied from kernel texture.c */ + if (tex->ns_outscale==0.0f) { + /* musgrave */ + tex->mg_H = 1.0f; + tex->mg_lacunarity = 2.0f; + tex->mg_octaves = 2.0f; + tex->mg_offset = 1.0f; + tex->mg_gain = 1.0f; + tex->ns_outscale = 1.0f; + /* distnoise */ + tex->dist_amount = 1.0f; + /* voronoi */ + tex->vn_w1 = 1.0f; + tex->vn_mexp = 2.5f; + } + tex= tex->id.next; + } + + while (wrld) { + if (wrld->aodist==0.0f) { + wrld->aodist= 10.0f; + wrld->aobias= 0.05f; + } + if (wrld->aosamp==0) wrld->aosamp= 5; + if (wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f; + wrld= wrld->id.next; + } + + + // new variable blockscale, for panels in any area, do again because new + // areas didnt initialize it to 0.7 yet + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->blockscale==0.0f) sl->blockscale= 0.7f; + + /* added: 5x better zoom in for nla */ + if (sl->spacetype==SPACE_NLA) { + SpaceNla *snla= (SpaceNla *)sl; + snla->v2d.maxzoom= 50; + } + } + } + } + sce= main->scene.first; + while (sce) { + if (sce->r.ocres==0) sce->r.ocres= 64; + sce= sce->id.next; + } + + } + if (main->versionfile <= 233) { + bScreen *sc; + Material *ma= main->mat.first; + /* Object *ob= main->object.first; */ + + while (ma) { + if (ma->rampfac_col==0.0f) ma->rampfac_col= 1.0; + if (ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0; + if (ma->pr_lamp==0) ma->pr_lamp= 3; + ma= ma->id.next; + } + + /* this should have been done loooong before! */ +#if 0 /* deprecated in 2.5+ */ + while (ob) { + if (ob->ipowin==0) ob->ipowin= ID_OB; + ob= ob->id.next; + } +#endif + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D *)sl; + v3d->flag |= V3D_SELECT_OUTLINE; + } + } + } + } + } + + + + + if (main->versionfile <= 234) { + World *wo; + bScreen *sc; + + // force sumo engine to be active + for (wo = main->world.first; wo; wo= wo->id.next) { + if (wo->physicsEngine==0) wo->physicsEngine = 2; + } + + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D *)sl; + v3d->flag |= V3D_ZBUF_SELECT; + } + else if (sl->spacetype==SPACE_TEXT) { + SpaceText *st= (SpaceText *)sl; + if (st->tabnumber==0) st->tabnumber= 2; + } + } + } + } + } + if (main->versionfile <= 235) { + Tex *tex= main->tex.first; + Scene *sce= main->scene.first; + Sequence *seq; + Editing *ed; + + while (tex) { + if (tex->nabla==0.0f) tex->nabla= 0.025f; + tex= tex->id.next; + } + while (sce) { + ed= sce->ed; + if (ed) { + SEQ_BEGIN (sce->ed, seq) + { + if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE) + seq->flag |= SEQ_MAKE_PREMUL; + } + SEQ_END + } + + sce= sce->id.next; + } + } + if (main->versionfile <= 236) { + Object *ob; + Camera *cam= main->camera.first; + Material *ma; + bScreen *sc; + + while (cam) { + if (cam->ortho_scale==0.0f) { + cam->ortho_scale= 256.0f/cam->lens; + if (cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n"); + } + cam= cam->id.next; + } + /* set manipulator type */ + /* force oops draw if depgraph was set*/ + /* set time line var */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D *)sl; + if (v3d->twtype==0) v3d->twtype= V3D_MANIP_TRANSLATE; + } + } + } + } + // init new shader vars + for (ma= main->mat.first; ma; ma= ma->id.next) { + if (ma->darkness==0.0f) { + ma->rms=0.1f; + ma->darkness=1.0f; + } + } + + /* softbody init new vars */ + for (ob= main->object.first; ob; ob= ob->id.next) { + if (ob->soft) { + if (ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f; + if (ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f; + + if (ob->soft->interval==0) { + ob->soft->interval= 2; + ob->soft->sfra= 1; + ob->soft->efra= 100; + } + } + if (ob->soft && ob->soft->vertgroup==0) { + bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL"); + if (locGroup) { + /* retrieve index for that group */ + ob->soft->vertgroup = 1 + BLI_findindex(&ob->defbase, locGroup); + } + } + } + } + if (main->versionfile <= 237) { + bArmature *arm; + bConstraint *con; + Object *ob; + Bone *bone; + + // armature recode checks + for (arm= main->armature.first; arm; arm= arm->id.next) { + where_is_armature(arm); + + for (bone= arm->bonebase.first; bone; bone= bone->next) + do_version_bone_head_tail_237(bone); + } + for (ob= main->object.first; ob; ob= ob->id.next) { + if (ob->parent) { + Object *parent= blo_do_versions_newlibadr(fd, lib, ob->parent); + if (parent && parent->type==OB_LATTICE) + ob->partype = PARSKEL; + } + + // btw. armature_rebuild_pose is further only called on leave editmode + if (ob->type==OB_ARMATURE) { + if (ob->pose) + ob->pose->flag |= POSE_RECALC; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // cannot call stuff now (pointers!), done in setup_app_data + + /* new generic xray option */ + arm= blo_do_versions_newlibadr(fd, lib, ob->data); + if (arm->flag & ARM_DRAWXRAY) { + ob->dtx |= OB_DRAWXRAY; + } + } + else if (ob->type==OB_MESH) { + Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data); + + if ((me->flag&ME_SUBSURF)) { + SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); + + smd->levels = MAX2(1, me->subdiv); + smd->renderLevels = MAX2(1, me->subdivr); + smd->subdivType = me->subsurftype; + + smd->modifier.mode = 0; + if (me->subdiv!=0) + smd->modifier.mode |= 1; + if (me->subdivr!=0) + smd->modifier.mode |= 2; + if (me->flag&ME_OPT_EDGES) + smd->flags |= eSubsurfModifierFlag_ControlEdges; + + BLI_addtail(&ob->modifiers, smd); + + modifier_unique_name(&ob->modifiers, (ModifierData*)smd); + } + } + + // follow path constraint needs to set the 'path' option in curves... + for (con=ob->constraints.first; con; con= con->next) { + if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) { + bFollowPathConstraint *data = con->data; + Object *obc= blo_do_versions_newlibadr(fd, lib, data->tar); + + if (obc && obc->type==OB_CURVE) { + Curve *cu= blo_do_versions_newlibadr(fd, lib, obc->data); + if (cu) cu->flag |= CU_PATH; + } + } + } + } + } + if (main->versionfile <= 238) { + Lattice *lt; + Object *ob; + bArmature *arm; + Mesh *me; + Key *key; + Scene *sce= main->scene.first; + + while (sce) { + if (sce->toolsettings == NULL) { + sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); + sce->toolsettings->cornertype=0; + sce->toolsettings->degr = 90; + sce->toolsettings->step = 9; + sce->toolsettings->turn = 1; + sce->toolsettings->extr_offs = 1; + sce->toolsettings->doublimit = 0.001f; + sce->toolsettings->segments = 32; + sce->toolsettings->rings = 32; + sce->toolsettings->vertices = 32; + } + sce= sce->id.next; + } + + for (lt=main->latt.first; lt; lt=lt->id.next) { + if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) { + calc_lat_fudu(lt->flag, lt->pntsu, <->fu, <->du); + calc_lat_fudu(lt->flag, lt->pntsv, <->fv, <->dv); + calc_lat_fudu(lt->flag, lt->pntsw, <->fw, <->dw); + } + } + + for (ob=main->object.first; ob; ob= ob->id.next) { + ModifierData *md; + PartEff *paf; + + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Subsurf) { + SubsurfModifierData *smd = (SubsurfModifierData*) md; + + smd->flags &= ~(eSubsurfModifierFlag_Incremental|eSubsurfModifierFlag_DebugIncr); + } + } + + if ((ob->softflag&OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) { + if (ob->softflag&OB_SB_POSTDEF) { + md = ob->modifiers.first; + + while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { + md = md->next; + } + + BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(eModifierType_Softbody)); + } + else { + BLI_addhead(&ob->modifiers, modifier_new(eModifierType_Softbody)); + } + + ob->softflag &= ~OB_SB_ENABLE; + } + if (ob->pose) { + bPoseChannel *pchan; + bConstraint *con; + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + // note, pchan->bone is also lib-link stuff + if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) { + pchan->limitmin[0]= pchan->limitmin[1]= pchan->limitmin[2]= -180.0f; + pchan->limitmax[0]= pchan->limitmax[1]= pchan->limitmax[2]= 180.0f; + + for (con= pchan->constraints.first; con; con= con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = (bKinematicConstraint*)con->data; + data->weight = 1.0f; + data->orientweight = 1.0f; + data->flag &= ~CONSTRAINT_IK_ROT; + + /* enforce conversion from old IK_TOPARENT to rootbone index */ + data->rootbone= -1; + + /* update_pose_etc handles rootbone==-1 */ + ob->pose->flag |= POSE_RECALC; + } + } + } + } + } + + paf = blo_do_version_give_parteff_245(ob); + if (paf) { + if (paf->disp == 0) + paf->disp = 100; + if (paf->speedtex == 0) + paf->speedtex = 8; + if (paf->omat == 0) + paf->omat = 1; + } + } + + for (arm=main->armature.first; arm; arm= arm->id.next) { + bone_version_238(&arm->bonebase); + arm->deformflag |= ARM_DEF_VGROUP; + } + + for (me=main->mesh.first; me; me= me->id.next) { + if (!me->medge) { + make_edges(me, 1); /* 1 = use mface->edcode */ + } + else { + mesh_strip_loose_faces(me); + } + } + + for (key= main->key.first; key; key= key->id.next) { + KeyBlock *kb; + int index = 1; + + for (kb= key->block.first; kb; kb= kb->next) { + if (kb==key->refkey) { + if (kb->name[0]==0) + strcpy(kb->name, "Basis"); + } + else { + if (kb->name[0]==0) { + BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index); + } + index++; + } + } + } + } + if (main->versionfile <= 239) { + bArmature *arm; + Object *ob; + Scene *sce= main->scene.first; + Camera *cam= main->camera.first; + Material *ma= main->mat.first; + int set_passepartout= 0; + + /* deformflag is local in modifier now */ + for (ob=main->object.first; ob; ob= ob->id.next) { + ModifierData *md; + + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData*) md; + if (amd->object && amd->deformflag==0) { + Object *oba= blo_do_versions_newlibadr(fd, lib, amd->object); + arm= blo_do_versions_newlibadr(fd, lib, oba->data); + amd->deformflag= arm->deformflag; + } + } + } + } + + /* updating stepsize for ghost drawing */ + for (arm= main->armature.first; arm; arm= arm->id.next) { + if (arm->ghostsize==0) arm->ghostsize=1; + bone_version_239(&arm->bonebase); + if (arm->layer==0) arm->layer= 1; + } + + for (;sce;sce= sce->id.next) { + /* make 'innervert' the default subdivide type, for backwards compat */ + sce->toolsettings->cornertype=1; + + if (sce->r.scemode & R_PASSEPARTOUT) { + set_passepartout= 1; + sce->r.scemode &= ~R_PASSEPARTOUT; + } + /* gauss is filter variable now */ + if (sce->r.mode & R_GAUSS) { + sce->r.filtertype= R_FILTER_GAUSS; + sce->r.mode &= ~R_GAUSS; + } + } + + for (;cam; cam= cam->id.next) { + if (set_passepartout) + cam->flag |= CAM_SHOWPASSEPARTOUT; + + /* make sure old cameras have title safe on */ + if (!(cam->flag & CAM_SHOWTITLESAFE)) + cam->flag |= CAM_SHOWTITLESAFE; + + /* set an appropriate camera passepartout alpha */ + if (!(cam->passepartalpha)) cam->passepartalpha = 0.2f; + } + + for (; ma; ma= ma->id.next) { + if (ma->strand_sta==0.0f) { + ma->strand_sta= ma->strand_end= 1.0f; + ma->mode |= MA_TANGENT_STR; + } + if (ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF; + } + } + + if (main->versionfile <= 241) { + Object *ob; + Tex *tex; + Scene *sce; + World *wo; + Lamp *la; + Material *ma; + bArmature *arm; + bNodeTree *ntree; + + for (wo = main->world.first; wo; wo= wo->id.next) { + /* Migrate to Bullet for games, except for the NaN versions */ + /* People can still explicitly choose for Sumo (after 2.42 is out) */ + if (main->versionfile > 225) + wo->physicsEngine = WOPHY_BULLET; + if (WO_AODIST == wo->aomode) + wo->aocolor= WO_AOPLAIN; + } + + /* updating layers still */ + for (arm= main->armature.first; arm; arm= arm->id.next) { + bone_version_239(&arm->bonebase); + if (arm->layer==0) arm->layer= 1; + } + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->audio.mixrate==0) sce->audio.mixrate= 44100; + + if (sce->r.xparts<2) sce->r.xparts= 4; + if (sce->r.yparts<2) sce->r.yparts= 4; + /* adds default layer */ + if (sce->r.layers.first==NULL) + scene_add_render_layer(sce, NULL); + else { + SceneRenderLayer *srl; + /* new layer flag for sky, was default for solid */ + for (srl= sce->r.layers.first; srl; srl= srl->next) { + if (srl->layflag & SCE_LAY_SOLID) + srl->layflag |= SCE_LAY_SKY; + srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR); + } + } + + /* node version changes */ + if (sce->nodetree) + ntree_version_241(sce->nodetree); + + /* uv calculation options moved to toolsettings */ + if (sce->toolsettings->uvcalc_radius == 0.0f) { + sce->toolsettings->uvcalc_radius = 1.0f; + sce->toolsettings->uvcalc_cubesize = 1.0f; + sce->toolsettings->uvcalc_mapdir = 1; + sce->toolsettings->uvcalc_mapalign = 1; + sce->toolsettings->uvcalc_flag = UVCALC_FILLHOLES; + sce->toolsettings->unwrapper = 1; + } + + if (sce->r.mode & R_PANORAMA) { + /* all these checks to ensure saved files with svn version keep working... */ + if (sce->r.xsch < sce->r.ysch) { + Object *obc= blo_do_versions_newlibadr(fd, lib, sce->camera); + if (obc && obc->type==OB_CAMERA) { + Camera *cam= blo_do_versions_newlibadr(fd, lib, obc->data); + if (cam->lens>=10.0f) { + sce->r.xsch*= sce->r.xparts; + cam->lens*= (float)sce->r.ysch/(float)sce->r.xsch; + } + } + } + } + } + + for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + ntree_version_241(ntree); + + for (la= main->lamp.first; la; la= la->id.next) + if (la->buffers==0) + la->buffers= 1; + + for (tex= main->tex.first; tex; tex= tex->id.next) { + if (tex->env && tex->env->viewscale==0.0f) + tex->env->viewscale= 1.0f; +// tex->imaflag |= TEX_GAUSS_MIP; + } + + /* for empty drawsize and drawtype */ + for (ob=main->object.first; ob; ob= ob->id.next) { + if (ob->empty_drawsize==0.0f) { + ob->empty_drawtype = OB_ARROWS; + ob->empty_drawsize = 1.0; + } + } + + for (ma= main->mat.first; ma; ma= ma->id.next) { + /* stucci returns intensity from now on */ + int a; + for (a=0; amtex[a] && ma->mtex[a]->tex) { + tex= blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex); + if (tex && tex->type==TEX_STUCCI) + ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF); + } + } + /* transmissivity defaults */ + if (ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f; + } + + /* during 2.41 images with this name were used for viewer node output, lets fix that */ + if (main->versionfile == 241) { + Image *ima; + for (ima= main->image.first; ima; ima= ima->id.next) + if (strcmp(ima->name, "Compositor")==0) { + strcpy(ima->id.name+2, "Viewer Node"); + strcpy(ima->name, "Viewer Node"); + } + } + } + + if (main->versionfile <= 242) { + Scene *sce; + bScreen *sc; + Object *ob; + Curve *cu; + Material *ma; + Mesh *me; + Group *group; + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + bNodeTree *ntree; + int a; + + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + sa= sc->areabase.first; + while (sa) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D*) sl; + if (v3d->gridsubdiv == 0) + v3d->gridsubdiv = 10; + } + } + sa = sa->next; + } + } + + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings->select_thresh == 0.0f) + sce->toolsettings->select_thresh= 0.01f; + if (sce->toolsettings->clean_thresh == 0.0f) + sce->toolsettings->clean_thresh = 0.1f; + + if (sce->r.threads==0) { + if (sce->r.mode & R_THREADS) + sce->r.threads= 2; + else + sce->r.threads= 1; + } + if (sce->nodetree) + ntree_version_242(sce->nodetree); + } + + for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + ntree_version_242(ntree); + + /* add default radius values to old curve points */ + for (cu= main->curve.first; cu; cu= cu->id.next) { + for (nu= cu->nurb.first; nu; nu= nu->next) { + if (nu) { + if (nu->bezt) { + for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { + if (!bezt->radius) bezt->radius= 1.0; + } + } + else if (nu->bp) { + for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { + if (!bp->radius) bp->radius= 1.0; + } + } + } + } + } + + for (ob = main->object.first; ob; ob= ob->id.next) { + ModifierData *md; + ListBase *list; + list = &ob->constraints; + + /* check for already existing MinMax (floor) constraint + * and update the sticky flagging */ + + if (list) { + bConstraint *curcon; + for (curcon = list->first; curcon; curcon=curcon->next) { + switch (curcon->type) { + case CONSTRAINT_TYPE_MINMAX: + { + bMinMaxConstraint *data = curcon->data; + if (data->sticky==1) + data->flag |= MINMAX_STICKY; + else + data->flag &= ~MINMAX_STICKY; + } + break; + case CONSTRAINT_TYPE_ROTLIKE: + { + bRotateLikeConstraint *data = curcon->data; + + /* version patch from buttons_object.c */ + if (data->flag==0) + data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; + } + break; + } + } + } + + if (ob->type == OB_ARMATURE) { + if (ob->pose) { + bConstraint *curcon; + bPoseChannel *pchan; + for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) { + switch (curcon->type) { + case CONSTRAINT_TYPE_MINMAX: + { + bMinMaxConstraint *data = curcon->data; + if (data->sticky==1) + data->flag |= MINMAX_STICKY; + else + data->flag &= ~MINMAX_STICKY; + } + break; + case CONSTRAINT_TYPE_KINEMATIC: + { + bKinematicConstraint *data = curcon->data; + if (!(data->flag & CONSTRAINT_IK_POS)) { + data->flag |= CONSTRAINT_IK_POS; + data->flag |= CONSTRAINT_IK_STRETCH; + } + } + break; + case CONSTRAINT_TYPE_ROTLIKE: + { + bRotateLikeConstraint *data = curcon->data; + + /* version patch from buttons_object.c */ + if (data->flag==0) + data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; + } + break; + } + } + } + } + } + + /* copy old object level track settings to curve modifers */ + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Curve) { + CurveModifierData *cmd = (CurveModifierData*) md; + + if (cmd->defaxis == 0) cmd->defaxis = ob->trackflag+1; + } + } + + } + + for (ma = main->mat.first; ma; ma= ma->id.next) { + if (ma->shad_alpha==0.0f) + ma->shad_alpha= 1.0f; + if (ma->nodetree) + ntree_version_242(ma->nodetree); + } + + for (me=main->mesh.first; me; me=me->id.next) + customdata_version_242(me); + + for (group= main->group.first; group; group= group->id.next) + if (group->layer==0) + group->layer= (1<<20)-1; + + /* now, subversion control! */ + if (main->subversionfile < 3) { + Image *ima; + Tex *tex; + + /* Image refactor initialize */ + for (ima= main->image.first; ima; ima= ima->id.next) { + ima->source= IMA_SRC_FILE; + ima->type= IMA_TYPE_IMAGE; + + ima->gen_x= 256; ima->gen_y= 256; + ima->gen_type= 1; + + if (0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) { + ima->source= IMA_SRC_VIEWER; + ima->type= IMA_TYPE_COMPOSITE; + } + if (0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) { + ima->source= IMA_SRC_VIEWER; + ima->type= IMA_TYPE_R_RESULT; + } + + } + for (tex= main->tex.first; tex; tex= tex->id.next) { + if (tex->type==TEX_IMAGE && tex->ima) { + ima= blo_do_versions_newlibadr(fd, lib, tex->ima); + if (tex->imaflag & TEX_ANIM5_) + ima->source= IMA_SRC_MOVIE; + if (tex->imaflag & TEX_FIELDS_) + ima->flag |= IMA_FIELDS; + if (tex->imaflag & TEX_STD_FIELD_) + ima->flag |= IMA_STD_FIELD; + } + tex->iuser.frames= tex->frames; + tex->iuser.fie_ima= (char)tex->fie_ima; + tex->iuser.offset= tex->offset; + tex->iuser.sfra= tex->sfra; + tex->iuser.cycl= (tex->imaflag & TEX_ANIMCYCLIC_)!=0; + } + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->nodetree) + do_version_ntree_242_2(sce->nodetree); + } + for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + do_version_ntree_242_2(ntree); + for (ma = main->mat.first; ma; ma= ma->id.next) + if (ma->nodetree) + do_version_ntree_242_2(ma->nodetree); + + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_IMAGE) + ((SpaceImage *)sl)->iuser.fie_ima= 2; + else if (sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D *)sl; + BGpic *bgpic; + for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) + bgpic->iuser.fie_ima= 2; + } + } + } + } + } + + if (main->subversionfile < 4) { + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->r.bake_mode= 1; /* prevent to include render stuff here */ + sce->r.bake_filter= 2; + sce->r.bake_osa= 5; + sce->r.bake_flag= R_BAKE_CLEAR; + } + } + + if (main->subversionfile < 5) { + for (sce= main->scene.first; sce; sce= sce->id.next) { + /* improved triangle to quad conversion settings */ + if (sce->toolsettings->jointrilimit==0.0f) + sce->toolsettings->jointrilimit= 0.8f; + } + } + } + if (main->versionfile <= 243) { + Object *ob= main->object.first; + Material *ma; + + for (ma=main->mat.first; ma; ma= ma->id.next) { + if (ma->sss_scale==0.0f) { + ma->sss_radius[0]= 1.0f; + ma->sss_radius[1]= 1.0f; + ma->sss_radius[2]= 1.0f; + ma->sss_col[0]= 0.8f; + ma->sss_col[1]= 0.8f; + ma->sss_col[2]= 0.8f; + ma->sss_error= 0.05f; + ma->sss_scale= 0.1f; + ma->sss_ior= 1.3f; + ma->sss_colfac= 1.0f; + ma->sss_texfac= 0.0f; + } + if (ma->sss_front==0 && ma->sss_back==0) { + ma->sss_front= 1.0f; + ma->sss_back= 1.0f; + } + if (ma->sss_col[0]==0 && ma->sss_col[1]==0 && ma->sss_col[2]==0) { + ma->sss_col[0]= ma->r; + ma->sss_col[1]= ma->g; + ma->sss_col[2]= ma->b; + } + } + + for (; ob; ob= ob->id.next) { + bDeformGroup *curdef; + + for (curdef= ob->defbase.first; curdef; curdef=curdef->next) { + /* replace an empty-string name with unique name */ + if (curdef->name[0] == '\0') { + defgroup_unique_name(curdef, ob); + } + } + + if (main->versionfile < 243 || main->subversionfile < 1) { + ModifierData *md; + + /* translate old mirror modifier axis values to new flags */ + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Mirror) { + MirrorModifierData *mmd = (MirrorModifierData*) md; + + switch (mmd->axis) { + case 0: + mmd->flag |= MOD_MIR_AXIS_X; + break; + case 1: + mmd->flag |= MOD_MIR_AXIS_Y; + break; + case 2: + mmd->flag |= MOD_MIR_AXIS_Z; + break; + } + + mmd->axis = 0; + } + } + } + } + + /* render layer added, this is not the active layer */ + if (main->versionfile <= 243 || main->subversionfile < 2) { + Mesh *me; + for (me=main->mesh.first; me; me=me->id.next) + customdata_version_243(me); + } + + } + + if (main->versionfile <= 244) { + Scene *sce; + bScreen *sc; + Lamp *la; + World *wrld; + + if (main->versionfile != 244 || main->subversionfile < 2) { + for (sce= main->scene.first; sce; sce= sce->id.next) + sce->r.mode |= R_SSS; + + /* correct older action editors - incorrect scrolling */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + sa= sc->areabase.first; + while (sa) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype==SPACE_ACTION) { + SpaceAction *saction= (SpaceAction*) sl; + + saction->v2d.tot.ymin = -1000.0; + saction->v2d.tot.ymax = 0.0; + + saction->v2d.cur.ymin = -75.0; + saction->v2d.cur.ymax = 5.0; + } + } + sa = sa->next; + } + } + } + if (main->versionfile != 244 || main->subversionfile < 3) { + /* constraints recode version patch used to be here. Moved to 245 now... */ + + + for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + if (wrld->mode & WO_AMB_OCC) + wrld->ao_samp_method = WO_AOSAMP_CONSTANT; + else + wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; + + wrld->ao_adapt_thresh = 0.005f; + } + + for (la=main->lamp.first; la; la= la->id.next) { + if (la->type == LA_AREA) + la->ray_samp_method = LA_SAMP_CONSTANT; + else + la->ray_samp_method = LA_SAMP_HALTON; + + la->adapt_thresh = 0.001f; + } + } + } + if (main->versionfile <= 245) { + Scene *sce; + Object *ob; + Image *ima; + Lamp *la; + Material *ma; + ParticleSettings *part; + World *wrld; + Mesh *me; + bNodeTree *ntree; + Tex *tex; + ModifierData *md; + ParticleSystem *psys; + + /* unless the file was created 2.44.3 but not 2.45, update the constraints */ + if ( !(main->versionfile==244 && main->subversionfile==3) && + ((main->versionfile<245) || (main->versionfile==245 && main->subversionfile==0)) ) + { + for (ob = main->object.first; ob; ob= ob->id.next) { + ListBase *list; + list = &ob->constraints; + + /* fix up constraints due to constraint recode changes (originally at 2.44.3) */ + if (list) { + bConstraint *curcon; + for (curcon = list->first; curcon; curcon=curcon->next) { + /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */ + if (curcon->flag & 0x20) { + curcon->ownspace = CONSTRAINT_SPACE_LOCAL; + curcon->tarspace = CONSTRAINT_SPACE_LOCAL; + } + + switch (curcon->type) { + case CONSTRAINT_TYPE_LOCLIMIT: + { + bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data; + + /* old limit without parent option for objects */ + if (data->flag2) + curcon->ownspace = CONSTRAINT_SPACE_LOCAL; + } + break; + } + } + } + + /* correctly initialize constinv matrix */ + unit_m4(ob->constinv); + + if (ob->type == OB_ARMATURE) { + if (ob->pose) { + bConstraint *curcon; + bPoseChannel *pchan; + + for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { + /* make sure constraints are all up to date */ + for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) { + /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */ + if (curcon->flag & 0x20) { + curcon->ownspace = CONSTRAINT_SPACE_LOCAL; + curcon->tarspace = CONSTRAINT_SPACE_LOCAL; + } + + switch (curcon->type) { + case CONSTRAINT_TYPE_ACTION: + { + bActionConstraint *data= (bActionConstraint *)curcon->data; + + /* 'data->local' used to mean that target was in local-space */ + if (data->local) + curcon->tarspace = CONSTRAINT_SPACE_LOCAL; + } + break; + } + } + + /* correctly initialize constinv matrix */ + unit_m4(pchan->constinv); + } + } + } + } + } + + /* fix all versions before 2.45 */ + if (main->versionfile != 245) { + + /* repair preview from 242 - 244*/ + for (ima= main->image.first; ima; ima= ima->id.next) { + ima->preview = NULL; + } + } + + /* add point caches */ + for (ob=main->object.first; ob; ob=ob->id.next) { + if (ob->soft && !ob->soft->pointcache) + ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); + + for (psys=ob->particlesystem.first; psys; psys=psys->next) { + if (psys->pointcache) { + if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) { + printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n"); + psys->pointcache->flag &= ~PTCACHE_BAKED; + } + } + else + psys->pointcache= BKE_ptcache_add(&psys->ptcaches); + } + + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Cloth) { + ClothModifierData *clmd = (ClothModifierData*) md; + if (!clmd->point_cache) + clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches); + } + } + } + + /* Copy over old per-level multires vertex data + * into a single vertex array in struct Multires */ + for (me = main->mesh.first; me; me=me->id.next) { + if (me->mr && !me->mr->verts) { + MultiresLevel *lvl = me->mr->levels.last; + if (lvl) { + me->mr->verts = lvl->verts; + lvl->verts = NULL; + /* Don't need the other vert arrays */ + for (lvl = lvl->prev; lvl; lvl = lvl->prev) { + MEM_freeN(lvl->verts); + lvl->verts = NULL; + } + } + } + } + + if (main->versionfile != 245 || main->subversionfile < 1) { + for (la=main->lamp.first; la; la= la->id.next) { + if (la->mode & LA_QUAD) la->falloff_type = LA_FALLOFF_SLIDERS; + else la->falloff_type = LA_FALLOFF_INVLINEAR; + + if (la->curfalloff == NULL) { + la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); + curvemapping_initialize(la->curfalloff); + } + } + } + + for (ma=main->mat.first; ma; ma= ma->id.next) { + if (ma->samp_gloss_mir == 0) { + ma->gloss_mir = ma->gloss_tra= 1.0f; + ma->aniso_gloss_mir = 1.0f; + ma->samp_gloss_mir = ma->samp_gloss_tra= 18; + ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f; + ma->dist_mir = 0.0f; + ma->fadeto_mir = MA_RAYMIR_FADETOSKY; + } + + if (ma->strand_min == 0.0f) + ma->strand_min= 1.0f; + } + + for (part=main->particle.first; part; part=part->id.next) { + if (part->ren_child_nbr==0) + part->ren_child_nbr= part->child_nbr; + + if (part->simplify_refsize==0) { + part->simplify_refsize= 1920; + part->simplify_rate= 1.0f; + part->simplify_transition= 0.1f; + part->simplify_viewport= 0.8f; + } + } + + for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + if (wrld->ao_approx_error == 0.0f) + wrld->ao_approx_error= 0.25f; + } + + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->nodetree) + ntree_version_245(fd, lib, sce->nodetree); + + if (sce->r.simplify_shadowsamples == 0) { + sce->r.simplify_subsurf= 6; + sce->r.simplify_particles= 1.0f; + sce->r.simplify_shadowsamples= 16; + sce->r.simplify_aosss= 1.0f; + } + + if (sce->r.cineongamma == 0) { + sce->r.cineonblack= 95; + sce->r.cineonwhite= 685; + sce->r.cineongamma= 1.7f; + } + } + + for (ntree=main->nodetree.first; ntree; ntree= ntree->id.next) + ntree_version_245(fd, lib, ntree); + + /* fix for temporary flag changes during 245 cycle */ + for (ima= main->image.first; ima; ima= ima->id.next) { + if (ima->flag & IMA_OLD_PREMUL) { + ima->flag &= ~IMA_OLD_PREMUL; + ima->flag |= IMA_DO_PREMUL; + } + } + + for (tex=main->tex.first; tex; tex=tex->id.next) { + if (tex->iuser.flag & IMA_OLD_PREMUL) { + tex->iuser.flag &= ~IMA_OLD_PREMUL; + tex->iuser.flag |= IMA_DO_PREMUL; + + } + + ima= blo_do_versions_newlibadr(fd, lib, tex->ima); + if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) { + ima->flag &= ~IMA_OLD_PREMUL; + ima->flag |= IMA_DO_PREMUL; + } + } + } + + /* sanity check for skgen + * */ + { + Scene *sce; + for (sce=main->scene.first; sce; sce = sce->id.next) { + if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] || + sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] || + sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2]) + { + sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; + sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; + sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; + } + } + } + + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) { + Image *ima; + + /* initialize 1:1 Aspect */ + for (ima= main->image.first; ima; ima= ima->id.next) { + ima->aspx = ima->aspy = 1.0f; + } + + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) { + bArmature *arm; + ModifierData *md; + Object *ob; + + for (arm= main->armature.first; arm; arm= arm->id.next) + arm->deformflag |= ARM_DEF_B_BONE_REST; + + for (ob = main->object.first; ob; ob= ob->id.next) { + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Armature) + ((ArmatureModifierData*)md)->deformflag |= ARM_DEF_B_BONE_REST; + } + } + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) { + /* foreground color needs to be something other then black */ + Scene *sce; + for (sce= main->scene.first; sce; sce=sce->id.next) { + sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; + sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */ + sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */ + } + } + + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) { + Scene *sce; + /* fix frs_sec_base */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->r.frs_sec_base == 0) { + sce->r.frs_sec_base = 1; + } + } + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) { + Object *ob; + bPoseChannel *pchan; + bConstraint *con; + bConstraintTarget *ct; + + for (ob = main->object.first; ob; ob= ob->id.next) { + if (ob->pose) { + for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (con=pchan->constraints.first; con; con=con->next) { + if (con->type == CONSTRAINT_TYPE_PYTHON) { + bPythonConstraint *data= (bPythonConstraint *)con->data; + if (data->tar) { + /* version patching needs to be done */ + ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); + + ct->tar = data->tar; + BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); + ct->space = con->tarspace; + + BLI_addtail(&data->targets, ct); + data->tarnum++; + + /* clear old targets to avoid problems */ + data->tar = NULL; + data->subtarget[0]= '\0'; + } + } + else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { + bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; + + /* new headtail functionality makes Bone-Tip function obsolete */ + if (data->flag & LOCLIKE_TIP) + con->headtail = 1.0f; + } + } + } + } + + for (con=ob->constraints.first; con; con=con->next) { + if (con->type==CONSTRAINT_TYPE_PYTHON) { + bPythonConstraint *data= (bPythonConstraint *)con->data; + if (data->tar) { + /* version patching needs to be done */ + ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); + + ct->tar = data->tar; + BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); + ct->space = con->tarspace; + + BLI_addtail(&data->targets, ct); + data->tarnum++; + + /* clear old targets to avoid problems */ + data->tar = NULL; + data->subtarget[0]= '\0'; + } + } + else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { + bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; + + /* new headtail functionality makes Bone-Tip function obsolete */ + if (data->flag & LOCLIKE_TIP) + con->headtail = 1.0f; + } + } + + if (ob->soft && ob->soft->keys) { + SoftBody *sb = ob->soft; + int k; + + for (k=0; ktotkey; k++) { + if (sb->keys[k]) + MEM_freeN(sb->keys[k]); + } + + MEM_freeN(sb->keys); + + sb->keys = NULL; + sb->totkey = 0; + } + } + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) { + Scene *sce; + Object *ob; + PartEff *paf=NULL; + + for (ob = main->object.first; ob; ob= ob->id.next) { + if (ob->soft && ob->soft->keys) { + SoftBody *sb = ob->soft; + int k; + + for (k=0; ktotkey; k++) { + if (sb->keys[k]) + MEM_freeN(sb->keys[k]); + } + + MEM_freeN(sb->keys); + + sb->keys = NULL; + sb->totkey = 0; + } + + /* convert old particles to new system */ + if ((paf = blo_do_version_give_parteff_245(ob))) { + ParticleSystem *psys; + ModifierData *md; + ParticleSystemModifierData *psmd; + ParticleSettings *part; + + /* create new particle system */ + psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); + + part = psys->part = psys_new_settings("ParticleSettings", main); + + /* needed for proper libdata lookup */ + blo_do_versions_oldnewmap_insert(fd->libmap, psys->part, psys->part, 0); + part->id.lib= ob->id.lib; + + part->id.us--; + part->id.flag |= (ob->id.flag & LIB_NEEDLINK); + + psys->totpart=0; + psys->flag= PSYS_ENABLED|PSYS_CURRENT; + + BLI_addtail(&ob->particlesystem, psys); + + md= modifier_new(eModifierType_ParticleSystem); + BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + psmd= (ParticleSystemModifierData*) md; + psmd->psys=psys; + BLI_addtail(&ob->modifiers, md); + + /* convert settings from old particle system */ + /* general settings */ + part->totpart = MIN2(paf->totpart, 100000); + part->sta = paf->sta; + part->end = paf->end; + part->lifetime = paf->lifetime; + part->randlife = paf->randlife; + psys->seed = paf->seed; + part->disp = paf->disp; + part->omat = paf->mat[0]; + part->hair_step = paf->totkey; + + part->eff_group = paf->group; + + /* old system didn't interpolate between keypoints at render time */ + part->draw_step = part->ren_step = 0; + + /* physics */ + part->normfac = paf->normfac * 25.0f; + part->obfac = paf->obfac; + part->randfac = paf->randfac * 25.0f; + part->dampfac = paf->damp; + copy_v3_v3(part->acc, paf->force); + + /* flags */ + if (paf->stype & PAF_VECT) { + if (paf->flag & PAF_STATIC) { + /* new hair lifetime is always 100.0f */ + float fac = paf->lifetime / 100.0f; + + part->draw_as = PART_DRAW_PATH; + part->type = PART_HAIR; + psys->recalc |= PSYS_RECALC_REDO; + + part->normfac *= fac; + part->randfac *= fac; + } + else { + part->draw_as = PART_DRAW_LINE; + part->draw |= PART_DRAW_VEL_LENGTH; + part->draw_line[1] = 0.04f; + } + } + + part->rotmode = PART_ROT_VEL; + + part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0; + part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0; + part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0; + part->flag |= (paf->flag & PAF_UNBORN) ? PART_UNBORN : 0; + part->flag |= (paf->flag & PAF_DIED) ? PART_DIED : 0; + part->from |= (paf->flag & PAF_FACE) ? PART_FROM_FACE : 0; + part->draw |= (paf->flag & PAF_SHOWE) ? PART_DRAW_EMITTER : 0; + + psys->vgroup[PSYS_VG_DENSITY] = paf->vertgroup; + psys->vgroup[PSYS_VG_VEL] = paf->vertgroup_v; + psys->vgroup[PSYS_VG_LENGTH] = paf->vertgroup_v; + + /* dupliobjects */ + if (ob->transflag & OB_DUPLIVERTS) { + Object *dup = main->object.first; + + for (; dup; dup= dup->id.next) { + if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) { + part->dup_ob = dup; + ob->transflag |= OB_DUPLIPARTS; + ob->transflag &= ~OB_DUPLIVERTS; + + part->draw_as = PART_DRAW_OB; + + /* needed for proper libdata lookup */ + blo_do_versions_oldnewmap_insert(fd->libmap, dup, dup, 0); + } + } + } + + + { + FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); + if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE) + part->type = PART_FLUID; + } + + do_version_free_effects_245(&ob->effect); + + printf("Old particle system converted to new system.\n"); + } + } + + for (sce= main->scene.first; sce; sce=sce->id.next) { + ParticleEditSettings *pset= &sce->toolsettings->particle; + int a; + + if (pset->brush[0].size == 0) { + pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; + pset->emitterdist= 0.25f; + pset->totrekey= 5; + pset->totaddkey= 5; + pset->brushtype= PE_BRUSH_NONE; + + for (a=0; abrush[a].strength= 50; + pset->brush[a].size= 50; + pset->brush[a].step= 10; + } + + pset->brush[PE_BRUSH_CUT].strength= 100; + } + } + } + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 9)) { + Material *ma; + int a; + + for (ma=main->mat.first; ma; ma= ma->id.next) + if (ma->mode & MA_NORMAP_TANG) + for (a=0; amtex[a] && ma->mtex[a]->tex) + ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT; + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) { + Object *ob; + + /* dupliface scale */ + for (ob= main->object.first; ob; ob= ob->id.next) + ob->dupfacesca = 1.0f; + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) { + Object *ob; + bActionStrip *strip; + + /* nla-strips - scale */ + for (ob= main->object.first; ob; ob= ob->id.next) { + for (strip= ob->nlastrips.first; strip; strip= strip->next) { + float length, actlength, repeat; + + if (strip->flag & ACTSTRIP_USESTRIDE) + repeat= 1.0f; + else + repeat= strip->repeat; + + length = strip->end-strip->start; + if (length == 0.0f) length= 1.0f; + actlength = strip->actend-strip->actstart; + + strip->scale = length / (repeat * actlength); + if (strip->scale == 0.0f) strip->scale= 1.0f; + } + if (ob->soft) { + ob->soft->inpush = ob->soft->inspring; + ob->soft->shearstiff = 1.0f; + } + } + } + + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) { + Scene *sce; + Sequence *seq; + + for (sce=main->scene.first; sce; sce=sce->id.next) { + SEQ_BEGIN (sce->ed, seq) + { + if (seq->blend_mode == 0) + seq->blend_opacity = 100.0f; + } + SEQ_END + } + } + + /*fix broken group lengths in id properties*/ + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) { + idproperties_fix_group_lengths(main->scene); + idproperties_fix_group_lengths(main->library); + idproperties_fix_group_lengths(main->object); + idproperties_fix_group_lengths(main->mesh); + idproperties_fix_group_lengths(main->curve); + idproperties_fix_group_lengths(main->mball); + idproperties_fix_group_lengths(main->mat); + idproperties_fix_group_lengths(main->tex); + idproperties_fix_group_lengths(main->image); + idproperties_fix_group_lengths(main->latt); + idproperties_fix_group_lengths(main->lamp); + idproperties_fix_group_lengths(main->camera); + idproperties_fix_group_lengths(main->ipo); + idproperties_fix_group_lengths(main->key); + idproperties_fix_group_lengths(main->world); + idproperties_fix_group_lengths(main->screen); + idproperties_fix_group_lengths(main->script); + idproperties_fix_group_lengths(main->vfont); + idproperties_fix_group_lengths(main->text); + idproperties_fix_group_lengths(main->sound); + idproperties_fix_group_lengths(main->group); + idproperties_fix_group_lengths(main->armature); + idproperties_fix_group_lengths(main->action); + idproperties_fix_group_lengths(main->nodetree); + idproperties_fix_group_lengths(main->brush); + idproperties_fix_group_lengths(main->particle); + } + + /* sun/sky */ + if (main->versionfile < 246) { + Object *ob; + bActuator *act; + + /* dRot actuator change direction in 2.46 */ + for (ob = main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_OBJECT) { + bObjectActuator *ba= act->data; + + ba->drot[0] = -ba->drot[0]; + ba->drot[1] = -ba->drot[1]; + ba->drot[2] = -ba->drot[2]; + } + } + } + } + + // convert fluids to modifier + if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { + Object *ob; + + for (ob = main->object.first; ob; ob= ob->id.next) { + if (ob->fluidsimSettings) { + FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim); + BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd); + + MEM_freeN(fluidmd->fss); + fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings); + fluidmd->fss->ipo = blo_do_versions_newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo); + MEM_freeN(ob->fluidsimSettings); + + fluidmd->fss->lastgoodframe = INT_MAX; + fluidmd->fss->flag = 0; + fluidmd->fss->meshVelocities = NULL; + } + } + } + + + if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { + Mesh *me; + + for (me=main->mesh.first; me; me= me->id.next) + alphasort_version_246(fd, lib, me); + } + + if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { + Object *ob; + for (ob = main->object.first; ob; ob= ob->id.next) { + if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) + ob->pd->f_noise = 0.0f; + } + } + + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) { + Object *ob; + for (ob = main->object.first; ob; ob= ob->id.next) { + ob->gameflag |= OB_COLLISION; + ob->margin = 0.06f; + } + } + + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) { + Object *ob; + for (ob = main->object.first; ob; ob= ob->id.next) { + // Starting from subversion 3, ACTOR is a separate feature. + // Before it was conditioning all the other dynamic flags + if (!(ob->gameflag & OB_ACTOR)) + ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE); + /* suitable default for older files */ + } + } + + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) { + Lamp *la= main->lamp.first; + for (; la; la= la->id.next) { + la->skyblendtype= MA_RAMP_ADD; + la->skyblendfac= 1.0f; + } + } + + /* set the curve radius interpolation to 2.47 default - easy */ + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) { + Curve *cu; + Nurb *nu; + + for (cu= main->curve.first; cu; cu= cu->id.next) { + for (nu= cu->nurb.first; nu; nu= nu->next) { + if (nu) { + nu->radius_interp = 3; + + /* resolu and resolv are now used differently for surfaces + * rather than using the resolution to define the entire number of divisions, + * use it for the number of divisions per segment + */ + if (nu->pntsv > 1) { + nu->resolu = MAX2( 1, (int)(((float)nu->resolu / (float)nu->pntsu)+0.5f) ); + nu->resolv = MAX2( 1, (int)(((float)nu->resolv / (float)nu->pntsv)+0.5f) ); + } + } + } + } + } + /* direction constraint actuators were always local in previous version */ + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) { + bActuator *act; + Object *ob; + + for (ob = main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_CONSTRAINT) { + bConstraintActuator *coa = act->data; + if (coa->type == ACT_CONST_TYPE_DIST) { + coa->flag |= ACT_CONST_LOCAL; + } + } + } + } + } + + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) { + Lamp *la= main->lamp.first; + for (; la; la= la->id.next) { + la->sky_exposure= 1.0f; + } + } + + /* BGE message actuators needed OB prefix, very confusing */ + if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) { + bActuator *act; + Object *ob; + + for (ob = main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_MESSAGE) { + bMessageActuator *msgAct = (bMessageActuator *) act->data; + if (BLI_strnlen(msgAct->toPropName, 3) > 2) { + /* strip first 2 chars, would have only worked if these were OB anyway */ + memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2); + } + else { + msgAct->toPropName[0] = '\0'; + } + } + } + } + } + + if (main->versionfile < 248) { + Lamp *la; + + for (la=main->lamp.first; la; la= la->id.next) { + if (la->atm_turbidity == 0.0f) { + la->sun_effect_type = 0; + la->horizon_brightness = 1.0f; + la->spread = 1.0f; + la->sun_brightness = 1.0f; + la->sun_size = 1.0f; + la->backscattered_light = 1.0f; + la->atm_turbidity = 2.0f; + la->atm_inscattering_factor = 1.0f; + la->atm_extinction_factor = 1.0f; + la->atm_distance_factor = 1.0f; + la->sun_intensity = 1.0f; + } + } + } + + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) { + Scene *sce; + + /* Note, these will need to be added for painting */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->toolsettings->imapaint.seam_bleed = 2; + sce->toolsettings->imapaint.normal_angle = 80; + + /* initialize skeleton generation toolsettings */ + sce->toolsettings->skgen_resolution = 250; + sce->toolsettings->skgen_threshold_internal = 0.1f; + sce->toolsettings->skgen_threshold_external = 0.1f; + sce->toolsettings->skgen_angle_limit = 30.0f; + sce->toolsettings->skgen_length_ratio = 1.3f; + sce->toolsettings->skgen_length_limit = 1.5f; + sce->toolsettings->skgen_correlation_limit = 0.98f; + sce->toolsettings->skgen_symmetry_limit = 0.1f; + sce->toolsettings->skgen_postpro = SKGEN_SMOOTH; + sce->toolsettings->skgen_postpro_passes = 3; + sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_SUB_CORRELATION|SKGEN_HARMONIC; + sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; + sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; + sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; + + + sce->toolsettings->skgen_retarget_angle_weight = 1.0f; + sce->toolsettings->skgen_retarget_length_weight = 1.0f; + sce->toolsettings->skgen_retarget_distance_weight = 1.0f; + + /* Skeleton Sketching */ + sce->toolsettings->bone_sketching = 0; + sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW; + } + } + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { + bScreen *sc; + + /* adjust default settings for Animation Editors */ + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + + for (sl= sa->spacedata.first; sl; sl= sl->next) { + switch (sl->spacetype) { + case SPACE_ACTION: + { + SpaceAction *sact= (SpaceAction *)sl; + + sact->mode= SACTCONT_DOPESHEET; + sact->autosnap= SACTSNAP_FRAME; + } + break; + case SPACE_IPO: + { + SpaceIpo *sipo= (SpaceIpo *)sl; + sipo->autosnap= SACTSNAP_FRAME; + } + break; + case SPACE_NLA: + { + SpaceNla *snla= (SpaceNla *)sl; + snla->autosnap= SACTSNAP_FRAME; + } + break; + } + } + } + } + } + + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { + Object *ob; + + /* Adjustments needed after Bullets update */ + for (ob = main->object.first; ob; ob= ob->id.next) { + ob->damping *= 0.635f; + ob->rdamping = 0.1f + (0.8f * ob->rdamping); + } + } + + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) { + Scene *sce; + World *wrld; + + /* Dome (Fisheye) default parameters */ + for (sce= main->scene.first; sce; sce= sce->id.next) { + sce->r.domeangle = 180; + sce->r.domemode = 1; + sce->r.domeres = 4; + sce->r.domeresbuf = 1.0f; + sce->r.dometilt = 0; + } + /* DBVT culling by default */ + for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + wrld->mode |= WO_DBVT_CULLING; + wrld->occlusionRes = 128; + } + } + + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) { + Object *ob; + World *wrld; + for (ob = main->object.first; ob; ob= ob->id.next) { + ob->m_contactProcessingThreshold = 1.0f; //pad3 is used for m_contactProcessingThreshold + if (ob->parent) { + /* check if top parent has compound shape set and if yes, set this object + * to compound shaper as well (was the behavior before, now it's optional) */ + Object *parent= blo_do_versions_newlibadr(fd, lib, ob->parent); + while (parent && parent != ob && parent->parent != NULL) { + parent = blo_do_versions_newlibadr(fd, lib, parent->parent); + } + if (parent) { + if (parent->gameflag & OB_CHILD) + ob->gameflag |= OB_CHILD; + } + } + } + for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + wrld->ticrate = 60; + wrld->maxlogicstep = 5; + wrld->physubstep = 1; + wrld->maxphystep = 5; + } + } + + // correct introduce of seed for wind force + if (main->versionfile < 249 && main->subversionfile < 1) { + Object *ob; + for (ob = main->object.first; ob; ob= ob->id.next) { + if (ob->pd) + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; + } + + } + + if (main->versionfile < 249 && main->subversionfile < 2) { + Scene *sce= main->scene.first; + Sequence *seq; + Editing *ed; + + while (sce) { + ed= sce->ed; + if (ed) { + SEQP_BEGIN (ed, seq) + { + if (seq->strip && seq->strip->proxy) { + seq->strip->proxy->quality =90; + } + } + SEQ_END + } + + sce= sce->id.next; + } + + } + + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ + /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ + + /* don't forget to set version number in blender.c! */ +} + From b6edcc4b33e782b4a91a61d1c46136c52a4172c9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2012 16:17:09 +0000 Subject: [PATCH 58/88] make text move up/down into a single operator with a direction property --- source/blender/blenkernel/BKE_text.h | 8 ++- source/blender/blenkernel/intern/text.c | 38 ++++++++------ .../blender/editors/space_text/space_text.c | 10 ++-- .../blender/editors/space_text/text_intern.h | 3 +- source/blender/editors/space_text/text_ops.c | 50 ++++++------------- 5 files changed, 51 insertions(+), 58 deletions(-) diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 393663456d5..115c00d9e73 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -96,8 +96,7 @@ void txt_unindent (struct Text *text); void txt_comment (struct Text *text); void txt_indent (struct Text *text); void txt_uncomment (struct Text *text); -void txt_move_lines_up (struct Text *text); -void txt_move_lines_down (struct Text *text); +void txt_move_lines (struct Text *text, const int direction); void txt_duplicate_line (struct Text *text); int setcurr_tab_spaces (struct Text *text, int space); @@ -116,6 +115,11 @@ int text_check_digit(const char ch); int text_check_identifier(const char ch); int text_check_whitespace(const char ch); +enum { + TXT_MOVE_LINE_UP = -1, + TXT_MOVE_LINE_DOWN = 1 +}; + /* Undo opcodes */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index db0ff6eeca6..d67c5fb3698 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2201,10 +2201,10 @@ void txt_do_undo(Text *text) txt_delete_line(text, text->curl->next); break; case UNDO_MOVE_LINES_UP: - txt_move_lines_down(text); + txt_move_lines(text, TXT_MOVE_LINE_DOWN); break; case UNDO_MOVE_LINES_DOWN: - txt_move_lines_up(text); + txt_move_lines(text, TXT_MOVE_LINE_UP); break; default: //XXX error("Undo buffer error - resetting"); @@ -2407,10 +2407,10 @@ void txt_do_redo(Text *text) txt_duplicate_line(text); break; case UNDO_MOVE_LINES_UP: - txt_move_lines_up(text); + txt_move_lines(text, TXT_MOVE_LINE_UP); break; case UNDO_MOVE_LINES_DOWN: - txt_move_lines_down(text); + txt_move_lines(text, TXT_MOVE_LINE_DOWN); break; default: //XXX error("Undo buffer error - resetting"); @@ -3069,26 +3069,34 @@ void txt_move_lines_up(struct Text *text) } } -void txt_move_lines_down(struct Text *text) +void txt_move_lines(struct Text *text, const int direction) { - TextLine *next_line; - + TextLine *line_other; + + BLI_assert(ELEM(direction, TXT_MOVE_LINE_UP, TXT_MOVE_LINE_DOWN)); + if (!text || !text->curl || !text->sell) return; txt_order_cursors(text); + + line_other = (direction == TXT_MOVE_LINE_DOWN) ? text->sell->next : text->curl->prev; - next_line= text->sell->next; - - if (!next_line) return; + if (!line_other) return; - BLI_remlink(&text->lines, next_line); - BLI_insertlinkbefore(&text->lines, text->curl, next_line); - + BLI_remlink(&text->lines, line_other); + + if (direction == TXT_MOVE_LINE_DOWN) { + BLI_insertlinkbefore(&text->lines, text->curl, line_other); + } + else { + BLI_insertlinkafter(&text->lines, text->sell, line_other); + } + txt_make_dirty(text); txt_clean_text(text); - if (!undoing) { - txt_undo_add_op(text, UNDO_MOVE_LINES_DOWN); + if (!undoing) { + txt_undo_add_op(text, (direction == TXT_MOVE_LINE_DOWN) ? UNDO_MOVE_LINES_DOWN : UNDO_MOVE_LINES_UP); } } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index ddff1fe603f..85eda858d24 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_text.h" #include "ED_space_api.h" #include "ED_screen.h" @@ -203,8 +204,7 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_select_all); WM_operatortype_append(TEXT_OT_select_word); - WM_operatortype_append(TEXT_OT_move_lines_up); - WM_operatortype_append(TEXT_OT_move_lines_down); + WM_operatortype_append(TEXT_OT_move_lines); WM_operatortype_append(TEXT_OT_jump); WM_operatortype_append(TEXT_OT_move); @@ -323,9 +323,9 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_word", LEFTMOUSE, KM_DBL_CLICK, 0, 0); - - WM_keymap_add_item(keymap, "TEXT_OT_move_lines_up", UPARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - WM_keymap_add_item(keymap, "TEXT_OT_move_lines_down", DOWNARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_lines", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "direction", TXT_MOVE_LINE_UP); + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_lines", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "direction", TXT_MOVE_LINE_DOWN); WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_unindent", TABKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index be6287a939c..4f973e7076b 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -137,8 +137,7 @@ void TEXT_OT_select_line(struct wmOperatorType *ot); void TEXT_OT_select_all(struct wmOperatorType *ot); void TEXT_OT_select_word(struct wmOperatorType *ot); -void TEXT_OT_move_lines_up(struct wmOperatorType *ot); -void TEXT_OT_move_lines_down(struct wmOperatorType *ot); +void TEXT_OT_move_lines(struct wmOperatorType *ot); void TEXT_OT_jump(struct wmOperatorType *ot); void TEXT_OT_move(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index cb8daa0f03e..a07493ef8fc 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1333,11 +1333,12 @@ void TEXT_OT_select_word(wmOperatorType *ot) /********************* move lines operators ***********************/ -static int move_lines_up_exec(bContext *C, wmOperator *UNUSED(op)) +static int move_lines_exec(bContext *C, wmOperator *op) { Text *text = CTX_data_edit_text(C); + const int direction = RNA_enum_get(op->ptr, "direction"); - txt_move_lines_up(text); + txt_move_lines(text, direction); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); @@ -1349,44 +1350,25 @@ static int move_lines_up_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void TEXT_OT_move_lines_up(wmOperatorType *ot) +void TEXT_OT_move_lines(wmOperatorType *ot) { + static EnumPropertyItem direction_items[]= { + {TXT_MOVE_LINE_UP, "UP", 0, "Up", ""}, + {TXT_MOVE_LINE_DOWN, "DOWN", 0, "Down", ""}, + {0, NULL, 0, NULL, NULL} + }; + /* identifiers */ - ot->name = "Move Lines Up"; - ot->idname = "TEXT_OT_move_lines_up"; - ot->description = "Moves the currently selected line(s) up."; + ot->name = "Move Lines"; + ot->idname = "TEXT_OT_move_lines"; + ot->description = "Moves the currently selected line(s) up/down"; /* api callbacks */ - ot->exec = move_lines_up_exec; + ot->exec = move_lines_exec; ot->poll = text_edit_poll; -} -static int move_lines_down_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Text *text = CTX_data_edit_text(C); - - txt_move_lines_down(text); - - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); - - /* run the script while editing, evil but useful */ - if (CTX_wm_space_text(C)->live_edit) - text_run_script(C, NULL); - - return OPERATOR_FINISHED; -} - -void TEXT_OT_move_lines_down(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Move Lines Down"; - ot->idname = "TEXT_OT_move_lines_down"; - ot->description = "Moves the currently selected line(s) down."; - - /* api callbacks */ - ot->exec = move_lines_down_exec; - ot->poll = text_edit_poll; + /* properties */ + RNA_def_enum(ot->srna, "direction", direction_items, 1, "Direction", ""); } /******************* previous marker operator *********************/ From d7fbe03a8a128408c86687ef34273adddccdb347 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 4 May 2012 16:20:51 +0000 Subject: [PATCH 59/88] Fisheye Camera for Cycles For sample images see: http://www.dalaifelinto.com/?p=399 (equisolid) http://www.dalaifelinto.com/?p=389 (equidistant) The 'use_panorama' option is now part of a new Camera type: 'Panorama'. Created two other panorama cameras: - Equisolid: most of lens in the market simulate this lens - e.g. Nikon, Canon, ...) this works as a real lens up to an extent. The final result takes the sensor dimensions into account also. .:. to simulate a Nikon DX2S with a 10.5mm lens do: sensor: 23.7 x 15.7 fisheye lens: 10.5 fisheye fov: 180 render dimensions: 4288 x 2848 - Equidistant: this is not a real lens model. Although the old equidistant lens simulate this lens. The result is always as a circular fisheye that takes the whole sensor (in other words, it doesn't take the sensor into consideration). This is perfect for fulldomes ;) For the UI we have 10 to 360 as soft values and 10 to 3600 as hard values (because we can). Reference material: http://www.hdrlabs.com/tutorials/downloads_files/HDRI%20for%20CGI.pdf http://www.bobatkins.com/photography/technical/field_of_view.html Note, this is not a real simulation of the light path through the lens. The ideal solution would be this: https://graphics.stanford.edu/wikis/cs348b-11/Assignment3 http://www.graphics.stanford.edu/papers/camera/ Thanks Brecht for the fix, suggestions and code review. Kudos for the dome community for keeping me stimulated on the topic since 2009 ;) Patch partly implemented during lab time at VisGraf, IMPA - Rio de Janeiro. --- intern/cycles/app/cycles_xml.cpp | 18 ++++++- intern/cycles/blender/addon/enums.py | 6 +++ intern/cycles/blender/addon/properties.py | 19 +++++++ intern/cycles/blender/blender_camera.cpp | 50 ++++++++++++++++-- intern/cycles/kernel/kernel_camera.h | 42 ++++++++++----- intern/cycles/kernel/kernel_montecarlo.h | 51 +++++++++++++++++++ intern/cycles/kernel/kernel_path.h | 7 ++- intern/cycles/kernel/kernel_types.h | 21 +++++++- intern/cycles/render/camera.cpp | 22 +++++++- intern/cycles/render/camera.h | 9 ++++ .../startup/bl_ui/properties_data_camera.py | 14 +++-- source/blender/blenkernel/intern/camera.c | 2 +- source/blender/blenlib/intern/uvproject.c | 2 +- source/blender/blenloader/intern/readfile.c | 12 +++++ source/blender/collada/CameraExporter.cpp | 16 ++++-- source/blender/makesdna/DNA_camera_types.h | 5 +- source/blender/makesrna/intern/rna_camera.c | 7 +-- .../blender/modifiers/intern/MOD_uvproject.c | 2 +- 18 files changed, 262 insertions(+), 43 deletions(-) diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 82f1338d86b..db3592f1227 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -290,8 +290,22 @@ static void xml_read_camera(const XMLReadState& state, pugi::xml_node node) cam->type = CAMERA_ORTHOGRAPHIC; else if(xml_equal_string(node, "type", "perspective")) cam->type = CAMERA_PERSPECTIVE; - else if(xml_equal_string(node, "type", "environment")) - cam->type = CAMERA_ENVIRONMENT; + else if(xml_equal_string(node, "type", "panorama")) + cam->type = CAMERA_PANORAMA; + + if(xml_equal_string(node, "panorama_type", "equirectangular")) + cam->panorama_type = PANORAMA_EQUIRECTANGULAR; + else if(xml_equal_string(node, "panorama_type", "fisheye_equidistant")) + cam->panorama_type = PANORAMA_FISHEYE_EQUIDISTANT; + else if(xml_equal_string(node, "panorama_type", "fisheye_equisolid")) + cam->panorama_type = PANORAMA_FISHEYE_EQUISOLID; + + xml_read_float(&cam->fisheye_fov, node, "fisheye_fov"); + xml_read_float(&cam->fisheye_lens, node, "fisheye_lens"); + + xml_read_float(&cam->sensorwidth, node, "sensorwidth"); + xml_read_float(&cam->sensorheight, node, "sensorheight"); + cam->matrix = state.tfm; diff --git a/intern/cycles/blender/addon/enums.py b/intern/cycles/blender/addon/enums.py index b4b1646c10d..6cc3010eb0e 100644 --- a/intern/cycles/blender/addon/enums.py +++ b/intern/cycles/blender/addon/enums.py @@ -54,3 +54,9 @@ aperture_types = ( ('RADIUS', "Radius", "Directly change the size of the aperture"), ('FSTOP', "F/stop", "Change the size of the aperture by f/stops"), ) + +panorama_types = ( + ('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"), + ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"), + ('FISHEYE_EQUISOLID', "Fisheye Equisolid", "Similar to most fisheye modern lens, take sensor dimensions into consideration"), + ) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 35f97bf629f..fb066a3a939 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -278,6 +278,25 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): subtype='ANGLE', default=0, ) + cls.panorama_type = EnumProperty( + name="Panorama Type", + description="Distortion to use for the calculation", + items=enums.panorama_types, + default='FISHEYE_EQUISOLID', + ) + cls.fisheye_fov = FloatProperty( + name="Field of View", + description="Field of view for the fisheye lens", + min=0.1745, soft_max=2*math.pi, max=10.0*math.pi, + subtype='ANGLE', + default=math.pi, + ) + cls.fisheye_lens = FloatProperty( + name="Fisheye Lens", + description="Lens focal length (mm))", + min=0.01, soft_max=15.0, max=100.0, + default=10.5, + ) @classmethod def unregister(cls): diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 55a32d8fc10..bdd02bb5086 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -48,6 +48,10 @@ struct BlenderCamera { float2 pixelaspect; + PanoramaType panorama_type; + float fisheye_fov; + float fisheye_lens; + enum { AUTO, HORIZONTAL, VERTICAL } sensor_fit; float sensor_width; float sensor_height; @@ -94,9 +98,37 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob) bcam->nearclip = b_camera.clip_start(); bcam->farclip = b_camera.clip_end(); - bcam->type = (b_camera.type() == BL::Camera::type_ORTHO)? CAMERA_ORTHOGRAPHIC: CAMERA_PERSPECTIVE; - if(bcam->type == CAMERA_PERSPECTIVE && b_camera.use_panorama()) - bcam->type = CAMERA_ENVIRONMENT; + switch(b_camera.type()) + { + case BL::Camera::type_ORTHO: + bcam->type = CAMERA_ORTHOGRAPHIC; + break; + case BL::Camera::type_PANO: + bcam->type = CAMERA_PANORAMA; + break; + case BL::Camera::type_PERSP: + default: + bcam->type = CAMERA_PERSPECTIVE; + break; + } + + switch(RNA_enum_get(&ccamera, "panorama_type")) + { + case 1: + bcam->panorama_type = PANORAMA_FISHEYE_EQUIDISTANT; + break; + case 2: + bcam->panorama_type = PANORAMA_FISHEYE_EQUISOLID; + break; + case 0: + default: + bcam->panorama_type = PANORAMA_EQUIRECTANGULAR; + break; + } + + bcam->fisheye_fov = RNA_float_get(&ccamera, "fisheye_fov"); + bcam->fisheye_lens = RNA_float_get(&ccamera, "fisheye_lens"); + bcam->ortho_scale = b_camera.ortho_scale(); bcam->lens = b_camera.lens(); @@ -138,7 +170,7 @@ static Transform blender_camera_matrix(const Transform& tfm, CameraType type) { Transform result; - if(type == CAMERA_ENVIRONMENT) { + if(type == CAMERA_PANORAMA) { /* make it so environment camera needs to be pointed in the direction of the positive x-axis to match an environment texture, this way it is looking at the center of the texture */ @@ -172,6 +204,9 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int bool horizontal_fit; float sensor_size; + cam->sensorwidth = bcam->sensor_width; + cam->sensorheight = bcam->sensor_height; + if(bcam->sensor_fit == BlenderCamera::AUTO) { horizontal_fit = (xratio > yratio); sensor_size = bcam->sensor_width; @@ -203,7 +238,7 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int aspectratio = bcam->ortho_scale/2.0f; } - if(bcam->type == CAMERA_ENVIRONMENT) { + if(bcam->type == CAMERA_PANORAMA) { /* set viewplane */ cam->left = 0.0f; cam->right = 1.0f; @@ -240,6 +275,11 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int /* type */ cam->type = bcam->type; + /* panorama */ + cam->panorama_type = bcam->panorama_type; + cam->fisheye_fov = bcam->fisheye_fov; + cam->fisheye_lens = bcam->fisheye_lens; + /* perspective */ cam->fov = 2.0f*atan((0.5f*sensor_size)/bcam->lens/aspectratio); cam->focaldistance = bcam->focaldistance; diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index e4b10f6151c..6d49fd96dd7 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -132,16 +132,40 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa #endif } -/* Environment Camera */ +/* Panorama Camera */ -__device void camera_sample_environment(KernelGlobals *kg, float raster_x, float raster_y, Ray *ray) +__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v, Ray *ray) +{ + switch (kernel_data.cam.panorama_type) { + case PANORAMA_EQUIRECTANGULAR: + return equirectangular_to_direction(u, v); + break; + case PANORAMA_FISHEYE_EQUIDISTANT: + return fisheye_to_direction(u, v, kernel_data.cam.fisheye_fov, ray); + break; + case PANORAMA_FISHEYE_EQUISOLID: + default: + return fisheye_equisolid_to_direction(u, v, kernel_data.cam.fisheye_lens, kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight, ray); + break; + } +} + +__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, Ray *ray) { Transform rastertocamera = kernel_data.cam.rastertocamera; float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f)); /* create ray form raster position */ ray->P = make_float3(0.0f, 0.0f, 0.0f); - ray->D = equirectangular_to_direction(Pcamera.x, Pcamera.y); + +#ifdef __CAMERA_CLIPPING__ + /* clipping */ + ray->t = kernel_data.cam.cliplength; +#else + ray->t = FLT_MAX; +#endif + + ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray); /* transform ray from camera to world */ Transform cameratoworld = kernel_data.cam.cameratoworld; @@ -161,17 +185,11 @@ __device void camera_sample_environment(KernelGlobals *kg, float raster_x, float ray->dP.dy = make_float3(0.0f, 0.0f, 0.0f); Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f)); - ray->dD.dx = normalize(transform_direction(&cameratoworld, equirectangular_to_direction(Pcamera.x, Pcamera.y))) - ray->D; + ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray))) - ray->D; Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f)); - ray->dD.dy = normalize(transform_direction(&cameratoworld, equirectangular_to_direction(Pcamera.x, Pcamera.y))) - ray->D; -#endif + ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray))) - ray->D; -#ifdef __CAMERA_CLIPPING__ - /* clipping */ - ray->t = kernel_data.cam.cliplength; -#else - ray->t = FLT_MAX; #endif } @@ -198,7 +216,7 @@ __device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, flo else if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) camera_sample_orthographic(kg, raster_x, raster_y, ray); else - camera_sample_environment(kg, raster_x, raster_y, ray); + camera_sample_panorama(kg, raster_x, raster_y, ray); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index 68f007cfd97..3fb4d41ce06 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -224,6 +224,57 @@ __device float3 equirectangular_to_direction(float u, float v) cos(theta)); } +/* Fisheye <- Cartesian direction */ + +__device float3 fisheye_to_direction(float u, float v, float fov, Ray *ray) +{ + u = (u - 0.5f) * 2.f; + v = (v - 0.5f) * 2.f; + + float r = sqrt(u*u + v*v); + + if (r > 1.0) { + ray->t = 0.f; + return make_float3(0.f,0.f,0.f); + } + + float phi = acosf((r!=0.f)?u/r:0.f); + float theta = asinf(r) * (fov / M_PI_F); + + if (v < 0.f) phi = -phi; + + return make_float3( + cosf(theta), + -cosf(phi)*sinf(theta), + sinf(phi)*sinf(theta) + ); +} + +__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height, Ray *ray) +{ + u = (u - 0.5f) * width; + v = (v - 0.5f) * height; + + float rmax = 2.f * lens * sinf(fov * 0.5f); + float r = sqrt(u*u + v*v); + + if (r > rmax) { + ray->t = 0.f; + return make_float3(0.f,0.f,0.f); + } + + float phi = acosf((r!=0.f)?u/r:0.f); + float theta = 2.f * asinf(r/(2.f * lens)); + + if (v < 0.f) phi = -phi; + + return make_float3( + cosf(theta), + -cosf(phi)*sinf(theta), + sinf(phi)*sinf(theta) + ); +} + /* Mirror Ball <-> Cartesion direction */ __device float3 mirrorball_to_direction(float u, float v) diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 87d996ef9e2..d53951a1f34 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -474,7 +474,12 @@ __device void kernel_path_trace(KernelGlobals *kg, camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, &ray); /* integrate */ - float4 L = kernel_path_integrate(kg, &rng, sample, ray, buffer); + float4 L; + + if (ray.t != 0.f) + L = kernel_path_integrate(kg, &rng, sample, ray, buffer); + else + L = make_float4(0.f, 0.f, 0.f, 0.f); /* accumulate result in output buffer */ kernel_write_pass_float4(buffer, sample, L); diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 85ee16fc5c6..25ff7f73888 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -268,7 +268,15 @@ typedef enum LightType { enum CameraType { CAMERA_PERSPECTIVE, CAMERA_ORTHOGRAPHIC, - CAMERA_ENVIRONMENT + CAMERA_PANORAMA +}; + +/* Panorama Type */ + +enum PanoramaType { + PANORAMA_EQUIRECTANGULAR, + PANORAMA_FISHEYE_EQUIDISTANT, + PANORAMA_FISHEYE_EQUISOLID }; /* Differential */ @@ -452,7 +460,11 @@ typedef struct ShaderData { typedef struct KernelCamera { /* type */ int type; - int pad1, pad2, pad3; + + /* panorama */ + int panorama_type; + float fisheye_fov; + float fisheye_lens; /* matrices */ Transform cameratoworld; @@ -476,6 +488,11 @@ typedef struct KernelCamera { float nearclip; float cliplength; + /* sensor size */ + float sensorwidth; + float sensorheight; + int pad1, pad2; + /* more matrices */ Transform screentoworld; Transform rastertoworld; diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index f0b77871130..95405519cc0 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -39,8 +39,14 @@ Camera::Camera() use_motion = false; type = CAMERA_PERSPECTIVE; + panorama_type = PANORAMA_EQUIRECTANGULAR; + fisheye_fov = M_PI_F; + fisheye_lens = 10.5f; fov = M_PI_F/4.0f; + sensorwidth = 0.036; + sensorheight = 0.024; + nearclip = 1e-5f; farclip = 1e5f; @@ -181,6 +187,15 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) /* type */ kcam->type = type; + /* panorama */ + kcam->panorama_type = panorama_type; + kcam->fisheye_fov = fisheye_fov; + kcam->fisheye_lens = fisheye_lens; + + /* sensor size */ + kcam->sensorwidth = sensorwidth; + kcam->sensorheight = sensorheight; + /* store differentials */ kcam->dx = float3_to_float4(dx); kcam->dy = float3_to_float4(dy); @@ -208,6 +223,8 @@ bool Camera::modified(const Camera& cam) (fov == cam.fov) && (nearclip == cam.nearclip) && (farclip == cam.farclip) && + (sensorwidth == cam.sensorwidth) && + (sensorheight == cam.sensorheight) && // modified for progressive render // (width == cam.width) && // (height == cam.height) && @@ -217,7 +234,10 @@ bool Camera::modified(const Camera& cam) (top == cam.top) && (matrix == cam.matrix) && (motion == cam.motion) && - (use_motion == cam.use_motion)); + (use_motion == cam.use_motion) && + (panorama_type == cam.panorama_type) && + (fisheye_fov == cam.fisheye_fov) && + (fisheye_lens == cam.fisheye_lens)); } void Camera::tag_update() diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index 935489711c8..7a09b5981e4 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -50,6 +50,15 @@ public: CameraType type; float fov; + /* panorama */ + PanoramaType panorama_type; + float fisheye_fov; + float fisheye_lens; + + /* sensor */ + float sensorwidth; + float sensorheight; + /* clipping */ float nearclip; float farclip; diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py index 5da41a668f6..49457b8e569 100644 --- a/release/scripts/startup/bl_ui/properties_data_camera.py +++ b/release/scripts/startup/bl_ui/properties_data_camera.py @@ -87,10 +87,16 @@ class DATA_PT_lens(CameraButtonsPanel, Panel): elif cam.type == 'ORTHO': col.prop(cam, "ortho_scale") - col = layout.column() - col.enabled = cam.type == 'PERSP' - - col.prop(cam, "use_panorama") + elif cam.type == 'PANO': + if context.scene.render.engine == 'CYCLES': + ccam = cam.cycles + col.prop(ccam, "panorama_type", text="Type") + if ccam.panorama_type == 'FISHEYE_EQUIDISTANT': + col.prop(ccam, "fisheye_fov") + elif ccam.panorama_type == 'FISHEYE_EQUISOLID': + row = layout.row() + row.prop(ccam, "fisheye_lens", text="Lens") + row.prop(ccam, "fisheye_fov") split = layout.split() diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 2be22e0e28b..6b1c6a26493 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -141,7 +141,7 @@ void object_camera_mode(RenderData *rd, Object *cam_ob) if (cam_ob && cam_ob->type==OB_CAMERA) { Camera *cam= cam_ob->data; if (cam->type == CAM_ORTHO) rd->mode |= R_ORTHO; - if (cam->flag & CAM_PANORAMA) rd->mode |= R_PANORAMA; + if (cam->type == CAM_PANO) rd->mode |= R_PANORAMA; } } diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 89621cdf48d..268b4cbe4a3 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -138,7 +138,7 @@ UvCameraInfo *project_camera_info(Object *ob, float(*rotmat)[4], float winx, flo UvCameraInfo uci; Camera *camera = ob->data; - uci.do_pano = (camera->flag & CAM_PANORAMA); + uci.do_pano = (camera->type == CAM_PANO); uci.do_persp = (camera->type == CAM_PERSP); uci.camangle = focallength_to_fov(camera->lens, camera->sensor_x) / 2.0f; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index cab45f58e2e..9e921b55635 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7398,6 +7398,18 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4)) + { + Camera *cam; + + for (cam = main->camera.first; cam; cam = cam->id.next) { + if (cam->flag & CAM_PANORAMA) { + cam->type = CAM_PANO; + cam->flag &= ~CAM_PANORAMA; + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp index c3614ac49a2..ce46c681c8c 100644 --- a/source/blender/collada/CameraExporter.cpp +++ b/source/blender/collada/CameraExporter.cpp @@ -67,8 +67,10 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) Camera *cam = (Camera*)ob->data; std::string cam_id(get_camera_id(ob)); std::string cam_name(id_name(cam)); - - if (cam->type == CAM_PERSP) { + + switch (cam->type) { + case CAM_PANO: + case CAM_PERSP: { COLLADASW::PerspectiveOptic persp(mSW); persp.setXFov(RAD2DEGF(focallength_to_fov(cam->lens, cam->sensor_x)), "xfov"); persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio"); @@ -76,8 +78,11 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) persp.setZNear(cam->clipsta, false, "znear"); COLLADASW::Camera ccam(mSW, &persp, cam_id, cam_name); addCamera(ccam); + break; } - else { + case CAM_ORTHO: + default: + { COLLADASW::OrthographicOptic ortho(mSW); ortho.setXMag(cam->ortho_scale, "xmag"); ortho.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch), false, "aspect_ratio"); @@ -85,5 +90,6 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) ortho.setZNear(cam->clipsta, false, "znear"); COLLADASW::Camera ccam(mSW, &ortho, cam_id, cam_name); addCamera(ccam); - } -} + break; + }} +} diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 112247f3d66..73cebfb3d9f 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -48,7 +48,7 @@ typedef struct Camera { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ - char type; /* CAM_PERSP or CAM_ORTHO */ + char type; /* CAM_PERSP, CAM_ORTHO or CAM_PANO */ char dtx; /* draw type extra */ short flag; float passepartalpha; @@ -75,6 +75,7 @@ typedef struct Camera { /* type */ #define CAM_PERSP 0 #define CAM_ORTHO 1 +#define CAM_PANO 2 /* dtx */ #define CAM_DTX_CENTER 1 @@ -94,7 +95,7 @@ typedef struct Camera { #define CAM_SHOWNAME 16 #define CAM_ANGLETOGGLE 32 #define CAM_DS_EXPAND 64 -#define CAM_PANORAMA 128 +#define CAM_PANORAMA 128 /* deprecated */ #define CAM_SHOWSENSOR 256 /* yafray: dof sampling switch */ diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 180479d6f63..5331cfe8775 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -97,6 +97,7 @@ void RNA_def_camera(BlenderRNA *brna) static EnumPropertyItem prop_type_items[] = { {CAM_PERSP, "PERSP", 0, "Perspective", ""}, {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""}, + {CAM_PANO, "PANO", 0, "Panoramic", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_draw_type_extra_items[] = { {CAM_DTX_CENTER, "CENTER", 0, "Center", ""}, @@ -271,12 +272,6 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_lens_unit_items); RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface"); - prop = RNA_def_property(srna, "use_panorama", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_PANORAMA); - RNA_def_property_ui_text(prop, "Panorama", - "Render the scene with a cylindrical camera for pseudo-fisheye lens effects"); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); - /* pointers */ rna_def_animdata_common(srna); diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 80a3b70d8e3..af98684c7e3 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -193,7 +193,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if (projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; - if (cam->flag & CAM_PANORAMA) { + if (cam->type == CAM_PANO) { projectors[i].uci= project_camera_info(projectors[i].ob, NULL, aspx, aspy); project_camera_info_scale(projectors[i].uci, scax, scay); free_uci= 1; From d710638c47491619f14495ffb130b183019782c5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 4 May 2012 16:29:41 +0000 Subject: [PATCH 60/88] small fix for equisolid fisheye (cycles) the FOV formular is: R = 2 * lens * sin (theta / 2) in this case theta is fov/2 already, thus the fix --- intern/cycles/kernel/kernel_montecarlo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index 3fb4d41ce06..ba24c2ea402 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -255,7 +255,7 @@ __device float3 fisheye_equisolid_to_direction(float u, float v, float lens, flo u = (u - 0.5f) * width; v = (v - 0.5f) * height; - float rmax = 2.f * lens * sinf(fov * 0.5f); + float rmax = 2.f * lens * sinf(fov * 0.25f); float r = sqrt(u*u + v*v); if (r > rmax) { From 0c318c4a476e013ffedf7786ec77e492352d0bcb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 May 2012 16:38:11 +0000 Subject: [PATCH 61/88] Fix (harmless) uninitialized memory usage in BVH binning. Fix unneeded warnings with c++ guardedalloc, delete NULL is valid. --- intern/cycles/bvh/bvh_binning.cpp | 1 + intern/guardedalloc/cpp/mallocn.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/intern/cycles/bvh/bvh_binning.cpp b/intern/cycles/bvh/bvh_binning.cpp index 661541a8d23..e4b88584a33 100644 --- a/intern/cycles/bvh/bvh_binning.cpp +++ b/intern/cycles/bvh/bvh_binning.cpp @@ -122,6 +122,7 @@ BVHObjectBinning::BVHObjectBinning(const BVHRange& job, BVHReference *prims) bx = merge(bx,bin_bounds[i][0]); r_area[i][0] = bx.half_area(); by = merge(by,bin_bounds[i][1]); r_area[i][1] = by.half_area(); bz = merge(bz,bin_bounds[i][2]); r_area[i][2] = bz.half_area(); + r_area[i][3] = r_area[i][2]; } /* sweep from left to right and compute SAH */ diff --git a/intern/guardedalloc/cpp/mallocn.cpp b/intern/guardedalloc/cpp/mallocn.cpp index 97e68d06ace..130fcb6960b 100644 --- a/intern/guardedalloc/cpp/mallocn.cpp +++ b/intern/guardedalloc/cpp/mallocn.cpp @@ -41,5 +41,7 @@ void* operator new (size_t size, const char *str) void operator delete (void *p) { - MEM_freeN(p); + /* delete NULL is valid in c++ */ + if(p) + MEM_freeN(p); } From a9ecc86ec935735c66c5fdbd926b4ae2e94eee97 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2012 17:02:02 +0000 Subject: [PATCH 62/88] fix [#31205] Loop cut don't slide when hidden faces between --- source/blender/editors/transform/transform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 81791721015..ae7d02e1cfb 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4387,7 +4387,7 @@ static int createSlideVerts(TransInfo *t) BMVert *v, *v2, *first; BMLoop *l, *l1, *l2; TransDataSlideVert *sv_array; - BMBVHTree *btree = BMBVH_NewBVH(em, 0, NULL, NULL); + BMBVHTree *btree = BMBVH_NewBVH(em, BMBVH_RESPECT_HIDDEN, NULL, NULL); SmallHash table; SlideData *sld = MEM_callocN(sizeof(*sld), "sld"); View3D *v3d = t->sa ? t->sa->spacedata.first : NULL; From 72fa15872489672694b9066ac9bbf7949ca847a8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 May 2012 17:04:20 +0000 Subject: [PATCH 63/88] Added start and end bevel factor for curves, so now it's possible to make a bevelled curve which isn't fully covered with a bevel. --- .../startup/bl_ui/properties_data_curve.py | 8 ++- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/intern/curve.c | 2 + source/blender/blenkernel/intern/displist.c | 67 +++++++++++++++---- source/blender/blenloader/intern/readfile.c | 16 +++-- source/blender/makesdna/DNA_curve_types.h | 2 + source/blender/makesrna/intern/rna_curve.c | 12 ++++ 7 files changed, 87 insertions(+), 22 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_curve.py b/release/scripts/startup/bl_ui/properties_data_curve.py index b8a37e38a17..6a7415f7cec 100644 --- a/release/scripts/startup/bl_ui/properties_data_curve.py +++ b/release/scripts/startup/bl_ui/properties_data_curve.py @@ -173,9 +173,11 @@ class DATA_PT_geometry_curve(CurveButtonsPanel, Panel): col.label(text="Bevel Object:") col.prop(curve, "bevel_object", text="") - row = col.row() - row.active = (curve.bevel_object is not None) - row.prop(curve, "use_fill_caps") + col = layout.column(align=True) + col.active = (curve.bevel_object is not None) + col.prop(curve, "use_fill_caps") + col.prop(curve, "bevel_factor_start") + col.prop(curve, "bevel_factor_end") class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel): diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 4ea38628001..62f1dbc5867 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 906757bdd62..85e3d85dfc4 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -169,6 +169,8 @@ Curve *BKE_curve_add(const char *name, int type) cu->smallcaps_scale= 0.75f; cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... cu->type= type; + cu->bevfac1= 0.0f; + cu->bevfac2= 1.0f; cu->bb= unit_boundbox(); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 1411c910894..de61929aa18 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1220,10 +1220,11 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid *data_r = data; } -static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, ListBase *dispbase) +static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *dispbase) { DispList *dl; float *data; + int b; dl= MEM_callocN(sizeof(DispList), "makeDispListbev2"); dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts"); @@ -1239,7 +1240,8 @@ static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, flo /* CU_2D conflicts with R_NOPUNOFLIP */ dl->rt= nu->flag & ~CU_2D; - rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); + for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3) + copy_v3_v3(data, prev_fp); BLI_addtail(dispbase, dl); } @@ -1332,9 +1334,26 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase top_capbase = {NULL, NULL}; for (dlb=dlbev.first; dlb; dlb=dlb->next) { + int i, start, steps; + float bevfac1 = MIN2(cu->bevfac1, cu->bevfac2), bevfac2 = MAX2(cu->bevfac1, cu->bevfac2); + float firstblend = 0.0f, lastblend = 0.0f; + + if (cu->bevfac1 - cu->bevfac2 == 0.0f) + continue; + + start = (int)(bevfac1*(bl->nr-1)); + steps = 2+(int)((bevfac2)*(bl->nr-1)) - start; + firstblend = 1.0f - ((float)bevfac1*(bl->nr-1) - (int)((float)bevfac1*(bl->nr-1))); + lastblend = (float)bevfac2*(bl->nr-1) - (int)((float)bevfac2*(bl->nr-1)); + + if (steps > bl->nr) { + steps = bl->nr; + lastblend = 1.0f; + } + /* for each part of the bevel use a separate displblock */ dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); - dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts"); + dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*steps, "dlverts"); BLI_addtail(dispbase, dl); dl->type= DL_SURF; @@ -1342,8 +1361,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE); if (dlb->type==DL_POLY) dl->flag |= DL_CYCL_U; if (bl->poly>=0) dl->flag |= DL_CYCL_V; - - dl->parts= bl->nr; + + dl->parts= steps; dl->nr= dlb->nr; dl->col= nu->mat_nr; dl->charidx= nu->charidx; @@ -1352,18 +1371,20 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* CU_2D conflicts with R_NOPUNOFLIP */ dl->rt= nu->flag & ~CU_2D; - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "bevelSplitFlag"); + dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+0x1F)>>5), "bevelSplitFlag"); /* for each point of poly make a bevel piece */ - bevp= (BevPoint *)(bl+1); - for (a=0; anr; a++, bevp++) { + bevp= (BevPoint *)(bl+1) + start; + for (i=start, a=0; ataperobj==NULL) { if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { - fac = calc_taper(scene, cu->taperobj, a, bl->nr); + fac = calc_taper(scene, cu->taperobj, i, bl->nr); } if (bevp->split_tag) { @@ -1373,11 +1394,31 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* rotate bevel piece and write in data */ rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); + if (a == 1 || a == steps - 1) { + float *cur_fp = cur_data, *prev_fp = cur_data - 3*dlb->nr; + int b; + + for (b = 0; b < dlb->nr; b++, prev_fp += 3, cur_fp += 3) { + float cur[3], prev[3]; + + copy_v3_v3(cur, cur_fp); + copy_v3_v3(prev, prev_fp); + + if (a == 1) + interp_v3_v3v3(prev, cur_fp, prev_fp, firstblend); + if (a == steps - 1) + interp_v3_v3v3(cur, prev_fp, cur_fp, lastblend); + + copy_v3_v3(cur_fp, cur); + copy_v3_v3(prev_fp, prev); + } + } + if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { - if (a == 0) - fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &bottom_capbase); - else if (a == bl->nr - 1) - fillBevelCap(cu, nu, bevp, dlb, fac, widfac, &top_capbase); + if (a == 1) + fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase); + if (a == steps - 1) + fillBevelCap(nu, dlb, cur_data, &top_capbase); } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9e921b55635..c07b1d4f66a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7390,17 +7390,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4)) { Lamp *la; + Camera *cam; + Curve *cu; + for (la= main->lamp.first; la; la= la->id.next) { if (la->shadow_frustum_size == 0.0) la->shadow_frustum_size= 10.0f; } - } - - if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 4)) - { - Camera *cam; for (cam = main->camera.first; cam; cam = cam->id.next) { if (cam->flag & CAM_PANORAMA) { @@ -7408,6 +7407,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) cam->flag &= ~CAM_PANORAMA; } } + + for(cu= main->curve.first; cu; cu= cu->id.next) { + if(cu->bevfac2 == 0.0f) { + cu->bevfac1 = 0.0f; + cu->bevfac2 = 1.0f; + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index c9d80476fde..acdd25a101e 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -234,6 +234,8 @@ typedef struct Curve { struct CharInfo *strinfo; struct CharInfo curinfo; + + float bevfac1, bevfac2; } Curve; /* **************** CURVE ********************* */ diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index cdfaa8aae1d..a62ee6d78d1 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1470,6 +1470,18 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Materials", ""); RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */ RNA_def_property_collection_funcs(prop, 0, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int"); + + prop = RNA_def_property(srna, "bevel_factor_start", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "bevfac1"); + RNA_def_property_range(prop, 0, 1.0); + RNA_def_property_ui_text(prop, "Start Bevel Factor", "Factor that defines from where beveling of spline happens (0=from the very beginning, 1=from the very end)"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + prop = RNA_def_property(srna, "bevel_factor_end", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "bevfac2"); + RNA_def_property_range(prop, 0, 1.0); + RNA_def_property_ui_text(prop, "End Bevel Factor", "Factor that defines to where beveling of spline happens (0=to the very beginning, 1=to the very end)"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_curve_nurb(BlenderRNA *brna) From ad93736bd461d4e78fad3816dc4d6789ceb20b10 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Fri, 4 May 2012 17:39:14 +0000 Subject: [PATCH 64/88] Windows: * Fix compile for recent do_versions() splitting. --- source/blender/blenloader/intern/versioning_250.c | 2 ++ source/blender/blenloader/intern/versioning_legacy.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index c6bab33f364..8b4471086a8 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -28,6 +28,8 @@ /** \file blender/blenloader/intern/readfile_250.c * \ingroup blenloader */ + +#include "zlib.h" #ifndef WIN32 # include // for read close diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index fc238204251..7d8905d5902 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -30,7 +30,7 @@ */ -//#include "zlib.h" +#include "zlib.h" #include //#include // for printf fopen fwrite fclose sprintf FILE From e96187250e6b570432ddb88b761171c2afc88c44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 May 2012 17:39:37 +0000 Subject: [PATCH 65/88] fix [#31136] Save All Edited only works for Saved external image, not New or Packed image (bpy.ops.image.save_dirty) --- release/scripts/startup/bl_operators/image.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py index 1b7d5e3a40d..6af6488e86b 100644 --- a/release/scripts/startup/bl_operators/image.py +++ b/release/scripts/startup/bl_operators/image.py @@ -118,16 +118,24 @@ class SaveDirty(Operator): unique_paths = set() for image in bpy.data.images: if image.is_dirty: - filepath = bpy.path.abspath(image.filepath) - if "\\" not in filepath and "/" not in filepath: - self.report({'WARNING'}, "Invalid path: " + filepath) - elif filepath in unique_paths: - self.report({'WARNING'}, - "Path used by more then one image: %r" % - filepath) + if image.packed_file: + if image.library: + self.report({'WARNING'}, + "Packed library image: %r from library %r can't be re-packed" % + (image.name, image.library.filepath)) + else: + image.pack(as_png=True) else: - unique_paths.add(filepath) - image.save() + filepath = bpy.path.abspath(image.filepath, library=image.library) + if "\\" not in filepath and "/" not in filepath: + self.report({'WARNING'}, "Invalid path: " + filepath) + elif filepath in unique_paths: + self.report({'WARNING'}, + "Path used by more then one image: %r" % + filepath) + else: + unique_paths.add(filepath) + image.save() return {'FINISHED'} From 54d2689a50f506dbd38d3b53a2fa00bb3f13c23c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 May 2012 18:00:37 +0000 Subject: [PATCH 66/88] Clip editor: fixed crash when opening dopesheet view without having clip opened --- source/blender/editors/space_clip/space_clip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 32a4a7d1f83..1c0d2db91a9 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1135,7 +1135,8 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) View2DScrollers *scrollers; short unit = 0; - BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + if (clip) + BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -1194,7 +1195,8 @@ static void clip_channels_area_draw(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); + if (clip) + BKE_tracking_dopesheet_update(&clip->tracking, sc->dope_sort, sc->dope_flag & SC_DOPE_SORT_INVERSE); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); From 0f5e1f2ff0221e20b6e23579a7baae20aa600e72 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Fri, 4 May 2012 23:28:27 +0000 Subject: [PATCH 67/88] Fixes for * [#31285] VSE: audio pitch change delays audio * [#31260] VSE Trimmed audio plays when overlaped --- intern/audaspace/intern/AUD_SequencerHandle.cpp | 1 + .../editors/space_sequencer/sequencer_edit.c | 16 ---------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/intern/audaspace/intern/AUD_SequencerHandle.cpp b/intern/audaspace/intern/AUD_SequencerHandle.cpp index d13efb9683b..f4bfae6cee7 100644 --- a/intern/audaspace/intern/AUD_SequencerHandle.cpp +++ b/intern/audaspace/intern/AUD_SequencerHandle.cpp @@ -154,6 +154,7 @@ void AUD_SequencerHandle::seek(float position) if(seekpos < 0) seekpos = 0; seekpos += m_entry->m_skip; + m_handle->setPitch(1.0f); m_handle->seek(seekpos); if(position < m_entry->m_begin) m_handle->pause(); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 5766099aabb..b021c233f8c 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -2657,19 +2657,6 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) /* properties */ } -static void seq_paste_add_sound(Scene *scene, Sequence *seq) -{ - if (seq->type == SEQ_META) { - Sequence *iseq; - for (iseq = seq->seqbase.first; iseq; iseq = iseq->next) { - seq_paste_add_sound(scene, iseq); - } - } - else if (seq->type == SEQ_SOUND) { - seq->scene_sound = sound_add_scene_sound_defaults(scene, seq); - } -} - static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -2698,9 +2685,6 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) /* make sure the pasted strips have unique names between them */ for (; iseq; iseq = iseq->next) { seq_recursive_apply(iseq, apply_unique_name_cb, scene); - - /* restore valid sound_scene for newly added strips */ - seq_paste_add_sound(scene, iseq); } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); From 9466af0eabf05bfcb966cac01ee72dca544f7dd1 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Fri, 4 May 2012 23:36:10 +0000 Subject: [PATCH 68/88] Patch [#31240] Fix audaspace deadlock fix for [#31097] glibc error when playing sound using BGE by Wander Lairson Costa Note: This deadlock fix makes the code non-threadsafe again, a proper solution has to be found still. --- intern/audaspace/intern/AUD_Reference.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/intern/audaspace/intern/AUD_Reference.h b/intern/audaspace/intern/AUD_Reference.h index 0c9f02c0155..5a1aa947148 100644 --- a/intern/audaspace/intern/AUD_Reference.h +++ b/intern/audaspace/intern/AUD_Reference.h @@ -174,8 +174,14 @@ public: std::cerr << "-" << typeid(*m_reference).name() << std::endl; #endif if(AUD_ReferenceHandler::decref(m_original)) + { + pthread_mutex_unlock(AUD_ReferenceHandler::getMutex()); delete m_reference; - pthread_mutex_unlock(AUD_ReferenceHandler::getMutex()); + } + else + { + pthread_mutex_unlock(AUD_ReferenceHandler::getMutex()); + } } /** @@ -194,7 +200,11 @@ public: std::cerr << "-" << typeid(*m_reference).name() << std::endl; #endif if(AUD_ReferenceHandler::decref(m_original)) + { + pthread_mutex_unlock(AUD_ReferenceHandler::getMutex()); delete m_reference; + pthread_mutex_lock(AUD_ReferenceHandler::getMutex()); + } m_original = ref.m_original; m_reference = ref.m_reference; From 4c5502bfd690cad5c02aa6a0be0bd59400ef3407 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 00:23:55 +0000 Subject: [PATCH 69/88] code cleanup: function naming for BLI functions. --- source/blender/blenkernel/intern/blender.c | 4 +- source/blender/blenkernel/intern/displist.c | 12 +++--- .../blenkernel/intern/editderivedmesh.c | 12 +++--- source/blender/blenkernel/intern/library.c | 6 +-- source/blender/blenkernel/intern/mesh.c | 12 +++--- source/blender/blenkernel/intern/scene.c | 12 +++--- source/blender/blenlib/BLI_bitmap.h | 2 +- source/blender/blenlib/BLI_boxpack2d.h | 6 +-- source/blender/blenlib/BLI_bpath.h | 30 ++++++------- source/blender/blenlib/BLI_callbacks.h | 8 ++-- source/blender/blenlib/BLI_jitter.h | 2 +- source/blender/blenlib/BLI_scanfill.h | 12 +++--- source/blender/blenlib/BLI_uvproject.h | 12 +++--- source/blender/blenlib/BLI_voxel.h | 10 ++--- source/blender/blenlib/intern/boxpack2d.c | 22 +++++----- source/blender/blenlib/intern/bpath.c | 42 +++++++++---------- source/blender/blenlib/intern/callbacks.c | 8 ++-- source/blender/blenlib/intern/jitter.c | 2 +- source/blender/blenlib/intern/scanfill.c | 22 +++++----- source/blender/blenlib/intern/uvproject.c | 20 ++++----- source/blender/blenlib/intern/voxel.c | 16 +++---- source/blender/blenloader/intern/writefile.c | 4 +- .../blender/bmesh/operators/bmo_triangulate.c | 12 +++--- source/blender/editors/mesh/editmesh_knife.c | 12 +++--- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/space_info/info_ops.c | 8 ++-- .../editors/uvedit/uvedit_parametrizer.c | 6 +-- .../editors/uvedit/uvedit_unwrap_ops.c | 20 ++++----- .../blender/modifiers/intern/MOD_uvproject.c | 8 ++-- source/blender/python/intern/bpy.c | 8 ++-- .../blender/python/intern/bpy_app_handlers.c | 2 +- .../python/mathutils/mathutils_geometry.c | 14 +++---- .../blender/render/intern/source/initrender.c | 4 +- .../blender/render/intern/source/pipeline.c | 20 ++++----- source/blender/render/intern/source/shadbuf.c | 2 +- .../render/intern/source/volume_precache.c | 10 ++--- .../blender/render/intern/source/volumetric.c | 6 +-- .../blender/render/intern/source/voxeldata.c | 10 ++--- source/blender/render/intern/source/zbuf.c | 2 +- .../blender/windowmanager/intern/wm_files.c | 8 ++-- .../blender/windowmanager/intern/wm_gesture.c | 12 +++--- source/creator/creator.c | 2 +- 42 files changed, 222 insertions(+), 222 deletions(-) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 2b741d6d8eb..b0bfd2ee98d 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -110,7 +110,7 @@ void free_blender(void) IMB_exit(); - BLI_cb_finalize(); + BLI_callback_global_finalize(); seq_stripelem_cache_destruct(); IMB_moviecache_destruct(); @@ -173,7 +173,7 @@ static void clean_paths(Main *main) { Scene *scene; - bpath_traverse_main(main, clean_paths_visit_cb, BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); + BLI_bpath_traverse_main(main, clean_paths_visit_cb, BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); for (scene= main->scene.first; scene; scene= scene->id.next) { BLI_clean(scene->r.pic); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index de61929aa18..cf7750520a3 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -432,7 +432,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) totvert= 0; nextcol= 0; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); dl= dispbase->first; while (dl) { @@ -449,18 +449,18 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) while (a--) { vlast= eve; - eve = BLI_addfillvert(&sf_ctx, f1); + eve = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; if (vlast==NULL) v1= eve; else { - BLI_addfilledge(&sf_ctx, vlast, eve); + BLI_scanfill_edge_add(&sf_ctx, vlast, eve); } f1+=3; } if (eve!=NULL && v1!=NULL) { - BLI_addfilledge(&sf_ctx, eve, v1); + BLI_scanfill_edge_add(&sf_ctx, eve, v1); } } else if (colnrcol) { @@ -473,7 +473,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) dl= dl->next; } - if (totvert && (tot= BLI_edgefill(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { + if (totvert && (tot= BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { if (tot) { dlnew= MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type= DL_INDEX3; @@ -518,7 +518,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) BLI_addhead(to, dlnew); } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); if (nextcol) { /* stay at current char but fill polys with next material */ diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 8d7ac99e2a3..428dc176e1d 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -196,18 +196,18 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) ScanFillFace *efa; int totfilltri; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); /*scanfill time*/ l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f); for (j=0; l; l=BM_iter_step(&liter), j++) { /*mark order*/ BM_elem_index_set(l, j); /* set_loop */ - v = BLI_addfillvert(&sf_ctx, l->v->co); + v = BLI_scanfill_vert_add(&sf_ctx, l->v->co); v->tmp.p = l; if (lastv) { - /* e = */ BLI_addfilledge(&sf_ctx, lastv, v); + /* e = */ BLI_scanfill_edge_add(&sf_ctx, lastv, v); } lastv = v; @@ -215,9 +215,9 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) } /*complete the loop*/ - BLI_addfilledge(&sf_ctx, firstv, v); + BLI_scanfill_edge_add(&sf_ctx, firstv, v); - totfilltri = BLI_edgefill_ex(&sf_ctx, FALSE, f->no); + totfilltri = BLI_scanfill_calc_ex(&sf_ctx, FALSE, f->no); BLI_array_grow_items(looptris, totfilltri); for (efa = sf_ctx.fillfacebase.first; efa; efa=efa->next) { @@ -235,7 +235,7 @@ static void BMEdit_RecalcTessellation_intern(BMEditMesh *tm) i += 1; } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); } } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 2924ea457a8..14ab8166f0a 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -135,9 +135,9 @@ void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id) { char *bpath_user_data[2]= {bmain->name, lib->filepath}; - bpath_traverse_id(bmain, id, - bpath_relocate_visitor, - BPATH_TRAVERSE_SKIP_MULTIFILE, + BLI_bpath_traverse_id(bmain, id, + BLI_bpath_relocate_visitor, + BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, bpath_user_data); } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 6dd5923a803..4b14c2aec4b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2481,24 +2481,24 @@ int mesh_recalcTessellation(CustomData *fdata, ml = mloop + mp->loopstart; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); firstv = NULL; lastv = NULL; for (j=0; jtotloop; j++, ml++) { - v = BLI_addfillvert(&sf_ctx, mvert[ml->v].co); + v = BLI_scanfill_vert_add(&sf_ctx, mvert[ml->v].co); v->keyindex = mp->loopstart + j; if (lastv) - BLI_addfilledge(&sf_ctx, lastv, v); + BLI_scanfill_edge_add(&sf_ctx, lastv, v); if (!firstv) firstv = v; lastv = v; } - BLI_addfilledge(&sf_ctx, lastv, firstv); + BLI_scanfill_edge_add(&sf_ctx, lastv, firstv); - totfilltri = BLI_edgefill(&sf_ctx, FALSE); + totfilltri = BLI_scanfill_calc(&sf_ctx, FALSE); if (totfilltri) { BLI_array_grow_items(mface_to_poly_map, totfilltri); BLI_array_grow_items(mface, totfilltri); @@ -2531,7 +2531,7 @@ int mesh_recalcTessellation(CustomData *fdata, } } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); } } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index c8f41f26c9b..c66aa375a13 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1007,7 +1007,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen void scene_update_tagged(Main *bmain, Scene *scene) { /* keep this first */ - BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); + BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); @@ -1035,7 +1035,7 @@ void scene_update_tagged(Main *bmain, Scene *scene) BKE_ptcache_quick_cache_all(bmain, scene); /* notify editors and python about recalc */ - BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST); + BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST); DAG_ids_check_recalc(bmain, scene, FALSE); /* clear recalc flags */ @@ -1049,8 +1049,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) Scene *sce_iter; /* keep this first */ - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE); - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE); sound_set_cfra(sce->r.cfra); @@ -1084,8 +1084,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) scene_update_tagged_recursive(bmain, sce, sce); /* notify editors and python about recalc */ - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST); - BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST); + BLI_callback_exec(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST); DAG_ids_check_recalc(bmain, sce, TRUE); diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h index 2aed71a7d44..f19d6d6f465 100644 --- a/source/blender/blenlib/BLI_bitmap.h +++ b/source/blender/blenlib/BLI_bitmap.h @@ -69,7 +69,7 @@ typedef unsigned int* BLI_bitmap; /* set or clear the value of a single bit at '_index' */ #define BLI_BITMAP_MODIFY(_bitmap, _index, _set) \ do { \ - if(_set) \ + if (_set) \ BLI_BITMAP_SET(_bitmap, _index); \ else \ BLI_BITMAP_CLEAR(_bitmap, _index); \ diff --git a/source/blender/blenlib/BLI_boxpack2d.h b/source/blender/blenlib/BLI_boxpack2d.h index 7f92047b312..77e937d7b6f 100644 --- a/source/blender/blenlib/BLI_boxpack2d.h +++ b/source/blender/blenlib/BLI_boxpack2d.h @@ -34,7 +34,7 @@ /* Box Packer */ -typedef struct boxPack { +typedef struct BoxPack { float x; float y; float w; @@ -44,9 +44,9 @@ typedef struct boxPack { /* Verts this box uses * (BL,TR,TL,BR) / 0,1,2,3 */ struct boxVert *v[4]; -} boxPack; +} BoxPack; -void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_height); +void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float *tot_height); #endif diff --git a/source/blender/blenlib/BLI_bpath.h b/source/blender/blenlib/BLI_bpath.h index 91252d3beb5..27b373e6eb8 100644 --- a/source/blender/blenlib/BLI_bpath.h +++ b/source/blender/blenlib/BLI_bpath.h @@ -43,25 +43,25 @@ struct ReportList; * path has changed, and in that case, should write the result to pathOut. */ typedef int (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src); /* Executes 'visit' for each path associated with 'id'. */ -void bpath_traverse_id(struct Main *bmain, struct ID *id, BPathVisitor visit_cb, const int flag, void *userdata); -void bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVisitor visit_cb, const int flag, void *userdata); -void bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata); -int bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src); +void BLI_bpath_traverse_id(struct Main *bmain, struct ID *id, BPathVisitor visit_cb, const int flag, void *userdata); +void BLI_bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVisitor visit_cb, const int flag, void *userdata); +void BLI_bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata); +int BLI_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src); -#define BPATH_TRAVERSE_ABS (1<<0) /* convert paths to absolute */ -#define BPATH_TRAVERSE_SKIP_LIBRARY (1<<2) /* skip library paths */ -#define BPATH_TRAVERSE_SKIP_PACKED (1<<3) /* skip packed data */ -#define BPATH_TRAVERSE_SKIP_MULTIFILE (1<<4) /* skip paths where a single dir is used with an array of files, eg. - * sequence strip images and pointcache. in this case only use the first - * file, this is needed for directory manipulation functions which might - * otherwise modify the same directory multiple times */ +#define BLI_BPATH_TRAVERSE_ABS (1<<0) /* convert paths to absolute */ +#define BLI_BPATH_TRAVERSE_SKIP_LIBRARY (1<<2) /* skip library paths */ +#define BLI_BPATH_TRAVERSE_SKIP_PACKED (1<<3) /* skip packed data */ +#define BLI_BPATH_TRAVERSE_SKIP_MULTIFILE (1<<4) /* skip paths where a single dir is used with an array of files, eg. + * sequence strip images and pointcache. in this case only use the first + * file, this is needed for directory manipulation functions which might + * otherwise modify the same directory multiple times */ /* high level funcs */ /* creates a text file with missing files if there are any */ -void checkMissingFiles(struct Main *bmain, struct ReportList *reports); -void makeFilesRelative(struct Main *bmain, const char *basedir, struct ReportList *reports); -void makeFilesAbsolute(struct Main *bmain, const char *basedir, struct ReportList *reports); -void findMissingFiles(struct Main *bmain, const char *searchpath, struct ReportList *reports); +void BLI_bpath_missing_files_check(struct Main *bmain, struct ReportList *reports); +void BLI_bpath_missing_files_find(struct Main *bmain, const char *searchpath, struct ReportList *reports); +void BLI_bpath_relative_convert(struct Main *bmain, const char *basedir, struct ReportList *reports); +void BLI_bpath_absolute_convert(struct Main *bmain, const char *basedir, struct ReportList *reports); #endif // __BLI_BPATH_H__ diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index b32a1e272c8..bfc336781aa 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -62,11 +62,11 @@ typedef struct { } bCallbackFuncStore; -void BLI_exec_cb(struct Main *main, struct ID *self, eCbEvent evt); -void BLI_add_cb(bCallbackFuncStore *funcstore, eCbEvent evt); +void BLI_callback_exec(struct Main *main, struct ID *self, eCbEvent evt); +void BLI_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt); -void BLI_cb_init(void); -void BLI_cb_finalize(void); +void BLI_callback_global_init(void); +void BLI_callback_global_finalize(void); /* This is blenlib internal only, unrelated to above */ diff --git a/source/blender/blenlib/BLI_jitter.h b/source/blender/blenlib/BLI_jitter.h index 9aa21a89521..c2a6250c154 100644 --- a/source/blender/blenlib/BLI_jitter.h +++ b/source/blender/blenlib/BLI_jitter.h @@ -32,7 +32,7 @@ * \ingroup bli */ -void BLI_initjit(float *jitarr, int num); +void BLI_jitter_init(float *jitarr, int num); void BLI_jitterate1(float *jit1, float *jit2, int num, float rad1); void BLI_jitterate2(float *jit1, float *jit2, int num, float rad2); diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index 26bcd50ef3e..081d5ccfb66 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -91,14 +91,14 @@ typedef struct ScanFillFace } ScanFillFace; /* scanfill.c: used in displist only... */ -struct ScanFillVert *BLI_addfillvert(ScanFillContext *sf_ctx, const float vec[3]); -struct ScanFillEdge *BLI_addfilledge(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2); +struct ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]); +struct ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2); -int BLI_begin_edgefill(ScanFillContext *sf_ctx); -int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup); -int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, +int BLI_scanfill_begin(ScanFillContext *sf_ctx); +int BLI_scanfill_calc(ScanFillContext *sf_ctx, const short do_quad_tri_speedup); +int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, const float nor_proj[3]); -void BLI_end_edgefill(ScanFillContext *sf_ctx); +void BLI_scanfill_end(ScanFillContext *sf_ctx); /* These callbacks are needed to make the lib finction properly */ diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h index 5abad87452c..516a9b8b237 100644 --- a/source/blender/blenlib/BLI_uvproject.h +++ b/source/blender/blenlib/BLI_uvproject.h @@ -24,22 +24,22 @@ * \ingroup bli */ -struct UvCameraInfo; +struct ProjCameraInfo; struct Object; /* create uv info from the camera, needs to be freed */ -struct UvCameraInfo *project_camera_info(struct Object *ob, float rotmat[4][4], float winx, float winy); +struct ProjCameraInfo *BLI_uvproject_camera_info(struct Object *ob, float rotmat[4][4], float winx, float winy); /* apply uv from uvinfo (camera) */ -void project_from_camera(float target[2], float source[3], struct UvCameraInfo *uci); +void BLI_uvproject_from_camera(float target[2], float source[3], struct ProjCameraInfo *uci); /* apply uv from perspective matrix */ -void project_from_view(float target[2], float source[3], float persmat[4][4], float rotmat[4][4], float winx, float winy); +void BLI_uvproject_from_view(float target[2], float source[3], float persmat[4][4], float rotmat[4][4], float winx, float winy); /* apply ortho uv's */ -void project_from_view_ortho(float target[2], float source[3], float rotmat[4][4]); +void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotmat[4][4]); /* so we can adjust scale with keeping the struct private */ -void project_camera_info_scale(struct UvCameraInfo *uci, float scale_x, float scale_y); +void BLI_uvproject_camera_info_scale(struct ProjCameraInfo *uci, float scale_x, float scale_y); #endif diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h index 4a13810a705..4e9e6f111db 100644 --- a/source/blender/blenlib/BLI_voxel.h +++ b/source/blender/blenlib/BLI_voxel.h @@ -33,12 +33,12 @@ */ /** find the index number of a voxel, given x/y/z integer coords and resolution vector */ -#define V_I(x, y, z, res) ( (z)*(res)[1]*(res)[0] + (y)*(res)[0] + (x) ) +#define BLI_VEXEL_INDEX(x, y, z, res) ((z) * (res)[1] * (res)[0] + (y) * (res)[0] + (x)) /* all input coordinates must be in bounding box 0.0 - 1.0 */ -float voxel_sample_nearest(float *data, const int res[3], const float co[3]); -float voxel_sample_trilinear(float *data, const int res[3], const float co[3]); -float voxel_sample_triquadratic(float *data, const int res[3], const float co[3]); -float voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline); +float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]); +float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3]); +float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float co[3]); +float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline); #endif /* __BLI_VOXEL_H__ */ diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 6631e36fc72..f1931d35819 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -38,14 +38,14 @@ typedef struct boxVert { float y; short free; - struct boxPack *trb; /* top right box */ - struct boxPack *blb; /* bottom left box */ - struct boxPack *brb; /* bottom right box */ - struct boxPack *tlb; /* top left box */ + struct BoxPack *trb; /* top right box */ + struct BoxPack *blb; /* bottom left box */ + struct BoxPack *brb; /* bottom right box */ + struct BoxPack *tlb; /* top left box */ /* Store last intersecting boxes here * speedup intersection testing */ - struct boxPack *isect_cache[4]; + struct BoxPack *isect_cache[4]; int index; } boxVert; @@ -105,7 +105,7 @@ typedef struct boxVert { /* qsort function - sort largest to smallest */ static int box_areasort(const void *p1, const void *p2) { - const boxPack *b1 = p1, *b2 = p2; + const BoxPack *b1 = p1, *b2 = p2; const float a1 = BOXAREA(b1); const float a2 = BOXAREA(b2); @@ -152,12 +152,12 @@ static int vertex_sort(const void *p1, const void *p2) * len - the number of boxes in the array. * tot_width and tot_height are set so you can normalize the data. * */ -void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_height) +void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float *tot_height) { boxVert *vert; /* the current vert */ int box_index, verts_pack_len, i, j, k, isect; int quad_flags[4] = {BLF, TRF, TLF, BRF}; /* use for looping */ - boxPack *box, *box_test; /*current box and another for intersection tests*/ + BoxPack *box, *box_test; /*current box and another for intersection tests*/ int *vertex_pack_indices; /*an array of indices used for sorting verts*/ if (!len) { @@ -167,11 +167,11 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he } /* Sort boxes, biggest first */ - qsort(boxarray, len, sizeof(boxPack), box_areasort); + qsort(boxarray, len, sizeof(BoxPack), box_areasort); /* add verts to the boxes, these are only used internally */ - vert = vertarray = MEM_mallocN(len * 4 * sizeof(boxVert), "boxPack Verts"); - vertex_pack_indices = MEM_mallocN(len * 3 * sizeof(int), "boxPack Indices"); + vert = vertarray = MEM_mallocN(len * 4 * sizeof(boxVert), "BoxPack Verts"); + vertex_pack_indices = MEM_mallocN(len * 3 * sizeof(int), "BoxPack Indices"); for (box = boxarray, box_index = 0, i = 0; box_index < len; box_index++, box++) { diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index 739c4e00cc7..48912eb927a 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -92,9 +92,9 @@ static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), co } /* high level function */ -void checkMissingFiles(Main *bmain, ReportList *reports) +void BLI_bpath_missing_files_check(Main *bmain, ReportList *reports) { - bpath_traverse_main(bmain, checkMissingFiles_visit_cb, BPATH_TRAVERSE_ABS, reports); + BLI_bpath_traverse_main(bmain, checkMissingFiles_visit_cb, BLI_BPATH_TRAVERSE_ABS, reports); } typedef struct BPathRemap_Data { @@ -129,7 +129,7 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char } } -void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) +void BLI_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports) { BPathRemap_Data data = {NULL}; @@ -141,7 +141,7 @@ void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) data.basedir = basedir; data.reports = reports; - bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data); + BLI_bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data); BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO, "Total files %d|Changed %d|Failed %d", @@ -171,8 +171,8 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char } } -/* similar to makeFilesRelative - keep in sync! */ -void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) +/* similar to BLI_bpath_relative_convert - keep in sync! */ +void BLI_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports) { BPathRemap_Data data = {NULL}; @@ -184,7 +184,7 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports) data.basedir = basedir; data.reports = reports; - bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data); + BLI_bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data); BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO, "Total files %d|Changed %d|Failed %d", @@ -293,14 +293,14 @@ static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char } } -void findMissingFiles(Main *bmain, const char *searchpath, ReportList *reports) +void BLI_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports) { struct BPathFind_Data data = {NULL}; data.reports = reports; BLI_split_dir_part(searchpath, data.searchdir, sizeof(data.searchdir)); - bpath_traverse_main(bmain, findMissingFiles_visit_cb, 0, (void *)&data); + BLI_bpath_traverse_main(bmain, findMissingFiles_visit_cb, 0, (void *)&data); } /* Run a visitor on a string, replacing the contents of the string as needed. */ @@ -378,19 +378,19 @@ static int rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *ab } /* Run visitor function 'visit' on all paths contained in 'id'. */ -void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data) +void BLI_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data) { Image *ima; - const char *absbase = (flag & BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL; + const char *absbase = (flag & BLI_BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL; - if ((flag & BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) { + if ((flag & BLI_BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) { return; } switch (GS(id->name)) { case ID_IM: ima= (Image *)id; - if (ima->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) { + if (ima->packedfile == NULL || (flag & BLI_BPATH_TRAVERSE_SKIP_PACKED) == 0) { if (ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data); } @@ -470,7 +470,7 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla case ID_SO: { bSound *sound= (bSound *)id; - if (sound->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) { + if (sound->packedfile == NULL || (flag & BLI_BPATH_TRAVERSE_SKIP_PACKED) == 0) { rewrite_path_fixed(sound->name, visit_cb, absbase, bpath_user_data); } } @@ -483,7 +483,7 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla case ID_VF: { VFont *vf= (VFont *)id; - if (vf->packedfile == NULL || (flag & BPATH_TRAVERSE_SKIP_PACKED) == 0) { + if (vf->packedfile == NULL || (flag & BLI_BPATH_TRAVERSE_SKIP_PACKED) == 0) { if (strcmp(vf->name, FO_BUILTIN_NAME) != 0) { rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data); } @@ -523,7 +523,7 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla int len= MEM_allocN_len(se) / sizeof(*se); int i; - if (flag & BPATH_TRAVERSE_SKIP_MULTIFILE) { + if (flag & BLI_BPATH_TRAVERSE_SKIP_MULTIFILE) { /* only operate on one path */ len= MIN2(1, len); } @@ -575,26 +575,26 @@ void bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int fla } } -void bpath_traverse_id_list(Main *bmain, ListBase *lb, BPathVisitor visit_cb, const int flag, void *bpath_user_data) +void BLI_bpath_traverse_id_list(Main *bmain, ListBase *lb, BPathVisitor visit_cb, const int flag, void *bpath_user_data) { ID *id; for (id = lb->first; id; id = id->next) { - bpath_traverse_id(bmain, id, visit_cb, flag, bpath_user_data); + BLI_bpath_traverse_id(bmain, id, visit_cb, flag, bpath_user_data); } } -void bpath_traverse_main(Main *bmain, BPathVisitor visit_cb, const int flag, void *bpath_user_data) +void BLI_bpath_traverse_main(Main *bmain, BPathVisitor visit_cb, const int flag, void *bpath_user_data) { ListBase *lbarray[MAX_LIBARRAY]; int a = set_listbasepointers(bmain, lbarray); while (a--) { - bpath_traverse_id_list(bmain, lbarray[a], visit_cb, flag, bpath_user_data); + BLI_bpath_traverse_id_list(bmain, lbarray[a], visit_cb, flag, bpath_user_data); } } /* Rewrites a relative path to be relative to the main file - unless the path is * absolute, in which case it is not altered. */ -int bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src) +int BLI_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src) { /* be sure there is low chance of the path being too short */ char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE]; diff --git a/source/blender/blenlib/intern/callbacks.c b/source/blender/blenlib/intern/callbacks.c index 0cb986d9090..876599f7480 100644 --- a/source/blender/blenlib/intern/callbacks.c +++ b/source/blender/blenlib/intern/callbacks.c @@ -28,7 +28,7 @@ static ListBase callback_slots[BLI_CB_EVT_TOT]= {{NULL}}; -void BLI_exec_cb(struct Main *main, struct ID *self, eCbEvent evt) +void BLI_callback_exec(struct Main *main, struct ID *self, eCbEvent evt) { ListBase *lb= &callback_slots[evt]; bCallbackFuncStore *funcstore; @@ -38,19 +38,19 @@ void BLI_exec_cb(struct Main *main, struct ID *self, eCbEvent evt) } } -void BLI_add_cb(bCallbackFuncStore *funcstore, eCbEvent evt) +void BLI_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt) { ListBase *lb= &callback_slots[evt]; BLI_addtail(lb, funcstore); } -void BLI_cb_init(void) +void BLI_callback_global_init(void) { /* do nothing */ } /* call on application exit */ -void BLI_cb_finalize(void) +void BLI_callback_global_finalize(void) { eCbEvent evt; for (evt= 0; evt < BLI_CB_EVT_TOT; evt++) { diff --git a/source/blender/blenlib/intern/jitter.c b/source/blender/blenlib/intern/jitter.c index c7977378f6a..afe31fb1377 100644 --- a/source/blender/blenlib/intern/jitter.c +++ b/source/blender/blenlib/intern/jitter.c @@ -136,7 +136,7 @@ void BLI_jitterate2(float *jit1, float *jit2, int num, float rad2) } -void BLI_initjit(float *jitarr, int num) +void BLI_jitter_init(float *jitarr, int num) { float *jit2, x, rad1, rad2, rad3; int i; diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 25850e14ae7..503de31616a 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -99,7 +99,7 @@ typedef struct ScanFillVertLink { #define SF_VERT_ZERO_LEN 255 /* Optionally set ScanFillEdge f to this to mark original boundary edges. - * Only needed if there are internal diagonal edges passed to BLI_edgefill. */ + * Only needed if there are internal diagonal edges passed to BLI_scanfill_calc. */ #define SF_EDGE_BOUNDARY 1 #define SF_EDGE_UNKNOWN 2 /* TODO, what is this for exactly? - need to document it! */ @@ -191,7 +191,7 @@ static void mem_element_reset(ScanFillContext *sf_ctx, int keep_first) sf_ctx->melem__offs = 0; } -void BLI_end_edgefill(ScanFillContext *sf_ctx) +void BLI_scanfill_end(ScanFillContext *sf_ctx) { mem_element_reset(sf_ctx, FALSE); @@ -202,7 +202,7 @@ void BLI_end_edgefill(ScanFillContext *sf_ctx) /* **** FILL ROUTINES *************************** */ -ScanFillVert *BLI_addfillvert(ScanFillContext *sf_ctx, const float vec[3]) +ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3]) { ScanFillVert *eve; @@ -214,7 +214,7 @@ ScanFillVert *BLI_addfillvert(ScanFillContext *sf_ctx, const float vec[3]) return eve; } -ScanFillEdge *BLI_addfilledge(ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2) +ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, ScanFillVert *v2) { ScanFillEdge *newed; @@ -453,7 +453,7 @@ static void testvertexnearedge(ScanFillContext *sf_ctx) const float dist = dist_to_line_v2(eed->v1->xy, eed->v2->xy, eve->xy); if (dist < SF_EPSILON) { /* new edge */ - ed1 = BLI_addfilledge(sf_ctx, eed->v1, eve); + ed1 = BLI_scanfill_edge_add(sf_ctx, eed->v1, eve); /* printf("fill: vertex near edge %x\n",eve); */ ed1->f = 0; @@ -681,7 +681,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf) /* make new edge, and start over */ /* printf("add new edge %x %x and start again\n",v2,sc1->v1); */ - ed3 = BLI_addfilledge(sf_ctx, v2, sc1->v1); + ed3 = BLI_scanfill_edge_add(sf_ctx, v2, sc1->v1); BLI_remlink(&sf_ctx->filledgebase, ed3); BLI_insertlinkbefore((ListBase *)&(sc->first), ed2, ed3); ed3->v2->f = SF_VERT_UNKNOWN; @@ -709,7 +709,7 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf) } /* new edge */ - ed3 = BLI_addfilledge(sf_ctx, v1, v3); + ed3 = BLI_scanfill_edge_add(sf_ctx, v1, v3); BLI_remlink(&sf_ctx->filledgebase, ed3); ed3->f = SF_EDGE_UNKNOWN; ed3->v1->h++; @@ -764,19 +764,19 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf) } -int BLI_begin_edgefill(ScanFillContext *sf_ctx) +int BLI_scanfill_begin(ScanFillContext *sf_ctx) { memset(sf_ctx, 0, sizeof(*sf_ctx)); return 1; } -int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup) +int BLI_scanfill_calc(ScanFillContext *sf_ctx, const short do_quad_tri_speedup) { - return BLI_edgefill_ex(sf_ctx, do_quad_tri_speedup, NULL); + return BLI_scanfill_calc_ex(sf_ctx, do_quad_tri_speedup, NULL); } -int BLI_edgefill_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, const float nor_proj[3]) +int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedup, const float nor_proj[3]) { /* * - fill works with its own lists, so create that first (no faces!) diff --git a/source/blender/blenlib/intern/uvproject.c b/source/blender/blenlib/intern/uvproject.c index 268b4cbe4a3..a630084e79d 100644 --- a/source/blender/blenlib/intern/uvproject.c +++ b/source/blender/blenlib/intern/uvproject.c @@ -32,7 +32,7 @@ #include "BLI_math.h" #include "BLI_uvproject.h" -typedef struct UvCameraInfo { +typedef struct ProjCameraInfo { float camangle; float camsize; float xasp, yasp; @@ -40,9 +40,9 @@ typedef struct UvCameraInfo { float rotmat[4][4]; float caminv[4][4]; short do_persp, do_pano, do_rotmat; -} UvCameraInfo; +} ProjCameraInfo; -void project_from_camera(float target[2], float source[3], UvCameraInfo *uci) +void BLI_uvproject_from_camera(float target[2], float source[3], ProjCameraInfo *uci) { float pv4[4]; @@ -93,7 +93,7 @@ void project_from_camera(float target[2], float source[3], UvCameraInfo *uci) } /* could rv3d->persmat */ -void project_from_view(float target[2], float source[3], float persmat[4][4], float rotmat[4][4], float winx, float winy) +void BLI_uvproject_from_view(float target[2], float source[3], float persmat[4][4], float rotmat[4][4], float winx, float winy) { float pv[3], pv4[4], x = 0.0, y = 0.0; @@ -133,9 +133,9 @@ void project_from_view(float target[2], float source[3], float persmat[4][4], fl /* 'rotmat' can be obedit->obmat when uv project is used. * 'winx' and 'winy' can be from scene->r.xsch/ysch */ -UvCameraInfo *project_camera_info(Object *ob, float(*rotmat)[4], float winx, float winy) +ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float(*rotmat)[4], float winx, float winy) { - UvCameraInfo uci; + ProjCameraInfo uci; Camera *camera = ob->data; uci.do_pano = (camera->type == CAM_PANO); @@ -149,7 +149,7 @@ UvCameraInfo *project_camera_info(Object *ob, float(*rotmat)[4], float winx, flo normalize_m4(uci.caminv); if (invert_m4(uci.caminv)) { - UvCameraInfo *uci_pt; + ProjCameraInfo *uci_pt; /* normal projection */ if (rotmat) { @@ -174,7 +174,7 @@ UvCameraInfo *project_camera_info(Object *ob, float(*rotmat)[4], float winx, flo uci.shiftx = 0.5f - (camera->shiftx * uci.xasp); uci.shifty = 0.5f - (camera->shifty * uci.yasp); - uci_pt = MEM_mallocN(sizeof(UvCameraInfo), "UvCameraInfo"); + uci_pt = MEM_mallocN(sizeof(ProjCameraInfo), "ProjCameraInfo"); *uci_pt = uci; return uci_pt; } @@ -182,7 +182,7 @@ UvCameraInfo *project_camera_info(Object *ob, float(*rotmat)[4], float winx, flo return NULL; } -void project_from_view_ortho(float target[2], float source[3], float rotmat[4][4]) +void BLI_uvproject_from_view_ortho(float target[2], float source[3], float rotmat[4][4]) { float pv[3]; @@ -193,7 +193,7 @@ void project_from_view_ortho(float target[2], float source[3], float rotmat[4][4 target[1] = pv[2]; } -void project_camera_info_scale(UvCameraInfo *uci, float scale_x, float scale_y) +void BLI_uvproject_camera_info_scale(ProjCameraInfo *uci, float scale_x, float scale_y) { uci->xasp *= scale_x; uci->yasp *= scale_y; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 34862c724e1..1fe42384eb6 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -37,15 +37,15 @@ BLI_INLINE float D(float *data, const int res[3], int x, int y, int z) { - CLAMP(x, 0, res[0]-1); - CLAMP(y, 0, res[1]-1); - CLAMP(z, 0, res[2]-1); - return data[ V_I(x, y, z, res) ]; + CLAMP(x, 0, res[0] - 1); + CLAMP(y, 0, res[1] - 1); + CLAMP(z, 0, res[2] - 1); + return data[ BLI_VEXEL_INDEX(x, y, z, res) ]; } /* *** nearest neighbor *** */ /* input coordinates must be in bounding box 0.0 - 1.0 */ -float voxel_sample_nearest(float *data, const int res[3], const float co[3]) +float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]) { int xi, yi, zi; @@ -70,7 +70,7 @@ BLI_INLINE int _clamp(int a, int b, int c) return (a < b) ? b : ((a > c) ? c : a); } -float voxel_sample_trilinear(float *data, const int res[3], const float co[3]) +float BLI_voxel_sample_trilinear(float *data, const int res[3], const float co[3]) { if (data) { @@ -102,7 +102,7 @@ float voxel_sample_trilinear(float *data, const int res[3], const float co[3]) } -float voxel_sample_triquadratic(float *data, const int res[3], const float co[3]) +float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float co[3]) { if (data) { @@ -132,7 +132,7 @@ float voxel_sample_triquadratic(float *data, const int res[3], const float co[3] return 0.f; } -float voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline) +float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline) { if (data) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 14c8d42654c..c741ebbc5bf 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2919,7 +2919,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL * we should not have any relative paths, but if there * is somehow, an invalid or empty G.main->name it will * print an error, don't try make the absolute in this case. */ - makeFilesAbsolute(mainvar, G.main->name, NULL); + BLI_bpath_absolute_convert(mainvar, G.main->name, NULL); } } } @@ -2928,7 +2928,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL write_user_block= (BLI_path_cmp(filepath, userfilename) == 0); if (write_flags & G_FILE_RELATIVE_REMAP) - makeFilesRelative(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */ + BLI_bpath_relative_convert(mainvar, filepath, NULL); /* note, making relative to something OTHER then G.main->name */ /* actual file writing */ err= write_file_handle(mainvar, file, NULL, NULL, write_user_block, write_flags, thumb); diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c index 755dceefdc5..afc60d844db 100644 --- a/source/blender/bmesh/operators/bmo_triangulate.c +++ b/source/blender/bmesh/operators/bmo_triangulate.c @@ -168,30 +168,30 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) BLI_smallhash_init(&hash); - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { BMO_elem_flag_enable(bm, e, EDGE_MARK); if (!BLI_smallhash_haskey(&hash, (uintptr_t)e->v1)) { - eve = BLI_addfillvert(&sf_ctx, e->v1->co); + eve = BLI_scanfill_vert_add(&sf_ctx, e->v1->co); eve->tmp.p = e->v1; BLI_smallhash_insert(&hash, (uintptr_t)e->v1, eve); } if (!BLI_smallhash_haskey(&hash, (uintptr_t)e->v2)) { - eve = BLI_addfillvert(&sf_ctx, e->v2->co); + eve = BLI_scanfill_vert_add(&sf_ctx, e->v2->co); eve->tmp.p = e->v2; BLI_smallhash_insert(&hash, (uintptr_t)e->v2, eve); } v1 = BLI_smallhash_lookup(&hash, (uintptr_t)e->v1); v2 = BLI_smallhash_lookup(&hash, (uintptr_t)e->v2); - /* eed = */ BLI_addfilledge(&sf_ctx, v1, v2); + /* eed = */ BLI_scanfill_edge_add(&sf_ctx, v1, v2); /* eed->tmp.p = e; */ /* UNUSED */ } - BLI_edgefill(&sf_ctx, FALSE); + BLI_scanfill_calc(&sf_ctx, FALSE); for (efa = sf_ctx.fillfacebase.first; efa; efa = efa->next) { BMFace *f = BM_face_create_quad_tri(bm, @@ -208,7 +208,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op) } } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); BLI_smallhash_release(&hash); /* clean up fill */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index b215f0ac345..57d7869d3db 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1877,11 +1877,11 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) if (face_nets[i].first) BMO_elem_flag_enable(bm, f, DEL); - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); for (entry = face_nets[i].first; entry; entry = entry->next) { if (!BLI_smallhash_haskey(hash, (intptr_t)entry->kfe->v1)) { - eve = BLI_addfillvert(&sf_ctx, entry->kfe->v1->v->co); + eve = BLI_scanfill_vert_add(&sf_ctx, entry->kfe->v1->v->co); eve->poly_nr = 0; rnd_offset_co(eve->co, rndscale); eve->tmp.p = entry->kfe->v1->v; @@ -1889,7 +1889,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) } if (!BLI_smallhash_haskey(hash, (intptr_t)entry->kfe->v2)) { - eve = BLI_addfillvert(&sf_ctx, entry->kfe->v2->v->co); + eve = BLI_scanfill_vert_add(&sf_ctx, entry->kfe->v2->v->co); eve->poly_nr = 0; rnd_offset_co(eve->co, rndscale); eve->tmp.p = entry->kfe->v2->v; @@ -1911,7 +1911,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) if (eve->poly_nr > 1 && lasteve->poly_nr > 1) { ScanFillEdge *eed; - eed = BLI_addfilledge(&sf_ctx, lasteve, eve); + eed = BLI_scanfill_edge_add(&sf_ctx, lasteve, eve); if (entry->kfe->oe) eed->f = SF_EDGE_BOUNDARY; /* mark as original boundary edge */ @@ -1926,7 +1926,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) } } - BLI_edgefill(&sf_ctx, FALSE); + BLI_scanfill_calc(&sf_ctx, FALSE); for (efa = sf_ctx.fillfacebase.first; efa; efa = efa->next) { BMVert *v1 = efa->v3->tmp.p, *v2 = efa->v2->tmp.p, *v3 = efa->v1->tmp.p; @@ -1959,7 +1959,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) } } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); BLI_smallhash_release(hash); } bm->elem_index_dirty |= BM_FACE; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index cfc7ba0537f..9f611b52669 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -192,7 +192,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) float *accum_tmp = MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum2"); int j; - BLI_initjit(jit_ofs[0], scene->r.osa); + BLI_jitter_init(jit_ofs[0], scene->r.osa); /* first sample buffer, also initializes 'rv3d->persmat' */ ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 4698c734f8e..080f12bf35b 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -200,7 +200,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - makeFilesRelative(bmain, bmain->name, op->reports); + BLI_bpath_relative_convert(bmain, bmain->name, op->reports); /* redraw everything so any changed paths register */ WM_main_add_notifier(NC_WINDOW, NULL); @@ -233,7 +233,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - makeFilesAbsolute(bmain, bmain->name, op->reports); + BLI_bpath_absolute_convert(bmain, bmain->name, op->reports); /* redraw everything so any changed paths register */ WM_main_add_notifier(NC_WINDOW, NULL); @@ -262,7 +262,7 @@ static int report_missing_files_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); /* run the missing file check */ - checkMissingFiles(bmain, op->reports); + BLI_bpath_missing_files_check(bmain, op->reports); return OPERATOR_FINISHED; } @@ -287,7 +287,7 @@ static int find_missing_files_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); const char *searchpath = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); - findMissingFiles(bmain, searchpath, op->reports); + BLI_bpath_missing_files_find(bmain, searchpath, op->reports); MEM_freeN((void *)searchpath); return OPERATOR_FINISHED; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 478643be947..2b93246e797 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -4356,7 +4356,7 @@ void param_smooth_area(ParamHandle *handle) void param_pack(ParamHandle *handle, float margin) { /* box packing variables */ - boxPack *boxarray, *box; + BoxPack *boxarray, *box; float tot_width, tot_height, scale; PChart *chart; @@ -4373,7 +4373,7 @@ void param_pack(ParamHandle *handle, float margin) param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy); /* we may not use all these boxes */ - boxarray = MEM_mallocN(phandle->ncharts * sizeof(boxPack), "boxPack box"); + boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box"); for (i = 0; i < phandle->ncharts; i++) { @@ -4424,7 +4424,7 @@ void param_pack(ParamHandle *handle, float margin) } } - boxPack2D(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height); + BLI_box_pack_2D(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height); if (tot_height > tot_width) scale = 1.0f / tot_height; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index b2c7dd59f1d..14c8420a8f5 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -262,13 +262,13 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, } else { /* ngon - scanfill time! */ - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); firstv = lastv = NULL; BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { int i; - v = BLI_addfillvert(&sf_ctx, l->v->co); + v = BLI_scanfill_vert_add(&sf_ctx, l->v->co); /* add small random offset */ for (i = 0; i < 3; i++) { @@ -278,7 +278,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, v->tmp.p = l; if (lastv) { - BLI_addfilledge(&sf_ctx, lastv, v); + BLI_scanfill_edge_add(&sf_ctx, lastv, v); } lastv = v; @@ -286,9 +286,9 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, firstv = v; } - BLI_addfilledge(&sf_ctx, firstv, v); + BLI_scanfill_edge_add(&sf_ctx, firstv, v); - BLI_edgefill_ex(&sf_ctx, TRUE, efa->no); + BLI_scanfill_calc_ex(&sf_ctx, TRUE, efa->no); for (sefa = sf_ctx.fillfacebase.first; sefa; sefa = sefa->next) { ls[0] = sefa->v1->tmp.p; ls[1] = sefa->v2->tmp.p; @@ -306,7 +306,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, param_face_add(handle, key, 3, vkeys, co, uv, pin, select); } - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); } } @@ -1265,12 +1265,12 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - project_from_view_ortho(luv->uv, l->v->co, rotmat); + BLI_uvproject_from_view_ortho(luv->uv, l->v->co, rotmat); } } } else if (camera) { - struct UvCameraInfo *uci = project_camera_info(v3d->camera, obedit->obmat, scene->r.xsch, scene->r.ysch); + struct ProjCameraInfo *uci = BLI_uvproject_camera_info(v3d->camera, obedit->obmat, scene->r.xsch, scene->r.ysch); if (uci) { BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { @@ -1279,7 +1279,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - project_from_camera(luv->uv, l->v->co, uci); + BLI_uvproject_from_camera(luv->uv, l->v->co, uci); } } @@ -1295,7 +1295,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - project_from_view(luv->uv, l->v->co, rv3d->persmat, rotmat, ar->winx, ar->winy); + BLI_uvproject_from_view(luv->uv, l->v->co, rv3d->persmat, rotmat, ar->winx, ar->winy); } } } diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index af98684c7e3..4f8fd83491f 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -194,8 +194,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, cam = (Camera *)projectors[i].ob->data; if (cam->type == CAM_PANO) { - projectors[i].uci= project_camera_info(projectors[i].ob, NULL, aspx, aspy); - project_camera_info_scale(projectors[i].uci, scax, scay); + projectors[i].uci= BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy); + BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay); free_uci= 1; } else { @@ -304,7 +304,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, do { unsigned int lidx= mp->loopstart + fidx; unsigned int vidx= mloop[lidx].v; - project_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci); + BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci); } while (fidx--); } else { @@ -347,7 +347,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, do { unsigned int lidx= mp->loopstart + fidx; unsigned int vidx= mloop[lidx].v; - project_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci); + BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci); } while (fidx--); } else { diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 834ca1227b5..4d5c02dad68 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -125,13 +125,13 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec return NULL; } - if (absolute) flag |= BPATH_TRAVERSE_ABS; - if (!packed) flag |= BPATH_TRAVERSE_SKIP_PACKED; - if (local) flag |= BPATH_TRAVERSE_SKIP_LIBRARY; + if (absolute) flag |= BLI_BPATH_TRAVERSE_ABS; + if (!packed) flag |= BLI_BPATH_TRAVERSE_SKIP_PACKED; + if (local) flag |= BLI_BPATH_TRAVERSE_SKIP_LIBRARY; list = PyList_New(0); - bpath_traverse_main(G.main, bpy_blend_paths_visit_cb, flag, (void *)list); + BLI_bpath_traverse_main(G.main, bpy_blend_paths_visit_cb, flag, (void *)list); return list; } diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 5128cf0b924..bab5a83a6ed 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -225,7 +225,7 @@ PyObject *BPY_app_handlers_struct(void) funcstore->func = bpy_app_generic_callback; funcstore->alloc = 0; funcstore->arg = SET_INT_IN_POINTER(pos); - BLI_add_cb(funcstore, pos); + BLI_callback_add(funcstore, pos); } } diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 203da5d1bd2..9e9b96a885b 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1150,11 +1150,11 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject } -static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) +static int boxPack_FromPyObject(PyObject *value, BoxPack **boxarray) { Py_ssize_t len, i; PyObject *list_item, *item_1, *item_2; - boxPack *box; + BoxPack *box; /* Error checking must already be done */ @@ -1166,7 +1166,7 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) len = PyList_GET_SIZE(value); - *boxarray = MEM_mallocN(len * sizeof(boxPack), "boxPack box"); + *boxarray = MEM_mallocN(len * sizeof(BoxPack), "BoxPack box"); for (i = 0; i < len; i++) { @@ -1201,11 +1201,11 @@ static int boxPack_FromPyObject(PyObject *value, boxPack **boxarray) return 0; } -static void boxPack_ToPyObject(PyObject *value, boxPack **boxarray) +static void boxPack_ToPyObject(PyObject *value, BoxPack **boxarray) { Py_ssize_t len, i; PyObject *list_item; - boxPack *box; + BoxPack *box; len = PyList_GET_SIZE(value); @@ -1243,13 +1243,13 @@ static PyObject *M_Geometry_box_pack_2d(PyObject *UNUSED(self), PyObject *boxlis len = PyList_GET_SIZE(boxlist); if (len) { - boxPack *boxarray = NULL; + BoxPack *boxarray = NULL; if (boxPack_FromPyObject(boxlist, &boxarray) == -1) { return NULL; /* exception set */ } /* Non Python function */ - boxPack2D(boxarray, len, &tot_width, &tot_height); + BLI_box_pack_2D(boxarray, len, &tot_width, &tot_height); boxPack_ToPyObject(boxlist, &boxarray); } diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 3e82bec7e52..56aadfd63d0 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -94,10 +94,10 @@ static void init_render_jit(Render *re) if (lastjit!=re->r.osa || last_mblur_jit != re->r.mblur_samples) { memset(jit, 0, sizeof(jit)); - BLI_initjit(jit[0], re->r.osa); + BLI_jitter_init(jit[0], re->r.osa); memset(mblur_jit, 0, sizeof(mblur_jit)); - BLI_initjit(mblur_jit[0], re->r.mblur_samples); + BLI_jitter_init(mblur_jit[0], re->r.mblur_samples); } lastjit= re->r.osa; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 57c39a03c06..9ca2337e27f 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -171,7 +171,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); } - BLI_exec_cb(G.main, NULL, BLI_CB_EVT_RENDER_STATS); + BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); fputc('\n', stdout); fflush(stdout); @@ -2021,7 +2021,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr if (render_initialize_from_main(re, bmain, scene, srl, camera_override, lay, 0, 0)) { MEM_reset_peak_memory(); - BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); + BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); do_render_all_options(re); @@ -2039,10 +2039,10 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr } } - BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ + BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ } - BLI_exec_cb(re->main, (ID *)scene, G.afbreek ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE); + BLI_callback_exec(re->main, (ID *)scene, G.afbreek ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE); /* UGLY WARNING */ G.rendering= 0; @@ -2120,7 +2120,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie BLI_timestr(re->i.lastframetime, name); printf(" Time: %s", name); - BLI_exec_cb(G.main, NULL, BLI_CB_EVT_RENDER_STATS); + BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); fputc('\n', stdout); fflush(stdout); /* needed for renderd !! (not anymore... (ton)) */ @@ -2155,7 +2155,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if (nf >= 0 && nf >= scene->r.sfra && nf <= scene->r.efra) { scene->r.cfra = re->r.cfra = nf; - BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); + BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); do_render_all_options(re); totrendered++; @@ -2166,7 +2166,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri } if (G.afbreek == 0) { - BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ + BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ } } else { @@ -2220,7 +2220,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri re->r.cfra= scene->r.cfra; /* weak.... */ /* run callbacs before rendering, before the scene is updated */ - BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); + BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); do_render_all_options(re); @@ -2246,7 +2246,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri } if (G.afbreek==0) { - BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ + BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ } } } @@ -2262,7 +2262,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri re->flag &= ~R_ANIMATION; - BLI_exec_cb(re->main, (ID *)scene, G.afbreek ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE); + BLI_callback_exec(re->main, (ID *)scene, G.afbreek ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE); /* UGLY WARNING */ G.rendering= 0; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 1c572524a70..b3167e15df5 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -139,7 +139,7 @@ static float *give_jitter_tab(int samp) if (ctab[samp]==0) { ctab[samp]= 1; - BLI_initjit(jit[offset], samp*samp); + BLI_jitter_init(jit[offset], samp*samp); } return jit[offset]; diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index 69aa6082950..e7c97574629 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -177,7 +177,7 @@ static float get_avg_surrounds(float *cache, int *res, int xx, int yy, int zz) for (x=-1; x <= 1; x++) { x_ = xx+x; if (x_ >= 0 && x_ <= res[0]-1) { - const int i= V_I(x_, y_, z_, res); + const int i= BLI_VEXEL_INDEX(x_, y_, z_, res); if (cache[i] > 0.0f) { tot += cache[i]; @@ -208,7 +208,7 @@ static void lightcache_filter(VolumePrecache *vp) for (y=0; y < vp->res[1]; y++) { for (x=0; x < vp->res[0]; x++) { /* trigger for outside mesh */ - const int i= V_I(x, y, z, vp->res); + const int i= BLI_VEXEL_INDEX(x, y, z, vp->res); if (vp->data_r[i] < -0.f) vp->data_r[i] = get_avg_surrounds(vp->data_r, vp->res, x, y, z); @@ -240,7 +240,7 @@ static void lightcache_filter2(VolumePrecache *vp) for (y=0; y < vp->res[1]; y++) { for (x=0; x < vp->res[0]; x++) { /* trigger for outside mesh */ - const int i= V_I(x, y, z, vp->res); + const int i= BLI_VEXEL_INDEX(x, y, z, vp->res); if (vp->data_r[i] < -0.f) new_r[i] = get_avg_surrounds(vp->data_r, vp->res, x, y, z); if (vp->data_g[i] < -0.f) @@ -291,7 +291,7 @@ static float total_ss_energy(Render *re, int do_test_break, VolumePrecache *vp) for (z=0; z < res[2]; z++) { for (y=0; y < res[1]; y++) { for (x=0; x < res[0]; x++) { - const int i=V_I(x, y, z, res); + const int i=BLI_VEXEL_INDEX(x, y, z, res); if (vp->data_r[i] > 0.f) energy += vp->data_r[i]; if (vp->data_g[i] > 0.f) energy += vp->data_g[i]; @@ -527,7 +527,7 @@ static void *vol_precache_part(void *data) /* convert from world->camera space for shading */ mul_v3_m4v3(cco, pa->viewmat, co); - i= V_I(x, y, z, res); + i= BLI_VEXEL_INDEX(x, y, z, res); // don't bother if the point is not inside the volume mesh if (!point_inside_obi(tree, obi, cco)) { diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index c51cb2af842..b599da48803 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -234,9 +234,9 @@ static void vol_get_precached_scattering(Render *re, ShadeInput *shi, float scat sample_co[1] = (world_co[1] - bbmin[1]) / dim[1]; sample_co[2] = (world_co[2] - bbmin[2]) / dim[2]; - scatter_col[0] = voxel_sample_triquadratic(vp->data_r, vp->res, sample_co); - scatter_col[1] = voxel_sample_triquadratic(vp->data_g, vp->res, sample_co); - scatter_col[2] = voxel_sample_triquadratic(vp->data_b, vp->res, sample_co); + scatter_col[0] = BLI_voxel_sample_triquadratic(vp->data_r, vp->res, sample_co); + scatter_col[1] = BLI_voxel_sample_triquadratic(vp->data_g, vp->res, sample_co); + scatter_col[2] = BLI_voxel_sample_triquadratic(vp->data_b, vp->res, sample_co); } /* Meta object density, brute force for now diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 940f718d4ad..5135061bc5c 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -184,7 +184,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) for (y=0; y < ibuf->y; y++) { for (x=0; x < ibuf->x; x++) { /* currently averaged to monchrome */ - vd->dataset[ V_I(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2])*0.333f; + vd->dataset[ BLI_VEXEL_INDEX(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2]) * 0.333f; rf +=4; } } @@ -423,17 +423,17 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre switch (vd->interp_type) { case TEX_VD_NEARESTNEIGHBOR: - texres->tin = voxel_sample_nearest(vd->dataset, vd->resol, co); + texres->tin = BLI_voxel_sample_nearest(vd->dataset, vd->resol, co); break; case TEX_VD_LINEAR: - texres->tin = voxel_sample_trilinear(vd->dataset, vd->resol, co); + texres->tin = BLI_voxel_sample_trilinear(vd->dataset, vd->resol, co); break; case TEX_VD_QUADRATIC: - texres->tin = voxel_sample_triquadratic(vd->dataset, vd->resol, co); + texres->tin = BLI_voxel_sample_triquadratic(vd->dataset, vd->resol, co); break; case TEX_VD_TRICUBIC_CATROM: case TEX_VD_TRICUBIC_BSPLINE: - texres->tin = voxel_sample_tricubic(vd->dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE)); + texres->tin = BLI_voxel_sample_tricubic(vd->dataset, vd->resol, co, (vd->interp_type == TEX_VD_TRICUBIC_BSPLINE)); break; } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index b9e69743995..4c3c9889d53 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3047,7 +3047,7 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* has to become static, the init-jit calls a random-seed, screwing up texture noise node */ if (firsttime) { firsttime= 0; - BLI_initjit(jit[0], 256); + BLI_jitter_init(jit[0], 256); } memset(newrect, 0, sizeof(float)*xsize*ysize*4); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e50fbaa624e..a366810e647 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -361,7 +361,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) WM_cursor_wait(1); - BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); + BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); /* first try to append data from exotic file formats... */ /* it throws error box when file doesn't exist and returns -1 */ @@ -421,7 +421,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) #endif /* important to do before NULL'ing the context */ - BLI_exec_cb(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); + BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); if (!G.background) { /* in background mode this makes it hard to load @@ -791,7 +791,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re ibuf_thumb = blend_file_thumb(CTX_data_scene(C), CTX_wm_screen(C), &thumb); } - BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_PRE); + BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_PRE); /* operator now handles overwrite checks */ @@ -826,7 +826,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re write_history(); } - BLI_exec_cb(G.main, NULL, BLI_CB_EVT_SAVE_POST); + BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_POST); /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index bfa3645bf57..7f40d2980a6 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -236,7 +236,7 @@ static void draw_filled_lasso(wmGesture *gt) short *lasso = (short *)gt->customdata; int i; - BLI_begin_edgefill(&sf_ctx); + BLI_scanfill_begin(&sf_ctx); for (i = 0; i < gt->points; i++, lasso += 2) { float co[3]; @@ -244,9 +244,9 @@ static void draw_filled_lasso(wmGesture *gt) co[1] = (float)lasso[1]; co[2] = 0.0f; - v = BLI_addfillvert(&sf_ctx, co); + v = BLI_scanfill_vert_add(&sf_ctx, co); if (lastv) - /* e = */ /* UNUSED */ BLI_addfilledge(&sf_ctx, lastv, v); + /* e = */ /* UNUSED */ BLI_scanfill_edge_add(&sf_ctx, lastv, v); lastv = v; if (firstv == NULL) firstv = v; } @@ -254,8 +254,8 @@ static void draw_filled_lasso(wmGesture *gt) /* highly unlikely this will fail, but could crash if (gt->points == 0) */ if (firstv) { float zvec[3] = {0.0f, 0.0f, 1.0f}; - BLI_addfilledge(&sf_ctx, firstv, v); - BLI_edgefill_ex(&sf_ctx, FALSE, zvec); + BLI_scanfill_edge_add(&sf_ctx, firstv, v); + BLI_scanfill_calc_ex(&sf_ctx, FALSE, zvec); glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 0.05); @@ -268,7 +268,7 @@ static void draw_filled_lasso(wmGesture *gt) glEnd(); glDisable(GL_BLEND); - BLI_end_edgefill(&sf_ctx); + BLI_scanfill_end(&sf_ctx); } } diff --git a/source/creator/creator.c b/source/creator/creator.c index 8024356c181..4847df1168d 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1248,7 +1248,7 @@ int main(int argc, const char **argv) IMB_init(); - BLI_cb_init(); + BLI_callback_global_init(); #ifdef WITH_GAMEENGINE syshandle = SYS_GetSystem(); From 084fedd03a006982b386873a70f649627bf200aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 00:58:22 +0000 Subject: [PATCH 70/88] code cleanup: brush/camera naming --- source/blender/blenkernel/BKE_brush.h | 70 +++---- source/blender/blenkernel/BKE_camera.h | 32 +-- source/blender/blenkernel/intern/brush.c | 192 +++++++++--------- source/blender/blenkernel/intern/camera.c | 58 +++--- source/blender/blenkernel/intern/constraint.c | 4 +- source/blender/blenkernel/intern/library.c | 12 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/paint.c | 2 +- source/blender/blenlib/BLI_voxel.h | 2 +- source/blender/blenlib/intern/voxel.c | 2 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/collada/DocumentImporter.cpp | 4 +- source/blender/editors/object/object_add.c | 2 +- .../blender/editors/object/object_relations.c | 2 +- .../blender/editors/physics/particle_edit.c | 4 +- .../editors/sculpt_paint/paint_cursor.c | 38 ++-- .../editors/sculpt_paint/paint_image.c | 64 +++--- .../blender/editors/sculpt_paint/paint_ops.c | 14 +- .../editors/sculpt_paint/paint_stroke.c | 8 +- .../editors/sculpt_paint/paint_utils.c | 2 +- .../editors/sculpt_paint/paint_vertex.c | 20 +- source/blender/editors/sculpt_paint/sculpt.c | 32 +-- .../blender/editors/sculpt_paint/sculpt_uv.c | 16 +- .../blender/editors/space_image/image_draw.c | 2 +- .../blender/editors/space_view3d/drawobject.c | 4 +- .../editors/space_view3d/view3d_draw.c | 30 +-- .../editors/space_view3d/view3d_edit.c | 4 +- .../editors/space_view3d/view3d_view.c | 12 +- source/blender/makesrna/intern/rna_brush.c | 4 +- source/blender/makesrna/intern/rna_camera.c | 4 +- .../blender/makesrna/intern/rna_camera_api.c | 2 +- source/blender/makesrna/intern/rna_main_api.c | 4 +- source/blender/makesrna/intern/rna_scene.c | 4 +- .../blender/modifiers/intern/MOD_uvproject.c | 4 +- .../composite/nodes/node_composite_defocus.c | 2 +- .../blender/render/intern/source/initrender.c | 18 +- .../blender/render/intern/source/pipeline.c | 2 +- .../render/intern/source/volume_precache.c | 10 +- .../blender/render/intern/source/voxeldata.c | 2 +- .../windowmanager/intern/wm_operators.c | 2 +- 40 files changed, 347 insertions(+), 347 deletions(-) diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h index 52666ca1538..b5edc8f3e50 100644 --- a/source/blender/blenkernel/BKE_brush.h +++ b/source/blender/blenkernel/BKE_brush.h @@ -41,34 +41,34 @@ struct wmOperator; // enum CurveMappingPreset; /* datablock functions */ -struct Brush *add_brush(const char *name); -struct Brush *copy_brush(struct Brush *brush); -void make_local_brush(struct Brush *brush); -void free_brush(struct Brush *brush); +struct Brush *BKE_brush_add(const char *name); +struct Brush *BKE_brush_copy(struct Brush *brush); +void BKE_brush_make_local(struct Brush *brush); +void BKE_brush_free(struct Brush *brush); -void brush_reset_sculpt(struct Brush *brush); +void BKE_brush_sculpt_reset(struct Brush *brush); /* image icon function */ struct ImBuf *get_brush_icon(struct Brush *brush); /* brush library operations used by different paint panels */ -int brush_texture_set_nr(struct Brush *brush, int nr); -int brush_texture_delete(struct Brush *brush); -int brush_clone_image_set_nr(struct Brush *brush, int nr); -int brush_clone_image_delete(struct Brush *brush); +int BKE_brush_texture_set_nr(struct Brush *brush, int nr); +int BKE_brush_texture_delete(struct Brush *brush); +int BKE_brush_clone_image_set_nr(struct Brush *brush, int nr); +int BKE_brush_clone_image_delete(struct Brush *brush); /* jitter */ -void brush_jitter_pos(const struct Scene *scene, struct Brush *brush, +void BKE_brush_jitter_pos(const struct Scene *scene, struct Brush *brush, const float pos[2], float jitterpos[2]); /* brush curve */ -void brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset); -float brush_curve_strength_clamp(struct Brush *br, float p, const float len); -float brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */ +void BKE_brush_curve_preset(struct Brush *b, /*enum CurveMappingPreset*/int preset); +float BKE_brush_curve_strength_clamp(struct Brush *br, float p, const float len); +float BKE_brush_curve_strength(struct Brush *br, float p, const float len); /* used for sculpt */ /* sampling */ -void brush_sample_tex(const struct Scene *scene, struct Brush *brush, const float xy[2], float rgba[4], const int thread); -void brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size, +void BKE_brush_sample_tex(const struct Scene *scene, struct Brush *brush, const float xy[2], float rgba[4], const int thread); +void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt, short texfalloff, int size, struct ImBuf **imbuf, int use_color_correction); /* painting */ @@ -76,48 +76,48 @@ struct BrushPainter; typedef struct BrushPainter BrushPainter; typedef int (*BrushFunc)(void *user, struct ImBuf *ibuf, const float lastpos[2], const float pos[2]); -BrushPainter *brush_painter_new(struct Scene *scene, struct Brush *brush); -void brush_painter_require_imbuf(BrushPainter *painter, short flt, +BrushPainter *BKE_brush_painter_new(struct Scene *scene, struct Brush *brush); +void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size); -int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], +int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, void *user, int use_color_correction); -void brush_painter_break_stroke(BrushPainter *painter); -void brush_painter_free(BrushPainter *painter); +void BKE_brush_painter_break_stroke(BrushPainter *painter); +void BKE_brush_painter_free(BrushPainter *painter); /* texture */ -unsigned int *brush_gen_texture_cache(struct Brush *br, int half_side); +unsigned int *BKE_brush_gen_texture_cache(struct Brush *br, int half_side); /* radial control */ -struct ImBuf *brush_gen_radial_control_imbuf(struct Brush *br); +struct ImBuf *BKE_brush_gen_radial_control_imbuf(struct Brush *br); /* unified strength and size */ -int brush_size(const struct Scene *scene, struct Brush *brush); -void brush_set_size(struct Scene *scene, struct Brush *brush, int value); +int BKE_brush_size_get(const struct Scene *scene, struct Brush *brush); +void BKE_brush_size_set(struct Scene *scene, struct Brush *brush, int value); -float brush_unprojected_radius(const struct Scene *scene, struct Brush *brush); -void brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, float value); +float BKE_brush_unprojected_radius_get(const struct Scene *scene, struct Brush *brush); +void BKE_brush_unprojected_radius_set(struct Scene *scene, struct Brush *brush, float value); -float brush_alpha(const struct Scene *scene, struct Brush *brush); -float brush_weight(const Scene *scene, struct Brush *brush); -void brush_set_weight(const Scene *scene, struct Brush *brush, float value); +float BKE_brush_alpha_get(const struct Scene *scene, struct Brush *brush); +float BKE_brush_weight_get(const Scene *scene, struct Brush *brush); +void BKE_brush_weight_set(const Scene *scene, struct Brush *brush, float value); -int brush_use_locked_size(const struct Scene *scene, struct Brush *brush); -int brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush); -int brush_use_size_pressure(const struct Scene *scene, struct Brush *brush); +int BKE_brush_use_locked_size(const struct Scene *scene, struct Brush *brush); +int BKE_brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush); +int BKE_brush_use_size_pressure(const struct Scene *scene, struct Brush *brush); /* scale unprojected radius to reflect a change in the brush's 2D size */ -void brush_scale_unprojected_radius(float *unprojected_radius, +void BKE_brush_scale_unprojected_radius(float *unprojected_radius, int new_brush_size, int old_brush_size); /* scale brush size to reflect a change in the brush's unprojected radius */ -void brush_scale_size(int *brush_size, +void BKE_brush_scale_size(int *BKE_brush_size_get, float new_unprojected_radius, float old_unprojected_radius); /* debugging only */ -void brush_debug_print_state(struct Brush *br); +void BKE_brush_debug_print_state(struct Brush *br); #endif diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 6d10219e74c..8f68d7abcac 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -48,18 +48,18 @@ struct View3D; /* Camera Datablock */ -void *add_camera(const char *name); -struct Camera *copy_camera(struct Camera *cam); -void make_local_camera(struct Camera *cam); -void free_camera(struct Camera *ca); +void *BKE_camera_add(const char *name); +struct Camera *BKE_camera_copy(struct Camera *cam); +void BKE_camera_make_local(struct Camera *cam); +void BKE_camera_free(struct Camera *ca); /* Camera Usage */ -float object_camera_dof_distance(struct Object *ob); -void object_camera_mode(struct RenderData *rd, struct Object *ob); +float BKE_camera_object_dof_distance(struct Object *ob); +void BKE_camera_object_mode(struct RenderData *rd, struct Object *ob); -int camera_sensor_fit(int sensor_fit, float sizex, float sizey); -float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y); +int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey); +float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y); /* Camera Parameters: * @@ -102,21 +102,21 @@ typedef struct CameraParams { float winmat[4][4]; } CameraParams; -void camera_params_init(CameraParams *params); -void camera_params_from_object(CameraParams *params, struct Object *camera); -void camera_params_from_view3d(CameraParams *params, struct View3D *v3d, struct RegionView3D *rv3d); +void BKE_camera_params_init(CameraParams *params); +void BKE_camera_params_from_object(CameraParams *params, struct Object *camera); +void BKE_camera_params_from_view3d(CameraParams *params, struct View3D *v3d, struct RegionView3D *rv3d); -void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy); -void camera_params_compute_matrix(CameraParams *params); +void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy); +void BKE_camera_params_compute_matrix(CameraParams *params); /* Camera View Frame */ -void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3], +void BKE_camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]); -void camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); +void BKE_camera_view_frame(struct Scene *scene, struct Camera *camera, float r_vec[4][3]); -int camera_view_frame_fit_to_scene( +int BKE_camera_view_frame_fit_to_scene( struct Scene *scene, struct View3D *v3d, struct Object *camera_ob, float r_co[3]); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index b3d128bf2b4..51258b13f68 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -67,7 +67,7 @@ #include "RE_render_ext.h" /* externtex */ #include "RE_shader_ext.h" -static void brush_set_defaults(Brush *brush) +static void brush_defaults(Brush *brush) { brush->blend = 0; brush->flag = 0; @@ -122,7 +122,7 @@ static void brush_set_defaults(Brush *brush) /* Datablock add/copy/free/make_local */ -Brush *add_brush(const char *name) +Brush *BKE_brush_add(const char *name) { Brush *brush; @@ -131,17 +131,17 @@ Brush *add_brush(const char *name) /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; - brush_set_defaults(brush); + brush_defaults(brush); brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ /* the default alpha falloff curve */ - brush_curve_preset(brush, CURVE_PRESET_SMOOTH); + BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH); return brush; } -Brush *copy_brush(Brush *brush) +Brush *BKE_brush_copy(Brush *brush) { Brush *brushn; @@ -167,7 +167,7 @@ Brush *copy_brush(Brush *brush) } /* not brush itself */ -void free_brush(Brush *brush) +void BKE_brush_free(Brush *brush) { if (brush->mtex.tex) brush->mtex.tex->id.us--; @@ -186,7 +186,7 @@ static void extern_local_brush(Brush *brush) id_lib_extern((ID *)brush->clone.image); } -void make_local_brush(Brush *brush) +void BKE_brush_make_local(Brush *brush) { /* - only lib users: do nothing @@ -225,7 +225,7 @@ void make_local_brush(Brush *brush) } } else if (is_local && is_lib) { - Brush *brush_new= copy_brush(brush); + Brush *brush_new= BKE_brush_copy(brush); brush_new->id.us= 1; /* only keep fake user */ brush_new->id.flag |= LIB_FAKEUSER; @@ -242,11 +242,11 @@ void make_local_brush(Brush *brush) } } -void brush_debug_print_state(Brush *br) +void BKE_brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ Brush def= {{NULL}}; - brush_set_defaults(&def); + brush_defaults(&def); #define BR_TEST(field, t) \ if (br->field != def.field) \ @@ -329,14 +329,14 @@ void brush_debug_print_state(Brush *br) #undef BR_TEST_FLAG } -void brush_reset_sculpt(Brush *br) +void BKE_brush_sculpt_reset(Brush *br) { /* enable this to see any non-default * settings used by a brush: */ - // brush_debug_print_state(br); + // BKE_brush_debug_print_state(br); - brush_set_defaults(br); - brush_curve_preset(br, CURVE_PRESET_SMOOTH); + brush_defaults(br); + BKE_brush_curve_preset(br, CURVE_PRESET_SMOOTH); switch (br->sculpt_tool) { case SCULPT_TOOL_CLAY: @@ -409,7 +409,7 @@ void brush_reset_sculpt(Brush *br) } /* Library Operations */ -void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) +void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) { CurveMap *cm = NULL; @@ -424,7 +424,7 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) curvemapping_changed(b->curve, 0); } -int brush_texture_set_nr(Brush *brush, int nr) +int BKE_brush_texture_set_nr(Brush *brush, int nr) { ID *idtest, *id=NULL; @@ -437,7 +437,7 @@ int brush_texture_set_nr(Brush *brush, int nr) idtest->us--; } if (idtest!=id) { - brush_texture_delete(brush); + BKE_brush_texture_delete(brush); brush->mtex.tex= (Tex*)idtest; id_us_plus(idtest); @@ -448,7 +448,7 @@ int brush_texture_set_nr(Brush *brush, int nr) return 0; } -int brush_texture_delete(Brush *brush) +int BKE_brush_texture_delete(Brush *brush) { if (brush->mtex.tex) brush->mtex.tex->id.us--; @@ -456,13 +456,13 @@ int brush_texture_delete(Brush *brush) return 1; } -int brush_clone_image_set_nr(Brush *brush, int nr) +int BKE_brush_clone_image_set_nr(Brush *brush, int nr) { if (brush && nr > 0) { Image *ima= (Image*)BLI_findlink(&G.main->image, nr-1); if (ima) { - brush_clone_image_delete(brush); + BKE_brush_clone_image_delete(brush); brush->clone.image= ima; id_us_plus(&ima->id); brush->clone.offset[0]= brush->clone.offset[1]= 0.0f; @@ -474,7 +474,7 @@ int brush_clone_image_set_nr(Brush *brush, int nr) return 0; } -int brush_clone_image_delete(Brush *brush) +int BKE_brush_clone_image_delete(Brush *brush) { if (brush && brush->clone.image) { brush->clone.image->id.us--; @@ -486,14 +486,14 @@ int brush_clone_image_delete(Brush *brush) } /* Brush Sampling */ -void brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) +void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) { MTex *mtex= &brush->mtex; if (mtex && mtex->tex) { float co[3], tin, tr, tg, tb, ta; int hasrgb; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); co[0]= xy[0]/radius; co[1]= xy[1]/radius; @@ -520,14 +520,14 @@ void brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float } /* TODO, use define for 'texfall' arg */ -void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction) +void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction) { ImBuf *ibuf; float xy[2], rgba[4], *dstf; int x, y, rowbytes, xoff, yoff, imbflag; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); unsigned char *dst, crgb[3]; - const float alpha= brush_alpha(scene, brush); + const float alpha= BKE_brush_alpha_get(scene, brush); float brush_rgb[3]; imbflag= (flt)? IB_rectfloat: IB_rect; @@ -555,15 +555,15 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, if (texfall == 0) { copy_v3_v3(dstf, brush_rgb); - dstf[3]= alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3]= alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } else if (texfall == 1) { - brush_sample_tex(scene, brush, xy, dstf, 0); + BKE_brush_sample_tex(scene, brush, xy, dstf, 0); } else { - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3v3(dstf, rgba, brush_rgb); - dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3] = rgba[3]*alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } } } @@ -580,7 +580,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, xy[1] = y + yoff; if (texfall == 0) { - alpha_f = alpha * brush_curve_strength(brush, len_v2(xy), radius); + alpha_f = alpha * BKE_brush_curve_strength(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -588,21 +588,21 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, dst[3] = FTOCHAR(alpha_f); } else if (texfall == 1) { - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); rgba_float_to_uchar(dst, rgba); } else if (texfall == 2) { - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3(rgba, brush->rgb); - alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius); + alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); rgb_float_to_uchar(dst, rgba); dst[3] = FTOCHAR(alpha_f); } else { - brush_sample_tex(scene, brush, xy, rgba, 0); - alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); + alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -631,7 +631,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, // In anycase, a better solution is needed to prevent // inconsistency. -void brush_set_size(Scene *scene, Brush *brush, int size) +void BKE_brush_size_set(Scene *scene, Brush *brush, int size) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -641,14 +641,14 @@ void brush_set_size(Scene *scene, Brush *brush, int size) brush->size= size; } -int brush_size(const Scene *scene, Brush *brush) +int BKE_brush_size_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size; } -int brush_use_locked_size(const Scene *scene, Brush *brush) +int BKE_brush_use_locked_size(const Scene *scene, Brush *brush) { const short us_flag = scene->toolsettings->unified_paint_settings.flag; @@ -657,7 +657,7 @@ int brush_use_locked_size(const Scene *scene, Brush *brush) (brush->flag & BRUSH_LOCK_SIZE); } -int brush_use_size_pressure(const Scene *scene, Brush *brush) +int BKE_brush_use_size_pressure(const Scene *scene, Brush *brush) { const short us_flag = scene->toolsettings->unified_paint_settings.flag; @@ -666,7 +666,7 @@ int brush_use_size_pressure(const Scene *scene, Brush *brush) (brush->flag & BRUSH_SIZE_PRESSURE); } -int brush_use_alpha_pressure(const Scene *scene, Brush *brush) +int BKE_brush_use_alpha_pressure(const Scene *scene, Brush *brush) { const short us_flag = scene->toolsettings->unified_paint_settings.flag; @@ -675,7 +675,7 @@ int brush_use_alpha_pressure(const Scene *scene, Brush *brush) (brush->flag & BRUSH_ALPHA_PRESSURE); } -void brush_set_unprojected_radius(Scene *scene, Brush *brush, float unprojected_radius) +void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -685,7 +685,7 @@ void brush_set_unprojected_radius(Scene *scene, Brush *brush, float unprojected_ brush->unprojected_radius= unprojected_radius; } -float brush_unprojected_radius(const Scene *scene, Brush *brush) +float BKE_brush_unprojected_radius_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -694,7 +694,7 @@ float brush_unprojected_radius(const Scene *scene, Brush *brush) brush->unprojected_radius; } -static void brush_set_alpha(Scene *scene, Brush *brush, float alpha) +static void brush_alpha_set(Scene *scene, Brush *brush, float alpha) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -704,21 +704,21 @@ static void brush_set_alpha(Scene *scene, Brush *brush, float alpha) brush->alpha= alpha; } -float brush_alpha(const Scene *scene, Brush *brush) +float BKE_brush_alpha_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_ALPHA) ? ups->alpha : brush->alpha; } -float brush_weight(const Scene *scene, Brush *brush) +float BKE_brush_weight_get(const Scene *scene, Brush *brush) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_WEIGHT) ? ups->weight : brush->weight; } -void brush_set_weight(const Scene *scene, Brush *brush, float value) +void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -729,9 +729,9 @@ void brush_set_weight(const Scene *scene, Brush *brush, float value) } /* scale unprojected radius to reflect a change in the brush's 2D size */ -void brush_scale_unprojected_radius(float *unprojected_radius, - int new_brush_size, - int old_brush_size) +void BKE_brush_scale_unprojected_radius(float *unprojected_radius, + int new_brush_size, + int old_brush_size) { float scale = new_brush_size; /* avoid division by zero */ @@ -741,15 +741,15 @@ void brush_scale_unprojected_radius(float *unprojected_radius, } /* scale brush size to reflect a change in the brush's unprojected radius */ -void brush_scale_size(int *brush_size, - float new_unprojected_radius, - float old_unprojected_radius) +void BKE_brush_scale_size(int *BKE_brush_size_get, + float new_unprojected_radius, + float old_unprojected_radius) { float scale = new_unprojected_radius; /* avoid division by zero */ if (old_unprojected_radius != 0) scale /= new_unprojected_radius; - (*brush_size)= (int)((float)(*brush_size) * scale); + (*BKE_brush_size_get)= (int)((float)(*BKE_brush_size_get) * scale); } /* Brush Painting */ @@ -757,7 +757,7 @@ void brush_scale_size(int *brush_size, typedef struct BrushPainterCache { short enabled; - int size; /* size override, if 0 uses 2*brush_size(brush) */ + int size; /* size override, if 0 uses 2*BKE_brush_size_get(brush) */ short flt; /* need float imbuf? */ short texonly; /* no alpha, color or fallof, only texture in imbuf */ @@ -795,7 +795,7 @@ struct BrushPainter { BrushPainterCache cache; }; -BrushPainter *brush_painter_new(Scene *scene, Brush *brush) +BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush) { BrushPainter *painter= MEM_callocN(sizeof(BrushPainter), "BrushPainter"); @@ -804,15 +804,15 @@ BrushPainter *brush_painter_new(Scene *scene, Brush *brush) painter->firsttouch= 1; painter->cache.lastsize= -1; /* force ibuf create in refresh */ - painter->startsize = brush_size(scene, brush); - painter->startalpha = brush_alpha(scene, brush); + painter->startsize = BKE_brush_size_get(scene, brush); + painter->startalpha = BKE_brush_alpha_get(scene, brush); painter->startjitter = brush->jitter; painter->startspacing = brush->spacing; return painter; } -void brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size) +void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size) { if ((painter->cache.flt != flt) || (painter->cache.size != size) || ((painter->cache.texonly != texonly) && texonly)) { @@ -834,12 +834,12 @@ void brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly painter->cache.enabled= 1; } -void brush_painter_free(BrushPainter *painter) +void BKE_brush_painter_free(BrushPainter *painter) { Brush *brush = painter->brush; - brush_set_size(painter->scene, brush, painter->startsize); - brush_set_alpha(painter->scene, brush, painter->startalpha); + BKE_brush_size_set(painter->scene, brush, painter->startsize); + brush_alpha_set(painter->scene, brush, painter->startalpha); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -859,7 +859,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4]; unsigned char *b, *m, *t, *ot= NULL; int dotexold, origx= x, origy= y; - const int radius= brush_size(painter->scene, brush); + const int radius= BKE_brush_size_get(painter->scene, brush); xoff = -radius + 0.5f; yoff = -radius + 0.5f; @@ -897,7 +897,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(scene, brush, xy, tf, 0); + BKE_brush_sample_tex(scene, brush, xy, tf, 0); } bf[0] = tf[0]*mf[0]; @@ -928,7 +928,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(scene, brush, xy, rgba, 0); + BKE_brush_sample_tex(scene, brush, xy, rgba, 0); rgba_float_to_uchar(t, rgba); } @@ -948,7 +948,7 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const BrushPainterCache *cache= &painter->cache; ImBuf *oldtexibuf, *ibuf; int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2; - const int diameter= 2*brush_size(scene, brush); + const int diameter= 2*BKE_brush_size_get(scene, brush); imbflag= (cache->flt)? IB_rectfloat: IB_rect; if (!cache->ibuf) @@ -1004,8 +1004,8 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 MTex *mtex= &brush->mtex; int size; short flt; - const int diameter= 2*brush_size(scene, brush); - const float alpha= brush_alpha(scene, brush); + const int diameter= 2*BKE_brush_size_get(scene, brush); + const float alpha= BKE_brush_alpha_get(scene, brush); if (diameter != cache->lastsize || alpha != cache->lastalpha || @@ -1024,11 +1024,11 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 size= (cache->size)? cache->size: diameter; if (brush->flag & BRUSH_FIXED_TEX) { - brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); + BKE_brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); brush_painter_fixed_tex_partial_update(painter, pos); } else - brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); + BKE_brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); cache->lastsize= diameter; cache->lastalpha= alpha; @@ -1043,24 +1043,24 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 } } -void brush_painter_break_stroke(BrushPainter *painter) +void BKE_brush_painter_break_stroke(BrushPainter *painter) { painter->firsttouch= 1; } -static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure) +static void brush_pressure_apply(BrushPainter *painter, Brush *brush, float pressure) { - if (brush_use_alpha_pressure(painter->scene, brush)) - brush_set_alpha(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure)); - if (brush_use_size_pressure(painter->scene, brush)) - brush_set_size(painter->scene, brush, MAX2(1.0f, painter->startsize*pressure)); + if (BKE_brush_use_alpha_pressure(painter->scene, brush)) + brush_alpha_set(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure)); + if (BKE_brush_use_size_pressure(painter->scene, brush)) + BKE_brush_size_set(painter->scene, brush, MAX2(1.0f, painter->startsize*pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) brush->jitter = MAX2(0.0f, painter->startjitter*pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure)); } -void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) +void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) { int use_jitter= brush->jitter != 0; @@ -1070,7 +1070,7 @@ void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], floa if (use_jitter) { float rand_pos[2]; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); const int diameter= 2*radius; // find random position within a circle of diameter 1 @@ -1087,8 +1087,8 @@ void brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], floa } } -int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, - void *user, int use_color_correction) +int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, + void *user, int use_color_correction) { Scene *scene= painter->scene; Brush *brush= painter->brush; @@ -1105,7 +1105,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 painter->startpaintpos[0]= pos[0]; painter->startpaintpos[1]= pos[1]; - brush_apply_pressure(painter, brush, pressure); + brush_pressure_apply(painter, brush, pressure); if (painter->cache.enabled) brush_painter_refresh_cache(painter, pos, use_color_correction); totpaintops += func(user, painter->cache.ibuf, pos, pos); @@ -1152,11 +1152,11 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 else { float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; - const int radius= brush_size(scene, brush); + const int radius= BKE_brush_size_get(scene, brush); /* compute brush spacing adapted to brush radius, spacing may depend * on pressure, so update it */ - brush_apply_pressure(painter, brush, painter->lastpressure); + brush_pressure_apply(painter, brush, painter->lastpressure); spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; /* setup starting distance, direction vector and accumulated distance */ @@ -1174,10 +1174,10 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 t = step/len; press= (1.0f-t)*painter->lastpressure + t*pressure; - brush_apply_pressure(painter, brush, press); + brush_pressure_apply(painter, brush, press); spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; - brush_jitter_pos(scene, brush, paintpos, finalpos); + BKE_brush_jitter_pos(scene, brush, paintpos, finalpos); if (painter->cache.enabled) brush_painter_refresh_cache(painter, finalpos, use_color_correction); @@ -1192,7 +1192,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 } } else { - brush_jitter_pos(scene, brush, pos, finalpos); + BKE_brush_jitter_pos(scene, brush, pos, finalpos); if (painter->cache.enabled) brush_painter_refresh_cache(painter, finalpos, use_color_correction); @@ -1218,9 +1218,9 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 painter->accumtime -= painttime; while (painter->accumtime >= (double)brush->rate) { - brush_apply_pressure(painter, brush, pressure); + brush_pressure_apply(painter, brush, pressure); - brush_jitter_pos(scene, brush, pos, finalpos); + BKE_brush_jitter_pos(scene, brush, pos, finalpos); if (painter->cache.enabled) brush_painter_refresh_cache(painter, finalpos, use_color_correction); @@ -1238,8 +1238,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 painter->lastmousepos[1]= pos[1]; painter->lastpressure= pressure; - brush_set_alpha(scene, brush, painter->startalpha); - brush_set_size(scene, brush, painter->startsize); + brush_alpha_set(scene, brush, painter->startalpha); + BKE_brush_size_set(scene, brush, painter->startsize); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -1247,7 +1247,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2 } /* Uses the brush curve control to find a strength value between 0 and 1 */ -float brush_curve_strength_clamp(Brush *br, float p, const float len) +float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) { if (p >= len) return 0; else p= p/len; @@ -1259,7 +1259,7 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len) } /* same as above but can return negative values if the curve enables * used for sculpt only */ -float brush_curve_strength(Brush *br, float p, const float len) +float BKE_brush_curve_strength(Brush *br, float p, const float len) { if (p >= len) p= 1.0f; @@ -1270,7 +1270,7 @@ float brush_curve_strength(Brush *br, float p, const float len) } /* TODO: should probably be unified with BrushPainter stuff? */ -unsigned int *brush_gen_texture_cache(Brush *br, int half_side) +unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) { unsigned int *texcache = NULL; MTex *mtex = &br->mtex; @@ -1316,7 +1316,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) } /**** Radial Control ****/ -struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) +struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br) { ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture"); unsigned int *texcache; @@ -1324,14 +1324,14 @@ struct ImBuf *brush_gen_radial_control_imbuf(Brush *br) int half = side / 2; int i, j; - texcache = brush_gen_texture_cache(br, half); + texcache = BKE_brush_gen_texture_cache(br, half); im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; for (i=0; irect_float[i*side + j]= brush_curve_strength_clamp(br, magn, half); + im->rect_float[i*side + j]= BKE_brush_curve_strength_clamp(br, magn, half); } } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 6b1c6a26493..11c628e7848 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -50,7 +50,7 @@ /****************************** Camera Datablock *****************************/ -void *add_camera(const char *name) +void *BKE_camera_add(const char *name) { Camera *cam; @@ -69,7 +69,7 @@ void *add_camera(const char *name) return cam; } -Camera *copy_camera(Camera *cam) +Camera *BKE_camera_copy(Camera *cam) { Camera *camn; @@ -80,7 +80,7 @@ Camera *copy_camera(Camera *cam) return camn; } -void make_local_camera(Camera *cam) +void BKE_camera_make_local(Camera *cam) { Main *bmain= G.main; Object *ob; @@ -108,7 +108,7 @@ void make_local_camera(Camera *cam) id_clear_lib_data(bmain, &cam->id); } else if (is_local && is_lib) { - Camera *cam_new= copy_camera(cam); + Camera *cam_new= BKE_camera_copy(cam); cam_new->id.us= 0; @@ -127,14 +127,14 @@ void make_local_camera(Camera *cam) } } -void free_camera(Camera *ca) +void BKE_camera_free(Camera *ca) { BKE_free_animdata((ID *)ca); } /******************************** Camera Usage *******************************/ -void object_camera_mode(RenderData *rd, Object *cam_ob) +void BKE_camera_object_mode(RenderData *rd, Object *cam_ob) { rd->mode &= ~(R_ORTHO|R_PANORAMA); @@ -146,7 +146,7 @@ void object_camera_mode(RenderData *rd, Object *cam_ob) } /* get the camera's dof value, takes the dof object into account */ -float object_camera_dof_distance(Object *ob) +float BKE_camera_object_dof_distance(Object *ob) { Camera *cam = (Camera *)ob->data; if (ob->type != OB_CAMERA) @@ -165,7 +165,7 @@ float object_camera_dof_distance(Object *ob) return cam->YF_dofdist; } -float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) +float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) { /* sensor size used to fit to. for auto, sensor_x is both x and y. */ if (sensor_fit == CAMERA_SENSOR_FIT_VERT) @@ -174,7 +174,7 @@ float camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) return sensor_x; } -int camera_sensor_fit(int sensor_fit, float sizex, float sizey) +int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey) { if (sensor_fit == CAMERA_SENSOR_FIT_AUTO) { if (sizex >= sizey) @@ -188,7 +188,7 @@ int camera_sensor_fit(int sensor_fit, float sizex, float sizey) /******************************** Camera Params *******************************/ -void camera_params_init(CameraParams *params) +void BKE_camera_params_init(CameraParams *params) { memset(params, 0, sizeof(CameraParams)); @@ -200,7 +200,7 @@ void camera_params_init(CameraParams *params) params->zoom= 1.0f; } -void camera_params_from_object(CameraParams *params, Object *ob) +void BKE_camera_params_from_object(CameraParams *params, Object *ob) { if (!ob) return; @@ -239,7 +239,7 @@ void camera_params_from_object(CameraParams *params, Object *ob) } } -void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d) +void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d) { /* common */ params->lens= v3d->lens; @@ -248,7 +248,7 @@ void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D * if (rv3d->persp==RV3D_CAMOB) { /* camera view */ - camera_params_from_object(params, v3d->camera); + BKE_camera_params_from_object(params, v3d->camera); params->zoom= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); @@ -275,7 +275,7 @@ void camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D * } } -void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float xasp, float yasp) +void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float xasp, float yasp) { rctf viewplane; float pixsize, viewfac, sensor_size, dx, dy; @@ -293,12 +293,12 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f } else { /* perspective camera */ - sensor_size= camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); + sensor_size= BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); pixsize= (sensor_size * params->clipsta)/params->lens; } /* determine sensor fit */ - sensor_fit = camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy); + sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy); if (sensor_fit==CAMERA_SENSOR_FIT_HOR) viewfac= winx; @@ -351,23 +351,23 @@ void camera_params_compute_viewplane(CameraParams *params, int winx, int winy, f } /* viewplane is assumed to be already computed */ -void camera_params_compute_matrix(CameraParams *params) +void BKE_camera_params_compute_matrix(CameraParams *params) { - rctf viewplane= params->viewplane; + rctf viewplane = params->viewplane; /* compute projection matrix */ if (params->is_ortho) orthographic_m4(params->winmat, viewplane.xmin, viewplane.xmax, - viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); + viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); else perspective_m4(params->winmat, viewplane.xmin, viewplane.xmax, - viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); + viewplane.ymin, viewplane.ymax, params->clipsta, params->clipend); } /***************************** Camera View Frame *****************************/ -void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short do_clip, const float scale[3], - float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]) +void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short do_clip, const float scale[3], + float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3]) { float facx, facy; float depth; @@ -376,7 +376,7 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh if (scene) { float aspx= (float) scene->r.xsch*scene->r.xasp; float aspy= (float) scene->r.ysch*scene->r.yasp; - int sensor_fit= camera_sensor_fit(camera->sensor_fit, aspx, aspy); + int sensor_fit= BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy); if (sensor_fit==CAMERA_SENSOR_FIT_HOR) { r_asp[0]= 1.0; @@ -431,14 +431,14 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth; } -void camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) +void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) { float dummy_asp[2]; float dummy_shift[2]; float dummy_drawsize; const float dummy_scale[3]= {1.0f, 1.0f, 1.0f}; - camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, + BKE_camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, dummy_asp, dummy_shift, &dummy_drawsize, r_vec); } @@ -450,7 +450,7 @@ typedef struct CameraViewFrameData { unsigned int tot; } CameraViewFrameData; -static void camera_to_frame_view_cb(const float co[3], void *user_data) +static void BKE_camera_to_frame_view_cb(const float co[3], void *user_data) { CameraViewFrameData *data= (CameraViewFrameData *)user_data; unsigned int i; @@ -467,7 +467,7 @@ static void camera_to_frame_view_cb(const float co[3], void *user_data) /* don't move the camera, just yield the fit location */ /* only valid for perspective cameras */ -int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3]) +int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *camera_ob, float r_co[3]) { float shift[2]; float plane_tx[4][3]; @@ -477,7 +477,7 @@ int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *cam unsigned int i; - camera_view_frame(scene, camera_ob->data, data_cb.frame_tx); + BKE_camera_view_frame(scene, camera_ob->data, data_cb.frame_tx); copy_m3_m4(rot_obmat, camera_ob->obmat); normalize_m3(rot_obmat); @@ -514,7 +514,7 @@ int camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object *cam data_cb.tot= 0; /* run callback on all visible points */ BKE_scene_foreach_display_point(scene, v3d, BA_SELECT, - camera_to_frame_view_cb, &data_cb); + BKE_camera_to_frame_view_cb, &data_cb); if (data_cb.tot <= 1) { return FALSE; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 47b497188ec..424ded0397e 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4012,8 +4012,8 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase add_v2_v2v2(pos, marker->pos, track->offset); - camera_params_init(¶ms); - camera_params_from_object(¶ms, camob); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, camob); if (params.is_ortho) { vec[0] = params.ortho_scale * (pos[0] - 0.5f + params.shiftx); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 14ab8166f0a..14e2d75bee5 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -224,7 +224,7 @@ int id_make_local(ID *id, int test) if (!test) make_local_lamp((Lamp*)id); return 1; case ID_CA: - if (!test) make_local_camera((Camera*)id); + if (!test) BKE_camera_make_local((Camera*)id); return 1; case ID_SPK: if (!test) make_local_speaker((Speaker*)id); @@ -258,7 +258,7 @@ int id_make_local(ID *id, int test) case ID_NT: return 0; /* not implemented */ case ID_BR: - if (!test) make_local_brush((Brush*)id); + if (!test) BKE_brush_make_local((Brush*)id); return 1; case ID_PA: if (!test) make_local_particlesettings((ParticleSettings*)id); @@ -315,7 +315,7 @@ int id_copy(ID *id, ID **newid, int test) if (!test) *newid= (ID*)copy_speaker((Speaker*)id); return 1; case ID_CA: - if (!test) *newid= (ID*)copy_camera((Camera*)id); + if (!test) *newid= (ID*)BKE_camera_copy((Camera*)id); return 1; case ID_IP: return 0; /* deprecated */ @@ -349,7 +349,7 @@ int id_copy(ID *id, ID **newid, int test) if (!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id); return 1; case ID_BR: - if (!test) *newid= (ID*)copy_brush((Brush*)id); + if (!test) *newid= (ID*)BKE_brush_copy((Brush*)id); return 1; case ID_PA: if (!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id); @@ -831,7 +831,7 @@ void free_libblock(ListBase *lb, void *idv) free_lamp((Lamp *)id); break; case ID_CA: - free_camera((Camera*) id); + BKE_camera_free((Camera*) id); break; case ID_IP: free_ipo((Ipo *)id); @@ -873,7 +873,7 @@ void free_libblock(ListBase *lb, void *idv) ntreeFreeTree((bNodeTree *)id); break; case ID_BR: - free_brush((Brush *)id); + BKE_brush_free((Brush *)id); break; case ID_PA: psys_free_settings((ParticleSettings *)id); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 280a8fdc2b2..fde8f8e3f3d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -755,7 +755,7 @@ void *add_obdata_from_type(int type) case OB_SURF: return BKE_curve_add("Surf", OB_SURF); case OB_FONT: return BKE_curve_add("Text", OB_FONT); case OB_MBALL: return BKE_metaball_add("Meta"); - case OB_CAMERA: return add_camera("Camera"); + case OB_CAMERA: return BKE_camera_add("Camera"); case OB_LAMP: return add_lamp("Lamp"); case OB_LATTICE: return add_lattice("Lattice"); case OB_ARMATURE: return add_armature("Armature"); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index f417f9b79fb..08d8479fd93 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -126,7 +126,7 @@ void paint_init(Paint *p, const char col[3]) /* If there's no brush, create one */ brush = paint_brush(p); if (brush == NULL) - brush= add_brush("Brush"); + brush= BKE_brush_add("Brush"); paint_brush_set(p, brush); memcpy(p->paint_cursor_col, col, 3); diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h index 4e9e6f111db..7b92ac05d29 100644 --- a/source/blender/blenlib/BLI_voxel.h +++ b/source/blender/blenlib/BLI_voxel.h @@ -33,7 +33,7 @@ */ /** find the index number of a voxel, given x/y/z integer coords and resolution vector */ -#define BLI_VEXEL_INDEX(x, y, z, res) ((z) * (res)[1] * (res)[0] + (y) * (res)[0] + (x)) +#define BLI_VOXEL_INDEX(x, y, z, res) ((z) * (res)[1] * (res)[0] + (y) * (res)[0] + (x)) /* all input coordinates must be in bounding box 0.0 - 1.0 */ float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]); diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 1fe42384eb6..3ad9edd14a3 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -40,7 +40,7 @@ BLI_INLINE float D(float *data, const int res[3], int x, int y, int z) CLAMP(x, 0, res[0] - 1); CLAMP(y, 0, res[1] - 1); CLAMP(z, 0, res[2] - 1); - return data[ BLI_VEXEL_INDEX(x, y, z, res) ]; + return data[ BLI_VOXEL_INDEX(x, y, z, res) ]; } /* *** nearest neighbor *** */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c07b1d4f66a..c0ae6415fe1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1685,7 +1685,7 @@ static void direct_link_brush(FileData *fd, Brush *brush) if (brush->curve) direct_link_curvemapping(fd, brush->curve); else - brush_curve_preset(brush, CURVE_PRESET_SHARP); + BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP); brush->preview= NULL; brush->icon_imbuf= NULL; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index c793453227a..1d315b6ea06 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -802,8 +802,8 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) cam_id = camera->getOriginalId(); cam_name = camera->getName(); - if (cam_name.size()) cam = (Camera*)add_camera((char*)cam_name.c_str()); - else cam = (Camera*)add_camera((char*)cam_id.c_str()); + if (cam_name.size()) cam = (Camera *)BKE_camera_add((char*)cam_name.c_str()); + else cam = (Camera *)BKE_camera_add((char*)cam_id.c_str()); if (!cam) { fprintf(stderr, "Cannot create camera.\n"); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 85735c1ac1c..d030e61952e 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1783,7 +1783,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_camera(obn->data); + obn->data = BKE_camera_copy(obn->data); didit = 1; } id->us--; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 35b3b0a0407..4678416e1c9 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1486,7 +1486,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) } break; case OB_CAMERA: - ob->data = copy_camera(ob->data); + ob->data = BKE_camera_copy(ob->data); break; case OB_MESH: ob->data = copy_mesh(ob->data); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index ba80fd83de7..7fb5352979d 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -2990,7 +2990,7 @@ static void brush_puff(PEData *data, int point_index) } -static void brush_weight(PEData *data, float UNUSED(mat[][4]), float UNUSED(imat[][4]), int point_index, int key_index, PTCacheEditKey *UNUSED(key)) +static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[][4]), float UNUSED(imat[][4]), int point_index, int key_index, PTCacheEditKey *UNUSED(key)) { /* roots have full weight allways */ if (key_index) { @@ -3622,7 +3622,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.weightfac = brush->strength; /* note that this will never be zero */ - foreach_mouse_hit_key(&data, brush_weight, selected); + foreach_mouse_hit_key(&data, BKE_brush_weight_get, selected); } break; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 553a9a335d7..c681f8ddb75 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -69,7 +69,7 @@ typedef struct Snapshot { float size[3]; float ofs[3]; float rot; - int brush_size; + int BKE_brush_size_get; int winx; int winy; int brush_map_mode; @@ -87,8 +87,8 @@ static int same_snap(Snapshot *snap, Brush *brush, ViewContext *vc) /* make brush smaller shouldn't cause a resample */ ((mtex->brush_map_mode == MTEX_MAP_MODE_FIXED && - (brush_size(vc->scene, brush) <= snap->brush_size)) || - (brush_size(vc->scene, brush) == snap->brush_size)) && + (BKE_brush_size_get(vc->scene, brush) <= snap->BKE_brush_size_get)) || + (BKE_brush_size_get(vc->scene, brush) == snap->BKE_brush_size_get)) && (mtex->brush_map_mode == snap->brush_map_mode) && (vc->ar->winx == snap->winx) && @@ -110,7 +110,7 @@ static void make_snap(Snapshot *snap, Brush *brush, ViewContext *vc) snap->rot = -1; } - snap->brush_size = brush_size(vc->scene, brush); + snap->BKE_brush_size_get = BKE_brush_size_get(vc->scene, brush); snap->winx = vc->ar->winx; snap->winy = vc->ar->winy; } @@ -155,7 +155,7 @@ static int load_tex(Sculpt *sd, Brush *br, ViewContext *vc) make_snap(&snap, br, vc); if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { - int s = brush_size(vc->scene, br); + int s = BKE_brush_size_get(vc->scene, br); int r = 1; for (s >>= 1; s > 0; s >>= 1) @@ -196,7 +196,7 @@ static int load_tex(Sculpt *sd, Brush *br, ViewContext *vc) // largely duplicated from tex_strength const float rotation = -br->mtex.rot; - float radius = brush_size(vc->scene, br); + float radius = BKE_brush_size_get(vc->scene, br); int index = j * size + i; float x; float avg; @@ -240,7 +240,7 @@ static int load_tex(Sculpt *sd, Brush *br, ViewContext *vc) avg += br->texture_sample_bias; if (br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) - avg *= brush_curve_strength(br, len, 1); /* Falloff curve */ + avg *= BKE_brush_curve_strength(br, len, 1); /* Falloff curve */ buffer[index] = 255 - (GLubyte)(255 * avg); } @@ -345,11 +345,11 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc, sculpt_stroke_get_location(C, location, window)) { *pixel_radius = project_brush_radius(vc, - brush_unprojected_radius(scene, brush), + BKE_brush_unprojected_radius_get(scene, brush), location); if (*pixel_radius == 0) - *pixel_radius = brush_size(scene, brush); + *pixel_radius = BKE_brush_size_get(scene, brush); mul_m4_v3(vc->obact->obmat, location); @@ -359,7 +359,7 @@ static int sculpt_get_brush_geometry(bContext *C, ViewContext *vc, Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = paint_brush(&sd->paint); - *pixel_radius = brush_size(scene, brush); + *pixel_radius = BKE_brush_size_get(scene, brush); hit = 0; } @@ -414,7 +414,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, glTranslatef(-0.5f, -0.5f, 0); /* scale based on tablet pressure */ - if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) { + if (sd->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) { glTranslatef(0.5f, 0.5f, 0); glScalef(1.0f / sd->pressure_value, 1.0f / sd->pressure_value, 1); glTranslatef(-0.5f, -0.5f, 0); @@ -429,7 +429,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, quad.ymax = aim[1] + sd->anchored_size - win->ymin; } else { - const int radius = brush_size(vc->scene, brush); + const int radius = BKE_brush_size_get(vc->scene, brush); quad.xmin = x - radius; quad.ymin = y - radius; quad.xmax = x + radius; @@ -475,7 +475,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, float unprojected_radius, projected_radius; /* update the brush's cached 3D radius */ - if (!brush_use_locked_size(vc->scene, brush)) { + if (!BKE_brush_use_locked_size(vc->scene, brush)) { /* get 2D brush radius */ if (sd->draw_anchored) projected_radius = sd->anchored_size; @@ -483,7 +483,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, if (brush->flag & BRUSH_ANCHORED) projected_radius = 8; else - projected_radius = brush_size(vc->scene, brush); + projected_radius = BKE_brush_size_get(vc->scene, brush); } /* convert brush radius from 2D to 3D */ @@ -491,11 +491,11 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, projected_radius); /* scale 3D brush radius by pressure */ - if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) + if (sd->draw_pressure && BKE_brush_use_size_pressure(vc->scene, brush)) unprojected_radius *= sd->pressure_value; /* set cached value in either Brush or UnifiedPaintSettings */ - brush_set_unprojected_radius(vc->scene, brush, unprojected_radius); + BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius); } } @@ -514,7 +514,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) translation[1] = y; outline_alpha = 0.5; outline_col = brush->add_col; - final_radius = brush_size(scene, brush); + final_radius = BKE_brush_size_get(scene, brush); /* check that brush drawing is enabled */ if (!(paint->flags & PAINT_SHOW_BRUSH)) @@ -557,8 +557,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* draw overlay */ paint_draw_alpha_overlay(sd, brush, &vc, x, y); - if (brush_use_locked_size(scene, brush)) - brush_set_size(scene, brush, pixel_radius); + if (BKE_brush_use_locked_size(scene, brush)) + BKE_brush_size_set(scene, brush, pixel_radius); /* check if brush is subtracting, use different color then */ /* TODO: no way currently to know state of pen flip or diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index dcf4efeff13..a025a84bea9 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1457,7 +1457,7 @@ static float project_paint_uvpixel_mask( // This only works when the opacity dosnt change while painting, stylus pressure messes with this // so don't use it. - // if (ps->is_airbrush==0) mask *= brush_alpha(ps->brush); + // if (ps->is_airbrush==0) mask *= BKE_brush_alpha_get(ps->brush); return mask; } @@ -2953,7 +2953,7 @@ static void project_paint_begin(ProjPaintState *ps) MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */ - const int diameter = 2 * brush_size(ps->scene, ps->brush); + const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush); /* ---- end defines ---- */ @@ -3091,10 +3091,10 @@ static void project_paint_begin(ProjPaintState *ps) invert_m4_m4(viewmat, viewinv); /* window matrix, clipping and ortho */ - camera_params_init(¶ms); - camera_params_from_object(¶ms, cam_ob); - camera_params_compute_viewplane(¶ms, ps->winx, ps->winy, 1.0f, 1.0f); - camera_params_compute_matrix(¶ms); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, cam_ob); + BKE_camera_params_compute_viewplane(¶ms, ps->winx, ps->winy, 1.0f, 1.0f); + BKE_camera_params_compute_matrix(¶ms); copy_m4_m4(winmat, params.winmat); ps->clipsta = params.clipsta; @@ -3597,7 +3597,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) { if (ps->source == PROJ_SRC_VIEW) { float min_brush[2], max_brush[2]; - const float radius = (float)brush_size(ps->scene, ps->brush); + const float radius = (float)BKE_brush_size_get(ps->scene, ps->brush); /* so we don't have a bucket bounds that is way too small to paint into */ // if (radius < 1.0f) radius = 1.0f; // this doesn't work yet :/ @@ -3635,7 +3635,7 @@ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) static int project_bucket_iter_next(ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2]) { - const int diameter = 2 * brush_size(ps->scene, ps->brush); + const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush); if (ps->thread_tot > 1) BLI_lock_thread(LOCK_CUSTOM1); @@ -3859,7 +3859,7 @@ static void *do_projectpaint_thread(void *ph_v) float co[2]; float mask = 1.0f; /* airbrush wont use mask */ unsigned short mask_short; - const float radius = (float)brush_size(ps->scene, ps->brush); + const float radius = (float)BKE_brush_size_get(ps->scene, ps->brush); const float radius_squared = radius * radius; /* avoid a square root with every dist comparison */ short lock_alpha = ELEM(ps->brush->blend, IMB_BLEND_ERASE_ALPHA, IMB_BLEND_ADD_ALPHA) ? 0 : ps->brush->flag & BRUSH_LOCK_ALPHA; @@ -3913,12 +3913,12 @@ static void *do_projectpaint_thread(void *ph_v) if (dist_nosqrt <= radius_squared) { dist = sqrtf(dist_nosqrt); - falloff = brush_curve_strength_clamp(ps->brush, dist, radius); + falloff = BKE_brush_curve_strength_clamp(ps->brush, dist, radius); if (falloff > 0.0f) { if (ps->is_texbrush) { /* note, for clone and smear, we only use the alpha, could be a special function */ - brush_sample_tex(ps->scene, ps->brush, projPixel->projCoSS, rgba, thread_index); + BKE_brush_sample_tex(ps->scene, ps->brush, projPixel->projCoSS, rgba, thread_index); alpha = rgba[3]; } else { @@ -3927,7 +3927,7 @@ static void *do_projectpaint_thread(void *ph_v) if (ps->is_airbrush) { /* for an aurbrush there is no real mask, so just multiply the alpha by it */ - alpha *= falloff * brush_alpha(ps->scene, ps->brush); + alpha *= falloff * BKE_brush_alpha_get(ps->scene, ps->brush); mask = ((float)projPixel->mask) / 65535.0f; } else { @@ -3935,7 +3935,7 @@ static void *do_projectpaint_thread(void *ph_v) falloff = 1.0f - falloff; falloff = 1.0f - (falloff * falloff); - mask_short = (unsigned short)(projPixel->mask * (brush_alpha(ps->scene, ps->brush) * falloff)); + mask_short = (unsigned short)(projPixel->mask * (BKE_brush_alpha_get(ps->scene, ps->brush) * falloff)); if (mask_short > projPixel->mask_max) { mask = ((float)mask_short) / 65535.0f; projPixel->mask_max = mask_short; @@ -4101,9 +4101,9 @@ static int project_paint_sub_stroke(ProjPaintState *ps, BrushPainter *painter, c pos[1] = (float)(mval_i[1]); // we may want to use this later - // brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0); + // BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float)? 1: 0), 0, 0); - if (brush_painter_paint(painter, project_paint_op, pos, time, pressure, ps, 0)) { + if (BKE_brush_painter_paint(painter, project_paint_op, pos, time, pressure, ps, 0)) { return 1; } else return 0; @@ -4525,9 +4525,9 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, pos[0] = uv[0] * ibuf->x; pos[1] = uv[1] * ibuf->y; - brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0); + BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0); - if (brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) { + if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) { if (update) imapaint_image_update(s->sima, image, ibuf, texpaint); return 1; @@ -4580,7 +4580,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint redraw |= imapaint_paint_sub_stroke(s, painter, s->image, texpaint, fwuv, time, 1, pressure); imapaint_clear_partial_redraw(); - brush_painter_break_stroke(painter); + BKE_brush_painter_break_stroke(painter); } /* set new canvas */ @@ -4854,7 +4854,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) if (pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) pop->s.tool = PAINT_TOOL_DRAW; pop->s.blend = brush->blend; - pop->orig_brush_size = brush_size(scene, brush); + pop->orig_brush_size = BKE_brush_size_get(scene, brush); if (pop->mode != PAINT_MODE_2D) { Object *ob = OBACT; @@ -4920,8 +4920,8 @@ static int texture_paint_init(bContext *C, wmOperator *op) return 0; /* Don't allow brush size below 2 */ - if (brush_size(scene, brush) < 2) - brush_set_size(scene, brush, 2); + if (BKE_brush_size_get(scene, brush) < 2) + BKE_brush_size_set(scene, brush, 2); /* allocate and initialize spacial data structures */ project_paint_begin(&pop->ps); @@ -4935,7 +4935,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) image_undo_restore, image_undo_free); /* create painter */ - pop->painter = brush_painter_new(scene, pop->s.brush); + pop->painter = BKE_brush_painter_new(scene, pop->s.brush); return 1; } @@ -5002,10 +5002,10 @@ static void paint_exit(bContext *C, wmOperator *op) settings->imapaint.flag &= ~IMAGEPAINT_DRAWING; imapaint_canvas_free(&pop->s); - brush_painter_free(pop->painter); + BKE_brush_painter_free(pop->painter); if (pop->mode == PAINT_MODE_3D_PROJECT) { - brush_set_size(scene, pop->ps.brush, pop->orig_brush_size); + BKE_brush_size_set(scene, pop->ps.brush, pop->orig_brush_size); paint_brush_exit_tex(pop->ps.brush); project_paint_end(&pop->ps); @@ -5079,13 +5079,13 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* special exception here for too high pressure values on first touch in * windows for some tablets, then we just skip first touch .. */ - if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(scene, pop->s.brush) || brush_use_size_pressure(scene, pop->s.brush))) + if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) return; /* This can be removed once fixed properly in - * brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) + * BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) * at zero pressure we should do nothing 1/2^12 is .0002 which is the sensitivity of the most sensitive pen tablet available */ - if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(scene, pop->s.brush) || brush_use_size_pressure(scene, pop->s.brush))) + if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || BKE_brush_use_alpha_pressure(scene, pop->s.brush) || BKE_brush_use_size_pressure(scene, pop->s.brush))) return; } @@ -5208,7 +5208,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { ToolSettings *ts; float zoomx, zoomy; - const float size = (float)brush_size(scene, brush); + const float size = (float)BKE_brush_size_get(scene, brush); short use_zoom; float pixel_size; float alpha = 0.5f; @@ -5702,8 +5702,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) /* override */ ps.is_texbrush = 0; ps.is_airbrush = 1; - orig_brush_size = brush_size(scene, ps.brush); - brush_set_size(scene, ps.brush, 32); /* cover the whole image */ + orig_brush_size = BKE_brush_size_get(scene, ps.brush); + BKE_brush_size_set(scene, ps.brush, 32); /* cover the whole image */ ps.tool = PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */ @@ -5716,7 +5716,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) project_paint_begin(&ps); if (ps.dm == NULL) { - brush_set_size(scene, ps.brush, orig_brush_size); + BKE_brush_size_set(scene, ps.brush, orig_brush_size); return OPERATOR_CANCELLED; } else { @@ -5740,7 +5740,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) project_paint_end(&ps); scene->toolsettings->imapaint.flag &= ~IMAGEPAINT_DRAWING; - brush_set_size(scene, ps.brush, orig_brush_size); + BKE_brush_size_set(scene, ps.brush, orig_brush_size); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e218cfe8fd2..2699e9f56f8 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -63,9 +63,9 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op)) struct Brush *br = paint_brush(paint); if (br) - br = copy_brush(br); + br = BKE_brush_copy(br); else - br = add_brush("Brush"); + br = BKE_brush_add("Brush"); paint_brush_set(paint_get_active(CTX_data_scene(C)), br); @@ -98,7 +98,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op) if (brush) { // pixel radius { - const int old_size = brush_size(scene, brush); + const int old_size = BKE_brush_size_get(scene, brush); int size = (int)(scalar * old_size); if (old_size == size) { @@ -111,17 +111,17 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op) } CLAMP(size, 1, 2000); // XXX magic number - brush_set_size(scene, brush, size); + BKE_brush_size_set(scene, brush, size); } // unprojected radius { - float unprojected_radius = scalar * brush_unprojected_radius(scene, brush); + float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush); if (unprojected_radius < 0.001f) // XXX magic number unprojected_radius = 0.001f; - brush_set_unprojected_radius(scene, brush, unprojected_radius); + BKE_brush_unprojected_radius_set(scene, brush, unprojected_radius); } } @@ -178,7 +178,7 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) if (!ob) return OPERATOR_CANCELLED; if (ob->mode & OB_MODE_SCULPT) - brush_reset_sculpt(brush); + BKE_brush_sculpt_reset(brush); /* TODO: other modes */ return OPERATOR_FINISHED; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 010278e8621..fe228839c47 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -146,10 +146,10 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev if (stroke->vc.obact->sculpt) { float delta[2]; - brush_jitter_pos(scene, brush, mouse_in, mouse); + BKE_brush_jitter_pos(scene, brush, mouse_in, mouse); /* XXX: meh, this is round about because - * brush_jitter_pos isn't written in the best way to + * BKE_brush_jitter_pos isn't written in the best way to * be reused here */ if (brush->flag & BRUSH_JITTER_PRESSURE) { sub_v2_v2v2(delta, mouse, mouse_in); @@ -231,11 +231,11 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const float pressure = 1.0f; /* XXX mysterious :) what has 'use size' do with this here... if you don't check for it, pressure fails */ - if (brush_use_size_pressure(scene, stroke->brush)) + if (BKE_brush_use_size_pressure(scene, stroke->brush)) pressure = event_tablet_data(event, NULL); if (pressure > FLT_EPSILON) { - scale = (brush_size(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length; + scale = (BKE_brush_size_get(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length; if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 89a46272a8f..fb5ddda7a3e 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -358,7 +358,7 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf static int brush_curve_preset_exec(bContext *C, wmOperator *op) { Brush *br = paint_brush(paint_get_active(CTX_data_scene(C))); - brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); + BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9c89eb7c573..37d5af553ab 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -859,7 +859,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float *vert_ } else { const float dist = sqrtf(dist_squared); - return brush_curve_strength_clamp(brush, dist, brush_size_pressure); + return BKE_brush_curve_strength_clamp(brush, dist, brush_size_pressure); } } @@ -1051,7 +1051,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) if (v_idx_best != -1) { /* should always be valid */ float vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active); - brush_set_weight(scene, brush, vgroup_weight); + BKE_brush_weight_set(scene, brush, vgroup_weight); change = TRUE; } } @@ -1641,7 +1641,7 @@ typedef struct WeightPaintInfo { char do_multipaint; char do_auto_normalize; - float brush_alpha_value; /* result of brush_alpha() */ + float brush_alpha_value; /* result of BKE_brush_alpha_get() */ } WeightPaintInfo; /* fresh start to make multi-paint and locking modular */ @@ -2244,9 +2244,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P char *defbase_sel; const float pressure = RNA_float_get(itemptr, "pressure"); - const float brush_size_pressure = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f); - const float brush_alpha_value = brush_alpha(scene, brush); - const float brush_alpha_pressure = brush_alpha_value * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f); + const float brush_size_pressure = BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f); + const float brush_alpha_value = BKE_brush_alpha_get(scene, brush); + const float brush_alpha_pressure = brush_alpha_value * (BKE_brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f); /* intentionally don't initialize as NULL, make sure we initialize all members below */ WeightPaintInfo wpi; @@ -2342,7 +2342,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) paintweight = 0.0f; else - paintweight = brush_weight(scene, brush); + paintweight = BKE_brush_weight_get(scene, brush); for (index = 0; index < totindex; index++) { if (indexar[index] && indexar[index] <= me->totpoly) { @@ -2510,7 +2510,7 @@ static int weight_paint_set_exec(bContext *C, wmOperator *UNUSED(op)) Object *obact = CTX_data_active_object(C); ToolSettings *ts = CTX_data_tool_settings(C); Brush *brush = paint_brush(&ts->wpaint->paint); - float vgroup_weight = brush_weight(scene, brush); + float vgroup_weight = BKE_brush_weight_get(scene, brush); wpaint_fill(scene->toolsettings->wpaint, obact, vgroup_weight); ED_region_tag_redraw(CTX_wm_region(C)); /* XXX - should redraw all 3D views */ @@ -2870,8 +2870,8 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P float mval[2]; const float pressure = RNA_float_get(itemptr, "pressure"); - const float brush_size_pressure = brush_size(scene, brush) * (brush_use_size_pressure(scene, brush) ? pressure : 1.0f); - const float brush_alpha_pressure = brush_alpha(scene, brush) * (brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f); + const float brush_size_pressure = BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f); + const float brush_alpha_pressure = BKE_brush_alpha_get(scene, brush) * (BKE_brush_use_alpha_pressure(scene, brush) ? pressure : 1.0f); RNA_float_get_array(itemptr, "mouse", mval); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 32ed55854b6..fa560dc138c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -505,7 +505,7 @@ static float overlapped_curve(Brush *br, float x) xx = fabs(x0 + i * h); if (xx < 1.0f) - sum += brush_curve_strength(br, xx, 1); + sum += BKE_brush_curve_strength(br, xx, 1); } return sum; @@ -618,10 +618,10 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) Brush *brush = paint_brush(&sd->paint); /* Primary strength input; square it to make lower values more sensitive */ - const float root_alpha = brush_alpha(scene, brush); + const float root_alpha = BKE_brush_alpha_get(scene, brush); float alpha = root_alpha * root_alpha; float dir = brush->flag & BRUSH_DIR_IN ? -1 : 1; - float pressure = brush_use_alpha_pressure(scene, brush) ? cache->pressure : 1; + float pressure = BKE_brush_use_alpha_pressure(scene, brush) ? cache->pressure : 1; float pen_flip = cache->pen_flip ? -1 : 1; float invert = cache->invert ? -1 : 1; float accum = integrate_overlap(brush); @@ -752,7 +752,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], /* leave the coordinates relative to the screen */ /* use unadjusted size for tiled mode */ - radius = brush_size(ss->cache->vc->scene, br); + radius = BKE_brush_size_get(ss->cache->vc->scene, br); x = point_2d[0]; y = point_2d[1]; @@ -792,7 +792,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], avg += br->texture_sample_bias; /* Falloff curve */ - avg *= brush_curve_strength(br, len, ss->cache->radius); + avg *= BKE_brush_curve_strength(br, len, ss->cache->radius); avg *= frontface(br, sculpt_normal, vno, fno); @@ -1250,8 +1250,8 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ - if (brush_alpha(scene, brush) > 0.0f) - crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor / (brush_alpha(scene, brush) * brush_alpha(scene, brush)); + if (BKE_brush_alpha_get(scene, brush) > 0.0f) + crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor / (BKE_brush_alpha_get(scene, brush) * BKE_brush_alpha_get(scene, brush)); else crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; @@ -2720,7 +2720,7 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob) static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) { Brush *brush = paint_brush(&sd->paint); - const int radius = brush_size(scene, brush); + const int radius = BKE_brush_size_get(scene, brush); if (ss->texcache) { MEM_freeN(ss->texcache); @@ -2730,7 +2730,7 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) /* Need to allocate a bigger buffer for bigger brush size */ ss->texcache_side = 2 * radius; if (!ss->texcache || ss->texcache_side > ss->texcache_actual) { - ss->texcache = brush_gen_texture_cache(brush, radius); + ss->texcache = BKE_brush_gen_texture_cache(brush, radius); ss->texcache_actual = ss->texcache_side; } } @@ -3130,19 +3130,19 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, sd->pressure_value = cache->pressure; cache->previous_pixel_radius = cache->pixel_radius; - cache->pixel_radius = brush_size(scene, brush); + cache->pixel_radius = BKE_brush_size_get(scene, brush); if (cache->first_time) { - if (!brush_use_locked_size(scene, brush)) { - cache->initial_radius = paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush)); - brush_set_unprojected_radius(scene, brush, cache->initial_radius); + if (!BKE_brush_use_locked_size(scene, brush)) { + cache->initial_radius = paint_calc_object_space_radius(cache->vc, cache->true_location, BKE_brush_size_get(scene, brush)); + BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius); } else { - cache->initial_radius = brush_unprojected_radius(scene, brush); + cache->initial_radius = BKE_brush_unprojected_radius_get(scene, brush); } } - if (brush_use_size_pressure(scene, brush)) { + if (BKE_brush_use_size_pressure(scene, brush)) { cache->pixel_radius *= cache->pressure; cache->radius = cache->initial_radius * cache->pressure; } @@ -3374,7 +3374,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) /* Restore the mesh before continuing with anchored stroke */ if ((brush->flag & BRUSH_ANCHORED) || (brush->sculpt_tool == SCULPT_TOOL_GRAB && - brush_use_size_pressure(ss->cache->vc->scene, brush)) || + BKE_brush_use_size_pressure(ss->cache->vc->scene, brush)) || (brush->flag & BRUSH_RESTORE_MESH)) { paint_mesh_restore_co(sd, ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 707d5b2aa7c..95441600d77 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -205,7 +205,7 @@ void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float if ((dist = dot_v2v2(diff, diff)) <= radius) { UvElement *element; float strength; - strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); + strength = alpha * BKE_brush_curve_strength(brush, sqrt(dist), radius_root); sculptdata->uv[i].uv[0] = (1.0f - strength) * sculptdata->uv[i].uv[0] + strength * (tmp_uvdata[i].p[0] - 0.5f * (tmp_uvdata[i].b[0] + tmp_uvdata[i].sum_b[0] / tmp_uvdata[i].ncounter)); sculptdata->uv[i].uv[1] = (1.0f - strength) * sculptdata->uv[i].uv[1] + strength * (tmp_uvdata[i].p[1] - 0.5f * (tmp_uvdata[i].b[1] + tmp_uvdata[i].sum_b[1] / tmp_uvdata[i].ncounter)); @@ -269,7 +269,7 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *scul if ((dist = dot_v2v2(diff, diff)) <= radius) { UvElement *element; float strength; - strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); + strength = alpha * BKE_brush_curve_strength(brush, sqrt(dist), radius_root); sculptdata->uv[i].uv[0] = (1.0f - strength) * sculptdata->uv[i].uv[0] + strength * tmp_uvdata[i].p[0]; sculptdata->uv[i].uv[1] = (1.0f - strength) * sculptdata->uv[i].uv[1] + strength * tmp_uvdata[i].p[1]; @@ -311,14 +311,14 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event, ToolSettings *toolsettings = CTX_data_tool_settings(C); tool = sculptdata->tool; invert = sculptdata->invert ? -1 : 1; - alpha = brush_alpha(scene, brush); + alpha = BKE_brush_alpha_get(scene, brush); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); sima = CTX_wm_space_image(C); ED_space_image_size(sima, &width, &height); ED_space_image_zoom(sima, ar, &zoomx, &zoomy); - radius = brush_size(scene, brush) / (width * zoomx); + radius = BKE_brush_size_get(scene, brush) / (width * zoomx); aspectRatio = width / (float)height; /* We will compare squares to save some computation */ @@ -344,7 +344,7 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event, if ((dist = dot_v2v2(diff, diff)) <= radius) { UvElement *element; float strength; - strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); + strength = alpha * BKE_brush_curve_strength(brush, sqrt(dist), radius_root); normalize_v2(diff); sculptdata->uv[i].uv[0] -= strength * diff[0] * 0.001f; @@ -679,9 +679,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent float alpha, zoomx, zoomy; Brush *brush = paint_brush(sculptdata->uvsculpt); - alpha = brush_alpha(scene, brush); + alpha = BKE_brush_alpha_get(scene, brush); - radius = brush_size(scene, brush); + radius = BKE_brush_size_get(scene, brush); sima = CTX_wm_space_image(C); ED_space_image_size(sima, &width, &height); ED_space_image_zoom(sima, ar, &zoomx, &zoomy); @@ -715,7 +715,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent diff[1] /= aspectRatio; if ((dist = dot_v2v2(diff, diff)) <= radius) { float strength; - strength = alpha * brush_curve_strength(brush, sqrt(dist), radius_root); + strength = alpha * BKE_brush_curve_strength(brush, sqrt(dist), radius_root); data->initial_stroke->initialSelection[counter].uv = i; data->initial_stroke->initialSelection[counter].strength = strength; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 793e5712c8c..aab628180c8 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -606,7 +606,7 @@ static void draw_image_view_tool(Scene *scene) if (draw) { getmouseco_areawin(mval); - radius = brush_size(brush) * G.sima->zoom; + radius = BKE_brush_size_get(brush) * G.sima->zoom; fdrawXORcirc(mval[0], mval[1], radius); if (brush->innerradius != 1.0) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index c8754681e41..068a31a888f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1762,7 +1762,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base scale[1] = 1.0f / len_v3(ob->obmat[1]); scale[2] = 1.0f / len_v3(ob->obmat[2]); - camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale, + BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale, asp, shift, &drawsize, vec); glDisable(GL_LIGHTING); @@ -1834,7 +1834,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base if (cam->flag & CAM_SHOWLIMITS) { draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); /* qdn: was yafray only, now also enabled for Blender to be used with defocus composite node */ - draw_focus_cross(object_camera_dof_distance(ob), cam->drawsize); + draw_focus_cross(BKE_camera_object_dof_distance(ob), cam->drawsize); } wrld = scene->world; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e1828bbef32..f48b45f9793 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -939,21 +939,21 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV rctf rect_view, rect_camera; /* get viewport viewplane */ - camera_params_init(¶ms); - camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_view3d(¶ms, v3d, rv3d); if (no_zoom) params.zoom = 1.0f; - camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); + BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); rect_view = params.viewplane; /* get camera viewplane */ - camera_params_init(¶ms); - camera_params_from_object(¶ms, v3d->camera); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, v3d->camera); if (no_shift) { params.shiftx = 0.0f; params.shifty = 0.0f; } - camera_params_compute_viewplane(¶ms, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp); + BKE_camera_params_compute_viewplane(¶ms, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp); rect_camera = params.viewplane; /* get camera border within viewport */ @@ -1226,7 +1226,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) * assume and square sensor and only use sensor_x */ float sizex = scene->r.xsch * scene->r.xasp; float sizey = scene->r.ysch * scene->r.yasp; - int sensor_fit = camera_sensor_fit(ca->sensor_fit, sizex, sizey); + int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, sizex, sizey); float sensor_x = ca->sensor_x; float sensor_y = (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO) ? ca->sensor_x : ca->sensor_y; @@ -2612,10 +2612,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, if (rv3d->persp == RV3D_CAMOB && v3d->camera) { CameraParams params; - camera_params_init(¶ms); - camera_params_from_object(¶ms, v3d->camera); - camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp); - camera_params_compute_matrix(¶ms); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, v3d->camera); + BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp); + BKE_camera_params_compute_matrix(¶ms); ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, params.winmat, draw_background); } @@ -2673,10 +2673,10 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int w { CameraParams params; - camera_params_init(¶ms); - camera_params_from_object(¶ms, v3d.camera); - camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp); - camera_params_compute_matrix(¶ms); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, v3d.camera); + BKE_camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp); + BKE_camera_params_compute_matrix(¶ms); copy_m4_m4(rv3d.winmat, params.winmat); v3d.near = params.clipsta; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 39cda3efd93..ea4d28ce32f 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3660,8 +3660,8 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, if (lens) { CameraParams params; - camera_params_init(¶ms); - camera_params_from_object(¶ms, ob); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, ob); *lens = params.lens; } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 8a0cb4b597b..733c5c55bfc 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -412,7 +412,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o float r_co[3]; /* the new location to apply */ /* this function does all the important stuff */ - if (camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co)) { + if (BKE_camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co)) { ObjectTfmProtectedChannels obtfm; float obmat_new[4][4]; @@ -1000,8 +1000,8 @@ int ED_view3d_clip_range_get(View3D *v3d, RegionView3D *rv3d, float *clipsta, fl { CameraParams params; - camera_params_init(¶ms); - camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_view3d(¶ms, v3d, rv3d); if (clipsta) *clipsta = params.clipsta; if (clipend) *clipend = params.clipend; @@ -1015,9 +1015,9 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy, { CameraParams params; - camera_params_init(¶ms); - camera_params_from_view3d(¶ms, v3d, rv3d); - camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_view3d(¶ms, v3d, rv3d); + BKE_camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); if (viewplane) *viewplane = params.viewplane; if (clipsta) *clipsta = params.clipsta; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index bdff545df5c..ee4b34508d1 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -288,7 +288,7 @@ static void rna_Brush_set_size(PointerRNA *ptr, int value) Brush* brush = ptr->data; /* scale unprojected radius so it stays consistent with brush size */ - brush_scale_unprojected_radius(&brush->unprojected_radius, + BKE_brush_scale_unprojected_radius(&brush->unprojected_radius, value, brush->size); brush->size = value; } @@ -298,7 +298,7 @@ static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value) Brush* brush = ptr->data; /* scale brush size so it stays consistent with unprojected_radius */ - brush_scale_size(&brush->size, value, brush->unprojected_radius); + BKE_brush_scale_size(&brush->size, value, brush->unprojected_radius); brush->unprojected_radius = value; } diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 5331cfe8775..70a33734c3f 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -46,14 +46,14 @@ static float rna_Camera_angle_get(PointerRNA *ptr) { Camera *cam = ptr->id.data; - float sensor = camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); + float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); return focallength_to_fov(cam->lens, sensor); } static void rna_Camera_angle_set(PointerRNA *ptr, float value) { Camera *cam = ptr->id.data; - float sensor = camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); + float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); cam->lens = fov_to_focallength(value, sensor); } diff --git a/source/blender/makesrna/intern/rna_camera_api.c b/source/blender/makesrna/intern/rna_camera_api.c index 14391e74239..2d19047ef89 100644 --- a/source/blender/makesrna/intern/rna_camera_api.c +++ b/source/blender/makesrna/intern/rna_camera_api.c @@ -46,7 +46,7 @@ void rna_camera_view_frame(struct Camera *camera, struct Scene *scene, { float vec[4][3]; - camera_view_frame(scene, camera, vec); + BKE_camera_view_frame(scene, camera, vec); copy_v3_v3(vec1_r, vec[0]); copy_v3_v3(vec2_r, vec[1]); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 63006af7c72..f00126986a5 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -92,7 +92,7 @@ Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name) { - ID *id = add_camera(name); + ID *id = BKE_camera_add(name); id_us_min(id); return (Camera *)id; } @@ -385,7 +385,7 @@ void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) { - Brush *brush = add_brush(name); + Brush *brush = BKE_brush_add(name); id_us_min(&brush->id); return brush; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index eb3c1c75cf4..d9f5ca1f9ed 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1370,7 +1370,7 @@ static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value) UnifiedPaintSettings* ups = ptr->data; /* scale unprojected radius so it stays consistent with brush size */ - brush_scale_unprojected_radius(&ups->unprojected_radius, + BKE_brush_scale_unprojected_radius(&ups->unprojected_radius, value, ups->size); ups->size = value; } @@ -1380,7 +1380,7 @@ static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, flo UnifiedPaintSettings* ups = ptr->data; /* scale brush size so it stays consistent with unprojected_radius */ - brush_scale_size(&ups->size, value, ups->unprojected_radius); + BKE_brush_scale_size(&ups->size, value, ups->unprojected_radius); ups->unprojected_radius = value; } diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 4f8fd83491f..ef8cf24987c 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -199,8 +199,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, free_uci= 1; } else { - float sensor= camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); - int sensor_fit= camera_sensor_fit(cam->sensor_fit, aspx, aspy); + float sensor= BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); + int sensor_fit= BKE_camera_sensor_fit(cam->sensor_fit, aspx, aspy); float scale= (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale; float xmax, xmin, ymax, ymin; diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index fc6e6847f34..72dec01066e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -261,7 +261,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, if (camob && camob->type==OB_CAMERA) { Camera* cam = (Camera*)camob->data; cam_lens = cam->lens; - cam_fdist = object_camera_dof_distance(camob); + cam_fdist = BKE_camera_object_dof_distance(camob); if (cam_fdist==0.0f) cam_fdist = 1e10f; /* if the dof is 0.0 then set it be be far away */ cam_invfdist = 1.f/cam_fdist; } diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 56aadfd63d0..e712950f4f8 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -463,7 +463,7 @@ static void re_camera_params_get(Render *re, CameraParams *params, Object *cam_o re->viewdy= params->viewdy; re->viewplane= params->viewplane; - object_camera_mode(&re->r, cam_ob); + BKE_camera_object_mode(&re->r, cam_ob); } void RE_SetEnvmapCamera(Render *re, Object *cam_ob, float viewscale, float clipsta, float clipend) @@ -471,8 +471,8 @@ void RE_SetEnvmapCamera(Render *re, Object *cam_ob, float viewscale, float clips CameraParams params; /* setup parameters */ - camera_params_init(¶ms); - camera_params_from_object(¶ms, cam_ob); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, cam_ob); params.lens= 16.0f*viewscale; params.sensor_x= 32.0f; @@ -482,8 +482,8 @@ void RE_SetEnvmapCamera(Render *re, Object *cam_ob, float viewscale, float clips params.clipend= clipend; /* compute matrix, viewplane, .. */ - camera_params_compute_viewplane(¶ms, re->winx, re->winy, 1.0f, 1.0f); - camera_params_compute_matrix(¶ms); + BKE_camera_params_compute_viewplane(¶ms, re->winx, re->winy, 1.0f, 1.0f); + BKE_camera_params_compute_matrix(¶ms); /* extract results */ re_camera_params_get(re, ¶ms, cam_ob); @@ -496,16 +496,16 @@ void RE_SetCamera(Render *re, Object *cam_ob) CameraParams params; /* setup parameters */ - camera_params_init(¶ms); - camera_params_from_object(¶ms, cam_ob); + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, cam_ob); params.use_fields= (re->r.mode & R_FIELDS); params.field_second= (re->flag & R_SEC_FIELD); params.field_odd= (re->r.mode & R_ODDFIELD); /* compute matrix, viewplane, .. */ - camera_params_compute_viewplane(¶ms, re->winx, re->winy, re->r.xasp, re->r.yasp); - camera_params_compute_matrix(¶ms); + BKE_camera_params_compute_viewplane(¶ms, re->winx, re->winy, re->r.xasp, re->r.yasp); + BKE_camera_params_compute_matrix(¶ms); /* extract results */ re_camera_params_get(re, ¶ms, cam_ob); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 9ca2337e27f..f0fea072530 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1872,7 +1872,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r } /* get panorama & ortho, only after camera is set */ - object_camera_mode(&scene->r, camera_override ? camera_override : scene->camera); + BKE_camera_object_mode(&scene->r, camera_override ? camera_override : scene->camera); /* forbidden combinations */ if (scene->r.mode & R_PANORAMA) { diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index e7c97574629..ff715eeca07 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -177,7 +177,7 @@ static float get_avg_surrounds(float *cache, int *res, int xx, int yy, int zz) for (x=-1; x <= 1; x++) { x_ = xx+x; if (x_ >= 0 && x_ <= res[0]-1) { - const int i= BLI_VEXEL_INDEX(x_, y_, z_, res); + const int i = BLI_VOXEL_INDEX(x_, y_, z_, res); if (cache[i] > 0.0f) { tot += cache[i]; @@ -208,7 +208,7 @@ static void lightcache_filter(VolumePrecache *vp) for (y=0; y < vp->res[1]; y++) { for (x=0; x < vp->res[0]; x++) { /* trigger for outside mesh */ - const int i= BLI_VEXEL_INDEX(x, y, z, vp->res); + const int i = BLI_VOXEL_INDEX(x, y, z, vp->res); if (vp->data_r[i] < -0.f) vp->data_r[i] = get_avg_surrounds(vp->data_r, vp->res, x, y, z); @@ -240,7 +240,7 @@ static void lightcache_filter2(VolumePrecache *vp) for (y=0; y < vp->res[1]; y++) { for (x=0; x < vp->res[0]; x++) { /* trigger for outside mesh */ - const int i= BLI_VEXEL_INDEX(x, y, z, vp->res); + const int i = BLI_VOXEL_INDEX(x, y, z, vp->res); if (vp->data_r[i] < -0.f) new_r[i] = get_avg_surrounds(vp->data_r, vp->res, x, y, z); if (vp->data_g[i] < -0.f) @@ -291,7 +291,7 @@ static float total_ss_energy(Render *re, int do_test_break, VolumePrecache *vp) for (z=0; z < res[2]; z++) { for (y=0; y < res[1]; y++) { for (x=0; x < res[0]; x++) { - const int i=BLI_VEXEL_INDEX(x, y, z, res); + const int i = BLI_VOXEL_INDEX(x, y, z, res); if (vp->data_r[i] > 0.f) energy += vp->data_r[i]; if (vp->data_g[i] > 0.f) energy += vp->data_g[i]; @@ -527,7 +527,7 @@ static void *vol_precache_part(void *data) /* convert from world->camera space for shading */ mul_v3_m4v3(cco, pa->viewmat, co); - i= BLI_VEXEL_INDEX(x, y, z, res); + i = BLI_VOXEL_INDEX(x, y, z, res); // don't bother if the point is not inside the volume mesh if (!point_inside_obi(tree, obi, cco)) { diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 5135061bc5c..90e6594d888 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -184,7 +184,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) for (y=0; y < ibuf->y; y++) { for (x=0; x < ibuf->x; x++) { /* currently averaged to monchrome */ - vd->dataset[ BLI_VEXEL_INDEX(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2]) * 0.333f; + vd->dataset[ BLI_VOXEL_INDEX(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2]) * 0.333f; rf +=4; } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index cc4cf030988..db0429d33ab 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2987,7 +2987,7 @@ static void radial_control_set_tex(RadialControl *rc) switch (RNA_type_to_ID_code(rc->image_id_ptr.type)) { case ID_BR: - if ((ibuf = brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) { + if ((ibuf = BKE_brush_gen_radial_control_imbuf(rc->image_id_ptr.data))) { glGenTextures(1, &rc->gltex); glBindTexture(GL_TEXTURE_2D, rc->gltex); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, ibuf->x, ibuf->y, 0, From 3b4c9f50415ac87b8c5a1d8e4503b056ed17314e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 5 May 2012 05:23:28 +0000 Subject: [PATCH 71/88] Mango Bugfix - Actions being tweaked in NLA Editor were not being played back if the track that they belonged to was currently being played back "solo" --- source/blender/blenkernel/intern/anim_sys.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index f3a7ff90373..78584333367 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -2035,8 +2035,10 @@ static void animsys_evaluate_nla (ListBase *echannels, PointerRNA *ptr, AnimData /* add 'active' Action (may be tweaking track) as last strip to evaluate in NLA stack * - only do this if we're not exclusively evaluating the 'solo' NLA-track + * - however, if the 'solo' track houses the current 'tweaking' strip, + * then we should allow this to play, otherwise nothing happens */ - if ((adt->action) && !(adt->flag & ADT_NLA_SOLO_TRACK)) { + if ((adt->action) && ((adt->flag & ADT_NLA_SOLO_TRACK)==0 || (adt->flag & ADT_NLA_EDIT_ON))) { /* if there are strips, evaluate action as per NLA rules */ if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ From f1e3c31d4ffa86b695fddd45d9ccc6ce9ac62ea7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 5 May 2012 05:46:45 +0000 Subject: [PATCH 72/88] Style Cleanup: Wrapping with parens for safety and whitespace edits --- source/blender/makesrna/RNA_types.h | 54 +++++++++++----------- source/blender/modifiers/intern/MOD_mask.c | 10 ++-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index c3beffbe223..47b25720373 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -147,49 +147,49 @@ typedef enum PropertyFlag { /* editable means the property is editable in the user * interface, properties are editable by default except * for pointers and collections. */ - PROP_EDITABLE = 1<<0, + PROP_EDITABLE = (1<<0), /* this property is editable even if it is lib linked, * meaning it will get lost on reload, but it's useful * for editing. */ - PROP_LIB_EXCEPTION = 1<<16, + PROP_LIB_EXCEPTION = (1<<16), /* animatable means the property can be driven by some * other input, be it animation curves, expressions, .. * properties are animatable by default except for pointers * and collections */ - PROP_ANIMATABLE = 1<<1, + PROP_ANIMATABLE = (1<<1), /* icon */ - PROP_ICONS_CONSECUTIVE = 1<<12, + PROP_ICONS_CONSECUTIVE = (1<<12), /* hidden in the user interface */ - PROP_HIDDEN = 1<<19, + PROP_HIDDEN = (1<<19), /* do not write in presets */ - PROP_SKIP_SAVE = 1<<28, + PROP_SKIP_SAVE = (1<<28), /* function paramater flags */ - PROP_REQUIRED = 1<<2, - PROP_OUTPUT = 1<<3, - PROP_RNAPTR = 1<<11, + PROP_REQUIRED = (1<<2), + PROP_OUTPUT = (1<<3), + PROP_RNAPTR = (1<<11), /* registering */ - PROP_REGISTER = 1<<4, + PROP_REGISTER = (1<<4), PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5), /* pointers */ - PROP_ID_REFCOUNT = 1<<6, + PROP_ID_REFCOUNT = (1<<6), /* disallow assigning a variable to its self, eg an object tracking its self * only apply this to types that are derived from an ID ()*/ - PROP_ID_SELF_CHECK = 1<<20, + PROP_ID_SELF_CHECK = (1<<20), /* use for... * - pointers: in the UI and python so unsetting or setting to None won't work * - strings: so our internal generated get/length/set functions know to do NULL checks before access [#30865] */ - PROP_NEVER_NULL = 1<<18, + PROP_NEVER_NULL = (1<<18), /* currently only used for UI, this is similar to PROP_NEVER_NULL * except that the value may be NULL at times, used for ObData, where an Empty's will be NULL * but setting NULL on a mesh object is not possible. So, if its not NULL, setting NULL cant be done! */ - PROP_NEVER_UNLINK = 1<<25, + PROP_NEVER_UNLINK = (1<<25), /* flag contains multiple enums. * note: not to be confused with prop->enumbitflags @@ -197,32 +197,32 @@ typedef enum PropertyFlag { * * note: these can't be animated so use with care. */ - PROP_ENUM_FLAG = 1<<21, + PROP_ENUM_FLAG = (1<<21), /* need context for update function */ - PROP_CONTEXT_UPDATE = 1<<22, + PROP_CONTEXT_UPDATE = (1<<22), PROP_CONTEXT_PROPERTY_UPDATE = (1<<22)|(1<<27), /* Use for arrays or for any data that should not have a referene kept * most common case is functions that return arrays where the array */ - PROP_THICK_WRAP = 1<<23, + PROP_THICK_WRAP = (1<<23), /* Reject values outside limits, use for python api only so far * this is for use when silently clamping string length will give * bad behavior later. Could also enforce this for INT's and other types. * note: currently no support for function arguments or non utf8 paths (filepaths) */ - PROP_NEVER_CLAMP = 1<<26, + PROP_NEVER_CLAMP = (1<<26), /* internal flags */ - PROP_BUILTIN = 1<<7, - PROP_EXPORT = 1<<8, - PROP_RUNTIME = 1<<9, - PROP_IDPROPERTY = 1<<10, - PROP_RAW_ACCESS = 1<<13, - PROP_RAW_ARRAY = 1<<14, - PROP_FREE_POINTERS = 1<<15, - PROP_DYNAMIC = 1<<17, /* for dynamic arrays, and retvals of type string */ - PROP_ENUM_NO_CONTEXT = 1<<24 /* for enum that shouldn't be contextual */ + PROP_BUILTIN = (1<<7), + PROP_EXPORT = (1<<8), + PROP_RUNTIME = (1<<9), + PROP_IDPROPERTY = (1<<10), + PROP_RAW_ACCESS = (1<<13), + PROP_RAW_ARRAY = (1<<14), + PROP_FREE_POINTERS = (1<<15), + PROP_DYNAMIC = (1<<17), /* for dynamic arrays, and retvals of type string */ + PROP_ENUM_NO_CONTEXT = (1<<24) /* for enum that shouldn't be contextual */ } PropertyFlag; typedef struct CollectionPropertyIterator { diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index a8f5f008e0c..9faca7bddc5 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -146,13 +146,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, char *bone_select_array; int bone_select_tot= 0; const int defbase_tot= BLI_countlist(&ob->defbase); - + /* check that there is armature object with bones to use, otherwise return original mesh */ if (ELEM3(NULL, mmd->ob_arm, mmd->ob_arm->pose, ob->defbase.first)) return derivedData; - + bone_select_array= MEM_mallocN(defbase_tot * sizeof(char), "mask array"); - + for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { pchan = get_pose_channel(oba->pose, def->name); if (pchan && pchan->bone && (pchan->bone->flag & BONE_SELECTED)) { @@ -198,7 +198,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { MDeformWeight *dw= dv->dw; int j; - + for (j= dv->totweight; j > 0; j--, dw++) { if (dw->def_nr < defbase_tot) { if (bone_select_array[dw->def_nr]) { @@ -291,7 +291,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MLoop *ml = mloop + mp->loopstart; int ok = TRUE; int j; - + for (j = 0; j < mp->totloop; j++, ml++) { if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(ml->v))) { ok = FALSE; From aa9c9173b173923776d339497231874357c146a3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 May 2012 09:30:57 +0000 Subject: [PATCH 73/88] Fix #31302: UV unwrap no longer remember last conformal/angle based unwrapper choice with bmesh. --- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 14c8420a8f5..f9db8b5423b 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1178,7 +1178,8 @@ static int unwrap_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh."); /* remember last method for live unwrap */ - scene->toolsettings->unwrapper = method; + if(RNA_struct_property_is_set(op->ptr, "method")) + scene->toolsettings->unwrapper = method; scene->toolsettings->uv_subsurf_level = subsurf_level; From a30dec8e5968ae6568184cfdc2e1a69bad0e39d6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 May 2012 10:17:18 +0000 Subject: [PATCH 74/88] Fix related to #31317: viewport render layer rendering now uses render visibility rather than viewport visibility, is more useful that way. --- intern/cycles/blender/blender_object.cpp | 2 +- intern/cycles/blender/blender_sync.cpp | 2 ++ intern/cycles/blender/blender_sync.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index bbf48050222..16b46aa2e2c 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -286,7 +286,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) BL::Scene::objects_iterator b_ob; for(b_scene.objects.begin(b_ob); b_ob != b_scene.objects.end(); ++b_ob) { - bool hide = (b_v3d)? b_ob->hide(): b_ob->hide_render(); + bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render(); uint ob_layer = get_layer(b_ob->layers()); if(!hide && (ob_layer & scene_layer)) { diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 24cf10bc028..7eccf52579d 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -215,6 +215,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) render_layer.holdout_layer = 0; render_layer.material_override = PointerRNA_NULL; render_layer.use_background = true; + render_layer.use_viewport_visibility = true; render_layer.samples = 0; return; } @@ -234,6 +235,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) render_layer.layer |= render_layer.holdout_layer; render_layer.material_override = b_rlay->material_override(); render_layer.use_background = b_rlay->use_sky(); + render_layer.use_viewport_visibility = false; render_layer.samples = b_rlay->samples(); } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index d6a7218f74f..904cc1b1831 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -113,6 +113,7 @@ private: : scene_layer(0), layer(0), holdout_layer(0), material_override(PointerRNA_NULL), use_background(true), + use_viewport_visibility(false), samples(0) {} @@ -122,6 +123,7 @@ private: uint holdout_layer; BL::Material material_override; bool use_background; + bool use_viewport_visibility; int samples; } render_layer; }; From a731e130432a98ab8228112027cd3eaa8ed700b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 14:03:12 +0000 Subject: [PATCH 75/88] code cleanup: function naming, use BKE_*type* prefix. --- source/blender/blenkernel/BKE_action.h | 6 +- source/blender/blenkernel/BKE_armature.h | 6 +- source/blender/blenkernel/BKE_font.h | 2 +- source/blender/blenkernel/BKE_gpencil.h | 2 +- source/blender/blenkernel/BKE_group.h | 6 +- source/blender/blenkernel/BKE_image.h | 4 +- source/blender/blenkernel/BKE_ipo.h | 2 +- source/blender/blenkernel/BKE_key.h | 6 +- source/blender/blenkernel/BKE_lamp.h | 4 +- source/blender/blenkernel/BKE_lattice.h | 6 +- source/blender/blenkernel/BKE_library.h | 11 +- source/blender/blenkernel/BKE_material.h | 4 +- source/blender/blenkernel/BKE_mesh.h | 6 +- source/blender/blenkernel/BKE_object.h | 125 +++++---- source/blender/blenkernel/BKE_particle.h | 6 +- source/blender/blenkernel/BKE_scene.h | 5 +- source/blender/blenkernel/BKE_screen.h | 2 +- source/blender/blenkernel/BKE_sound.h | 2 +- source/blender/blenkernel/BKE_speaker.h | 4 +- source/blender/blenkernel/BKE_text.h | 6 +- source/blender/blenkernel/BKE_texture.h | 4 +- source/blender/blenkernel/BKE_world.h | 6 +- .../blender/blenkernel/intern/DerivedMesh.c | 4 +- source/blender/blenkernel/intern/action.c | 20 +- source/blender/blenkernel/intern/anim.c | 12 +- source/blender/blenkernel/intern/anim_sys.c | 18 +- source/blender/blenkernel/intern/armature.c | 22 +- source/blender/blenkernel/intern/brush.c | 6 +- source/blender/blenkernel/intern/camera.c | 4 +- source/blender/blenkernel/intern/constraint.c | 12 +- source/blender/blenkernel/intern/curve.c | 10 +- source/blender/blenkernel/intern/depsgraph.c | 4 +- source/blender/blenkernel/intern/displist.c | 2 +- .../blender/blenkernel/intern/dynamicpaint.c | 4 +- source/blender/blenkernel/intern/effect.c | 4 +- source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/font.c | 4 +- source/blender/blenkernel/intern/gpencil.c | 4 +- source/blender/blenkernel/intern/group.c | 14 +- source/blender/blenkernel/intern/image.c | 10 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/key.c | 10 +- source/blender/blenkernel/intern/lamp.c | 12 +- source/blender/blenkernel/intern/lattice.c | 14 +- source/blender/blenkernel/intern/library.c | 160 +++++------ source/blender/blenkernel/intern/material.c | 14 +- source/blender/blenkernel/intern/mball.c | 6 +- source/blender/blenkernel/intern/mesh.c | 20 +- source/blender/blenkernel/intern/movieclip.c | 2 +- source/blender/blenkernel/intern/multires.c | 6 +- source/blender/blenkernel/intern/node.c | 8 +- source/blender/blenkernel/intern/object.c | 262 ++++++++---------- source/blender/blenkernel/intern/particle.c | 12 +- .../blenkernel/intern/particle_system.c | 4 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/scene.c | 33 ++- source/blender/blenkernel/intern/screen.c | 2 +- source/blender/blenkernel/intern/sound.c | 18 +- source/blender/blenkernel/intern/speaker.c | 10 +- source/blender/blenkernel/intern/text.c | 12 +- source/blender/blenkernel/intern/texture.c | 14 +- source/blender/blenkernel/intern/tracking.c | 2 +- source/blender/blenkernel/intern/world.c | 16 +- source/blender/blenloader/intern/readfile.c | 6 +- source/blender/bmesh/operators/bmo_dupe.c | 4 +- source/blender/collada/AnimationImporter.cpp | 4 +- source/blender/collada/DocumentImporter.cpp | 10 +- source/blender/collada/MeshImporter.cpp | 2 +- source/blender/collada/SkinInfo.cpp | 4 +- source/blender/collada/TransformWriter.cpp | 2 +- source/blender/collada/collada_utils.cpp | 10 +- .../blender/editors/armature/editarmature.c | 22 +- source/blender/editors/armature/poseSlide.c | 4 +- source/blender/editors/armature/poselib.c | 4 +- source/blender/editors/armature/poseobject.c | 46 +-- source/blender/editors/curve/editfont.c | 4 +- source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/gpencil/gpencil_undo.c | 4 +- .../editors/interface/interface_templates.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/mesh/editmesh_utils.c | 4 +- source/blender/editors/mesh/meshtools.c | 6 +- source/blender/editors/object/object_add.c | 56 ++-- .../editors/object/object_constraint.c | 24 +- source/blender/editors/object/object_edit.c | 8 +- source/blender/editors/object/object_hook.c | 6 +- .../blender/editors/object/object_modifier.c | 4 +- .../blender/editors/object/object_relations.c | 48 ++-- .../blender/editors/object/object_shapekey.c | 4 +- .../blender/editors/object/object_transform.c | 30 +- .../blender/editors/physics/particle_edit.c | 2 +- .../blender/editors/physics/particle_object.c | 2 +- .../blender/editors/physics/physics_fluid.c | 2 +- .../blender/editors/render/render_preview.c | 10 +- .../blender/editors/render/render_shading.c | 6 +- .../blender/editors/screen/screen_context.c | 8 +- source/blender/editors/screen/screen_edit.c | 10 +- source/blender/editors/screen/screen_ops.c | 2 +- .../editors/sculpt_paint/paint_image.c | 2 +- .../editors/sculpt_paint/paint_vertex.c | 2 +- .../editors/space_action/action_edit.c | 2 +- .../blender/editors/space_clip/tracking_ops.c | 22 +- .../editors/space_logic/logic_window.c | 8 +- .../blender/editors/space_logic/space_logic.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 2 +- .../editors/space_outliner/outliner_tools.c | 2 +- .../editors/space_sequencer/space_sequencer.c | 2 +- source/blender/editors/space_text/text_ops.c | 4 +- .../blender/editors/space_view3d/drawobject.c | 6 +- .../editors/space_view3d/space_view3d.c | 2 +- .../editors/space_view3d/view3d_draw.c | 14 +- .../editors/space_view3d/view3d_edit.c | 18 +- .../blender/editors/space_view3d/view3d_fly.c | 12 +- .../editors/space_view3d/view3d_select.c | 2 +- .../editors/space_view3d/view3d_snap.c | 6 +- .../editors/space_view3d/view3d_view.c | 16 +- .../editors/transform/transform_conversions.c | 14 +- .../editors/transform/transform_snap.c | 12 +- source/blender/gpu/intern/gpu_draw.c | 2 +- source/blender/makesdna/DNA_curve_types.h | 2 +- source/blender/makesdna/DNA_particle_types.h | 2 +- source/blender/makesdna/DNA_scene_types.h | 2 +- source/blender/makesrna/intern/rna_main_api.c | 52 ++-- source/blender/makesrna/intern/rna_object.c | 14 +- .../blender/makesrna/intern/rna_object_api.c | 16 +- source/blender/makesrna/intern/rna_scene.c | 2 +- source/blender/modifiers/intern/MOD_array.c | 2 +- .../modifiers/intern/MOD_boolean_util.c | 2 +- .../modifiers/intern/MOD_particlesystem.c | 2 +- .../nodes/composite/node_composite_tree.c | 2 +- source/blender/nodes/intern/node_common.c | 6 +- .../nodes/shader/nodes/node_shader_dynamic.c | 6 +- .../render/intern/source/convertblender.c | 2 +- .../render/intern/source/render_texture.c | 4 +- source/blender/windowmanager/intern/wm.c | 2 +- .../blender/windowmanager/intern/wm_window.c | 2 +- .../gameengine/Converter/BL_ShapeDeformer.cpp | 6 +- .../Converter/KX_BlenderSceneConverter.cpp | 8 +- 138 files changed, 837 insertions(+), 835 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 564cd235869..b9d7fb88a22 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -59,13 +59,13 @@ extern "C" { struct bAction *add_empty_action(const char name[]); /* Allocate a copy of the given Action and all its data */ -struct bAction *copy_action(struct bAction *src); +struct bAction *BKE_action_copy(struct bAction *src); /* Deallocate all of the Action's data, but not the Action itself */ -void free_action(struct bAction *act); +void BKE_action_free(struct bAction *act); // XXX is this needed? -void make_local_action(struct bAction *act); +void BKE_action_make_local(struct bAction *act); /* Action API ----------------- */ diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index dfe3fde17eb..72d452150a1 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -78,9 +78,9 @@ extern "C" { struct bArmature *add_armature(const char *name); struct bArmature *get_armature(struct Object *ob); void free_bonelist (struct ListBase *lb); -void free_armature(struct bArmature *arm); -void make_local_armature(struct bArmature *arm); -struct bArmature *copy_armature(struct bArmature *arm); +void BKE_armature_free(struct bArmature *arm); +void BKE_armature_make_local(struct bArmature *arm); +struct bArmature *BKE_armature_copy(struct bArmature *arm); /* Bounding box. */ struct BoundBox *BKE_armature_get_bb(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 16e98f25e0c..640a70a8e87 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -73,7 +73,7 @@ typedef struct EditFont { void BKE_font_register_builtin(void *mem, int size); -void free_vfont(struct VFont *sc); +void BKE_vfont_free(struct VFont *sc); void free_ttfont(void); struct VFont *get_builtin_font(void); struct VFont *load_vfont(struct Main *bmain, const char *name); diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index bb0216fe11c..134ec1acd8e 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -41,7 +41,7 @@ struct bGPDframe; void free_gpencil_strokes(struct bGPDframe *gpf); void free_gpencil_frames(struct bGPDlayer *gpl); void free_gpencil_layers(struct ListBase *list); -void free_gpencil_data(struct bGPdata *gpd); +void BKE_gpencil_free(struct bGPdata *gpd); struct bGPDframe *gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe); struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd); diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index 6629f0bdf7f..ccf9e0cef5b 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -40,10 +40,10 @@ struct Object; struct bAction; struct Scene; -void free_group_objects(struct Group *group); -void unlink_group(struct Group *group); +void BKE_group_free(struct Group *group); +void BKE_group_unlink(struct Group *group); struct Group *add_group(const char *name); -struct Group *copy_group(struct Group *group); +struct Group *BKE_group_copy(struct Group *group); int add_to_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base); int rem_from_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base); struct Group *find_group(struct Object *ob, struct Group *group); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index c2112d1e169..637b57af0bc 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -46,7 +46,7 @@ struct Object; struct ImageFormatData; /* call from library */ -void free_image(struct Image *me); +void BKE_image_free(struct Image *me); void BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels); @@ -176,7 +176,7 @@ void BKE_image_memorypack(struct Image *ima); void BKE_image_print_memlist(void); /* empty image block, of similar type and filename */ -struct Image *copy_image(struct Image *ima); +struct Image *BKE_image_copy(struct Image *ima); /* merge source into dest, and free source */ void BKE_image_merge(struct Image *dest, struct Image *source); diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h index 547e7de7634..ca86e90f192 100644 --- a/source/blender/blenkernel/BKE_ipo.h +++ b/source/blender/blenkernel/BKE_ipo.h @@ -45,7 +45,7 @@ void do_versions_ipos_to_animato(struct Main *main); /* --------------------- xxx stuff ------------------------ */ -void free_ipo(struct Ipo *ipo); +void BKE_ipo_free(struct Ipo *ipo); #ifdef __cplusplus }; diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 63d9d731097..757952515e5 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -47,12 +47,12 @@ struct Mesh; extern "C" { #endif -void free_key(struct Key *sc); +void BKE_key_free(struct Key *sc); void free_key_nolib(struct Key *key); struct Key *add_key(struct ID *id); -struct Key *copy_key(struct Key *key); +struct Key *BKE_key_copy(struct Key *key); struct Key *copy_key_nolib(struct Key *key); -void make_local_key(struct Key *key); +void BKE_key_make_local(struct Key *key); void sort_keys(struct Key *key); void key_curve_position_weights(float t, float *data, int type); diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h index 50e25576320..fd19794085d 100644 --- a/source/blender/blenkernel/BKE_lamp.h +++ b/source/blender/blenkernel/BKE_lamp.h @@ -39,10 +39,10 @@ extern "C" { struct Lamp; void *add_lamp(const char *name); -struct Lamp *copy_lamp(struct Lamp *la); +struct Lamp *BKE_lamp_copy(struct Lamp *la); struct Lamp *localize_lamp(struct Lamp *la); void make_local_lamp(struct Lamp *la); -void free_lamp(struct Lamp *la); +void BKE_lamp_free(struct Lamp *la); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index a0075c4d6be..251f02fecd7 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -43,9 +43,9 @@ struct MDeformVert; void resizelattice(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); struct Lattice *add_lattice(const char *name); -struct Lattice *copy_lattice(struct Lattice *lt); -void free_lattice(struct Lattice *lt); -void make_local_lattice(struct Lattice *lt); +struct Lattice *BKE_lattice_copy(struct Lattice *lt); +void BKE_lattice_free(struct Lattice *lt); +void BKE_lattice_make_local(struct Lattice *lt); void calc_lat_fudu(int flag, int res, float *fu, float *du); void init_latt_deform(struct Object *oblatt, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index be21996428a..8a93366ea9a 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -45,15 +45,16 @@ struct bContext; struct PointerRNA; struct PropertyRNA; -void *alloc_libblock(struct ListBase *lb, short type, const char *name); -void *copy_libblock(struct ID *id); -void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action); +void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name); +void *BKE_libblock_copy(struct ID *id); +void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const short do_action); void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id); void id_lib_extern(struct ID *id); void BKE_library_filepath_set(struct Library *lib, const char *filepath); void id_us_plus(struct ID *id); void id_us_min(struct ID *id); + int id_make_local(struct ID *id, int test); int id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop); int id_copy(struct ID *id, struct ID **newid, int test); @@ -68,8 +69,8 @@ struct ListBase *which_libbase(struct Main *mainlib, short type); #define MAX_LIBARRAY 40 int set_listbasepointers(struct Main *main, struct ListBase **lb); -void free_libblock(struct ListBase *lb, void *idv); -void free_libblock_us(struct ListBase *lb, void *idv); +void BKE_libblock_free(struct ListBase *lb, void *idv); +void BKE_libblock_free_us(struct ListBase *lb, void *idv); void free_main(struct Main *mainvar); void tag_main_idcode(struct Main *mainvar, const short type, const short tag); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 99561a687b9..32570311d02 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -46,12 +46,12 @@ struct MTFace; /* materials */ void init_def_material(void); -void free_material(struct Material *sc); +void BKE_material_free(struct Material *sc); void test_object_materials(struct ID *id); void resize_object_material(struct Object *ob, const short totcol); void init_material(struct Material *ma); struct Material *add_material(const char *name); -struct Material *copy_material(struct Material *ma); +struct Material *BKE_material_copy(struct Material *ma); struct Material *localize_material(struct Material *ma); struct Material *give_node_material(struct Material *ma); /* returns node material or self */ void make_local_material(struct Material *ma); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 14cb5d19ddf..34289a2ae4d 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -119,12 +119,12 @@ void mesh_flush_hidden_from_verts(const struct MVert *mvert, struct MPoly *mpoly, int totpoly); void unlink_mesh(struct Mesh *me); -void free_mesh(struct Mesh *me, int unlink); +void BKE_mesh_free(struct Mesh *me, int unlink); struct Mesh *add_mesh(const char *name); -struct Mesh *copy_mesh(struct Mesh *me); +struct Mesh *BKE_mesh_copy(struct Mesh *me); void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess_cd); -void make_local_mesh(struct Mesh *me); +void BKE_mesh_make_local(struct Mesh *me); void boundbox_mesh(struct Mesh *me, float *loc, float *size); void tex_space_mesh(struct Mesh *me); float *get_mesh_orco_verts(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 2e334c4abc9..92a447f9351 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -50,65 +50,66 @@ struct RenderData; struct rctf; struct MovieClip; -void clear_workob(struct Object *workob); -void what_does_parent(struct Scene *scene, struct Object *ob, struct Object *workob); +void BKE_object_workob_clear(struct Object *workob); +void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob); -void copy_baseflags(struct Scene *scene); -void copy_objectflags(struct Scene *scene); struct SoftBody *copy_softbody(struct SoftBody *sb); struct BulletSoftBody *copy_bulletsoftbody(struct BulletSoftBody *sb); -void copy_object_particlesystems(struct Object *obn, struct Object *ob); -void copy_object_softbody(struct Object *obn, struct Object *ob); -void object_free_particlesystems(struct Object *ob); -void object_free_softbody(struct Object *ob); -void object_free_bulletsoftbody(struct Object *ob); -void update_base_layer(struct Scene *scene, struct Object *ob); +void BKE_object_copy_particlesystems(struct Object *obn, struct Object *ob); +void BKE_object_copy_softbody(struct Object *obn, struct Object *ob); +void BKE_object_free_particlesystems(struct Object *ob); +void BKE_object_free_softbody(struct Object *ob); +void BKE_object_free_bulletsoftbody(struct Object *ob); +void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob); -void free_object(struct Object *ob); -void object_free_display(struct Object *ob); +void BKE_object_free(struct Object *ob); +void BKE_object_free_display(struct Object *ob); -int object_support_modifier_type(struct Object *ob, int modifier_type); +int BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type); -void object_link_modifiers(struct Object *ob, struct Object *from); -void object_free_modifiers(struct Object *ob); +void BKE_object_link_modifiers(struct Object *ob, struct Object *from); +void BKE_object_free_modifiers(struct Object *ob); -void object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); -void object_copy_proxy_drivers(struct Object *ob, struct Object *target); +void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); +void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target); -void unlink_object(struct Object *ob); -int exist_object(struct Object *obtest); +void BKE_object_unlink(struct Object *ob); +int BKE_object_exists_check(struct Object *obtest); -struct Object *add_only_object(int type, const char *name); -struct Object *add_object(struct Scene *scene, int type); -void *add_obdata_from_type(int type); +struct Object *BKE_object_add_only_object(int type, const char *name); +struct Object *BKE_object_add(struct Scene *scene, int type); +void *BKE_object_obdata_add_from_type(int type); -struct Object *copy_object(struct Object *ob); -void make_local_object(struct Object *ob); -int object_is_libdata(struct Object *ob); -int object_data_is_libdata(struct Object *ob); +struct Object *BKE_object_copy(struct Object *ob); +void BKE_object_make_local(struct Object *ob); +int BKE_object_is_libdata(struct Object *ob); +int BKE_object_obdata_is_libdata(struct Object *ob); -void object_scale_to_mat3(struct Object *ob, float mat[][3]); -void object_rot_to_mat3(struct Object *ob, float mat[][3]); -void object_mat3_to_rot(struct Object *ob, float mat[][3], short use_compat); -void object_to_mat3(struct Object *ob, float mat[][3]); -void object_to_mat4(struct Object *ob, float mat[][4]); -void object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent); +void BKE_object_scale_to_mat3(struct Object *ob, float mat[][3]); +void BKE_object_rot_to_mat3(struct Object *ob, float mat[][3]); +void BKE_object_mat3_to_rot(struct Object *ob, float mat[][3], short use_compat); +void BKE_object_to_mat3(struct Object *ob, float mat[][3]); +void BKE_object_to_mat4(struct Object *ob, float mat[][4]); +void BKE_object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent); -struct Object *object_pose_armature_get(struct Object *ob); +struct Object *BKE_object_pose_armature_get(struct Object *ob); -void where_is_object_time(struct Scene *scene, struct Object *ob, float ctime); -void where_is_object(struct Scene *scene, struct Object *ob); -void where_is_object_simul(struct Scene *scene, struct Object *ob); -void where_is_object_mat(struct Scene *scene, struct Object *ob, float obmat[4][4]); +void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob); +void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime); +void BKE_object_where_is_calc_simul(struct Scene *scene, struct Object *ob); +void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]); -struct BoundBox *unit_boundbox(void); -void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]); -struct BoundBox *object_get_boundbox(struct Object *ob); -void object_get_dimensions(struct Object *ob, float vec[3]); -void object_set_dimensions(struct Object *ob, const float *value); -void object_boundbox_flag(struct Object *ob, int flag, int set); -void minmax_object(struct Object *ob, float min[3], float max[3]); -int minmax_object_duplis(struct Scene *scene, struct Object *ob, float min[3], float max[3]); +/* possibly belong in own moduke? */ +struct BoundBox *BKE_boundbox_alloc_unit(void); +void BKE_boundbox_init_from_minmax(struct BoundBox *bb, float min[3], float max[3]); +int BKE_boundbox_ray_hit_check(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); + +struct BoundBox *BKE_object_boundbox_get(struct Object *ob); +void BKE_object_dimensions_get(struct Object *ob, float vec[3]); +void BKE_object_dimensions_set(struct Object *ob, const float *value); +void BKE_object_boundbox_flag(struct Object *ob, int flag, int set); +void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3]); +int BKE_object_minmax_dupli(struct Scene *scene, struct Object *ob, float r_min[3], float r_max[3]); /* sometimes min-max isn't enough, we need to loop over each point */ void BKE_object_foreach_display_point( @@ -122,10 +123,8 @@ void BKE_scene_foreach_display_point( int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob); -int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); - -void *object_tfm_backup(struct Object *ob); -void object_tfm_restore(struct Object *ob, void *obtfm_pt); +void *BKE_object_tfm_backup(struct Object *ob); +void BKE_object_tfm_restore(struct Object *ob, void *obtfm_pt); typedef struct ObjectTfmProtectedChannels { float loc[3], dloc[3]; @@ -136,28 +135,28 @@ typedef struct ObjectTfmProtectedChannels { float rotAngle, drotAngle; } ObjectTfmProtectedChannels; -void object_tfm_protected_backup(const struct Object *ob, - ObjectTfmProtectedChannels *obtfm); +void BKE_object_tfm_protected_backup(const struct Object *ob, + ObjectTfmProtectedChannels *obtfm); -void object_tfm_protected_restore(struct Object *ob, - const ObjectTfmProtectedChannels *obtfm, - const short protectflag); +void BKE_object_tfm_protected_restore(struct Object *ob, + const ObjectTfmProtectedChannels *obtfm, + const short protectflag); -void object_handle_update(struct Scene *scene, struct Object *ob); -void object_sculpt_modifiers_changed(struct Object *ob); +void BKE_object_handle_update(struct Scene *scene, struct Object *ob); +void BKE_object_sculpt_modifiers_changed(struct Object *ob); -int give_obdata_texspace(struct Object *ob, short **texflag, float **loc, float **size, float **rot); +int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot); -int object_insert_ptcache(struct Object *ob); +int BKE_object_insert_ptcache(struct Object *ob); // void object_delete_ptcache(struct Object *ob, int index); -struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix); +struct KeyBlock *BKE_object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix); -int object_is_modified(struct Scene *scene, struct Object *ob); -int object_is_deform_modified(struct Scene *scene, struct Object *ob); +int BKE_object_is_modified(struct Scene *scene, struct Object *ob); +int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob); -void object_relink(struct Object *ob); +void BKE_object_relink(struct Object *ob); -struct MovieClip *object_get_movieclip(struct Scene *scene, struct Object *ob, int use_default); +struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct Object *ob, int use_default); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 67dba6fd7a7..f776295b912 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -246,7 +246,7 @@ void psys_check_group_weights(struct ParticleSettings *part); int psys_uses_gravity(struct ParticleSimulationData *sim); /* free */ -void psys_free_settings(struct ParticleSettings *part); +void BKE_particlesettings_free(struct ParticleSettings *part); void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit); void psys_free(struct Object * ob, struct ParticleSystem * psys); @@ -266,8 +266,8 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name); void object_remove_particle_system(struct Scene *scene, struct Object *ob); struct ParticleSettings *psys_new_settings(const char *name, struct Main *main); -struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part); -void make_local_particlesettings(struct ParticleSettings *part); +struct ParticleSettings *BKE_particlesettings_copy(struct ParticleSettings *part); +void BKE_particlesettings_make_local(struct ParticleSettings *part); void psys_reset(struct ParticleSystem *psys, int mode); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index e46d99ed873..f2c07fb82e0 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -61,7 +61,7 @@ struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base); void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); -void free_scene(struct Scene *sce); +void BKE_scene_free(struct Scene *sce); struct Scene *add_scene(const char *name); struct Base *object_in_scene(struct Object *ob, struct Scene *sce); @@ -104,6 +104,9 @@ float get_render_aosss_error(struct RenderData *r, float error); int scene_use_new_shading_nodes(struct Scene *scene); +void copy_baseflags(struct Scene *scene); +void copy_objectflags(struct Scene *scene); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index fbb93c761c2..af6e793cf2f 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -252,7 +252,7 @@ float BKE_screen_view3d_zoom_to_fac(float camzoom); float BKE_screen_view3d_zoom_from_fac(float zoomfac); /* screen */ -void free_screen(struct bScreen *sc); +void BKE_screen_free(struct bScreen *sc); unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene); #endif diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 8b01dbde531..5234f10ddb3 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -77,7 +77,7 @@ void sound_delete_cache(struct bSound* sound); void sound_load(struct Main *main, struct bSound* sound); -void sound_free(struct bSound* sound); +void BKE_sound_free(struct bSound* sound); #ifdef __AUD_C_API_H__ AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume); diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h index fddcfb2c7f3..5ff881ee085 100644 --- a/source/blender/blenkernel/BKE_speaker.h +++ b/source/blender/blenkernel/BKE_speaker.h @@ -34,8 +34,8 @@ */ void *add_speaker(const char *name); -struct Speaker *copy_speaker(struct Speaker *spk); +struct Speaker *BKE_speaker_copy(struct Speaker *spk); void make_local_speaker(struct Speaker *spk); -void free_speaker(struct Speaker *spk); +void BKE_speaker_free(struct Speaker *spk); #endif diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 115c00d9e73..4b033557026 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -42,15 +42,15 @@ struct Text; struct TextLine; struct SpaceText; -void free_text (struct Text *text); +void BKE_text_free (struct Text *text); void txt_set_undostate (int u); int txt_get_undostate (void); struct Text* add_empty_text (const char *name); int txt_extended_ascii_as_utf8(char **str); int reopen_text (struct Text *text); struct Text* add_text (const char *file, const char *relpath); -struct Text* copy_text (struct Text *ta); -void unlink_text (struct Main *bmain, struct Text *text); +struct Text* BKE_text_copy (struct Text *ta); +void BKE_text_unlink (struct Main *bmain, struct Text *text); void clear_text(struct Text *text); void write_text(struct Text *text, const char *str); diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 2574c45eec2..aa6f56c5d8f 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -59,7 +59,7 @@ struct World; #define MAXCOLORBAND 32 -void free_texture(struct Tex *t); +void BKE_texture_free(struct Tex *t); int test_dlerr(const char *name, const char *symbol); void open_plugin_tex(struct PluginTex *pit); struct PluginTex *add_plugin_tex(char *str); @@ -79,7 +79,7 @@ void tex_set_type(struct Tex *tex, int type); void default_mtex(struct MTex *mtex); struct MTex *add_mtex(void); struct MTex *add_mtex_id(struct ID *id, int slot); -struct Tex *copy_texture(struct Tex *tex); +struct Tex *BKE_texture_copy(struct Tex *tex); struct Tex *localize_texture(struct Tex *tex); void make_local_texture(struct Tex *tex); void autotexname(struct Tex *tex); diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h index 16ff3acaf71..67896fffc4d 100644 --- a/source/blender/blenkernel/BKE_world.h +++ b/source/blender/blenkernel/BKE_world.h @@ -35,11 +35,11 @@ struct World; -void free_world(struct World *sc); +void BKE_world_free(struct World *sc); struct World *add_world(const char *name); -struct World *copy_world(struct World *wrld); +struct World *BKE_world_copy(struct World *wrld); struct World *localize_world(struct World *wrld); -void make_local_world(struct World *wrld); +void BKE_world_make_local(struct World *wrld); #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index f648a9e297c..db9df4050b0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2111,7 +2111,7 @@ static void clear_mesh_caches(Object *ob) } if (ob->sculpt) { - object_sculpt_modifiers_changed(ob); + BKE_object_sculpt_modifiers_changed(ob); } } @@ -2884,7 +2884,7 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm) if (!ob->bb) ob->bb= MEM_callocN(sizeof(BoundBox), "DM-BoundBox"); - boundbox_set_from_min_max(ob->bb, min, max); + BKE_boundbox_init_from_minmax(ob->bb, min, max); } /* --- NAVMESH (begin) --- */ diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5a2407ca56b..9ed1a2e8956 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -83,14 +83,14 @@ bAction *add_empty_action(const char name[]) { bAction *act; - act= alloc_libblock(&G.main->action, ID_AC, name); + act= BKE_libblock_alloc(&G.main->action, ID_AC, name); return act; } /* .................................. */ -/* temp data for make_local_action */ +/* temp data for BKE_action_make_local */ typedef struct tMakeLocalActionContext { bAction *act; /* original action */ bAction *act_new; /* new action */ @@ -99,7 +99,7 @@ typedef struct tMakeLocalActionContext { int is_local; /* some action users were not libraries */ } tMakeLocalActionContext; -/* helper function for make_local_action() - local/lib init step */ +/* helper function for BKE_action_make_local() - local/lib init step */ static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr) { tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; @@ -110,7 +110,7 @@ static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr) } } -/* helper function for make_local_action() - change references */ +/* helper function for BKE_action_make_local() - change references */ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) { tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; @@ -126,7 +126,7 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) } // does copy_fcurve... -void make_local_action(bAction *act) +void BKE_action_make_local(bAction *act) { tMakeLocalActionContext mlac = {act, NULL, FALSE, FALSE}; Main *bmain= G.main; @@ -146,7 +146,7 @@ void make_local_action(bAction *act) id_clear_lib_data(bmain, &act->id); } else if (mlac.is_local && mlac.is_lib) { - mlac.act_new= copy_action(act); + mlac.act_new= BKE_action_copy(act); mlac.act_new->id.us= 0; BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id); @@ -157,7 +157,7 @@ void make_local_action(bAction *act) /* .................................. */ -void free_action(bAction *act) +void BKE_action_free(bAction *act) { /* sanity check */ if (act == NULL) @@ -177,7 +177,7 @@ void free_action(bAction *act) /* .................................. */ -bAction *copy_action (bAction *src) +bAction *BKE_action_copy (bAction *src) { bAction *dst = NULL; bActionGroup *dgrp, *sgrp; @@ -185,7 +185,7 @@ bAction *copy_action (bAction *src) if (src == NULL) return NULL; - dst= copy_libblock(&src->id); + dst= BKE_libblock_copy(&src->id); /* duplicate the lists of groups and markers */ BLI_duplicatelist(&dst->groups, &src->groups); @@ -1139,7 +1139,7 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c bActionGroup *agrp= action_groups_find_named(act, groupname); /* clear workob */ - clear_workob(workob); + BKE_object_workob_clear(workob); /* init workob */ copy_m4_m4(workob->obmat, ob->obmat); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index afa4723bc6d..353caece2be 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -341,7 +341,7 @@ static void motionpaths_calc_update_scene(Scene *scene) // is animated but not attached to/updatable from objects for (base=scene->base.first; base; base=base->next) { /* update this object */ - object_handle_update(scene, base->object); + BKE_object_handle_update(scene, base->object); /* if this is the last one we need to update, let's stop to save some time */ if (base == last) @@ -816,7 +816,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine! */ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ - where_is_object_time(scene, ob, (float)scene->r.cfra); + BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); copy_m4_m4(dob->omat, copyob.obmat); @@ -831,7 +831,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, scene->r.cfra= cfrao; BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ - where_is_object_time(scene, ob, (float)scene->r.cfra); + BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); /* but, to make sure unkeyed object transforms are still sane, * let's copy object's original data back over @@ -1309,7 +1309,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } /* we also copy the actual objects to restore afterwards, since - * where_is_object_time will change the object which breaks transform */ + * BKE_object_where_is_calc_time will change the object which breaks transform */ oblist = MEM_callocN(totgroup*sizeof(Object *), "dupgroup object list"); obcopylist = MEM_callocN(totgroup*sizeof(Object), "dupgroup copy list"); @@ -1445,7 +1445,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } else { /* to give ipos in object correct offset */ - where_is_object_time(scene, ob, ctime-pa_time); + BKE_object_where_is_calc_time(scene, ob, ctime-pa_time); copy_v3_v3(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; @@ -1486,7 +1486,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } } - /* restore objects since they were changed in where_is_object_time */ + /* restore objects since they were changed in BKE_object_where_is_calc_time */ if (part->ren_as==PART_DRAW_GR) { for (a=0; aaction= copy_action(adt->action); - dadt->tmpact= copy_action(adt->tmpact); + dadt->action= BKE_action_copy(adt->action); + dadt->tmpact= BKE_action_copy(adt->tmpact); } else { id_us_plus((ID *)dadt->action); @@ -298,11 +298,11 @@ void BKE_copy_animdata_id_action(ID *id) if (adt) { if (adt->action) { id_us_min((ID *)adt->action); - adt->action= copy_action(adt->action); + adt->action= BKE_action_copy(adt->action); } if (adt->tmpact) { id_us_min((ID *)adt->tmpact); - adt->tmpact= copy_action(adt->tmpact); + adt->tmpact= BKE_action_copy(adt->tmpact); } } } @@ -314,8 +314,8 @@ static void make_local_strips(ListBase *strips) NlaStrip *strip; for (strip=strips->first; strip; strip=strip->next) { - if (strip->act) make_local_action(strip->act); - if (strip->remap && strip->remap->target) make_local_action(strip->remap->target); + if (strip->act) BKE_action_make_local(strip->act); + if (strip->remap && strip->remap->target) BKE_action_make_local(strip->remap->target); make_local_strips(&strip->strips); } @@ -327,10 +327,10 @@ void BKE_animdata_make_local(AnimData *adt) NlaTrack *nlt; /* Actions - Active and Temp */ - if (adt->action) make_local_action(adt->action); - if (adt->tmpact) make_local_action(adt->tmpact); + if (adt->action) BKE_action_make_local(adt->action); + if (adt->tmpact) BKE_action_make_local(adt->tmpact); /* Remaps */ - if (adt->remap && adt->remap->target) make_local_action(adt->remap->target); + if (adt->remap && adt->remap->target) BKE_action_make_local(adt->remap->target); /* Drivers */ // TODO: need to remap the ID-targets too? diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b0d0ace2a7e..e2d90b60ffa 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -79,7 +79,7 @@ bArmature *add_armature(const char *name) { bArmature *arm; - arm = alloc_libblock (&G.main->armature, ID_AR, name); + arm = BKE_libblock_alloc (&G.main->armature, ID_AR, name); arm->deformflag = ARM_DEF_VGROUP|ARM_DEF_ENVELOPE; arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */ arm->layer = 1; @@ -108,7 +108,7 @@ void free_bonelist(ListBase *lb) BLI_freelistN(lb); } -void free_armature(bArmature *arm) +void BKE_armature_free(bArmature *arm) { if (arm) { free_bonelist(&arm->bonebase); @@ -135,7 +135,7 @@ void free_armature(bArmature *arm) } } -void make_local_armature(bArmature *arm) +void BKE_armature_make_local(bArmature *arm) { Main *bmain = G.main; int is_local = FALSE, is_lib = FALSE; @@ -161,7 +161,7 @@ void make_local_armature(bArmature *arm) id_clear_lib_data(bmain, &arm->id); } else if (is_local && is_lib) { - bArmature *arm_new = copy_armature(arm); + bArmature *arm_new = BKE_armature_copy(arm); arm_new->id.us = 0; /* Remap paths of new ID using old library as base. */ @@ -201,13 +201,13 @@ static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, Bone } } -bArmature *copy_armature(bArmature *arm) +bArmature *BKE_armature_copy(bArmature *arm) { bArmature *newArm; Bone *oldBone, *newBone; Bone *newActBone= NULL; - newArm = copy_libblock(&arm->id); + newArm = BKE_libblock_copy(&arm->id); BLI_duplicatelist(&newArm->bonebase, &arm->bonebase); /* Duplicate the childrens' lists*/ @@ -1316,7 +1316,7 @@ void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[] armature_mat_pose_to_bone(&work_pchan, inmat, outmat); } -/* same as object_mat3_to_rot() */ +/* same as BKE_object_mat3_to_rot() */ void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) { switch (pchan->rotmode) { @@ -1335,7 +1335,7 @@ void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) } /* Apply a 4x4 matrix to the pose bone, - * similar to object_apply_mat4() */ + * similar to BKE_object_apply_mat4() */ void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) { float rot[3][3]; @@ -1732,7 +1732,7 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) /* synchronize protected layers with proxy */ if (ob->proxy) { - object_copy_proxy_drivers(ob, ob->proxy); + BKE_object_copy_proxy_drivers(ob, ob->proxy); pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected); } @@ -2517,7 +2517,7 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot) { bDeformGroup *defgroup; unsigned int i; - Object *armob = object_pose_armature_get(ob); + Object *armob = BKE_object_pose_armature_get(ob); int dg_flags_sel_tot = 0; if (armob) { @@ -2581,7 +2581,7 @@ void boundbox_armature(Object *ob, float *loc, float *size) size[1] = (max[1] - min[1]) / 2.0f; size[2] = (max[2] - min[2]) / 2.0f; - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } BoundBox *BKE_armature_get_bb(Object *ob) diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 51258b13f68..a1e8a11e9ff 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -126,7 +126,7 @@ Brush *BKE_brush_add(const char *name) { Brush *brush; - brush= alloc_libblock(&G.main->brush, ID_BR, name); + brush= BKE_libblock_alloc(&G.main->brush, ID_BR, name); /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; @@ -145,7 +145,7 @@ Brush *BKE_brush_copy(Brush *brush) { Brush *brushn; - brushn= copy_libblock(&brush->id); + brushn= BKE_libblock_copy(&brush->id); if (brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); @@ -432,7 +432,7 @@ int BKE_brush_texture_set_nr(Brush *brush, int nr) idtest= (ID*)BLI_findlink(&G.main->tex, nr-1); if (idtest==NULL) { /* new tex */ - if (id) idtest= (ID *)copy_texture((Tex *)id); + if (id) idtest= (ID *)BKE_texture_copy((Tex *)id); else idtest= (ID *)add_texture("Tex"); idtest->us--; } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 11c628e7848..efede6bbae7 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -54,7 +54,7 @@ void *BKE_camera_add(const char *name) { Camera *cam; - cam= alloc_libblock(&G.main->camera, ID_CA, name); + cam= BKE_libblock_alloc(&G.main->camera, ID_CA, name); cam->lens= 35.0f; cam->sensor_x= 32.0f; @@ -73,7 +73,7 @@ Camera *BKE_camera_copy(Camera *cam) { Camera *camn; - camn= copy_libblock(&cam->id); + camn= BKE_libblock_copy(&cam->id); id_lib_extern((ID *)camn->dof_ob); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 424ded0397e..399aedc914f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -383,7 +383,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* Local space in this case will have to be defined as local to the owner's * transform-property-rotated axes. So subtract this rotation component. */ - object_to_mat4(ob, diff_mat); + BKE_object_to_mat4(ob, diff_mat); normalize_m4(diff_mat); zero_v3(diff_mat[3]); @@ -402,7 +402,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* Local space in this case will have to be defined as local to the owner's * transform-property-rotated axes. So add back this rotation component. */ - object_to_mat4(ob, diff_mat); + BKE_object_to_mat4(ob, diff_mat); normalize_m4(diff_mat); zero_v3(diff_mat[3]); @@ -2218,7 +2218,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* evaluate using workob */ // FIXME: we don't have any consistent standards on limiting effects on object... what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); - object_to_mat4(&workob, ct->matrix); + BKE_object_to_mat4(&workob, ct->matrix); } else { /* behavior undefined... */ @@ -3149,7 +3149,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta copy_v3_v3(ownLoc, obmat[3]); INIT_MINMAX(curveMin, curveMax) - minmax_object(ct->tar, curveMin, curveMax); + BKE_object_minmax(ct->tar, curveMin, curveMax); /* get targetmatrix */ if (cu->path && cu->path->data) { @@ -3989,7 +3989,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase float aspect= (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); float len, d; - where_is_object_mat(scene, camob, mat); + BKE_object_where_is_calc_mat4(scene, camob, mat); /* camera axis */ vec[0] = 0.0f; @@ -4198,7 +4198,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase if (object) { float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4]; - where_is_object_mat(scene, camob, cammat); + BKE_object_where_is_calc_mat4(scene, camob, cammat); BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 85e3d85dfc4..04a2eef5615 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -155,7 +155,7 @@ Curve *BKE_curve_add(const char *name, int type) { Curve *cu; - cu = alloc_libblock(&G.main->curve, ID_CU, name); + cu = BKE_libblock_alloc(&G.main->curve, ID_CU, name); copy_v3_fl(cu->size, 1.0f); cu->flag= CU_FRONT|CU_BACK|CU_DEFORM_BOUNDS_OFF|CU_PATH_RADIUS; cu->pathlen= 100; @@ -172,7 +172,7 @@ Curve *BKE_curve_add(const char *name, int type) cu->bevfac1= 0.0f; cu->bevfac2= 1.0f; - cu->bb= unit_boundbox(); + cu->bb= BKE_boundbox_alloc_unit(); if (type==OB_FONT) { cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font(); @@ -194,7 +194,7 @@ Curve *BKE_curve_copy(Curve *cu) Curve *cun; int a; - cun= copy_libblock(&cu->id); + cun= BKE_libblock_copy(&cu->id); cun->nurb.first= cun->nurb.last= NULL; BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); @@ -208,7 +208,7 @@ Curve *BKE_curve_copy(Curve *cu) cun->tb= MEM_dupallocN(cu->tb); cun->bb= MEM_dupallocN(cu->bb); - cun->key= copy_key(cu->key); + cun->key= BKE_key_copy(cu->key); if (cun->key) cun->key->from= (ID *)cun; cun->disp.first= cun->disp.last= NULL; @@ -385,7 +385,7 @@ void BKE_curve_tex_space_calc(Curve *cu) max[0] = max[1] = max[2] = 1.0f; } - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); if (cu->texflag & CU_AUTOSPACE) { mid_v3_v3v3(cu->loc, min, max); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 75e22195c6a..d8287644abf 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1896,7 +1896,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if ((all_layer & layer)==0) { // XXX && (ob != obedit)) { /* but existing displaylists or derivedmesh should be freed */ if (ob->recalc & OB_RECALC_DATA) - object_free_display(ob); + BKE_object_free_display(ob); ob->recalc &= ~OB_RECALC_ALL; } @@ -2613,7 +2613,7 @@ static void dag_id_flush_update(Scene *sce, ID *id) * so it should happen tracking-related constraints recalculation * when camera is changing (sergey) */ if (sce->camera && &sce->camera->id == id) { - MovieClip *clip = object_get_movieclip(sce, sce->camera, 1); + MovieClip *clip = BKE_object_movieclip_get(sce, sce->camera, 1); if (clip) dag_id_flush_update(sce, &clip->id); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index cf7750520a3..60f060d154e 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1569,7 +1569,7 @@ static void boundbox_displist(Object *ob) } if (bb) { - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6c5826c5bab..fde5d2d2a2d 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -540,11 +540,11 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram /* ignore cache clear during subframe updates * to not mess up cache validity */ object_cacheIgnoreClear(ob, 1); - object_handle_update(scene, ob); + BKE_object_handle_update(scene, ob); object_cacheIgnoreClear(ob, 0); } else - where_is_object_time(scene, ob, frame); + BKE_object_where_is_calc_time(scene, ob, frame); return 0; } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 7fb0cf9f0fa..4024deee1e8 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -202,9 +202,9 @@ static void precalculate_effector(EffectorCache *eff) if (eff->ob) { float old_vel[3]; - where_is_object_time(eff->scene, eff->ob, cfra - 1.0f); + BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f); copy_v3_v3(old_vel, eff->ob->obmat[3]); - where_is_object_time(eff->scene, eff->ob, cfra); + BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra); sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel); } } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 0414d69785f..71c6c8d80aa 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1302,7 +1302,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) } else { /* transforms to matrix */ - object_to_mat4(ob, mat); + BKE_object_to_mat4(ob, mat); } } else { diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a7f01393a02..03a1298a053 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -63,7 +63,7 @@ static ListBase ttfdata= {NULL, NULL}; /* The vfont code */ -void free_vfont(struct VFont *vf) +void BKE_vfont_free(struct VFont *vf) { if (vf == NULL) return; @@ -242,7 +242,7 @@ VFont *load_vfont(Main *bmain, const char *name) vfd= BLI_vfontdata_from_freetypefont(pf); if (vfd) { - vfont = alloc_libblock(&bmain->vfont, ID_VF, filename); + vfont = BKE_libblock_alloc(&bmain->vfont, ID_VF, filename); vfont->data = vfd; /* if there's a font name, use it for the ID name */ diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 9ea4eafdd73..da3acce9228 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -108,7 +108,7 @@ void free_gpencil_layers(ListBase *list) } /* Free all of GPencil datablock's related data, but not the block itself */ -void free_gpencil_data(bGPdata *gpd) +void BKE_gpencil_free(bGPdata *gpd) { /* free layers */ free_gpencil_layers(&gpd->layers); @@ -198,7 +198,7 @@ bGPdata *gpencil_data_addnew (const char name[]) bGPdata *gpd; /* allocate memory for a new block */ - gpd= alloc_libblock(&G.main->gpencil, ID_GD, name); + gpd= BKE_libblock_alloc(&G.main->gpencil, ID_GD, name); /* initial settings */ gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND); diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index d46ceebdfee..6e105c7d0bb 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -60,7 +60,7 @@ static void free_group_object(GroupObject *go) } -void free_group_objects(Group *group) +void BKE_group_free(Group *group) { /* don't free group itself */ GroupObject *go; @@ -72,7 +72,7 @@ void free_group_objects(Group *group) } } -void unlink_group(Group *group) +void BKE_group_unlink(Group *group) { Main *bmain= G.main; Material *ma; @@ -133,7 +133,7 @@ void unlink_group(Group *group) } /* group stays in library, but no members */ - free_group_objects(group); + BKE_group_free(group); group->id.us= 0; } @@ -141,12 +141,12 @@ Group *add_group(const char *name) { Group *group; - group = alloc_libblock(&G.main->group, ID_GR, name); + group = BKE_libblock_alloc(&G.main->group, ID_GR, name); group->layer= (1<<20)-1; return group; } -Group *copy_group(Group *group) +Group *BKE_group_copy(Group *group) { Group *groupn; @@ -361,7 +361,7 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group go->ob->recalc= go->recalc; group_replaces_nla(parent, go->ob, 's'); - object_handle_update(scene, go->ob); + BKE_object_handle_update(scene, go->ob); group_replaces_nla(parent, go->ob, 'e'); /* leave recalc tags in case group members are in normal scene */ @@ -379,7 +379,7 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group for (go= group->gobject.first; go; go= go->next) { if (go->ob) { if (go->ob->recalc) { - object_handle_update(scene, go->ob); + BKE_object_handle_update(scene, go->ob); } } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 9c5c99592ed..77728e4114a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -198,7 +198,7 @@ static void image_free_buffers(Image *ima) } /* called by library too, do not free ima itself */ -void free_image(Image *ima) +void BKE_image_free(Image *ima) { int a; @@ -225,7 +225,7 @@ static Image *image_alloc(const char *name, short source, short type) { Image *ima; - ima= alloc_libblock(&G.main->image, ID_IM, name); + ima= BKE_libblock_alloc(&G.main->image, ID_IM, name); if (ima) { ima->ok= IMA_OK; @@ -300,7 +300,7 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) } /* empty image block, of similar type and filename */ -Image *copy_image(Image *ima) +Image *BKE_image_copy(Image *ima) { Image *nima= image_alloc(ima->id.name+2, ima->source, ima->type); @@ -408,7 +408,7 @@ void make_local_image(struct Image *ima) extern_local_image(ima); } else if (is_local && is_lib) { - Image *ima_new= copy_image(ima); + Image *ima_new= BKE_image_copy(ima); ima_new->id.us= 0; @@ -501,7 +501,7 @@ void BKE_image_merge(Image *dest, Image *source) image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index)); } - free_libblock(&G.main->image, source); + BKE_libblock_free(&G.main->image, source); } } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 48763382f2a..d7af24b394d 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -81,7 +81,7 @@ /* Free data from old IPO-Blocks (those which haven't been converted), but not IPO block itself */ // XXX this shouldn't be necessary anymore, but may occur while not all data is converted yet -void free_ipo(Ipo *ipo) +void BKE_ipo_free(Ipo *ipo) { IpoCurve *icu, *icn; int n= 0; diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 54a2613991a..e36e7bf6cf3 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -78,7 +78,7 @@ int slurph_opt = 1; -void free_key(Key *key) +void BKE_key_free(Key *key) { KeyBlock *kb; @@ -126,7 +126,7 @@ Key *add_key(ID *id) /* common function */ Key *key; char *el; - key = alloc_libblock(&G.main->key, ID_KE, "Key"); + key = BKE_libblock_alloc(&G.main->key, ID_KE, "Key"); key->type = KEY_NORMAL; key->from = id; @@ -170,14 +170,14 @@ Key *add_key(ID *id) /* common function */ return key; } -Key *copy_key(Key *key) +Key *BKE_key_copy(Key *key) { Key *keyn; KeyBlock *kbn, *kb; if (key == NULL) return NULL; - keyn = copy_libblock(&key->id); + keyn = BKE_libblock_copy(&key->id); BLI_duplicatelist(&keyn->block, &key->block); @@ -223,7 +223,7 @@ Key *copy_key_nolib(Key *key) return keyn; } -void make_local_key(Key *key) +void BKE_key_make_local(Key *key) { /* - only lib users: do nothing diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 11c3269ad37..927a4390999 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -55,7 +55,7 @@ void *add_lamp(const char *name) { Lamp *la; - la= alloc_libblock(&G.main->lamp, ID_LA, name); + la= BKE_libblock_alloc(&G.main->lamp, ID_LA, name); la->r= la->g= la->b= la->k= 1.0f; la->haint= la->energy= 1.0f; @@ -102,12 +102,12 @@ void *add_lamp(const char *name) return la; } -Lamp *copy_lamp(Lamp *la) +Lamp *BKE_lamp_copy(Lamp *la) { Lamp *lan; int a; - lan= copy_libblock(&la->id); + lan= BKE_libblock_copy(&la->id); for (a=0; amtex[a]) { @@ -133,7 +133,7 @@ Lamp *localize_lamp(Lamp *la) Lamp *lan; int a; - lan= copy_libblock(&la->id); + lan= BKE_libblock_copy(&la->id); BLI_remlink(&G.main->lamp, lan); for (a=0; aid); } else if (is_local && is_lib) { - Lamp *la_new= copy_lamp(la); + Lamp *la_new= BKE_lamp_copy(la); la_new->id.us= 0; /* Remap paths of new ID using old library as base. */ @@ -206,7 +206,7 @@ void make_local_lamp(Lamp *la) } } -void free_lamp(Lamp *la) +void BKE_lamp_free(Lamp *la) { MTex *mtex; int a; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index e78da48d153..d9ee95857ca 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -188,7 +188,7 @@ Lattice *add_lattice(const char *name) { Lattice *lt; - lt= alloc_libblock(&G.main->latt, ID_LT, name); + lt= BKE_libblock_alloc(&G.main->latt, ID_LT, name); lt->flag= LT_GRID; @@ -200,14 +200,14 @@ Lattice *add_lattice(const char *name) return lt; } -Lattice *copy_lattice(Lattice *lt) +Lattice *BKE_lattice_copy(Lattice *lt) { Lattice *ltn; - ltn= copy_libblock(<->id); + ltn= BKE_libblock_copy(<->id); ltn->def= MEM_dupallocN(lt->def); - ltn->key= copy_key(ltn->key); + ltn->key= BKE_key_copy(ltn->key); if (ltn->key) ltn->key->from= (ID *)ltn; if (lt->dvert) { @@ -221,7 +221,7 @@ Lattice *copy_lattice(Lattice *lt) return ltn; } -void free_lattice(Lattice *lt) +void BKE_lattice_free(Lattice *lt) { if (lt->def) MEM_freeN(lt->def); if (lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); @@ -243,7 +243,7 @@ void free_lattice(Lattice *lt) } -void make_local_lattice(Lattice *lt) +void BKE_lattice_make_local(Lattice *lt) { Main *bmain= G.main; Object *ob; @@ -271,7 +271,7 @@ void make_local_lattice(Lattice *lt) id_clear_lib_data(bmain, <->id); } else if (is_local && is_lib) { - Lattice *lt_new= copy_lattice(lt); + Lattice *lt_new= BKE_lattice_copy(lt); lt_new->id.us= 0; /* Remap paths of new ID using old library as base. */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 14e2d75bee5..1c13c96d8a3 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -188,54 +188,54 @@ int id_make_local(ID *id, int test) case ID_LI: return 0; /* can't be linked */ case ID_OB: - if (!test) make_local_object((Object*)id); + if (!test) BKE_object_make_local((Object *)id); return 1; case ID_ME: if (!test) { - make_local_mesh((Mesh*)id); - make_local_key(((Mesh*)id)->key); + BKE_mesh_make_local((Mesh *)id); + BKE_key_make_local(((Mesh *)id)->key); } return 1; case ID_CU: if (!test) { - BKE_curve_make_local((Curve*)id); - make_local_key(((Curve*)id)->key); + BKE_curve_make_local((Curve *)id); + BKE_key_make_local(((Curve *)id)->key); } return 1; case ID_MB: - if (!test) BKE_metaball_make_local((MetaBall*)id); + if (!test) BKE_metaball_make_local((MetaBall *)id); return 1; case ID_MA: - if (!test) make_local_material((Material*)id); + if (!test) make_local_material((Material *)id); return 1; case ID_TE: - if (!test) make_local_texture((Tex*)id); + if (!test) make_local_texture((Tex *)id); return 1; case ID_IM: - if (!test) make_local_image((Image*)id); + if (!test) make_local_image((Image *)id); return 1; case ID_LT: if (!test) { - make_local_lattice((Lattice*)id); - make_local_key(((Lattice*)id)->key); + BKE_lattice_make_local((Lattice *)id); + BKE_key_make_local(((Lattice *)id)->key); } return 1; case ID_LA: - if (!test) make_local_lamp((Lamp*)id); + if (!test) make_local_lamp((Lamp *)id); return 1; case ID_CA: - if (!test) BKE_camera_make_local((Camera*)id); + if (!test) BKE_camera_make_local((Camera *)id); return 1; case ID_SPK: - if (!test) make_local_speaker((Speaker*)id); + if (!test) make_local_speaker((Speaker *)id); return 1; case ID_IP: return 0; /* deprecated */ case ID_KE: - if (!test) make_local_key((Key*)id); + if (!test) BKE_key_make_local((Key *)id); return 1; case ID_WO: - if (!test) make_local_world((World*)id); + if (!test) BKE_world_make_local((World *)id); return 1; case ID_SCR: return 0; /* can't be linked */ @@ -250,18 +250,18 @@ int id_make_local(ID *id, int test) case ID_GR: return 0; /* not implemented */ case ID_AR: - if (!test) make_local_armature((bArmature*)id); + if (!test) BKE_armature_make_local((bArmature *)id); return 1; case ID_AC: - if (!test) make_local_action((bAction*)id); + if (!test) BKE_action_make_local((bAction *)id); return 1; case ID_NT: return 0; /* not implemented */ case ID_BR: - if (!test) BKE_brush_make_local((Brush*)id); + if (!test) BKE_brush_make_local((Brush *)id); return 1; case ID_PA: - if (!test) make_local_particlesettings((ParticleSettings*)id); + if (!test) BKE_particlesettings_make_local((ParticleSettings *)id); return 1; case ID_WM: return 0; /* can't be linked */ @@ -285,74 +285,74 @@ int id_copy(ID *id, ID **newid, int test) case ID_LI: return 0; /* can't be copied from here */ case ID_OB: - if (!test) *newid= (ID*)copy_object((Object*)id); + if (!test) *newid = (ID *)BKE_object_copy((Object*)id); return 1; case ID_ME: - if (!test) *newid= (ID*)copy_mesh((Mesh*)id); + if (!test) *newid = (ID *)BKE_mesh_copy((Mesh*)id); return 1; case ID_CU: - if (!test) *newid= (ID*)BKE_curve_copy((Curve*)id); + if (!test) *newid = (ID *)BKE_curve_copy((Curve*)id); return 1; case ID_MB: - if (!test) *newid= (ID*)BKE_metaball_copy((MetaBall*)id); + if (!test) *newid = (ID *)BKE_metaball_copy((MetaBall*)id); return 1; case ID_MA: - if (!test) *newid= (ID*)copy_material((Material*)id); + if (!test) *newid = (ID *)BKE_material_copy((Material*)id); return 1; case ID_TE: - if (!test) *newid= (ID*)copy_texture((Tex*)id); + if (!test) *newid = (ID *)BKE_texture_copy((Tex*)id); return 1; case ID_IM: - if (!test) *newid= (ID*)copy_image((Image*)id); + if (!test) *newid = (ID *)BKE_image_copy((Image*)id); return 1; case ID_LT: - if (!test) *newid= (ID*)copy_lattice((Lattice*)id); + if (!test) *newid = (ID *)BKE_lattice_copy((Lattice*)id); return 1; case ID_LA: - if (!test) *newid= (ID*)copy_lamp((Lamp*)id); + if (!test) *newid = (ID *)BKE_lamp_copy((Lamp*)id); return 1; case ID_SPK: - if (!test) *newid= (ID*)copy_speaker((Speaker*)id); + if (!test) *newid = (ID *)BKE_speaker_copy((Speaker*)id); return 1; case ID_CA: - if (!test) *newid= (ID*)BKE_camera_copy((Camera*)id); + if (!test) *newid = (ID *)BKE_camera_copy((Camera*)id); return 1; case ID_IP: return 0; /* deprecated */ case ID_KE: - if (!test) *newid= (ID*)copy_key((Key*)id); + if (!test) *newid = (ID *)BKE_key_copy((Key*)id); return 1; case ID_WO: - if (!test) *newid= (ID*)copy_world((World*)id); + if (!test) *newid = (ID *)BKE_world_copy((World*)id); return 1; case ID_SCR: return 0; /* can't be copied from here */ case ID_VF: return 0; /* not implemented */ case ID_TXT: - if (!test) *newid= (ID*)copy_text((Text*)id); + if (!test) *newid = (ID *)BKE_text_copy((Text*)id); return 1; case ID_SCRIPT: return 0; /* deprecated */ case ID_SO: return 0; /* not implemented */ case ID_GR: - if (!test) *newid= (ID*)copy_group((Group*)id); + if (!test) *newid = (ID *)BKE_group_copy((Group*)id); return 1; case ID_AR: - if (!test) *newid= (ID*)copy_armature((bArmature*)id); + if (!test) *newid = (ID *)BKE_armature_copy((bArmature*)id); return 1; case ID_AC: - if (!test) *newid= (ID*)copy_action((bAction*)id); + if (!test) *newid = (ID *)BKE_action_copy((bAction*)id); return 1; case ID_NT: - if (!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id); + if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree*)id); return 1; case ID_BR: - if (!test) *newid= (ID*)BKE_brush_copy((Brush*)id); + if (!test) *newid = (ID *)BKE_brush_copy((Brush*)id); return 1; case ID_PA: - if (!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id); + if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings*)id); return 1; case ID_WM: return 0; /* can't be copied from here */ @@ -371,15 +371,15 @@ int id_unlink(ID *id, int test) switch (GS(id->name)) { case ID_TXT: if (test) return 1; - unlink_text(mainlib, (Text*)id); + BKE_text_unlink(mainlib, (Text *)id); break; case ID_GR: if (test) return 1; - unlink_group((Group*)id); + BKE_group_unlink((Group *)id); break; case ID_OB: if (test) return 1; - unlink_object((Object*)id); + BKE_object_unlink((Object *)id); break; } @@ -387,7 +387,7 @@ int id_unlink(ID *id, int test) if (test) return 1; lb= which_libbase(mainlib, GS(id->name)); - free_libblock(lb, id); + BKE_libblock_free(lb, id); return 1; } @@ -577,10 +577,10 @@ int set_listbasepointers(Main *main, ListBase **lb) /* *********** ALLOC AND FREE ***************** * - * free_libblock(ListBase *lb, ID *id ) + * BKE_libblock_free(ListBase *lb, ID *id ) * provide a list-basis and datablock, but only ID is read * - * void *alloc_libblock(ListBase *lb, type, name) + * void *BKE_libblock_alloc(ListBase *lb, type, name) * inserts in list and returns a new ID * * **************************** */ @@ -685,7 +685,7 @@ static ID *alloc_libblock_notest(short type) } /* used everywhere in blenkernel and text.c */ -void *alloc_libblock(ListBase *lb, short type, const char *name) +void *BKE_libblock_alloc(ListBase *lb, short type, const char *name) { ID *id= NULL; @@ -714,7 +714,7 @@ static void id_copy_animdata(ID *id, const short do_action) } /* material nodes use this since they are not treated as libdata */ -void copy_libblock_data(ID *id, const ID *id_from, const short do_action) +void BKE_libblock_copy_data(ID *id, const ID *id_from, const short do_action) { if (id_from->properties) id->properties = IDP_CopyProperty(id_from->properties); @@ -724,14 +724,14 @@ void copy_libblock_data(ID *id, const ID *id_from, const short do_action) } /* used everywhere in blenkernel */ -void *copy_libblock(ID *id) +void *BKE_libblock_copy(ID *id) { ID *idn; ListBase *lb; size_t idn_len; lb= which_libbase(G.main, GS(id->name)); - idn= alloc_libblock(lb, GS(id->name), id->name+2); + idn= BKE_libblock_alloc(lb, GS(id->name), id->name+2); assert(idn != NULL); @@ -746,12 +746,12 @@ void *copy_libblock(ID *id) id->newid= idn; idn->flag |= LIB_NEW; - copy_libblock_data(idn, id, FALSE); + BKE_libblock_copy_data(idn, id, FALSE); return idn; } -static void free_library(Library *UNUSED(lib)) +static void BKE_library_free(Library *UNUSED(lib)) { /* no freeing needed for libraries yet */ } @@ -788,7 +788,7 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata /* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */ -void free_libblock(ListBase *lb, void *idv) +void BKE_libblock_free(ListBase *lb, void *idv) { ID *id= idv; @@ -798,16 +798,16 @@ void free_libblock(ListBase *lb, void *idv) switch ( GS(id->name) ) { /* GetShort from util.h */ case ID_SCE: - free_scene((Scene *)id); + BKE_scene_free((Scene *)id); break; case ID_LI: - free_library((Library *)id); + BKE_library_free((Library *)id); break; case ID_OB: - free_object((Object *)id); + BKE_object_free((Object *)id); break; case ID_ME: - free_mesh((Mesh *)id, 1); + BKE_mesh_free((Mesh *)id, 1); break; case ID_CU: BKE_curve_free((Curve *)id); @@ -816,58 +816,58 @@ void free_libblock(ListBase *lb, void *idv) BKE_metaball_free((MetaBall *)id); break; case ID_MA: - free_material((Material *)id); + BKE_material_free((Material *)id); break; case ID_TE: - free_texture((Tex *)id); + BKE_texture_free((Tex *)id); break; case ID_IM: - free_image((Image *)id); + BKE_image_free((Image *)id); break; case ID_LT: - free_lattice((Lattice *)id); + BKE_lattice_free((Lattice *)id); break; case ID_LA: - free_lamp((Lamp *)id); + BKE_lamp_free((Lamp *)id); break; case ID_CA: - BKE_camera_free((Camera*) id); + BKE_camera_free((Camera *) id); break; case ID_IP: - free_ipo((Ipo *)id); + BKE_ipo_free((Ipo *)id); break; case ID_KE: - free_key((Key *)id); + BKE_key_free((Key *)id); break; case ID_WO: - free_world((World *)id); + BKE_world_free((World *)id); break; case ID_SCR: - free_screen((bScreen *)id); + BKE_screen_free((bScreen *)id); break; case ID_VF: - free_vfont((VFont *)id); + BKE_vfont_free((VFont *)id); break; case ID_TXT: - free_text((Text *)id); + BKE_text_free((Text *)id); break; case ID_SCRIPT: //XXX free_script((Script *)id); break; case ID_SPK: - free_speaker((Speaker *)id); + BKE_speaker_free((Speaker *)id); break; case ID_SO: - sound_free((bSound*)id); + BKE_sound_free((bSound *)id); break; case ID_GR: - free_group_objects((Group *)id); + BKE_group_free((Group *)id); break; case ID_AR: - free_armature((bArmature *)id); + BKE_armature_free((bArmature *)id); break; case ID_AC: - free_action((bAction *)id); + BKE_action_free((bAction *)id); break; case ID_NT: ntreeFreeTree((bNodeTree *)id); @@ -876,14 +876,14 @@ void free_libblock(ListBase *lb, void *idv) BKE_brush_free((Brush *)id); break; case ID_PA: - psys_free_settings((ParticleSettings *)id); + BKE_particlesettings_free((ParticleSettings *)id); break; case ID_WM: if (free_windowmanager_cb) free_windowmanager_cb(NULL, (wmWindowManager *)id); break; case ID_GD: - free_gpencil_data((bGPdata *)id); + BKE_gpencil_free((bGPdata *)id); break; case ID_MC: BKE_movieclip_free((MovieClip *)id); @@ -903,7 +903,7 @@ void free_libblock(ListBase *lb, void *idv) MEM_freeN(id); } -void free_libblock_us(ListBase *lb, void *idv) /* test users */ +void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */ { ID *id= idv; @@ -914,9 +914,9 @@ void free_libblock_us(ListBase *lb, void *idv) /* test users */ else printf("ERROR block %s users %d\n", id->name, id->us); } if (id->us==0) { - if ( GS(id->name)==ID_OB ) unlink_object((Object *)id); + if ( GS(id->name)==ID_OB ) BKE_object_unlink((Object *)id); - free_libblock(lb, id); + BKE_libblock_free(lb, id); } } @@ -933,7 +933,7 @@ void free_main(Main *mainvar) ID *id; while ( (id= lb->first) ) { - free_libblock(lb, id); + BKE_libblock_free(lb, id); } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e52a9217673..16b3cb639bc 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -77,7 +77,7 @@ void init_def_material(void) } /* not material itself */ -void free_material(Material *ma) +void BKE_material_free(Material *ma) { MTex *mtex; int a; @@ -203,7 +203,7 @@ Material *add_material(const char *name) { Material *ma; - ma= alloc_libblock(&G.main->mat, ID_MA, name); + ma= BKE_libblock_alloc(&G.main->mat, ID_MA, name); init_material(ma); @@ -211,12 +211,12 @@ Material *add_material(const char *name) } /* XXX keep synced with next function */ -Material *copy_material(Material *ma) +Material *BKE_material_copy(Material *ma) { Material *man; int a; - man= copy_libblock(&ma->id); + man= BKE_libblock_copy(&ma->id); id_lib_extern((ID *)man->group); @@ -248,7 +248,7 @@ Material *localize_material(Material *ma) Material *man; int a; - man= copy_libblock(&ma->id); + man= BKE_libblock_copy(&ma->id); BLI_remlink(&G.main->mat, man); /* no increment for texture ID users, in previewrender.c it prevents decrement */ @@ -365,7 +365,7 @@ void make_local_material(Material *ma) } /* Both user and local, so copy. */ else if (is_local && is_lib) { - Material *ma_new= copy_material(ma); + Material *ma_new= BKE_material_copy(ma); ma_new->id.us= 0; @@ -1743,7 +1743,7 @@ static void convert_tfacematerial(Main *main, Material *ma) } /* create a new material */ else { - mat_new=copy_material(ma); + mat_new=BKE_material_copy(ma); if (mat_new) { /* rename the material*/ strcpy(mat_new->id.name, idname); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 8b2e66812c7..9fd8707cc01 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -203,7 +203,7 @@ MetaBall *BKE_metaball_add(const char *name) { MetaBall *mb; - mb= alloc_libblock(&G.main->mball, ID_MB, name); + mb= BKE_libblock_alloc(&G.main->mball, ID_MB, name); mb->size[0]= mb->size[1]= mb->size[2]= 1.0; mb->texflag= MB_AUTOSPACE; @@ -220,7 +220,7 @@ MetaBall *BKE_metaball_copy(MetaBall *mb) MetaBall *mbn; int a; - mbn= copy_libblock(&mb->id); + mbn= BKE_libblock_copy(&mb->id); BLI_duplicatelist(&mbn->elems, &mb->elems); @@ -387,7 +387,7 @@ void BKE_metaball_tex_space_calc(Object *ob) size[1]= (max[1]-min[1])/2.0f; size[2]= (max[2]-min[2])/2.0f; #endif - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 4b14c2aec4b..da758ea0f0b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -412,7 +412,7 @@ void unlink_mesh(Mesh *me) } /* do not free mesh itself */ -void free_mesh(Mesh *me, int unlink) +void BKE_mesh_free(Mesh *me, int unlink) { if (unlink) unlink_mesh(me); @@ -488,19 +488,19 @@ Mesh *add_mesh(const char *name) { Mesh *me; - me= alloc_libblock(&G.main->mesh, ID_ME, name); + me= BKE_libblock_alloc(&G.main->mesh, ID_ME, name); me->size[0]= me->size[1]= me->size[2]= 1.0; me->smoothresh= 30; me->texflag= ME_AUTOSPACE; me->flag= ME_TWOSIDED; - me->bb= unit_boundbox(); + me->bb= BKE_boundbox_alloc_unit(); me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; return me; } -Mesh *copy_mesh(Mesh *me) +Mesh *BKE_mesh_copy(Mesh *me) { Mesh *men; MTFace *tface; @@ -508,7 +508,7 @@ Mesh *copy_mesh(Mesh *me) int a, i; const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */ - men= copy_libblock(&me->id); + men= BKE_libblock_copy(&me->id); men->mat= MEM_dupallocN(me->mat); for (a=0; atotcol; a++) { @@ -555,7 +555,7 @@ Mesh *copy_mesh(Mesh *me) men->bb= MEM_dupallocN(men->bb); - men->key= copy_key(me->key); + men->key= BKE_key_copy(me->key); if (men->key) men->key->from= (ID *)men; return men; @@ -611,7 +611,7 @@ static void expand_local_mesh(Mesh *me) } } -void make_local_mesh(Mesh *me) +void BKE_mesh_make_local(Mesh *me) { Main *bmain= G.main; Object *ob; @@ -641,7 +641,7 @@ void make_local_mesh(Mesh *me) expand_local_mesh(me); } else if (is_local && is_lib) { - Mesh *me_new= copy_mesh(me); + Mesh *me_new= BKE_mesh_copy(me); me_new->id.us= 0; @@ -682,7 +682,7 @@ void boundbox_mesh(Mesh *me, float *loc, float *size) size[1]= (max[1]-min[1])/2.0f; size[2]= (max[2]-min[2])/2.0f; - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } void tex_space_mesh(Mesh *me) @@ -1518,7 +1518,7 @@ void nurbs_to_mesh(Object *ob) cu->totcol= 0; if (ob->data) { - free_libblock(&bmain->curve, ob->data); + BKE_libblock_free(&bmain->curve, ob->data); } ob->data= me; ob->type= OB_MESH; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 7a279572738..849dbd83366 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -430,7 +430,7 @@ static MovieClip *movieclip_alloc(const char *name) { MovieClip *clip; - clip = alloc_libblock(&G.main->movieclip, ID_MC, name); + clip = BKE_libblock_alloc(&G.main->movieclip, ID_MC, name); clip->aspx = clip->aspy = 1.0f; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index f3901cec506..bc7d3af930b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -2146,7 +2146,7 @@ void multiresModifier_scale_disp(Scene *scene, Object *ob) float smat[3][3]; /* object's scale matrix */ - object_scale_to_mat3(ob, smat); + BKE_object_scale_to_mat3(ob, smat); multires_apply_smat(scene, ob, smat); } @@ -2157,9 +2157,9 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) multires_sync_levels(scene, ob, to_ob); /* construct scale matrix for displacement */ - object_scale_to_mat3(to_ob, tmat); + BKE_object_scale_to_mat3(to_ob, tmat); invert_m3(tmat); - object_scale_to_mat3(ob, smat); + BKE_object_scale_to_mat3(ob, smat); mul_m3_m3m3(mat, smat, tmat); multires_apply_smat(scene, ob, mat); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index b2a85ad0629..5d76458b157 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -643,7 +643,7 @@ bNodeTree *ntreeAddTree(const char *name, int type, int nodetype) BLI_strncpy(ntree->id.name+2, name, sizeof(ntree->id.name)); } else - ntree= alloc_libblock(&G.main->nodetree, ID_NT, name); + ntree= BKE_libblock_alloc(&G.main->nodetree, ID_NT, name); ntree->type= type; ntree->nodetype = nodetype; @@ -675,11 +675,11 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree) for (newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next) if (newtree==ntree) break; if (newtree) { - newtree= copy_libblock(&ntree->id); + newtree= BKE_libblock_copy(&ntree->id); } else { newtree= MEM_dupallocN(ntree); - copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ + BKE_libblock_copy_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ } id_us_plus((ID *)newtree->gpd); @@ -931,7 +931,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node) ntree->update |= NTREE_UPDATE_NODES; } -/* do not free ntree itself here, free_libblock calls this function too */ +/* do not free ntree itself here, BKE_libblock_free calls this function too */ void ntreeFreeTree(bNodeTree *ntree) { bNode *node, *next; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index fde8f8e3f3d..37d261c6d29 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -117,9 +117,9 @@ /* Local function protos */ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); -float originmat[3][3]; /* after where_is_object(), can be used in other functions (bad!) */ +float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */ -void clear_workob(Object *workob) +void BKE_object_workob_clear(Object *workob) { memset(workob, 0, sizeof(Object)); @@ -128,27 +128,7 @@ void clear_workob(Object *workob) workob->rotmode= ROT_MODE_EUL; } -void copy_baseflags(struct Scene *scene) -{ - Base *base= scene->base.first; - - while (base) { - base->object->flag= base->flag; - base= base->next; - } -} - -void copy_objectflags(struct Scene *scene) -{ - Base *base= scene->base.first; - - while (base) { - base->flag= base->object->flag; - base= base->next; - } -} - -void update_base_layer(struct Scene *scene, Object *ob) +void BKE_object_update_base_layer(struct Scene *scene, Object *ob) { Base *base= scene->base.first; @@ -158,7 +138,7 @@ void update_base_layer(struct Scene *scene, Object *ob) } } -void object_free_particlesystems(Object *ob) +void BKE_object_free_particlesystems(Object *ob) { while (ob->particlesystem.first) { ParticleSystem *psys = ob->particlesystem.first; @@ -169,7 +149,7 @@ void object_free_particlesystems(Object *ob) } } -void object_free_softbody(Object *ob) +void BKE_object_free_softbody(Object *ob) { if (ob->soft) { sbFree(ob->soft); @@ -177,7 +157,7 @@ void object_free_softbody(Object *ob) } } -void object_free_bulletsoftbody(Object *ob) +void BKE_object_free_bulletsoftbody(Object *ob) { if (ob->bsoft) { bsbFree(ob->bsoft); @@ -185,7 +165,7 @@ void object_free_bulletsoftbody(Object *ob) } } -void object_free_modifiers(Object *ob) +void BKE_object_free_modifiers(Object *ob) { while (ob->modifiers.first) { ModifierData *md = ob->modifiers.first; @@ -196,13 +176,13 @@ void object_free_modifiers(Object *ob) } /* particle modifiers were freed, so free the particlesystems as well */ - object_free_particlesystems(ob); + BKE_object_free_particlesystems(ob); /* same for softbody */ - object_free_softbody(ob); + BKE_object_free_softbody(ob); } -int object_support_modifier_type(Object *ob, int modifier_type) +int BKE_object_support_modifier_type_check(Object *ob, int modifier_type) { ModifierTypeInfo *mti; @@ -217,10 +197,10 @@ int object_support_modifier_type(Object *ob, int modifier_type) return TRUE; } -void object_link_modifiers(struct Object *ob, struct Object *from) +void BKE_object_link_modifiers(struct Object *ob, struct Object *from) { ModifierData *md; - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { /* only objects listed above can have modifiers and linking them to objects @@ -233,7 +213,7 @@ void object_link_modifiers(struct Object *ob, struct Object *from) if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue; - if (!object_support_modifier_type(ob, md->type)) + if (!BKE_object_support_modifier_type_check(ob, md->type)) continue; nmd = modifier_new(md->type); @@ -241,15 +221,15 @@ void object_link_modifiers(struct Object *ob, struct Object *from) BLI_addtail(&ob->modifiers, nmd); } - copy_object_particlesystems(ob, from); - copy_object_softbody(ob, from); + BKE_object_copy_particlesystems(ob, from); + BKE_object_copy_softbody(ob, from); // TODO: smoke?, cloth? } /* here we will collect all local displist stuff */ /* also (ab)used in depsgraph */ -void object_free_display(Object *ob) +void BKE_object_free_display(Object *ob) { if (ob->derivedDeform) { ob->derivedDeform->needsFree = 1; @@ -308,11 +288,11 @@ void free_sculptsession(Object *ob) /* do not free object itself */ -void free_object(Object *ob) +void BKE_object_free(Object *ob) { int a; - object_free_display(ob); + BKE_object_free_display(ob); /* disconnect specific data */ if (ob->data) { @@ -345,7 +325,7 @@ void free_object(Object *ob) if (ob->mpath) animviz_free_motionpath(ob->mpath); free_properties(&ob->prop); - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); free_sensors(&ob->sensors); free_controllers(&ob->controllers); @@ -374,7 +354,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec } } -void unlink_object(Object *ob) +void BKE_object_unlink(Object *ob) { Main *bmain= G.main; Object *obt; @@ -731,7 +711,7 @@ void unlink_object(Object *ob) } } -int exist_object(Object *obtest) +int BKE_object_exists_check(Object *obtest) { Object *ob; @@ -747,7 +727,7 @@ int exist_object(Object *obtest) /* *************************************************** */ -void *add_obdata_from_type(int type) +void *BKE_object_obdata_add_from_type(int type) { switch (type) { case OB_MESH: return add_mesh("Mesh"); @@ -762,7 +742,7 @@ void *add_obdata_from_type(int type) case OB_SPEAKER: return add_speaker("Speaker"); case OB_EMPTY: return NULL; default: - printf("add_obdata_from_type: Internal error, bad type: %d\n", type); + printf("BKE_object_obdata_add_from_type: Internal error, bad type: %d\n", type); return NULL; } } @@ -788,14 +768,14 @@ static const char *get_obdata_defname(int type) } /* more general add: creates minimum required data, but without vertices etc. */ -Object *add_only_object(int type, const char *name) +Object *BKE_object_add_only_object(int type, const char *name) { Object *ob; if(!name) name = get_obdata_defname(type); - ob= alloc_libblock(&G.main->object, ID_OB, name); + ob= BKE_libblock_alloc(&G.main->object, ID_OB, name); /* default object vars */ ob->type= type; @@ -869,16 +849,16 @@ Object *add_only_object(int type, const char *name) /* general add: to scene, with layer from area and default name */ /* creates minimum required data, but without vertices etc. */ -Object *add_object(struct Scene *scene, int type) +Object *BKE_object_add(struct Scene *scene, int type) { Object *ob; Base *base; char name[MAX_ID_NAME]; BLI_strncpy(name, get_obdata_defname(type), sizeof(name)); - ob = add_only_object(type, name); + ob = BKE_object_add_only_object(type, name); - ob->data= add_obdata_from_type(type); + ob->data= BKE_object_obdata_add_from_type(type); ob->lay= scene->lay; @@ -992,7 +972,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) return psysn; } -void copy_object_particlesystems(Object *obn, Object *ob) +void BKE_object_copy_particlesystems(Object *obn, Object *ob) { ParticleSystem *psys, *npsys; ModifierData *md; @@ -1037,7 +1017,7 @@ void copy_object_particlesystems(Object *obn, Object *ob) } } -void copy_object_softbody(Object *obn, Object *ob) +void BKE_object_copy_softbody(Object *obn, Object *ob) { if (ob->soft) obn->soft= copy_softbody(ob->soft); @@ -1090,7 +1070,7 @@ static int object_pose_context(Object *ob) } } -Object *object_pose_armature_get(Object *ob) +Object *BKE_object_pose_armature_get(Object *ob) { if (ob==NULL) return NULL; @@ -1117,13 +1097,13 @@ static void copy_object_transform(Object *ob_tar, Object *ob_src) copy_v3_v3(ob_tar->size, ob_src->size); } -Object *copy_object(Object *ob) +Object *BKE_object_copy(Object *ob) { Object *obn; ModifierData *md; int a; - obn= copy_libblock(&ob->id); + obn= BKE_libblock_copy(&ob->id); if (ob->totcol) { obn->mat= MEM_dupallocN(ob->mat); @@ -1181,7 +1161,7 @@ Object *copy_object(Object *ob) obn->soft= copy_softbody(ob->soft); obn->bsoft = copy_bulletsoftbody(ob->bsoft); - copy_object_particlesystems(obn, ob); + BKE_object_copy_particlesystems(obn, ob); obn->derivedDeform = NULL; obn->derivedFinal = NULL; @@ -1209,7 +1189,7 @@ static void extern_local_object(Object *ob) id_lib_extern((ID *)psys->part); } -void make_local_object(Object *ob) +void BKE_object_make_local(Object *ob) { Main *bmain= G.main; Scene *sce; @@ -1242,7 +1222,7 @@ void make_local_object(Object *ob) extern_local_object(ob); } else if (is_local && is_lib) { - Object *ob_new= copy_object(ob); + Object *ob_new= BKE_object_copy(ob); ob_new->id.us= 0; @@ -1271,7 +1251,7 @@ void make_local_object(Object *ob) /* * Returns true if the Object is a from an external blend file (libdata) */ -int object_is_libdata(Object *ob) +int BKE_object_is_libdata(Object *ob) { if (!ob) return 0; if (ob->proxy) return 0; @@ -1280,7 +1260,7 @@ int object_is_libdata(Object *ob) } /* Returns true if the Object data is a from an external blend file (libdata) */ -int object_data_is_libdata(Object *ob) +int BKE_object_obdata_is_libdata(Object *ob) { if (!ob) return 0; if (ob->proxy && (ob->data==NULL || ((ID *)ob->data)->lib==NULL)) return 0; @@ -1307,7 +1287,7 @@ static void armature_set_id_extern(Object *ob) } -void object_copy_proxy_drivers(Object *ob, Object *target) +void BKE_object_copy_proxy_drivers(Object *ob, Object *target) { if ((target->adt) && (target->adt->drivers.first)) { FCurve *fcu; @@ -1349,7 +1329,7 @@ void object_copy_proxy_drivers(Object *ob, Object *target) /* local_object->proxy == pointer to library object, saved in files and read */ /* local_object->proxy_group == pointer to group dupli-object, saved in files and read */ -void object_make_proxy(Object *ob, Object *target, Object *gob) +void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) { /* paranoia checks */ if (ob->id.lib || target->id.lib==NULL) { @@ -1378,7 +1358,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) mul_mat3_m4_v3(ob->obmat, tvec); sub_v3_v3(ob->obmat[3], tvec); } - object_apply_mat4(ob, ob->obmat, FALSE, TRUE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, TRUE); } else { copy_object_transform(ob, target); @@ -1387,7 +1367,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) } /* copy animdata stuff - drivers only for now... */ - object_copy_proxy_drivers(ob, target); + BKE_object_copy_proxy_drivers(ob, target); /* skip constraints? */ // FIXME: this is considered by many as a bug @@ -1447,14 +1427,14 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) /* *************** CALC ****************** */ -void object_scale_to_mat3(Object *ob, float mat[][3]) +void BKE_object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; mul_v3_v3v3(vec, ob->size, ob->dscale); size_to_mat3(mat, vec); } -void object_rot_to_mat3(Object *ob, float mat[][3]) +void BKE_object_rot_to_mat3(Object *ob, float mat[][3]) { float rmat[3][3], dmat[3][3]; @@ -1488,7 +1468,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) mul_m3_m3m3(mat, dmat, rmat); } -void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) +void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { switch (ob->rotmode) { case ROT_MODE_QUAT: @@ -1525,7 +1505,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) } } -void object_tfm_protected_backup(const Object *ob, +void BKE_object_tfm_protected_backup(const Object *ob, ObjectTfmProtectedChannels *obtfm) { @@ -1552,7 +1532,7 @@ void object_tfm_protected_backup(const Object *ob, } -void object_tfm_protected_restore(Object *ob, +void BKE_object_tfm_protected_restore(Object *ob, const ObjectTfmProtectedChannels *obtfm, const short protectflag) { @@ -1591,7 +1571,7 @@ void object_tfm_protected_restore(Object *ob, } /* see pchan_apply_mat4() for the equivalent 'pchan' function */ -void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent) +void BKE_object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent) { float rot[3][3]; @@ -1600,15 +1580,15 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv); invert_m4_m4(imat, diff_mat); mult_m4_m4m4(rmat, imat, mat); /* get the parent relative matrix */ - object_apply_mat4(ob, rmat, use_compat, FALSE); + BKE_object_apply_mat4(ob, rmat, use_compat, FALSE); /* same as below, use rmat rather than mat */ mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat); - object_mat3_to_rot(ob, rot, use_compat); + BKE_object_mat3_to_rot(ob, rot, use_compat); } else { mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat); - object_mat3_to_rot(ob, rot, use_compat); + BKE_object_mat3_to_rot(ob, rot, use_compat); } sub_v3_v3(ob->loc, ob->dloc); @@ -1617,28 +1597,28 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const if (ob->dscale[1] != 0.0f) ob->size[1] /= ob->dscale[1]; if (ob->dscale[2] != 0.0f) ob->size[2] /= ob->dscale[2]; - /* object_mat3_to_rot handles delta rotations */ + /* BKE_object_mat3_to_rot handles delta rotations */ } -void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ +void BKE_object_to_mat3(Object *ob, float mat[][3]) /* no parent */ { float smat[3][3]; float rmat[3][3]; /*float q1[4];*/ /* size */ - object_scale_to_mat3(ob, smat); + BKE_object_scale_to_mat3(ob, smat); /* rot */ - object_rot_to_mat3(ob, rmat); + BKE_object_rot_to_mat3(ob, rmat); mul_m3_m3m3(mat, rmat, smat); } -void object_to_mat4(Object *ob, float mat[][4]) +void BKE_object_to_mat4(Object *ob, float mat[][4]) { float tmat[3][3]; - object_to_mat3(ob, tmat); + BKE_object_to_mat3(ob, tmat); copy_m4_m3(mat, tmat); @@ -1937,7 +1917,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ return 1; } -void where_is_object_time(Scene *scene, Object *ob, float ctime) +void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) { float slowmat[4][4] = MAT4_UNITY; float stime=ctime; @@ -1961,7 +1941,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) Object tmp= *par; if (par->proxy_from); // was a copied matrix, no where_is! bad... - else where_is_object_time(scene, par, ctime); + else BKE_object_where_is_calc_time(scene, par, ctime); solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); @@ -1979,7 +1959,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } } else { - object_to_mat4(ob, ob->obmat); + BKE_object_to_mat4(ob, ob->obmat); } /* solve constraints */ @@ -1988,7 +1968,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); - /* constraints need ctime, not stime. Some call where_is_object_time and bsystem_time */ + /* constraints need ctime, not stime. Some call BKE_object_where_is_calc_time and bsystem_time */ solve_constraints (&ob->constraints, cob, ctime); constraints_clear_evalob(cob); @@ -2003,7 +1983,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) * constraints -- assume dependencies are already solved by depsgraph. * no changes to object and it's parent would be done. * used for bundles orientation in 3d space relative to parented blender camera */ -void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4]) +void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) { float slowmat[4][4] = MAT4_UNITY; @@ -2016,7 +1996,7 @@ void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4]) where_is_object_parslow(ob, obmat, slowmat); } else { - object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, obmat); } } @@ -2028,7 +2008,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ float vec[3]; int ok; - object_to_mat4(ob, locmat); + BKE_object_to_mat4(ob, locmat); if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); @@ -2099,13 +2079,13 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } -void where_is_object(struct Scene *scene, Object *ob) +void BKE_object_where_is_calc(struct Scene *scene, Object *ob) { - where_is_object_time(scene, ob, (float)scene->r.cfra); + BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); } -void where_is_object_simul(Scene *scene, Object *ob) +void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) /* was written for the old game engine (until 2.04) */ /* It seems that this function is only called * for a lamp that is the child of another object */ @@ -2133,7 +2113,7 @@ void where_is_object_simul(Scene *scene, Object *ob) } } else { - object_to_mat4(ob, ob->obmat); + BKE_object_to_mat4(ob, ob->obmat); } /* solve constraints */ @@ -2147,9 +2127,9 @@ void where_is_object_simul(Scene *scene, Object *ob) } /* for calculation of the inverse parent transform, only used for editor */ -void what_does_parent(Scene *scene, Object *ob, Object *workob) +void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob) { - clear_workob(workob); + BKE_object_workob_clear(workob); unit_m4(workob->obmat); unit_m4(workob->parentinv); @@ -2169,21 +2149,21 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); - where_is_object(scene, workob); + BKE_object_where_is_calc(scene, workob); } -BoundBox *unit_boundbox(void) +BoundBox *BKE_boundbox_alloc_unit(void) { BoundBox *bb; float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {-1.0f, -1.0f, -1.0f}; bb= MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); return bb; } -void boundbox_set_from_min_max(BoundBox *bb, float min[3], float max[3]) +void BKE_boundbox_init_from_minmax(BoundBox *bb, float min[3], float max[3]) { bb->vec[0][0]=bb->vec[1][0]=bb->vec[2][0]=bb->vec[3][0]= min[0]; bb->vec[4][0]=bb->vec[5][0]=bb->vec[6][0]=bb->vec[7][0]= max[0]; @@ -2195,7 +2175,7 @@ void boundbox_set_from_min_max(BoundBox *bb, float min[3], float max[3]) bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= max[2]; } -BoundBox *object_get_boundbox(Object *ob) +BoundBox *BKE_object_boundbox_get(Object *ob) { BoundBox *bb= NULL; @@ -2212,20 +2192,20 @@ BoundBox *object_get_boundbox(Object *ob) } /* used to temporally disable/enable boundbox */ -void object_boundbox_flag(Object *ob, int flag, int set) +void BKE_object_boundbox_flag(Object *ob, int flag, int set) { - BoundBox *bb= object_get_boundbox(ob); + BoundBox *bb= BKE_object_boundbox_get(ob); if (bb) { if (set) bb->flag |= flag; else bb->flag &= ~flag; } } -void object_get_dimensions(Object *ob, float vec[3]) +void BKE_object_dimensions_get(Object *ob, float vec[3]) { BoundBox *bb = NULL; - bb= object_get_boundbox(ob); + bb= BKE_object_boundbox_get(ob); if (bb) { float scale[3]; @@ -2240,11 +2220,11 @@ void object_get_dimensions(Object *ob, float vec[3]) } } -void object_set_dimensions(Object *ob, const float *value) +void BKE_object_dimensions_set(Object *ob, const float *value) { BoundBox *bb = NULL; - bb= object_get_boundbox(ob); + bb= BKE_object_boundbox_get(ob); if (bb) { float scale[3], len[3]; @@ -2260,7 +2240,7 @@ void object_set_dimensions(Object *ob, const float *value) } } -void minmax_object(Object *ob, float min[3], float max[3]) +void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) { BoundBox bb; float vec[3]; @@ -2279,7 +2259,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) for (a=0; a<8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); - DO_MINMAX(bb.vec[a], min, max); + DO_MINMAX(bb.vec[a], min_r, max_r); } change= TRUE; } @@ -2294,7 +2274,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) for (v=0; vpntsv; v++) { for (u=0; upntsu; u++, bp++) { mul_v3_m4v3(vec, ob->obmat, bp->vec); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); } } } @@ -2306,9 +2286,9 @@ void minmax_object(Object *ob, float min[3], float max[3]) bPoseChannel *pchan; for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); } change= TRUE; } @@ -2322,7 +2302,7 @@ void minmax_object(Object *ob, float min[3], float max[3]) for (a=0; a<8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); - DO_MINMAX(bb.vec[a], min, max); + DO_MINMAX(bb.vec[a], min_r, max_r); } change= TRUE; } @@ -2331,19 +2311,19 @@ void minmax_object(Object *ob, float min[3], float max[3]) } if (change == FALSE) { - DO_MINMAX(ob->obmat[3], min, max); + DO_MINMAX(ob->obmat[3], min_r, max_r); copy_v3_v3(vec, ob->obmat[3]); add_v3_v3(vec, ob->size); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); copy_v3_v3(vec, ob->obmat[3]); sub_v3_v3(vec, ob->size); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); } } -int minmax_object_duplis(Scene *scene, Object *ob, float min[3], float max[3]) +int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3]) { int ok= 0; if ((ob->transflag & OB_DUPLI)==0) { @@ -2356,14 +2336,14 @@ int minmax_object_duplis(Scene *scene, Object *ob, float min[3], float max[3]) lb= object_duplilist(scene, ob); for (dob= lb->first; dob; dob= dob->next) { if (dob->no_draw == 0) { - BoundBox *bb= object_get_boundbox(dob->ob); + BoundBox *bb= BKE_object_boundbox_get(dob->ob); if (bb) { int i; for (i=0; i<8; i++) { float vec[3]; mul_v3_m4v3(vec, dob->mat, bb->vec[i]); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, r_min, r_max); } ok= 1; @@ -2453,7 +2433,7 @@ typedef struct ObTfmBack { float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ } ObTfmBack; -void *object_tfm_backup(Object *ob) +void *BKE_object_tfm_backup(Object *ob) { ObTfmBack *obtfm= MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack"); copy_v3_v3(obtfm->loc, ob->loc); @@ -2477,7 +2457,7 @@ void *object_tfm_backup(Object *ob) return (void *)obtfm; } -void object_tfm_restore(Object *ob, void *obtfm_pt) +void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) { ObTfmBack *obtfm= (ObTfmBack *)obtfm_pt; copy_v3_v3(ob->loc, obtfm->loc); @@ -2514,7 +2494,7 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob) /* the main object update call, for object matrix, constraints, keys and displist (modifiers) */ /* requires flags to be set! */ -void object_handle_update(Scene *scene, Object *ob) +void BKE_object_handle_update(Scene *scene, Object *ob) { if (ob->recalc & OB_RECALC_ALL) { /* speed optimization for animation lookups */ @@ -2524,7 +2504,7 @@ void object_handle_update(Scene *scene, Object *ob) if (ob->recalc & OB_RECALC_DATA) { if (ob->type==OB_ARMATURE) { /* this happens for reading old files and to match library armatures - * with poses we do it ahead of where_is_object to ensure animation + * with poses we do it ahead of BKE_object_where_is_calc to ensure animation * is evaluated on the rebuilt pose, otherwise we get incorrect poses * on file load */ if (ob->pose==NULL || (ob->pose->flag & POSE_RECALC)) @@ -2533,7 +2513,7 @@ void object_handle_update(Scene *scene, Object *ob) } /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, - * which is only in where_is_object now */ + * which is only in BKE_object_where_is_calc now */ // XXX: should this case be OB_RECALC_OB instead? if (ob->recalc & OB_RECALC_ALL) { @@ -2555,7 +2535,7 @@ void object_handle_update(Scene *scene, Object *ob) copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } else - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); } if (ob->recalc & OB_RECALC_DATA) { @@ -2695,7 +2675,7 @@ void object_handle_update(Scene *scene, Object *ob) /* set pointer in library proxy target, for copying, but restore it */ ob->proxy->proxy_from= ob; // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name); - object_handle_update(scene, ob->proxy); + BKE_object_handle_update(scene, ob->proxy); } ob->recalc &= ~OB_RECALC_ALL; @@ -2708,7 +2688,7 @@ void object_handle_update(Scene *scene, Object *ob) } } -void object_sculpt_modifiers_changed(Object *ob) +void BKE_object_sculpt_modifiers_changed(Object *ob) { SculptSession *ss= ob->sculpt; @@ -2736,7 +2716,7 @@ void object_sculpt_modifiers_changed(Object *ob) } } -int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, float **rot) +int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot) { if (ob->data==NULL) @@ -2746,28 +2726,28 @@ int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, case ID_ME: { Mesh *me= ob->data; - if (texflag) *texflag = &me->texflag; - if (loc) *loc = me->loc; - if (size) *size = me->size; - if (rot) *rot = me->rot; + if (r_texflag) *r_texflag = &me->texflag; + if (r_loc) *r_loc = me->loc; + if (r_size) *r_size = me->size; + if (r_rot) *r_rot = me->rot; break; } case ID_CU: { Curve *cu= ob->data; - if (texflag) *texflag = &cu->texflag; - if (loc) *loc = cu->loc; - if (size) *size = cu->size; - if (rot) *rot = cu->rot; + if (r_texflag) *r_texflag = &cu->texflag; + if (r_loc) *r_loc = cu->loc; + if (r_size) *r_size = cu->size; + if (r_rot) *r_rot = cu->rot; break; } case ID_MB: { MetaBall *mb= ob->data; - if (texflag) *texflag = &mb->texflag; - if (loc) *loc = mb->loc; - if (size) *size = mb->size; - if (rot) *rot = mb->rot; + if (r_texflag) *r_texflag = &mb->texflag; + if (r_loc) *r_loc = mb->loc; + if (r_size) *r_size = mb->size; + if (r_rot) *r_rot = mb->rot; break; } default: @@ -2780,7 +2760,7 @@ int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, * Test a bounding box for ray intersection * assumes the ray is already local to the boundbox space */ -int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]) +int BKE_boundbox_ray_hit_check(struct BoundBox *bb, float ray_start[3], float ray_normal[3]) { static int triangle_indexes[12][3] = {{0, 1, 2}, {0, 2, 3}, {3, 2, 6}, {3, 6, 7}, @@ -2811,7 +2791,7 @@ static int pc_cmp(void *a, void *b) else return 0; } -int object_insert_ptcache(Object *ob) +int BKE_object_insert_ptcache(Object *ob) { LinkData *link = NULL; int i = 0; @@ -2970,7 +2950,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int return kb; } -KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix) +KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix) { switch (ob->type) { case OB_MESH: @@ -2988,7 +2968,7 @@ KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, in /* most important if this is modified it should _always_ return True, in certain * cases false positives are hard to avoid (shape keys for example) */ -int object_is_modified(Scene *scene, Object *ob) +int BKE_object_is_modified(Scene *scene, Object *ob) { int flag= 0; @@ -3016,7 +2996,7 @@ int object_is_modified(Scene *scene, Object *ob) /* test if object is affected by deforming modifiers (for motion blur). again * most important is to avoid false positives, this is to skip computations * and we can still if there was actual deformation afterwards */ -int object_is_deform_modified(Scene *scene, Object *ob) +int BKE_object_is_deform_modified(Scene *scene, Object *ob) { ModifierData *md; int flag= 0; @@ -3046,7 +3026,7 @@ static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UN if (*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; } -void object_relink(Object *ob) +void BKE_object_relink(Object *ob) { if (ob->id.lib) return; @@ -3069,7 +3049,7 @@ void object_relink(Object *ob) ID_NEW(ob->proxy_group); } -MovieClip *object_get_movieclip(Scene *scene, Object *ob, int use_default) +MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, int use_default) { MovieClip *clip= use_default ? scene->clip : NULL; bConstraint *con= ob->constraints.first, *scon= NULL; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1a1ae8e949c..7b2cb147597 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -369,7 +369,7 @@ static void fluid_free_settings(SPHFluidSettings *fluid) MEM_freeN(fluid); } -void psys_free_settings(ParticleSettings *part) +void BKE_particlesettings_free(ParticleSettings *part) { MTex *mtex; int a; @@ -3610,19 +3610,19 @@ ParticleSettings *psys_new_settings(const char *name, Main *main) if (main==NULL) main = G.main; - part= alloc_libblock(&main->particle, ID_PA, name); + part= BKE_libblock_alloc(&main->particle, ID_PA, name); default_particle_settings(part); return part; } -ParticleSettings *psys_copy_settings(ParticleSettings *part) +ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part) { ParticleSettings *partn; int a; - partn= copy_libblock(&part->id); + partn= BKE_libblock_copy(&part->id); partn->pd= MEM_dupallocN(part->pd); partn->pd2= MEM_dupallocN(part->pd2); partn->effector_weights= MEM_dupallocN(part->effector_weights); @@ -3653,7 +3653,7 @@ static void expand_local_particlesettings(ParticleSettings *part) } } -void make_local_particlesettings(ParticleSettings *part) +void BKE_particlesettings_make_local(ParticleSettings *part) { Main *bmain= G.main; Object *ob; @@ -3687,7 +3687,7 @@ void make_local_particlesettings(ParticleSettings *part) expand_local_particlesettings(part); } else if (is_local && is_lib) { - ParticleSettings *part_new= psys_copy_settings(part); + ParticleSettings *part_new= BKE_particlesettings_copy(part); part_new->id.us= 0; /* Remap paths of new ID using old library as base. */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a4d61cea3fb..63db4d5e854 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1854,7 +1854,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, ob = ob->parent; } ob = sim->ob; - where_is_object_time(sim->scene, ob, pa->time); + BKE_object_where_is_calc_time(sim->scene, ob, pa->time); psys->flag |= PSYS_OB_ANIM_RESTORE; } @@ -4612,7 +4612,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) ob = ob->parent; } ob = sim.ob; - where_is_object_time(scene, ob, cfra); + BKE_object_where_is_calc_time(scene, ob, cfra); psys->flag &= ~PSYS_OB_ANIM_RESTORE; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 1e80f1e6d1e..b24007ec491 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1122,7 +1122,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p if (do_ext) { if (pid->cache->index < 0) - pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob); + pid->cache->index = pid->stack_index = BKE_object_insert_ptcache(pid->ob); if (pid->cache->flag & PTCACHE_EXTERNAL) { if (pid->cache->index >= 0) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index c66aa375a13..6c21b462a7a 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -131,7 +131,7 @@ Scene *copy_scene(Scene *sce, int type) MEM_freeN(scen->toolsettings); } else { - scen= copy_libblock(&sce->id); + scen= BKE_libblock_copy(&sce->id); BLI_duplicatelist(&(scen->base), &(sce->base)); clear_id_newpoins(); @@ -229,7 +229,7 @@ Scene *copy_scene(Scene *sce, int type) BKE_copy_animdata_id_action((ID *)scen); if (scen->world) { id_us_plus((ID *)scen->world); - scen->world= copy_world(scen->world); + scen->world= BKE_world_copy(scen->world); BKE_copy_animdata_id_action((ID *)scen->world); } @@ -244,7 +244,7 @@ Scene *copy_scene(Scene *sce, int type) } /* do not free scene itself */ -void free_scene(Scene *sce) +void BKE_scene_free(Scene *sce) { Base *base; @@ -339,7 +339,7 @@ Scene *add_scene(const char *name) ParticleEditSettings *pset; int a; - sce= alloc_libblock(&bmain->scene, ID_SCE, name); + sce= BKE_libblock_alloc(&bmain->scene, ID_SCE, name); sce->lay= sce->layact= 1; sce->r.mode= R_GAMMA|R_OSA|R_SHADOW|R_SSS|R_ENVMAP|R_RAYTRACE; @@ -647,7 +647,7 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) if (sc->scene == sce) sc->scene= newsce; - free_libblock(&bmain->scene, sce); + BKE_libblock_free(&bmain->scene, sce); } /* used by metaballs @@ -987,7 +987,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen for (base= scene->base.first; base; base= base->next) { Object *ob= base->object; - object_handle_update(scene_parent, ob); + BKE_object_handle_update(scene_parent, ob); if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); @@ -1080,7 +1080,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) BKE_animsys_evaluate_all_animation(bmain, sce, ctime); /*...done with recusrive funcs */ - /* object_handle_update() on all objects, groups and sets */ + /* BKE_object_handle_update() on all objects, groups and sets */ scene_update_tagged_recursive(bmain, sce, sce); /* notify editors and python about recalc */ @@ -1215,3 +1215,22 @@ int scene_use_new_shading_nodes(Scene *scene) return (type && type->flag & RE_USE_SHADING_NODES); } +void copy_baseflags(struct Scene *scene) +{ + Base *base= scene->base.first; + + while (base) { + base->object->flag= base->flag; + base= base->next; + } +} + +void copy_objectflags(struct Scene *scene) +{ + Base *base= scene->base.first; + + while (base) { + base->flag= base->object->flag; + base= base->next; + } +} diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index f69495483ea..8e380c3674f 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -297,7 +297,7 @@ void BKE_screen_area_free(ScrArea *sa) } /* don't free screen itself */ -void free_screen(bScreen *sc) +void BKE_screen_free(bScreen *sc) { ScrArea *sa, *san; ARegion *ar; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 28ce95ea8d1..da73491eaa3 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -89,21 +89,21 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) while (len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') len--; - sound = alloc_libblock(&bmain->sound, ID_SO, filename+len); + sound = BKE_libblock_alloc(&bmain->sound, ID_SO, filename+len); BLI_strncpy(sound->name, filename, FILE_MAX); // XXX unused currently sound->type = SOUND_TYPE_FILE; sound_load(bmain, sound); if (!sound->playback_handle) { - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); sound = NULL; } return sound; } -void sound_free(struct bSound* sound) +void BKE_sound_free(struct bSound* sound) { if (sound->packedfile) { freePackedFile(sound->packedfile); @@ -231,7 +231,7 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) strcpy(name, "buf_"); strcpy(name + 4, source->id.name); - sound = alloc_libblock(&bmain->sound, ID_SO, name); + sound = BKE_libblock_alloc(&bmain->sound, ID_SO, name); sound->child_sound = source; sound->type = SOUND_TYPE_BUFFER; @@ -240,7 +240,7 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) if (!sound->playback_handle) { - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); sound = NULL; } @@ -255,7 +255,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa strcpy(name, "lim_"); strcpy(name + 4, source->id.name); - sound = alloc_libblock(&bmain->sound, ID_SO, name); + sound = BKE_libblock_alloc(&bmain->sound, ID_SO, name); sound->child_sound = source; sound->start = start; @@ -266,7 +266,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa if (!sound->playback_handle) { - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); sound = NULL; } @@ -277,9 +277,9 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa void sound_delete(struct Main *bmain, struct bSound* sound) { if (sound) { - sound_free(sound); + BKE_sound_free(sound); - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); } } diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index 5466630f621..d3c38221c00 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -47,7 +47,7 @@ void *add_speaker(const char *name) { Speaker *spk; - spk= alloc_libblock(&G.main->speaker, ID_SPK, name); + spk= BKE_libblock_alloc(&G.main->speaker, ID_SPK, name); spk->attenuation = 1.0f; spk->cone_angle_inner = 360.0f; @@ -65,11 +65,11 @@ void *add_speaker(const char *name) return spk; } -Speaker *copy_speaker(Speaker *spk) +Speaker *BKE_speaker_copy(Speaker *spk) { Speaker *spkn; - spkn= copy_libblock(&spk->id); + spkn= BKE_libblock_copy(&spk->id); if (spkn->sound) spkn->sound->id.us++; @@ -106,7 +106,7 @@ void make_local_speaker(Speaker *spk) id_clear_lib_data(bmain, &spk->id); } else if (is_local && is_lib) { - Speaker *spk_new= copy_speaker(spk); + Speaker *spk_new= BKE_speaker_copy(spk); spk_new->id.us= 0; /* Remap paths of new ID using old library as base. */ @@ -127,7 +127,7 @@ void make_local_speaker(Speaker *spk) } } -void free_speaker(Speaker *spk) +void BKE_speaker_free(Speaker *spk) { if (spk->sound) spk->sound->id.us--; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index d67c5fb3698..bd925faf847 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -160,7 +160,7 @@ static void init_undo_text(Text *text) text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); } -void free_text(Text *text) +void BKE_text_free(Text *text) { TextLine *tmp; @@ -186,7 +186,7 @@ Text *add_empty_text(const char *name) Text *ta; TextLine *tmp; - ta= alloc_libblock(&bmain->text, ID_TXT, name); + ta= BKE_libblock_alloc(&bmain->text, ID_TXT, name); ta->id.us= 1; ta->name= NULL; @@ -391,7 +391,7 @@ Text *add_text(const char *file, const char *relpath) fp= BLI_fopen(str, "r"); if (fp==NULL) return NULL; - ta= alloc_libblock(&bmain->text, ID_TXT, BLI_path_basename(str)); + ta= BKE_libblock_alloc(&bmain->text, ID_TXT, BLI_path_basename(str)); ta->id.us= 1; ta->lines.first= ta->lines.last= NULL; @@ -473,12 +473,12 @@ Text *add_text(const char *file, const char *relpath) return ta; } -Text *copy_text(Text *ta) +Text *BKE_text_copy(Text *ta) { Text *tan; TextLine *line, *tmp; - tan= copy_libblock(&ta->id); + tan= BKE_libblock_copy(&ta->id); /* file name can be NULL */ if (ta->name) { @@ -521,7 +521,7 @@ Text *copy_text(Text *ta) return tan; } -void unlink_text(Main *bmain, Text *text) +void BKE_text_unlink(Main *bmain, Text *text) { bScreen *scr; ScrArea *area; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9200b1dca18..5ba3e95154b 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -547,7 +547,7 @@ int colorband_element_remove(struct ColorBand *coba, int index) /* ******************* TEX ************************ */ -void free_texture(Tex *tex) +void BKE_texture_free(Tex *tex) { free_plugin_tex(tex->plugin); @@ -693,7 +693,7 @@ Tex *add_texture(const char *name) Main *bmain= G.main; Tex *tex; - tex= alloc_libblock(&bmain->tex, ID_TE, name); + tex= BKE_libblock_alloc(&bmain->tex, ID_TE, name); default_tex(tex); @@ -824,11 +824,11 @@ MTex *add_mtex_id(ID *id, int slot) /* ------------------------------------------------------------------------- */ -Tex *copy_texture(Tex *tex) +Tex *BKE_texture_copy(Tex *tex) { Tex *texn; - texn= copy_libblock(&tex->id); + texn= BKE_libblock_copy(&tex->id); if (texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); else texn->ima= NULL; @@ -859,10 +859,10 @@ Tex *localize_texture(Tex *tex) { Tex *texn; - texn= copy_libblock(&tex->id); + texn= BKE_libblock_copy(&tex->id); BLI_remlink(&G.main->tex, texn); - /* image texture: free_texture also doesn't decrease */ + /* image texture: BKE_texture_free also doesn't decrease */ if (texn->plugin) { texn->plugin= MEM_dupallocN(texn->plugin); @@ -978,7 +978,7 @@ void make_local_texture(Tex *tex) extern_local_texture(tex); } else if (is_local && is_lib) { - Tex *tex_new= copy_texture(tex); + Tex *tex_new= BKE_texture_copy(tex); tex_new->id.us= 0; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index f4335862629..144fd9ddb20 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2127,7 +2127,7 @@ void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4]) } if (ob) - where_is_object_mat(scene, ob, mat); + BKE_object_where_is_calc_mat4(scene, ob, mat); else unit_m4(mat); } diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 07a83da3d8c..f50a655236f 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -51,7 +51,7 @@ #include "BKE_node.h" #include "BKE_world.h" -void free_world(World *wrld) +void BKE_world_free(World *wrld) { MTex *mtex; int a; @@ -81,7 +81,7 @@ World *add_world(const char *name) Main *bmain= G.main; World *wrld; - wrld= alloc_libblock(&bmain->world, ID_WO, name); + wrld= BKE_libblock_alloc(&bmain->world, ID_WO, name); wrld->horr= 0.05f; wrld->horg= 0.05f; @@ -113,16 +113,16 @@ World *add_world(const char *name) return wrld; } -World *copy_world(World *wrld) +World *BKE_world_copy(World *wrld) { World *wrldn; int a; - wrldn= copy_libblock(&wrld->id); + wrldn= BKE_libblock_copy(&wrld->id); for (a=0; amtex[a]) { - wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copy_world"); + wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "BKE_world_copy"); memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex)); id_us_plus((ID *)wrldn->mtex[a]->tex); } @@ -142,7 +142,7 @@ World *localize_world(World *wrld) World *wrldn; int a; - wrldn= copy_libblock(&wrld->id); + wrldn= BKE_libblock_copy(&wrld->id); BLI_remlink(&G.main->world, wrldn); for (a=0; aid); } else if (is_local && is_lib) { - World *wrld_new= copy_world(wrld); + World *wrld_new= BKE_world_copy(wrld); wrld_new->id.us= 0; /* Remap paths of new ID using old library as base. */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c0ae6415fe1..475a05339f5 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -558,7 +558,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepat m= MEM_callocN(sizeof(Main), "find_main"); BLI_addtail(mainlist, m); - lib= alloc_libblock(&m->library, ID_LI, "lib"); + lib= BKE_libblock_alloc(&m->library, ID_LI, "lib"); BLI_strncpy(lib->name, filepath, sizeof(lib->name)); BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath)); @@ -8605,8 +8605,8 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) if (((group->id.flag & LIB_INDIRECT)==0 && (group->id.flag & LIB_PRE_EXISTING)==0)) { Base *base; - /* add_object(...) messes with the selection */ - Object *ob= add_only_object(OB_EMPTY, group->id.name+2); + /* BKE_object_add(...) messes with the selection */ + Object *ob= BKE_object_add_only_object(OB_EMPTY, group->id.name+2); ob->type= OB_EMPTY; ob->lay= scene->lay; diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 0659a42c26d..212ec33e626 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -181,7 +181,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, * Internal Copy function. */ -static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) +static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) { BMVert *v = NULL, *v2; @@ -326,7 +326,7 @@ void bmo_dupe_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, dupeop, "geom", BM_ALL, DUPE_INPUT); /* use the internal copy function */ - copy_mesh(dupeop, bm, bm2); + BKE_mesh_copy(dupeop, bm, bm2); /* Output */ /* First copy the input buffers to output buffers - original data */ diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index a72d51721ce..34f7efa9de0 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -324,7 +324,7 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob) TransformReader::get_node_mat(mat, node, &uid_animated_map, ob); if (ob) { copy_m4_m4(ob->obmat, mat); - object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); } } @@ -1800,7 +1800,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No job->parsubstr[0] = 0; } - where_is_object(scene, job); + BKE_object_where_is_calc(scene, job); // after parenting and layer change DAG_scene_sort(CTX_data_main(C), scene); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 1d315b6ea06..9216d7fa30e 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -230,7 +230,7 @@ void DocumentImporter::finish() Base *base = object_in_scene(ob, sce); if (base) { BLI_remlink(&sce->base, base); - free_libblock_us(&G.main->object, base->object); + BKE_libblock_free_us(&G.main->object, base->object); if (sce->basact==base) sce->basact= NULL; MEM_freeN(base); @@ -312,7 +312,7 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera ob->data = cam; old_cam->id.us--; if (old_cam->id.us == 0) - free_libblock(&G.main->camera, old_cam); + BKE_libblock_free(&G.main->camera, old_cam); return ob; } @@ -330,7 +330,7 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce ob->data = la; old_lamp->id.us--; if (old_lamp->id.us == 0) - free_libblock(&G.main->lamp, old_lamp); + BKE_libblock_free(&G.main->lamp, old_lamp); return ob; } @@ -338,7 +338,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod { fprintf(stderr, "create under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL); - Object *obn = copy_object(source_ob); + Object *obn = BKE_object_copy(source_ob); obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; scene_add_base(sce, obn); @@ -359,7 +359,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod } // calc new matrix and apply mult_m4_m4m4(obn->obmat, obn->obmat, mat); - object_apply_mat4(obn, obn->obmat, 0, 0); + BKE_object_apply_mat4(obn, obn->obmat, 0, 0); } } else { diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index ba6be75e051..c20975145ac 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -914,7 +914,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta set_mesh(ob, uid_mesh_map[*geom_uid]); - if (old_mesh->id.us == 0) free_libblock(&G.main->mesh, old_mesh); + if (old_mesh->id.us == 0) BKE_libblock_free(&G.main->mesh, old_mesh); char layername[100]; layername[0] = '\0'; diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 0727ec21682..d807b049152 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -221,7 +221,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapobject = ob_arm; copy_m4_m4(ob->obmat, bind_shape_matrix); - object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); #if 1 bc_set_parent(ob, ob_arm, C); #else @@ -229,7 +229,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapparent = ob_arm; ob->partype = PAROBJECT; - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA; diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 4974566bba1..fbd36cd6613 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -70,7 +70,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob) copy_v3_v3(scale, ob->size); ob->size[0] = ob->size[1] = ob->size[2] = 1.0f; - object_to_mat4(ob, C); + BKE_object_to_mat4(ob, C); copy_v3_v3(ob->size, scale); mul_serie_m4(tmat, ob->parent->obmat, ob->parentinv, C, NULL, NULL, NULL, NULL, NULL); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index bd0f82fb0ac..d7ea74b7b04 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -88,7 +88,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) if (is_parent_space) { float mat[4][4]; // calc par->obmat - where_is_object(sce, par); + BKE_object_where_is_calc(sce, par); // move child obmat into world space mult_m4_m4m4(mat, par->obmat, ob->obmat); @@ -96,10 +96,10 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) } // apply child obmat (i.e. decompose it into rot/loc/size) - object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); // compute parentinv - what_does_parent(sce, ob, &workob); + BKE_object_workob_calc_parent(sce, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; @@ -114,9 +114,9 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) Object *bc_add_object(Scene *scene, int type, const char *name) { - Object *ob = add_only_object(type, name); + Object *ob = BKE_object_add_only_object(type, name); - ob->data= add_obdata_from_type(type); + ob->data= BKE_object_obdata_add_from_type(type); ob->lay= scene->lay; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index a2e95622bcf..5c43ba6e67f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -632,9 +632,9 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob) /* apply current transform from parent (not yet destroyed), * then calculate new parent inverse matrix */ - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } } @@ -644,7 +644,7 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob) static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object bArmature *arm= get_armature(ob); bPose *pose; bPoseChannel *pchan; @@ -653,7 +653,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) /* don't check if editmode (should be done by caller) */ if (ob->type!=OB_ARMATURE) return OPERATOR_CANCELLED; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata(); return OPERATOR_CANCELLED; } @@ -746,7 +746,7 @@ void POSE_OT_armature_apply(wmOperatorType *ot) /* set the current pose as the restpose */ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object /* don't check if editmode (should be done by caller) */ if (ob->type!=OB_ARMATURE) @@ -5088,7 +5088,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, void (*clear_func)(bPoseChannel*), const char default_ksName[]) { Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); short autokey = 0; /* sanity checks */ @@ -5292,7 +5292,7 @@ void POSE_OT_select_all(wmOperatorType *ot) static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan, *parent; /* Determine if there is an active bone */ @@ -5368,7 +5368,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr /* active object is armature in posemode, poll checked */ static int pose_hide_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm= ob->data; if (RNA_boolean_get(op->ptr, "unselected")) @@ -5417,7 +5417,7 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) /* active object is armature in posemode, poll checked */ static int pose_reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm= ob->data; bone_looper(ob, arm->bonebase.first, NULL, show_pose_bone_cb); @@ -5932,7 +5932,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) ED_armature_edit_free(obedit); } - dst = add_object(scene, OB_ARMATURE); + dst = BKE_object_add(scene, OB_ARMATURE); ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot obedit= scene->basact->object; @@ -5941,7 +5941,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) mat4_to_eul(dst->rot, src->obmat); mat4_to_size(dst->size, src->obmat); - where_is_object(scene, obedit); + BKE_object_where_is_calc(scene, obedit); ED_armature_to_edit(obedit); diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 40dc0a7cd36..f33dce00f8d 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -130,7 +130,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode) /* get info from context */ pso->scene= CTX_data_scene(C); - pso->ob= object_pose_armature_get(CTX_data_active_object(C)); + pso->ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); pso->arm= (pso->ob)? pso->ob->data : NULL; pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */ pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */ @@ -1165,7 +1165,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, static int pose_propagate_exec (bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bAction *act= (ob && ob->adt)? ob->adt->action : NULL; ListBase pflinks = {NULL, NULL}; diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 8791a345489..3b01ba20dd5 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -174,7 +174,7 @@ static Object *get_poselib_object (bContext *C) if (sa && (sa->spacetype == SPACE_BUTS)) return ED_object_context(C); else - return object_pose_armature_get(CTX_data_active_object(C)); + return BKE_object_pose_armature_get(CTX_data_active_object(C)); } /* Poll callback for operators that require existing PoseLib data (with poses) to work */ @@ -650,7 +650,7 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) static int poselib_rename_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bAction *act= (ob) ? ob->poselib : NULL; TimeMarker *marker; char newname[64]; diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 8a2af14e6f3..95e7a845a78 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -200,7 +200,7 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) /* show popup to determine settings */ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -227,7 +227,7 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNU */ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); Scene *scene= CTX_data_scene(C); if (ELEM(NULL, ob, ob->pose)) @@ -320,7 +320,7 @@ static void ED_pose_clear_paths(Object *ob) /* operator callback for this */ static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ELEM(NULL, ob, ob->pose)) @@ -354,7 +354,7 @@ void POSE_OT_paths_clear(wmOperatorType *ot) static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bConstraint *con; int found= 0; @@ -414,7 +414,7 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot) static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm= ob->data; Bone *curbone, *pabone, *chbone; int direction = RNA_enum_get(op->ptr, "direction"); @@ -674,7 +674,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) static int pose_select_grouped_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); short extend= RNA_boolean_get(op->ptr, "extend"); short changed = 0; @@ -741,7 +741,7 @@ void POSE_OT_select_grouped(wmOperatorType *ot) static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) { Object *ob_act= CTX_data_active_object(C); - Object *ob= object_pose_armature_get(ob_act); + Object *ob= BKE_object_pose_armature_get(ob_act); if (ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; @@ -1163,7 +1163,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s static int pose_copy_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* sanity checking */ if (ELEM(NULL, ob, ob->pose)) { @@ -1201,7 +1201,7 @@ void POSE_OT_copy(wmOperatorType *ot) static int pose_paste_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); Scene *scene= CTX_data_scene(C); bPoseChannel *chan; int flip= RNA_boolean_get(op->ptr, "flipped"); @@ -1284,7 +1284,7 @@ static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op)) if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) @@ -1324,7 +1324,7 @@ static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op)) if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) @@ -1372,7 +1372,7 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1421,7 +1421,7 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op) if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1484,7 +1484,7 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *UNUSED(op)) if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1719,7 +1719,7 @@ static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op)) if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1757,7 +1757,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op)) if (sa->spacetype == SPACE_BUTS) ob= ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1790,7 +1790,7 @@ void POSE_OT_group_deselect(wmOperatorType *ot) static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; /* paranoia checks */ @@ -1835,7 +1835,7 @@ void POSE_OT_flip_names(wmOperatorType *ot) static int pose_autoside_names_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; char newname[MAXBONENAME]; short axis= RNA_enum_get(op->ptr, "axis"); @@ -1939,7 +1939,7 @@ static int pose_armature_layers_showall_poll (bContext *C) static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm = (ob)? ob->data : NULL; PointerRNA ptr; int maxLayers = (RNA_boolean_get(op->ptr, "all"))? 32 : 16; @@ -1991,7 +1991,7 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot) /* Present a popup to get the layers that should be used */ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm= (ob)? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2012,7 +2012,7 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev /* Set the visible layers for the active armature (edit and pose modes) */ static int pose_armature_layers_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2102,7 +2102,7 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) /* Set the visible layers for the active armature (edit and pose modes) */ static int pose_bone_layers_exec (bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2225,7 +2225,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); /* loop through all selected pchans, flipping and keying (as needed) */ diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 0a976e6ed6b..22f1cd578ac 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -437,12 +437,12 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float int nchars = 0, a; float rot[3] = {0.f, 0.f, 0.f}; - obedit= add_object(scene, OB_FONT); + obedit= BKE_object_add(scene, OB_FONT); base= scene->basact; ED_object_base_init_transform(C, base, NULL, rot); /* seems to assume view align ? TODO - look into this, could be an operator option */ - where_is_object(scene, obedit); + BKE_object_where_is_calc(scene, obedit); obedit->loc[0] += offset[0]; obedit->loc[1] += offset[1]; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 34a95cd89bf..990b1acd321 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -568,7 +568,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* init the curve object (remove rotation and get curve data from it) * - must clear transforms set on object, as those skew our results */ - ob= add_object(scene, OB_CURVE); + ob= BKE_object_add(scene, OB_CURVE); zero_v3(ob->loc); zero_v3(ob->rot); cu= ob->data; diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 36624b88a9f..916b4fff561 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -131,7 +131,7 @@ void gpencil_undo_push(bGPdata *gpd) while (undo_node) { bGPundonode *next_node= undo_node->next; - free_gpencil_data(undo_node->gpd); + BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); BLI_freelinkN(&undo_nodes, undo_node); @@ -154,7 +154,7 @@ void gpencil_undo_finish(void) bGPundonode *undo_node= undo_nodes.first; while (undo_node) { - free_gpencil_data(undo_node->gpd); + BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); undo_node= undo_node->next; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bc6753be557..ee61b2a3141 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -835,7 +835,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { /* only here obdata, the rest of modifiers is ob level */ - uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + uiBlockSetButLock(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if (md->type == eModifierType_ParticleSystem) { ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 96cfd95b96a..0f300cc375e 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -485,7 +485,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe * automatically building this data if invalid. Or something. */ // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - object_handle_update(scene, obedit); + BKE_object_handle_update(scene, obedit); /* individual faces? */ // BIF_TransformSetUndo("Extrude"); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index a17f335091b..faf5bbc6bfc 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -545,11 +545,11 @@ static void free_undo(void *me_v) { Mesh *me = me_v; if (me->key) { - free_key(me->key); + BKE_key_free(me->key); MEM_freeN(me->key); } - free_mesh(me, FALSE); + BKE_mesh_free(me, FALSE); MEM_freeN(me); } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index e41807787f1..aa89eaa0c6d 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -182,7 +182,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) */ if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ - nkey = copy_key(key); + nkey = BKE_key_copy(key); /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { @@ -524,13 +524,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if (nkey->ipo) { - free_ipo(nkey->ipo); + BKE_ipo_free(nkey->ipo); BLI_remlink(&bmain->ipo, nkey->ipo); MEM_freeN(nkey->ipo); } #endif - free_key(nkey); + BKE_key_free(nkey); BLI_remlink(&bmain->key, nkey); MEM_freeN(nkey); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d030e61952e..d58b71f54e5 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -147,7 +147,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *r if (rot) copy_v3_v3(ob->rot, rot); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); } /* uses context to figure out transform for primitive */ @@ -325,7 +325,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ - ob = add_object(scene, type); + ob = BKE_object_add(scene, type); BASACT->lay = ob->lay = layer; /* editor level activate, notifiers */ ED_base_object_activate(C, BASACT); @@ -891,7 +891,7 @@ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) { DAG_id_type_tag(bmain, ID_OB); BLI_remlink(&scene->base, base); - free_libblock_us(&bmain->object, base->object); + BKE_libblock_free_us(&bmain->object, base->object); if (scene->basact == base) scene->basact = NULL; MEM_freeN(base); } @@ -975,7 +975,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* XXX check object pointers */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - object_relink(ob); + BKE_object_relink(ob); } CTX_DATA_END; @@ -993,7 +993,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) id = (ID *)ma->mtex[a]->tex; if (id) { ID_NEW_US(ma->mtex[a]->tex) - else ma->mtex[a]->tex = copy_texture(ma->mtex[a]->tex); + else ma->mtex[a]->tex = BKE_texture_copy(ma->mtex[a]->tex); id->us--; } } @@ -1073,7 +1073,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, for (dob = lb->first; dob; dob = dob->next) { Base *basen; - Object *ob = copy_object(dob->ob); + Object *ob = BKE_object_copy(dob->ob); /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ @@ -1097,7 +1097,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, ob->lay = base->lay; copy_m4_m4(ob->obmat, dob->mat); - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); if (dupli_gh) BLI_ghash_insert(dupli_gh, dob, ob); @@ -1143,7 +1143,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* note, this may be the parent of other objects, but it should * still work out ok */ - object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + BKE_object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); /* to set ob_dst->orig and in case theres any other discrepicies */ DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); @@ -1162,7 +1162,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* similer to the code above, see comments */ invert_m4_m4(ob_dst->parentinv, dob->mat); - object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + BKE_object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); @@ -1244,7 +1244,7 @@ static void curvetomesh(Scene *scene, Object *ob) nurbs_to_mesh(ob); /* also does users */ if (ob->type == OB_MESH) - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); } static int convert_poll(bContext *C) @@ -1265,7 +1265,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) ob = base->object; } - obn = copy_object(ob); + obn = BKE_object_copy(ob); obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; basen = MEM_mallocN(sizeof(Base), "duplibase"); @@ -1325,7 +1325,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* When 2 objects with linked data are selected, converting both * would keep modifiers on all but the converted object [#26003] */ if (ob->type == OB_MESH) { - object_free_modifiers(ob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(ob); /* after derivedmesh calls! */ } } } @@ -1341,7 +1341,7 @@ static int convert_exec(bContext *C, wmOperator *op) me->id.us--; /* make a new copy of the mesh */ - newob->data = copy_mesh(me); + newob->data = BKE_mesh_copy(me); } else { newob = ob; @@ -1350,7 +1350,7 @@ static int convert_exec(bContext *C, wmOperator *op) mesh_to_curve(scene, newob); if (newob->type == OB_CURVE) - object_free_modifiers(newob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ ob->flag |= OB_DONE; @@ -1364,7 +1364,7 @@ static int convert_exec(bContext *C, wmOperator *op) me->id.us--; /* make a new copy of the mesh */ - newob->data = copy_mesh(me); + newob->data = BKE_mesh_copy(me); } else { newob = ob; @@ -1383,7 +1383,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* re-tessellation is called by DM_to_mesh */ dm->release(dm); - object_free_modifiers(newob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_FONT) { ob->flag |= OB_DONE; @@ -1631,7 +1631,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base ; /* nothing? */ } else { - obn = copy_object(ob); + obn = BKE_object_copy(ob); obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; basen = MEM_mallocN(sizeof(Base), "duplibase"); @@ -1657,7 +1657,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *)obn->mat[a]; if (id) { ID_NEW_US(obn->mat[a]) - else obn->mat[a] = copy_material(obn->mat[a]); + else obn->mat[a] = BKE_material_copy(obn->mat[a]); id->us--; if (dupflag & USER_DUP_ACT) { @@ -1672,7 +1672,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *) psys->part; if (id) { ID_NEW_US(psys->part) - else psys->part = psys_copy_settings(psys->part); + else psys->part = BKE_particlesettings_copy(psys->part); if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&psys->part->id); @@ -1691,7 +1691,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_MESH) { ID_NEW_US2(obn->data) else { - obn->data = copy_mesh(obn->data); + obn->data = BKE_mesh_copy(obn->data); if (obn->fluidsimSettings) { obn->fluidsimSettings->orgMesh = (Mesh *)obn->data; @@ -1746,7 +1746,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_LAMP) { ID_NEW_US2(obn->data) else { - obn->data = copy_lamp(obn->data); + obn->data = BKE_lamp_copy(obn->data); didit = 1; } id->us--; @@ -1760,7 +1760,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_ARM) { ID_NEW_US2(obn->data) else { - obn->data = copy_armature(obn->data); + obn->data = BKE_armature_copy(obn->data); armature_rebuild_pose(obn, obn->data); didit = 1; } @@ -1773,7 +1773,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_lattice(obn->data); + obn->data = BKE_lattice_copy(obn->data); didit = 1; } id->us--; @@ -1793,7 +1793,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_speaker(obn->data); + obn->data = BKE_speaker_copy(obn->data); didit = 1; } id->us--; @@ -1832,7 +1832,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *)(*matarar)[a]; if (id) { ID_NEW_US((*matarar)[a]) - else (*matarar)[a] = copy_material((*matarar)[a]); + else (*matarar)[a] = BKE_material_copy((*matarar)[a]); id->us--; } @@ -1863,7 +1863,7 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag ob = basen->object; /* link own references to the newly duplicated data [#26816] */ - object_relink(ob); + BKE_object_relink(ob); set_sca_new_poins_ob(ob); DAG_scene_sort(bmain, scene); @@ -2033,7 +2033,7 @@ static int join_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if (object_data_is_libdata(ob)) { + else if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } @@ -2086,7 +2086,7 @@ static int join_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if (object_data_is_libdata(ob)) { + else if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index e63e0e34934..60ca674bb8a 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -309,7 +309,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) * the constraint is deemed invalid */ /* default IK check ... */ - if (exist_object(data->tar) == 0) { + if (BKE_object_exists_check(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } @@ -320,7 +320,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) } if (data->poletar) { - if (exist_object(data->poletar) == 0) { + if (BKE_object_exists_check(data->poletar) == 0) { data->poletar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } @@ -339,7 +339,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) bPivotConstraint *data = curcon->data; /* target doesn't have to exist, but if it is non-null, it must exist! */ - if (data->tar && exist_object(data->tar) == 0) { + if (data->tar && BKE_object_exists_check(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } @@ -446,7 +446,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) /* disable and clear constraints targets that are incorrect */ for (ct = targets.first; ct; ct = ct->next) { /* general validity checks (for those constraints that need this) */ - if (exist_object(ct->tar) == 0) { + if (BKE_object_exists_check(ct->tar) == 0) { /* object doesn't exist, but constraint requires target */ ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; @@ -774,8 +774,8 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, else if (ob) { Object workob; - /* use what_does_parent to find inverse - just like for normal parenting */ - what_does_parent(scene, ob, &workob); + /* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */ + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(invmat, workob.obmat); } } @@ -1147,7 +1147,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* free constraints for all selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -1413,7 +1413,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o Object *obt; /* add new target object */ - obt = add_object(scene, OB_EMPTY); + obt = BKE_object_add(scene, OB_EMPTY); /* set layers OK */ newbase = BASACT; @@ -1434,7 +1434,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o copy_v3_v3(obt->loc, obact->obmat[3]); } - /* restore, add_object sets active */ + /* restore, BKE_object_add sets active */ BASACT = base; base->flag |= SELECT; @@ -1586,7 +1586,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) /* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { - Object *ob = object_pose_armature_get(ED_object_active_context(C)); + Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C)); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; @@ -1689,7 +1689,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) /* present menu with options + validation for targets to use */ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan = get_active_posechannel(ob); bConstraint *con = NULL; @@ -1773,7 +1773,7 @@ void POSE_OT_ik_add(wmOperatorType *ot) /* remove IK constraints from selected bones */ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only remove IK Constraints */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c669bbfe3b2..a683b1cc0ae 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -427,7 +427,7 @@ void ED_object_enter_editmode(bContext *C, int flag) ob = base->object; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { error_libdata(); return; } @@ -465,11 +465,11 @@ void ED_object_enter_editmode(bContext *C, int flag) bArmature *arm = base->object->data; if (!arm) return; /* - * The function object_data_is_libdata make a problem here, the + * The function BKE_object_obdata_is_libdata make a problem here, the * check for ob->proxy return 0 and let blender enter to edit mode * this causes a crash when you try leave the edit mode. * The problem is that i can't remove the ob->proxy check from - * object_data_is_libdata that prevent the bugfix #6614, so + * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so * i add this little hack here. */ if (arm->id.lib) { @@ -783,7 +783,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) return; } else if (event == 24) { - /* moved to object_link_modifiers */ + /* moved to BKE_object_link_modifiers */ /* copymenu_modifiers(bmain, scene, v3d, ob); */ return; } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 2cfefa61a18..6a41cb93e19 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -417,13 +417,13 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) Base *base, *basedit; Object *ob; - ob = add_object(scene, OB_EMPTY); + ob = BKE_object_add(scene, OB_EMPTY); basedit = object_in_scene(obedit, scene); base = object_in_scene(ob, scene); base->lay = ob->lay = obedit->lay; - /* icky, add_object sets new base as active. + /* icky, BKE_object_add sets new base as active. * so set it back to the original edit object */ scene->basact = basedit; @@ -469,7 +469,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m4_m4(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 281ca7e59b6..b4207efc21f 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -368,7 +368,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * if (totvert == 0) return 0; /* add new mesh */ - obn = add_object(scene, OB_MESH); + obn = BKE_object_add(scene, OB_MESH); me = obn->data; me->totvert = totvert; @@ -661,7 +661,7 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) if (mti->flags & eModifierTypeFlag_NoUserAdd) continue; - if (!object_support_modifier_type(ob, md_item->value)) + if (!BKE_object_support_modifier_type_check(ob, md_item->value)) continue; } else { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 4678416e1c9..95c9773eabd 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -235,7 +235,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) ob->par3 = v3 - 1; /* inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { @@ -243,7 +243,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) ob->par1 = v1 - 1; /* inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } } @@ -335,24 +335,24 @@ static int make_proxy_exec(bContext *C, wmOperator *op) char name[MAX_ID_NAME + 4]; /* Add new object for the proxy */ - newob = add_object(scene, OB_EMPTY); + newob = BKE_object_add(scene, OB_EMPTY); BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); rename_id(&newob->id, name); /* set layers OK */ - newbase = BASACT; /* add_object sets active... */ + newbase = BASACT; /* BKE_object_add sets active... */ newbase->lay = oldbase->lay; newob->lay = newbase->lay; - /* remove base, leave user count of object, it gets linked in object_make_proxy */ + /* remove base, leave user count of object, it gets linked in BKE_object_make_proxy */ if (gob == NULL) { BLI_remlink(&scene->base, oldbase); MEM_freeN(oldbase); } - object_make_proxy(newob, ob, gob); + BKE_object_make_proxy(newob, ob, gob); /* depsgraph flushes are needed for the new data */ DAG_scene_sort(bmain, scene); @@ -439,7 +439,7 @@ void ED_object_parent_clear(bContext *C, int type) } else if (type == 1) { ob->parent = NULL; - object_apply_mat4(ob, ob->obmat, TRUE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if (type == 2) unit_m4(ob->parentinv); @@ -571,7 +571,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object Object workob; /* apply transformation of previous parenting */ - /* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ + /* BKE_object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ /* set the parent (except for follow-path constraint option) */ if (partype != PAR_PATH_CONST) { @@ -650,13 +650,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } /* get corrected inverse */ ob->partype = PAROBJECT; - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { /* calculate inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } @@ -814,7 +814,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->parent) { if (ob->partype & PARSLOW) { ob->partype -= PARSLOW; - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); ob->partype |= PARSLOW; ob->recalc |= OB_RECALC_OB; } @@ -920,7 +920,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } if (type == 1) - object_apply_mat4(ob, ob->obmat, TRUE, TRUE); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, TRUE); } CTX_DATA_END; @@ -1313,7 +1313,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - object_link_modifiers(obt, ob); + BKE_object_link_modifiers(obt, ob); obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; break; } @@ -1401,7 +1401,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) if ( (base->flag & flag) == flag) { if (ob->id.lib == NULL && ob->id.us > 1) { /* base gets copy of object */ - obn = copy_object(ob); + obn = BKE_object_copy(ob); base->object = obn; ob->id.us--; } @@ -1413,7 +1413,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) /* object pointers */ for (base = FIRSTBASE; base; base = base->next) { - object_relink(base->object); + BKE_object_relink(base->object); } set_sca_new_poins(); @@ -1447,7 +1447,7 @@ static void new_id_matar(Material **matar, int totcol) id->us--; } else if (id->us > 1) { - matar[a] = copy_material(matar[a]); + matar[a] = BKE_material_copy(matar[a]); id->us--; id->newid = (ID *)matar[a]; } @@ -1478,7 +1478,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) switch (ob->type) { case OB_LAMP: - ob->data = la = copy_lamp(ob->data); + ob->data = la = BKE_lamp_copy(ob->data); for (a = 0; a < MAX_MTEX; a++) { if (la->mtex[a]) { ID_NEW(la->mtex[a]->object); @@ -1489,7 +1489,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ob->data = BKE_camera_copy(ob->data); break; case OB_MESH: - ob->data = copy_mesh(ob->data); + ob->data = BKE_mesh_copy(ob->data); //me= ob->data; //if (me && me->key) // ipo_idnew(me->key->ipo); /* drivers */ @@ -1505,15 +1505,15 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ID_NEW(cu->taperobj); break; case OB_LATTICE: - ob->data = copy_lattice(ob->data); + ob->data = BKE_lattice_copy(ob->data); break; case OB_ARMATURE: ob->recalc |= OB_RECALC_DATA; - ob->data = copy_armature(ob->data); + ob->data = BKE_armature_copy(ob->data); armature_rebuild_pose(ob, ob->data); break; case OB_SPEAKER: - ob->data = copy_speaker(ob->data); + ob->data = BKE_speaker_copy(ob->data); break; default: if (G.debug & G_DEBUG) @@ -1568,7 +1568,7 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) /* do not test for LIB_NEW: this functions guaranteed delivers single_users! */ if (ma->id.us > 1) { - man = copy_material(ma); + man = BKE_material_copy(ma); BKE_copy_animdata_id_action(&man->id); man->id.us = 0; @@ -1579,7 +1579,7 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) { if (tex->id.us > 1) { tex->id.us--; - tex = copy_texture(tex); + tex = BKE_texture_copy(tex); BKE_copy_animdata_id_action(&tex->id); man->mtex[b]->tex = tex; } @@ -1606,7 +1606,7 @@ static void do_single_tex_user(Tex **from) tex->id.us--; } else if (tex->id.us > 1) { - texn = copy_texture(tex); + texn = BKE_texture_copy(tex); BKE_copy_animdata_id_action(&texn->id); tex->id.newid = (ID *)texn; tex->id.us--; diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 5d31bfff99a..df73e435737 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -77,7 +77,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int from_mix) { KeyBlock *kb; - if ((kb = object_insert_shape_key(scene, ob, NULL, from_mix))) { + if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) { Key *key = ob_get_key(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -141,7 +141,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) else if (GS(key->from->name) == ID_CU) ((Curve *)key->from)->key = NULL; else if (GS(key->from->name) == ID_LT) ((Lattice *)key->from)->key = NULL; - free_libblock_us(&(bmain->key), key); + BKE_libblock_free_us(&(bmain->key), key); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index b8a7ce999f1..92dc9b9bd4a 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -370,8 +370,8 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob) /* a change was made, adjust the children to compensate */ for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) { if (ob_child->parent == ob) { - object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); - what_does_parent(scene, ob_child, &workob); + BKE_object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); + BKE_object_workob_calc_parent(scene, ob_child, &workob); invert_m4_m4(ob_child->parentinv, workob.obmat); } } @@ -434,17 +434,17 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* calculate rotation/scale matrix */ if (apply_scale && apply_rot) - object_to_mat3(ob, rsmat); + BKE_object_to_mat3(ob, rsmat); else if (apply_scale) - object_scale_to_mat3(ob, rsmat); + BKE_object_scale_to_mat3(ob, rsmat); else if (apply_rot) { float tmat[3][3], timat[3][3]; /* simple rotation matrix */ - object_rot_to_mat3(ob, rsmat); + BKE_object_rot_to_mat3(ob, rsmat); /* correct for scale, note mul_m3_m3m3 has swapped args! */ - object_scale_to_mat3(ob, tmat); + BKE_object_scale_to_mat3(ob, tmat); invert_m3_m3(timat, tmat); mul_m3_m3m3(rsmat, timat, rsmat); mul_m3_m3m3(rsmat, rsmat, tmat); @@ -460,7 +460,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if (!(apply_scale && apply_rot)) { /* correct for scale and rotation that is still applied */ - object_to_mat3(ob, obmat); + BKE_object_to_mat3(ob, obmat); invert_m3_m3(iobmat, obmat); mul_m3_m3m3(tmat, rsmat, iobmat); mul_m3_v3(tmat, mat[3]); @@ -546,7 +546,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo unit_axis_angle(ob->rotAxis, &ob->rotAngle); } - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { where_is_pose(scene, ob); /* needed for bone parents */ } @@ -573,9 +573,9 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - where_is_object(scene, ob); - object_apply_mat4(ob, ob->obmat, TRUE, TRUE); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, TRUE); + BKE_object_where_is_calc(scene, ob); /* update for any children that may get moved */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -750,7 +750,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else { /* only bounds support */ INIT_MINMAX(min, max); - minmax_object_duplis(scene, ob, min, max); + BKE_object_minmax_dupli(scene, ob, min, max); mid_v3_v3v3(cent, min, max); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); @@ -854,7 +854,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) arm->id.flag |= LIB_DOIT; /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */ - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); where_is_pose(scene, ob); /* needed for bone parents */ ignore_parent_tx(bmain, scene, ob); @@ -893,7 +893,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */ add_v3_v3(ob->loc, centn); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { where_is_pose(scene, ob); /* needed for bone parents */ } @@ -915,7 +915,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ add_v3_v3(ob_other->loc, centn); - where_is_object(scene, ob_other); + BKE_object_where_is_calc(scene, ob_other); if (ob_other->type == OB_ARMATURE) { where_is_pose(scene, ob_other); /* needed for bone parents */ } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7fb5352979d..28f789b5f9e 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -4068,7 +4068,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) } if (!ok) { - minmax_object(ob, min, max); + BKE_object_minmax(ob, min, max); ok= 1; } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 13e407040c3..b57500df719 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -158,7 +158,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy particle setting */ if (psys->part) - part= psys_copy_settings(psys->part); + part= BKE_particlesettings_copy(psys->part); else part= psys_new_settings("ParticleSettings", bmain); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 068e93e7a5a..5a56672f766 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -126,7 +126,7 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * float dim[3]; float longest_axis; - object_get_dimensions(domainob, dim); + BKE_object_dimensions_get(domainob, dim); longest_axis = MAX3(dim[0], dim[1], dim[2]); return longest_axis * scene->unit.scale_length; diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 32ed74097e1..f7024444e86 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -754,13 +754,13 @@ static void shader_preview_free(void *customdata) /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - /* free_material decrements texture, prevent this. hack alert! */ + /* BKE_material_free decrements texture, prevent this. hack alert! */ for (a = 0; a < MAX_MTEX; a++) { MTex *mtex = sp->matcopy->mtex[a]; if (mtex && mtex->tex) mtex->tex = NULL; } - free_material(sp->matcopy); + BKE_material_free(sp->matcopy); properties = IDP_GetProperties((ID *)sp->matcopy, FALSE); if (properties) { @@ -776,7 +776,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied texture */ BLI_remlink(&pr_main->tex, sp->texcopy); - free_texture(sp->texcopy); + BKE_texture_free(sp->texcopy); properties = IDP_GetProperties((ID *)sp->texcopy, FALSE); if (properties) { @@ -792,7 +792,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied world */ BLI_remlink(&pr_main->world, sp->worldcopy); - free_world(sp->worldcopy); + BKE_world_free(sp->worldcopy); properties = IDP_GetProperties((ID *)sp->worldcopy, FALSE); if (properties) { @@ -808,7 +808,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied lamp */ BLI_remlink(&pr_main->lamp, sp->lampcopy); - free_lamp(sp->lampcopy); + BKE_lamp_free(sp->lampcopy); properties = IDP_GetProperties((ID *)sp->lampcopy, FALSE); if (properties) { diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 0b8408c698c..bdfcaa90eb1 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -372,7 +372,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy material */ if (ma) { - ma = copy_material(ma); + ma = BKE_material_copy(ma); } else { ma = add_material("Material"); @@ -425,7 +425,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy texture */ if (tex) - tex = copy_texture(tex); + tex = BKE_texture_copy(tex); else tex = add_texture("Texture"); @@ -472,7 +472,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy world */ if (wo) { - wo = copy_world(wo); + wo = BKE_world_copy(wo); } else { wo = add_world("World"); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 9e044068468..69ea428b2ba 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -145,7 +145,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult for (base=scene->base.first; base; base=base->next) { if ((base->flag & SELECT) && (base->lay & scene->lay)) { if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if (0==object_is_libdata(base->object)) { + if (0==BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -242,7 +242,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "visible_pose_bones")) { - Object *obpose= object_pose_armature_get(obact); + Object *obpose= BKE_object_pose_armature_get(obact); bArmature *arm= (obpose) ? obpose->data : NULL; bPoseChannel *pchan; @@ -258,7 +258,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_pose_bones")) { - Object *obpose= object_pose_armature_get(obact); + Object *obpose= BKE_object_pose_armature_get(obact); bArmature *arm= (obpose) ? obpose->data : NULL; bPoseChannel *pchan; @@ -293,7 +293,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "active_pose_bone")) { bPoseChannel *pchan; - Object *obpose= object_pose_armature_get(obact); + Object *obpose= BKE_object_pose_armature_get(obact); pchan= get_active_posechannel(obpose); if (pchan) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 512cd404273..e7ad73b3e49 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -419,7 +419,7 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name) bScreen *sc; ScrVert *sv1, *sv2, *sv3, *sv4; - sc= alloc_libblock(&G.main->screen, ID_SCR, name); + sc= BKE_libblock_alloc(&G.main->screen, ID_SCR, name); sc->scene= scene; sc->do_refresh= 1; sc->redraws_flag= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; @@ -448,7 +448,7 @@ static void screen_copy(bScreen *to, bScreen *from) ScrArea *sa, *saf; /* free contents of 'to', is from blenkernel screen.c */ - free_screen(to); + BKE_screen_free(to); BLI_duplicatelist(&to->vertbase, &from->vertbase); BLI_duplicatelist(&to->edgebase, &from->edgebase); @@ -1426,7 +1426,7 @@ void ED_screen_delete(bContext *C, bScreen *sc) ED_screen_set(C, newsc); if (delete && win->screen != sc) - free_libblock(&bmain->screen, sc); + BKE_libblock_free(&bmain->screen, sc); } /* only call outside of area/region loops */ @@ -1654,8 +1654,8 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) ED_screen_set(C, sc); - free_screen(oldscreen); - free_libblock(&CTX_data_main(C)->screen, oldscreen); + BKE_screen_free(oldscreen); + BKE_libblock_free(&CTX_data_main(C)->screen, oldscreen); } else { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 49672b77d43..4395efc23db 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -347,7 +347,7 @@ int ED_operator_posemode(bContext *C) if (obact && !(obact->mode & OB_MODE_EDIT)) { Object *obpose; - if ((obpose= object_pose_armature_get(obact))) { + if ((obpose= BKE_object_pose_armature_get(obact))) { if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) { return 1; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a025a84bea9..f65a8116efb 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5554,7 +5554,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) if (ob == NULL) return OPERATOR_CANCELLED; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 37d5af553ab..8f8c4ae13d3 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2543,7 +2543,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me = get_mesh(ob); - if (me == NULL || object_data_is_libdata(ob)) { + if (me == NULL || BKE_object_obdata_is_libdata(ob)) { ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a44eca17dfd..723efdc484c 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -98,7 +98,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) if (oldact && GS(oldact->id.name)==ID_AC) { /* make a copy of the existing action */ - action= copy_action(oldact); + action= BKE_action_copy(oldact); } else { /* just make a new (empty) action */ diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 825415764f1..56f50d41a12 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1973,13 +1973,13 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) Object *camera = scene->camera; Base *base; - if (camera && object_get_movieclip(scene, camera, 0)==clip) + if (camera && BKE_object_movieclip_get(scene, camera, 0)==clip) return camera; base = scene->base.first; while (base) { if (base->object->type == OB_CAMERA) { - if (object_get_movieclip(scene, base->object, 0)==clip) { + if (BKE_object_movieclip_get(scene, base->object, 0)==clip) { camera = base->object; break; } @@ -2069,7 +2069,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat if (!found) { Object *cam = data->camera ? data->camera : scene->camera; - where_is_object_mat(scene, cam, invmat); + BKE_object_where_is_calc_mat4(scene, cam, invmat); } mult_m4_m4m4(invmat, invmat, data->invmat); @@ -2196,7 +2196,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb int flip = FALSE; float mat[4][4], vec[3], obmat[4][4], dvec[3]; - object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, obmat); BKE_get_tracking_mat(scene, camera, mat); mul_v3_m4v3(vec, mat, track->bundle_pos); @@ -2281,7 +2281,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb if (!flip) { float lmat[4][4], ilmat[4][4], rmat[3][3]; - object_rot_to_mat3(ob, rmat); + BKE_object_rot_to_mat3(ob, rmat); invert_m3(rmat); mul_m4_m4m3(mat, mat, rmat); @@ -2296,7 +2296,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb } } - object_apply_mat4(ob, mat, 0, 0); + BKE_object_apply_mat4(ob, mat, 0, 0); } static int set_plane_exec(bContext *C, wmOperator *op) @@ -2383,23 +2383,23 @@ static int set_plane_exec(bContext *C, wmOperator *op) if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { invert_m4(mat); - object_to_mat4(object, obmat); + BKE_object_to_mat4(object, obmat); mult_m4_m4m4(mat, mat, obmat); mult_m4_m4m4(newmat, rot, mat); - object_apply_mat4(object, newmat, 0, 0); + BKE_object_apply_mat4(object, newmat, 0, 0); /* make camera have positive z-coordinate */ if (object->loc[2]<0) { invert_m4(rot); mult_m4_m4m4(newmat, rot, mat); - object_apply_mat4(object, newmat, 0, 0); + BKE_object_apply_mat4(object, newmat, 0, 0); } } else { - object_apply_mat4(object, mat, 0, 0); + BKE_object_apply_mat4(object, mat, 0, 0); } - where_is_object(scene, object); + BKE_object_where_is_calc(scene, object); set_axis(scene, object, clip, tracking_object, axis_track, 'X'); DAG_id_tag_update(&clip->id, 0); diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 184357344e1..891236d6d21 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4789,7 +4789,7 @@ void logic_buttons(bContext *C, ARegion *ar) } if (ob==NULL) return; -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); block= uiBeginBlock(C, ar, numstr, UI_EMBOSS); @@ -4833,7 +4833,7 @@ void logic_buttons(bContext *C, ARegion *ar) ob= (Object *)idar[a]; // uiClearButLock(); -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if ( (ob->scavisflag & OB_VIS_CONT) == 0) continue; /* presume it is only objects for now */ @@ -4970,7 +4970,7 @@ void logic_buttons(bContext *C, ARegion *ar) for (a=0; ascavisflag & OB_VIS_SENS) == 0) continue; @@ -5051,7 +5051,7 @@ void logic_buttons(bContext *C, ARegion *ar) for (a=0; ascavisflag & OB_VIS_ACT) == 0) continue; /* presume it is only objects for now */ diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 93105c39f39..1caf1075ae6 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -152,7 +152,7 @@ static void logic_free(SpaceLink *UNUSED(sl)) // Spacelogic *slogic= (SpaceLogic*) sl; // if (slogic->gpd) -// XXX free_gpencil_data(slogic->gpd); +// XXX BKE_gpencil_free(slogic->gpd); } diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 994021db9ff..57ad552f7e2 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1682,7 +1682,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) continue; if (strip->act->id.us > 1) { /* make a copy of the Action to work on */ - bAction *act= copy_action(strip->act); + bAction *act= BKE_action_copy(strip->act); /* set this as the new referenced action, decrementing the users of the old one */ strip->act->id.us--; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 89eb51f73ba..12575e0a151 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -202,7 +202,7 @@ static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme } } else { - unlink_group(group); + BKE_group_unlink(group); } } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index e421ace75a0..4168cb9ac77 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -186,7 +186,7 @@ static void sequencer_free(SpaceLink *UNUSED(sl)) { // SpaceSeq *sseq= (SpaceSequencer*) sl; -// XXX if (sseq->gpd) free_gpencil_data(sseq->gpd); +// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index a07493ef8fc..ca72d1e3094 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -379,8 +379,8 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op)) } } - unlink_text(bmain, text); - free_libblock(&bmain->text, text); + BKE_text_unlink(bmain, text); + BKE_libblock_free(&bmain->text, text); text_drawcache_tag_update(st, 1); WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, NULL); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 068a31a888f..72697497646 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1740,7 +1740,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base int i; float drawsize; const short is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); - MovieClip *clip = object_get_movieclip(scene, base->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, base->object, 0); /* draw data for movie clip set as active for scene */ if (clip) { @@ -6092,7 +6092,7 @@ static void draw_box(float vec[8][3]) #if 0 static void get_local_bounds(Object *ob, float center[3], float size[3]) { - BoundBox *bb = object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb == NULL) { zero_v3(center); @@ -6435,7 +6435,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) view3d_cached_text_draw_begin(); /* patch? children objects with a timeoffs change the parents. How to solve! */ - /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ + /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) BKE_object_where_is_calc(scene, ob); */ /* draw motion paths (in view space) */ if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 72b67c2a716..f9b8f9228b9 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1071,7 +1071,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & lay)) { if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { - if (0 == object_is_libdata(base->object)) { + if (0 == BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f48b45f9793..7ede8e01194 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1552,7 +1552,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) if (bgpic->flag & V3D_BGPIC_CAMERACLIP) { if (scene->camera) - clip = object_get_movieclip(scene, scene->camera, 1); + clip = BKE_object_movieclip_get(scene, scene->camera, 1); } else clip = bgpic->clip; @@ -1866,7 +1866,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas /* lamp drawing messes with matrices, could be handled smarter... but this works */ (dob->ob->type == OB_LAMP) || (dob->type == OB_DUPLIGROUP && dob->animated) || - !(bb_tmp = object_get_boundbox(dob->ob))) + !(bb_tmp = BKE_object_boundbox_get(dob->ob))) { // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2); use_displist = 0; @@ -1876,7 +1876,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas bb = *bb_tmp; /* must make a copy */ /* disable boundbox check for list creation */ - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); /* need this for next part of code */ unit_m4(dob->ob->obmat); /* obmat gets restored */ @@ -1886,7 +1886,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas glEndList(); use_displist = 1; - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); } } if (use_displist) { @@ -2043,7 +2043,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) RegionView3D *rv3d = ar->regiondata; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2078,7 +2078,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) U.obcenter_dia = 0; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2367,7 +2367,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view if (viewmat) copy_m4_m4(rv3d->viewmat, viewmat); else - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ /* update utilitity matrices */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ea4d28ce32f..cd128798d2a 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -121,9 +121,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat); - object_tfm_protected_backup(root_parent, &obtfm); - object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); - object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); + BKE_object_tfm_protected_backup(root_parent, &obtfm); + BKE_object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); + BKE_object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); ob_update = v3d->camera; while (ob_update) { @@ -133,9 +133,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) } } else { - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); @@ -2068,7 +2068,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in continue; } - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); } } if (!onedone) { @@ -2214,8 +2214,8 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (minmax_object_duplis(scene, base->object, min, max) == 0) - minmax_object(base->object, min, max); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max) == 0) + BKE_object_minmax(base->object, min, max); /* use if duplis not found */ ok = 1; } @@ -3671,7 +3671,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co { float mat[4][4]; ED_view3d_to_m4(mat, ofs, quat, dist); - object_apply_mat4(ob, mat, TRUE, TRUE); + BKE_object_apply_mat4(ob, mat, TRUE, TRUE); } BGpic *ED_view3D_background_image_new(View3D *v3d) diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 5b6624889c8..c2a2a2be2fd 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -366,9 +366,9 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event /* store the original camera loc and rot */ /* TODO. axis angle etc */ - fly->obtfm = object_tfm_backup(ob_back); + fly->obtfm = BKE_object_tfm_backup(ob_back); - where_is_object(fly->scene, fly->v3d->camera); + BKE_object_where_is_calc(fly->scene, fly->v3d->camera); negate_v3_v3(fly->rv3d->ofs, fly->v3d->camera->obmat[3]); fly->rv3d->dist = 0.0; @@ -429,7 +429,7 @@ static int flyEnd(bContext *C, FlyInfo *fly) ob_back = (fly->root_parent) ? fly->root_parent : fly->v3d->camera; /* store the original camera loc and rot */ - object_tfm_restore(ob_back, fly->obtfm); + BKE_object_tfm_restore(ob_back, fly->obtfm); DAG_id_tag_update(&ob_back->id, OB_RECALC_OB); } @@ -709,9 +709,9 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); mult_m4_m4m4(diff_mat, view_mat, prev_view_imat); mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat); - object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); + BKE_object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); - // where_is_object(scene, fly->root_parent); + // BKE_object_where_is_calc(scene, fly->root_parent); ob_update = v3d->camera->parent; while (ob_update) { @@ -724,7 +724,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien else { float view_mat[4][4]; ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); + BKE_object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); id_key = &v3d->camera->id; } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f106fcc268e..44f7dd0b871 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1407,7 +1407,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* index of bundle is 1<<16-based. if there's no "bone" index * in hight word, this buffer value belongs to camera,. not to bundle */ if (buffer[4 * i + 3] & 0xFFFF0000) { - MovieClip *clip = object_get_movieclip(scene, basact->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, basact->object, 0); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase; MovieTrackingTrack *track; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 87edf6a37a0..2fe0a30c71b 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -613,7 +613,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + gridf *floorf(0.5f + ob->obmat[3][2] / gridf); if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -738,7 +738,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + curs[2]; if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -818,7 +818,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) { - MovieClip *clip = object_get_movieclip(scene, ob, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, ob, 0); MovieTracking *tracking; MovieTrackingObject *object; int ok = 0; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 733c5c55bfc..22ac3b8a8e8 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -358,11 +358,11 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) rv3d->lpersp = rv3d->persp; } - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; @@ -421,9 +421,9 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o copy_v3_v3(obmat_new[3], r_co); /* only touch location */ - object_tfm_protected_backup(camera_ob, &obtfm); - object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); - object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); + BKE_object_tfm_protected_backup(camera_ob, &obtfm); + BKE_object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); + BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); /* notifiers */ DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB); @@ -1155,7 +1155,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) { if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { - where_is_object(scene, v3d->camera); + BKE_object_where_is_calc(scene, v3d->camera); obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { @@ -1412,7 +1412,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) } else { if (scene->obedit) { - minmax_object(scene->obedit, min, max); + BKE_object_minmax(scene->obedit, min, max); ok = 1; @@ -1422,7 +1422,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); base->lay |= locallay; base->object->lay = base->lay; ok = 1; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 599d4a559ed..af5c414a751 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -284,7 +284,7 @@ static void createTransTexspace(TransInfo *t) normalize_m3(td->axismtx); invert_m3_m3(td->smtx, td->mtx); - if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { + if (BKE_object_obdata_texspace_get(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { ob->dtx |= OB_TEXSPACE; *texflag &= ~ME_AUTOSPACE; } @@ -4258,15 +4258,15 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) if (skip_invert == 0 && constinv == 0) { if (constinv == 0) - ob->transflag |= OB_NO_CONSTRAINTS; /* where_is_object_time checks this */ + ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */ - where_is_object(t->scene, ob); + BKE_object_where_is_calc(t->scene, ob); if (constinv == 0) ob->transflag &= ~OB_NO_CONSTRAINTS; } else - where_is_object(t->scene, ob); + BKE_object_where_is_calc(t->scene, ob); td->ob = ob; @@ -4320,7 +4320,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * NOTE: some Constraints, and also Tracking should never get this * done, as it doesn't work well. */ - object_to_mat3(ob, obmtx); + BKE_object_to_mat3(ob, obmtx); copy_m3_m4(totmat, ob->obmat); invert_m3_m3(obinv, totmat); mul_m3_m3m3(td->smtx, obmtx, obinv); @@ -4362,7 +4362,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* handle pending update events, otherwise they got copied below */ for (base= scene->base.first; base; base= base->next) { if (base->object->recalc) - object_handle_update(t->scene, base->object); + BKE_object_handle_update(t->scene, base->object); } for (base= scene->base.first; base; base= base->next) { @@ -5141,7 +5141,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* recalculating the frame positions means we loose our original transform if its not auto-keyed [#24451] * this hack re-applies it, which is annoying, only alternatives are... * - don't recalc paths. - * - have an object_handle_update() which gives is the new transform without touching the objects. + * - have an BKE_object_handle_update() which gives is the new transform without touching the objects. * - only recalc paths on auto-keying. * - ED_objects_recalculate_paths could backup/restore transforms. * - re-apply the transform which is simplest in this case. (2 lines below) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index fa579293a73..b875886e80a 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -284,7 +284,7 @@ void applyProject(TransInfo *t) } else if (t->flag & T_OBJECT) { td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - object_handle_update(t->scene, td->ob); + BKE_object_handle_update(t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } @@ -966,7 +966,7 @@ static void TargetSnapClosest(TransInfo *t) if (t->flag & T_OBJECT) { int i; for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { - struct BoundBox *bb = object_get_boundbox(td->ob); + struct BoundBox *bb = BKE_object_boundbox_get(td->ob); /* use boundbox if possible */ if (bb) { @@ -1303,8 +1303,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh * test against boundbox first * */ if (totface > 16) { - struct BoundBox *bb = object_get_boundbox(ob); - test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local); + struct BoundBox *bb = BKE_object_boundbox_get(ob); + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local); } if (test == 1) { @@ -1709,8 +1709,8 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], * test against boundbox first * */ if (totface > 16) { - struct BoundBox *bb = object_get_boundbox(ob); - test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local); + struct BoundBox *bb = BKE_object_boundbox_get(ob); + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local); } if (test == 1) { diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index b2c2bc092b2..f41d1c3c8a3 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1410,7 +1410,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 glPushMatrix(); glLoadMatrixf((float *)viewmat); - where_is_object_simul(scene, base->object); + BKE_object_where_is_calc_simul(scene, base->object); if (la->type==LA_SUN) { /* sun lamp */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index acdd25a101e..da8458d587e 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -190,7 +190,7 @@ typedef struct Curve { short type; /* creation-time type of curve datablock */ - short texflag; /* keep a short because of give_obdata_texspace() */ + short texflag; /* keep a short because of BKE_object_obdata_texspace_get() */ short drawflag, twist_mode; float twist_smooth, smallcaps_scale; diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 58ffcf6480e..f5d525d47b5 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -236,7 +236,7 @@ typedef struct ParticleSettings { typedef struct ParticleSystem { /* note1: make sure all (runtime) are NULL's in 'copy_particlesystem' XXX, this function is no more! - need to invstigate */ - /* note2: make sure any uses of this struct in DNA are accounted for in 'copy_object_particlesystems' */ + /* note2: make sure any uses of this struct in DNA are accounted for in 'BKE_object_copy_particlesystems' */ struct ParticleSystem *next, *prev; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 81cc4f13372..25abfe02db6 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1119,7 +1119,7 @@ typedef struct Scene { /* Movie Tracking */ struct MovieClip *clip; /* active movie clip */ - uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ + uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */ uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ } Scene; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index f00126986a5..bba85cadbc3 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -99,7 +99,7 @@ Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name) void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) { if (ID_REAL_USERS(camera) <= 0) - free_libblock(&bmain->camera, camera); + BKE_libblock_free(&bmain->camera, camera); else BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d", camera->id.name+2, ID_REAL_USERS(camera)); @@ -113,7 +113,7 @@ Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name) } void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) { - /* don't call free_libblock(...) directly */ + /* don't call BKE_libblock_free(...) directly */ Scene *newscene; if (scene->id.prev) @@ -175,7 +175,7 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha id_us_plus(data); } - ob = add_only_object(type, name); + ob = BKE_object_add_only_object(type, name); id_us_min(&ob->id); ob->data = data; @@ -187,8 +187,8 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { if (ID_REAL_USERS(object) <= 0) { - unlink_object(object); /* needed or ID pointers to this are not cleared */ - free_libblock(&bmain->object, object); + BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */ + BKE_libblock_free(&bmain->object, object); } else { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d", @@ -205,7 +205,7 @@ struct Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) { if (ID_REAL_USERS(material) <= 0) - free_libblock(&bmain->mat, material); + BKE_libblock_free(&bmain->mat, material); else BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d", material->id.name+2, ID_REAL_USERS(material)); @@ -223,7 +223,7 @@ struct bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, i void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree) { if (ID_REAL_USERS(tree) <= 0) - free_libblock(&bmain->nodetree, tree); + BKE_libblock_free(&bmain->nodetree, tree); else BKE_reportf(reports, RPT_ERROR, "Node Tree \"%s\" must have zero users to be removed, found %d", tree->id.name+2, ID_REAL_USERS(tree)); @@ -240,7 +240,7 @@ Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) { if (ID_REAL_USERS(mesh) <= 0) - free_libblock(&bmain->mesh, mesh); + BKE_libblock_free(&bmain->mesh, mesh); else BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d", mesh->id.name+2, ID_REAL_USERS(mesh)); @@ -258,7 +258,7 @@ Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) { if (ID_REAL_USERS(lamp) <= 0) - free_libblock(&bmain->lamp, lamp); + BKE_libblock_free(&bmain->lamp, lamp); else BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d", lamp->id.name+2, ID_REAL_USERS(lamp)); @@ -289,7 +289,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) { if (ID_REAL_USERS(image) <= 0) - free_libblock(&bmain->image, image); + BKE_libblock_free(&bmain->image, image); else BKE_reportf(reports, RPT_ERROR, "Image \"%s\" must have zero users to be removed, found %d", image->id.name+2, ID_REAL_USERS(image)); @@ -306,7 +306,7 @@ Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt) { if (ID_REAL_USERS(lt) <= 0) - free_libblock(&bmain->latt, lt); + BKE_libblock_free(&bmain->latt, lt); else BKE_reportf(reports, RPT_ERROR, "Lattice \"%s\" must have zero users to be removed, found %d", lt->id.name+2, ID_REAL_USERS(lt)); @@ -321,7 +321,7 @@ Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type) void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) { if (ID_REAL_USERS(cu) <= 0) - free_libblock(&bmain->curve, cu); + BKE_libblock_free(&bmain->curve, cu); else BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d", cu->id.name+2, ID_REAL_USERS(cu)); @@ -336,7 +336,7 @@ MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb) { if (ID_REAL_USERS(mb) <= 0) - free_libblock(&bmain->mball, mb); + BKE_libblock_free(&bmain->mball, mb); else BKE_reportf(reports, RPT_ERROR, "Metaball \"%s\" must have zero users to be removed, found %d", mb->id.name+2, ID_REAL_USERS(mb)); @@ -359,7 +359,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) { if (ID_REAL_USERS(vfont) <= 0) - free_libblock(&bmain->vfont, vfont); + BKE_libblock_free(&bmain->vfont, vfont); else BKE_reportf(reports, RPT_ERROR, "Font \"%s\" must have zero users to be removed, found %d", vfont->id.name+2, ID_REAL_USERS(vfont)); @@ -377,7 +377,7 @@ Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type) void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) { if (ID_REAL_USERS(tex) <= 0) - free_libblock(&bmain->tex, tex); + BKE_libblock_free(&bmain->tex, tex); else BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d", tex->id.name+2, ID_REAL_USERS(tex)); @@ -392,7 +392,7 @@ Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush) { if (ID_REAL_USERS(brush) <= 0) - free_libblock(&bmain->brush, brush); + BKE_libblock_free(&bmain->brush, brush); else BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d", brush->id.name+2, ID_REAL_USERS(brush)); @@ -407,7 +407,7 @@ World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name) void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world) { if (ID_REAL_USERS(world) <= 0) - free_libblock(&bmain->world, world); + BKE_libblock_free(&bmain->world, world); else BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d", world->id.name+2, ID_REAL_USERS(world)); @@ -419,8 +419,8 @@ Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name) } void rna_Main_groups_remove(Main *bmain, Group *group) { - unlink_group(group); - free_libblock(&bmain->group, group); + BKE_group_unlink(group); + BKE_libblock_free(&bmain->group, group); /* XXX python now has invalid pointer? */ } @@ -433,7 +433,7 @@ Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker) { if (ID_REAL_USERS(speaker) <= 0) - free_libblock(&bmain->speaker, speaker); + BKE_libblock_free(&bmain->speaker, speaker); else BKE_reportf(reports, RPT_ERROR, "Speaker \"%s\" must have zero users to be removed, found %d", speaker->id.name+2, ID_REAL_USERS(speaker)); @@ -447,8 +447,8 @@ Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name) } void rna_Main_texts_remove(Main *bmain, Text *text) { - unlink_text(bmain, text); - free_libblock(&bmain->text, text); + BKE_text_unlink(bmain, text); + BKE_libblock_free(&bmain->text, text); /* XXX python now has invalid pointer? */ } @@ -475,7 +475,7 @@ bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name) void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) { if (ID_REAL_USERS(arm) <= 0) - free_libblock(&bmain->armature, arm); + BKE_libblock_free(&bmain->armature, arm); else BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d", arm->id.name+2, ID_REAL_USERS(arm)); @@ -493,7 +493,7 @@ bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name) void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) { if (ID_REAL_USERS(act) <= 0) - free_libblock(&bmain->action, act); + BKE_libblock_free(&bmain->action, act); else BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d", act->id.name+2, ID_REAL_USERS(act)); @@ -510,7 +510,7 @@ ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part) { if (ID_REAL_USERS(part) <= 0) - free_libblock(&bmain->particle, part); + BKE_libblock_free(&bmain->particle, part); else BKE_reportf(reports, RPT_ERROR, "Particle Settings \"%s\" must have zero users to be removed, found %d", part->id.name+2, ID_REAL_USERS(part)); @@ -535,7 +535,7 @@ MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, con void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip) { BKE_movieclip_unlink(bmain, clip); - free_libblock(&bmain->movieclip, clip); + BKE_libblock_free(&bmain->movieclip, clip); /* XXX python now has invalid pointer? */ } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6a4809e54e5..4effa9f7f38 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -164,7 +164,7 @@ static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene) static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) { /* don't use compat so we get predictable rotation */ - object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE); + BKE_object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE); rna_Object_internal_update(bmain, scene, ptr); } @@ -199,19 +199,19 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) } /* don't use compat so we get predictable rotation */ - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); } static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; - object_to_mat4(ob, (float(*)[4])values); + BKE_object_to_mat4(ob, (float(*)[4])values); } static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16]) { Object *ob = ptr->id.data; - object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE); + BKE_object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE); } void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -708,13 +708,13 @@ static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value) static void rna_Object_dimensions_get(PointerRNA *ptr, float *value) { Object *ob = ptr->data; - object_get_dimensions(ob, value); + BKE_object_dimensions_get(ob, value); } static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value) { Object *ob = ptr->data; - object_set_dimensions(ob, value); + BKE_object_dimensions_set(ob, value); } static int rna_Object_location_editable(PointerRNA *ptr, int index) @@ -1202,7 +1202,7 @@ static void rna_Object_modifier_clear(Object *object, bContext *C) static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) { Object *ob = (Object*)ptr->id.data; - BoundBox *bb = object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { memcpy(values, bb->vec, sizeof(bb->vec)); } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index cb0f1d307aa..77110f85655 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -87,13 +87,13 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ case OB_SURF: /* copies object and modifiers (but not the data) */ - tmpobj = copy_object(ob); + tmpobj = BKE_object_copy(ob); tmpcu = (Curve *)tmpobj->data; tmpcu->id.us--; /* if getting the original caged mesh, delete object modifiers */ if ( cage ) - object_free_modifiers(tmpobj); + BKE_object_free_modifiers(tmpobj); /* copies the data */ copycu = tmpobj->data = BKE_curve_copy((Curve *) ob->data ); @@ -114,12 +114,12 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ /* nurbs_to_mesh changes the type to a mesh, check it worked */ if (tmpobj->type != OB_MESH) { - free_libblock_us(&(G.main->object), tmpobj); + BKE_libblock_free_us(&(G.main->object), tmpobj); BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?"); return NULL; } tmpmesh = tmpobj->data; - free_libblock_us(&G.main->object, tmpobj); + BKE_libblock_free_us(&G.main->object, tmpobj); break; case OB_MBALL: { @@ -148,7 +148,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ /* copies object and modifiers (but not the data) */ if (cage) { /* copies the data */ - tmpmesh = copy_mesh( ob->data ); + tmpmesh = BKE_mesh_copy( ob->data ); /* if not getting the original caged mesh, get final derived mesh */ } else { @@ -328,7 +328,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList * Scene *scene = CTX_data_scene(C); KeyBlock *kb = NULL; - if ((kb = object_insert_shape_key(scene, ob, name, from_mix))) { + if ((kb = BKE_object_insert_shape_key(scene, ob, name, from_mix))) { PointerRNA keyptr; RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); @@ -473,12 +473,12 @@ void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) int rna_Object_is_modified(Object *ob, Scene *scene, int settings) { - return object_is_modified(scene, ob) & settings; + return BKE_object_is_modified(scene, ob) & settings; } int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) { - return object_is_deform_modified(scene, ob) & settings; + return BKE_object_is_deform_modified(scene, ob) & settings; } #ifndef NDEBUG diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d9f5ca1f9ed..9da230d90e8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -338,7 +338,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report base = scene_add_base(scene, ob); id_us_plus(&ob->id); - /* this is similar to what object_add_type and add_object do */ + /* this is similar to what object_add_type and BKE_object_add do */ base->lay = scene->lay; /* when linking to an inactive scene don't touch the layer */ diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 1fe4f92e124..6f1f379987d 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -356,7 +356,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float tmp_mat[3][3]; float scale; - object_to_mat3(amd->curve_ob, tmp_mat); + BKE_object_to_mat3(amd->curve_ob, tmp_mat); scale = mat3_to_scale(tmp_mat); if (!cu->path) { diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 8d6295ee6d4..4f16bfa1ed0 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -277,7 +277,7 @@ static Object *AddNewBlenderMesh(Scene *scene, Base *base) // now create a new blender object. // duplicating all the settings from the previous object // to the new one. - ob_new= copy_object(base->object); + ob_new= BKE_object_copy(base->object); // Ok we don't want to use the actual data from the // last object, the above function incremented the diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index dc1429208a0..5ac1e2786d6 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -79,7 +79,7 @@ static void copyData(ModifierData *md, ModifierData *target) tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0; //tpsmd->facepa = 0; tpsmd->flag = psmd->flag; - /* need to keep this to recognise a bit later in copy_object */ + /* need to keep this to recognise a bit later in BKE_object_copy */ tpsmd->psys = psmd->psys; } diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 049b5dd8178..b526c25e2dc 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -136,7 +136,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (node->id) { if (node->flag & NODE_DO_OUTPUT) - node->new_node->id= (ID *)copy_image((Image *)node->id); + node->new_node->id= (ID *)BKE_image_copy((Image *)node->id); else node->new_node->id= NULL; } diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 3aadcef4c82..49a3d6c07b4 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -368,7 +368,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bAction *waction; /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ - waction = wgroup->adt->action = copy_action(wgroup->adt->action); + waction = wgroup->adt->action = BKE_action_copy(wgroup->adt->action); /* now perform the moving */ BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); @@ -383,7 +383,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* free temp action too */ if (waction) { - free_libblock(&G.main->action, waction); + BKE_libblock_free(&G.main->action, waction); } } @@ -391,7 +391,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) nodeFreeNode(ntree, gnode); /* free the group tree (takes care of user count) */ - free_libblock(&G.main->nodetree, wgroup); + BKE_libblock_free(&G.main->nodetree, wgroup); ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; ntreeUpdateTree(ntree); diff --git a/source/blender/nodes/shader/nodes/node_shader_dynamic.c b/source/blender/nodes/shader/nodes/node_shader_dynamic.c index 5a6a92b5e27..b441545441a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_dynamic.c +++ b/source/blender/nodes/shader/nodes/node_shader_dynamic.c @@ -254,7 +254,7 @@ static void node_dynamic_rem_all_links(bNodeType *tinfo) /* node_dynamic_reset: clean a pynode, getting rid of all * data dynamically created for it. */ -static void node_dynamic_reset(bNode *node, int unlink_text) +static void node_dynamic_reset(bNode *node, int BKE_text_unlink) { bNodeType *tinfo, *tinfo_default; Material *ma; @@ -262,7 +262,7 @@ static void node_dynamic_reset(bNode *node, int unlink_text) tinfo = node->typeinfo; tinfo_default = node_dynamic_find_typeinfo(&node_all_shaders, NULL); - if ((tinfo == tinfo_default) && unlink_text) { + if ((tinfo == tinfo_default) && BKE_text_unlink) { ID *textID = node->id; /* already at default (empty) state, which happens if this node's * script failed to parse at the first stage: definition. We're here @@ -296,7 +296,7 @@ static void node_dynamic_reset(bNode *node, int unlink_text) node_dynamic_free_sockets(nd); //node_dynamic_update_socket_links(nd, ma->nodetree); nd->typeinfo = tinfo_default; - if (unlink_text) { + if (BKE_text_unlink) { nd->id = NULL; nd->custom1 = 0; nd->custom1 = BSET(nd->custom1, NODE_DYNAMIC_NEW); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f6030c8c0b5..5df78a3f5da 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -5868,7 +5868,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d) me->msticky= CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_CALLOC, NULL, me->totvert); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); mult_m4_m4m4(mat, re->viewmat, ob->obmat); ms= me->msticky; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 521b295fb0b..0c090e7e984 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -3644,14 +3644,14 @@ void RE_free_sample_material(Material *mat) MTex *mtex= mat->mtex[tex_nr]; if (mtex->tex) { - free_texture(mtex->tex); + BKE_texture_free(mtex->tex); MEM_freeN(mtex->tex); mtex->tex = NULL; } } } - free_material(mat); + BKE_material_free(mat); MEM_freeN(mat); } diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 638dd4ca807..7285e155dc6 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -291,7 +291,7 @@ void wm_clear_default_size(bContext *C) /* on startup, it adds all data, for matching */ void wm_add_default(bContext *C) { - wmWindowManager *wm = alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan"); + wmWindowManager *wm = BKE_libblock_alloc(&CTX_data_main(C)->wm, ID_WM, "WinMan"); wmWindow *win; bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 031cfe90042..8d962c828ca 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -282,7 +282,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) /* if temp screen, delete it after window free (it stops jobs that can access it) */ if (screen->temp) { Main *bmain = CTX_data_main(C); - free_libblock(&bmain->screen, screen); + BKE_libblock_free(&bmain->screen, screen); } /* check remaining windows */ diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index bb3636881ea..b93d731c5e6 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -77,7 +77,7 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, m_lastShapeUpdate(-1) { m_key = m_bmesh->key; - m_bmesh->key = copy_key(m_key); + m_bmesh->key = BKE_key_copy(m_key); }; /* this second constructor is needed for making a mesh deformable on the fly. */ @@ -94,14 +94,14 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, m_lastShapeUpdate(-1) { m_key = m_bmesh->key; - m_bmesh->key = copy_key(m_key); + m_bmesh->key = BKE_key_copy(m_key); }; BL_ShapeDeformer::~BL_ShapeDeformer() { if (m_key && m_bmesh->key && m_key != m_bmesh->key) { - free_key(m_bmesh->key); + BKE_key_free(m_bmesh->key); BLI_remlink_safe(&G.main->key, m_bmesh->key); MEM_freeN(m_bmesh->key); m_bmesh->key = m_key; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index df6be142b30..b62e667c211 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -88,8 +88,8 @@ extern "C" #include "BKE_global.h" #include "BKE_animsys.h" #include "BKE_library.h" -#include "BKE_material.h" // copy_material -#include "BKE_mesh.h" // copy_mesh +#include "BKE_material.h" // BKE_material_copy +#include "BKE_mesh.h" // BKE_mesh_copy #include "DNA_space_types.h" #include "DNA_anim_types.h" #include "RNA_define.h" @@ -1409,7 +1409,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene, /* Watch this!, if its used in the original scene can cause big troubles */ if (me->us > 0) { printf("Mesh has a user \"%s\"\n", name); - me = (ID*)copy_mesh((Mesh*)me); + me = (ID*)BKE_mesh_copy((Mesh*)me); me->us--; } BLI_remlink(&m_maggie->mesh, me); /* even if we made the copy it needs to be removed */ @@ -1433,7 +1433,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene, if (mat_old && (mat_old->id.flag & LIB_DOIT)==0) { Material *mat_old= mesh->mat[i]; - Material *mat_new= copy_material( mat_old ); + Material *mat_new= BKE_material_copy( mat_old ); mat_new->id.flag |= LIB_DOIT; mat_old->id.us--; From 299ff91ea1fe5623bea1c6775cb8250d5e4ec3a0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 14:33:36 +0000 Subject: [PATCH 76/88] code cleanup: BKE_scene api naming. also stop numpy from being found in /usr/include with cmake. --- CMakeLists.txt | 1 + intern/cycles/blender/blender_mesh.cpp | 4 +- intern/cycles/blender/blender_object.cpp | 4 +- intern/cycles/blender/blender_sync.cpp | 2 +- intern/cycles/blender/blender_sync.h | 2 +- intern/cycles/blender/blender_util.h | 4 +- source/blender/blenkernel/BKE_scene.h | 53 ++++++------- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/anim.c | 4 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/blender.c | 2 +- .../blender/blenkernel/intern/dynamicpaint.c | 14 ++-- source/blender/blenkernel/intern/group.c | 6 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/mball.c | 18 ++--- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/object.c | 8 +- source/blender/blenkernel/intern/particle.c | 4 +- .../blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 8 +- source/blender/blenkernel/intern/scene.c | 74 +++++++++---------- source/blender/blenkernel/intern/sequencer.c | 6 +- source/blender/blenkernel/intern/tracking.c | 2 +- source/blender/blenloader/intern/readfile.c | 4 +- .../blenloader/intern/versioning_legacy.c | 2 +- source/blender/collada/AnimationExporter.cpp | 4 +- source/blender/collada/AnimationImporter.cpp | 2 +- source/blender/collada/DocumentImporter.cpp | 6 +- source/blender/collada/collada_utils.cpp | 2 +- .../blender/editors/animation/anim_markers.c | 6 +- .../blender/editors/include/ED_keyframing.h | 2 +- .../editors/interface/interface_templates.c | 2 +- source/blender/editors/mesh/mesh_navmesh.c | 4 +- source/blender/editors/object/object_add.c | 4 +- source/blender/editors/object/object_hook.c | 4 +- .../blender/editors/object/object_relations.c | 2 +- source/blender/editors/object/object_select.c | 6 +- .../blender/editors/render/render_internal.c | 2 +- source/blender/editors/render/render_opengl.c | 14 ++-- .../blender/editors/render/render_shading.c | 8 +- source/blender/editors/screen/screen_edit.c | 14 ++-- source/blender/editors/screen/screen_ops.c | 4 +- .../editors/sculpt_paint/paint_image.c | 8 +- source/blender/editors/sound/sound_ops.c | 4 +- .../editors/space_buttons/buttons_texture.c | 2 +- .../blender/editors/space_image/space_image.c | 2 +- source/blender/editors/space_node/node_edit.c | 4 +- .../blender/editors/space_node/node_header.c | 2 +- .../editors/space_node/node_templates.c | 2 +- .../editors/space_outliner/outliner_draw.c | 8 +- .../editors/space_outliner/outliner_edit.c | 10 +-- .../editors/space_outliner/outliner_select.c | 12 +-- .../editors/space_outliner/outliner_tools.c | 8 +- .../blender/editors/space_view3d/drawmesh.c | 2 +- .../blender/editors/space_view3d/drawobject.c | 8 +- .../editors/space_view3d/view3d_draw.c | 6 +- .../editors/space_view3d/view3d_edit.c | 2 +- .../editors/space_view3d/view3d_view.c | 4 +- .../editors/transform/transform_conversions.c | 6 +- source/blender/editors/uvedit/uvedit_ops.c | 2 +- source/blender/gpu/intern/gpu_draw.c | 2 +- source/blender/gpu/intern/gpu_material.c | 2 +- source/blender/makesdna/DNA_scene_types.h | 2 +- source/blender/makesrna/intern/rna_main_api.c | 4 +- source/blender/makesrna/intern/rna_object.c | 4 +- source/blender/makesrna/intern/rna_scene.c | 14 ++-- .../blender/makesrna/intern/rna_scene_api.c | 8 +- source/blender/makesrna/intern/rna_space.c | 2 +- source/blender/modifiers/intern/MOD_build.c | 2 +- .../blender/modifiers/intern/MOD_collision.c | 2 +- source/blender/modifiers/intern/MOD_explode.c | 2 +- source/blender/modifiers/intern/MOD_wave.c | 2 +- .../blender/nodes/shader/node_shader_tree.c | 2 +- .../render/intern/source/convertblender.c | 8 +- .../render/intern/source/external_engine.c | 2 +- .../blender/render/intern/source/pipeline.c | 20 ++--- .../render/intern/source/pointdensity.c | 2 +- .../render/intern/source/render_texture.c | 6 +- .../windowmanager/intern/wm_event_system.c | 4 +- .../windowmanager/intern/wm_operators.c | 6 +- source/creator/creator.c | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 2 +- 82 files changed, 256 insertions(+), 254 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43636740e91..fe9b535d373 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1641,6 +1641,7 @@ if(WITH_PYTHON) PATH_SUFFIXES site-packages dist-packages + NO_DEFAULT_PATH ) if(NOT EXISTS "${PYTHON_NUMPY_PATH}") diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 867cc71bf47..d7003729c46 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -202,7 +202,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated) { /* test if we can instance or if the object is modified */ BL::ID b_ob_data = b_ob.data(); - BL::ID key = (object_is_modified(b_ob))? b_ob: b_ob_data; + BL::ID key = (BKE_object_is_modified(b_ob))? b_ob: b_ob_data; BL::Material material_override = render_layer.material_override; /* find shader indices */ @@ -309,7 +309,7 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion) /* skip objects without deforming modifiers. this is not a totally reliable, * would need a more extensive check to see which objects are animated */ - if(!size || !ccl::object_is_deform_modified(b_ob, b_scene, preview)) + if(!size || !ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) return; /* get derived mesh */ diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 16b46aa2e2c..641aa88d6ef 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -34,10 +34,10 @@ CCL_NAMESPACE_BEGIN /* Utilities */ -bool BlenderSync::object_is_modified(BL::Object b_ob) +bool BlenderSync::BKE_object_is_modified(BL::Object b_ob) { /* test if we can instance or if the object is modified */ - if(ccl::object_is_modified(b_ob, b_scene, preview)) { + if(ccl::BKE_object_is_modified(b_ob, b_scene, preview)) { /* modifiers */ return true; } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 7eccf52579d..c0b6e210bb1 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -87,7 +87,7 @@ bool BlenderSync::sync_recalc() if(object_is_mesh(*b_ob)) { if(b_ob->is_updated_data() || b_ob->data().is_updated()) { - BL::ID key = object_is_modified(*b_ob)? *b_ob: b_ob->data(); + BL::ID key = BKE_object_is_modified(*b_ob)? *b_ob: b_ob->data(); mesh_map.set_recalc(key); } } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 904cc1b1831..10afd468850 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -88,7 +88,7 @@ private: /* util */ void find_shader(BL::ID id, vector& used_shaders, int default_shader); - bool object_is_modified(BL::Object b_ob); + bool BKE_object_is_modified(BL::Object b_ob); bool object_is_mesh(BL::Object b_ob); bool object_is_light(BL::Object b_ob); diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 9184e14bc76..b01fa81ee40 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -91,12 +91,12 @@ static inline void object_free_duplilist(BL::Object self) rna_Object_free_duplilist(self.ptr.data, NULL); } -static inline bool object_is_modified(BL::Object self, BL::Scene scene, bool preview) +static inline bool BKE_object_is_modified(BL::Object self, BL::Scene scene, bool preview) { return rna_Object_is_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false; } -static inline bool object_is_deform_modified(BL::Object self, BL::Scene scene, bool preview) +static inline bool BKE_object_is_deform_modified(BL::Object self, BL::Scene scene, bool preview) { return rna_Object_is_deform_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false; } diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index f2c07fb82e0..3a93562707d 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -62,39 +62,43 @@ void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); void BKE_scene_free(struct Scene *sce); -struct Scene *add_scene(const char *name); -struct Base *object_in_scene(struct Object *ob, struct Scene *sce); +struct Scene *BKE_scene_add(const char *name); -void set_scene_bg(struct Main *bmain, struct Scene *sce); -struct Scene *set_scene_name(struct Main *bmain, const char *name); +/* base functions */ +struct Base *BKE_scene_base_find(struct Scene *scene, struct Object *ob); +struct Base *BKE_scene_base_add(struct Scene *sce, struct Object *ob); +void BKE_scene_base_deselect_all(struct Scene *sce); +void BKE_scene_base_select(struct Scene *sce, struct Base *selbase); +int BKE_scene_base_iter_next(struct Scene **scene, int val, struct Base **base, struct Object **ob); -struct Scene *copy_scene(struct Scene *sce, int type); -void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); +void BKE_scene_base_flag_to_objects(struct Scene *scene); +void BKE_scene_base_flag_from_objects(struct Scene *scene); -int next_object(struct Scene **scene, int val, struct Base **base, struct Object **ob); -struct Object *scene_find_camera(struct Scene *sc); -struct Object *scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH -int scene_camera_switch_update(struct Scene *scene); +void BKE_scene_set_background(struct Main *bmain, struct Scene *sce); +struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name); -char *scene_find_marker_name(struct Scene *scene, int frame); -char *scene_find_last_marker_name(struct Scene *scene, int frame); +struct Scene *BKE_scene_copy(struct Scene *sce, int type); +void BKE_scene_unlink(struct Main *bmain, struct Scene *sce, struct Scene *newsce); -struct Base *scene_add_base(struct Scene *sce, struct Object *ob); -void scene_deselect_all(struct Scene *sce); -void scene_select_base(struct Scene *sce, struct Base *selbase); +struct Object *BKE_scene_camera_find(struct Scene *sc); +struct Object *BKE_scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH +int BKE_scene_camera_switch_update(struct Scene *scene); + +char *BKE_scene_find_marker_name(struct Scene *scene, int frame); +char *BKE_scene_find_last_marker_name(struct Scene *scene, int frame); /* checks for cycle, returns 1 if it's all OK */ -int scene_check_setscene(struct Main *bmain, struct Scene *sce); +int BKE_scene_validate_setscene(struct Main *bmain, struct Scene *sce); -float BKE_curframe(struct Scene *scene); -float BKE_frame_to_ctime(struct Scene *scene, const float frame); +float BKE_scene_frame_get(struct Scene *scene); +float BKE_scene_frame_get_from_ctime(struct Scene *scene, const float frame); -void scene_update_tagged(struct Main *bmain, struct Scene *sce); +void BKE_scene_update_tagged(struct Main *bmain, struct Scene *sce); -void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); +void BKE_scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); -struct SceneRenderLayer *scene_add_render_layer(struct Scene *sce, const char *name); -int scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl); +struct SceneRenderLayer *BKE_scene_add_render_layer(struct Scene *sce, const char *name); +int BKE_scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl); /* render profile */ int get_render_subsurf_level(struct RenderData *r, int level); @@ -102,10 +106,7 @@ int get_render_child_particle_number(struct RenderData *r, int num); int get_render_shadow_samples(struct RenderData *r, int samples); float get_render_aosss_error(struct RenderData *r, float error); -int scene_use_new_shading_nodes(struct Scene *scene); - -void copy_baseflags(struct Scene *scene); -void copy_objectflags(struct Scene *scene); +int BKE_scene_use_new_shading_nodes(struct Scene *scene); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 9ed1a2e8956..addbde139d2 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1453,7 +1453,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) bActionStrip *strip, *striplast=NULL, *stripfirst=NULL; float striptime, frametime, length, actlength; float blendfac, stripframe; - float scene_cfra= BKE_curframe(scene); + float scene_cfra= BKE_scene_frame_get(scene); int doit, dostride; if (blocktype==ID_AR) { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 353caece2be..96e962bc3d3 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -353,7 +353,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * that doesn't force complete update, but for now, this is the * most accurate way! */ - scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving + BKE_scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving #endif } @@ -1249,7 +1249,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (G.rendering == 0) no_draw_flag |= PARS_NO_DISP; - ctime = BKE_curframe(scene); /* NOTE: in old animsys, used parent object's timeoffset... */ + ctime = BKE_scene_frame_get(scene); /* NOTE: in old animsys, used parent object's timeoffset... */ totpart = psys->totpart; totchild = psys->totchild; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e2d90b60ffa..56275f5735b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2452,7 +2452,7 @@ void where_is_pose(Scene *scene, Object *ob) if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) armature_rebuild_pose(ob, arm); - ctime = BKE_curframe(scene); /* not accurate... */ + ctime = BKE_scene_frame_get(scene); /* not accurate... */ /* In editmode or restposition we read the data from the bones */ if (arm->edbo || (arm->flag & ARM_RESTPOS)) { diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b0bfd2ee98d..58ada7b0784 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -314,7 +314,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath BLI_strncpy(G.main->name, filepath, FILE_MAX); /* baseflags, groups, make depsgraph, etc */ - set_scene_bg(G.main, CTX_data_scene(C)); + BKE_scene_set_background(G.main, CTX_data_scene(C)); MEM_freeN(bfd); diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index fde5d2d2a2d..2bde31cfd63 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3066,7 +3066,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); dm_p = CDDM_copy(brush->dm); numOfVerts_p = dm_p->getNumVerts(dm_p); mvert_p = dm_p->getVertArray(dm_p); @@ -3076,7 +3076,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); dm_c = brush->dm; numOfVerts_c = dm_c->getNumVerts(dm_c); mvert_c = dm_p->getVertArray(dm_c); @@ -3126,13 +3126,13 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, /* previous frame dm */ scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_scene_frame_get(scene)); copy_m4_m4(prev_obmat, ob->obmat); /* current frame dm */ scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_scene_frame_get(scene)); /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); @@ -4841,7 +4841,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* update object data on this subframe */ if (subframe) { scene_setSubframe(scene, subframe); - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); } /* Prepare materials if required */ if (brush_usesMaterial(brush, scene)) @@ -4854,7 +4854,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su psys_check_enabled(brushObj, brush->psys)) { /* Paint a particle system */ - BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt, BKE_curframe(scene), ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); dynamicPaint_paintParticles(surface, brush->psys, brush, timescale); } } @@ -4874,7 +4874,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su if (subframe) { scene->r.cfra = scene_frame; scene->r.subframe = scene_subframe; - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); } /* process special brush effects, like smudge */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 6e105c7d0bb..c722522250c 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -52,7 +52,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_scene.h" /* object_in_scene */ +#include "BKE_scene.h" /* BKE_scene_base_find */ static void free_group_object(GroupObject *go) { @@ -182,7 +182,7 @@ int add_to_group(Group *group, Object *object, Scene *scene, Base *base) if ((object->flag & OB_FROMGROUP)==0) { if (scene && base==NULL) - base= object_in_scene(object, scene); + base= BKE_scene_base_find(scene, object); object->flag |= OB_FROMGROUP; @@ -223,7 +223,7 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) /* object can be NULL */ if (object && find_group(object, NULL) == NULL) { if (scene && base==NULL) - base= object_in_scene(object, scene); + base= BKE_scene_base_find(scene, object); object->flag &= ~OB_FROMGROUP; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 77728e4114a..8262e8722c6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1222,7 +1222,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d } if (scene->r.stamp & R_STAMP_MARKER) { - char *name = scene_find_last_marker_name(scene, CFRA); + char *name = BKE_scene_find_last_marker_name(scene, CFRA); if (name) BLI_strncpy(text, name, sizeof(text)); else BLI_strncpy(text, "", sizeof(text)); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 9fd8707cc01..a841649e007 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -482,11 +482,11 @@ void BKE_metaball_properties_copy(Scene *scene, Object *active_object) BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.'); - /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL)) + /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */ + if (F_ERROR==BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL)) return; - while (next_object(&sce_iter, 1, &base, &ob)) { + while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) { if (ob->type==OB_MBALL) { if (ob != active_object) { BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); @@ -528,11 +528,11 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) BLI_split_name_num(basisname, &basisnr, basis->id.name+2, '.'); totelem= 0; - /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL)) + /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */ + if (F_ERROR==BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL)) return NULL; - while (next_object(&sce_iter, 1, &base, &ob)) { + while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) { if (ob->type==OB_MBALL) { if (ob==bob) { @@ -1701,15 +1701,15 @@ static float init_meta(Scene *scene, Object *ob) /* return totsize */ int a, obnr, zero_size=0; char obname[MAX_ID_NAME]; - copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from next_object */ + copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */ invert_m4_m4(obinv, ob->obmat); a= 0; BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); /* make main array */ - next_object(&sce_iter, 0, NULL, NULL); - while (next_object(&sce_iter, 1, &base, &bob)) { + BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL); + while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &bob)) { if (bob->type==OB_MBALL) { zero_size= 0; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 5d76458b157..7832947be73 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2093,7 +2093,7 @@ void free_nodesystem(void) free_typeinfos(&ntreeGetType(NTREE_TEXTURE)->node_types); } -/* called from unlink_scene, when deleting a scene goes over all scenes +/* called from BKE_scene_unlink, when deleting a scene goes over all scenes * other than the input, checks if they have render layer nodes referencing * the to-be-deleted scene, and resets them to NULL. */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 37d261c6d29..3cdf45e3569 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -862,9 +862,9 @@ Object *BKE_object_add(struct Scene *scene, int type) ob->lay= scene->lay; - base= scene_add_base(scene, ob); - scene_deselect_all(scene); - scene_select_base(scene, base); + base= BKE_scene_base_add(scene, ob); + BKE_scene_base_deselect_all(scene); + BKE_scene_base_select(scene, base); ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; return ob; @@ -1211,7 +1211,7 @@ void BKE_object_make_local(Object *ob) } else { for (sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) { - if (object_in_scene(ob, sce)) { + if (BKE_scene_base_find(sce, ob)) { if (sce->id.lib) is_lib= TRUE; else is_local= TRUE; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7b2cb147597..0e56839a6e9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3475,7 +3475,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->totpart=0; psys->flag = PSYS_ENABLED|PSYS_CURRENT; - psys->cfra = BKE_frame_to_ctime(scene, CFRA + 1); + psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1); DAG_scene_sort(G.main, scene); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -4266,7 +4266,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta float timestep = psys_get_timestep(sim); /* negative time means "use current time" */ - cfra = state->time > 0 ? state->time : BKE_curframe(sim->scene); + cfra = state->time > 0 ? state->time : BKE_scene_frame_get(sim->scene); if (p>=totpart) { if (!psys->totchild) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 63db4d5e854..e5c95c116fd 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4465,7 +4465,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if (!psys_check_enabled(ob, psys)) return; - cfra= BKE_curframe(scene); + cfra= BKE_scene_frame_get(scene); sim.scene= scene; sim.ob= ob; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b24007ec491..69808db52b6 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2320,8 +2320,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra cache= pid->cache; if (timescale) { - time= BKE_curframe(scene); - nexttime = BKE_frame_to_ctime(scene, CFRA + 1.0f); + time= BKE_scene_frame_get(scene); + nexttime = BKE_scene_frame_get_from_ctime(scene, CFRA + 1.0f); *timescale= MAX2(nexttime - time, 0.0f); } @@ -2743,7 +2743,7 @@ static void *ptcache_bake_thread(void *ptr) efra = data->endframe; for (; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) { - scene_update_for_newframe(data->main, data->scene, data->scene->lay); + BKE_scene_update_for_newframe(data->main, data->scene, data->scene->lay); if (G.background) { printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe); } @@ -2974,7 +2974,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker) CFRA = cfrao; if (bake) /* already on cfra unless baking */ - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); if (thread_data.break_operation) WM_cursor_wait(0); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6c21b462a7a..9e21538b5ca 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -110,7 +110,7 @@ void free_qtcodecdata(QuicktimeCodecData *qcd) } } -Scene *copy_scene(Scene *sce, int type) +Scene *BKE_scene_copy(Scene *sce, int type) { Scene *scen; ToolSettings *ts; @@ -118,7 +118,7 @@ Scene *copy_scene(Scene *sce, int type) if (type == SCE_COPY_EMPTY) { ListBase lb; - scen= add_scene(sce->id.name+2); + scen= BKE_scene_add(sce->id.name+2); lb= scen->r.layers; scen->r= sce->r; @@ -332,7 +332,7 @@ void BKE_scene_free(Scene *sce) sound_destroy_scene(sce); } -Scene *add_scene(const char *name) +Scene *BKE_scene_add(const char *name) { Main *bmain= G.main; Scene *sce; @@ -490,7 +490,7 @@ Scene *add_scene(const char *name) sce->r.osa= 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ - scene_add_render_layer(sce, NULL); + BKE_scene_add_render_layer(sce, NULL); /* game data */ sce->gm.stereoflag = STEREO_NOSTEREO; @@ -544,11 +544,11 @@ Scene *add_scene(const char *name) return sce; } -Base *object_in_scene(Object *ob, Scene *sce) +Base *BKE_scene_base_find(Scene *scene, Object *ob) { Base *base; - base= sce->base.first; + base= scene->base.first; while (base) { if (base->object == ob) return base; base= base->next; @@ -556,7 +556,7 @@ Base *object_in_scene(Object *ob, Scene *sce) return NULL; } -void set_scene_bg(Main *bmain, Scene *scene) +void BKE_scene_set_background(Main *bmain, Scene *scene) { Scene *sce; Base *base; @@ -566,7 +566,7 @@ void set_scene_bg(Main *bmain, Scene *scene) int flag; /* check for cyclic sets, for reading old files but also for definite security (py?) */ - scene_check_setscene(bmain, scene); + BKE_scene_validate_setscene(bmain, scene); /* can happen when switching modes in other scenes */ if (scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT)) @@ -613,11 +613,11 @@ void set_scene_bg(Main *bmain, Scene *scene) } /* called from creator.c */ -Scene *set_scene_name(Main *bmain, const char *name) +Scene *BKE_scene_set_name(Main *bmain, const char *name) { Scene *sce= (Scene *)find_id("SC", name); if (sce) { - set_scene_bg(bmain, sce); + BKE_scene_set_background(bmain, sce); printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name); return sce; } @@ -626,7 +626,7 @@ Scene *set_scene_name(Main *bmain, const char *name) return NULL; } -void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) +void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce) { Scene *sce1; bScreen *sc; @@ -653,7 +653,7 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) /* used by metaballs * doesnt return the original duplicated object, only dupli's */ -int next_object(Scene **scene, int val, Base **base, Object **ob) +int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) { static ListBase *duplilist= NULL; static DupliObject *dupob; @@ -776,7 +776,7 @@ int next_object(Scene **scene, int val, Base **base, Object **ob) return fase; } -Object *scene_find_camera(Scene *sc) +Object *BKE_scene_camera_find(Scene *sc) { Base *base; @@ -788,7 +788,7 @@ Object *scene_find_camera(Scene *sc) } #ifdef DURIAN_CAMERA_SWITCH -Object *scene_camera_switch_find(Scene *scene) +Object *BKE_scene_camera_switch_find(Scene *scene) { TimeMarker *m; int cfra = scene->r.cfra; @@ -809,10 +809,10 @@ Object *scene_camera_switch_find(Scene *scene) } #endif -int scene_camera_switch_update(Scene *scene) +int BKE_scene_camera_switch_update(Scene *scene) { #ifdef DURIAN_CAMERA_SWITCH - Object *camera= scene_camera_switch_find(scene); + Object *camera= BKE_scene_camera_switch_find(scene); if (camera) { scene->camera= camera; return 1; @@ -823,7 +823,7 @@ int scene_camera_switch_update(Scene *scene) return 0; } -char *scene_find_marker_name(Scene *scene, int frame) +char *BKE_scene_find_marker_name(Scene *scene, int frame) { ListBase *markers= &scene->markers; TimeMarker *m1, *m2; @@ -845,7 +845,7 @@ char *scene_find_marker_name(Scene *scene, int frame) /* return the current marker for this frame, * we can have more then 1 marker per frame, this just returns the first :/ */ -char *scene_find_last_marker_name(Scene *scene, int frame) +char *BKE_scene_find_last_marker_name(Scene *scene, int frame) { TimeMarker *marker, *best_marker = NULL; int best_frame = -MAXFRAME*2; @@ -864,9 +864,9 @@ char *scene_find_last_marker_name(Scene *scene, int frame) } -Base *scene_add_base(Scene *sce, Object *ob) +Base *BKE_scene_base_add(Scene *sce, Object *ob) { - Base *b= MEM_callocN(sizeof(*b), "scene_add_base"); + Base *b= MEM_callocN(sizeof(*b), "BKE_scene_base_add"); BLI_addhead(&sce->base, b); b->object= ob; @@ -876,7 +876,7 @@ Base *scene_add_base(Scene *sce, Object *ob) return b; } -void scene_deselect_all(Scene *sce) +void BKE_scene_base_deselect_all(Scene *sce) { Base *b; @@ -886,7 +886,7 @@ void scene_deselect_all(Scene *sce) } } -void scene_select_base(Scene *sce, Base *selbase) +void BKE_scene_base_select(Scene *sce, Base *selbase) { selbase->flag |= SELECT; selbase->object->flag= selbase->flag; @@ -895,7 +895,7 @@ void scene_select_base(Scene *sce, Base *selbase) } /* checks for cycle, returns 1 if it's all OK */ -int scene_check_setscene(Main *bmain, Scene *sce) +int BKE_scene_validate_setscene(Main *bmain, Scene *sce) { Scene *scene; int a, totscene; @@ -921,13 +921,13 @@ int scene_check_setscene(Main *bmain, Scene *sce) /* This function is needed to cope with fractional frames - including two Blender rendering features * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering. */ -float BKE_curframe(Scene *scene) +float BKE_scene_frame_get(Scene *scene) { - return BKE_frame_to_ctime(scene, scene->r.cfra); + return BKE_scene_frame_get_from_ctime(scene, scene->r.cfra); } /* This function is used to obtain arbitrary fractional frames */ -float BKE_frame_to_ctime(Scene *scene, const float frame) +float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame) { float ctime = frame; ctime += scene->r.subframe; @@ -944,7 +944,7 @@ float BKE_frame_to_ctime(Scene *scene, const float frame) */ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) { - float ctime = BKE_curframe(scene); + float ctime = BKE_scene_frame_get(scene); /* scene itself */ if (scene->adt && scene->adt->drivers.first) { @@ -1004,7 +1004,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen } /* this is called in main loop, doing tagged updates before redraw */ -void scene_update_tagged(Main *bmain, Scene *scene) +void BKE_scene_update_tagged(Main *bmain, Scene *scene) { /* keep this first */ BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); @@ -1024,7 +1024,7 @@ void scene_update_tagged(Main *bmain, Scene *scene) /* extra call here to recalc scene animation (for sequencer) */ { AnimData *adt= BKE_animdata_from_id(&scene->id); - float ctime = BKE_curframe(scene); + float ctime = BKE_scene_frame_get(scene); if (adt && (adt->recalc & ADT_RECALC_ANIM)) BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0); @@ -1043,9 +1043,9 @@ void scene_update_tagged(Main *bmain, Scene *scene) } /* applies changes right away, does all sets too */ -void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) +void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) { - float ctime = BKE_curframe(sce); + float ctime = BKE_scene_frame_get(sce); Scene *sce_iter; /* keep this first */ @@ -1064,7 +1064,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* flush recalc flags to dependencies, if we were only changing a frame * this would not be necessary, but if a user or a script has modified - * some datablock before scene_update_tagged was called, we need the flush */ + * some datablock before BKE_scene_update_tagged was called, we need the flush */ DAG_ids_flush_tagged(bmain); /* Following 2 functions are recursive @@ -1094,7 +1094,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) } /* return default layer, also used to patch old files */ -SceneRenderLayer *scene_add_render_layer(Scene *sce, const char *name) +SceneRenderLayer *BKE_scene_add_render_layer(Scene *sce, const char *name) { SceneRenderLayer *srl; @@ -1114,7 +1114,7 @@ SceneRenderLayer *scene_add_render_layer(Scene *sce, const char *name) return srl; } -int scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl) +int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl) { const int act= BLI_findindex(&scene->r.layers, srl); Scene *sce; @@ -1209,13 +1209,13 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) return NULL; } -int scene_use_new_shading_nodes(Scene *scene) +int BKE_scene_use_new_shading_nodes(Scene *scene) { RenderEngineType *type= RE_engines_find(scene->r.engine); return (type && type->flag & RE_USE_SHADING_NODES); } -void copy_baseflags(struct Scene *scene) +void BKE_scene_base_flag_to_objects(struct Scene *scene) { Base *base= scene->base.first; @@ -1225,7 +1225,7 @@ void copy_baseflags(struct Scene *scene) } } -void copy_objectflags(struct Scene *scene) +void BKE_scene_base_flag_from_objects(struct Scene *scene) { Base *base= scene->base.first; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 395214b1609..6e043c74816 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2099,7 +2099,7 @@ static ImBuf *seq_render_scene_strip( if (seq->scene_camera) camera = seq->scene_camera; else { - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); camera = scene->camera; } @@ -2127,7 +2127,7 @@ static ImBuf *seq_render_scene_strip( context.scene->r.seq_prev_type = 3 /* ==OB_SOLID */; /* opengl offscreen render */ - scene_update_for_newframe(context.bmain, scene, scene->lay); + BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type, TRUE, err_out); if (ibuf == NULL) { @@ -2182,7 +2182,7 @@ static ImBuf *seq_render_scene_strip( scene->r.cfra = oldcfra; if (frame != oldcfra) - scene_update_for_newframe(context.bmain, scene, scene->lay); + BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); #ifdef DURIAN_CAMERA_SWITCH /* stooping to new low's in hackyness :( */ diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 144fd9ddb20..b68102885ea 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -2123,7 +2123,7 @@ void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4]) if (scene->camera) ob = scene->camera; else - ob = scene_find_camera(scene); + ob = BKE_scene_camera_find(scene); } if (ob) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 475a05339f5..3005837ba7f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8529,7 +8529,7 @@ static int object_in_any_scene(Main *mainvar, Object *ob) Scene *sce; for (sce= mainvar->scene.first; sce; sce= sce->id.next) - if (object_in_scene(ob, sce)) + if (BKE_scene_base_find(sce, ob)) return 1; return 0; } @@ -8611,7 +8611,7 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) ob->lay= scene->lay; /* assign the base */ - base= scene_add_base(scene, ob); + base= BKE_scene_base_add(scene, ob); base->flag |= SELECT; base->object->flag= base->flag; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 7d8905d5902..6b03fab13e4 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -2144,7 +2144,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (sce->r.yparts<2) sce->r.yparts= 4; /* adds default layer */ if (sce->r.layers.first==NULL) - scene_add_render_layer(sce, NULL); + BKE_scene_add_render_layer(sce, NULL); else { SceneRenderLayer *srl; /* new layer flag for sky, was default for solid */ diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 6565a9e0c2e..3c90c5ad055 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -753,7 +753,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj for (it = frames.begin(); it != frames.end(); it++) { float mat[4][4], ipar[4][4]; - float ctime = BKE_frame_to_ctime(scene, *it); + float ctime = BKE_scene_frame_get_from_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); @@ -1278,7 +1278,7 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i for (it = frames.begin(); it != frames.end(); it++) { float mat[4][4], ipar[4][4]; - float ctime = BKE_frame_to_ctime(scene, *it); + float ctime = BKE_scene_frame_get_from_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 34f7efa9de0..d6b6bfeb73d 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -1772,7 +1772,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) { Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node)); - job->lay = object_in_scene(job, scene)->lay = 2; + job->lay = BKE_scene_base_find(scene, job)->lay = 2; mul_v3_fl(job->size, 0.5f); job->recalc |= OB_RECALC_OB; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 9216d7fa30e..3976d8115c1 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -122,7 +122,7 @@ bool DocumentImporter::import() loader.registerExtraDataCallbackHandler(ehandler); // deselect all to select new objects - scene_deselect_all(CTX_data_scene(mContext)); + BKE_scene_base_deselect_all(CTX_data_scene(mContext)); if (!root.loadDocument(mFilename)) { fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n"); @@ -227,7 +227,7 @@ void DocumentImporter::finish() for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) { Object *ob = *it; - Base *base = object_in_scene(ob, sce); + Base *base = BKE_scene_base_find(sce, ob); if (base) { BLI_remlink(&sce->base, base); BKE_libblock_free_us(&G.main->object, base->object); @@ -340,7 +340,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod Object *obn = BKE_object_copy(source_ob); obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - scene_add_base(sce, obn); + BKE_scene_base_add(sce, obn); if (instance_node) { anim_importer.read_node_transform(instance_node, obn); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index d7ea74b7b04..8b7a28e5fbe 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -120,7 +120,7 @@ Object *bc_add_object(Scene *scene, int type, const char *name) ob->lay= scene->lay; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - scene_select_base(scene, scene_add_base(scene, ob)); + BKE_scene_base_select(scene, BKE_scene_base_add(scene, ob)); return ob; } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2527cb7eb40..1db43177ef0 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1048,7 +1048,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) int sel= 0; if (!extend) - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); for (marker= markers->first; marker; marker= marker->next) { if (marker->frame==cfra) { @@ -1060,7 +1060,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) for (marker= markers->first; marker; marker= marker->next) { if (marker->camera) { if (marker->frame==cfra) { - base= object_in_scene(marker->camera, scene); + base= BKE_scene_base_find(scene, marker->camera); if (base) { ED_base_object_select(base, sel); if (sel) @@ -1437,7 +1437,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op)) marker->camera= ob; /* camera may have changes */ - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); BKE_screen_view3d_scene_sync(sc); WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index afb14191797..3795de7469c 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -292,7 +292,7 @@ short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter); * Checks whether a keyframe exists for the given ID-block one the given frame. * - It is recommended to call this method over the other keyframe-checkers directly, * in case some detail of the implementation changes... - * - frame: the value of this is quite often result of BKE_curframe() + * - frame: the value of this is quite often result of BKE_scene_frame_get() */ short id_frame_has_keyframe(struct ID *id, float frame, short filter); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ee61b2a3141..149921c94b2 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2150,7 +2150,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name, icon); ma = give_current_material(ob, index + 1); - if (ma && !scene_use_new_shading_nodes(scene)) { + if (ma && !BKE_scene_use_new_shading_nodes(scene)) { manode = give_node_material(ma); if (manode) { char str[MAX_ID_NAME + 12]; diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index cc640e38fc2..14d20d68455 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -316,8 +316,8 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, } else { obedit = base->object; - scene_deselect_all(scene); - scene_select_base(scene, base); + BKE_scene_base_deselect_all(scene); + BKE_scene_base_select(scene, base); copy_v3_v3(obedit->loc, co); copy_v3_v3(obedit->rot, rot); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d58b71f54e5..3c19871aac6 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -733,7 +733,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) rename_id(&ob->id, get_lamp_defname(type)); rename_id(&la->id, get_lamp_defname(type)); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &la->id); la->use_nodes = 1; } @@ -923,7 +923,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) { if (scene_iter != scene && !(scene_iter->id.lib)) { - base_other = object_in_scene(base->object, scene_iter); + base_other = BKE_scene_base_find(scene_iter, base->object); if (base_other) { ED_base_object_free_and_unlink(bmain, scene_iter, base_other); } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 6a41cb93e19..6ec844e39b2 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -419,8 +419,8 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) ob = BKE_object_add(scene, OB_EMPTY); - basedit = object_in_scene(obedit, scene); - base = object_in_scene(ob, scene); + basedit = BKE_scene_base_find(scene, obedit); + base = BKE_scene_base_find(scene, ob); base->lay = ob->lay = obedit->lay; /* icky, BKE_object_add sets new base as active. diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 95c9773eabd..666bccaf67e 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1217,7 +1217,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_bases) { - if (!object_in_scene(base->object, scene_to)) { + if (!BKE_scene_base_find(scene_to, base->object)) { Base *nbase = MEM_mallocN(sizeof(Base), "newbase"); *nbase = *base; BLI_addhead(&(scene_to->base), nbase); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ed53e4a9b91..0ef4bb503cf 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -416,7 +416,7 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ - baspar = object_in_scene(basact->object->parent, scene); + baspar = BKE_scene_base_find(scene, basact->object->parent); /* can be NULL if parent in other scene */ if (baspar && BASE_SELECTABLE(v3d, baspar)) { @@ -487,7 +487,7 @@ static short select_grouped_object_hooks(bContext *C, Object *ob) if (md->type == eModifierType_Hook) { hmd = (HookModifierData *) md; if (hmd->object && !(hmd->object->flag & SELECT)) { - base = object_in_scene(hmd->object, scene); + base = BKE_scene_base_find(scene, hmd->object); if (base && (BASE_SELECTABLE(v3d, base))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -886,7 +886,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ Object *ob = (Object *)find_id("OB", tmpname); if (ob) { - Base *secbase = object_in_scene(ob, scene); + Base *secbase = BKE_scene_base_find(scene, ob); if (secbase) { ED_base_object_select(secbase, BA_SELECT); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1a2e42d691a..595b51d22c4 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -170,7 +170,7 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s if (scn) { /* camera switch wont have updated */ scn->r.cfra = (*scene)->r.cfra; - scene_camera_switch_update(scn); + BKE_scene_camera_switch_update(scn); *scene = scn; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 9f611b52669..57588c0e33a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -413,7 +413,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) if (oglrender->timer) { /* exec will not have a timer */ scene->r.cfra = oglrender->cfrao; - scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer); } @@ -478,7 +478,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) Object *camera = NULL; /* update animated image textures for gpu, etc, - * call before scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, scene->r.cfra); /* go to next frame */ @@ -488,17 +488,17 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if (lay & 0xFF000000) lay &= 0xFF000000; - scene_update_for_newframe(bmain, scene, lay); + BKE_scene_update_for_newframe(bmain, scene, lay); CFRA++; } - scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if (view_context) { if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { - /* since scene_update_for_newframe() is used rather + /* since BKE_scene_update_for_newframe() is used rather * then ED_update_for_newframe() the camera needs to be set */ - if (scene_camera_switch_update(scene)) { + if (BKE_scene_camera_switch_update(scene)) { oglrender->v3d->camera = scene->camera; } @@ -506,7 +506,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); camera = scene->camera; } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index bdfcaa90eb1..eb874932d40 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -377,7 +377,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) else { ma = add_material("Material"); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &ma->id); ma->use_nodes = 1; } @@ -477,7 +477,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) else { wo = add_world("World"); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &wo->id); wo->use_nodes = 1; } @@ -521,7 +521,7 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - scene_add_render_layer(scene, NULL); + BKE_scene_add_render_layer(scene, NULL); scene->r.actlay = BLI_countlist(&scene->r.layers) - 1; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); @@ -548,7 +548,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay); - if (!scene_remove_render_layer(CTX_data_main(C), scene, rl)) + if (!BKE_scene_remove_render_layer(CTX_data_main(C), scene, rl)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index e7ad73b3e49..b2a2a371a1a 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1471,8 +1471,8 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) BKE_screen_view3d_sync(v3d, scene); - if (!v3d->camera || !object_in_scene(v3d->camera, scene)) { - v3d->camera= scene_find_camera(sc->scene); + if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { + v3d->camera= BKE_scene_camera_find(sc->scene); // XXX if (sc==curscreen) handle_view3d_lock(); if (!v3d->camera) { ARegion *ar; @@ -1495,7 +1495,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) } CTX_data_scene_set(C, scene); - set_scene_bg(bmain, scene); + BKE_scene_set_background(bmain, scene); ED_render_engine_changed(bmain); ED_update_for_newframe(bmain, scene, screen, 1); @@ -1520,7 +1520,7 @@ void ED_screen_delete_scene(bContext *C, Scene *scene) ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - unlink_scene(bmain, scene, newscene); + BKE_scene_unlink(bmain, scene, newscene); } ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) @@ -1816,7 +1816,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUSED(mute)) { #ifdef DURIAN_CAMERA_SWITCH - void *camera= scene_camera_switch_find(scene); + void *camera= BKE_scene_camera_switch_find(scene); if (camera && scene->camera != camera) { bScreen *sc; scene->camera= camera; @@ -1830,14 +1830,14 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS //extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */ /* update animated image textures for gpu, etc, - * call before scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, scene->r.cfra); ED_clip_update_frame(bmain, scene->r.cfra); /* this function applies the changes too */ /* XXX future: do all windows */ - scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ + BKE_scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4395efc23db..1f30fe691c1 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3319,10 +3319,10 @@ static int scene_new_exec(bContext *C, wmOperator *op) int type= RNA_enum_get(op->ptr, "type"); if (type == SCE_COPY_NEW) { - newscene= add_scene("Scene"); + newscene= BKE_scene_add("Scene"); } else { /* different kinds of copying */ - newscene= copy_scene(scene, type); + newscene= BKE_scene_copy(scene, type); /* these can't be handled in blenkernel curently, so do them here */ if (type == SCE_COPY_LINK_DATA) { diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index f65a8116efb..8bac74e0899 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -310,7 +310,7 @@ typedef struct ProjPaintState { short do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/ short do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */ short do_mask_normal; /* mask out pixels based on their normals */ - short do_new_shading_nodes; /* cache scene_use_new_shading_nodes value */ + short do_new_shading_nodes; /* cache BKE_scene_use_new_shading_nodes value */ float normal_angle; /* what angle to mask at*/ float normal_angle_inner; float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */ @@ -526,7 +526,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) { Image *ima; - if (scene_use_new_shading_nodes(s->scene)) { + if (BKE_scene_use_new_shading_nodes(s->scene)) { MFace *mf = &s->dm_mface[face_index]; ED_object_get_active_image(s->ob, mf->mat_nr + 1, &ima, NULL, NULL); } @@ -542,7 +542,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa { Image *ima; - if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ + if (ps->do_new_shading_nodes) { /* cached BKE_scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface + face_index; ED_object_get_active_image(ps->ob, mf->mat_nr + 1, &ima, NULL, NULL); } @@ -4775,7 +4775,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1; ps->do_occlude = (settings->imapaint.flag & IMAGEPAINT_PROJECT_XRAY) ? 0 : 1; ps->do_mask_normal = (settings->imapaint.flag & IMAGEPAINT_PROJECT_FLAT) ? 0 : 1; - ps->do_new_shading_nodes = scene_use_new_shading_nodes(scene); /* only cache the value */ + ps->do_new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* only cache the value */ if (ps->tool == PAINT_TOOL_CLONE) ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 24bc01989fc..e91b29ff0c1 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -286,11 +286,11 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) for (cfra = (scene->r.sfra > 0) ? (scene->r.sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) { scene->r.cfra = cfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); } scene->r.cfra = oldfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index ba37cb8a892..88f66855cff 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -253,7 +253,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) ButsContextTexture *ct= sbuts->texuser; Scene *scene= CTX_data_scene(C); - if (!scene_use_new_shading_nodes(scene)) { + if (!BKE_scene_use_new_shading_nodes(scene)) { if (ct) { BLI_freelistN(&ct->users); MEM_freeN(ct); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 447028b8bef..426cc3207e4 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -599,7 +599,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) struct BMEditMesh *em = me->edit_btmesh; int sloppy = 1; /* partially selected face is ok */ - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { /* new shading system, get image from material */ BMFace *efa = BM_active_face_get(em->bm, sloppy); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 5166387d6f4..746fa9e34d7 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -289,7 +289,7 @@ void ED_node_shader_default(Scene *scene, ID *id) Material *ma= (Material*)id; ma->nodetree = ntree; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { output_type = SH_NODE_OUTPUT_MATERIAL; shader_type = SH_NODE_BSDF_DIFFUSE; } @@ -347,7 +347,7 @@ void ED_node_shader_default(Scene *scene, ID *id) nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { sock= in->inputs.first; copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 7ddc4bdf857..bb52c1570aa 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -201,7 +201,7 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) } if (ntree->type == NTREE_SHADER) { - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 13e85c7f74d..785eafeb7c9 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -333,7 +333,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) int compatibility= 0; if (ntree->type == NTREE_SHADER) { - if (scene_use_new_shading_nodes(arg->scene)) + if (BKE_scene_use_new_shading_nodes(arg->scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 042b668c9cc..a32923f17c9 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -136,7 +136,7 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) if (ob->restrictflag & OB_RESTRICT_VIEW) { /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); @@ -153,7 +153,7 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) if (ob->restrictflag & OB_RESTRICT_SELECT) { /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); @@ -230,7 +230,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) if (flag==OB_RESTRICT_VIEW) if (gob->ob->flag & SELECT) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT); } } else { @@ -241,7 +241,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) if (flag==OB_RESTRICT_VIEW) if ((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 7b200e9593d..9bc87a27ba3 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -348,7 +348,7 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre /* add check for edit mode */ if (!common_restrict_check(C, ob)) return; - if (base || (base= object_in_scene(ob, scene))) { + if (base || (base= BKE_scene_base_find(scene, ob))) { if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); } @@ -395,7 +395,7 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme { Base *base= (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->object->restrictflag^=OB_RESTRICT_SELECT; } @@ -441,7 +441,7 @@ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme { Base *base= (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->object->restrictflag^=OB_RESTRICT_RENDER; } @@ -1487,7 +1487,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) - ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { @@ -1663,7 +1663,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) - ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 00b3979b074..800953c1a62 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -159,7 +159,7 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops } /* find associated base in current scene */ - base= object_in_scene(ob, scene); + base= BKE_scene_base_find(scene, ob); if (base) { if (set==2) { @@ -171,7 +171,7 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops } else { /* deleselect all */ - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); ED_base_object_select(base, BA_SELECT); } if (C) { @@ -551,7 +551,7 @@ static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), S static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { Object *ob= (Object *)tselem->id; - Base *base= object_in_scene(ob, scene); + Base *base= BKE_scene_base_find(scene, ob); if (set) { if (scene->obedit) @@ -745,15 +745,15 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa } for (gob= gr->gobject.first; gob; gob= gob->next) { - ED_base_object_select(object_in_scene(gob->ob, scene), sel); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), sel); } } else { - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); for (gob= gr->gobject.first; gob; gob= gob->next) { if ((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 12575e0a151..c22ed22ff92 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -242,7 +242,7 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, { Base *base= (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { base->flag |= SELECT; base->object->flag |= SELECT; @@ -253,7 +253,7 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t { Base *base= (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->flag &= ~SELECT; base->object->flag &= ~SELECT; @@ -265,7 +265,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto Base *base= (Base *)te->directdata; if (base==NULL) - base= object_in_scene((Object *)tselem->id, scene); + base= BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { // check also library later if (scene->obedit==base->object) @@ -349,7 +349,7 @@ static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElemen Base *base; for (gob=group->gobject.first; gob; gob=gob->next) { - base= object_in_scene(gob->ob, scene); + base= BKE_scene_base_find(scene, gob->ob); if (base) { base->object->flag |= SELECT; base->flag |= SELECT; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 530b26d566a..b27ca604810 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -928,7 +928,7 @@ static int tex_mat_set_face_editmesh_cb(void *userData, int index) void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { - if ((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 72697497646..37f24dda8ab 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -190,7 +190,7 @@ static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) return TRUE; /* textured solid */ - if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !scene_use_new_shading_nodes(scene)) + if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !BKE_scene_use_new_shading_nodes(scene)) return TRUE; return FALSE; @@ -332,7 +332,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) return 0; return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); @@ -4285,7 +4285,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv totpart = psys->totpart; - cfra = BKE_curframe(scene); + cfra = BKE_scene_frame_get(scene); if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL) draw_as = PART_DRAW_DOT; @@ -7141,7 +7141,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for (ct = targets.first; ct; ct = ct->next) { /* calculate target's matrix */ if (cti->get_target_matrix) - cti->get_target_matrix(curcon, cob, ct, BKE_curframe(scene)); + cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene)); else unit_m4(ct->matrix); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 7ede8e01194..fe7511c70cc 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -847,7 +847,7 @@ static void draw_selected_name(Scene *scene, Object *ob) short offset = 30; /* get name of marker on current frame (if available) */ - markern = scene_find_marker_name(scene, CFRA); + markern = BKE_scene_find_marker_name(scene, CFRA); /* check if there is an object */ if (ob) { @@ -910,7 +910,7 @@ static void draw_selected_name(Scene *scene, Object *ob) } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_scene_frame_get(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -2297,7 +2297,7 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { if (v3d->drawtype == OB_MATERIAL) mask |= CD_MASK_ORCO; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index cd128798d2a..b5354ac5e03 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2851,7 +2851,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) v3d->camera = ob; if (v3d->camera == NULL) - v3d->camera = scene_find_camera(scene); + v3d->camera = BKE_scene_camera_find(scene); /* couldnt find any useful camera, bail out */ if (v3d->camera == NULL) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 22ac3b8a8e8..1509242cf58 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1799,8 +1799,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) RestoreState(C, prevwin); //XXX restore_all_scene_cfra(scene_cfra_store); - set_scene_bg(CTX_data_main(C), startscene); - //XXX scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_set_background(CTX_data_main(C), startscene); + //XXX BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; #else diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index af5c414a751..d7ad0c0c9ea 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4357,7 +4357,7 @@ static void set_trans_object_base_flags(TransInfo *t) return; /* makes sure base flags and object flags are identical */ - copy_baseflags(t->scene); + BKE_scene_base_flag_to_objects(t->scene); /* handle pending update events, otherwise they got copied below */ for (base= scene->base.first; base; base= base->next) { @@ -4375,7 +4375,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* if parent selected, deselect */ while (parsel) { if (parsel->flag & SELECT) { - Base *parbase = object_in_scene(parsel, scene); + Base *parbase = BKE_scene_base_find(scene, parsel); if (parbase) { /* in rare cases this can fail */ if (TESTBASELIB_BGMODE(v3d, scene, parbase)) { break; @@ -5878,7 +5878,7 @@ void createTransData(bContext *C, TransInfo *t) * lines below just check is also visible */ Object *ob_armature= modifiers_isDeformedByArmature(ob); if (ob_armature && ob_armature->mode & OB_MODE_POSE) { - Base *base_arm= object_in_scene(ob_armature, t->scene); + Base *base_arm= BKE_scene_base_find(t->scene, ob_armature); if (base_arm) { View3D *v3d = t->view; if (BASE_VISIBLE(v3d, base_arm)) { diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b515f30e150..53bf19c04cc 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -186,7 +186,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im return; } - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { /* new shading system, assign image in material */ int sloppy = 1; BMFace *efa = BM_active_face_get(em->bm, sloppy); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index f41d1c3c8a3..6add8cd74c6 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1076,7 +1076,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O GPUBlendMode alphablend; int a; int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; - int new_shading_nodes = scene_use_new_shading_nodes(scene); + int new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* initialize state */ memset(&GMS, 0, sizeof(GMS)); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 383dd6b8f2f..f75c1576fb9 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1501,7 +1501,7 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma) GPU_material_output_link(mat, outlink); } - if (!scene_use_new_shading_nodes(scene)) { + if (!BKE_scene_use_new_shading_nodes(scene)) { if (gpu_do_color_management(mat)) if (mat->outlink) GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 25abfe02db6..a40b07a8d01 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1398,7 +1398,7 @@ typedef struct Scene { #define SCE_FRAME_DROP (1<<3) - /* return flag next_object function */ + /* return flag BKE_scene_base_iter_next function */ #define F_ERROR -1 #define F_START 0 #define F_SCENE 1 diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index bba85cadbc3..2b6582bc1d9 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -109,7 +109,7 @@ void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *ca Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name) { - return add_scene(name); + return BKE_scene_add(name); } void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) { @@ -128,7 +128,7 @@ void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struc if (CTX_wm_screen(C)->scene == scene) ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - unlink_scene(bmain, scene, newscene); + BKE_scene_unlink(bmain, scene, newscene); } Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 4effa9f7f38..3e8ee8cfe10 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -263,7 +263,7 @@ static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerR if (scene) { Object *ob = (Object*)ptr->id.data; short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT; - ED_base_object_select(object_in_scene(ob, scene), mode); + ED_base_object_select(BKE_scene_base_find(scene, ob), mode); } } @@ -298,7 +298,7 @@ static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) Object *ob = (Object*)ptr->id.data; Base *base; - base = scene ? object_in_scene(ob, scene) : NULL; + base = scene ? BKE_scene_base_find(scene, ob) : NULL; if (!base) return; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 9da230d90e8..aae5d5ae031 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -330,12 +330,12 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report Scene *scene_act = CTX_data_scene(C); Base *base; - if (object_in_scene(ob, scene)) { + if (BKE_scene_base_find(scene, ob)) { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\"", ob->id.name+2, scene->id.name+2); return NULL; } - base = scene_add_base(scene, ob); + base = BKE_scene_base_add(scene, ob); id_us_plus(&ob->id); /* this is similar to what object_add_type and BKE_object_add do */ @@ -357,7 +357,7 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *ob) { - Base *base = object_in_scene(ob, scene); + Base *base = BKE_scene_base_find(scene, ob); if (!base) { BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in this scene '%s'", ob->id.name+2, scene->id.name+2); return; @@ -401,7 +401,7 @@ static void rna_Scene_active_object_set(PointerRNA *ptr, PointerRNA value) { Scene *scene = (Scene*)ptr->data; if (value.data) - scene->basact = object_in_scene((Object*)value.data, scene); + scene->basact = BKE_scene_base_find(scene, (Object *)value.data); else scene->basact = NULL; } @@ -993,7 +993,7 @@ static void rna_RenderSettings_active_layer_set(PointerRNA *ptr, PointerRNA valu static SceneRenderLayer *rna_RenderLayer_new(ID *id, RenderData *UNUSED(rd), const char *name) { Scene *scene = (Scene *)id; - SceneRenderLayer *srl = scene_add_render_layer(scene, name); + SceneRenderLayer *srl = BKE_scene_add_render_layer(scene, name); WM_main_add_notifier(NC_SCENE|ND_RENDER_OPTIONS, NULL); @@ -1005,7 +1005,7 @@ static void rna_RenderLayer_remove(ID *id, RenderData *UNUSED(rd), Main *bmain, { Scene *scene = (Scene *)id; - if (!scene_remove_render_layer(bmain, scene, srl)) { + if (!BKE_scene_remove_render_layer(bmain, scene, srl)) { BKE_reportf(reports, RPT_ERROR, "RenderLayer '%s' could not be removed from scene '%s'", srl->name, scene->id.name+2); } @@ -1125,7 +1125,7 @@ static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) static int rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) { Scene *scene = (Scene*)ptr->id.data; - return scene_use_new_shading_nodes(scene); + return BKE_scene_use_new_shading_nodes(scene); } static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index c92a29cec3c..a5e807a9622 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -56,11 +56,11 @@ void rna_Scene_frame_set(Scene *scene, int frame, float subframe) scene->r.subframe = subframe; CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME); - scene_update_for_newframe(G.main, scene, (1<<20) - 1); - scene_camera_switch_update(scene); + BKE_scene_update_for_newframe(G.main, scene, (1<<20) - 1); + BKE_scene_camera_switch_update(scene); /* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call - * scene_update_for_newframe which will loose any un-keyed changes [#24690] */ + * BKE_scene_update_for_newframe which will loose any un-keyed changes [#24690] */ /* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */ /* instead just redraw the views */ @@ -69,7 +69,7 @@ void rna_Scene_frame_set(Scene *scene, int frame, float subframe) static void rna_Scene_update_tagged(Scene *scene) { - scene_update_tagged(G.main, scene); + BKE_scene_update_tagged(G.main, scene); } static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 51f5cdcda85..aafcc381c51 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -494,7 +494,7 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_SOLID); RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_TEXTURE); - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_MATERIAL); if (type->view_draw) diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index ddfb793bd5d..8e23555ea12 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -115,7 +115,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), faceMap = MEM_callocN(sizeof(*faceMap) * numPoly_src, "build modifier faceMap"); for (i = 0; i < numPoly_src; i++) faceMap[i] = i; - frac = (BKE_curframe(md->scene) - bmd->start) / bmd->length; + frac = (BKE_scene_frame_get(md->scene) - bmd->start) / bmd->length; CLAMP(frac, 0.0f, 1.0f); numFaces_dst = numPoly_src * frac; diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 9636104cb06..e0b9939d152 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -131,7 +131,7 @@ static void deformVerts(ModifierData *md, Object *ob, CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); - current_time = BKE_curframe(md->scene); + current_time = BKE_scene_frame_get(md->scene); if (G.rt > 0) printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew); diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 4270659d851..429369d6650 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -815,7 +815,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* timestep= psys_get_timestep(&sim); */ - cfra= BKE_curframe(scene); + cfra= BKE_scene_frame_get(scene); /* hash table for vertice <-> particle relations */ vertpahash= BLI_edgehash_new(); diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 5fa3090cd87..db5538aba51 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -178,7 +178,7 @@ static void waveModifier_do(WaveModifierData *md, MVert *mvert = NULL; MDeformVert *dvert; int defgrp_index; - float ctime = BKE_curframe(scene); + float ctime = BKE_scene_frame_get(scene); float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); float lifefac = wmd->height; diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index c028ca83664..716d31a8cd1 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -83,7 +83,7 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f func(calldata, NODE_CLASS_INPUT, IFACE_("Input")); func(calldata, NODE_CLASS_OUTPUT, IFACE_("Output")); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { func(calldata, NODE_CLASS_SHADER, IFACE_("Shader")); func(calldata, NODE_CLASS_TEXTURE, IFACE_("Texture")); } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 5df78a3f5da..75901008d9f 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1574,7 +1574,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem float hasize, pa_size, r_tilt, r_length; float pa_time, pa_birthtime, pa_dietime; float random, simplify[2], pa_co[3]; - const float cfra= BKE_curframe(re->scene); + const float cfra= BKE_scene_frame_get(re->scene); int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0, use_duplimat = 0; int totchild=0; int seed, path_nbr=0, orco1=0, num; @@ -5051,12 +5051,12 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* applies changes fully */ if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) - scene_update_for_newframe(re->main, re->scene, lay); + BKE_scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ if (use_camera_view && camera) { /* called before but need to call again in case of lens animation from the - * above call to scene_update_for_newframe, fixes bug. [#22702]. + * above call to BKE_scene_update_for_newframe, fixes bug. [#22702]. * following calls don't depend on 'RE_SetCamera' */ RE_SetCamera(re, camera); @@ -5206,7 +5206,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la /* applies changes fully */ scene->r.cfra += timeoffset; - scene_update_for_newframe(re->main, re->scene, lay); + BKE_scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ if (camera) { diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index b3c7a565d55..c23a93a52fe 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -313,7 +313,7 @@ int RE_engine_render(Render *re, int do_all) engine->camera_override = re->camera_override; if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) - scene_update_for_newframe(re->main, re->scene, re->lay); + BKE_scene_update_for_newframe(re->main, re->scene, re->lay); if (type->update) type->update(engine, re->main, re->scene); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index f0fea072530..fef542b9957 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1265,7 +1265,7 @@ static void render_scene(Render *re, Scene *sce, int cfra) sce->r.cfra= cfra; - scene_camera_switch_update(sce); + BKE_scene_camera_switch_update(sce); /* exception: scene uses own size (unfinished code) */ if (0) { @@ -1282,7 +1282,7 @@ static void render_scene(Render *re, Scene *sce, int cfra) resc->lay= sce->lay; /* ensure scene has depsgraph, base flags etc OK */ - set_scene_bg(re->main, sce); + BKE_scene_set_background(re->main, sce); /* copy callbacks */ resc->display_draw= re->display_draw; @@ -1368,7 +1368,7 @@ static void ntree_render_scenes(Render *re) /* restore scene if we rendered another last */ if (restore_scene) - set_scene_bg(re->main, re->scene); + BKE_scene_set_background(re->main, re->scene); } /* bad call... need to think over proper method still */ @@ -1591,7 +1591,7 @@ static void do_render_composite_fields_blur_3d(Render *re) R.stats_draw= re->stats_draw; if (update_newframe) - scene_update_for_newframe(re->main, re->scene, re->lay); + BKE_scene_update_for_newframe(re->main, re->scene, re->lay); if (re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, ntree); @@ -1654,7 +1654,7 @@ static void do_render_seq(Render * re) if (recurs_depth==0) { /* otherwise sequencer animation isn't updated */ - BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_curframe(re->scene) + BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_scene_frame_get(re->scene) } recurs_depth++; @@ -1713,7 +1713,7 @@ static void do_render_seq(Render * re) /* main loop: doing sequence + fields + blur + 3d render + compositing */ static void do_render_all_options(Render *re) { - scene_camera_switch_update(re->scene); + BKE_scene_camera_switch_update(re->scene); re->i.starttime= PIL_check_seconds_timer(); @@ -1751,7 +1751,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) int check_comp= 1; if (camera_override == NULL && scene->camera == NULL) - scene->camera= scene_find_camera(scene); + scene->camera= BKE_scene_camera_find(scene); if (scene->r.scemode&R_DOSEQ) { if (scene->ed) { @@ -1762,7 +1762,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) while (seq) { if (seq->type == SEQ_SCENE && seq->scene) { if (!seq->scene_camera) { - if (!seq->scene->camera && !scene_find_camera(seq->scene)) { + if (!seq->scene->camera && !BKE_scene_camera_find(seq->scene)) { if (seq->scene == scene) { /* for current scene camera could be unneeded due to compisite nodes */ check_comp= 1; @@ -1788,7 +1788,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) if (node->type == CMP_NODE_R_LAYERS) { Scene *sce= node->id ? (Scene*)node->id : scene; - if (!sce->camera && !scene_find_camera(sce)) { + if (!sce->camera && !BKE_scene_camera_find(sce)) { /* all render layers nodes need camera */ return 0; } @@ -2195,7 +2195,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri else updatelay= re->lay; - scene_update_for_newframe(bmain, scene, updatelay); + BKE_scene_update_for_newframe(bmain, scene, updatelay); continue; } else diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 8bbb16739f7..96a1a13b75f 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -106,7 +106,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa ParticleKey state; ParticleSimulationData sim= {NULL}; ParticleData *pa=NULL; - float cfra = BKE_curframe(re->scene); + float cfra = BKE_scene_frame_get(re->scene); int i /*, childexists*/ /* UNUSED */; int total_particles, offset=0; int data_used = point_data_used(pd); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 0c090e7e984..1332bf8922c 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -106,7 +106,7 @@ static void init_render_texture(Render *re, Tex *tex) if (tex->type==TEX_PLUGIN) { if (tex->plugin && tex->plugin->doit) { if (tex->plugin->cfra) { - *(tex->plugin->cfra)= (float)cfra; //BKE_curframe(re->scene); // XXX old animsys - timing stuff to be fixed + *(tex->plugin->cfra)= (float)cfra; //BKE_scene_frame_get(re->scene); // XXX old animsys - timing stuff to be fixed } } } @@ -3558,7 +3558,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) mat = localize_material(orig_mat); /* update material anims */ - BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_curframe(scene), ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); /* strip material copy from unsupported flags */ for (tex_nr=0; tex_nrtex = localize_texture(mtex->tex); /* update texture anims */ - BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_curframe(scene), ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); /* update texture cache if required */ if (tex->type==TEX_VOXELDATA) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 56a7ff30ad8..fd3e287a6a5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -240,7 +240,7 @@ void wm_event_do_notifiers(bContext *C) if (do_anim) { /* XXX, quick frame changes can cause a crash if framechange and rendering - * collide (happens on slow scenes), scene_update_for_newframe can be called + * collide (happens on slow scenes), BKE_scene_update_for_newframe can be called * twice which can depgraph update the same object at once */ if (!G.rendering) { @@ -311,7 +311,7 @@ void wm_event_do_notifiers(bContext *C) /* XXX, hack so operators can enforce datamasks [#26482], gl render */ win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal; - scene_update_tagged(bmain, win->screen->scene); + BKE_scene_update_tagged(bmain, win->screen->scene); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index db0429d33ab..e9915361833 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1774,7 +1774,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* now we have or selected, or an indicated file */ if (RNA_boolean_get(op->ptr, "autoselect")) - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); flag = wm_link_append_flag(op); @@ -3533,7 +3533,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) if (a & 1) scene->r.cfra--; else scene->r.cfra++; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); } else if (type == 5) { @@ -3548,7 +3548,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) if (scene->r.cfra > scene->r.efra) scene->r.cfra = scene->r.sfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); redraw_timer_window_swap(C); } } diff --git a/source/creator/creator.c b/source/creator/creator.c index 4847df1168d..8394ff32750 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -795,7 +795,7 @@ static int set_scene(int argc, const char **argv, void *data) { if (argc > 1) { bContext *C = data; - Scene *scene = set_scene_name(CTX_data_main(C), argv[1]); + Scene *scene = BKE_scene_set_name(CTX_data_main(C), argv[1]); if (scene) { CTX_data_scene_set(C, scene); } diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index ad232818c33..6659f137057 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -188,7 +188,7 @@ extern "C" { #endif //XXX #include "BSE_headerbuttons.h" //XXX void update_for_newframe(); -//void scene_update_for_newframe(struct Scene *sce, unsigned int lay); +//void BKE_scene_update_for_newframe(struct Scene *sce, unsigned int lay); //#include "BKE_ipo.h" //void do_all_data_ipos(void); #ifdef __cplusplus From 34b18fcbc18c6d89a1a1516d19c489994e4964dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 14:52:04 +0000 Subject: [PATCH 77/88] code cleanup: BKE_ naming, also make bpy.data.images.load() always load a new image. (not use existing one) --- source/blender/blenkernel/BKE_font.h | 14 ++--- source/blender/blenkernel/BKE_image.h | 6 +- source/blender/blenkernel/BKE_text.h | 10 +-- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/displist.c | 2 +- source/blender/blenkernel/intern/font.c | 20 +++--- source/blender/blenkernel/intern/image.c | 63 +++++++++++-------- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/text.c | 10 +-- source/blender/blenlib/intern/freetypefont.c | 2 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/collada/DocumentImporter.cpp | 2 +- source/blender/editors/curve/editfont.c | 22 +++---- .../blender/editors/interface/interface_ops.c | 6 +- source/blender/editors/mesh/mesh_data.c | 2 +- source/blender/editors/object/object_edit.c | 2 +- .../blender/editors/render/render_shading.c | 2 +- .../blender/editors/space_image/image_ops.c | 2 +- source/blender/editors/space_node/node_edit.c | 2 +- source/blender/editors/space_text/text_ops.c | 6 +- .../blender/editors/space_view3d/drawobject.c | 2 +- .../editors/space_view3d/view3d_edit.c | 2 +- source/blender/makesrna/intern/rna_ID.c | 2 +- source/blender/makesrna/intern/rna_main_api.c | 8 +-- source/blender/makesrna/intern/rna_text_api.c | 4 +- .../blender/windowmanager/intern/wm_files.c | 2 +- .../windowmanager/intern/wm_init_exit.c | 2 +- source/creator/creator.c | 2 +- .../gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 +- 30 files changed, 109 insertions(+), 98 deletions(-) diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 640a70a8e87..6636a70e94d 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -71,17 +71,17 @@ typedef struct EditFont { } EditFont; -void BKE_font_register_builtin(void *mem, int size); +void BKE_vfont_builtin_register(void *mem, int size); void BKE_vfont_free(struct VFont *sc); -void free_ttfont(void); -struct VFont *get_builtin_font(void); -struct VFont *load_vfont(struct Main *bmain, const char *name); -struct TmpFont *vfont_find_tmpfont(struct VFont *vfont); +void BKE_vfont_free_global_ttf(void); +struct VFont *BKE_vfont_builtin_get(void); +struct VFont *BKE_vfont_load(struct Main *bmain, const char *name); +struct TmpFont *BKE_vfont_find_tmpfont(struct VFont *vfont); -struct chartrans *BKE_text_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode); +struct chartrans *BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode); -int BKE_font_getselection(struct Object *ob, int *start, int *end); +int BKE_vfont_select_get(struct Object *ob, int *start, int *end); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 637b57af0bc..d9a656a8a40 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -74,7 +74,7 @@ struct anim *openanim(const char *name, int flags, int streamindex); void image_de_interlace(struct Image *ima, int odd); -void make_local_image(struct Image *ima); +void BKE_image_make_local(struct Image *ima); void tag_image_time(struct Image *ima); void free_old_images(void); @@ -130,8 +130,10 @@ struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser); struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r); void BKE_image_release_ibuf(struct Image *ima, void *lock); +/* returns a new image or NULL if it can't load */ +struct Image *BKE_image_load(const char *filepath); /* returns existing Image when filename/type is same (frame optional) */ -struct Image *BKE_add_image_file(const char *name); +struct Image *BKE_image_load_exists(const char *filepath); /* adds image, adds ibuf, generates color or pattern */ struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 4b033557026..875903f2e20 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -45,14 +45,14 @@ struct SpaceText; void BKE_text_free (struct Text *text); void txt_set_undostate (int u); int txt_get_undostate (void); -struct Text* add_empty_text (const char *name); +struct Text* BKE_text_add (const char *name); int txt_extended_ascii_as_utf8(char **str); -int reopen_text (struct Text *text); -struct Text* add_text (const char *file, const char *relpath); +int BKE_text_reload (struct Text *text); +struct Text* BKE_text_load (const char *file, const char *relpath); struct Text* BKE_text_copy (struct Text *ta); void BKE_text_unlink (struct Main *bmain, struct Text *text); -void clear_text(struct Text *text); -void write_text(struct Text *text, const char *str); +void BKE_text_clear (struct Text *text); +void BKE_text_write (struct Text *text, const char *str); char* txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 96e962bc3d3..1d05ecca909 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1545,7 +1545,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i /* in par the family name is stored, use this to find the other objects */ - chartransdata= BKE_text_to_curve(G.main, scene, par, FO_DUPLI); + chartransdata= BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI); if (chartransdata==NULL) return; cu= par->data; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 04a2eef5615..bfefc1f0cd9 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -175,7 +175,7 @@ Curve *BKE_curve_add(const char *name, int type) cu->bb= BKE_boundbox_alloc_unit(); if (type==OB_FONT) { - cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font(); + cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= BKE_vfont_builtin_get(); cu->vfont->id.us+=4; cu->str= MEM_mallocN(12, "str"); BLI_strncpy(cu->str, "Text", 12); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 60f060d154e..ebcebaedd2d 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1271,7 +1271,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (cu->path) free_path(cu->path); cu->path= NULL; - if (ob->type==OB_FONT) BKE_text_to_curve(G.main, scene, ob, 0); + if (ob->type==OB_FONT) BKE_vfont_to_curve(G.main, scene, ob, 0); if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 03a1298a053..fa57cc7ce44 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -93,7 +93,7 @@ void BKE_vfont_free(struct VFont *vf) static void *builtin_font_data= NULL; static int builtin_font_size= 0; -void BKE_font_register_builtin(void *mem, int size) +void BKE_vfont_builtin_register(void *mem, int size) { builtin_font_data= mem; builtin_font_size= size; @@ -115,7 +115,7 @@ static PackedFile *get_builtin_packedfile(void) } } -void free_ttfont(void) +void BKE_vfont_free_global_ttf(void) { struct TmpFont *tf; @@ -127,7 +127,7 @@ void free_ttfont(void) BLI_freelistN(&ttfdata); } -struct TmpFont *vfont_find_tmpfont(VFont *vfont) +struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont) { struct TmpFont *tmpfnt = NULL; @@ -151,7 +151,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (vfont==NULL) return NULL; // Try finding the font from font list - tmpfnt = vfont_find_tmpfont(vfont); + tmpfnt = BKE_vfont_find_tmpfont(vfont); // And then set the data if (!vfont->data) { @@ -210,7 +210,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) return vfont->data; } -VFont *load_vfont(Main *bmain, const char *name) +VFont *BKE_vfont_load(Main *bmain, const char *name) { char filename[FILE_MAXFILE]; VFont *vfont= NULL; @@ -290,7 +290,7 @@ static VFont *which_vfont(Curve *cu, CharInfo *info) } } -VFont *get_builtin_font(void) +VFont *BKE_vfont_builtin_get(void) { VFont *vf; @@ -298,7 +298,7 @@ VFont *get_builtin_font(void) if (strcmp(vf->name, FO_BUILTIN_NAME)==0) return vf; - return load_vfont(G.main, FO_BUILTIN_NAME); + return BKE_vfont_load(G.main, FO_BUILTIN_NAME); } static VChar *find_vfont_char(VFontData *vfd, intptr_t character) @@ -487,7 +487,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } } -int BKE_font_getselection(Object *ob, int *start, int *end) +int BKE_vfont_select_get(Object *ob, int *start, int *end) { Curve *cu= ob->data; @@ -520,7 +520,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) } } -struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int mode) +struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode) { VFont *vfont, *oldvfont; VFontData *vfd= NULL; @@ -605,7 +605,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if (cu->selboxes) MEM_freeN(cu->selboxes); cu->selboxes = NULL; - if (BKE_font_getselection(ob, &selstart, &selend)) + if (BKE_vfont_select_get(ob, &selstart, &selend)) cu->selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes"); tb = &(cu->tb[0]); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8262e8722c6..1690ad9e3aa 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -327,7 +327,7 @@ static void extern_local_image(Image *UNUSED(ima)) * match id_make_local pattern. */ } -void make_local_image(struct Image *ima) +void BKE_image_make_local(struct Image *ima) { Main *bmain= G.main; Tex *tex; @@ -505,26 +505,48 @@ void BKE_image_merge(Image *dest, Image *source) } } +Image *BKE_image_load(const char *filepath) +{ + Image *ima; + int file, len; + const char *libname; + char str[FILE_MAX]; + + BLI_strncpy(str, filepath, sizeof(str)); + BLI_path_abs(str, G.main->name); + + /* exists? */ + file= BLI_open(str, O_BINARY|O_RDONLY, 0); + if (file== -1) return NULL; + close(file); + + /* create a short library name */ + len= strlen(filepath); + + while (len > 0 && filepath[len - 1] != '/' && filepath[len - 1] != '\\') len--; + libname= filepath+len; + + ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); + BLI_strncpy(ima->name, filepath, sizeof(ima->name)); + + if (BLI_testextensie_array(filepath, imb_ext_movie)) + ima->source= IMA_SRC_MOVIE; + + return ima; +} /* checks if image was already loaded, then returns same image */ /* otherwise creates new. */ /* does not load ibuf itself */ /* pass on optional frame for #name images */ -Image *BKE_add_image_file(const char *name) +Image *BKE_image_load_exists(const char *filepath) { Image *ima; - int file, len; - const char *libname; char str[FILE_MAX], strtest[FILE_MAX]; - BLI_strncpy(str, name, sizeof(str)); + BLI_strncpy(str, filepath, sizeof(str)); BLI_path_abs(str, G.main->name); - - /* exists? */ - file= BLI_open(str, O_BINARY|O_RDONLY, 0); - if (file== -1) return NULL; - close(file); - + /* first search an identical image */ for (ima= G.main->image.first; ima; ima= ima->id.next) { if (ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) { @@ -533,7 +555,7 @@ Image *BKE_add_image_file(const char *name) if (BLI_path_cmp(strtest, str)==0) { if (ima->anim==NULL || ima->id.us==0) { - BLI_strncpy(ima->name, name, sizeof(ima->name)); /* for stringcode */ + BLI_strncpy(ima->name, filepath, sizeof(ima->name)); /* for stringcode */ ima->id.us++; /* officially should not, it doesn't link here! */ if (ima->ok==0) ima->ok= IMA_OK; @@ -543,21 +565,8 @@ Image *BKE_add_image_file(const char *name) } } } - /* add new image */ - - /* create a short library name */ - len= strlen(name); - - while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\') len--; - libname= name+len; - - ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); - BLI_strncpy(ima->name, name, sizeof(ima->name)); - - if (BLI_testextensie_array(name, imb_ext_movie)) - ima->source= IMA_SRC_MOVIE; - - return ima; + + return BKE_image_load(filepath); } static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 1c13c96d8a3..e9520566dd0 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -212,7 +212,7 @@ int id_make_local(ID *id, int test) if (!test) make_local_texture((Tex *)id); return 1; case ID_IM: - if (!test) make_local_image((Image *)id); + if (!test) BKE_image_make_local((Image *)id); return 1; case ID_LT: if (!test) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bd925faf847..e3e4f663e27 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -180,7 +180,7 @@ void BKE_text_free(Text *text) #endif } -Text *add_empty_text(const char *name) +Text *BKE_text_add(const char *name) { Main *bmain= G.main; Text *ta; @@ -278,7 +278,7 @@ static void cleanup_textline(TextLine * tl) tl->len+= txt_extended_ascii_as_utf8(&tl->line); } -int reopen_text(Text *text) +int BKE_text_reload(Text *text) { FILE *fp; int i, llen, len; @@ -373,7 +373,7 @@ int reopen_text(Text *text) return 1; } -Text *add_text(const char *file, const char *relpath) +Text *BKE_text_load(const char *file, const char *relpath) { Main *bmain= G.main; FILE *fp; @@ -593,7 +593,7 @@ void BKE_text_unlink(Main *bmain, Text *text) text->id.us= 0; } -void clear_text(Text *text) /* called directly from rna */ +void BKE_text_clear(Text *text) /* called directly from rna */ { int oldstate; @@ -606,7 +606,7 @@ void clear_text(Text *text) /* called directly from rna */ txt_make_dirty(text); } -void write_text(Text *text, const char *str) /* called directly from rna */ +void BKE_text_write(Text *text, const char *str) /* called directly from rna */ { int oldstate; diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index c9f7b7c7e64..d85765d8f56 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -297,7 +297,7 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) struct TmpFont *tf; // Find the correct FreeType font - tf= vfont_find_tmpfont(vfont); + tf= BKE_vfont_find_tmpfont(vfont); // What, no font found. Something strange here if (!tf) return FALSE; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3005837ba7f..231c1ab8d03 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2955,7 +2955,7 @@ static void direct_link_text(FileData *fd, Text *text) #if 0 if (text->flags & TXT_ISEXT) { - reopen_text(text); + BKE_text_reload(text); } else { #endif diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 3976d8115c1..98a30fbef74 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -921,7 +921,7 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image ) BLI_split_dir_part(filename, dir, sizeof(dir)); BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str()); - Image *ima = BKE_add_image_file(full_path); + Image *ima = BKE_image_load_exists(full_path); if (!ima) { fprintf(stderr, "Cannot create image.\n"); return true; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 22f1cd578ac..05dc2d1c04e 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -275,7 +275,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re if (mode == FO_EDIT) update_string(cu); - BKE_text_to_curve(bmain, scene, obedit, mode); + BKE_vfont_to_curve(bmain, scene, obedit, mode); if (recalc) DAG_id_tag_update(obedit->data, 0); @@ -449,7 +449,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float obedit->loc[2] += offset[2]; cu= obedit->data; - cu->vfont= get_builtin_font(); + cu->vfont= BKE_vfont_builtin_get(); cu->vfont->id.us++; for (tmp=firstline, a=0; cu->lennext, a++) @@ -556,7 +556,7 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ int offset = 0; int getfrom; - direction = BKE_font_getselection(obedit, &selstart, &selend); + direction = BKE_vfont_select_get(obedit, &selstart, &selend); if (direction) { int size; if (ins) offset = 1; @@ -593,7 +593,7 @@ static int set_style(bContext *C, const int style, const int clear) EditFont *ef= cu->editfont; int i, selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; for (i=selstart; i<=selend; i++) { @@ -644,7 +644,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op) Curve *cu= obedit->data; int style, clear, selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; style= RNA_enum_get(op->ptr, "style"); @@ -679,7 +679,7 @@ static void copy_selection(Object *obedit) { int selstart, selend; - if (BKE_font_getselection(obedit, &selstart, &selend)) { + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { Curve *cu= obedit->data; EditFont *ef= cu->editfont; @@ -718,7 +718,7 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit= CTX_data_edit_object(C); int selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; copy_selection(obedit); @@ -901,7 +901,7 @@ static int move_cursor(bContext *C, int type, int select) struct Main *bmain= CTX_data_main(C); cu->selstart = cu->selend = 0; update_string(cu); - BKE_text_to_curve(bmain, scene, obedit, FO_SELCHANGE); + BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE); } } @@ -1121,7 +1121,7 @@ static int delete_exec(bContext *C, wmOperator *op) if (cu->len == 0) return OPERATOR_CANCELLED; - if (BKE_font_getselection(obedit, &selstart, &selend)) { + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { if (type == DEL_NEXT_SEL) type= DEL_SELECTION; else if (type == DEL_PREV_SEL) type= DEL_SELECTION; } @@ -1634,7 +1634,7 @@ static int font_open_exec(bContext *C, wmOperator *op) char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - font= load_vfont(bmain, filepath); + font= BKE_vfont_load(bmain, filepath); if (!font) { if (op->customdata) MEM_freeN(op->customdata); @@ -1726,7 +1726,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - builtin_font = get_builtin_font(); + builtin_font = BKE_vfont_builtin_get(); RNA_id_pointer_create(&builtin_font->id, &idptr); RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 93546d74c1b..aaca5181531 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -507,7 +507,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) char *str; /* create new text-block to write to */ - txt = add_empty_text("Recent Reports"); + txt = BKE_text_add("Recent Reports"); /* convert entire list to a display string, and add this to the text-block * - if commandline debug option enabled, show debug reports too @@ -516,7 +516,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) str = BKE_reports_string(reports, (G.debug & G_DEBUG) ? RPT_DEBUG : RPT_INFO); if (str) { - write_text(txt, str); + BKE_text_write(txt, str); MEM_freeN(str); return OPERATOR_FINISHED; @@ -652,7 +652,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, } if (text == NULL) { - text = add_text(filepath, bmain->name); + text = BKE_text_load(filepath, bmain->name); } if (text == NULL) { diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index f611a985797..042deb3def7 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -556,7 +556,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else { RNA_string_get(op->ptr, "name", name); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a683b1cc0ae..fa8ed0fd94d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -885,7 +885,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->vfontbi = cu->vfontbi; id_us_plus((ID *)cu1->vfontbi); - BKE_text_to_curve(bmain, scene, base->object, 0); /* needed? */ + BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */ BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index eb874932d40..c8fd8d0c93f 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -190,7 +190,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op)) EditFont *ef = ((Curve *)ob->data)->editfont; int i, selstart, selend; - if (ef && BKE_font_getselection(ob, &selstart, &selend)) { + if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) { for (i = selstart; i <= selend; i++) ef->textbufinfo[i].mat_nr = ob->actcol; } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index bbc12520978..66070bf54b0 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -833,7 +833,7 @@ static int image_open_exec(bContext *C, wmOperator *op) errno = 0; - ima = BKE_add_image_file(str); + ima = BKE_image_load_exists(str); if (!ima) { if (op->customdata) MEM_freeN(op->customdata); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 746fa9e34d7..d47a1d557ab 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -3408,7 +3408,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) errno= 0; - ima= BKE_add_image_file(path); + ima= BKE_image_load_exists(path); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index ca72d1e3094..d38a4caeab7 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -167,7 +167,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) PointerRNA ptr, idptr; PropertyRNA *prop; - text = add_empty_text("Text"); + text = BKE_text_add("Text"); /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -236,7 +236,7 @@ static int text_open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", str); - text = add_text(str, G.main->name); + text = BKE_text_load(str, G.main->name); if (!text) { if (op->customdata) MEM_freeN(op->customdata); @@ -320,7 +320,7 @@ static int text_reload_exec(bContext *C, wmOperator *op) { Text *text = CTX_data_edit_text(C); - if (!reopen_text(text)) { + if (!BKE_text_reload(text)) { BKE_report(op->reports, RPT_ERROR, "Could not reopen file"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 37f24dda8ab..79dce3e6bcd 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6647,7 +6647,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) setlinestyle(0); - if (BKE_font_getselection(ob, &selstart, &selend) && cu->selboxes) { + if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) { float selboxw; cpack(0xffffff); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b5354ac5e03..de17f0af1e8 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3094,7 +3094,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 6992d992cca..74a55b97e1b 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -269,7 +269,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) if (ob->type == OB_FONT) { Curve *cu = ob->data; freedisplist(&cu->disp); - BKE_text_to_curve(sce, ob, CU_LEFT); + BKE_vfont_to_curve(sce, ob, CU_LEFT); } #endif diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 2b6582bc1d9..661e4b18c6d 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -278,7 +278,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char Image *ima; errno = 0; - ima = BKE_add_image_file(filepath); + ima = BKE_image_load(filepath); if (!ima) BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, @@ -347,7 +347,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat VFont *font; errno = 0; - font = load_vfont(bmain, filepath); + font = BKE_vfont_load(bmain, filepath); if (!font) BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, @@ -443,7 +443,7 @@ void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name) { - return add_empty_text(name); + return BKE_text_add(name); } void rna_Main_texts_remove(Main *bmain, Text *text) { @@ -457,7 +457,7 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath Text *txt; errno = 0; - txt = add_text(filepath, bmain->name); + txt = BKE_text_load(filepath, bmain->name); if (!txt) BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, diff --git a/source/blender/makesrna/intern/rna_text_api.c b/source/blender/makesrna/intern/rna_text_api.c index 3f511858332..338d0c7c52c 100644 --- a/source/blender/makesrna/intern/rna_text_api.c +++ b/source/blender/makesrna/intern/rna_text_api.c @@ -37,13 +37,13 @@ static void rna_Text_clear(Text *text) { - clear_text(text); + BKE_text_clear(text); WM_main_add_notifier(NC_TEXT|NA_EDITED, text); } static void rna_Text_write(Text *text, const char *str) { - write_text(text, str); + BKE_text_write(text, str); WM_main_add_notifier(NC_TEXT|NA_EDITED, text); } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index a366810e647..56052b895ab 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -484,7 +484,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory char tstr[FILE_MAX]; int success = 0; - free_ttfont(); /* still weird... what does it here? */ + BKE_vfont_free_global_ttf(); /* still weird... what does it here? */ G.relbase_valid = 0; if (!from_memory) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 58c2c649163..1a1cb9d6507 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -360,7 +360,7 @@ void WM_exit_ext(bContext *C, const short do_python) // BIF_freeRetarget(); BIF_freeTemplates(C); - free_ttfont(); /* bke_font.h */ + BKE_vfont_free_global_ttf(); /* bke_font.h */ free_openrecent(); diff --git a/source/creator/creator.c b/source/creator/creator.c index 8394ff32750..c3da352136d 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1270,7 +1270,7 @@ int main(int argc, const char **argv) #endif /* background render uses this font too */ - BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size); + BKE_vfont_builtin_register(datatoc_Bfont, datatoc_Bfont_size); /* Initialize ffmpeg if built in, also needed for bg mode if videos are * rendered via ffmpeg */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index b5e165a58ec..9e072f2de3a 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -870,7 +870,7 @@ int main(int argc, char** argv) if (domeWarp) { //XXX to do: convert relative to absolute path - domeText= add_text(domeWarp, ""); + domeText= BKE_text_load(domeWarp, ""); if (!domeText) printf("error: invalid warpdata text file - %s\n", domeWarp); else From ff4ff9c8a429d9869e7056417bc7acd47a545eb2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 5 May 2012 15:54:08 +0000 Subject: [PATCH 78/88] Bugfixes for various ID-block references (Constraints, NLA) * ID-blocks referenced by Constraints but not being used as the target objects (such as Actions in the Action Constraint, or Text Blocks in PyConstraints) now get usercounts for being referenced in this way. This should fix ancient bugs such as [#19205] and [#8593]. More tests still needed to verify that this does now play nicely with proxies. * Changing actions used by NLA strips should now update the usercounts accordingly --- source/blender/blenkernel/BKE_constraint.h | 2 +- source/blender/blenkernel/intern/constraint.c | 78 +++++++++++-------- source/blender/blenloader/intern/readfile.c | 15 +++- .../blender/makesrna/intern/rna_animation.c | 2 +- .../blender/makesrna/intern/rna_constraint.c | 4 +- source/blender/makesrna/intern/rna_nla.c | 2 +- 6 files changed, 62 insertions(+), 41 deletions(-) diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index f834ad5e774..b12ab538184 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -62,7 +62,7 @@ typedef struct bConstraintOb { /* ---------------------------------------------------------------------------- */ /* Callback format for performing operations on ID-pointers for Constraints */ -typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, void *userdata); +typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, short isReference, void *userdata); /* ....... */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 399aedc914f..a244fa96fda 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -781,7 +781,7 @@ static void childof_id_looper (bConstraint *con, ConstraintIDFunc func, void *us bChildOfConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int childof_get_tars (bConstraint *con, ListBase *list) @@ -917,7 +917,7 @@ static void trackto_id_looper (bConstraint *con, ConstraintIDFunc func, void *us bTrackToConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int trackto_get_tars (bConstraint *con, ListBase *list) @@ -1098,10 +1098,10 @@ static void kinematic_id_looper (bConstraint *con, ConstraintIDFunc func, void * bKinematicConstraint *data= con->data; /* chain target */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); /* poletarget */ - func(con, (ID**)&data->poletar, userdata); + func(con, (ID**)&data->poletar, FALSE, userdata); } static int kinematic_get_tars (bConstraint *con, ListBase *list) @@ -1191,7 +1191,7 @@ static void followpath_id_looper (bConstraint *con, ConstraintIDFunc func, void bFollowPathConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int followpath_get_tars (bConstraint *con, ListBase *list) @@ -1541,7 +1541,7 @@ static void loclike_id_looper (bConstraint *con, ConstraintIDFunc func, void *us bLocateLikeConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int loclike_get_tars (bConstraint *con, ListBase *list) @@ -1632,7 +1632,7 @@ static void rotlike_id_looper (bConstraint *con, ConstraintIDFunc func, void *us bChildOfConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int rotlike_get_tars (bConstraint *con, ListBase *list) @@ -1745,7 +1745,7 @@ static void sizelike_id_looper (bConstraint *con, ConstraintIDFunc func, void *u bSizeLikeConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int sizelike_get_tars (bConstraint *con, ListBase *list) @@ -1835,7 +1835,7 @@ static void translike_id_looper (bConstraint *con, ConstraintIDFunc func, void * bTransLikeConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int translike_get_tars (bConstraint *con, ListBase *list) @@ -2007,10 +2007,10 @@ static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *user /* targets */ for (ct= data->targets.first; ct; ct= ct->next) - func(con, (ID**)&ct->tar, userdata); + func(con, (ID**)&ct->tar, FALSE, userdata); /* script */ - func(con, (ID**)&data->text, userdata); + func(con, (ID**)&data->text, TRUE, userdata); } /* Whether this approach is maintained remains to be seen (aligorith) */ @@ -2107,10 +2107,10 @@ static void actcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *use bActionConstraint *data= con->data; /* target */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); /* action */ - func(con, (ID**)&data->act, userdata); + func(con, (ID**)&data->act, TRUE, userdata); } static int actcon_get_tars (bConstraint *con, ListBase *list) @@ -2273,7 +2273,7 @@ static void locktrack_id_looper (bConstraint *con, ConstraintIDFunc func, void * bLockTrackConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int locktrack_get_tars (bConstraint *con, ListBase *list) @@ -2584,7 +2584,7 @@ static void distlimit_id_looper (bConstraint *con, ConstraintIDFunc func, void * bDistLimitConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int distlimit_get_tars (bConstraint *con, ListBase *list) @@ -2712,7 +2712,7 @@ static void stretchto_id_looper (bConstraint *con, ConstraintIDFunc func, void * bStretchToConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int stretchto_get_tars (bConstraint *con, ListBase *list) @@ -2887,7 +2887,7 @@ static void minmax_id_looper (bConstraint *con, ConstraintIDFunc func, void *use bMinMaxConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int minmax_get_tars (bConstraint *con, ListBase *list) @@ -3030,8 +3030,8 @@ static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userda bRigidBodyJointConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); - func(con, (ID**)&data->child, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID**)&data->child, FALSE, userdata); } static int rbj_get_tars (bConstraint *con, ListBase *list) @@ -3083,7 +3083,7 @@ static void clampto_id_looper (bConstraint *con, ConstraintIDFunc func, void *us bClampToConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int clampto_get_tars (bConstraint *con, ListBase *list) @@ -3268,7 +3268,7 @@ static void transform_id_looper (bConstraint *con, ConstraintIDFunc func, void * bTransformConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int transform_get_tars (bConstraint *con, ListBase *list) @@ -3403,10 +3403,10 @@ static bConstraintTypeInfo CTI_TRANSFORM = { static void shrinkwrap_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) { - bShrinkwrapConstraint *data= con->data; + bShrinkwrapConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->target, userdata); + func(con, (ID**)&data->target, FALSE, userdata); } static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) @@ -3571,7 +3571,7 @@ static void damptrack_id_looper (bConstraint *con, ConstraintIDFunc func, void * bDampTrackConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int damptrack_get_tars (bConstraint *con, ListBase *list) @@ -3717,7 +3717,7 @@ static void splineik_id_looper (bConstraint *con, ConstraintIDFunc func, void *u bSplineIKConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int splineik_get_tars (bConstraint *con, ListBase *list) @@ -3790,7 +3790,7 @@ static void pivotcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *u bPivotConstraint *data= con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->tar, FALSE, userdata); } static int pivotcon_get_tars (bConstraint *con, ListBase *list) @@ -3922,9 +3922,9 @@ static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void { bFollowTrackConstraint *data = con->data; - func(con, (ID**)&data->clip, userdata); - func(con, (ID**)&data->camera, userdata); - func(con, (ID**)&data->depth_ob, userdata); + func(con, (ID**)&data->clip, TRUE, userdata); + func(con, (ID**)&data->camera, FALSE, userdata); + func(con, (ID**)&data->depth_ob, FALSE, userdata); } static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -4116,7 +4116,7 @@ static void camerasolver_id_looper(bConstraint *con, ConstraintIDFunc func, void { bCameraSolverConstraint *data = con->data; - func(con, (ID**)&data->clip, userdata); + func(con, (ID**)&data->clip, TRUE, userdata); } static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -4172,8 +4172,8 @@ static void objectsolver_id_looper(bConstraint *con, ConstraintIDFunc func, void { bObjectSolverConstraint *data= con->data; - func(con, (ID**)&data->clip, userdata); - func(con, (ID**)&data->camera, userdata); + func(con, (ID**)&data->clip, FALSE, userdata); + func(con, (ID**)&data->camera, FALSE, userdata); } static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -4535,12 +4535,20 @@ void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdat /* ......... */ /* helper for copy_constraints(), to be used for making sure that ID's are valid */ -static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, void *UNUSED(userData)) +static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userData)) { if (*idpoin && (*idpoin)->lib) id_lib_extern(*idpoin); } +/* helper for copy_constraints(), to be used for making sure that usercounts of copied ID's are fixed up */ +static void con_fix_copied_refs_cb(bConstraint *con, ID **idpoin, short isReference, void *UNUSED(userData)) +{ + /* increment usercount if this is a reference type */ + if ((*idpoin) && (isReference)) + id_us_plus(*idpoin); +} + /* duplicate all of the constraints in a constraint stack */ void copy_constraints(ListBase *dst, const ListBase *src, int do_extern) { @@ -4560,6 +4568,10 @@ void copy_constraints(ListBase *dst, const ListBase *src, int do_extern) /* perform custom copying operations if needed */ if (cti->copy_data) cti->copy_data(con, srccon); + + /* fix usercounts for all referenced data in referenced data */ + if (cti->id_looper) + cti->id_looper(con, con_fix_copied_refs_cb, NULL); /* for proxies we don't want to make extern */ if (do_extern) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 231c1ab8d03..ec7d58035b4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2473,10 +2473,19 @@ typedef struct tConstraintLinkData { ID *id; } tConstraintLinkData; /* callback function used to relink constraint ID-links */ -static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, void *userdata) +static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *userdata) { tConstraintLinkData *cld= (tConstraintLinkData *)userdata; - *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); + + /* for reference types, we need to increment the usercounts on load... */ + if (isReference) { + /* reference type - with usercount */ + *idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin); + } + else { + /* target type - no usercount needed */ + *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); + } } static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) @@ -8115,7 +8124,7 @@ typedef struct tConstraintExpandData { Main *mainvar; } tConstraintExpandData; /* callback function used to expand constraint ID-links */ -static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, void *userdata) +static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *userdata) { tConstraintExpandData *ced= (tConstraintExpandData *)userdata; expand_doit(ced->fd, ced->mainvar, *idpoin); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 94ea79099c2..06352fd727c 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -837,7 +837,7 @@ void rna_def_animdata(BlenderRNA *brna) /* Active Action */ prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); /* this flag as well as the dynamic test must be defined for this to be editable... */ - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_pointer_funcs(prop, NULL, "rna_AnimData_action_set", NULL, "rna_Action_id_poll"); RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this datablock"); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index e321e83dd61..b812c574a01 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -562,7 +562,7 @@ static void rna_def_constraint_python(BlenderRNA *brna) prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Script", "The text object that contains the Python script"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "use_targets", PROP_BOOLEAN, PROP_NONE); @@ -1097,7 +1097,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); RNA_def_property_ui_text(prop, "Action", "The constraining action"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 8d262c58f9b..7ad13b8a6d1 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -459,7 +459,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_editable_func(prop, "rna_NlaStrip_action_editable"); RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip"); RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ From 1dccd4c98a4909383b9c11f7c2ee987e22833dad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 16:03:57 +0000 Subject: [PATCH 79/88] code cleanup: naming - pose/armature/image also use ..._find_name(..., name) rather then ..._find_named(..., name) --- both were used. --- source/blender/blenkernel/BKE_action.h | 38 +++--- source/blender/blenkernel/BKE_armature.h | 46 +++---- source/blender/blenkernel/BKE_image.h | 22 ++-- source/blender/blenkernel/BKE_lamp.h | 4 +- source/blender/blenkernel/BKE_lattice.h | 12 +- source/blender/blenkernel/BKE_library.h | 2 +- source/blender/blenkernel/BKE_material.h | 4 +- source/blender/blenkernel/BKE_mesh.h | 4 +- source/blender/blenkernel/BKE_speaker.h | 4 +- source/blender/blenkernel/BKE_texture.h | 2 +- source/blender/blenkernel/intern/action.c | 76 ++++++------ source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/armature.c | 112 +++++++++--------- .../blenkernel/intern/booleanops_mesh.c | 4 +- source/blender/blenkernel/intern/constraint.c | 18 +-- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/fcurve.c | 8 +- source/blender/blenkernel/intern/image.c | 34 +++--- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/lamp.c | 4 +- source/blender/blenkernel/intern/lattice.c | 20 ++-- source/blender/blenkernel/intern/library.c | 10 +- source/blender/blenkernel/intern/material.c | 6 +- source/blender/blenkernel/intern/mesh.c | 8 +- source/blender/blenkernel/intern/multires.c | 6 +- source/blender/blenkernel/intern/object.c | 50 ++++---- source/blender/blenkernel/intern/ocean.c | 6 +- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/shrinkwrap.c | 2 +- source/blender/blenkernel/intern/speaker.c | 4 +- source/blender/blenkernel/intern/texture.c | 2 +- source/blender/blenloader/intern/readfile.c | 6 +- .../blenloader/intern/versioning_legacy.c | 4 +- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/collada/AnimationExporter.cpp | 20 ++-- source/blender/collada/AnimationImporter.cpp | 18 +-- source/blender/collada/ArmatureExporter.cpp | 12 +- source/blender/collada/ArmatureImporter.cpp | 14 +-- source/blender/collada/DocumentImporter.cpp | 6 +- source/blender/collada/MeshImporter.cpp | 2 +- source/blender/collada/SkinInfo.cpp | 4 +- source/blender/collada/SkinInfo.h | 2 +- source/blender/editors/animation/anim_deps.c | 4 +- .../blender/editors/animation/anim_filter.c | 2 +- source/blender/editors/animation/keyframing.c | 2 +- source/blender/editors/animation/keyingsets.c | 6 +- .../blender/editors/armature/editarmature.c | 48 ++++---- source/blender/editors/armature/poseUtils.c | 2 +- source/blender/editors/armature/poselib.c | 12 +- source/blender/editors/armature/poseobject.c | 32 ++--- .../blender/editors/include/ED_keyframing.h | 2 +- .../editors/interface/interface_templates.c | 4 +- source/blender/editors/mesh/editface.c | 22 ++-- source/blender/editors/mesh/mesh_data.c | 2 +- source/blender/editors/object/object_add.c | 6 +- .../editors/object/object_constraint.c | 30 ++--- source/blender/editors/object/object_hook.c | 2 +- .../blender/editors/object/object_lattice.c | 4 +- .../blender/editors/object/object_modifier.c | 2 +- .../blender/editors/object/object_relations.c | 6 +- source/blender/editors/object/object_select.c | 2 +- .../blender/editors/object/object_transform.c | 8 +- source/blender/editors/render/render_opengl.c | 4 +- .../blender/editors/render/render_shading.c | 2 +- .../blender/editors/screen/screen_context.c | 2 +- source/blender/editors/screen/screendump.c | 4 +- .../editors/sculpt_paint/paint_image.c | 8 +- .../editors/sculpt_paint/paint_vertex.c | 28 ++--- source/blender/editors/sculpt_paint/sculpt.c | 6 +- .../editors/space_buttons/buttons_context.c | 2 +- .../editors/space_image/image_buttons.c | 4 +- .../blender/editors/space_image/image_ops.c | 14 +-- .../blender/editors/space_image/space_image.c | 2 +- .../editors/space_logic/logic_window.c | 2 +- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_node/node_edit.c | 2 +- .../editors/space_outliner/outliner_edit.c | 20 ++-- .../editors/space_view3d/drawanimviz.c | 2 +- .../editors/space_view3d/drawarmature.c | 32 ++--- .../blender/editors/space_view3d/drawobject.c | 4 +- .../editors/space_view3d/space_view3d.c | 4 +- .../editors/space_view3d/view3d_buttons.c | 2 +- .../editors/space_view3d/view3d_draw.c | 2 +- .../editors/space_view3d/view3d_edit.c | 2 +- .../editors/space_view3d/view3d_snap.c | 4 +- .../editors/space_view3d/view3d_view.c | 2 +- .../editors/transform/transform_conversions.c | 12 +- .../editors/transform/transform_generics.c | 2 +- .../editors/transform/transform_manipulator.c | 2 +- source/blender/gpu/intern/gpu_draw.c | 2 +- .../blender/ikplugin/intern/iksolver_plugin.c | 6 +- .../blender/ikplugin/intern/itasc_plugin.cpp | 12 +- source/blender/makesdna/DNA_action_types.h | 6 +- .../blender/makesrna/intern/rna_animation.c | 4 +- source/blender/makesrna/intern/rna_image.c | 2 +- .../blender/makesrna/intern/rna_image_api.c | 2 +- source/blender/makesrna/intern/rna_lattice.c | 10 +- source/blender/makesrna/intern/rna_main_api.c | 14 +-- source/blender/makesrna/intern/rna_object.c | 2 +- .../blender/makesrna/intern/rna_object_api.c | 4 +- source/blender/makesrna/intern/rna_pose.c | 14 +-- source/blender/makesrna/intern/rna_scene.c | 4 +- .../modifiers/intern/MOD_boolean_util.c | 2 +- source/blender/modifiers/intern/MOD_hook.c | 2 +- source/blender/modifiers/intern/MOD_mask.c | 4 +- source/blender/modifiers/intern/MOD_util.c | 4 +- .../composite/nodes/node_composite_image.c | 2 +- .../nodes/node_composite_outputFile.c | 2 +- .../nodes/node_composite_splitViewer.c | 2 +- .../composite/nodes/node_composite_viewer.c | 2 +- source/blender/render/intern/source/envmap.c | 2 +- .../blender/render/intern/source/pipeline.c | 6 +- .../render/intern/source/render_result.c | 2 +- .../render/intern/source/render_texture.c | 6 +- .../blender/render/intern/source/rendercore.c | 2 +- .../bad_level_call_stubs/stubs.c | 2 +- .../Converter/BL_ActionActuator.cpp | 14 +-- .../Converter/BL_ArmatureObject.cpp | 14 +-- .../gameengine/Converter/BL_ArmatureObject.h | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 2 +- .../gameengine/Converter/BL_SkinDeformer.cpp | 2 +- 121 files changed, 566 insertions(+), 566 deletions(-) diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index b9d7fb88a22..a326b514f9a 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -122,7 +122,7 @@ void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, s void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu); /* Find a group with the given name */ -struct bActionGroup *action_groups_find_named(struct bAction *act, const char name[]); +struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char name[]); /* Clear all 'temp' flags on all groups */ void action_groups_clear_tempflags(struct bAction *act); @@ -133,71 +133,71 @@ void action_groups_clear_tempflags(struct bAction *act); * Deallocates a pose channel. * Does not free the pose channel itself. */ -void free_pose_channel(struct bPoseChannel *pchan); +void BKE_pose_channel_free(struct bPoseChannel *pchan); /** * Removes and deallocates all channels from a pose. * Does not free the pose itself. */ -void free_pose_channels(struct bPose *pose); +void BKE_pose_channels_free(struct bPose *pose); /** * Removes the hash for quick lookup of channels, must * be done when adding/removing channels. */ -void make_pose_channels_hash(struct bPose *pose); -void free_pose_channels_hash(struct bPose *pose); +void BKE_pose_channels_hash_make(struct bPose *pose); +void BKE_pose_channels_hash_free(struct bPose *pose); /** * Removes and deallocates all data from a pose, and also frees the pose. */ -void free_pose(struct bPose *pose); +void BKE_pose_free(struct bPose *pose); /** * Allocate a new pose on the heap, and copy the src pose and it's channels * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL. */ -void copy_pose(struct bPose **dst, struct bPose *src, int copyconstraints); +void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, int copyconstraints); /** * Copy the internal members of each pose channel including constraints * and ID-Props, used when duplicating bones in editmode. */ -void duplicate_pose_channel_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from); +void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from); /** * Return a pointer to the pose channel of the given name * from this pose. */ -struct bPoseChannel *get_pose_channel(const struct bPose *pose, const char *name); +struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name); /** * Return a pointer to the active pose channel from this Object. * (Note: Object, not bPose is used here, as we need layer info from Armature) */ -struct bPoseChannel *get_active_posechannel(struct Object *ob); +struct bPoseChannel *BKE_pose_channel_active(struct Object *ob); /** * Looks to see if the channel with the given name * already exists in this pose - if not a new one is * allocated and initialized. */ -struct bPoseChannel *verify_pose_channel(struct bPose* pose, const char* name); +struct bPoseChannel *BKE_pose_channel_verify(struct bPose* pose, const char* name); /* Copy the data from the action-pose (src) into the pose */ void extract_pose_from_pose(struct bPose *pose, const struct bPose *src); /* sets constraint flags */ -void update_pose_constraint_flags(struct bPose *pose); +void BKE_pose_update_constraint_flags(struct bPose *pose); /* return the name of structure pointed by pose->ikparam */ -const char *get_ikparam_name(struct bPose *pose); +const char *BKE_pose_ikparam_get_name(struct bPose *pose); /* allocate and initialize pose->ikparam according to pose->iksolver */ -void init_pose_ikparam(struct bPose *pose); +void BKE_pose_ikparam_init(struct bPose *pose); /* initialize a bItasc structure with default value */ -void init_pose_itasc(struct bItasc *itasc); +void BKE_pose_itasc_init(struct bItasc *itasc); /* clears BONE_UNKEYED flags for frame changing */ // XXX to be depreceated for a more general solution in animsys... @@ -206,10 +206,10 @@ void framechange_poses_clear_unkeyed(void); /* Bone Groups API --------------------- */ /* Adds a new bone-group */ -void pose_add_group(struct Object *ob); +void BKE_pose_add_group(struct Object *ob); /* Remove the active bone-group */ -void pose_remove_group(struct Object *ob); +void BKE_pose_remove_group(struct Object *ob); /* Assorted Evaluation ----------------- */ @@ -217,9 +217,9 @@ void pose_remove_group(struct Object *ob); void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); /* for proxy */ -void copy_pose_result(struct bPose *to, struct bPose *from); +void BKE_pose_copy_result(struct bPose *to, struct bPose *from); /* clear all transforms */ -void rest_pose(struct bPose *pose); +void BKE_pose_rest(struct bPose *pose); #ifdef __cplusplus }; diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 72d452150a1..b8c2c42f8d5 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -75,28 +75,28 @@ typedef struct PoseTree extern "C" { #endif -struct bArmature *add_armature(const char *name); -struct bArmature *get_armature(struct Object *ob); -void free_bonelist (struct ListBase *lb); +struct bArmature *BKE_armature_add(const char *name); +struct bArmature *BKE_armature_from_object(struct Object *ob); +void BKE_armature_bonelist_free (struct ListBase *lb); void BKE_armature_free(struct bArmature *arm); void BKE_armature_make_local(struct bArmature *arm); struct bArmature *BKE_armature_copy(struct bArmature *arm); /* Bounding box. */ -struct BoundBox *BKE_armature_get_bb(struct Object *ob); +struct BoundBox *BKE_armature_boundbox_get(struct Object *ob); int bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail); -struct Bone *get_named_bone (struct bArmature *arm, const char *name); +struct Bone *BKE_armature_find_bone_name (struct bArmature *arm, const char *name); float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float r1, float r2, float rdist); -void where_is_armature (struct bArmature *arm); -void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone); -void armature_rebuild_pose(struct Object *ob, struct bArmature *arm); -void where_is_pose (struct Scene *scene, struct Object *ob); -void where_is_pose_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, int do_extra); -void where_is_pose_bone_tail(struct bPoseChannel *pchan); +void BKE_armature_where_is(struct bArmature *arm); +void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone); +void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm); +void BKE_pose_where_is(struct Scene *scene, struct Object *ob); +void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, int do_extra); +void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan); /* get_objectspace_bone_matrix has to be removed still */ void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed); @@ -106,23 +106,23 @@ void mat3_to_vec_roll(float mat[][3], float *vec, float *roll); int get_selected_defgroups(struct Object *ob, char *defbase_sel, int defbase_len); /* Common Conversions Between Co-ordinate Spaces */ -void armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); -void armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); -void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); -void armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); +void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); +void BKE_armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); +void BKE_armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); +void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); +void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); +void BKE_armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); -void armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); +void BKE_armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[][3], short use_compat); -void pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4], short use_comat); -void pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]); -void pchan_calc_mat(struct bPoseChannel *pchan); +void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[][3], short use_compat); +void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4], short use_comat); +void BKE_pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]); +void BKE_pchan_calc_mat(struct bPoseChannel *pchan); /* Get the "pchan to pose" transform matrix. These matrices apply the effects of * HINGE/NO_SCALE/NO_LOCAL_LOCATION options over the pchan loc/rot/scale transformations. */ -void pchan_to_pose_mat(struct bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]); +void BKE_pchan_to_pose_mat(struct bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]); /* Rotation Mode Conversions - Used for PoseChannels + Objects... */ void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index d9a656a8a40..563f066bda6 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -48,12 +48,12 @@ struct ImageFormatData; /* call from library */ void BKE_image_free(struct Image *me); -void BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); +void BKE_imbuf_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels); -int BKE_alphatest_ibuf(struct ImBuf *ibuf); -int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); -int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); -int BKE_write_ibuf_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy); +int BKE_imbuf_alpha_test(struct ImBuf *ibuf); +int BKE_imbuf_write_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); +int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); +int BKE_imbuf_write_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy); void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, const char imtype, const short use_ext, const short use_frames); int BKE_add_image_extension(char *string, const char imtype); char BKE_ftype_to_imtype(const int ftype); @@ -72,11 +72,11 @@ void BKE_imformat_defaults(struct ImageFormatData *im_format); struct anim *openanim(const char *name, int flags, int streamindex); -void image_de_interlace(struct Image *ima, int odd); +void BKE_image_de_interlace(struct Image *ima, int odd); void BKE_image_make_local(struct Image *ima); -void tag_image_time(struct Image *ima); +void BKE_image_tag_time(struct Image *ima); void free_old_images(void); /* ********************************** NEW IMAGE API *********************** */ @@ -136,9 +136,9 @@ struct Image *BKE_image_load(const char *filepath); struct Image *BKE_image_load_exists(const char *filepath); /* adds image, adds ibuf, generates color or pattern */ -struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); +struct Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); /* adds image from imbuf, owns imbuf */ -struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf); +struct Image *BKE_image_add_from_imbuf(struct ImBuf *ibuf); /* for reload, refresh, pack */ void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal); @@ -150,8 +150,8 @@ struct Image *BKE_image_verify_viewer(int type, const char *name); void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); /* called on frame change or before render */ -void BKE_image_user_calc_frame(struct ImageUser *iuser, int cfra, int fieldnr); -int BKE_image_user_get_frame(const struct ImageUser *iuser, int cfra, int fieldnr); +void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); +int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr); /* sets index offset for multilayer files */ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser); diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h index fd19794085d..f9137e50d74 100644 --- a/source/blender/blenkernel/BKE_lamp.h +++ b/source/blender/blenkernel/BKE_lamp.h @@ -38,10 +38,10 @@ extern "C" { struct Lamp; -void *add_lamp(const char *name); +void *BKE_lamp_add(const char *name); struct Lamp *BKE_lamp_copy(struct Lamp *la); struct Lamp *localize_lamp(struct Lamp *la); -void make_local_lamp(struct Lamp *la); +void BKE_lamp_make_local(struct Lamp *la); void BKE_lamp_free(struct Lamp *la); #ifdef __cplusplus diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 251f02fecd7..9a952fc6b1e 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -41,8 +41,8 @@ struct DerivedMesh; struct BPoint; struct MDeformVert; -void resizelattice(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); -struct Lattice *add_lattice(const char *name); +void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); +struct Lattice *BKE_lattice_add(const char *name); struct Lattice *BKE_lattice_copy(struct Lattice *lt); void BKE_lattice_free(struct Lattice *lt); void BKE_lattice_make_local(struct Lattice *lt); @@ -69,11 +69,11 @@ void armature_deform_verts(struct Object *armOb, struct Object *target, float (*defMats)[3][3], int numVerts, int deformflag, float (*prevCos)[3], const char *defgrp_name); -float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]; -void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]); -void lattice_calc_modifiers(struct Scene *scene, struct Object *ob); +float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3]; +void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]); +void BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob); -struct MDeformVert* lattice_get_deform_verts(struct Object *lattice); +struct MDeformVert* BKE_lattice_deform_verts_get(struct Object *lattice); #endif diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 8a93366ea9a..e8dff6633bc 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -82,7 +82,7 @@ void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only); -struct ID *find_id(const char *type, const char *name); +struct ID *BKE_libblock_find_name(const char *type, const char *name); void clear_id_newpoins(void); void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 32570311d02..801724d1d4f 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -50,11 +50,11 @@ void BKE_material_free(struct Material *sc); void test_object_materials(struct ID *id); void resize_object_material(struct Object *ob, const short totcol); void init_material(struct Material *ma); -struct Material *add_material(const char *name); +struct Material *BKE_material_add(const char *name); struct Material *BKE_material_copy(struct Material *ma); struct Material *localize_material(struct Material *ma); struct Material *give_node_material(struct Material *ma); /* returns node material or self */ -void make_local_material(struct Material *ma); +void BKE_material_make_local(struct Material *ma); void extern_local_matarar(struct Material **matar, short totcol); void automatname(struct Material *); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 34289a2ae4d..256d4b1cae1 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -120,7 +120,7 @@ void mesh_flush_hidden_from_verts(const struct MVert *mvert, void unlink_mesh(struct Mesh *me); void BKE_mesh_free(struct Mesh *me, int unlink); -struct Mesh *add_mesh(const char *name); +struct Mesh *BKE_mesh_add(const char *name); struct Mesh *BKE_mesh_copy(struct Mesh *me); void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess_cd); @@ -130,7 +130,7 @@ void tex_space_mesh(struct Mesh *me); float *get_mesh_orco_verts(struct Object *ob); void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, int invert); int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr); -struct Mesh *get_mesh(struct Object *ob); +struct Mesh *BKE_mesh_from_object(struct Object *ob); void set_mesh(struct Object *ob, struct Mesh *me); void mball_to_mesh(struct ListBase *lb, struct Mesh *me); int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *totvert, diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h index 5ff881ee085..52c177fce57 100644 --- a/source/blender/blenkernel/BKE_speaker.h +++ b/source/blender/blenkernel/BKE_speaker.h @@ -33,9 +33,9 @@ * \brief General operations for speakers. */ -void *add_speaker(const char *name); +void *BKE_speaker_add(const char *name); struct Speaker *BKE_speaker_copy(struct Speaker *spk); -void make_local_speaker(struct Speaker *spk); +void BKE_speaker_make_local(struct Speaker *spk); void BKE_speaker_free(struct Speaker *spk); #endif diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index aa6f56c5d8f..ed58620b716 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -81,7 +81,7 @@ struct MTex *add_mtex(void); struct MTex *add_mtex_id(struct ID *id, int slot); struct Tex *BKE_texture_copy(struct Tex *tex); struct Tex *localize_texture(struct Tex *tex); -void make_local_texture(struct Tex *tex); +void BKE_texture_make_local(struct Tex *tex); void autotexname(struct Tex *tex); struct Tex *give_current_object_texture(struct Object *ob); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index addbde139d2..90cfb9a1d82 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -69,7 +69,7 @@ * - Pose is the local (object level) component of armature. The current * object pose is saved in files, and (will be) is presorted for dependency * - Actions have fewer (or other) channels, and write data to a Pose - * - Currently ob->pose data is controlled in where_is_pose only. The (recalc) + * - Currently ob->pose data is controlled in BKE_pose_where_is only. The (recalc) * event system takes care of calling that * - The NLA system (here too) uses Poses as interpolation format for Actions * - Therefore we assume poses to be static, and duplicates of poses have channels in @@ -383,7 +383,7 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu) } /* Find a group with the given name */ -bActionGroup *action_groups_find_named (bAction *act, const char name[]) +bActionGroup *BKE_action_group_find_name (bAction *act, const char name[]) { /* sanity checks */ if (ELEM3(NULL, act, act->groups.first, name) || (name[0] == 0)) @@ -410,7 +410,7 @@ void action_groups_clear_tempflags(bAction *act) /* *************** Pose channels *************** */ /* usually used within a loop, so we got a N^2 slowdown */ -bPoseChannel *get_pose_channel(const bPose *pose, const char *name) +bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name) { if (ELEM(NULL, pose, name) || (name[0] == 0)) return NULL; @@ -423,7 +423,7 @@ bPoseChannel *get_pose_channel(const bPose *pose, const char *name) /* Use with care, not on Armature poses but for temporal ones */ /* (currently used for action constraints and in rebuild_pose) */ -bPoseChannel *verify_pose_channel(bPose *pose, const char *name) +bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) { bPoseChannel *chan; @@ -454,13 +454,13 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */ BLI_addtail(&pose->chanbase, chan); - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(pose); return chan; } /* Find the active posechannel for an object (we can't just use pose, as layer info is in armature) */ -bPoseChannel *get_active_posechannel (Object *ob) +bPoseChannel *BKE_pose_channel_active (Object *ob) { bArmature *arm= (ob) ? ob->data : NULL; bPoseChannel *pchan; @@ -478,7 +478,7 @@ bPoseChannel *get_active_posechannel (Object *ob) return NULL; } -const char *get_ikparam_name(bPose *pose) +const char *BKE_pose_ikparam_get_name(bPose *pose) { if (pose) { switch (pose->iksolver) { @@ -491,7 +491,7 @@ const char *get_ikparam_name(bPose *pose) return NULL; } /* dst should be freed already, makes entire duplicate */ -void copy_pose(bPose **dst, bPose *src, int copycon) +void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) { bPose *outPose; bPoseChannel *pchan; @@ -503,7 +503,7 @@ void copy_pose(bPose **dst, bPose *src, int copycon) } if (*dst==src) { - printf("copy_pose source and target are the same\n"); + printf("BKE_pose_copy_data source and target are the same\n"); *dst=NULL; return; } @@ -536,7 +536,7 @@ void copy_pose(bPose **dst, bPose *src, int copycon) *dst=outPose; } -void init_pose_itasc(bItasc *itasc) +void BKE_pose_itasc_init(bItasc *itasc) { if (itasc) { itasc->iksolver = IKSOLVER_ITASC; @@ -553,13 +553,13 @@ void init_pose_itasc(bItasc *itasc) itasc->dampeps = 0.15; } } -void init_pose_ikparam(bPose *pose) +void BKE_pose_ikparam_init(bPose *pose) { bItasc *itasc; switch (pose->iksolver) { case IKSOLVER_ITASC: itasc = MEM_callocN(sizeof(bItasc), "itasc"); - init_pose_itasc(itasc); + BKE_pose_itasc_init(itasc); pose->ikparam = itasc; break; case IKSOLVER_LEGACY: @@ -569,7 +569,7 @@ void init_pose_ikparam(bPose *pose) } } -void make_pose_channels_hash(bPose *pose) +void BKE_pose_channels_hash_make(bPose *pose) { if (!pose->chanhash) { bPoseChannel *pchan; @@ -580,7 +580,7 @@ void make_pose_channels_hash(bPose *pose) } } -void free_pose_channels_hash(bPose *pose) +void BKE_pose_channels_hash_free(bPose *pose) { if (pose->chanhash) { BLI_ghash_free(pose->chanhash, NULL, NULL); @@ -589,7 +589,7 @@ void free_pose_channels_hash(bPose *pose) } -void free_pose_channel(bPoseChannel *pchan) +void BKE_pose_channel_free(bPoseChannel *pchan) { if (pchan->mpath) { @@ -605,25 +605,25 @@ void free_pose_channel(bPoseChannel *pchan) } } -void free_pose_channels(bPose *pose) +void BKE_pose_channels_free(bPose *pose) { bPoseChannel *pchan; if (pose->chanbase.first) { for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) - free_pose_channel(pchan); + BKE_pose_channel_free(pchan); BLI_freelistN(&pose->chanbase); } - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(pose); } -void free_pose(bPose *pose) +void BKE_pose_free(bPose *pose) { if (pose) { /* free pose-channels */ - free_pose_channels(pose); + BKE_pose_channels_free(pose); /* free pose-groups */ if (pose->agroups.first) @@ -665,8 +665,8 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan /* makes copies of internal data, unlike copy_pose_channel_data which only * copies the pose state. - * hint: use when copying bones in editmode (on returned value from verify_pose_channel) */ -void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_from) + * hint: use when copying bones in editmode (on returned value from BKE_pose_channel_verify) */ +void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from) { /* copy transform locks */ pchan->protectflag = pchan_from->protectflag; @@ -709,7 +709,7 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_ * can do more constraints flags later */ /* pose should be entirely OK */ -void update_pose_constraint_flags(bPose *pose) +void BKE_pose_update_constraint_flags(bPose *pose) { bPoseChannel *pchan, *parchan; bConstraint *con; @@ -792,7 +792,7 @@ void framechange_poses_clear_unkeyed(void) /* ************************** Bone Groups ************************** */ /* Adds a new bone-group */ -void pose_add_group(Object *ob) +void BKE_pose_add_group(Object *ob) { bPose *pose= (ob) ? ob->pose : NULL; bActionGroup *grp; @@ -809,7 +809,7 @@ void pose_add_group(Object *ob) } /* Remove the active bone-group */ -void pose_remove_group(Object *ob) +void BKE_pose_remove_group(Object *ob) { bPose *pose= (ob) ? ob->pose : NULL; bActionGroup *grp = NULL; @@ -1072,7 +1072,7 @@ void extract_pose_from_pose(bPose *pose, const bPose *src) } /* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */ -void rest_pose(bPose *pose) +void BKE_pose_rest(bPose *pose) { bPoseChannel *pchan; @@ -1094,7 +1094,7 @@ void rest_pose(bPose *pose) } /* both poses should be in sync */ -void copy_pose_result(bPose *to, bPose *from) +void BKE_pose_copy_result(bPose *to, bPose *from) { bPoseChannel *pchanto, *pchanfrom; @@ -1104,13 +1104,13 @@ void copy_pose_result(bPose *to, bPose *from) } if (to==from) { - printf("copy_pose_result source and target are the same\n"); + printf("BKE_pose_copy_result source and target are the same\n"); return; } for (pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) { - pchanto= get_pose_channel(to, pchanfrom->name); + pchanto= BKE_pose_channel_find_name(to, pchanfrom->name); if (pchanto) { copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat); copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat); @@ -1136,7 +1136,7 @@ void copy_pose_result(bPose *to, bPose *from) */ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { - bActionGroup *agrp= action_groups_find_named(act, groupname); + bActionGroup *agrp= BKE_action_group_find_name(act, groupname); /* clear workob */ BKE_object_workob_clear(workob); @@ -1243,9 +1243,9 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, /* are we also blending with matching bones? */ if (strip->prev && strip->start>=strip->prev->start) { - bPoseChannel *dpchan= get_pose_channel(dst, strip->offs_bone); + bPoseChannel *dpchan= BKE_pose_channel_find_name(dst, strip->offs_bone); if (dpchan) { - bPoseChannel *spchan= get_pose_channel(src, strip->offs_bone); + bPoseChannel *spchan= BKE_pose_channel_find_name(src, strip->offs_bone); if (spchan) { float vec[3]; @@ -1397,11 +1397,11 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float if (foundvert) { /* bring it into armature space */ sub_v3_v3v3(min, max, min); - bone= get_named_bone(ob->data, strip->offs_bone); /* weak */ + bone= BKE_armature_find_bone_name(ob->data, strip->offs_bone); /* weak */ if (bone) { mul_mat3_m4_v3(bone->arm_mat, min); - /* dominant motion, cyclic_offset was cleared in rest_pose */ + /* dominant motion, cyclic_offset was cleared in BKE_pose_rest */ if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0]= time*min[0]; if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1]= time*min[1]; @@ -1457,8 +1457,8 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) int doit, dostride; if (blocktype==ID_AR) { - copy_pose(&tpose, ob->pose, 1); - rest_pose(ob->pose); // potentially destroying current not-keyed pose + BKE_pose_copy_data(&tpose, ob->pose, 1); + BKE_pose_rest(ob->pose); // potentially destroying current not-keyed pose } else { key= ob_get_key(ob); @@ -1504,7 +1504,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (striptime>=0.0) { if (blocktype==ID_AR) - rest_pose(tpose); + BKE_pose_rest(tpose); /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ if (striptime < 1.0f + 0.1f/length) { @@ -1656,7 +1656,7 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) /* free */ if (tpose) - free_pose(tpose); + BKE_pose_free(tpose); if (chanbase.first) BLI_freelistN(&chanbase); } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 66c91c034a9..de70ffcaaef 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -425,7 +425,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha /* if grouped... */ if (fcu->grp) { /* make sure there will be a matching group on the other side for the migrants */ - agrp = action_groups_find_named(dstAct, fcu->grp->name); + agrp = BKE_action_group_find_name(dstAct, fcu->grp->name); if (agrp == NULL) { /* add a new one with a similar name (usually will be the same though) */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 56275f5735b..814e9d53503 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -75,7 +75,7 @@ /* **************** Generic Functions, data level *************** */ -bArmature *add_armature(const char *name) +bArmature *BKE_armature_add(const char *name) { bArmature *arm; @@ -86,14 +86,14 @@ bArmature *add_armature(const char *name) return arm; } -bArmature *get_armature(Object *ob) +bArmature *BKE_armature_from_object(Object *ob) { if (ob->type == OB_ARMATURE) return (bArmature *)ob->data; return NULL; } -void free_bonelist(ListBase *lb) +void BKE_armature_bonelist_free(ListBase *lb) { Bone *bone; @@ -102,7 +102,7 @@ void free_bonelist(ListBase *lb) IDP_FreeProperty(bone->prop); MEM_freeN(bone->prop); } - free_bonelist(&bone->childbase); + BKE_armature_bonelist_free(&bone->childbase); } BLI_freelistN(lb); @@ -111,7 +111,7 @@ void free_bonelist(ListBase *lb) void BKE_armature_free(bArmature *arm) { if (arm) { - free_bonelist(&arm->bonebase); + BKE_armature_bonelist_free(&arm->bonebase); /* free editmode data */ if (arm->edbo) { @@ -245,7 +245,7 @@ static Bone *get_named_bone_bonechildren(Bone *bone, const char *name) /* Walk the list until the bone is found */ -Bone *get_named_bone(bArmature *arm, const char *name) +Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name) { Bone *bone = NULL, *curBone; @@ -909,7 +909,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float defnrToPC = MEM_callocN(sizeof(*defnrToPC) * defbase_tot, "defnrToBone"); defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * defbase_tot, "defnrToIndex"); for (i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) { - defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); + defnrToPC[i] = BKE_pose_channel_find_name(armOb->pose, dg->name); /* exclude non-deforming bones */ if (defnrToPC[i]) { if (defnrToPC[i]->bone->flag & BONE_NO_DEFORM) { @@ -1099,7 +1099,7 @@ void get_objectspace_bone_matrix(struct Bone* bone, float M_accumulatedMatrix[][ /* **************** Space to Space API ****************** */ /* Convert World-Space Matrix to Pose-Space Matrix */ -void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) { float obmat[4][4]; @@ -1117,7 +1117,7 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) /* Convert World-Space Location to Pose-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3]) +void BKE_armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3]) { float xLocMat[4][4] = MAT4_UNITY; float nLocMat[4][4]; @@ -1126,7 +1126,7 @@ void armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3 copy_v3_v3(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ - armature_mat_world_to_pose(ob, xLocMat, nLocMat); + BKE_armature_mat_world_to_pose(ob, xLocMat, nLocMat); copy_v3_v3(outloc, nLocMat[3]); } @@ -1165,7 +1165,7 @@ static void get_offset_bone_mat(Bone *bone, float offs_bone[][4]) * pose-channel into its local space (i.e. 'visual'-keyframing). * (note: I don't understand that, so I keep it :p --mont29). */ -void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]) +void BKE_pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]) { Bone *bone, *parbone; bPoseChannel *parchan; @@ -1254,14 +1254,14 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m /* Convert Pose-Space Matrix to Bone-Space Matrix. * NOTE: this cannot be used to convert to pose-space transforms of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) { float rotscale_mat[4][4], loc_mat[4][4], inmat_[4][4]; /* Security, this allows to call with inmat == outmat! */ copy_m4_m4(inmat_, inmat); - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); invert_m4(rotscale_mat); invert_m4(loc_mat); @@ -1270,14 +1270,14 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm } /* Convert Bone-Space Matrix to Pose-Space Matrix. */ -void armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) { float rotscale_mat[4][4], loc_mat[4][4], inmat_[4][4]; /* Security, this allows to call with inmat == outmat! */ copy_m4_m4(inmat_, inmat); - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); mult_m4_m4m4(outmat, rotscale_mat, inmat_); mul_v3_m4v3(outmat[3], loc_mat, inmat_[3]); @@ -1286,7 +1286,7 @@ void armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outm /* Convert Pose-Space Location to Bone-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3]) +void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3]) { float xLocMat[4][4] = MAT4_UNITY; float nLocMat[4][4]; @@ -1295,29 +1295,29 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float copy_v3_v3(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ - armature_mat_pose_to_bone(pchan, xLocMat, nLocMat); + BKE_armature_mat_pose_to_bone(pchan, xLocMat, nLocMat); copy_v3_v3(outloc, nLocMat[3]); } -void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[][4], float outmat[][4]) { bPoseChannel work_pchan = *pchan; /* recalculate pose matrix with only parent transformations, * bone loc/sca/rot is ignored, scene and frame are not used. */ - where_is_pose_bone(NULL, ob, &work_pchan, 0.0f, FALSE); + BKE_pose_where_is_bone(NULL, ob, &work_pchan, 0.0f, FALSE); /* find the matrix, need to remove the bone transforms first so this is * calculated as a matrix to set rather then a difference ontop of whats * already there. */ unit_m4(outmat); - pchan_apply_mat4(&work_pchan, outmat, FALSE); + BKE_pchan_apply_mat4(&work_pchan, outmat, FALSE); - armature_mat_pose_to_bone(&work_pchan, inmat, outmat); + BKE_armature_mat_pose_to_bone(&work_pchan, inmat, outmat); } /* same as BKE_object_mat3_to_rot() */ -void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) +void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) { switch (pchan->rotmode) { case ROT_MODE_QUAT: @@ -1336,17 +1336,17 @@ void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) /* Apply a 4x4 matrix to the pose bone, * similar to BKE_object_apply_mat4() */ -void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) +void BKE_pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) { float rot[3][3]; mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat); - pchan_mat3_to_rot(pchan, rot, use_compat); + BKE_pchan_mat3_to_rot(pchan, rot, use_compat); } /* Remove rest-position effects from pose-transform for obtaining * 'visual' transformation of pose-channel. * (used by the Visual-Keyframing stuff) */ -void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) +void BKE_armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) { float imat[4][4]; @@ -1496,7 +1496,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) /* recursive part, calculates restposition of entire tree of children */ /* used by exiting editmode too */ -void where_is_armature_bone(Bone *bone, Bone *prevbone) +void BKE_armature_where_is_bone(Bone *bone, Bone *prevbone) { float vec[3]; @@ -1529,19 +1529,19 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) /* and the kiddies */ prevbone = bone; for (bone = bone->childbase.first; bone; bone = bone->next) { - where_is_armature_bone(bone, prevbone); + BKE_armature_where_is_bone(bone, prevbone); } } /* updates vectors and matrices on rest-position level, only needed * after editing armature itself, now only on reading file */ -void where_is_armature(bArmature *arm) +void BKE_armature_where_is(bArmature *arm) { Bone *bone; /* hierarchical from root to children */ for (bone = arm->bonebase.first; bone; bone = bone->next) { - where_is_armature_bone(bone, NULL); + BKE_armature_where_is_bone(bone, NULL); } } @@ -1561,7 +1561,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected * to avoid crashing check for possible errors here */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->layer & layer_protected) { - if (get_pose_channel(frompose, pchan->name) == NULL) { + if (BKE_pose_channel_find_name(frompose, pchan->name) == NULL) { printf("failed to sync proxy armature because '%s' is missing pose channel '%s'\n", from->id.name, pchan->name); error = 1; @@ -1573,7 +1573,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected return; /* clear all transformation values from library */ - rest_pose(frompose); + BKE_pose_rest(frompose); /* copy over all of the proxy's bone groups */ /* TODO for later @@ -1585,7 +1585,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected pose->active_group = frompose->active_group; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - pchanp = get_pose_channel(frompose, pchan->name); + pchanp = BKE_pose_channel_find_name(frompose, pchan->name); if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; @@ -1638,7 +1638,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected } /* free stuff from current channel */ - free_pose_channel(pchan); + BKE_pose_channel_free(pchan); /* the final copy */ *pchan = pchanw; @@ -1672,7 +1672,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int counter) { - bPoseChannel *pchan = verify_pose_channel(pose, bone->name); /* verify checks and/or adds */ + bPoseChannel *pchan = BKE_pose_channel_verify(pose, bone->name); /* verify checks and/or adds */ pchan->bone = bone; pchan->parent = parchan; @@ -1683,7 +1683,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int counter = rebuild_pose_bone(pose, bone, pchan, counter); /* for quick detecting of next bone in chain, only b-bone uses it now */ if (bone->flag & BONE_CONNECTED) - pchan->child = get_pose_channel(pose, bone->name); + pchan->child = BKE_pose_channel_find_name(pose, bone->name); } return counter; @@ -1691,7 +1691,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int /* only after leave editmode, duplicating, validating older files, library syncing */ /* NOTE: pose->flag is set for it */ -void armature_rebuild_pose(Object *ob, bArmature *arm) +void BKE_pose_rebuild(Object *ob, bArmature *arm) { Bone *bone; bPose *pose; @@ -1723,8 +1723,8 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) for (pchan = pose->chanbase.first; pchan; pchan = next) { next = pchan->next; if (pchan->bone == NULL) { - free_pose_channel(pchan); - free_pose_channels_hash(pose); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(pose); BLI_freelinkN(&pose->chanbase, pchan); } } @@ -1736,7 +1736,7 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected); } - update_pose_constraint_flags(ob->pose); /* for IK detection for example */ + BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */ /* the sorting */ if (counter>1) @@ -1745,7 +1745,7 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) ob->pose->flag &= ~POSE_RECALC; ob->pose->flag |= POSE_WAS_REBUILT; - make_pose_channels_hash(ob->pose); + BKE_pose_channels_hash_make(ob->pose); } @@ -1959,7 +1959,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o float splineVec[3], scaleFac, radius =1.0f; /* firstly, calculate the bone matrix the standard way, since this is needed for roll control */ - where_is_pose_bone(scene, ob, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); copy_v3_v3(poseHead, pchan->pose_head); copy_v3_v3(poseTail, pchan->pose_tail); @@ -2145,7 +2145,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o copy_v3_v3(pchan->pose_head, poseHead); /* recalculate tail, as it's now outdated after the head gets adjusted above! */ - where_is_pose_bone_tail(pchan); + BKE_pose_where_is_bone_tail(pchan); /* done! */ pchan->flag |= POSE_DONE; @@ -2183,7 +2183,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_ /* ********************** THE POSE SOLVER ******************* */ /* loc/rot/size to given mat4 */ -void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) +void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) { float smat[3][3]; float rmat[3][3]; @@ -2226,12 +2226,12 @@ void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) /* loc/rot/size to mat4 */ /* used in constraint.c too */ -void pchan_calc_mat(bPoseChannel *pchan) +void BKE_pchan_calc_mat(bPoseChannel *pchan) { /* this is just a wrapper around the copy of this function which calculates the matrix * and stores the result in any given channel */ - pchan_to_mat4(pchan, pchan->chan_mat); + BKE_pchan_to_mat4(pchan, pchan->chan_mat); } #if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ @@ -2361,7 +2361,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha #endif /* calculate tail of posechannel */ -void where_is_pose_bone_tail(bPoseChannel *pchan) +void BKE_pose_where_is_bone_tail(bPoseChannel *pchan) { float vec[3]; @@ -2374,17 +2374,17 @@ void where_is_pose_bone_tail(bPoseChannel *pchan) /* pchan is validated, as having bone and parent pointer * 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers. */ -void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, int do_extra) +void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, int do_extra) { /* This gives a chan_mat with actions (ipos) results. */ if (do_extra) - pchan_calc_mat(pchan); + BKE_pchan_calc_mat(pchan); else unit_m4(pchan->chan_mat); /* Construct the posemat based on PoseChannels, that we do before applying constraints. */ /* pose_mat(b) = pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */ - armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); + BKE_armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); /* Only rootbones get the cyclic offset (unless user doesn't want that). */ /* XXX That could be a problem for snapping and other "reverse transform" features... */ @@ -2430,12 +2430,12 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* calculate head */ copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]); /* calculate tail */ - where_is_pose_bone_tail(pchan); + BKE_pose_where_is_bone_tail(pchan); } /* This only reads anim data from channels, and writes to channels */ /* This is the only function adding poses */ -void where_is_pose(Scene *scene, Object *ob) +void BKE_pose_where_is(Scene *scene, Object *ob) { bArmature *arm; Bone *bone; @@ -2450,7 +2450,7 @@ void where_is_pose(Scene *scene, Object *ob) if (ELEM(NULL, arm, scene)) return; if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, arm); + BKE_pose_rebuild(ob, arm); ctime = BKE_scene_frame_get(scene); /* not accurate... */ @@ -2494,7 +2494,7 @@ void where_is_pose(Scene *scene, Object *ob) } /* 5. otherwise just call the normal solver */ else if (!(pchan->flag & POSE_DONE)) { - where_is_pose_bone(scene, ob, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); } } /* 6. release the IK tree */ @@ -2523,7 +2523,7 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot) if (armob) { bPose *pose = armob->pose; for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { - bPoseChannel *pchan = get_pose_channel(pose, defgroup->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, defgroup->name); if (pchan && (pchan->bone->flag & BONE_SELECTED)) { dg_selection[i] = TRUE; dg_flags_sel_tot++; @@ -2545,7 +2545,7 @@ int minmax_armature(Object *ob, float min[3], float max[3]) { bPoseChannel *pchan; - /* For now, we assume where_is_pose has already been called (hence we have valid data in pachan). */ + /* For now, we assume BKE_pose_where_is has already been called (hence we have valid data in pachan). */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { DO_MINMAX(pchan->pose_head, min, max); DO_MINMAX(pchan->pose_tail, min, max); @@ -2584,7 +2584,7 @@ void boundbox_armature(Object *ob, float *loc, float *size) BKE_boundbox_init_from_minmax(bb, min, max); } -BoundBox *BKE_armature_get_bb(Object *ob) +BoundBox *BKE_armature_boundbox_get(Object *ob) { boundbox_armature(ob, NULL, NULL); diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 7c225eb0fad..972793227a8 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -78,7 +78,7 @@ MakeCSGMeshFromBlenderBase( Mesh *me; if (output == NULL || base == NULL) return 0; - me = get_mesh(base->object); + me = BKE_mesh_from_object(base->object); output->m_descriptor.user_face_vertex_data_size = 0; output->m_descriptor.user_data_size = sizeof(FaceData); @@ -105,7 +105,7 @@ CSG_LoadBlenderMesh( Mesh *me; if (output == NULL || obj == NULL) return 0; - me = get_mesh(obj); + me = BKE_mesh_from_object(obj); output->m_descriptor.user_face_vertex_data_size = 0; output->m_descriptor.user_data_size = sizeof(FaceData); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a244fa96fda..66209e8a924 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -308,7 +308,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* pose to local */ else if (to == CONSTRAINT_SPACE_LOCAL) { if (pchan->bone) { - armature_mat_pose_to_bone(pchan, mat, mat); + BKE_armature_mat_pose_to_bone(pchan, mat, mat); #if 0 /* XXX Old code, will remove it later. */ constraint_pchan_diff_mat(pchan, diff_mat); @@ -317,7 +317,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* override with local location */ if ((pchan->parent) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) { - armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat); + BKE_armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat); copy_v3_v3(mat[3], tempmat[3]); } #endif @@ -337,7 +337,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* local to pose - do inverse procedure that was done for pose to local */ if (pchan->bone) { /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */ - armature_mat_bone_to_pose(pchan, mat, mat); + BKE_armature_mat_bone_to_pose(pchan, mat, mat); #if 0 constraint_pchan_diff_mat(pchan, diff_mat); @@ -593,7 +593,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float else { bPoseChannel *pchan; - pchan = get_pose_channel(ob->pose, substring); + pchan = BKE_pose_channel_find_name(ob->pose, substring); if (pchan) { /* Multiply the PoseSpace accumulation/final matrix for this * PoseChannel by the Armature Object's Matrix to get a worldspace @@ -687,7 +687,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC \ if (ct->tar) { \ if ((ct->tar->type==OB_ARMATURE) && (ct->subtarget[0])) { \ - bPoseChannel *pchan= get_pose_channel(ct->tar->pose, ct->subtarget); \ + bPoseChannel *pchan= BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); \ ct->type = CONSTRAINT_OBTYPE_BONE; \ ct->rotOrder= (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \ }\ @@ -2199,18 +2199,18 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint */ pchan = cob->pchan; - tchan= verify_pose_channel(pose, pchan->name); + tchan= BKE_pose_channel_verify(pose, pchan->name); tchan->rotmode= pchan->rotmode; /* evaluate action using workob (it will only set the PoseChannel in question) */ what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t); /* convert animation to matrices for use here */ - pchan_calc_mat(tchan); + BKE_pchan_calc_mat(tchan); copy_m4_m4(ct->matrix, tchan->chan_mat); /* Clean up */ - free_pose(pose); + BKE_pose_free(pose); } else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) { Object workob; @@ -4542,7 +4542,7 @@ static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(is } /* helper for copy_constraints(), to be used for making sure that usercounts of copied ID's are fixed up */ -static void con_fix_copied_refs_cb(bConstraint *con, ID **idpoin, short isReference, void *UNUSED(userData)) +static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData)) { /* increment usercount if this is a reference type */ if ((*idpoin) && (isReference)) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index d8287644abf..54655cf8582 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2840,7 +2840,7 @@ void DAG_pose_sort(Object *ob) for (ct= targets.first; ct; ct= ct->next) { if (ct->tar==ob && ct->subtarget[0]) { - bPoseChannel *target= get_pose_channel(ob->pose, ct->subtarget); + bPoseChannel *target= BKE_pose_channel_find_name(ob->pose, ct->subtarget); if (target) { node2= dag_get_node(dag, target); dag_add_relation(dag, node2, node, 0, "Pose Constraint"); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 71c6c8d80aa..f1942b24810 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1085,7 +1085,7 @@ static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dt Object *ob= (Object *)id; /* get pose, and subsequently, posechannel */ - return get_pose_channel(ob->pose, dtar->pchan_name); + return BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); } else { /* cannot find a posechannel this way */ @@ -1164,7 +1164,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) } /* try to get posechannel */ - pchan= get_pose_channel(ob->pose, dtar->pchan_name); + pchan= BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); /* check if object or bone */ if (pchan) { @@ -1251,7 +1251,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) } /* try to get posechannel */ - pchan= get_pose_channel(ob->pose, dtar->pchan_name); + pchan= BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); /* check if object or bone, and get transform matrix accordingly * - "useEulers" code is used to prevent the problems associated with non-uniqueness @@ -1278,7 +1278,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) * since it stores delta transform of pose_mat so that deforms work * so it cannot be used here for "transform" space */ - pchan_to_mat4(pchan, mat); + BKE_pchan_to_mat4(pchan, mat); } } else { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 1690ad9e3aa..88cfa63e3e7 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -157,7 +157,7 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ ibuf->y /= 2; } -void image_de_interlace(Image *ima, int odd) +void BKE_image_de_interlace(Image *ima, int odd) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); if (ibuf) { @@ -602,7 +602,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); @@ -626,7 +626,7 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n } /* creates an image image owns the imbuf passed */ -Image *BKE_add_image_imbuf(ImBuf *ibuf) +Image *BKE_image_add_from_imbuf(ImBuf *ibuf) { /* on save, type is changed to FILE in editsima.c */ Image *ima; @@ -678,7 +678,7 @@ void BKE_image_memorypack(Image *ima) } } -void tag_image_time(Image *ima) +void BKE_image_tag_time(Image *ima) { if (ima) ima->lastused = (int)PIL_check_seconds_timer(); @@ -1531,7 +1531,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec #undef BUFF_MARGIN_Y } -void BKE_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) +void BKE_imbuf_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) { struct StampData stamp_data; @@ -1553,7 +1553,7 @@ void BKE_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } -int BKE_alphatest_ibuf(ImBuf *ibuf) +int BKE_imbuf_alpha_test(ImBuf *ibuf) { int tot; if (ibuf->rect_float) { @@ -1578,7 +1578,7 @@ int BKE_alphatest_ibuf(ImBuf *ibuf) /* note: imf->planes is ignored here, its assumed the image channels * are already set */ -int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) +int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) { char imtype= imf->imtype; char compress= imf->compress; @@ -1682,9 +1682,9 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) return(ok); } -/* same as BKE_write_ibuf() but crappy workaround not to perminantly modify +/* same as BKE_imbuf_write() but crappy workaround not to perminantly modify * _some_, values in the imbuf */ -int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, +int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, const short save_copy) { ImBuf ibuf_back= *ibuf; @@ -1694,7 +1694,7 @@ int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, * this just controls how to save for some formats */ ibuf->planes= imf->planes; - ok= BKE_write_ibuf(ibuf, name, imf); + ok= BKE_imbuf_write(ibuf, name, imf); if (save_copy) { /* note that we are not restoring _all_ settings */ @@ -1705,12 +1705,12 @@ int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, return ok; } -int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf) +int BKE_imbuf_write_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf) { if (scene && scene->r.stamp & R_STAMP_ALL) - BKE_stamp_info(scene, camera, ibuf); + BKE_imbuf_stamp_info(scene, camera, ibuf); - return BKE_write_ibuf(ibuf, name, imf); + return BKE_imbuf_write(ibuf, name, imf); } @@ -2575,7 +2575,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) BLI_unlock_thread(LOCK_IMAGE); } - tag_image_time(ima); + BKE_image_tag_time(ima); return ibuf; } @@ -2599,7 +2599,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) return BKE_image_acquire_ibuf(ima, iuser, NULL); } -int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr) +int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) { const int len= (iuser->fie_ima*iuser->frames)/2; @@ -2639,9 +2639,9 @@ int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr) } } -void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr) +void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr) { - const int framenr= BKE_image_user_get_frame(iuser, cfra, fieldnr); + const int framenr= BKE_image_user_frame_get(iuser, cfra, fieldnr); /* allows image users to handle redraws */ if (iuser->flag & IMA_ANIM_ALWAYS) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index d7af24b394d..c2cb45d9f9d 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1104,7 +1104,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c /* ... xxx, the other vars don't need to be filled in */ /* get the group to use */ - agrp= action_groups_find_named(&tmp_act, grpname); + agrp= BKE_action_group_find_name(&tmp_act, grpname); /* no matching group, so add one */ if (agrp == NULL) { /* Add a new group, and make it active */ diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 927a4390999..e7206af3a0f 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -51,7 +51,7 @@ #include "BKE_main.h" #include "BKE_node.h" -void *add_lamp(const char *name) +void *BKE_lamp_add(const char *name) { Lamp *la; @@ -155,7 +155,7 @@ Lamp *localize_lamp(Lamp *la) return lan; } -void make_local_lamp(Lamp *la) +void BKE_lamp_make_local(Lamp *la) { Main *bmain= G.main; Object *ob; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index d9ee95857ca..12496e78037 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -83,7 +83,7 @@ void calc_lat_fudu(int flag, int res, float *fu, float *du) } } -void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) +void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) { BPoint *bp; int i, u, v, w; @@ -184,7 +184,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) MEM_freeN(vertexCos); } -Lattice *add_lattice(const char *name) +Lattice *BKE_lattice_add(const char *name) { Lattice *lt; @@ -195,7 +195,7 @@ Lattice *add_lattice(const char *name) lt->typeu= lt->typev= lt->typew= KEY_BSPLINE; lt->def= MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ - resizelattice(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ + BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ return lt; } @@ -353,7 +353,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight) /* vgroup influence */ int defgroup_nr= -1; float co_prev[3], weight_blend= 0.0f; - MDeformVert *dvert= lattice_get_deform_verts(ob); + MDeformVert *dvert= BKE_lattice_deform_verts_get(ob); if (lt->editlatt) lt= lt->editlatt->latt; @@ -928,7 +928,7 @@ void outside_lattice(Lattice *lt) } } -float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] +float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3] { Lattice *lt = ob->data; int i, numVerts; @@ -946,7 +946,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] return vertexCos; } -void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]) +void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]) { Lattice *lt = ob->data; int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw; @@ -956,7 +956,7 @@ void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]) } } -void lattice_calc_modifiers(Scene *scene, Object *ob) +void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) { Lattice *lt= ob->data; ModifierData *md = modifiers_getVirtualModifierList(ob); @@ -975,12 +975,12 @@ void lattice_calc_modifiers(Scene *scene, Object *ob) if (mti->isDisabled && mti->isDisabled(md, 0)) continue; if (mti->type!=eModifierTypeType_OnlyDeform) continue; - if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts); + if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); } /* always displist to make this work like derivedmesh */ - if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts); + if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); { DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl"); @@ -993,7 +993,7 @@ void lattice_calc_modifiers(Scene *scene, Object *ob) } } -struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt) +struct MDeformVert* BKE_lattice_deform_verts_get(struct Object *oblatt) { Lattice *lt = (Lattice*)oblatt->data; BLI_assert(oblatt->type == OB_LATTICE); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index e9520566dd0..8d643349b8c 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -206,10 +206,10 @@ int id_make_local(ID *id, int test) if (!test) BKE_metaball_make_local((MetaBall *)id); return 1; case ID_MA: - if (!test) make_local_material((Material *)id); + if (!test) BKE_material_make_local((Material *)id); return 1; case ID_TE: - if (!test) make_local_texture((Tex *)id); + if (!test) BKE_texture_make_local((Tex *)id); return 1; case ID_IM: if (!test) BKE_image_make_local((Image *)id); @@ -221,13 +221,13 @@ int id_make_local(ID *id, int test) } return 1; case ID_LA: - if (!test) make_local_lamp((Lamp *)id); + if (!test) BKE_lamp_make_local((Lamp *)id); return 1; case ID_CA: if (!test) BKE_camera_make_local((Camera *)id); return 1; case ID_SPK: - if (!test) make_local_speaker((Speaker *)id); + if (!test) BKE_speaker_make_local((Speaker *)id); return 1; case ID_IP: return 0; /* deprecated */ @@ -943,7 +943,7 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *find_id(const char *type, const char *name) /* type: "OB" or "MA" etc */ +ID *BKE_libblock_find_name(const char *type, const char *name) /* type: "OB" or "MA" etc */ { ListBase *lb= which_libbase(G.main, GS(type)); return BLI_findstring(lb, name, offsetof(ID, name) + 2); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 16b3cb639bc..f4d9bcfd218 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -199,7 +199,7 @@ void init_material(Material *ma) ma->preview = NULL; } -Material *add_material(const char *name) +Material *BKE_material_add(const char *name) { Material *ma; @@ -280,7 +280,7 @@ static void extern_local_material(Material *ma) } } -void make_local_material(Material *ma) +void BKE_material_make_local(Material *ma) { Main *bmain= G.main; Object *ob; @@ -1674,7 +1674,7 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) } /* create a new material */ else { - ma= add_material(idname+2); + ma= BKE_material_add(idname+2); if (ma) { printf("TexFace Convert: Material \"%s\" created.\n", idname+2); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index da758ea0f0b..fd054dee44a 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -484,7 +484,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata) memset(&mesh->fdata, 0, sizeof(mesh->fdata)); } -Mesh *add_mesh(const char *name) +Mesh *BKE_mesh_add(const char *name) { Mesh *me; @@ -846,7 +846,7 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) return nr; } -Mesh *get_mesh(Object *ob) +Mesh *BKE_mesh_from_object(Object *ob) { if (ob==NULL) return NULL; @@ -1489,7 +1489,7 @@ void nurbs_to_mesh(Object *ob) } /* make mesh */ - me= add_mesh("Mesh"); + me= BKE_mesh_add("Mesh"); me->totvert= totvert; me->totedge= totedge; me->totloop = totloop; @@ -1505,7 +1505,7 @@ void nurbs_to_mesh(Object *ob) BKE_mesh_calc_edges(me, TRUE); } else { - me= add_mesh("Mesh"); + me= BKE_mesh_add("Mesh"); DM_to_mesh(dm, me, ob); } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index bc7d3af930b..e432428eae4 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -381,7 +381,7 @@ void multires_force_update(Object *ob) void multires_force_external_reload(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); CustomData_external_reload(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); multires_force_update(ob); @@ -650,7 +650,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) /* direction=1 for delete higher, direction=0 for lower (not implemented yet) */ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); int lvl = multires_get_level(ob, mmd, 0); int levels = mmd->totlvl - lvl; MDisps *mdisps; @@ -717,7 +717,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) multires_force_update(ob); - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); totlvl = mmd->totlvl; /* nothing to do */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3cdf45e3569..14f23032dd9 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -321,7 +321,7 @@ void BKE_object_free(Object *ob) if (ob->defbase.first) BLI_freelistN(&ob->defbase); if (ob->pose) - free_pose(ob->pose); + BKE_pose_free(ob->pose); if (ob->mpath) animviz_free_motionpath(ob->mpath); free_properties(&ob->prop); @@ -730,17 +730,17 @@ int BKE_object_exists_check(Object *obtest) void *BKE_object_obdata_add_from_type(int type) { switch (type) { - case OB_MESH: return add_mesh("Mesh"); - case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE); - case OB_SURF: return BKE_curve_add("Surf", OB_SURF); - case OB_FONT: return BKE_curve_add("Text", OB_FONT); - case OB_MBALL: return BKE_metaball_add("Meta"); - case OB_CAMERA: return BKE_camera_add("Camera"); - case OB_LAMP: return add_lamp("Lamp"); - case OB_LATTICE: return add_lattice("Lattice"); - case OB_ARMATURE: return add_armature("Armature"); - case OB_SPEAKER: return add_speaker("Speaker"); - case OB_EMPTY: return NULL; + case OB_MESH: return BKE_mesh_add("Mesh"); + case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE); + case OB_SURF: return BKE_curve_add("Surf", OB_SURF); + case OB_FONT: return BKE_curve_add("Text", OB_FONT); + case OB_MBALL: return BKE_metaball_add("Meta"); + case OB_CAMERA: return BKE_camera_add("Camera"); + case OB_LAMP: return BKE_lamp_add("Lamp"); + case OB_LATTICE: return BKE_lattice_add("Lattice"); + case OB_ARMATURE: return BKE_armature_add("Armature"); + case OB_SPEAKER: return BKE_speaker_add("Speaker"); + case OB_EMPTY: return NULL; default: printf("BKE_object_obdata_add_from_type: Internal error, bad type: %d\n", type); return NULL; @@ -1027,9 +1027,9 @@ static void copy_object_pose(Object *obn, Object *ob) { bPoseChannel *chan; - /* note: need to clear obn->pose pointer first, so that copy_pose works (otherwise there's a crash) */ + /* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */ obn->pose= NULL; - copy_pose(&obn->pose, ob->pose, 1); /* 1 = copy constraints */ + BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */ for (chan = obn->pose->chanbase.first; chan; chan=chan->next) { bConstraint *con; @@ -1134,7 +1134,7 @@ Object *BKE_object_copy(Object *ob) copy_object_pose(obn, ob); /* backwards compat... non-armatures can get poses in older files? */ if (ob->type==OB_ARMATURE) - armature_rebuild_pose(obn, obn->data); + BKE_pose_rebuild(obn, obn->data); } defgroup_copy_list(&obn->defbase, &ob->defbase); copy_constraints(&obn->constraints, &ob->constraints, TRUE); @@ -1400,8 +1400,8 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) /* type conversions */ if (target->type == OB_ARMATURE) { copy_object_pose(ob, target); /* data copy, object pointers in constraints */ - rest_pose(ob->pose); /* clear all transforms in channels */ - armature_rebuild_pose(ob, ob->data); /* set all internal links */ + BKE_pose_rest(ob->pose); /* clear all transforms in channels */ + BKE_pose_rebuild(ob, ob->data); /* set all internal links */ armature_set_id_extern(ob); } @@ -1570,7 +1570,7 @@ void BKE_object_tfm_protected_restore(Object *ob, } } -/* see pchan_apply_mat4() for the equivalent 'pchan' function */ +/* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */ void BKE_object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent) { float rot[3][3]; @@ -1723,7 +1723,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) } /* Make sure the bone is still valid */ - pchan= get_pose_channel(par->pose, ob->parsubstr); + pchan= BKE_pose_channel_find_name(par->pose, ob->parsubstr); if (!pchan) { printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr); unit_m4(mat); @@ -2295,7 +2295,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) break; case OB_MESH: { - Mesh *me= get_mesh(ob); + Mesh *me= BKE_mesh_from_object(ob); if (me) { bb = *mesh_get_bb(ob); @@ -2499,7 +2499,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (ob->recalc & OB_RECALC_ALL) { /* speed optimization for animation lookups */ if (ob->pose) - make_pose_channels_hash(ob->pose); + BKE_pose_channels_hash_make(ob->pose); if (ob->recalc & OB_RECALC_DATA) { if (ob->type==OB_ARMATURE) { @@ -2508,7 +2508,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) * is evaluated on the rebuilt pose, otherwise we get incorrect poses * on file load */ if (ob->pose==NULL || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); } } @@ -2585,10 +2585,10 @@ void BKE_object_handle_update(Scene *scene, Object *ob) case OB_ARMATURE: if (ob->id.lib && ob->proxy_from) { // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); - copy_pose_result(ob->pose, ob->proxy_from->pose); + BKE_pose_copy_result(ob->pose, ob->proxy_from->pose); } else { - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } break; @@ -2603,7 +2603,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) break; case OB_LATTICE: - lattice_calc_modifiers(scene, ob); + BKE_lattice_modifiers_calc(scene, ob); break; } diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 4ddcd6f4b51..6242976d323 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -1251,18 +1251,18 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v /* write the images */ cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); - if (0 == BKE_write_ibuf(ibuf_disp, string, &imf)) + if (0 == BKE_imbuf_write(ibuf_disp, string, &imf)) printf("Cannot save Displacement File Output to %s\n", string); if (o->_do_jacobian) { cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); - if (0 == BKE_write_ibuf(ibuf_foam, string, &imf)) + if (0 == BKE_imbuf_write(ibuf_foam, string, &imf)) printf("Cannot save Foam File Output to %s\n", string); } if (o->_do_normals) { cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); - if (0 == BKE_write_ibuf(ibuf_normal, string, &imf)) + if (0 == BKE_imbuf_write(ibuf_normal, string, &imf)) printf("Cannot save Normal File Output to %s\n", string); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9e21538b5ca..2673200690b 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -615,7 +615,7 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) /* called from creator.c */ Scene *BKE_scene_set_name(Main *bmain, const char *name) { - Scene *sce= (Scene *)find_id("SC", name); + Scene *sce= (Scene *)BKE_libblock_find_name("SC", name); if (sce) { BKE_scene_set_background(bmain, sce); printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name); diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index d6fea87397d..fdda1c6ec0a 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -492,7 +492,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); } else if (calc.ob->type == OB_LATTICE) { - calc.dvert = lattice_get_deform_verts(calc.ob); + calc.dvert = BKE_lattice_deform_verts_get(calc.ob); } diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index d3c38221c00..e94a11b8f89 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -43,7 +43,7 @@ #include "BKE_main.h" #include "BKE_speaker.h" -void *add_speaker(const char *name) +void *BKE_speaker_add(const char *name) { Speaker *spk; @@ -76,7 +76,7 @@ Speaker *BKE_speaker_copy(Speaker *spk) return spkn; } -void make_local_speaker(Speaker *spk) +void BKE_speaker_make_local(Speaker *spk) { Main *bmain= G.main; Object *ob; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 5ba3e95154b..9b3689df941 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -901,7 +901,7 @@ static void extern_local_texture(Tex *tex) id_lib_extern((ID *)tex->ima); } -void make_local_texture(Tex *tex) +void BKE_texture_make_local(Tex *tex) { Main *bmain= G.main; Material *ma; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ec7d58035b4..637bb085aa2 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2574,7 +2574,7 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose) /* sync proxy active bone */ if (pose->proxy_act_bone[0]) { - Bone *bone = get_named_bone(arm, pose->proxy_act_bone); + Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone); if (bone) arm->act_bone = bone; } @@ -2584,7 +2584,7 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose) lib_link_constraints(fd, (ID *)ob, &pchan->constraints); /* hurms... loop in a loop, but yah... later... (ton) */ - pchan->bone= get_named_bone(arm, pchan->name); + pchan->bone= BKE_armature_find_bone_name(arm, pchan->name); pchan->custom= newlibadr_us(fd, arm->id.lib, pchan->custom); if (pchan->bone==NULL) @@ -4096,7 +4096,7 @@ static void lib_link_object(FileData *fd, Main *main) warn= 1; if (ob->pose) { - free_pose(ob->pose); + BKE_pose_free(ob->pose); ob->pose= NULL; ob->mode &= ~OB_MODE_POSE; } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 6b03fab13e4..43d32b40e1a 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1854,7 +1854,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) // armature recode checks for (arm= main->armature.first; arm; arm= arm->id.next) { - where_is_armature(arm); + BKE_armature_where_is(arm); for (bone= arm->bonebase.first; bone; bone= bone->next) do_version_bone_head_tail_237(bone); @@ -1866,7 +1866,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob->partype = PARSKEL; } - // btw. armature_rebuild_pose is further only called on leave editmode + // btw. BKE_pose_rebuild is further only called on leave editmode if (ob->type==OB_ARMATURE) { if (ob->pose) ob->pose->flag |= POSE_RECALC; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c741ebbc5bf..11f6b972837 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1271,7 +1271,7 @@ static void write_pose(WriteData *wd, bPose *pose) /* write IK param */ if (pose->ikparam) { - char *structname = (char *)get_ikparam_name(pose); + char *structname = (char *)BKE_pose_ikparam_get_name(pose); if (structname) writestruct(wd, DATA, structname, 1, pose->ikparam); } diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 3c90c5ad055..3e40afadd99 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -371,7 +371,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B } if (!(fcu)) return; - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); if (!pchan) return; @@ -379,7 +379,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } if (fra.size()) { @@ -388,7 +388,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B if (flag & ARM_RESTPOS) arm->flag = flag; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm, Bone *bone) @@ -739,7 +739,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj bPoseChannel *pchan = NULL; bPose *pose = ob_arm->pose; - pchan = get_pose_channel(pose, bone->name); + pchan = BKE_pose_channel_find_name(pose, bone->name); if (!pchan) return ""; @@ -756,7 +756,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj float ctime = BKE_scene_frame_get_from_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob_arm, pchan, ctime, 1); // compute bone local mat if (bone->parent) { @@ -1206,7 +1206,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); if (!pchan) return; //Fill frame array with key frame values framed at \param:transform_type @@ -1227,7 +1227,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo // exit rest position if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } //v array will hold all values which will be exported. if (fra.size()) { @@ -1257,7 +1257,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo // restore restpos if (flag & ARM_RESTPOS) arm->flag = flag; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) @@ -1265,7 +1265,7 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i bPoseChannel *parchan = NULL; bPose *pose = ob_arm->pose; - pchan = get_pose_channel(pose, bone->name); + pchan = BKE_pose_channel_find_name(pose, bone->name); if (!pchan) return; @@ -1282,7 +1282,7 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob_arm, pchan, ctime, 1); // compute bone local mat if (bone->parent) { diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index d6b6bfeb73d..195057817dd 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -206,7 +206,7 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector& if (bone_name) { /* try to find group */ - grp = action_groups_find_named(act, bone_name); + grp = BKE_action_group_find_name(act, bone_name); /* no matching groups, so add one */ if (grp == NULL) { @@ -361,7 +361,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) create_fcurve(3, rna_path) }; - bPoseChannel *chan = get_pose_channel(ob->pose, grp->name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, grp->name); float m4[4][4], irest[3][3]; invert_m4_m4(m4, chan->bone->arm_mat); @@ -670,7 +670,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& get_joint_rest_mat(irest_dae, root, node); invert_m4(irest_dae); - Bone *bone = get_named_bone((bArmature*)ob->data, bone_name); + Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); return; @@ -784,7 +784,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& } if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name); chan->rotmode = ROT_MODE_QUAT; } else { @@ -1025,7 +1025,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vectordata, bone_name); + Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); return; @@ -1123,7 +1123,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vectorpose, bone_name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name); chan->rotmode = ROT_MODE_QUAT; } @@ -1307,7 +1307,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, get_joint_rest_mat(irest_dae, root, node); invert_m4(irest_dae); - Bone *bone = get_named_bone((bArmature*)ob->data, bone_name); + Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); return NULL; @@ -1515,7 +1515,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, if (is_rotation || is_matrix) { if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name); chan->rotmode = ROT_MODE_QUAT; } else { @@ -1849,7 +1849,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv bAction *act = ob->adt->action; /* try to find group */ - bActionGroup *grp = action_groups_find_named(act, bone_name); + bActionGroup *grp = BKE_action_group_find_name(act, bone_name); /* no matching groups, so add one */ if (grp == NULL) { diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index d5a3b4cb0a2..38a5e9b5df4 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -251,13 +251,13 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, }*/ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node) { - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); float mat[4][4]; if (bone->parent) { // get bone-space matrix from armature-space - bPoseChannel *parchan = get_pose_channel(ob_arm->pose, bone->parent->name); + bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, bone->parent->name); float invpar[4][4]; invert_m4_m4(invpar, parchan->pose_mat); @@ -481,12 +481,12 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase // put armature in rest position if (!(arm->flag & ARM_RESTPOS)) { arm->flag |= ARM_RESTPOS; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) { if (is_bone_defgroup(ob_arm, def)) { - bPoseChannel *pchan = get_pose_channel(pose, def->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, def->name); float mat[4][4]; float world[4][4]; @@ -515,7 +515,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase // back from rest positon if (!(flag & ARM_RESTPOS)) { arm->flag = flag; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } source.finish(); @@ -525,7 +525,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase Bone *ArmatureExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def) { - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, def->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name); return pchan ? pchan->bone : NULL; } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 4316edf1e67..97de7590d07 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -321,7 +321,7 @@ void ArmatureImporter::set_leaf_bone_shapes(Object *ob_arm) for (it = leaf_bones.begin(); it != leaf_bones.end(); it++) { LeafBone& leaf = *it; - bPoseChannel *pchan = get_pose_channel(pose, leaf.name); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, leaf.name); if (pchan) { pchan->custom = get_empty_for_leaves(); } @@ -499,7 +499,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) std::map::iterator it; for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) { SkinInfo *b = &it->second; - if (b == a || b->get_armature() == NULL) + if (b == a || b->BKE_armature_from_object() == NULL) continue; skin_root_joints.clear(); @@ -509,7 +509,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) std::vector::iterator ri; for (ri = skin_root_joints.begin(); ri != skin_root_joints.end(); ri++) { if (a->uses_joint_or_descendant(*ri)) { - shared = b->get_armature(); + shared = b->BKE_armature_from_object(); break; } } @@ -582,13 +582,13 @@ void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, c get_node_mat(obmat, root_node, NULL, NULL); //if (*edbone) - bPoseChannel * pchan = get_pose_channel(ob_arm -> pose, bone_name); + bPoseChannel * pchan = BKE_pose_channel_find_name(ob_arm -> pose, bone_name); //else fprintf ( "", // get world-space if (parentname) { mult_m4_m4m4(mat, parent_mat, obmat); - bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parentname); + bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname); mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat ); @@ -660,7 +660,7 @@ void ArmatureImporter::make_armatures(bContext *C) // set armature parent if any Object *par = skin.get_parent(); if (par) - bc_set_parent(skin.get_armature(), par, C, false); + bc_set_parent(skin.BKE_armature_from_object(), par, C, false); // free memory stolen from SkinControllerData skin.free(); @@ -761,7 +761,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node) SkinInfo& skin = it->second; if (skin.uses_joint_or_descendant(node)) - return skin.get_armature(); + return skin.BKE_armature_from_object(); } std::map::iterator arm; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 98a30fbef74..6dca7828cc2 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -572,7 +572,7 @@ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) return true; const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); - Material *ma = add_material((char*)str_mat_id.c_str()); + Material *ma = BKE_material_add((char*)str_mat_id.c_str()); this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; this->uid_material_map[cmat->getUniqueId()] = ma; @@ -949,8 +949,8 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) la_id = light->getOriginalId(); la_name = light->getName(); - if (la_name.size()) lamp = (Lamp*)add_lamp((char*)la_name.c_str()); - else lamp = (Lamp*)add_lamp((char*)la_id.c_str()); + if (la_name.size()) lamp = (Lamp*)BKE_lamp_add((char*)la_name.c_str()); + else lamp = (Lamp*)BKE_lamp_add((char*)la_id.c_str()); if (!lamp) { fprintf(stderr, "Cannot create lamp.\n"); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index c20975145ac..ca1f2d2f1be 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -962,7 +962,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) } const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId(); - Mesh *me = add_mesh((char*)str_geom_id.c_str()); + Mesh *me = BKE_mesh_add((char*)str_geom_id.c_str()); me->id.us--; // is already 1 here, but will be set later in set_mesh // store the Mesh pointer to link it later with an Object diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index d807b049152..f7cb7dc96c2 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -178,7 +178,7 @@ bool SkinInfo::get_joint_inv_bind_matrix(float inv_bind_mat[][4], COLLADAFW::Nod return false; } -Object *SkinInfo::get_armature() +Object *SkinInfo::BKE_armature_from_object() { return ob_arm; } @@ -288,7 +288,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mappose, bc_get_joint_name(node)); + return BKE_pose_channel_find_name(ob_arm->pose, bc_get_joint_name(node)); } void SkinInfo::set_parent(Object *_parent) diff --git a/source/blender/collada/SkinInfo.h b/source/blender/collada/SkinInfo.h index 7befe7168d3..894f53f07c3 100644 --- a/source/blender/collada/SkinInfo.h +++ b/source/blender/collada/SkinInfo.h @@ -105,7 +105,7 @@ public: bool get_joint_inv_bind_matrix(float inv_bind_mat[][4], COLLADAFW::Node *node); - Object *get_armature(); + Object *BKE_armature_from_object(); const COLLADAFW::UniqueId& get_controller_uid(); diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index b449c11ff7b..5b8e696f05a 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -144,7 +144,7 @@ static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone */ if (ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, agrp->name); + bPoseChannel *pchan= BKE_pose_channel_find_name(ob->pose, agrp->name); /* if one matches, sync the selection status */ if (pchan) { @@ -179,7 +179,7 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) /* get bone-name, and check if this bone is selected */ bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); - pchan= get_pose_channel(ob->pose, bone_name); + pchan= BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* F-Curve selection depends on whether the bone is selected */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index cc3401da6c5..180953ea017 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -842,7 +842,7 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ /* get bone-name, and check if this bone is selected */ bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); - pchan= get_pose_channel(ob->pose, bone_name); + pchan= BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* check whether to continue or skip */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 9d51b42f1a2..281a3e110bb 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -183,7 +183,7 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], /* if a group name has been provided, try to add or find a group, then add F-Curve to it */ if (group) { /* try to find group */ - grp= action_groups_find_named(act, group); + grp= BKE_action_group_find_name(act, group); /* no matching groups, so add one */ if (grp == NULL) diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 925cffca288..8f2a228ffef 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -531,7 +531,7 @@ ListBase builtin_keyingsets = {NULL, NULL}; /* --------------- */ /* Find KeyingSet type info given a name */ -KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]) +KeyingSetInfo *ANIM_keyingset_info_find_name (const char name[]) { /* sanity checks */ if ((name == NULL) || (name[0] == 0)) @@ -786,7 +786,7 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) @@ -868,7 +868,7 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* if relative Keying Sets, poll and build up the paths */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* clear all existing paths * NOTE: BKE_keyingset_free() frees all of the paths for the KeyingSet, but not the set itself diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 5c43ba6e67f..44dfcaacbfc 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -340,7 +340,7 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) for (curBone=bonelist->first; curBone; curBone=curBone->next) { /* sets local matrix and arm_mat (restpos) */ - where_is_armature_bone(curBone, curBone->parent); + BKE_armature_where_is_bone(curBone, curBone->parent); /* Find the associated editbone */ for (ebone = editbonelist->first; ebone; ebone=ebone->next) @@ -367,7 +367,7 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]); /* and set restposition again */ - where_is_armature_bone(curBone, curBone->parent); + BKE_armature_where_is_bone(curBone, curBone->parent); } fix_bonelist_roll(&curBone->childbase, editbonelist); } @@ -382,7 +382,7 @@ void ED_armature_from_edit(Object *obedit) Object *obt; /* armature bones */ - free_bonelist(&arm->bonebase); + BKE_armature_bonelist_free(&arm->bonebase); /* remove zero sized bones, this gives instable restposes */ for (eBone=arm->edbo->first; eBone; eBone= neBone) { @@ -476,13 +476,13 @@ void ED_armature_from_edit(Object *obedit) } /* Make a pass through the new armature to fix rolling */ - /* also builds restposition again (like where_is_armature) */ + /* also builds restposition again (like BKE_armature_where_is) */ fix_bonelist_roll(&arm->bonebase, arm->edbo); /* so all users of this armature should get rebuilt */ for (obt= G.main->object.first; obt; obt= obt->id.next) { if (obt->data==arm) - armature_rebuild_pose(obt, arm); + BKE_pose_rebuild(obt, arm); } DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); @@ -645,7 +645,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object - bArmature *arm= get_armature(ob); + bArmature *arm= BKE_armature_from_object(ob); bPose *pose; bPoseChannel *pchan; EditBone *curbone; @@ -716,7 +716,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) ED_armature_edit_free(ob); /* flush positions of posebones */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* fix parenting of objects which are bone-parented */ applyarmature_fix_boneparents(scene, ob); @@ -766,7 +766,7 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op) * change, thus changing the result we may be trying to record. */ copy_m4_m4(delta_mat, pchan->chan_mat); - pchan_apply_mat4(pchan, delta_mat, TRUE); + BKE_pchan_apply_mat4(pchan, delta_mat, TRUE); } CTX_DATA_END; @@ -991,8 +991,8 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) BLI_remlink(&opose->chanbase, pchan); BLI_addtail(&pose->chanbase, pchan); - free_pose_channels_hash(opose); - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(opose); + BKE_pose_channels_hash_free(pose); } ED_base_object_free_and_unlink(bmain, scene, base); @@ -1155,8 +1155,8 @@ static void separate_armature_bones(Object *ob, short sel) } /* free any of the extra-data this pchan might have */ - free_pose_channel(pchan); - free_pose_channels_hash(ob->pose); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(ob->pose); /* get rid of unneeded bone */ bone_free(arm, curbone); @@ -1694,8 +1694,8 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) curBone = editbone_name_exists(arm->edbo, pchan->name); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { - free_pose_channel(pchan); - free_pose_channels_hash(obedit->pose); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(obedit->pose); BLI_freelinkN (&obedit->pose->chanbase, pchan); } else { @@ -2481,7 +2481,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj bConstraint *curcon; ListBase *conlist; - if ( (pchan = verify_pose_channel(dst_ob->pose, dupBone->name)) ) { + if ( (pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name)) ) { if ( (conlist = &pchan->constraints) ) { for (curcon = conlist->first; curcon; curcon=curcon->next) { /* does this constraint have a subtarget in @@ -2552,15 +2552,15 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase if (src_ob->pose) { bPoseChannel *chanold, *channew; - chanold = verify_pose_channel(src_ob->pose, curBone->name); + chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name); if (chanold) { /* WARNING: this creates a new posechannel, but there will not be an attached bone * yet as the new bones created here are still 'EditBones' not 'Bones'. */ - channew= verify_pose_channel(dst_ob->pose, eBone->name); + channew= BKE_pose_channel_verify(dst_ob->pose, eBone->name); if (channew) { - duplicate_pose_channel_data(channew, chanold); + BKE_pose_channel_copy_data(channew, chanold); } } } @@ -4611,7 +4611,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { - if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; @@ -4678,7 +4678,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { - if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; @@ -4821,7 +4821,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, segments = 1; bbone = NULL; - if ((par->pose) && (pchan=get_pose_channel(par->pose, bone->name))) { + if ((par->pose) && (pchan=BKE_pose_channel_find_name(par->pose, bone->name))) { if (bone->segments > 1) { segments = bone->segments; bbone = b_bone_spline_setup(pchan, 1); @@ -5447,7 +5447,7 @@ void POSE_OT_reveal(wmOperatorType *ot) static int bone_unique_check(void *arg, const char *name) { - return get_named_bone((bArmature *)arg, name) != NULL; + return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL; } static void unique_bone_name(bArmature *arm, char *name) @@ -5509,7 +5509,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n else return; } else { - Bone *bone= get_named_bone(arm, oldname); + Bone *bone= BKE_armature_find_bone_name(arm, oldname); if (bone) { unique_bone_name(arm, newname); @@ -5528,7 +5528,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* Rename the pose channel, if it exists */ if (ob->pose) { - bPoseChannel *pchan = get_pose_channel(ob->pose, oldname); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname); if (pchan) { BLI_strncpy(pchan->name, newname, MAXBONENAME); diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 3c855ff96e6..3b613a6d25c 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -189,7 +189,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) if ((arm->flag & ARM_DELAYDEFORM)==0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 3b01ba20dd5..f180f735294 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -786,7 +786,7 @@ static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) /* for each posechannel that has an actionchannel in */ for (agrp= pld->act->groups.first; agrp; agrp= agrp->next) { /* try to find posechannel */ - pchan= get_pose_channel(pld->pose, agrp->name); + pchan= BKE_pose_channel_find_name(pld->pose, agrp->name); /* backup data if available */ if (pchan) { @@ -885,7 +885,7 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld) /* check if group has any keyframes */ if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) { /* has keyframe on this frame, so try to get a PoseChannel with this name */ - pchan= get_pose_channel(pose, agrp->name); + pchan= BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { short ok= 0; @@ -927,7 +927,7 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData /* start tagging/keying */ for (agrp= act->groups.first; agrp; agrp= agrp->next) { /* only for selected bones unless there aren't any selected, in which case all are included */ - pchan= get_pose_channel(pose, agrp->name); + pchan= BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { if ( (pld->selcount == 0) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) ) { @@ -987,7 +987,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) if ((pld->arm->flag & ARM_DELAYDEFORM)==0) DAG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(pld->scene, pld->ob); + BKE_pose_where_is(pld->scene, pld->ob); } /* do header print - if interactively previewing */ @@ -1495,7 +1495,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) if ((arm->flag & ARM_DELAYDEFORM)==0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } else if (pld->state == PL_PREVIEW_CONFIRM) { @@ -1514,7 +1514,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) //remake_action_ipos(ob->action); } else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } /* free memory used for backups and searching */ diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 95e7a845a78..15d2d32c073 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -164,7 +164,7 @@ static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level) } } for (bone= pchan->bone->childbase.first; bone; bone= bone->next) { - pchan= get_pose_channel(ob->pose, bone->name); + pchan= BKE_pose_channel_find_name(ob->pose, bone->name); if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) return 1; } @@ -371,7 +371,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op for (ct= targets.first; ct; ct= ct->next) { if ((ct->tar == ob) && (ct->subtarget[0])) { - bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget); + bPoseChannel *pchanc= BKE_pose_channel_find_name(ob->pose, ct->subtarget); if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) { pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; found= 1; @@ -650,7 +650,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) char *boneName = BLI_getQuotedStr(ksp->rna_path, "bones["); if (boneName) { - bPoseChannel *pchan = get_pose_channel(pose, boneName); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName); if (pchan) { /* select if bone is visible and can be affected */ @@ -751,7 +751,7 @@ static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) char name[MAXBONENAME]; flip_side_name(name, arm->act_bone->name, TRUE); - pchanf= get_pose_channel(ob->pose, name); + pchanf= BKE_pose_channel_find_name(ob->pose, name); if (pchanf && pchanf->bone != arm->act_bone) { arm->act_bone->flag &= ~BONE_SELECTED; pchanf->bone->flag |= BONE_SELECTED; @@ -805,7 +805,7 @@ static void pose_copy_menu(Scene *scene) if (ELEM(NULL, ob, ob->pose)) return; if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return; - pchan= get_active_posechannel(ob); + pchan= BKE_pose_channel_active(ob); if (pchan==NULL) return; pchanact= pchan; @@ -891,13 +891,13 @@ static void pose_copy_menu(Scene *scene) pchan->custom = pchanact->custom; break; case 9: /* Visual Location */ - armature_loc_pose_to_bone(pchan, pchanact->pose_mat[3], pchan->loc); + BKE_armature_loc_pose_to_bone(pchan, pchanact->pose_mat[3], pchan->loc); break; case 10: /* Visual Rotation */ { float delta_mat[4][4]; - armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); if (pchan->rotmode == ROT_MODE_AXISANGLE) { float tmp_quat[4]; @@ -916,7 +916,7 @@ static void pose_copy_menu(Scene *scene) { float delta_mat[4][4], size[4]; - armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); mat4_to_size(size, delta_mat); copy_v3_v3(pchan->size, size); } @@ -978,7 +978,7 @@ static void pose_copy_menu(Scene *scene) } } BLI_freelistN(&const_copy); - update_pose_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ + BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ if (ob->pose) ob->pose->flag |= POSE_RECALC; @@ -1059,7 +1059,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s * 1) channel exists - poses are not meant to add random channels to anymore * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical */ - pchan= get_pose_channel(ob->pose, name); + pchan= BKE_pose_channel_find_name(ob->pose, name); if (selOnly) paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED)); @@ -1176,7 +1176,7 @@ static int pose_copy_exec (bContext *C, wmOperator *op) /* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */ set_pose_keys(ob); - copy_pose(&g_posebuf, ob->pose, 0); + BKE_pose_copy_data(&g_posebuf, ob->pose, 0); return OPERATOR_FINISHED; @@ -1291,7 +1291,7 @@ static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* for now, just call the API function for this */ - pose_add_group(ob); + BKE_pose_add_group(ob); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); @@ -1331,7 +1331,7 @@ static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* for now, just call the API function for this */ - pose_remove_group(ob); + BKE_pose_remove_group(ob); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); @@ -1434,7 +1434,7 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op) */ pose->active_group= RNA_int_get(op->ptr, "type"); if (pose->active_group == 0) - pose_add_group(ob); + BKE_pose_add_group(ob); /* add selected bones to group then */ CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) @@ -2281,7 +2281,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan; /* execute animation step for current frame using a dummy copy of the pose */ - copy_pose(&dummyPose, ob->pose, 0); + BKE_pose_copy_data(&dummyPose, ob->pose, 0); BLI_strncpy(workob.id.name, "OB", sizeof(workob.id.name)); workob.type = OB_ARMATURE; @@ -2314,7 +2314,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) /* no animation, so just reset whole pose to rest pose * (cannot just restore for selected though) */ - rest_pose(ob->pose); + BKE_pose_rest(ob->pose); } /* notifiers and updates */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 3795de7469c..490a8830d3a 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -190,7 +190,7 @@ int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, const char name[]); /* Find KeyingSet type info given a name */ -KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]); +KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]); /* for RNA type registrations... */ void ANIM_keyingset_info_register(KeyingSetInfo *ksi); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 149921c94b2..1c0a98eda6e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -953,7 +953,7 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) // if there are problems because of this, then rna needs changed update functions. // // object_test_constraints(ob); - // if (ob->pose) update_pose_constraint_flags(ob->pose); + // if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -969,7 +969,7 @@ static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v) /* draw panel showing settings for a constraint */ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) { - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraintTypeInfo *cti; uiBlock *block; uiLayout *result = NULL, *col, *box, *row; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index cfc9e11879e..5f6384d6b24 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -67,7 +67,7 @@ * use in object mode when selecting faces (while painting) */ void paintface_flush_flags(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MPoly *polys, *mp_orig; MFace *faces; @@ -166,7 +166,7 @@ void paintface_hide(Object *ob, const int unselected) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; mpoly = me->mpoly; @@ -195,7 +195,7 @@ void paintface_reveal(Object *ob) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; mpoly = me->mpoly; @@ -325,7 +325,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] Mesh *me; unsigned int index = 0; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; if (mode == 0 || mode == 1) { @@ -347,7 +347,7 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (action == SEL_INVERT) { @@ -410,7 +410,7 @@ int paintface_minmax(Object *ob, float r_min[3], float r_max[3]) int a, b, ok = FALSE; float vec[3], bmat[3][3]; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!me || !me->mtpoly) return ok; copy_m3_m4(bmat, ob->obmat); @@ -459,7 +459,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) MEdge *med; int a, b; - me = get_mesh(OBACT); + me = BKE_mesh_from_object(OBACT); if (me == 0 || me->totpoly == 0) return; if (mode == 0) @@ -516,7 +516,7 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in unsigned int a, index; /* Get the face under the cursor */ - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!facesel_face_pick(C, me, ob, mval, &index, 1)) return 0; @@ -567,7 +567,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) int sx = rect->xmax - rect->xmin + 1; int sy = rect->ymax - rect->ymin + 1; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0 || sx * sy <= 0) return OPERATOR_CANCELLED; @@ -629,7 +629,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) * use in object mode when selecting vertices (while painting) */ void paintvert_flush_flags(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MVert *dm_mvert, *dm_mv; int *index_array = NULL; @@ -668,7 +668,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) MVert *mvert; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (action == SEL_INVERT) { diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 042deb3def7..49e472fada4 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -560,7 +560,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) } else { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name("IM", name); } if (!ima) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 3c19871aac6..40bca557169 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1499,7 +1499,7 @@ static int convert_exec(bContext *C, wmOperator *op) mb = newob->data; mb->id.us--; - newob->data = add_mesh("Mesh"); + newob->data = BKE_mesh_add("Mesh"); newob->type = OB_MESH; me = newob->data; @@ -1761,7 +1761,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base ID_NEW_US2(obn->data) else { obn->data = BKE_armature_copy(obn->data); - armature_rebuild_pose(obn, obn->data); + BKE_pose_rebuild(obn, obn->data); didit = 1; } id->us--; @@ -1954,7 +1954,7 @@ static int add_named_exec(bContext *C, wmOperator *op) /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); - ob = (Object *)find_id("OB", name); + ob = (Object *)BKE_libblock_find_name("OB", name); if (ob == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 60ca674bb8a..ec3360f236b 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -89,7 +89,7 @@ ListBase *get_active_constraints(Object *ob) if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (pchan) return &pchan->constraints; } @@ -314,7 +314,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) curcon->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { - if (!get_named_bone(get_armature(owner), data->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->subtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -325,7 +325,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) curcon->flag |= CONSTRAINT_DISABLE; } else if (data->poletar == owner) { - if (!get_named_bone(get_armature(owner), data->polesubtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->polesubtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -344,7 +344,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) curcon->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { - if (!get_named_bone(get_armature(owner), data->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->subtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -453,7 +453,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) } else if (ct->tar == owner) { if (type == CONSTRAINT_OBTYPE_BONE) { - if (!get_named_bone(get_armature(owner), ct->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), ct->subtarget)) { /* bone must exist in armature... */ // TODO: clear subtarget? curcon->flag |= CONSTRAINT_DISABLE; @@ -585,7 +585,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int list = &ob->constraints; } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) list = &pchan->constraints; else { @@ -713,7 +713,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, /* try to find a pose channel - assume that this is the constraint owner */ // TODO: get from context instead? if (ob && ob->pose) - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); /* calculate/set inverse matrix: * We just calculate all transform-stack eval up to but not including this constraint. @@ -729,7 +729,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, * to use as baseline ("pmat") to derive delta from. This extra calc saves users * from having pressing "Clear Inverse" first */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); copy_m4_m4(pmat, pchan->pose_mat); /* 2. knock out constraints starting from this one */ @@ -746,7 +746,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, } /* 3. solve pose without disabled constraints */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* 4. determine effect of constraint by removing the newly calculated * pchan->pose_mat from the original pchan->pose_mat, thus determining @@ -769,7 +769,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, } /* 6. recalculate pose with new inv-mat applied */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } else if (ob) { Object workob; @@ -977,7 +977,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) void ED_object_constraint_update(Object *ob) { - if (ob->pose) update_pose_constraint_flags(ob->pose); + if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); object_test_constraints(ob); @@ -1312,7 +1312,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) static short get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, short add) { Object *obact = ED_object_active_context(C); - bPoseChannel *pchanact = get_active_posechannel(obact); + bPoseChannel *pchanact = BKE_pose_channel_active(obact); short only_curve = 0, only_mesh = 0, only_ob = 0; short found = 0; @@ -1459,7 +1459,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase pchan = NULL; } else { - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); /* ensure not to confuse object/pose adding */ if (pchan == NULL) { @@ -1541,7 +1541,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase object_test_constraints(ob); if (pchan) - update_pose_constraint_flags(ob->pose); + BKE_pose_update_constraint_flags(ob->pose); /* force depsgraph to get recalculated since new relationships added */ @@ -1690,7 +1690,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraint *con = NULL; uiPopupMenu *pup; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 6ec844e39b2..e9341d90e86 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -648,7 +648,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) /* reset functionality */ if (hmd->object) { - bPoseChannel *pchan = get_pose_channel(hmd->object->pose, hmd->subtarget); + bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); if (hmd->subtarget[0] && pchan) { float imat[4][4], mat[4][4]; diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 648f530881a..7b37ca8ab95 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -271,12 +271,12 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) if (ob) { lt = ob->data; - resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } else { ob = CTX_data_active_object(C); lt = ob->data; - resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index b4207efc21f..f6bf9ba2f15 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1369,7 +1369,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) dm->release(dm); } else if (ob->type == OB_LATTICE) { - lattice_calc_modifiers(scene, ob); + BKE_lattice_modifiers_calc(scene, ob); } else if (ob->type == OB_MBALL) { makeDispListMBall(scene, ob); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 666bccaf67e..8cb7c1fdcb5 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -554,7 +554,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } } else if (partype == PAR_BONE) { - pchan = get_active_posechannel(par); + pchan = BKE_pose_channel_active(par); if (pchan == NULL) { BKE_report(reports, RPT_ERROR, "No active Bone"); @@ -1510,7 +1510,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) case OB_ARMATURE: ob->recalc |= OB_RECALC_DATA; ob->data = BKE_armature_copy(ob->data); - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); break; case OB_SPEAKER: ob->data = BKE_speaker_copy(ob->data); @@ -1911,7 +1911,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ma = (Material *)find_id("MA", name); + ma = (Material *)BKE_libblock_find_name("MA", name); if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 0ef4bb503cf..3e06db4bc6f 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -884,7 +884,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ - Object *ob = (Object *)find_id("OB", tmpname); + Object *ob = (Object *)BKE_libblock_find_name("OB", tmpname); if (ob) { Base *secbase = BKE_scene_base_find(scene, ob); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 92dc9b9bd4a..785b9c0a9b7 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -548,7 +548,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); @@ -855,7 +855,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */ BKE_object_where_is_calc(scene, ob); - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ ignore_parent_tx(bmain, scene, ob); @@ -895,7 +895,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); @@ -917,7 +917,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BKE_object_where_is_calc(scene, ob_other); if (ob_other->type == OB_ARMATURE) { - where_is_pose(scene, ob_other); /* needed for bone parents */ + BKE_pose_where_is(scene, ob_other); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob_other); } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 57588c0e33a..b106bd8754a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -271,7 +271,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); - ok = BKE_write_ibuf_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ + ok = BKE_imbuf_write_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ if (ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } @@ -546,7 +546,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } else { BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); - ok = BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); + ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); if (ok == 0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index c8fd8d0c93f..ca4683b864c 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -375,7 +375,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) ma = BKE_material_copy(ma); } else { - ma = add_material("Material"); + ma = BKE_material_add("Material"); if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &ma->id); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 69ea428b2ba..6c5991422e5 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -295,7 +295,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bPoseChannel *pchan; Object *obpose= BKE_object_pose_armature_get(obact); - pchan= get_active_posechannel(obpose); + pchan= BKE_pose_channel_active(obpose); if (pchan) { CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan); return 1; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 22a1770412f..4f2433977e0 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -190,7 +190,7 @@ static int screenshot_exec(bContext *C, wmOperator *op) /* bw screenshot? - users will notice if it fails! */ IMB_color_to_bw(ibuf); } - BKE_write_ibuf(ibuf, path, &scd->im_format); + BKE_imbuf_write(ibuf, path, &scd->im_format); IMB_freeImBuf(ibuf); } @@ -357,7 +357,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float BKE_makepicstring(name, rd.pic, sj->bmain->name, rd.cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE); ibuf->rect= sj->dumprect; - ok= BKE_write_ibuf(ibuf, name, &rd.im_format); + ok= BKE_imbuf_write(ibuf, name, &rd.im_format); if (ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 8bac74e0899..397bfadbd68 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4858,7 +4858,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) if (pop->mode != PAINT_MODE_2D) { Object *ob = OBACT; - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (!me) { return 0; @@ -5451,7 +5451,7 @@ static int image_paint_sample_color_poll(bContext *C) if (CTX_wm_view3d(C)) { Object *obact = CTX_data_active_object(C); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - Mesh *me = get_mesh(obact); + Mesh *me = BKE_mesh_from_object(obact); if (me) { return !(me->editflag & ME_EDIT_PAINT_MASK); } @@ -5559,7 +5559,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects"); @@ -5794,7 +5794,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - image = BKE_add_image_imbuf(ibuf); + image = BKE_image_add_from_imbuf(ibuf); if (image) { /* now for the trickyness. store the view projection here! diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 8f8c4ae13d3..bfd8f869e66 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -93,7 +93,7 @@ static int vertex_paint_use_fast_update_check(Object *ob) DerivedMesh *dm = ob->derivedFinal; if (dm) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (me && me->mcol) { return (me->mcol == CustomData_get_layer(&dm->faceData, CD_MCOL)); } @@ -110,7 +110,7 @@ static int vertex_paint_use_tessface_check(Object *ob) DerivedMesh *dm = ob->derivedFinal; if (dm) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); return (me->mpoly == CustomData_get_layer(&dm->faceData, CD_MPOLY)); } @@ -317,7 +317,7 @@ static void make_vertexcol(Object *ob) /* single ob */ { Mesh *me; if (!ob || ob->id.lib) return; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (me->edit_btmesh) return; @@ -433,7 +433,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol) MLoopCol *lcol; int i, j, selected; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; if (!me->mloopcol) make_vertexcol(ob); @@ -551,7 +551,7 @@ void vpaint_dogamma(Scene *scene) unsigned char *cp, gamtab[256]; ob = OBACT; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if (me == 0 || me->mcol == 0 || me->totface == 0) return; @@ -1007,7 +1007,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) short change = FALSE; view3d_set_viewcontext(C, &vc); - me = get_mesh(vc.obact); + me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { int index; @@ -1094,7 +1094,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA Mesh *me; view3d_set_viewcontext(C, &vc); - me = get_mesh(vc.obact); + me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { int index; @@ -1975,7 +1975,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ VPaint *wp = scene->toolsettings->wpaint; Mesh *me; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (ob->id.lib || me == NULL) return OPERATOR_PASS_THROUGH; if (ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; @@ -2139,7 +2139,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED return FALSE; } - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; /* if nothing was added yet, we make dverts and a vertex deform group */ @@ -2154,7 +2154,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED if ((modob = modifiers_isDeformedByArmature(ob))) { Bone *actbone = ((bArmature *)modob->data)->act_bone; if (actbone) { - bPoseChannel *pchan = get_pose_channel(modob->pose, actbone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(modob->pose, actbone->name); if (pchan) { bDeformGroup *dg = defgroup_find_name(ob, pchan->name); @@ -2541,7 +2541,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ VPaint *vp = scene->toolsettings->vpaint; Mesh *me; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || BKE_object_obdata_is_libdata(ob)) { ob->mode &= ~OB_MODE_VERTEX_PAINT; @@ -2678,7 +2678,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent float mat[4][4], imat[4][4]; /* context checks could be a poll() */ - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; @@ -2726,7 +2726,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); MFace *mface = &me->mface[index]; unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index; unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index; @@ -2771,7 +2771,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); MPoly *mpoly = &me->mpoly[index]; MFace *mf; MCol *mc; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fa560dc138c..a49a9f02c60 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2756,7 +2756,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->face_normals = NULL; } else { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); ss->totvert = me->totvert; ss->totpoly = me->totpoly; ss->mvert = me->mvert; @@ -2945,7 +2945,7 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); - br = (Brush *)find_id("BR", "Smooth"); + br = (Brush *)BKE_libblock_find_name("BR", "Smooth"); if (br) { paint_brush_set(p, br); brush = br; @@ -3508,7 +3508,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str /* Alt-Smooth */ if (ss->cache->alt_smooth) { Paint *p = &sd->paint; - brush = (Brush *)find_id("BR", ss->cache->saved_active_brush_name); + brush = (Brush *)BKE_libblock_find_name("BR", ss->cache->saved_active_brush_name); if (brush) { paint_brush_set(p, brush); } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 20d5257a62f..ff466c23953 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -294,7 +294,7 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) } else { if (arm->act_bone) { - bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name); + bPoseChannel *pchan= BKE_pose_channel_find_name(ob->pose, arm->act_bone->name); if (pchan) { RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]); path->len++; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ecbd9a4033a..de171bc45f8 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -146,7 +146,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, /* the frame number, even if we cant */ if (ima->source == IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ - const int framenr = BKE_image_user_get_frame(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); ofs += sprintf(str + ofs, ", Frame: %d", framenr); } @@ -430,7 +430,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) if (ima->anim) { iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); - BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(iuser, scene->r.cfra, 0); } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 66070bf54b0..51741b8972a 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1150,7 +1150,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ if (ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ - ibuf->planes = BKE_alphatest_ibuf(ibuf) ? 32 : 24; + ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24; } } @@ -1167,7 +1167,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI BKE_image_release_renderresult(scene, ima); } else { - if (BKE_write_ibuf_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { + if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { ok = TRUE; } } @@ -1528,7 +1528,7 @@ static int image_new_exec(bContext *C, wmOperator *op) if (!alpha) color[3] = 1.0f; - ima = BKE_add_image_size(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); + ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); if (!ima) return OPERATOR_CANCELLED; @@ -2408,7 +2408,7 @@ void ED_image_update_frame(const Main *mainp, int cfra) if (tex->type == TEX_IMAGE && tex->ima) { if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { if (tex->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&tex->iuser, cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, cfra, 0); } } } @@ -2423,12 +2423,12 @@ void ED_image_update_frame(const Main *mainp, int cfra) BGpic *bgpic; for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) if (bgpic->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, cfra, 0); } else if (sa->spacetype == SPACE_IMAGE) { SpaceImage *sima = sa->spacedata.first; if (sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, cfra, 0); + BKE_image_user_frame_calc(&sima->iuser, cfra, 0); } else if (sa->spacetype == SPACE_NODE) { SpaceNode *snode = sa->spacedata.first; @@ -2440,7 +2440,7 @@ void ED_image_update_frame(const Main *mainp, int cfra) ImageUser *iuser = node->storage; if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) if (iuser->flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(iuser, cfra, 0); + BKE_image_user_frame_calc(iuser, cfra, 0); } } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 426cc3207e4..9e0f538056c 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -590,7 +590,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) ima = ED_space_image(sima); if (sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&sima->iuser, scene->r.cfra, 0); /* check if we have to set the image from the editmesh */ if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) ; diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 891236d6d21..97b6c32d81d 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1084,7 +1084,7 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co { /* check that bone exist in the active object */ if (ob->type == OB_ARMATURE && ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, posechannel); + bPoseChannel *pchan= BKE_pose_channel_find_name(ob->pose, posechannel); if (pchan) { bConstraint *con= BLI_findstring(&pchan->constraints, constraint_name, offsetof(bConstraint, name)); if (con) { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index bfa8111af3e..c2b7a1d6a7f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1247,7 +1247,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * Scene *scene= CTX_data_scene(C); ImageUser *iuser= node->storage; char numstr[32]; - const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); + const int framenr= BKE_image_user_frame_get(iuser, CFRA, 0); BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr); uiItemL(layout, numstr, ICON_NONE); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index d47a1d557ab..be9b495619c 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -3418,7 +3418,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) else if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)find_id("IM", name); + ima= (Image *)BKE_libblock_find_name("IM", name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 9bc87a27ba3..47eecbc0d77 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -674,7 +674,7 @@ static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) } /* find next element that has this name */ -static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) +static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) { TreeElement *te, *tes; @@ -694,7 +694,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na return te; } - tes= outliner_find_named(soops, &te->subtree, name, flags, prev, prevFound); + tes= outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); if (tes) return tes; } @@ -721,18 +721,18 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so flags= soops->search_flags; /* try to find matching element */ - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); + te= outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); if (te==NULL) { /* no more matches after previous, start from beginning again */ prevFound= 1; - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); + te= outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); } } else { /* pop up panel - no previous, or user didn't want search after previous */ name[0]= '\0'; // XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { -// te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound); +// te= outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); // } // else return; /* XXX RETURN! XXX */ } @@ -1402,9 +1402,9 @@ static int parent_drop_exec(bContext *C, wmOperator *op) partype= RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)find_id("OB", parname); + par= (Object *)BKE_libblock_find_name("OB", parname); RNA_string_get(op->ptr, "child", childname); - ob= (Object *)find_id("OB", childname); + ob= (Object *)BKE_libblock_find_name("OB", childname); ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); @@ -1473,9 +1473,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_string_set(op->ptr, "parent", te_found->name); /* Identify parent and child */ RNA_string_get(op->ptr, "child", childname); - ob= (Object *)find_id("OB", childname); + ob= (Object *)BKE_libblock_find_name("OB", childname); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)find_id("OB", parname); + par= (Object *)BKE_libblock_find_name("OB", parname); if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); @@ -1659,7 +1659,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); - ob= (Object *)find_id("OB", obname); + ob= (Object *)BKE_libblock_find_name("OB", obname); /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index ca5b21012aa..a9801012d67 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -258,7 +258,7 @@ void draw_motion_path_instance(Scene *scene, * unless an option is set to always use the whole action */ if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) { - bActionGroup *agrp = action_groups_find_named(adt->action, pchan->name); + bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name); if (agrp) { agroup_to_keylist(adt, agrp, &keys, NULL); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 15e6994dfe4..2211b1ddb62 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2338,9 +2338,9 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2352,20 +2352,20 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; ob->ipoflag = ipoflago; } @@ -2415,9 +2415,9 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2431,7 +2431,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * CFRA = (int)ak->cfra; BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); @@ -2439,13 +2439,13 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BLI_dlrbTree_free(&keys); - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } @@ -2481,9 +2481,9 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2501,7 +2501,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2516,7 +2516,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2525,13 +2525,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 79dce3e6bcd..6c941765a57 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1971,7 +1971,7 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) /* now we default make displist, this will modifiers work for non animated case */ if (ob->disp.first == NULL) - lattice_calc_modifiers(scene, ob); + BKE_lattice_modifiers_calc(scene, ob); dl = find_displist(&ob->disp, DL_VERTS); if (is_edit) { @@ -6168,7 +6168,7 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) } } else if (ob->type == OB_ARMATURE) { - bb = BKE_armature_get_bb(ob); + bb = BKE_armature_boundbox_get(ob); } else { drawcube(); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index f9b8f9228b9..28fd2c8bc74 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) break; } - // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier. + // removed since BKE_image_user_frame_calc is now called in draw_bgpic because screen_ops doesnt call the notifier. #if 0 if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { View3D *v3d = area->spacedata.first; @@ -1025,7 +1025,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) for (; bgpic; bgpic = bgpic->next) { if (bgpic->ima) { Scene *scene = wmn->reference; - BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, scene->r.cfra, 0); } } } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 13129616843..723dc9d5fc8 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -939,7 +939,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) PointerRNA pchanptr; uiLayout *col; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (!pchan) { uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fe7511c70cc..dd90ef57307 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1544,7 +1544,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) ima = bgpic->ima; if (ima == NULL) continue; - BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0); + BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0); ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); } else { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index de17f0af1e8..b5933310a06 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3098,7 +3098,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name("IM", name); } bgpic = background_image_add(C); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 2fe0a30c71b..367b36db583 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -582,7 +582,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) mul_m4_v3(ob->imat, vec); /* Get location of grid point in pose space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* adjust location */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -707,7 +707,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if (pchan->bone->layer & arm->layer) { if ((pchan->bone->flag & BONE_CONNECTED) == 0) { /* Get position in pchan (pose) space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* copy new position */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 1509242cf58..e1be274663a 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1176,7 +1176,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) copy_v3_v3(vec, ob->obmat[3]); if (ob->type == OB_ARMATURE && v3d->ob_centre_bone[0]) { - bPoseChannel *pchan = get_pose_channel(ob->pose, v3d->ob_centre_bone); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, v3d->ob_centre_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); mul_m4_v3(ob->obmat, vec); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d7ad0c0c9ea..3cd41edacf5 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -424,7 +424,7 @@ static short apply_targetless_ik(Object *ob) bone= parchan->bone; bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */ - armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); + BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { @@ -535,11 +535,11 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* proper way to get parent transform + own transform + constraints transform */ copy_m3_m4(omat, ob->obmat); - /* New code, using "generic" pchan_to_pose_mat(). */ + /* New code, using "generic" BKE_pchan_to_pose_mat(). */ { float rotscale_mat[4][4], loc_mat[4][4]; - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); if (t->mode == TFM_TRANSLATION) copy_m3_m4(pmat, loc_mat); else @@ -884,7 +884,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone) } } if (wentdeeper==0) { - bPoseChannel *pchan= get_pose_channel(pose, bone->name); + bPoseChannel *pchan= BKE_pose_channel_find_name(pose, bone->name); if (pchan) added+= pose_grab_with_ik_add(pchan); } @@ -953,7 +953,7 @@ static void createTransPose(TransInfo *t, Object *ob) t->total= 0; /* check validity of state */ - arm= get_armature(ob); + arm= BKE_armature_from_object(ob); if ((arm==NULL) || (ob->pose==NULL)) return; if (arm->flag & ARM_RESTPOS) { @@ -5046,7 +5046,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * we need to update the pose otherwise no updates get called during * transform and the auto-ik is not applied. see [#26164] */ struct Object *pose_ob=t->poseobj; - where_is_pose(t->scene, pose_ob); + BKE_pose_where_is(t->scene, pose_ob); } /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index bea1002b5c6..b986bda4c13 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -833,7 +833,7 @@ static void recalcData_view3d(TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ } else - where_is_pose(t->scene, ob); + BKE_pose_where_is(t->scene, ob); } else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { if (t->state != TRANS_CANCEL) { diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 093c81c8d37..94f6640ca5b 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -203,7 +203,7 @@ int gimbal_axis(Object *ob, float gmat[][3]) { if (ob) { if (ob->mode & OB_MODE_POSE) { - bPoseChannel *pchan= get_active_posechannel(ob); + bPoseChannel *pchan= BKE_pose_channel_active(ob); if (pchan) { float mat[3][3], tmat[3][3], obmat[3][3]; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 6add8cd74c6..ebfedea3968 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -714,7 +714,7 @@ int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend) gpu_verify_repeat(ima); /* Did this get lost in the image recode? */ - /* tag_image_time(ima);*/ + /* BKE_image_tag_time(ima);*/ return 1; } diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 08c5e24aca6..c726102247a 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -229,7 +229,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = t } -/* called from within the core where_is_pose loop, all animsystems and constraints +/* called from within the core BKE_pose_where_is loop, all animsystems and constraints * were executed & assigned. Now as last we do an IK pass */ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) { @@ -535,8 +535,8 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose /* 4. walk over the tree for regular solving */ for (a=0; atotchannel; a++) { if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag - where_is_pose_bone(scene, ob, tree->pchan[a], ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each where_is_pose() + BKE_pose_where_is_bone(scene, ob, tree->pchan[a], ctime, 1); + // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() tree->pchan[a]->flag |= POSE_CHAIN; } /* 5. execute the IK solver */ diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 2e437c627a2..d94529b6104 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -418,7 +418,7 @@ static IK_Data* get_ikdata(bPose *pose) // here init ikdata if needed // now that we have scene, make sure the default param are initialized if (!DefIKParam.iksolver) - init_pose_itasc(&DefIKParam); + BKE_pose_itasc_init(&DefIKParam); return (IK_Data*)pose->ikdata; } @@ -1023,7 +1023,7 @@ static void convert_pose(IK_Scene *ikscene) } // compute array of joint value corresponding to current pose -static void rest_pose(IK_Scene *ikscene) +static void BKE_pose_rest(IK_Scene *ikscene) { bPoseChannel *pchan; IK_Channel *ikchan; @@ -1133,7 +1133,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) } else { // in Blender, the rest pose is always 0 for joints - rest_pose(ikscene); + BKE_pose_rest(ikscene); } rot = &ikscene->jointArray(0); for (a=0, ikchan = ikscene->channels; atotchannel; ++a, ++ikchan) { @@ -1545,7 +1545,7 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl if (ikparam->flag & ITASC_SIMULATION) { for (i=0, ikchan=ikscene->channels; inumchan; i++, ++ikchan) { // In simulation mode we don't allow external contraint to change our bones, mark the channel done - // also tell Blender that this channel is part of IK tree (cleared on each where_is_pose() + // also tell Blender that this channel is part of IK tree (cleared on each BKE_pose_where_is() ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); ikchan->jointValid = 0; } @@ -1554,8 +1554,8 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl // in animation mode, we must get the bone position from action and constraints for (i=0, ikchan=ikscene->channels; inumchan; i++, ++ikchan) { if (!(ikchan->pchan->flag & POSE_DONE)) - where_is_pose_bone(blscene, ikscene->blArmature, ikchan->pchan, ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each where_is_pose() + BKE_pose_where_is_bone(blscene, ikscene->blArmature, ikchan->pchan, ctime, 1); + // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); ikchan->jointValid = 0; } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 43474d72de9..30b3e75255d 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -335,7 +335,7 @@ typedef struct bPose { float ctime; /* local action time of this pose */ float stride_offset[3]; /* applied to object */ - float cyclic_offset[3]; /* result of match and cycles, applied in where_is_pose() */ + float cyclic_offset[3]; /* result of match and cycles, applied in BKE_pose_where_is() */ ListBase agroups; /* list of bActionGroups */ @@ -352,7 +352,7 @@ typedef struct bPose { /* Pose->flag */ typedef enum ePose_Flags { - /* results in armature_rebuild_pose being called */ + /* results in BKE_pose_rebuild being called */ POSE_RECALC = (1<<0), /* prevents any channel from getting overridden by anim from IPO */ POSE_LOCKED = (1<<1), @@ -362,7 +362,7 @@ typedef enum ePose_Flags { POSE_CONSTRAINTS_TIMEDEPEND = (1<<3), /* recalculate bone paths */ POSE_RECALCPATHS = (1<<4), - /* set by armature_rebuild_pose to give a chance to the IK solver to rebuild IK tree */ + /* set by BKE_pose_rebuild to give a chance to the IK solver to rebuild IK tree */ POSE_WAS_REBUILT = (1<<5), /* set by game_copy_pose to indicate that this pose is used in the game engine */ POSE_GAME_ENGINE = (1<<6) diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 06352fd727c..7f52456355c 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -201,7 +201,7 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, v } /* check if we have registered this info before, and remove it */ - ksi = ANIM_keyingset_info_find_named(dummyksi.idname); + ksi = ANIM_keyingset_info_find_name(dummyksi.idname); if (ksi && ksi->ext.srna) rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna); @@ -337,7 +337,7 @@ static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr) /* keying set info is only for builtin Keying Sets */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) - ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + ksi = ANIM_keyingset_info_find_name(ks->typeinfo); return rna_pointer_inherit_refine(ptr, &RNA_KeyingSetInfo, ksi); } diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index f7e7435598b..7052bfa8225 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -134,7 +134,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA * { ImageUser *iuser = ptr->data; - BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(iuser, scene->r.cfra, 0); } diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index ff717635250..84321809ae9 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -85,7 +85,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports const float dither_back = ibuf->dither; ibuf->planes = scene->r.im_format.planes; ibuf->dither = scene->r.dither_intensity; - if (!BKE_write_ibuf(ibuf, path, &scene->r.im_format)) { + if (!BKE_imbuf_write(ibuf, path, &scene->r.im_format)) { BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); } ibuf->planes = imb_planes_back; diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 5d8d8c7bd02..d919406a14d 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -109,21 +109,21 @@ static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr) newv = (lt->opntsv > 0)? lt->opntsv: lt->pntsv; neww = (lt->opntsw > 0)? lt->opntsw: lt->pntsw; - /* resizelattice needs an object, any object will have the same result */ + /* BKE_lattice_resize needs an object, any object will have the same result */ for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->data == lt) { - resizelattice(lt, newu, newv, neww, ob); + BKE_lattice_resize(lt, newu, newv, neww, ob); if (lt->editlatt) - resizelattice(lt->editlatt->latt, newu, newv, neww, ob); + BKE_lattice_resize(lt->editlatt->latt, newu, newv, neww, ob); break; } } /* otherwise without, means old points are not repositioned */ if (!ob) { - resizelattice(lt, newu, newv, neww, NULL); + BKE_lattice_resize(lt, newu, newv, neww, NULL); if (lt->editlatt) - resizelattice(lt->editlatt->latt, newu, newv, neww, NULL); + BKE_lattice_resize(lt->editlatt->latt, newu, newv, neww, NULL); } rna_Lattice_update_data(bmain, scene, ptr); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 661e4b18c6d..0451d7c239c 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -198,7 +198,7 @@ void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *ob struct Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) { - ID *id = (ID *)add_material(name); + ID *id = (ID *)BKE_material_add(name); id_us_min(id); return (Material *)id; } @@ -233,7 +233,7 @@ void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) { - Mesh *me = add_mesh(name); + Mesh *me = BKE_mesh_add(name); id_us_min(&me->id); return me; } @@ -250,7 +250,7 @@ void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) { - Lamp *lamp = add_lamp(name); + Lamp *lamp = BKE_lamp_add(name); lamp->type = type; id_us_min(&lamp->id); return lamp; @@ -269,7 +269,7 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer) { float color[4] = {0.0, 0.0, 0.0, 1.0}; - Image *image = BKE_add_image_size(width, height, name, alpha ? 32:24, float_buffer, 0, color); + Image *image = BKE_image_add_generated(width, height, name, alpha ? 32:24, float_buffer, 0, color); id_us_min(&image->id); return image; } @@ -299,7 +299,7 @@ void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) { - Lattice *lt = add_lattice(name); + Lattice *lt = BKE_lattice_add(name); id_us_min(<->id); return lt; } @@ -426,7 +426,7 @@ void rna_Main_groups_remove(Main *bmain, Group *group) Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) { - Speaker *speaker = add_speaker(name); + Speaker *speaker = BKE_speaker_add(name); id_us_min(&speaker->id); return speaker; } @@ -468,7 +468,7 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name) { - bArmature *arm = add_armature(name); + bArmature *arm = BKE_armature_add(name); id_us_min(&arm->id); return arm; } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 3e8ee8cfe10..38f0b7e26cb 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -355,7 +355,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) if (GS(id->name) == ID_CU) BKE_curve_type_test(ob); else if (ob->type == OB_ARMATURE) - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); } } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 77110f85655..e95e49e8150 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -131,7 +131,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ if (ob != basis_ob) return NULL; /* only do basis metaball */ - tmpmesh = add_mesh("Mesh"); + tmpmesh = BKE_mesh_add("Mesh"); if (render) { ListBase disp = {NULL, NULL}; @@ -164,7 +164,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ else dm = mesh_create_derived_view(sce, ob, mask); - tmpmesh = add_mesh("Mesh"); + tmpmesh = BKE_mesh_add("Mesh"); DM_to_mesh(dm, tmpmesh, ob); dm->release(dm); } diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index ceace424f35..c87dabf46ca 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -173,7 +173,7 @@ static void rna_Pose_ik_solver_set(struct PointerRNA *ptr, int value) pose->ikparam = NULL; } pose->iksolver = value; - init_pose_ikparam(pose); + BKE_pose_ikparam_init(pose); } } @@ -185,7 +185,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *scene, PointerRNA *ptr pose->flag |= POSE_RECALC; /* checks & sorts pose channels */ DAG_scene_sort(bmain, scene); - update_pose_constraint_flags(pose); + BKE_pose_update_constraint_flags(pose); object_test_constraints(ob); @@ -586,7 +586,7 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index) int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { bPose *pose = (bPose*)ptr->data; - bPoseChannel *pchan = get_pose_channel(pose, key); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, key); if (pchan) { RNA_pointer_create(ptr->id.data, &RNA_PoseBone, pchan, r_ptr); return TRUE; @@ -599,13 +599,13 @@ int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ static void rna_PoseChannel_matrix_basis_get(PointerRNA *ptr, float *values) { bPoseChannel *pchan = (bPoseChannel*)ptr->data; - pchan_to_mat4(pchan, (float (*)[4])values); + BKE_pchan_to_mat4(pchan, (float (*)[4])values); } static void rna_PoseChannel_matrix_basis_set(PointerRNA *ptr, const float *values) { bPoseChannel *pchan = (bPoseChannel*)ptr->data; - pchan_apply_mat4(pchan, (float (*)[4])values, FALSE); /* no compat for predictable result */ + BKE_pchan_apply_mat4(pchan, (float (*)[4])values, FALSE); /* no compat for predictable result */ } static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) @@ -614,9 +614,9 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) Object *ob = (Object*)ptr->id.data; float tmat[4][4]; - armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat); + BKE_armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat); - pchan_apply_mat4(pchan, tmat, FALSE); /* no compat for predictable result */ + BKE_pchan_apply_mat4(pchan, tmat, FALSE); /* no compat for predictable result */ } #else diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index aae5d5ae031..9a273d90f14 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1184,7 +1184,7 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value ts->selectmode = flag; if (scene->basact) { - Mesh *me = get_mesh(scene->basact->object); + Mesh *me = BKE_mesh_from_object(scene->basact->object); if (me && me->edit_btmesh && me->edit_btmesh->selectmode != flag) { me->edit_btmesh->selectmode = flag; EDBM_selectmode_set(me->edit_btmesh); @@ -1198,7 +1198,7 @@ static void rna_Scene_editmesh_select_mode_update(Main *UNUSED(bmain), Scene *sc Mesh *me = NULL; if (scene->basact) { - me = get_mesh(scene->basact->object); + me = BKE_mesh_from_object(scene->basact->object); if (me && me->edit_btmesh == NULL) me = NULL; } diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 4f16bfa1ed0..369b8ed9b0e 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -295,7 +295,7 @@ static Object *AddNewBlenderMesh(Scene *scene, Base *base) basen->flag &= ~SELECT; // Initialize the mesh data associated with this object. - ob_new->data= add_mesh("Mesh"); + ob_new->data= BKE_mesh_add("Mesh"); // Finally assign the object type. ob_new->type= OB_MESH; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index ef3a6d8217e..0b0a276c4a0 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -146,7 +146,7 @@ static float hook_falloff(const float co_1[3], const float co_2[3], const float static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { - bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); + bPoseChannel *pchan= BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); float vec[3], mat[4][4], dmat[4][4]; int i, *index_pt; const float falloff_squared= hmd->falloff * hmd->falloff; /* for faster comparisons */ diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 9faca7bddc5..aa7d0446a36 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -45,7 +45,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "BKE_action.h" /* get_pose_channel */ +#include "BKE_action.h" /* BKE_pose_channel_find_name */ #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" @@ -154,7 +154,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, bone_select_array= MEM_mallocN(defbase_tot * sizeof(char), "mask array"); for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { - pchan = get_pose_channel(oba->pose, def->name); + pchan = BKE_pose_channel_find_name(oba->pose, def->name); if (pchan && pchan->bone && (pchan->bone->flag & BONE_SELECTED)) { bone_select_array[i]= TRUE; bone_select_tot++; diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 4e143bcb008..6a173362ade 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -66,7 +66,7 @@ void modifier_init_texture(Scene *scene, Tex *tex) return; if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) - BKE_image_user_calc_frame(&tex->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, scene->r.cfra, 0); } void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) @@ -223,7 +223,7 @@ void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformV if (*defgrp_index >= 0) { if (ob->type == OB_LATTICE) - *dvert = lattice_get_deform_verts(ob); + *dvert = BKE_lattice_deform_verts_get(ob); else if (dm) *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 1789710b096..02bb16f644a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -420,7 +420,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE ImageUser *iuser= (ImageUser *)node->storage; /* first set the right frame number in iuser */ - BKE_image_user_calc_frame(iuser, rd->cfra, 0); + BKE_image_user_frame_calc(iuser, rd->cfra, 0); /* force a load, we assume iuser index will be set OK anyway */ if (ima->type==IMA_TYPE_MULTILAYER) diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index f89dcf63f64..18a535018ba 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -192,7 +192,7 @@ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack BLI_join_dirfile(path, FILE_MAX, nimf->base_path, sockdata->path); BKE_makepicstring(filename, path, bmain->name, rd->cfra, format->imtype, (rd->scemode & R_EXTENSION), TRUE); - if (0 == BKE_write_ibuf(ibuf, filename, format)) + if (0 == BKE_imbuf_write(ibuf, filename, format)) printf("Cannot save Node File Output to %s\n", filename); else printf("Saved: %s\n", filename); diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index c2263053987..a12a1042553 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -69,7 +69,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * buf1= typecheck_compbuf(in[0]->data, CB_RGBA); buf2= typecheck_compbuf(in[1]->data, CB_RGBA); - BKE_image_user_calc_frame(node->storage, rd->cfra, 0); + BKE_image_user_frame_calc(node->storage, rd->cfra, 0); /* always returns for viewer image, but we check nevertheless */ ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index f9b1e55f29f..3fdedbb2e42 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -55,7 +55,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, int rectx, recty; void *lock; - BKE_image_user_calc_frame(node->storage, rd->cfra, 0); + BKE_image_user_frame_calc(node->storage, rd->cfra, 0); /* always returns for viewer image, but we check nevertheless */ ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index da7e4335f7d..eebcf23a7a6 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -49,7 +49,7 @@ #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_image.h" // BKE_write_ibuf +#include "BKE_image.h" // BKE_imbuf_write #include "BKE_texture.h" diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index fef542b9957..63daaaed21a 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2090,7 +2090,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie else { ImBuf *ibuf= render_result_rect_to_ibuf(&rres, &scene->r); - ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); + ok= BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); if (ok==0) { printf("Render error: cannot save %s\n", name); @@ -2106,7 +2106,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie name[strlen(name)-4]= 0; BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90); ibuf->planes= 24; - BKE_write_ibuf_stamp(scene, camera, ibuf, name, &imf); + BKE_imbuf_write_stamp(scene, camera, ibuf, name, &imf); printf("\nSaved: %s", name); } @@ -2455,7 +2455,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, BLI_strncpy(filepath, relpath, sizeof(filepath)); BLI_path_abs(filepath, G.main->name); - ok= BKE_write_ibuf(ibuf, filepath, &imf); + ok= BKE_imbuf_write(ibuf, filepath, &imf); IMB_freeImBuf(ibuf); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index a49097f5b7d..a88057ef3d2 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1020,7 +1020,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) int flags = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE)? IB_cm_predivide: 0; ImBuf *ibuf= IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, flags); - /* if not exists, BKE_write_ibuf makes one */ + /* if not exists, BKE_imbuf_write makes one */ ibuf->rect= (unsigned int *)rr->rect32; ibuf->rect_float= rr->rectf; ibuf->zbuf_float= rr->rectz; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 1332bf8922c..9aec75c70d4 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -100,7 +100,7 @@ static void init_render_texture(Render *re, Tex *tex) /* imap test */ if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - BKE_image_user_calc_frame(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0); + BKE_image_user_frame_calc(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0); } if (tex->type==TEX_PLUGIN) { @@ -1214,7 +1214,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, case TEX_IMAGE: if (osatex) retval= imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres); else retval= imagewrap(tex, tex->ima, NULL, texvec, texres); - tag_image_time(tex->ima); /* tag image as having being used */ + BKE_image_tag_time(tex->ima); /* tag image as having being used */ break; case TEX_PLUGIN: retval= plugintex(tex, texvec, dxt, dyt, osatex, texres); @@ -3625,7 +3625,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) /* update image sequences and movies */ if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { if (tex->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&tex->iuser, (int)scene->r.cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, (int)scene->r.cfra, 0); } } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 04e1bee4376..0dc7f35dc56 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2567,7 +2567,7 @@ static void *do_bake_thread(void *bs_v) void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) { /* must check before filtering */ - const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_alphatest_ibuf(ibuf); + const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_imbuf_alpha_test(ibuf); /* Margin */ if (filter) { diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 55124ab227c..d1ace96194a 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -267,7 +267,7 @@ struct EditMesh; struct FCurve *verify_fcurve (struct bAction *act, const char group[], const char rna_path[], const int array_index, short add){return (struct FCurve *) NULL;} int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag){return 0;} void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc){} -struct KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]){return (struct KeyingSetInfo *) NULL;} +struct KeyingSetInfo *ANIM_keyingset_info_find_name (const char name[]){return (struct KeyingSetInfo *) NULL;} struct KeyingSet *ANIM_scene_get_active_keyingset (struct Scene *scene){return (struct KeyingSet *) NULL;} int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks){return 0;} struct ListBase builtin_keyingsets; diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 61379209151..9869dfb9424 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -370,10 +370,10 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ } - // get_pose_channel accounts for NULL pose, run on both in case one exists but + // BKE_pose_channel_find_name accounts for NULL pose, run on both in case one exists but // the channel doesnt - if ( !(pchan=get_pose_channel(m_userpose, string)) && - !(pchan=get_pose_channel(m_pose, string)) ) + if ( !(pchan=BKE_pose_channel_find_name(m_userpose, string)) && + !(pchan=BKE_pose_channel_find_name(m_pose, string)) ) { PyErr_SetString(PyExc_ValueError, "channel doesnt exist"); return NULL; @@ -457,8 +457,8 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ game_copy_pose(&m_userpose, m_pose, 0); } - // pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there. - pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there. + // pchan= BKE_pose_channel_verify(m_userpose, string); // adds the channel if its not there. + pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there. if (pchan) { copy_v3_v3(pchan->loc, matrix[3]); @@ -480,8 +480,8 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ game_copy_pose(&m_userpose, m_pose, 0); } - // pchan= verify_pose_channel(m_userpose, string); - pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there. + // pchan= BKE_pose_channel_verify(m_userpose, string); + pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there. // for some reason loc.setValue(pchan->loc) fails if (pchan) { diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index f9ddc258cfe..f38782a9405 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -61,7 +61,7 @@ /** * Move here pose function for game engine so that we can mix with GE objects * Principle is as follow: - * Use Blender structures so that where_is_pose can be used unchanged + * Use Blender structures so that BKE_pose_where_is can be used unchanged * Copy the constraint so that they can be enabled/disabled/added/removed at runtime * Don't copy the constraints for the pose used by the Action actuator, it does not need them. * Scan the constraint structures so that the KX equivalent of target objects are identified and @@ -84,7 +84,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) return; } else if (*dst==src) { - printf("copy_pose source and target are the same\n"); + printf("BKE_pose_copy_data source and target are the same\n"); *dst=NULL; return; } @@ -129,7 +129,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) BLI_ghash_free(ghash, NULL, NULL); // set acceleration structure for channel lookup - make_pose_channels_hash(out); + BKE_pose_channels_hash_make(out); *dst=out; } @@ -200,7 +200,7 @@ void game_free_pose(bPose *pose) { if (pose) { /* free pose-channels and constraints */ - free_pose_channels(pose); + BKE_pose_channels_free(pose); /* free IK solver state */ BIK_clear_data(pose); @@ -225,7 +225,7 @@ BL_ArmatureObject::BL_ArmatureObject( m_poseChannels(), m_objArma(armature), m_framePose(NULL), - m_scene(scene), // maybe remove later. needed for where_is_pose + m_scene(scene), // maybe remove later. needed for BKE_pose_where_is m_lastframe(0.0), m_timestep(0.040), m_activeAct(NULL), @@ -477,7 +477,7 @@ void BL_ArmatureObject::ApplyPose() } // update ourself UpdateBlenderObjectMatrix(m_objArma); - where_is_pose(m_scene, m_objArma); // XXX + BKE_pose_where_is(m_scene, m_objArma); // XXX // restore ourself memcpy(m_objArma->obmat, m_obmat, sizeof(m_obmat)); // restore active targets @@ -590,7 +590,7 @@ bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) bPoseChannel *pchan; ApplyPose(); - pchan = get_pose_channel(m_objArma->pose, bone->name); + pchan = BKE_pose_channel_find_name(m_objArma->pose, bone->name); if (pchan) matrix.setValue(&pchan->pose_mat[0][0]); RestorePose(); diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index a6848cf57df..ced6b94e6fd 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -132,7 +132,7 @@ protected: struct bPose *m_pose; struct bPose *m_armpose; struct bPose *m_framePose; - struct Scene *m_scene; // need for where_is_pose + struct Scene *m_scene; // need for BKE_pose_where_is double m_lastframe; double m_timestep; // delta since last pose evaluation. class BL_ActionActuator *m_activeAct; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 6659f137057..14362cd8f06 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2613,7 +2613,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, case PARBONE: { // parent this to a bone - Bone *parent_bone = get_named_bone( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr); + Bone *parent_bone = BKE_armature_find_bone_name( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr); if (parent_bone) { KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone); diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 2aa97370330..ab275fa773a 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -230,7 +230,7 @@ void BL_SkinDeformer::BGEDeformVerts() dg; ++i, dg=(bDeformGroup*)dg->next) { - m_dfnrToPC[i] = get_pose_channel(par_arma->pose, dg->name); + m_dfnrToPC[i] = BKE_pose_channel_find_name(par_arma->pose, dg->name); if (m_dfnrToPC[i] && m_dfnrToPC[i]->bone->flag & BONE_NO_DEFORM) m_dfnrToPC[i] = NULL; From 9b37bf21f46d897ad9b74eb97fb4f0a7ed59bd9d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 16:38:23 +0000 Subject: [PATCH 80/88] feature request from VenomGfx- lock to active as an operator since its tedious setting the object and bone manually (especially if you have it right in front of you) uses keys - Shift+PadPeriod --- to set - Alt+PadPeriod --- to clear (also clears cursor and camera locking) --- release/scripts/startup/bl_ui/space_view3d.py | 5 + source/blender/editors/include/ED_view3d.h | 2 + .../editors/space_view3d/view3d_edit.c | 94 +++++++++++++++++++ .../editors/space_view3d/view3d_intern.h | 2 + .../blender/editors/space_view3d/view3d_ops.c | 7 +- 5 files changed, 109 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index ca6da539884..6c2e98337a7 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -377,6 +377,11 @@ class VIEW3D_MT_view_align(Menu): layout.operator("view3d.view_selected") layout.operator("view3d.view_center_cursor") + layout.separator() + + layout.operator("view3d.view_lock_to_active") + layout.operator("view3d.view_lock_clear") + class VIEW3D_MT_view_align_selected(Menu): bl_label = "Align View to Selected" diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 4b614085f8e..e3759ef5fde 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -304,6 +304,8 @@ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the view to the camera, return TRUE if */ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); +void ED_view3D_lock_clear(struct View3D *v3d); + struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); void ED_view3D_background_image_clear(struct View3D *v3d); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b5933310a06..11afc5825a7 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -56,6 +56,8 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_action.h" +#include "BKE_armature.h" #include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ @@ -68,6 +70,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "ED_armature.h" #include "ED_particle.h" #include "ED_screen.h" #include "ED_transform.h" @@ -2291,6 +2294,89 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot) ot->flag = 0; } +static int view_lock_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + + if (v3d) { + ED_view3D_lock_clear(v3d); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_clear(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock Clear"; + ot->description = "Clears all view locking"; + ot->idname = "VIEW3D_OT_view_lock_clear"; + + /* api callbacks */ + ot->exec = view_lock_clear_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + +static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + Object *obact = CTX_data_active_object(C); + + if (v3d) { + + ED_view3D_lock_clear(v3d); + + v3d->ob_centre = obact; /* can be NULL */ + + if (obact && obact->type == OB_ARMATURE) { + if (obact->mode & OB_MODE_POSE) { + bPoseChannel *pcham_act = BKE_pose_channel_active(obact); + if (pcham_act) { + BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); + } + } + else { + EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; + if (ebone_act) { + BLI_strncpy(v3d->ob_centre_bone, ebone_act->name, sizeof(v3d->ob_centre_bone)); + } + } + } + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_to_active(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock to Active"; + ot->description = "Lock the view to the active object/bone"; + ot->idname = "VIEW3D_OT_view_lock_to_active"; + + /* api callbacks */ + ot->exec = view_lock_to_active_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); @@ -3709,3 +3795,11 @@ void ED_view3D_background_image_clear(View3D *v3d) bgpic = next_bgpic; } } + +void ED_view3D_lock_clear(View3D *v3d) +{ + v3d->ob_centre = NULL; + v3d->ob_centre_bone[0] = '\0'; + v3d->ob_centre_cursor = FALSE; + v3d->flag2 &= ~V3D_LOCK_CAMERA; +} diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 66b8ceb7a85..23de42ecc36 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -78,6 +78,8 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); void VIEW3D_OT_view_center_camera(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 99da487f923..f760254e8d2 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -72,6 +72,8 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_background_image_add); WM_operatortype_append(VIEW3D_OT_background_image_remove); WM_operatortype_append(VIEW3D_OT_view_selected); + WM_operatortype_append(VIEW3D_OT_view_lock_clear); + WM_operatortype_append(VIEW3D_OT_view_lock_to_active); WM_operatortype_append(VIEW3D_OT_view_center_cursor); WM_operatortype_append(VIEW3D_OT_view_center_camera); WM_operatortype_append(VIEW3D_OT_select); @@ -135,7 +137,10 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); - + + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); From 6292fb4cbd43c087c06886be7517a0dc07da9b43 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 17:00:11 +0000 Subject: [PATCH 81/88] code cleanup: BKE_libblock_find_name() now takes an ID constant rather then a string. --- source/blender/blenkernel/BKE_library.h | 2 +- source/blender/blenkernel/intern/library.c | 4 ++-- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/editors/mesh/mesh_data.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_relations.c | 2 +- source/blender/editors/object/object_select.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 4 ++-- source/blender/editors/space_node/node_edit.c | 2 +- source/blender/editors/space_outliner/outliner_edit.c | 10 +++++----- source/blender/editors/space_view3d/view3d_edit.c | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index e8dff6633bc..2804eb407db 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -82,7 +82,7 @@ void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only); -struct ID *BKE_libblock_find_name(const char *type, const char *name); +struct ID *BKE_libblock_find_name(const short type, const char *name); void clear_id_newpoins(void); void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8d643349b8c..20444045c1c 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -943,9 +943,9 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *BKE_libblock_find_name(const char *type, const char *name) /* type: "OB" or "MA" etc */ +ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or "MA" etc */ { - ListBase *lb= which_libbase(G.main, GS(type)); + ListBase *lb= which_libbase(G.main, type); return BLI_findstring(lb, name, offsetof(ID, name) + 2); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2673200690b..37d7cc06fe7 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -615,7 +615,7 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) /* called from creator.c */ Scene *BKE_scene_set_name(Main *bmain, const char *name) { - Scene *sce= (Scene *)BKE_libblock_find_name("SC", name); + Scene *sce = (Scene *)BKE_libblock_find_name(ID_SCE, name); if (sce) { BKE_scene_set_background(bmain, sce); printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name); diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 49e472fada4..668f34c60d3 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -560,7 +560,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) } else { RNA_string_get(op->ptr, "name", name); - ima = (Image *)BKE_libblock_find_name("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } if (!ima) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 40bca557169..ef861164c92 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1954,7 +1954,7 @@ static int add_named_exec(bContext *C, wmOperator *op) /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); - ob = (Object *)BKE_libblock_find_name("OB", name); + ob = (Object *)BKE_libblock_find_name(ID_OB, name); if (ob == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8cb7c1fdcb5..d31e0b69473 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1911,7 +1911,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ma = (Material *)BKE_libblock_find_name("MA", name); + ma = (Material *)BKE_libblock_find_name(ID_MA, name); if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 3e06db4bc6f..86823be09a4 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -884,7 +884,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ - Object *ob = (Object *)BKE_libblock_find_name("OB", tmpname); + Object *ob = (Object *)BKE_libblock_find_name(ID_OB, tmpname); if (ob) { Base *secbase = BKE_scene_base_find(scene, ob); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a49a9f02c60..09c7ecd6b48 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2945,7 +2945,7 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); - br = (Brush *)BKE_libblock_find_name("BR", "Smooth"); + br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth"); if (br) { paint_brush_set(p, br); brush = br; @@ -3508,7 +3508,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str /* Alt-Smooth */ if (ss->cache->alt_smooth) { Paint *p = &sd->paint; - brush = (Brush *)BKE_libblock_find_name("BR", ss->cache->saved_active_brush_name); + brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name); if (brush) { paint_brush_set(p, brush); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index be9b495619c..f30098d151d 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -3418,7 +3418,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) else if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)BKE_libblock_find_name("IM", name); + ima= (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 47eecbc0d77..43f186f4b31 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1402,9 +1402,9 @@ static int parent_drop_exec(bContext *C, wmOperator *op) partype= RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)BKE_libblock_find_name("OB", parname); + par= (Object *)BKE_libblock_find_name(ID_OB, parname); RNA_string_get(op->ptr, "child", childname); - ob= (Object *)BKE_libblock_find_name("OB", childname); + ob= (Object *)BKE_libblock_find_name(ID_OB, childname); ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); @@ -1473,9 +1473,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_string_set(op->ptr, "parent", te_found->name); /* Identify parent and child */ RNA_string_get(op->ptr, "child", childname); - ob= (Object *)BKE_libblock_find_name("OB", childname); + ob= (Object *)BKE_libblock_find_name(ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)BKE_libblock_find_name("OB", parname); + par= (Object *)BKE_libblock_find_name(ID_OB, parname); if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); @@ -1659,7 +1659,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); - ob= (Object *)BKE_libblock_find_name("OB", obname); + ob= (Object *)BKE_libblock_find_name(ID_OB, obname); /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 11afc5825a7..3e8ac58df8e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3184,7 +3184,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); - ima = (Image *)BKE_libblock_find_name("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } bgpic = background_image_add(C); From f3230c7897951941a562be97f42e79f68fb81761 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 5 May 2012 17:10:51 +0000 Subject: [PATCH 82/88] Second part of fix for [#31157]: Some (actually, 172) operators have no tooltip. About 30 undocumented ops remaining... --- source/blender/editors/animation/keyframing.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 2 ++ source/blender/editors/object/object_edit.c | 2 ++ source/blender/editors/object/object_group.c | 1 + .../blender/editors/object/object_shapekey.c | 2 ++ source/blender/editors/object/object_vgroup.c | 14 ++++++++++++ .../blender/editors/physics/particle_edit.c | 22 +++++++++++++++++-- .../blender/editors/sculpt_paint/paint_hide.c | 1 + .../editors/sculpt_paint/paint_image.c | 5 +++++ .../blender/editors/sculpt_paint/paint_ops.c | 1 + .../editors/sculpt_paint/paint_vertex.c | 7 ++++++ source/blender/editors/space_node/node_edit.c | 12 +++++++++- source/blender/editors/space_text/text_ops.c | 2 +- 13 files changed, 68 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 281a3e110bb..bcd0feb36cf 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1479,7 +1479,7 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) /* identifiers */ ot->name = "Insert Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_insert_button"; - ot->description = "Insert a keyframe keyframe for current UI-active property"; + ot->description = "Insert a keyframe for current UI-active property"; /* callbacks */ ot->exec = insert_key_button_exec; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0f300cc375e..9c7ef756147 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -1251,6 +1251,7 @@ void MESH_OT_edge_split(wmOperatorType *ot) /* identifiers */ ot->name = "Edge Split"; ot->idname = "MESH_OT_edge_split"; + ot->description = "Split selected edges so that each neighbor face gets its own copy"; /* api callbacks */ ot->exec = edbm_edge_split_exec; @@ -3060,6 +3061,7 @@ void MESH_OT_beautify_fill(wmOperatorType *ot) /* identifiers */ ot->name = "Beautify Fill"; ot->idname = "MESH_OT_beautify_fill"; + ot->description = "Rearrange some faces to try to get less degenerated geometry"; /* api callbacks */ ot->exec = edbm_beautify_fill_exec; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index fa8ed0fd94d..d6d7342f900 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1703,6 +1703,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Game Property"; ot->idname = "OBJECT_OT_game_property_copy"; + ot->description = "Copy/merge/replace a game property from active object to all selected objects"; /* api callbacks */ ot->exec = game_property_copy_exec; @@ -1733,6 +1734,7 @@ void OBJECT_OT_game_property_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Game Property"; ot->idname = "OBJECT_OT_game_property_clear"; + ot->description = "Remove all game properties from all selected objects"; /* api callbacks */ ot->exec = game_property_clear_exec; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index dd6c08a2247..b47591dddee 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -327,6 +327,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Group"; ot->idname = "OBJECT_OT_group_remove"; + ot->description = "Remove the active object from this group"; /* api callbacks */ ot->exec = group_remove_exec; diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index df73e435737..19864ed58cf 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -403,6 +403,7 @@ void OBJECT_OT_shape_key_mirror(wmOperatorType *ot) /* identifiers */ ot->name = "Mirror Shape Key"; ot->idname = "OBJECT_OT_shape_key_mirror"; + ot->description = "Mirror the current shape key along the local X axis"; /* api callbacks */ ot->poll = shape_key_mode_poll; @@ -474,6 +475,7 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) /* identifiers */ ot->name = "Move Shape Key"; ot->idname = "OBJECT_OT_shape_key_move"; + ot->description = "Move the active shape key up/down in the list"; /* api callbacks */ ot->poll = shape_key_mode_poll; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index acafe62150f..0c0611d3d33 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2122,6 +2122,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_add"; + ot->description = "Add a new vertex group to the active object"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2152,6 +2153,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove"; + ot->description = "Delete the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2187,6 +2189,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) /* identifiers */ ot->name = "Assign Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_assign"; + ot->description = "Assign the selected vertices to the current (or a new) vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2229,6 +2232,7 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) /* identifiers */ ot->name = "Remove from Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove_from"; + ot->description = "Remove the selected vertices from the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2262,6 +2266,7 @@ void OBJECT_OT_vertex_group_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_select"; + ot->description = "Select all the vertices assigned to the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2286,6 +2291,7 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot) /* identifiers */ ot->name = "Deselect Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_deselect"; + ot->description = "Deselect all selected vertices assigned to the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2312,6 +2318,7 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_copy"; + ot->description = "Make a copy of the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2342,6 +2349,7 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Group Levels"; ot->idname = "OBJECT_OT_vertex_group_levels"; + ot->description = "Add some offset and multiply with some gain the weights of the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2372,6 +2380,7 @@ void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot) /* identifiers */ ot->name = "Normalize Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_normalize"; + ot->description = "Normalize weights of the active vertex group, so that the highest ones are now 1.0"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2400,6 +2409,8 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) /* identifiers */ ot->name = "Normalize All Vertex Groups"; ot->idname = "OBJECT_OT_vertex_group_normalize_all"; + ot->description = "Normalize all weights of all vertex groups, " + "so that for each vertex, the sum of all weights is 1.0"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2480,6 +2491,7 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot) /* identifiers */ ot->name = "Change the Lock On Vertex Groups"; ot->idname = "OBJECT_OT_vertex_group_lock"; + ot->description = "Change the lock state of all vertex groups of active object"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2510,6 +2522,7 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) /* identifiers */ ot->name = "Invert Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_invert"; + ot->description = "Invert active vertex group's weights"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2996,6 +3009,7 @@ void OBJECT_OT_vertex_group_move(wmOperatorType *ot) /* identifiers */ ot->name = "Move Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_move"; + ot->description = "Move the active vertex group up/down in the list"; /* api callbacks */ ot->poll = vertex_group_poll; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 28f789b5f9e..64f4ffe4881 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1367,6 +1367,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /* identifiers */ ot->name = "(De)select All"; ot->idname = "PARTICLE_OT_select_all"; + ot->description = "(De)select all particles' keys"; /* api callbacks */ ot->exec = pe_select_all_exec; @@ -1441,6 +1442,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot) /* identifiers */ ot->name = "Select Roots"; ot->idname = "PARTICLE_OT_select_roots"; + ot->description = "Select roots of all visible particles"; /* api callbacks */ ot->exec = select_roots_exec; @@ -1481,7 +1483,8 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) /* identifiers */ ot->name = "Select Tips"; ot->idname = "PARTICLE_OT_select_tips"; - + ot->description = "Select tips of all visible particles"; + /* api callbacks */ ot->exec = select_tips_exec; ot->poll = PE_poll; @@ -1525,6 +1528,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked"; ot->idname = "PARTICLE_OT_select_linked"; + ot->description = "Select nearest particle from mouse pointer"; /* api callbacks */ ot->exec = select_linked_exec; @@ -1717,6 +1721,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot) /* identifiers */ ot->name = "Hide Selected"; ot->idname = "PARTICLE_OT_hide"; + ot->description = "Hide selected particles"; /* api callbacks */ ot->exec = hide_exec; @@ -1759,6 +1764,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name = "Reveal"; ot->idname = "PARTICLE_OT_reveal"; + ot->description = "Show hidden particles"; /* api callbacks */ ot->exec = reveal_exec; @@ -1817,6 +1823,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot) /* identifiers */ ot->name = "Select Less"; ot->idname = "PARTICLE_OT_select_less"; + ot->description = "Deselect boundary selected keys of each particle"; /* api callbacks */ ot->exec = select_less_exec; @@ -1878,6 +1885,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name = "Select More"; ot->idname = "PARTICLE_OT_select_more"; + ot->description = "Select keys linked to boundary selected keys of each particle"; /* api callbacks */ ot->exec = select_more_exec; @@ -1974,6 +1982,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot) /* identifiers */ ot->name = "Rekey"; ot->idname = "PARTICLE_OT_rekey"; + ot->description = "Change the number of keys of selected particles (root and tip keys included)"; /* api callbacks */ ot->exec = rekey_exec; @@ -2304,6 +2313,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot) /* identifiers */ ot->name = "Subdivide"; ot->idname = "PARTICLE_OT_subdivide"; + ot->description = "Subdivide selected particles segments (adds keys)"; /* api callbacks */ ot->exec = subdivide_exec; @@ -2392,6 +2402,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Doubles"; ot->idname = "PARTICLE_OT_remove_doubles"; + ot->description = "Remove selected particles close enough of others"; /* api callbacks */ ot->exec = remove_doubles_exec; @@ -2442,6 +2453,7 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Set"; ot->idname = "PARTICLE_OT_weight_set"; + ot->description = "Set the weight of selected keys"; /* api callbacks */ ot->exec = weight_set_exec; @@ -2450,7 +2462,8 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", "", 0, 1); + RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", + "Interpolation factor between current brush weight, and keys' weights", 0, 1); } /************************ cursor drawing *******************************/ @@ -2545,6 +2558,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name = "Delete"; ot->idname = "PARTICLE_OT_delete"; + ot->description = "Delete selected particles or keys"; /* api callbacks */ ot->exec = delete_exec; @@ -2710,6 +2724,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) /* identifiers */ ot->name = "Mirror"; ot->idname = "PARTICLE_OT_mirror"; + ot->description = "Duplicate and mirror the selected particles along the local X axis"; /* api callbacks */ ot->exec = mirror_exec; @@ -3739,6 +3754,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) /* identifiers */ ot->name = "Brush Edit"; ot->idname = "PARTICLE_OT_brush_edit"; + ot->description = "Apply a stroke of brush to the particles"; /* api callbacks */ ot->exec = brush_edit_exec; @@ -4229,6 +4245,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Particle Edit Toggle"; ot->idname = "PARTICLE_OT_particle_edit_toggle"; + ot->description = "Toggle particle edit mode"; /* api callbacks */ ot->exec = particle_edit_toggle_exec; @@ -4278,6 +4295,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Edited"; ot->idname = "PARTICLE_OT_edited_clear"; + ot->description = "Undo all edition performed on the particle system"; /* api callbacks */ ot->exec = clear_edited_exec; diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index 47536d99fcb..c96da7d52c6 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -364,6 +364,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) /* identifiers */ ot->name = "Hide/Show"; ot->idname = "PAINT_OT_hide_show"; + ot->description = "Hide/show some vertices"; /* api callbacks */ ot->invoke = hide_show_invoke; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 397bfadbd68..c46c153aa70 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5160,6 +5160,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Image Paint"; ot->idname = "PAINT_OT_image_paint"; + ot->description = "Paint a stroke into the image"; /* api callbacks */ ot->exec = paint_exec; @@ -5387,6 +5388,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot) /* identifiers */ ot->name = "Grab Clone"; ot->idname = "PAINT_OT_grab_clone"; + ot->description = "Move the clone source image"; /* api callbacks */ ot->exec = grab_clone_exec; @@ -5469,6 +5471,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /* identifiers */ ot->name = "Sample Color"; ot->idname = "PAINT_OT_sample_color"; + ot->description = "Use the mouse to sample a color in the image"; /* api callbacks */ ot->exec = sample_color_exec; @@ -5520,6 +5523,7 @@ void PAINT_OT_clone_cursor_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Clone Cursor"; ot->idname = "PAINT_OT_clone_cursor_set"; + ot->description = "Set the location of the clone cursor"; /* api callbacks */ ot->exec = set_clone_cursor_exec; @@ -5602,6 +5606,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Texture Paint Toggle"; ot->idname = "PAINT_OT_texture_paint_toggle"; + ot->description = "Toggle texture paint mode in 3D view"; /* api callbacks */ ot->exec = texture_paint_toggle_exec; diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 2699e9f56f8..c42f0e03d79 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -160,6 +160,7 @@ static void PAINT_OT_vertex_color_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Vertex Colors"; ot->idname = "PAINT_OT_vertex_color_set"; + ot->description = "Fill the active vertex color layer with the current paint color"; /* api callbacks */ ot->exec = vertex_color_set_exec; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index bfd8f869e66..9a572a24847 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1075,6 +1075,7 @@ void PAINT_OT_weight_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Sample Weight"; ot->idname = "PAINT_OT_weight_sample"; + ot->description = "Use the mouse to sample a weight in the 3D view"; /* api callbacks */ ot->invoke = weight_sample_invoke; @@ -1176,6 +1177,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Sample Group"; ot->idname = "PAINT_OT_weight_sample_group"; + ot->description = "Select one of the vertex groups available under current mouse position"; /* api callbacks */ ot->exec = weight_sample_group_exec; @@ -2038,6 +2040,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Mode"; ot->idname = "PAINT_OT_weight_paint_toggle"; + ot->description = "Toggle weight paint mode in 3D view"; /* api callbacks */ ot->exec = set_wpaint; @@ -2490,6 +2493,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint"; ot->idname = "PAINT_OT_weight_paint"; + ot->description = "Paint a stroke in the current vertex group's weights"; /* api callbacks */ ot->invoke = wpaint_invoke; @@ -2522,6 +2526,7 @@ void PAINT_OT_weight_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Weight"; ot->idname = "PAINT_OT_weight_set"; + ot->description = "Fill the active vertex group with the current paint weight"; /* api callbacks */ ot->exec = weight_paint_set_exec; @@ -2586,6 +2591,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Paint Mode"; ot->idname = "PAINT_OT_vertex_paint_toggle"; + ot->description = "Toggle the vertex paint mode in 3D view"; /* api callbacks */ ot->exec = set_vpaint; @@ -2991,6 +2997,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Paint"; ot->idname = "PAINT_OT_vertex_paint"; + ot->description = "Paint a stroke in the active vertex color layer"; /* api callbacks */ ot->invoke = vpaint_invoke; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index f30098d151d..fd4e9bc4ef0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1316,6 +1316,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Zoom"; ot->idname = "NODE_OT_backimage_zoom"; + ot->description = "Zoom in/out the brackground image"; /* api callbacks */ ot->exec = backimage_zoom; @@ -1482,6 +1483,7 @@ void NODE_OT_backimage_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Backimage Sample"; ot->idname = "NODE_OT_backimage_sample"; + ot->description = "Use mouse to sample background image"; /* api callbacks */ ot->invoke = sample_invoke; @@ -1593,6 +1595,7 @@ void NODE_OT_resize(wmOperatorType *ot) /* identifiers */ ot->name = "Resize Node"; ot->idname = "NODE_OT_resize"; + ot->description = "Resize a node"; /* api callbacks */ ot->invoke = node_resize_invoke; @@ -2547,6 +2550,7 @@ void NODE_OT_link(wmOperatorType *ot) /* identifiers */ ot->name = "Link Nodes"; ot->idname = "NODE_OT_link"; + ot->description = "Use the mouse to create a link between two nodes"; /* api callbacks */ ot->invoke = node_link_invoke; @@ -2666,6 +2670,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) ot->name = "Cut links"; ot->idname = "NODE_OT_links_cut"; + ot->description = "Use the mouse to cut (remove) some links"; ot->invoke = WM_gesture_lines_invoke; ot->modal = WM_gesture_lines_modal; @@ -2711,6 +2716,7 @@ void NODE_OT_links_detach(wmOperatorType *ot) { ot->name = "Detach Links"; ot->idname = "NODE_OT_links_detach"; + ot->description = "Remove all links to selected nodes, and try to connect neighbor nodes together"; ot->exec = detach_links_exec; ot->poll = ED_operator_node_active; @@ -2905,6 +2911,7 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) ot->name = "Read Render Layers"; ot->idname = "NODE_OT_read_renderlayers"; + ot->description = "Read all render layers of all used scenes"; ot->exec = node_read_renderlayers_exec; @@ -2938,6 +2945,7 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) ot->name = "Read Full Sample Layers"; ot->idname = "NODE_OT_read_fullsamplelayers"; + ot->description = "Read all render layers of current scene, in full sample"; ot->exec = node_read_fullsamplelayers_exec; @@ -2986,6 +2994,7 @@ void NODE_OT_render_changed(wmOperatorType *ot) ot->name = "Render Changed Layer"; ot->idname = "NODE_OT_render_changed"; + ot->description = "Render current scene, when input node's layer has been changed"; ot->exec = node_render_changed_exec; @@ -3544,8 +3553,9 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) void NODE_OT_new_node_tree(wmOperatorType *ot) { /* identifiers */ - ot->name = "New node tree"; + ot->name = "New Node Tree"; ot->idname = "NODE_OT_new_node_tree"; + ot->description = "Create a new node tree"; /* api callbacks */ ot->exec = new_node_tree_exec; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index d38a4caeab7..3116d94df87 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1361,7 +1361,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot) /* identifiers */ ot->name = "Move Lines"; ot->idname = "TEXT_OT_move_lines"; - ot->description = "Moves the currently selected line(s) up/down"; + ot->description = "Move the currently selected line(s) up/down"; /* api callbacks */ ot->exec = move_lines_exec; From 1c90c495c0f8a328ae2fca10141feb2ace515de7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 5 May 2012 17:25:58 +0000 Subject: [PATCH 83/88] - Fixed issue with printing file version triple times when loading file in debug mode - Remove commented out headers from versioning module --- source/blender/blenloader/intern/versioning_250.c | 3 --- source/blender/blenloader/intern/versioning_legacy.c | 10 ---------- 2 files changed, 13 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 8b4471086a8..8b9ff496507 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -690,9 +690,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (G.debug & G_DEBUG) - printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); - if (main->versionfile < 250) { bScreen *screen; Scene *scene; diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 43d32b40e1a..64d7fdfe112 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -33,13 +33,6 @@ #include "zlib.h" #include -//#include // for printf fopen fwrite fclose sprintf FILE -//#include // for getenv atoi -//#include // for offsetof -//#include // for open -//#include // for strrchr strncmp strstr -//#include // for fabs -//#include /* for va_start/end */ #ifndef WIN32 # include // for read close @@ -554,9 +547,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (G.debug & G_DEBUG) - printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); - if (main->versionfile == 100) { /* tex->extend and tex->imageflag have changed: */ Tex *tex = main->tex.first; From e9ac31bee498bf6395c16bd4284c3d3cbba311ca Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 5 May 2012 17:33:18 +0000 Subject: [PATCH 84/88] Fix [#31322] Assign to Active Group adds new group --- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 6c2e98337a7..8070b60126a 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1157,7 +1157,7 @@ class VIEW3D_MT_vertex_group(Menu): if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex): if ob.vertex_groups.active: layout.separator() - layout.operator("object.vertex_group_assign", text="Assign to Active Group") + layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True layout.separator() From fef40eda72ab1a37d9b779757fb326825b5c6c10 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 5 May 2012 19:26:53 +0000 Subject: [PATCH 85/88] Fix related to [#31157]: Tips (descriptions) of macro operators were not set into underlying RNA struct, hence did not show up in UI. --- .../blender/editors/armature/armature_ops.c | 15 ++++++---- source/blender/editors/curve/curve_ops.c | 8 +++--- source/blender/editors/mesh/mesh_ops.c | 28 +++++++++---------- source/blender/editors/object/object_ops.c | 12 ++++---- .../blender/editors/space_action/action_ops.c | 6 ++-- source/blender/editors/space_clip/clip_ops.c | 9 +++--- .../blender/editors/space_graph/graph_ops.c | 5 ++-- source/blender/editors/space_node/node_ops.c | 21 +++++++------- source/blender/windowmanager/WM_api.h | 2 +- .../windowmanager/intern/wm_operators.c | 3 +- 10 files changed, 59 insertions(+), 50 deletions(-) diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index aeecbc1fd28..9a15a100179 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -171,17 +171,19 @@ void ED_operatormacros_armature(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", + "Make copies of the selected bones within the same armature and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); if (ot) { - ot->description = "Make copies of the selected bones within the same armature and move them"; WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); } - ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", + "Create new bones from the selected joints and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); if (ot) { - ot->description = "Create new bones from the selected joints and move them"; otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", FALSE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -190,9 +192,10 @@ void ED_operatormacros_armature(void) // XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? // that would require fixing a properties bug 19733 - ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", + "Create new bones from the selected joints and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); if (ot) { - ot->description = "Create new bones from the selected joints and move them"; otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", TRUE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 94ec7c7ce93..dea7ccb161d 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -140,15 +140,15 @@ void ED_operatormacros_curve(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate curve and move"; + ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", "Duplicate curve and move", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Extrude curve and move result"; + ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", + "Extrude curve and move result", OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_extrude"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 1b87e7813db..e57285cca25 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -197,49 +197,49 @@ void ED_operatormacros_mesh(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Cut mesh loop and slide it"; + ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide"); RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); - ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Duplicate mesh and move"; + ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", "Duplicate mesh and move", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Rip polygons and move the result"; + ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_rip"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude region and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", + "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude faces and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", + "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude edges and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", + "Extrude edges and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude vertices and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", + "Extrude vertices and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 4cd18d91249..feb7c075264 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -222,18 +222,18 @@ void ED_operatormacros_object(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", + "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Duplicate selected objects and move them"; WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); } /* grr, should be able to pass options on... */ - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", + "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Duplicate selected objects and move them"; otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); RNA_boolean_set(otmacro->ptr, "linked", TRUE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -241,9 +241,9 @@ void ED_operatormacros_object(void) } /* XXX */ - ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add Named At Cursor", + "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Add named object at cursor"; RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME - 2, "Name", "Object name to add"); WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d"); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index f502a97967f..da3e88ba188 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -45,6 +45,7 @@ #include "action_intern.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_api.h" #include "WM_types.h" @@ -93,9 +94,10 @@ void ED_operatormacros_action(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", + "Make a copy of all selected keyframes and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); if (ot) { - ot->description = "Make a copy of all selected keyframes and move them"; WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index b05d204b07b..485830dbe6c 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1093,14 +1093,15 @@ void ED_operatormacros_clip(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("CLIP_OT_add_marker_move", "Add Marker and Move", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Add new marker and move it on movie"; + ot = WM_operatortype_append_macro("CLIP_OT_add_marker_move", "Add Marker and Move", + "Add new marker and move it on movie", OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CLIP_OT_add_marker"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); - ot = WM_operatortype_append_macro("CLIP_OT_add_marker_slide", "Add Marker and Slide", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Add new marker and slide it with mouse until mouse button release"; + ot = WM_operatortype_append_macro("CLIP_OT_add_marker_slide", "Add Marker and Slide", + "Add new marker and slide it with mouse until mouse button release", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CLIP_OT_add_marker"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(otmacro->ptr, "release_confirm", TRUE); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 2887fa1c881..49c56ec75e4 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -241,9 +241,10 @@ void ED_operatormacros_graph(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", + "Make a copy of all selected keyframes and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); if (ot) { - ot->description = "Make a copy of all selected keyframes and move them"; WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 1c681220016..7d9d7d736f6 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -111,30 +111,31 @@ void ED_operatormacros_node(void) wmOperatorType *ot; wmOperatorTypeMacro *mot; - ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate selected nodes and move them"; + ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", "Duplicate selected nodes and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); /* modified operator call for duplicating with input links */ - ot = WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate selected nodes keeping input links and move them"; + ot = WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", + "Duplicate selected nodes keeping input links and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); RNA_boolean_set(mot->ptr, "keep_inputs", TRUE); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO); - ot->description = "Select node and link it to a viewer node"; + ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", + "Select node and link it to a viewer node", OPTYPE_UNDO); WM_operatortype_macro_define(ot, "NODE_OT_select"); WM_operatortype_macro_define(ot, "NODE_OT_link_viewer"); - ot = WM_operatortype_append_macro("NODE_OT_move_detach_links", "Detach", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Move a node to detach links"; + ot = WM_operatortype_append_macro("NODE_OT_move_detach_links", "Detach", "Move a node to detach links", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_links_detach"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - ot = WM_operatortype_append_macro("NODE_OT_move_detach_links_release", "Detach", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Move a node to detach links"; + ot = WM_operatortype_append_macro("NODE_OT_move_detach_links_release", "Detach", "Move a node to detach links", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_links_detach"); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(mot->ptr, "release_confirm", TRUE); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 4c81a0a8654..f3872cb9594 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -188,7 +188,7 @@ void WM_operatortype_append_ptr (void (*opfunc)(struct wmOperatorType*, void *) void WM_operatortype_append_macro_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); int WM_operatortype_remove(const char *idname); -struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, int flag); +struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag); struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index e9915361833..36bacd34dfe 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -346,7 +346,7 @@ static int wm_macro_cancel(bContext *C, wmOperator *op) } /* Names have to be static for now */ -wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, int flag) +wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag) { wmOperatorType *ot; @@ -360,6 +360,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam ot->idname = idname; ot->name = name; + ot->description = description; ot->flag = OPTYPE_MACRO | flag; ot->exec = wm_macro_exec; From c53fe94bb4973362278b488ef26384a029d3cc69 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 May 2012 19:44:28 +0000 Subject: [PATCH 86/88] Fix #31318: cycles preview missing update for other materials using same node group with certain operations. --- source/blender/editors/space_node/node_edit.c | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index fd4e9bc4ef0..9e59b3372cb 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -243,8 +243,37 @@ static bNode *editnode_get_active(bNodeTree *ntree) return nodeGetActive(ntree); } -void snode_dag_update(bContext *UNUSED(C), SpaceNode *snode) +static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) { + bNode *node; + + if (ntree == lookup) + return 1; + + for (node=ntree->nodes.first; node; node=node->next) + if (node->type == NODE_GROUP && node->id) + if (has_nodetree((bNodeTree*)node->id, lookup)) + return 1; + + return 0; +} + +static void snode_dag_update_group(void *calldata, ID *owner_id, bNodeTree *ntree) +{ + if (has_nodetree(ntree, calldata)) + DAG_id_tag_update(owner_id, 0); +} + +void snode_dag_update(bContext *C, SpaceNode *snode) +{ + Main *bmain = CTX_data_main(C); + + /* for groups, update all ID's using this */ + if (snode->edittree!=snode->nodetree) { + bNodeTreeType *tti= ntreeGetType(snode->edittree->type); + tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group); + } + DAG_id_tag_update(snode->id, 0); } @@ -585,21 +614,6 @@ static void snode_update(SpaceNode *snode, bNode *node) nodeUpdateID(snode->nodetree, gnode->id); } -static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) -{ - bNode *node; - - if (ntree == lookup) - return 1; - - for (node=ntree->nodes.first; node; node=node->next) - if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) - return 1; - - return 0; -} - void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) { int was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE); From 8103381ded923a097eae5a0ba012ae41847a83ad Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 May 2012 19:44:33 +0000 Subject: [PATCH 87/88] Cycles: threading optimizations * Multithreaded image loading, each thread can load a separate image. * Better multithreading for multiple instanced meshes, different threads can now build BVH's for different meshes, rather than all cooperating on the same mesh. Especially noticeable for dynamic BVH building for the viewport, gave about 2x faster build on 8 core in fairly complex scene with many objects. * The main thread waiting for worker threads can now also work itself, so (num_cores + 1) threads will be working, this supposedly gives better performance on some operating systems, but did not measure performance for this very detailed yet. --- intern/cycles/bvh/bvh_build.cpp | 30 +++++----- intern/cycles/bvh/bvh_build.h | 5 +- intern/cycles/device/device_cpu.cpp | 18 ++++-- intern/cycles/render/image.cpp | 54 ++++++++++-------- intern/cycles/render/image.h | 2 +- intern/cycles/render/mesh.cpp | 85 +++++++++++++++-------------- intern/cycles/render/mesh.h | 2 +- intern/cycles/util/util_task.cpp | 81 ++++++++++++++++++++++----- intern/cycles/util/util_task.h | 14 +++-- 9 files changed, 182 insertions(+), 109 deletions(-) diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index d865426304a..28237aea611 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -36,12 +36,12 @@ CCL_NAMESPACE_BEGIN class BVHBuildTask : public Task { public: - BVHBuildTask(InnerNode *node_, int child_, BVHObjectBinning& range_, int level_) - : node(node_), child(child_), level(level_), range(range_) {} + BVHBuildTask(BVHBuild *build, InnerNode *node, int child, BVHObjectBinning& range_, int level) + : range(range_) + { + run = function_bind(&BVHBuild::thread_build_node, build, node, child, &range, level); + } - InnerNode *node; - int child; - int level; BVHObjectBinning range; }; @@ -55,8 +55,7 @@ BVHBuild::BVHBuild(const vector& objects_, prim_object(prim_object_), params(params_), progress(progress_), - progress_start_time(0.0), - task_pool(function_bind(&BVHBuild::thread_build_node, this, _1, _2)) + progress_start_time(0.0) { spatial_min_overlap = 0.0f; } @@ -177,7 +176,7 @@ BVHNode* BVHBuild::run() /* multithreaded binning build */ BVHObjectBinning rootbin(root, (references.size())? &references[0]: NULL); rootnode = build_node(rootbin, 0); - task_pool.wait(); + task_pool.wait_work(); } /* delete if we cancelled */ @@ -210,25 +209,24 @@ void BVHBuild::progress_update() progress_start_time = time_dt(); } -void BVHBuild::thread_build_node(Task *task_, int thread_id) +void BVHBuild::thread_build_node(InnerNode *inner, int child, BVHObjectBinning *range, int level) { if(progress.get_cancel()) return; /* build nodes */ - BVHBuildTask *task = (BVHBuildTask*)task_; - BVHNode *node = build_node(task->range, task->level); + BVHNode *node = build_node(*range, level); /* set child in inner node */ - task->node->children[task->child] = node; + inner->children[child] = node; /* update progress */ - if(task->range.size() < THREAD_TASK_SIZE) { + if(range->size() < THREAD_TASK_SIZE) { /*rotate(node, INT_MAX, 5);*/ thread_scoped_lock lock(build_mutex); - progress_count += task->range.size(); + progress_count += range->size(); progress_update(); } } @@ -262,8 +260,8 @@ BVHNode* BVHBuild::build_node(const BVHObjectBinning& range, int level) /* threaded build */ inner = new InnerNode(range.bounds()); - task_pool.push(new BVHBuildTask(inner, 0, left, level + 1), true); - task_pool.push(new BVHBuildTask(inner, 1, right, level + 1), true); + task_pool.push(new BVHBuildTask(this, inner, 0, left, level + 1), true); + task_pool.push(new BVHBuildTask(this, inner, 1, right, level + 1), true); } return inner; diff --git a/intern/cycles/bvh/bvh_build.h b/intern/cycles/bvh/bvh_build.h index 84e14632b4b..44ef918b326 100644 --- a/intern/cycles/bvh/bvh_build.h +++ b/intern/cycles/bvh/bvh_build.h @@ -29,7 +29,9 @@ CCL_NAMESPACE_BEGIN +class BVHBuildTask; class BVHParams; +class InnerNode; class Mesh; class Object; class Progress; @@ -54,6 +56,7 @@ protected: friend class BVHMixedSplit; friend class BVHObjectSplit; friend class BVHSpatialSplit; + friend class BVHBuildTask; /* adding references */ void add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh, int i); @@ -68,7 +71,7 @@ protected: /* threads */ enum { THREAD_TASK_SIZE = 4096 }; - void thread_build_node(Task *task_, int thread_id); + void thread_build_node(InnerNode *node, int child, BVHObjectBinning *range, int level); thread_mutex build_mutex; /* progress */ diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index ec84047c44f..07988d32aff 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -44,7 +44,6 @@ public: KernelGlobals *kg; CPUDevice(int threads_num) - : task_pool(function_bind(&CPUDevice::thread_run, this, _1, _2)) { kg = kernel_globals_create(); @@ -113,10 +112,8 @@ public: #endif } - void thread_run(Task *task_, int thread_id) + void thread_run(DeviceTask *task) { - DeviceTask *task = (DeviceTask*)task_; - if(task->type == DeviceTask::PATH_TRACE) thread_path_trace(*task); else if(task->type == DeviceTask::TONEMAP) @@ -125,6 +122,15 @@ public: thread_shader(*task); } + class CPUDeviceTask : public DeviceTask { + public: + CPUDeviceTask(CPUDevice *device, DeviceTask& task) + : DeviceTask(task) + { + run = function_bind(&CPUDevice::thread_run, device, this); + } + }; + void thread_path_trace(DeviceTask& task) { if(task_pool.cancelled()) @@ -226,12 +232,12 @@ public: task.split(tasks, TaskScheduler::num_threads()*10); foreach(DeviceTask& task, tasks) - task_pool.push(new DeviceTask(task)); + task_pool.push(new CPUDeviceTask(this, task)); } void task_wait() { - task_pool.wait(); + task_pool.wait_work(); } void task_cancel() diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 78b8f06c7b4..3e6052338c0 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -324,8 +324,10 @@ bool ImageManager::file_load_float_image(Image *img, device_vector& tex_ return true; } -void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot) +void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progress) { + if(progress->get_cancel()) + return; if(osl_texture_system) return; @@ -342,6 +344,9 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl } if(is_float) { + string filename = path_filename(float_images[slot]->filename); + progress->set_status("Updating Images", "Loading " + filename); + device_vector& tex_img = dscene->tex_float_image[slot - TEX_IMAGE_FLOAT_START]; if(tex_img.device_pointer) @@ -365,6 +370,9 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl device->tex_alloc(name.c_str(), tex_img, true, true); } else { + string filename = path_filename(images[slot]->filename); + progress->set_status("Updating Images", "Loading " + filename); + device_vector& tex_img = dscene->tex_image[slot]; if(tex_img.device_pointer) @@ -387,6 +395,8 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl device->tex_alloc(name.c_str(), tex_img, true, true); } + + img->need_load = false; } void ImageManager::device_free_image(Device *device, DeviceScene *dscene, int slot) @@ -431,39 +441,37 @@ void ImageManager::device_update(Device *device, DeviceScene *dscene, Progress& { if(!need_update) return; + + TaskPool pool; for(size_t slot = 0; slot < images.size(); slot++) { - if(images[slot]) { - if(images[slot]->users == 0) { - device_free_image(device, dscene, slot); - } - else if(images[slot]->need_load) { - string name = path_filename(images[slot]->filename); - progress.set_status("Updating Images", "Loading " + name); - device_load_image(device, dscene, slot); - images[slot]->need_load = false; - } + if(!images[slot]) + continue; - if(progress.get_cancel()) return; + if(images[slot]->users == 0) { + device_free_image(device, dscene, slot); + } + else if(images[slot]->need_load) { + if(!osl_texture_system) + pool.push(function_bind(&ImageManager::device_load_image, this, device, dscene, slot, &progress)); } } for(size_t slot = 0; slot < float_images.size(); slot++) { - if(float_images[slot]) { - if(float_images[slot]->users == 0) { - device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START); - } - else if(float_images[slot]->need_load) { - string name = path_filename(float_images[slot]->filename); - progress.set_status("Updating Images", "Loading " + name); - device_load_image(device, dscene, slot + TEX_IMAGE_FLOAT_START); - float_images[slot]->need_load = false; - } + if(!float_images[slot]) + continue; - if(progress.get_cancel()) return; + if(float_images[slot]->users == 0) { + device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START); + } + else if(float_images[slot]->need_load) { + if(!osl_texture_system) + pool.push(function_bind(&ImageManager::device_load_image, this, device, dscene, slot + TEX_IMAGE_FLOAT_START, &progress)); } } + pool.wait_work(); + need_update = false; } diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index d789e6885e3..cc01b4a8e4c 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -65,7 +65,7 @@ private: bool file_load_image(Image *img, device_vector& tex_img); bool file_load_float_image(Image *img, device_vector& tex_img); - void device_load_image(Device *device, DeviceScene *dscene, int slot); + void device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progess); void device_free_image(Device *device, DeviceScene *dscene, int slot); }; diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 5d96611ff26..0422f97a706 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -242,31 +242,47 @@ void Mesh::pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset) } } -void Mesh::compute_bvh(SceneParams *params, Progress& progress) +void Mesh::compute_bvh(SceneParams *params, Progress *progress, int n, int total) { - Object object; - object.mesh = this; + if(progress->get_cancel()) + return; - vector objects; - objects.push_back(&object); + compute_bounds(); - if(bvh && !need_update_rebuild) { - progress.set_substatus("Refitting BVH"); - bvh->objects = objects; - bvh->refit(progress); + if(!transform_applied) { + string msg = "Updating Mesh BVH "; + if(name == "") + msg += string_printf("%u/%u", (uint)(n+1), (uint)total); + else + msg += string_printf("%s %u/%u", name.c_str(), (uint)(n+1), (uint)total); + + Object object; + object.mesh = this; + + vector objects; + objects.push_back(&object); + + if(bvh && !need_update_rebuild) { + progress->set_status(msg, "Refitting BVH"); + bvh->objects = objects; + bvh->refit(*progress); + } + else { + progress->set_status(msg, "Building BVH"); + + BVHParams bparams; + bparams.use_cache = params->use_bvh_cache; + bparams.use_spatial_split = params->use_bvh_spatial_split; + bparams.use_qbvh = params->use_qbvh; + + delete bvh; + bvh = BVH::create(bparams, objects); + bvh->build(*progress); + } } - else { - progress.set_substatus("Building BVH"); - BVHParams bparams; - bparams.use_cache = params->use_bvh_cache; - bparams.use_spatial_split = params->use_bvh_spatial_split; - bparams.use_qbvh = params->use_qbvh; - - delete bvh; - bvh = BVH::create(bparams, objects); - bvh->build(progress); - } + need_update = false; + need_update_rebuild = false; } void Mesh::tag_update(Scene *scene, bool rebuild) @@ -686,35 +702,22 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen } /* update bvh */ - size_t i = 0, num_instance_bvh = 0; + size_t i = 0, num_bvh = 0; foreach(Mesh *mesh, scene->meshes) if(mesh->need_update && !mesh->transform_applied) - num_instance_bvh++; + num_bvh++; + + TaskPool pool; foreach(Mesh *mesh, scene->meshes) { if(mesh->need_update) { - mesh->compute_bounds(); - - if(!mesh->transform_applied) { - string msg = "Updating Mesh BVH "; - if(mesh->name == "") - msg += string_printf("%u/%u", (uint)(i+1), (uint)num_instance_bvh); - else - msg += string_printf("%s %u/%u", mesh->name.c_str(), (uint)(i+1), (uint)num_instance_bvh); - progress.set_status(msg, "Building BVH"); - - mesh->compute_bvh(&scene->params, progress); - - i++; - } - - if(progress.get_cancel()) return; - - mesh->need_update = false; - mesh->need_update_rebuild = false; + pool.push(function_bind(&Mesh::compute_bvh, mesh, &scene->params, &progress, i, num_bvh)); + i++; } } + + pool.wait_work(); foreach(Shader *shader, scene->shaders) shader->need_update_attributes = false; diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index 047a2d2624d..637143f5adf 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -96,7 +96,7 @@ public: void pack_normals(Scene *scene, float4 *normal, float4 *vnormal); void pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset); - void compute_bvh(SceneParams *params, Progress& progress); + void compute_bvh(SceneParams *params, Progress *progress, int n, int total); bool need_attribute(Scene *scene, AttributeStandard std); bool need_attribute(Scene *scene, ustring name); diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp index 6da9a70ec0c..fc806275ea4 100644 --- a/intern/cycles/util/util_task.cpp +++ b/intern/cycles/util/util_task.cpp @@ -25,14 +25,12 @@ CCL_NAMESPACE_BEGIN /* Task Pool */ -TaskPool::TaskPool(const TaskRunFunction& run_) +TaskPool::TaskPool() { num = 0; num_done = 0; do_cancel = false; - - run = run_; } TaskPool::~TaskPool() @@ -50,12 +48,55 @@ void TaskPool::push(Task *task, bool front) TaskScheduler::push(entry, front); } -void TaskPool::wait() +void TaskPool::push(const TaskRunFunction& run, bool front) { - thread_scoped_lock lock(done_mutex); + push(new Task(run), front); +} - while(num_done != num) - done_cond.wait(lock); +void TaskPool::wait_work() +{ + thread_scoped_lock done_lock(done_mutex); + + while(num_done != num) { + thread_scoped_lock queue_lock(TaskScheduler::queue_mutex); + + /* find task from this pool. if we get a task from another pool, + * we can get into deadlock */ + TaskScheduler::Entry work_entry; + bool found_entry = false; + list::iterator it; + + for(it = TaskScheduler::queue.begin(); it != TaskScheduler::queue.end(); it++) { + TaskScheduler::Entry& entry = *it; + + if(entry.pool == this) { + work_entry = entry; + found_entry = true; + TaskScheduler::queue.erase(it); + break; + } + } + + queue_lock.unlock(); + + /* if found task, do it, otherwise wait until other tasks are done */ + if(found_entry) { + done_lock.unlock(); + + /* run task */ + work_entry.task->run(); + + /* delete task */ + delete work_entry.task; + + /* notify pool task was done */ + done_increase(1); + + done_lock.lock(); + } + else + done_cond.wait(done_lock); + } } void TaskPool::cancel() @@ -63,7 +104,12 @@ void TaskPool::cancel() TaskScheduler::clear(this); do_cancel = true; - wait(); + { + thread_scoped_lock lock(done_mutex); + + while(num_done != num) + done_cond.wait(lock); + } do_cancel = false; } @@ -94,6 +140,7 @@ void TaskPool::done_increase(int done) thread_mutex TaskScheduler::mutex; int TaskScheduler::users = 0; vector TaskScheduler::threads; +vector TaskScheduler::thread_level; volatile bool TaskScheduler::do_exit = false; list TaskScheduler::queue; @@ -114,9 +161,12 @@ void TaskScheduler::init(int num_threads) num_threads = system_cpu_thread_count(); threads.resize(num_threads); + thread_level.resize(num_threads); - for(size_t i = 0; i < threads.size(); i++) + for(size_t i = 0; i < threads.size(); i++) { threads[i] = new thread(function_bind(&TaskScheduler::thread_run, i)); + thread_level[i] = 0; + } } users++; @@ -140,6 +190,7 @@ void TaskScheduler::exit() } threads.clear(); + thread_level.clear(); } } @@ -170,7 +221,7 @@ void TaskScheduler::thread_run(int thread_id) /* keep popping off tasks */ while(thread_wait_pop(entry)) { /* run task */ - entry.pool->run(entry.task, thread_id); + entry.task->run(); /* delete task */ delete entry.task; @@ -196,20 +247,20 @@ void TaskScheduler::push(Entry& entry, bool front) void TaskScheduler::clear(TaskPool *pool) { - thread_scoped_lock lock(TaskScheduler::queue_mutex); + thread_scoped_lock lock(queue_mutex); /* erase all tasks from this pool from the queue */ - list::iterator it = TaskScheduler::queue.begin(); + list::iterator it = queue.begin(); int done = 0; - while(it != TaskScheduler::queue.end()) { - TaskScheduler::Entry& entry = *it; + while(it != queue.end()) { + Entry& entry = *it; if(entry.pool == pool) { done++; delete entry.task; - it = TaskScheduler::queue.erase(it); + it = queue.erase(it); } else it++; diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index acdb2cb50a2..6b7562c2267 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -29,7 +29,7 @@ class Task; class TaskPool; class TaskScheduler; -typedef boost::function TaskRunFunction; +typedef boost::function TaskRunFunction; /* Task * @@ -39,7 +39,11 @@ class Task { public: Task() {}; + Task(const TaskRunFunction& run_) : run(run_) {} + virtual ~Task() {} + + TaskRunFunction run; }; /* Task Pool @@ -54,12 +58,13 @@ public: class TaskPool { public: - TaskPool(const TaskRunFunction& run); + TaskPool(); ~TaskPool(); void push(Task *task, bool front = false); + void push(const TaskRunFunction& run, bool front = false); - void wait(); /* wait until all tasks are done */ + void wait_work(); /* work and wait until all tasks are done */ void cancel(); /* cancel all tasks, keep worker threads running */ void stop(); /* stop all worker threads */ @@ -70,8 +75,6 @@ protected: void done_increase(int done); - TaskRunFunction run; - thread_mutex done_mutex; thread_condition_variable done_cond; @@ -103,6 +106,7 @@ protected: static thread_mutex mutex; static int users; static vector threads; + static vector thread_level; static volatile bool do_exit; static list queue; From c0331cfc090f218537937294fab0abfecc89e2aa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 May 2012 19:44:35 +0000 Subject: [PATCH 88/88] Cycles: minor refactoring of fisheye code to fit code style. --- intern/cycles/kernel/kernel_camera.h | 33 ++++++++++++---------- intern/cycles/kernel/kernel_montecarlo.h | 36 +++++++++++------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 6d49fd96dd7..220ebec13ce 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -134,19 +134,16 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa /* Panorama Camera */ -__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v, Ray *ray) +__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v) { - switch (kernel_data.cam.panorama_type) { - case PANORAMA_EQUIRECTANGULAR: - return equirectangular_to_direction(u, v); - break; - case PANORAMA_FISHEYE_EQUIDISTANT: - return fisheye_to_direction(u, v, kernel_data.cam.fisheye_fov, ray); - break; - case PANORAMA_FISHEYE_EQUISOLID: - default: - return fisheye_equisolid_to_direction(u, v, kernel_data.cam.fisheye_lens, kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight, ray); - break; + switch(kernel_data.cam.panorama_type) { + case PANORAMA_EQUIRECTANGULAR: + return equirectangular_to_direction(u, v); + case PANORAMA_FISHEYE_EQUIDISTANT: + return fisheye_to_direction(u, v, kernel_data.cam.fisheye_fov); + case PANORAMA_FISHEYE_EQUISOLID: + default: + return fisheye_equisolid_to_direction(u, v, kernel_data.cam.fisheye_lens, kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight); } } @@ -165,7 +162,13 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra ray->t = FLT_MAX; #endif - ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray); + ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y); + + /* indicates ray should not receive any light, outside of the lens */ + if(len_squared(ray->D) == 0.0f) { + ray->t = 0.0f; + return; + } /* transform ray from camera to world */ Transform cameratoworld = kernel_data.cam.cameratoworld; @@ -185,10 +188,10 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra ray->dP.dy = make_float3(0.0f, 0.0f, 0.0f); Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f)); - ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray))) - ray->D; + ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D; Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f)); - ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray))) - ray->D; + ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D; #endif } diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index ba24c2ea402..f51ce263ea2 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -91,8 +91,8 @@ __device_inline void sample_uniform_hemisphere(const float3 N, float3 *omega_in, float *pdf) { float z = randu; - float r = sqrtf(max(0.f, 1.f - z*z)); - float phi = 2.f * M_PI_F * randv; + float r = sqrtf(max(0.0f, 1.0f - z*z)); + float phi = 2.0f * M_PI_F * randv; float x = r * cosf(phi); float y = r * sinf(phi); @@ -226,22 +226,20 @@ __device float3 equirectangular_to_direction(float u, float v) /* Fisheye <- Cartesian direction */ -__device float3 fisheye_to_direction(float u, float v, float fov, Ray *ray) +__device float3 fisheye_to_direction(float u, float v, float fov) { - u = (u - 0.5f) * 2.f; - v = (v - 0.5f) * 2.f; + u = (u - 0.5f) * 2.0f; + v = (v - 0.5f) * 2.0f; float r = sqrt(u*u + v*v); - if (r > 1.0) { - ray->t = 0.f; - return make_float3(0.f,0.f,0.f); - } + if(r > 1.0f) + return make_float3(0.0f, 0.0f, 0.0f); - float phi = acosf((r!=0.f)?u/r:0.f); + float phi = acosf((r != 0.0f)? u/r: 0.0f); float theta = asinf(r) * (fov / M_PI_F); - if (v < 0.f) phi = -phi; + if(v < 0.0f) phi = -phi; return make_float3( cosf(theta), @@ -250,23 +248,21 @@ __device float3 fisheye_to_direction(float u, float v, float fov, Ray *ray) ); } -__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height, Ray *ray) +__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height) { u = (u - 0.5f) * width; v = (v - 0.5f) * height; - float rmax = 2.f * lens * sinf(fov * 0.25f); + float rmax = 2.0f * lens * sinf(fov * 0.25f); float r = sqrt(u*u + v*v); - if (r > rmax) { - ray->t = 0.f; - return make_float3(0.f,0.f,0.f); - } + if(r > rmax) + return make_float3(0.0f, 0.0f, 0.0f); - float phi = acosf((r!=0.f)?u/r:0.f); - float theta = 2.f * asinf(r/(2.f * lens)); + float phi = acosf((r != 0.0f)? u/r: 0.0f); + float theta = 2.0f * asinf(r/(2.0f * lens)); - if (v < 0.f) phi = -phi; + if(v < 0.0f) phi = -phi; return make_float3( cosf(theta),