From 203a4d42ca9f8a6e41c60c9d7a4e855b0c6cf635 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 2 May 2012 18:11:09 +0000 Subject: [PATCH 001/143] 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 002/143] 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 003/143] 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 004/143] 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 005/143] 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 006/143] 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 007/143] 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 008/143] 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 009/143] 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 010/143] 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 011/143] 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 012/143] 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 013/143] 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 014/143] 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 015/143] 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 016/143] 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 017/143] 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 018/143] 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 019/143] 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 020/143] 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 021/143] 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 022/143] 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 023/143] 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 024/143] 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 025/143] 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 026/143] 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 027/143] 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 028/143] 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 029/143] 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 030/143] 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 031/143] 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 032/143] 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 033/143] 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 034/143] 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 035/143] 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 036/143] 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 037/143] 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 038/143] 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 039/143] 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 040/143] 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 041/143] 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 042/143] 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 043/143] 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 044/143] 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 045/143] 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 046/143] 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 047/143] 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 048/143] 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 049/143] 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 050/143] 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 051/143] 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 052/143] 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 053/143] 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 054/143] 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 055/143] 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 056/143] 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 057/143] 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 058/143] 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 059/143] 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 060/143] 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 061/143] 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 062/143] 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 063/143] 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 064/143] 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 065/143] 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 066/143] 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 067/143] 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 068/143] 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 069/143] 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 070/143] 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 071/143] 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 072/143] 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 073/143] 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 074/143] 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 075/143] 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 076/143] 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 077/143] 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 078/143] 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 079/143] 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 080/143] 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 081/143] - 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 082/143] 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 083/143] 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 084/143] 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 085/143] 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 086/143] 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), From c91cee2bb9fd3a8ddef3355534971782e8e6f519 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 5 May 2012 21:28:12 +0000 Subject: [PATCH 087/143] code cleanup: naming - BKE_mesh_* --- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/BKE_mball.h | 2 +- source/blender/blenkernel/BKE_mesh.h | 117 +++++----- .../blender/blenkernel/intern/DerivedMesh.c | 12 +- source/blender/blenkernel/intern/anim.c | 12 +- .../blender/blenkernel/intern/cdderivedmesh.c | 29 +-- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/displist.c | 8 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/mesh.c | 199 +++++++++--------- .../blender/blenkernel/intern/mesh_validate.c | 4 +- source/blender/blenkernel/intern/multires.c | 6 +- source/blender/blenkernel/intern/object.c | 8 +- source/blender/blenkernel/intern/particle.c | 6 +- .../blenkernel/intern/particle_system.c | 18 +- .../blender/blenkernel/intern/subsurf_ccg.c | 12 +- source/blender/blenlib/intern/pbvh.c | 6 +- source/blender/blenloader/intern/readfile.c | 6 +- .../blenloader/intern/versioning_250.c | 4 +- .../blenloader/intern/versioning_legacy.c | 4 +- source/blender/blenloader/intern/writefile.c | 4 +- source/blender/collada/MeshImporter.cpp | 4 +- source/blender/editors/mesh/editmesh_utils.c | 2 +- source/blender/editors/mesh/mesh_data.c | 30 +-- source/blender/editors/object/object_add.c | 6 +- source/blender/editors/object/object_edit.c | 8 +- .../blender/editors/object/object_transform.c | 8 +- .../blender/editors/sculpt_paint/paint_hide.c | 6 +- source/blender/editors/sculpt_paint/sculpt.c | 4 +- .../editors/sculpt_paint/sculpt_undo.c | 4 +- .../blender/editors/space_view3d/drawobject.c | 6 +- source/blender/makesrna/intern/rna_curve.c | 6 +- source/blender/makesrna/intern/rna_mesh.c | 2 +- source/blender/makesrna/intern/rna_mesh_api.c | 2 +- .../blender/makesrna/intern/rna_object_api.c | 8 +- .../blender/modifiers/intern/MOD_multires.c | 12 +- source/blender/modifiers/intern/MOD_util.c | 2 +- .../blender/modifiers/intern/MOD_uvproject.c | 2 +- .../render/intern/source/convertblender.c | 2 +- 40 files changed, 292 insertions(+), 287 deletions(-) diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 3b9328ae1aa..6267104022c 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -63,7 +63,7 @@ void BKE_curve_make_local(struct Curve *cu); short BKE_curve_type_get(struct Curve *cu); void BKE_curve_type_test(struct Object *ob); void BKE_curve_curve_dimension_update(struct Curve *cu); -void BKE_curve_tex_space_calc(struct Curve *cu); +void BKE_curve_texspace_calc(struct Curve *cu); int BKE_curve_minmax(struct Curve *cu, float min[3], float max[3]); int BKE_curve_center_median(struct Curve *cu, float cent[3]); diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 018ee7f6c94..8a35690442d 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -51,7 +51,7 @@ int BKE_metaball_is_basis_for(struct Object *ob1, struct Object *ob2); int BKE_metaball_is_basis(struct Object *ob); struct Object *BKE_metaball_basis_find(struct Scene *scene, struct Object *ob); -void BKE_metaball_tex_space_calc(struct Object *ob); +void BKE_metaball_texspace_calc(struct Object *ob); float *BKE_metaball_make_orco(struct Object *ob, struct ListBase *dispbase); void BKE_metaball_properties_copy(struct Scene *scene, struct Object *active_object); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 256d4b1cae1..88a92d9028e 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -76,109 +76,109 @@ struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me, struct Object *ob); * if both of the above are 0, it'll use the indices of the mpolys of the MPoly * data in pdata, and ignore the origindex layer altogether. */ -int mesh_recalcTessellation(struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, - struct MVert *mvert, - int totface, int totloop, int totpoly, - const int do_face_normals); +int BKE_mesh_recalc_tessellation(struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, + struct MVert *mvert, + int totface, int totloop, int totpoly, + const int do_face_normals); /* for forwards compat only quad->tri polys to mface, skip ngons. */ -int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int totface, int totloop, int totpoly); +int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, + struct CustomData *pdata, int totface, int totloop, int totpoly); /*calculates a face normal.*/ void mesh_calc_poly_normal(struct MPoly *mpoly, struct MLoop *loopstart, struct MVert *mvarray, float no[3]); -void mesh_calc_poly_normal_coords(struct MPoly *mpoly, struct MLoop *loopstart, - const float (*vertex_coords)[3], float no[3]); +void BKE_mesh_calc_poly_normal_coords(struct MPoly *mpoly, struct MLoop *loopstart, + const float (*vertex_coords)[3], float no[3]); -void mesh_calc_poly_center(struct MPoly *mpoly, struct MLoop *loopstart, - struct MVert *mvarray, float cent[3]); +void BKE_mesh_calc_poly_center(struct MPoly *mpoly, struct MLoop *loopstart, + struct MVert *mvarray, float cent[3]); -float mesh_calc_poly_area(struct MPoly *mpoly, struct MLoop *loopstart, - struct MVert *mvarray, float polynormal[3]); +float BKE_mesh_calc_poly_area(struct MPoly *mpoly, struct MLoop *loopstart, + struct MVert *mvarray, float polynormal[3]); /* Find the index of the loop in 'poly' which references vertex, * returns -1 if not found */ int poly_find_loop_from_vert(const struct MPoly *poly, - const struct MLoop *loopstart, - unsigned vert); + const struct MLoop *loopstart, + unsigned vert); /* Fill 'adj_r' with the loop indices in 'poly' adjacent to the * vertex. Returns the index of the loop matching vertex, or -1 if the * vertex is not in 'poly' */ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const struct MPoly *poly, - const struct MLoop *mloop, unsigned vert); + const struct MLoop *mloop, unsigned vert); /* update the hide flag for edges and polys from the corresponding * flag in verts */ -void mesh_flush_hidden_from_verts(const struct MVert *mvert, - const struct MLoop *mloop, - struct MEdge *medge, int totedge, - struct MPoly *mpoly, int totpoly); +void BKE_mesh_flush_hidden_from_verts(const struct MVert *mvert, + const struct MLoop *mloop, + struct MEdge *medge, int totedge, + struct MPoly *mpoly, int totpoly); -void unlink_mesh(struct Mesh *me); +void BKE_mesh_unlink(struct Mesh *me); void BKE_mesh_free(struct Mesh *me, int unlink); 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); 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); -void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, int invert); +void BKE_mesh_boundbox_calc(struct Mesh *me, float *loc, float *size); +void BKE_mesh_texspace_calc(struct Mesh *me); +float *BKE_mesh_orco_verts_get(struct Object *ob); +void BKE_mesh_orco_verts_transform(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 *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, - struct MEdge **alledge, int *totedge, struct MLoop **allloop, struct MPoly **allpoly, - int *totloop, int *totpoly); -int nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert, - struct MEdge **alledge, int *_totedge, struct MLoop **allloop, struct MPoly **allpoly, - int *_totloop, int *_totpoly); -void nurbs_to_mesh(struct Object *ob); -void mesh_to_curve(struct Scene *scene, struct Object *ob); +void BKE_mesh_from_metaball(struct ListBase *lb, struct Mesh *me); +int BKE_mesh_nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *totvert, + struct MEdge **alledge, int *totedge, struct MLoop **allloop, struct MPoly **allpoly, + int *totloop, int *totpoly); +int BKE_mesh_nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert, + struct MEdge **alledge, int *_totedge, struct MLoop **allloop, struct MPoly **allpoly, + int *_totloop, int *_totpoly); +void BKE_mesh_from_nurbs(struct Object *ob); +void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob); void free_dverts(struct MDeformVert *dvert, int totvert); void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */ -void mesh_delete_material_index(struct Mesh *me, short index); -void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth); +void BKE_mesh_delete_material_index(struct Mesh *me, short index); +void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); -void mesh_calc_normals_tessface(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); +void BKE_mesh_calc_normals_tessface(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); /* used for unit testing; compares two meshes, checking only * differences we care about. should be usable with leaf's * testing framework I get RNA work done, will use hackish * testing code for now.*/ -const char *mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh); +const char *BKE_mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh); -struct BoundBox *mesh_get_bb(struct Object *ob); -void mesh_get_texspace(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]); +struct BoundBox *BKE_mesh_boundbox_get(struct Object *ob); +void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]); /* if old, it converts mface->edcode to edge drawflags */ -void make_edges(struct Mesh *me, int old); +void BKE_mesh_make_edges(struct Mesh *me, int old); -void mesh_strip_loose_faces(struct Mesh *me); /* Needed for compatibility (some old read code). */ -void mesh_strip_loose_polysloops(struct Mesh *me); -void mesh_strip_loose_edges(struct Mesh *me); +void BKE_mesh_strip_loose_faces(struct Mesh *me); /* Needed for compatibility (some old read code). */ +void BKE_mesh_strip_loose_polysloops(struct Mesh *me); +void BKE_mesh_strip_loose_edges(struct Mesh *me); /* Calculate vertex and face normals, face normals are returned in *faceNors_r if non-NULL * and vertex normals are stored in actual mverts. */ -void mesh_calc_normals_mapping( +void BKE_mesh_calc_normals_mapping( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]); - /* extended version of 'mesh_calc_normals' with option not to calc vertex normals */ -void mesh_calc_normals_mapping_ex( + /* extended version of 'BKE_mesh_calc_normals' with option not to calc vertex normals */ +void BKE_mesh_calc_normals_mapping_ex( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], const short only_face_normals); -void mesh_calc_normals( +void BKE_mesh_calc_normals( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3]); @@ -246,9 +246,10 @@ typedef struct UvElementMap { * to make that many islands, he can bite me :p */ #define INVALID_ISLAND 0xFFFF -UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, float *limit); -UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v); -void free_uv_vert_map(UvVertMap *vmap); +UvVertMap *BKE_mesh_uv_vert_map_make(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, + unsigned int totpoly, unsigned int totvert, int selected, float *limit); +UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v); +void BKE_mesh_uv_vert_map_free(UvVertMap *vmap); /* Connectivity data */ typedef struct MeshElemMap { @@ -270,10 +271,10 @@ void create_vert_edge_map(struct ListBase **map, IndexNode **mem, const struct M /* vertex level transformations & checks (no derived mesh) */ -int minmax_mesh(struct Mesh *me, float min[3], float max[3]); -int mesh_center_median(struct Mesh *me, float cent[3]); -int mesh_center_bounds(struct Mesh *me, float cent[3]); -void mesh_translate(struct Mesh *me, float offset[3], int do_keys); +int BKE_mesh_minmax(struct Mesh *me, float r_min[3], float r_max[3]); +int BKE_mesh_center_median(struct Mesh *me, float cent[3]); +int BKE_mesh_center_bounds(struct Mesh *me, float cent[3]); +void BKE_mesh_translate(struct Mesh *me, float offset[3], int do_keys); /* mesh_validate.c */ /* XXX Loop v/e are unsigned, so using max uint_32 value as invalid marker... */ @@ -298,10 +299,10 @@ void BKE_mesh_tessface_ensure(struct Mesh *mesh); void BKE_mesh_tessface_clear(struct Mesh *mesh); /* Convert a triangle or quadrangle of loop/poly data to tessface data */ -void mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int lindex[4], int findex, - const int polyindex, const int mf_len, - const int numTex, const int numCol, const int hasPCol, const int hasOrigSpace); +void BKE_mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata, + struct CustomData *pdata, int lindex[4], int findex, + const int polyindex, const int mf_len, + const int numTex, const int numCol, const int hasPCol, const int hasOrigSpace); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index db9df4050b0..2024a5ce091 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -446,10 +446,10 @@ void DM_update_tessface_data(DerivedMesh *dm) not_done--; } } - mesh_loops_to_mface_corners(fdata, ldata, pdata, - ml_idx, mf_idx, polyindex[mf_idx], - mf_len, - numTex, numCol, hasPCol, hasOrigSpace); + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + ml_idx, mf_idx, polyindex[mf_idx], + mf_len, + numTex, numCol, hasPCol, hasOrigSpace); } if (G.debug & G_DEBUG) @@ -870,7 +870,7 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free if (em) return (float(*)[3])get_editbmesh_orco_verts(em); else - return (float(*)[3])get_mesh_orco_verts(ob); + return (float(*)[3])BKE_mesh_orco_verts_get(ob); } else if (layer == CD_CLOTH_ORCO) { /* apply shape key for cloth, this should really be solved @@ -932,7 +932,7 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm, if (orco) { if (layer == CD_ORCO) - transform_mesh_orco_verts(ob->data, orco, totvert, 0); + BKE_mesh_orco_verts_transform(ob->data, orco, totvert, 0); if (!(layerorco = DM_get_vert_data_layer(dm, layer))) { DM_add_vert_layer(dm, layer, CD_CALLOC, NULL); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 1d05ecca909..f3b106efe33 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -931,8 +931,8 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); if (G.rendering) { - vdd.orco= (float(*)[3])get_mesh_orco_verts(par); - transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0); + vdd.orco= (float(*)[3])BKE_mesh_orco_verts_get(par); + BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0); } else vdd.orco= NULL; @@ -1063,8 +1063,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa if (G.rendering) { - orco= (float(*)[3])get_mesh_orco_verts(par); - transform_mesh_orco_verts(me, orco, me->totvert, 0); + orco= (float(*)[3])BKE_mesh_orco_verts_get(par); + BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0); mloopuv= me->mloopuv; } else { @@ -1143,7 +1143,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa } /* translation */ - mesh_calc_poly_center(mp, loopstart, mvert, cent); + BKE_mesh_calc_poly_center(mp, loopstart, mvert, cent); mul_m4_v3(pmat, cent); @@ -1160,7 +1160,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* scale */ if (par->transflag & OB_DUPLIFACES_SCALE) { - float size= mesh_calc_poly_area(mp, loopstart, mvert, NULL); + float size= BKE_mesh_calc_poly_area(mp, loopstart, mvert, NULL); size= sqrtf(size) * par->dupfacesca; mul_m3_fl(mat, size); } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 78a8b975b85..15db0df1bad 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1521,10 +1521,10 @@ void CDDM_recalc_tessellation_ex(DerivedMesh *dm, const int do_face_nor_cpy) { CDDerivedMesh *cddm = (CDDerivedMesh*)dm; - dm->numTessFaceData = mesh_recalcTessellation(&dm->faceData, &dm->loopData, &dm->polyData, - cddm->mvert, - dm->numTessFaceData, dm->numLoopData, dm->numPolyData, - do_face_nor_cpy); + dm->numTessFaceData = BKE_mesh_recalc_tessellation(&dm->faceData, &dm->loopData, &dm->polyData, + cddm->mvert, + dm->numTessFaceData, dm->numLoopData, dm->numPolyData, + do_face_nor_cpy); if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) { int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX); @@ -1723,8 +1723,9 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) MPoly *allpoly; int totvert, totedge, totloop, totpoly; - if (nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge, - &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) { + if (BKE_mesh_nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge, + &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) + { /* Error initializing mdata. This often happens when curve is empty */ return CDDM_new(0, 0, 0, 0, 0); } @@ -2116,10 +2117,10 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors"); /* calculate face normals */ - mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, - CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, - only_face_normals); + BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), + dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, + CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, + only_face_normals); CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, face_nors, dm->numTessFaceData); @@ -2151,8 +2152,8 @@ void CDDM_calc_normals(DerivedMesh *dm) poly_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData); } - mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, poly_nors); + BKE_mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), + dm->numLoopData, dm->numPolyData, poly_nors); } void CDDM_calc_normals_tessface(DerivedMesh *dm) @@ -2171,8 +2172,8 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm) face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, dm->numTessFaceData); } - mesh_calc_normals_tessface(cddm->mvert, dm->numVertData, - cddm->mface, dm->numTessFaceData, face_nors); + BKE_mesh_calc_normals_tessface(cddm->mvert, dm->numVertData, + cddm->mface, dm->numTessFaceData, face_nors); } #if 1 diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index bfefc1f0cd9..0f12b79e05d 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -354,7 +354,7 @@ void BKE_curve_type_test(Object *ob) BKE_curve_curve_dimension_update((Curve *)ob->data); } -void BKE_curve_tex_space_calc(Curve *cu) +void BKE_curve_texspace_calc(Curve *cu) { DispList *dl; BoundBox *bb; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ebcebaedd2d..04e559388ca 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -674,7 +674,7 @@ void makeDispListMBall(Scene *scene, Object *ob) if (ob->type==OB_MBALL) { if (ob==BKE_metaball_basis_find(scene, ob)) { BKE_metaball_polygonize(scene, ob, &ob->disp); - BKE_metaball_tex_space_calc(ob); + BKE_metaball_texspace_calc(ob); object_deform_mball(ob, &ob->disp); } @@ -686,7 +686,7 @@ void makeDispListMBall(Scene *scene, Object *ob) void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) { BKE_metaball_polygonize(scene, ob, dispbase); - BKE_metaball_tex_space_calc(ob); + BKE_metaball_texspace_calc(ob); object_deform_mball(ob, dispbase); } @@ -1182,7 +1182,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, copy_displist(&cu->disp, dispbase); if (!forRender) { - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); } if (!forOrco) @@ -1451,7 +1451,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba copy_displist(&cu->disp, dispbase); if (!forRender) { - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); } if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index f4d9bcfd218..13cfb40a0eb 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -527,7 +527,7 @@ static void data_delete_material_index_id(ID *id, short index) { switch (GS(id->name)) { case ID_ME: - mesh_delete_material_index((Mesh *)id, index); + BKE_mesh_delete_material_index((Mesh *)id, index); break; case ID_CU: BKE_curve_delete_material_index((Curve *)id, index); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index a841649e007..be6459bac90 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -346,7 +346,7 @@ MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) * basic MetaBall (usually with name Meta). All other MetaBalls (with * names Meta.001, Meta.002, etc) are included in this Bounding Box. */ -void BKE_metaball_tex_space_calc(Object *ob) +void BKE_metaball_texspace_calc(Object *ob) { DispList *dl; BoundBox *bb; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index fd054dee44a..ffc33e3b86a 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -277,7 +277,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 } /*used for testing. returns an error string the two meshes don't match*/ -const char *mesh_cmp(Mesh *me1, Mesh *me2, float thresh) +const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh) { int c; @@ -392,7 +392,7 @@ void mesh_update_customdata_pointers(Mesh *me, const short do_ensure_tess_cd) * we need a more generic method, like the expand() functions in * readfile.c */ -void unlink_mesh(Mesh *me) +void BKE_mesh_unlink(Mesh *me) { int a; @@ -415,7 +415,7 @@ void unlink_mesh(Mesh *me) void BKE_mesh_free(Mesh *me, int unlink) { if (unlink) - unlink_mesh(me); + BKE_mesh_unlink(me); CustomData_free(&me->vdata, me->totvert); CustomData_free(&me->edata, me->totedge); @@ -658,7 +658,7 @@ void BKE_mesh_make_local(Mesh *me) } } -void boundbox_mesh(Mesh *me, float *loc, float *size) +void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3]) { BoundBox *bb; float min[3], max[3]; @@ -667,30 +667,30 @@ void boundbox_mesh(Mesh *me, float *loc, float *size) if (me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= me->bb; - if (!loc) loc= mloc; - if (!size) size= msize; + if (!r_loc) r_loc= mloc; + if (!r_size) r_size= msize; INIT_MINMAX(min, max); - if (!minmax_mesh(me, min, max)) { + if (!BKE_mesh_minmax(me, min, max)) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } - mid_v3_v3v3(loc, min, max); + mid_v3_v3v3(r_loc, min, max); - size[0]= (max[0]-min[0])/2.0f; - size[1]= (max[1]-min[1])/2.0f; - size[2]= (max[2]-min[2])/2.0f; + r_size[0]= (max[0]-min[0])/2.0f; + r_size[1]= (max[1]-min[1])/2.0f; + r_size[2]= (max[2]-min[2])/2.0f; BKE_boundbox_init_from_minmax(bb, min, max); } -void tex_space_mesh(Mesh *me) +void BKE_mesh_texspace_calc(Mesh *me) { float loc[3], size[3]; int a; - boundbox_mesh(me, loc, size); + BKE_mesh_boundbox_calc(me, loc, size); if (me->texflag & ME_AUTOSPACE) { for (a=0; a<3; a++) { @@ -705,7 +705,7 @@ void tex_space_mesh(Mesh *me) } } -BoundBox *mesh_get_bb(Object *ob) +BoundBox *BKE_mesh_boundbox_get(Object *ob) { Mesh *me= ob->data; @@ -713,15 +713,15 @@ BoundBox *mesh_get_bb(Object *ob) return ob->bb; if (!me->bb) - tex_space_mesh(me); + BKE_mesh_texspace_calc(me); return me->bb; } -void mesh_get_texspace(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]) +void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]) { if (!me->bb) { - tex_space_mesh(me); + BKE_mesh_texspace_calc(me); } if (r_loc) copy_v3_v3(r_loc, me->loc); @@ -729,7 +729,7 @@ void mesh_get_texspace(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3] if (r_size) copy_v3_v3(r_size, me->size); } -float *get_mesh_orco_verts(Object *ob) +float *BKE_mesh_orco_verts_get(Object *ob) { Mesh *me = ob->data; MVert *mvert = NULL; @@ -749,12 +749,12 @@ float *get_mesh_orco_verts(Object *ob) return (float*)vcos; } -void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int invert) +void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert) { float loc[3], size[3]; int a; - mesh_get_texspace(me->texcomesh?me->texcomesh:me, loc, NULL, size); + BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, NULL, size); if (invert) { for (a=0; a1; a--, ed++) { @@ -1015,7 +1015,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll BLI_edgehash_free(hash, NULL); } -void make_edges(Mesh *me, int old) +void BKE_mesh_make_edges(Mesh *me, int old) { MEdge *medge; int totedge=0; @@ -1032,11 +1032,11 @@ void make_edges(Mesh *me, int old) me->medge= medge; me->totedge= totedge; - mesh_strip_loose_faces(me); + BKE_mesh_strip_loose_faces(me); } /* We need to keep this for edge creation (for now?), and some old readfile code... */ -void mesh_strip_loose_faces(Mesh *me) +void BKE_mesh_strip_loose_faces(Mesh *me) { MFace *f; int a, b; @@ -1060,7 +1060,7 @@ void mesh_strip_loose_faces(Mesh *me) /* Note: It won't try to guess which loops of an invalid poly to remove! * this is the work of the caller, to mark those loops... * See e.g. BKE_mesh_validate_arrays(). */ -void mesh_strip_loose_polysloops(Mesh *me) +void BKE_mesh_strip_loose_polysloops(Mesh *me) { MPoly *p; MLoop *l; @@ -1131,7 +1131,7 @@ void mesh_strip_loose_polysloops(Mesh *me) MEM_freeN(new_idx); } -void mesh_strip_loose_edges(Mesh *me) +void BKE_mesh_strip_loose_edges(Mesh *me) { MEdge *e; MLoop *l; @@ -1166,7 +1166,7 @@ void mesh_strip_loose_edges(Mesh *me) MEM_freeN(new_idx); } -void mball_to_mesh(ListBase *lb, Mesh *me) +void BKE_mesh_from_metaball(ListBase *lb, Mesh *me) { DispList *dl; MVert *mvert; @@ -1223,7 +1223,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me) mesh_update_customdata_pointers(me, TRUE); - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); BKE_mesh_calc_edges(me, TRUE); } @@ -1231,15 +1231,15 @@ void mball_to_mesh(ListBase *lb, Mesh *me) /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* return non-zero on error */ -int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, - MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly, - int *totloop, int *totpoly) +int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, + MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly, + int *totloop, int *totpoly) { - return nurbs_to_mdata_customdb(ob, &ob->disp, - allvert, totvert, - alledge, totedge, - allloop, allpoly, - totloop, totpoly); + return BKE_mesh_nurbs_to_mdata_customdb(ob, &ob->disp, + allvert, totvert, + alledge, totedge, + allloop, allpoly, + totloop, totpoly); } /* BMESH: this doesn't calculate all edges from polygons, @@ -1247,11 +1247,11 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* use specified dispbase */ -int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, - MVert **allvert, int *_totvert, - MEdge **alledge, int *_totedge, - MLoop **allloop, MPoly **allpoly, - int *_totloop, int *_totpoly) +int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, + MVert **allvert, int *_totvert, + MEdge **alledge, int *_totedge, + MLoop **allloop, MPoly **allpoly, + int *_totloop, int *_totpoly) { DispList *dl; Curve *cu; @@ -1467,7 +1467,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, } /* this may fail replacing ob->data, be sure to check ob->type */ -void nurbs_to_mesh(Object *ob) +void BKE_mesh_from_nurbs(Object *ob) { Main *bmain= G.main; Object *ob1; @@ -1483,7 +1483,10 @@ void nurbs_to_mesh(Object *ob) cu= ob->data; if (dm == NULL) { - if (nurbs_to_mdata(ob, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) { + if (BKE_mesh_nurbs_to_mdata(ob, &allvert, &totvert, + &alledge, &totedge, &allloop, + &allpoly, &totloop, &totpoly) != 0) + { /* Error initializing */ return; } @@ -1500,7 +1503,7 @@ void nurbs_to_mesh(Object *ob) me->mloop= CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop); me->mpoly= CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly); - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); BKE_mesh_calc_edges(me, TRUE); } @@ -1512,7 +1515,7 @@ void nurbs_to_mesh(Object *ob) me->totcol= cu->totcol; me->mat= cu->mat; - tex_space_mesh(me); + BKE_mesh_texspace_calc(me); cu->mat= NULL; cu->totcol= 0; @@ -1560,7 +1563,7 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) BLI_addtail(lb, vl); } -void mesh_to_curve(Scene *scene, Object *ob) +void BKE_mesh_from_curve(Scene *scene, Object *ob) { /* make new mesh data from the original copy */ DerivedMesh *dm= mesh_get_derived_final(scene, ob, CD_MASK_MESH); @@ -1732,7 +1735,7 @@ void mesh_to_curve(Scene *scene, Object *ob) } } -void mesh_delete_material_index(Mesh *me, short index) +void BKE_mesh_delete_material_index(Mesh *me, short index) { int i; @@ -1749,7 +1752,7 @@ void mesh_delete_material_index(Mesh *me, short index) } } -void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) +void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth) { Mesh *me = meshOb->data; int i; @@ -1777,16 +1780,16 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) } } -void mesh_calc_normals_mapping(MVert *mverts, int numVerts, +void BKE_mesh_calc_normals_mapping(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]) { - mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, - numLoops, numPolys, polyNors_r, mfaces, numFaces, - origIndexFace, faceNors_r, FALSE); + BKE_mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, + numLoops, numPolys, polyNors_r, mfaces, numFaces, + origIndexFace, faceNors_r, FALSE); } -void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, +void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], @@ -1814,7 +1817,7 @@ void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, if (only_face_normals == FALSE) { /* vertex normals are optional, they require some extra calculations, * so make them optional */ - mesh_calc_normals(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors); + BKE_mesh_calc_normals(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors); } else { /* only calc poly normals */ @@ -1836,7 +1839,7 @@ void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, } else { /* eek, we're not corresponding to polys */ - printf("error in mesh_calc_normals; tessellation face indices are incorrect. normals may look bad.\n"); + printf("error in BKE_mesh_calc_normals; tessellation face indices are incorrect. normals may look bad.\n"); } } } @@ -1848,8 +1851,8 @@ void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, } -void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, - int UNUSED(numLoops), int numPolys, float (*polyNors_r)[3]) +void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, + int UNUSED(numLoops), int numPolys, float (*polyNors_r)[3]) { float (*pnors)[3] = polyNors_r; @@ -1910,7 +1913,7 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, if (pnors != polyNors_r) MEM_freeN(pnors); } -void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3]) +void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3]) { float (*tnorms)[3]= MEM_callocN(numVerts*sizeof(*tnorms), "tnorms"); float (*fnors)[3]= (faceNors_r)? faceNors_r: MEM_callocN(sizeof(*fnors)*numFaces, "meshnormals"); @@ -2132,7 +2135,7 @@ float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3] /* this replaces the non bmesh function (in trunk) which takes MTFace's, if we ever need it back we could * but for now this replaces it because its unused. */ -UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, float *limit) +UvVertMap *BKE_mesh_uv_vert_map_make(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, float *limit) { UvVertMap *vmap; UvMapVert *buf; @@ -2159,7 +2162,7 @@ UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLo buf= vmap->buf= (UvMapVert*)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); return NULL; } @@ -2223,12 +2226,12 @@ UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLo return vmap; } -UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v) +UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v) { return vmap->vert[v]; } -void free_uv_vert_map(UvVertMap *vmap) +void BKE_mesh_uv_vert_map_free(UvVertMap *vmap) { if (vmap) { if (vmap->vert) MEM_freeN(vmap->vert); @@ -2302,17 +2305,17 @@ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, c } } -void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, - CustomData *pdata, int lindex[4], int findex, - const int polyindex, - const int mf_len, /* 3 or 4 */ +void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, + CustomData *pdata, int lindex[4], int findex, + const int polyindex, + const int mf_len, /* 3 or 4 */ - /* cache values to avoid lookups every time */ - const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */ - const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */ - const int hasPCol, /* CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL) */ - const int hasOrigSpace /* CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP) */ - ) + /* cache values to avoid lookups every time */ + const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */ + const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */ + const int hasPCol, /* CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL) */ + const int hasOrigSpace /* CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP) */ + ) { MTFace *texface; MTexPoly *texpoly; @@ -2366,7 +2369,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, * this function recreates a tessellation. * returns number of tessellation faces. */ -int mesh_recalcTessellation(CustomData *fdata, +int BKE_mesh_recalc_tessellation(CustomData *fdata, CustomData *ldata, CustomData *pdata, MVert *mvert, int totface, int UNUSED(totloop), int totpoly, @@ -2618,14 +2621,14 @@ int mesh_recalcTessellation(CustomData *fdata, if (mf_len == 4) mf->v4 = mloop[mf->v4].v; #endif - mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, mface_index, mface_to_poly_map[mface_index], + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + lindex, mface_index, mface_to_poly_map[mface_index], #ifdef USE_TESSFACE_QUADS - mf_len, + mf_len, #else - 3, + 3, #endif - numTex, numCol, hasPCol, hasOrigSpace); + numTex, numCol, hasPCol, hasOrigSpace); #ifdef USE_TESSFACE_QUADS @@ -2647,7 +2650,7 @@ int mesh_recalcTessellation(CustomData *fdata, * this function recreates a tessellation. * returns number of tessellation faces. */ -int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, +int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly) { MLoop *mloop; @@ -2719,9 +2722,9 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mf->v2 = mloop[mf->v2].v; mf->v3 = mloop[mf->v3].v; - mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, k, i, 3, - numTex, numCol, hasPCol, hasOrigSpace); + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + lindex, k, i, 3, + numTex, numCol, hasPCol, hasOrigSpace); test_index_face(mf, fdata, k, 3); } else { @@ -2739,9 +2742,9 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mf->v3 = mloop[mf->v3].v; mf->v4 = mloop[mf->v4].v; - mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, k, i, 4, - numTex, numCol, hasPCol, hasOrigSpace); + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + lindex, k, i, 4, + numTex, numCol, hasPCol, hasOrigSpace); test_index_face(mf, fdata, k, 4); } @@ -2829,7 +2832,7 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart, } } -void mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, +void BKE_mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, const float (*vertex_coords)[3], float no[3]) { if (mpoly->totloop > 4) { @@ -2870,7 +2873,7 @@ static void mesh_calc_ngon_center(MPoly *mpoly, MLoop *loopstart, } } -void mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, +void BKE_mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, MVert *mvarray, float cent[3]) { if (mpoly->totloop == 3) { @@ -2894,7 +2897,7 @@ void mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, } /* note, passing polynormal is only a speedup so we can skip calculating it */ -float mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, +float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, MVert *mvarray, float polynormal[3]) { if (mpoly->totloop == 3) { @@ -2974,7 +2977,7 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, /* update the hide flag for edges and faces from the corresponding * flag in verts */ -void mesh_flush_hidden_from_verts(const MVert *mvert, +void BKE_mesh_flush_hidden_from_verts(const MVert *mvert, const MLoop *mloop, MEdge *medge, int totedge, MPoly *mpoly, int totpoly) @@ -3003,18 +3006,18 @@ void mesh_flush_hidden_from_verts(const MVert *mvert, } /* basic vertex data functions */ -int minmax_mesh(Mesh *me, float min[3], float max[3]) +int BKE_mesh_minmax(Mesh *me, float r_min[3], float r_max[3]) { - int i= me->totvert; + int i = me->totvert; MVert *mvert; - for (mvert= me->mvert; i--; mvert++) { - DO_MINMAX(mvert->co, min, max); + for (mvert = me->mvert; i--; mvert++) { + DO_MINMAX(mvert->co, r_min, r_max); } return (me->totvert != 0); } -int mesh_center_median(Mesh *me, float cent[3]) +int BKE_mesh_center_median(Mesh *me, float cent[3]) { int i= me->totvert; MVert *mvert; @@ -3030,11 +3033,11 @@ int mesh_center_median(Mesh *me, float cent[3]) return (me->totvert != 0); } -int mesh_center_bounds(Mesh *me, float cent[3]) +int BKE_mesh_center_bounds(Mesh *me, float cent[3]) { float min[3], max[3]; INIT_MINMAX(min, max); - if (minmax_mesh(me, min, max)) { + if (BKE_mesh_minmax(me, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } @@ -3042,7 +3045,7 @@ int mesh_center_bounds(Mesh *me, float cent[3]) return 0; } -void mesh_translate(Mesh *me, float offset[3], int do_keys) +void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys) { int i= me->totvert; MVert *mvert; @@ -3079,7 +3082,7 @@ void BKE_mesh_ensure_navmesh(Mesh *me) void BKE_mesh_tessface_calc(Mesh *mesh) { - mesh->totface = mesh_recalcTessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->totface = BKE_mesh_recalc_tessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata, mesh->mvert, mesh->totface, mesh->totloop, mesh->totpoly, /* calc normals right after, don't copy from polys here */ diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 446ad399e11..1645a8c9c9b 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -536,11 +536,11 @@ int BKE_mesh_validate_arrays(Mesh *mesh, if (mesh) { if (do_polyloop_free) { - mesh_strip_loose_polysloops(mesh); + BKE_mesh_strip_loose_polysloops(mesh); } if (do_edge_free) { - mesh_strip_loose_edges(mesh); + BKE_mesh_strip_loose_edges(mesh); } if (do_edge_recalc) { diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index e432428eae4..35ee0549554 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -779,7 +779,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) float no[3]; /* set up poly, loops, and coords in order to call - * mesh_calc_poly_normal_coords() */ + * BKE_mesh_calc_poly_normal_coords() */ fake_poly.totloop = p->totloop; fake_poly.loopstart = 0; fake_loops = MEM_mallocN(sizeof(MLoop) * p->totloop, "fake_loops"); @@ -796,8 +796,8 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) copy_v3_v3(fake_co[k], origco[vndx]); } - mesh_calc_poly_normal_coords(&fake_poly, fake_loops, - (const float(*)[3])fake_co, no); + BKE_mesh_calc_poly_normal_coords(&fake_poly, fake_loops, + (const float(*)[3])fake_co, no); MEM_freeN(fake_loops); MEM_freeN(fake_co); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 14f23032dd9..1057b027d1b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -299,7 +299,7 @@ void BKE_object_free(Object *ob) ID *id= ob->data; id->us--; if (id->us==0) { - if (ob->type==OB_MESH) unlink_mesh(ob->data); + if (ob->type==OB_MESH) BKE_mesh_unlink(ob->data); else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data); else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data); } @@ -2180,7 +2180,7 @@ BoundBox *BKE_object_boundbox_get(Object *ob) BoundBox *bb= NULL; if (ob->type==OB_MESH) { - bb = mesh_get_bb(ob); + bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { bb= ob->bb ? ob->bb : ((Curve *)ob->data )->bb; @@ -2254,7 +2254,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) { Curve *cu= ob->data; - if (cu->bb==NULL) BKE_curve_tex_space_calc(cu); + if (cu->bb==NULL) BKE_curve_texspace_calc(cu); bb= *(cu->bb); for (a=0; a<8; a++) { @@ -2298,7 +2298,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) Mesh *me= BKE_mesh_from_object(ob); if (me) { - bb = *mesh_get_bb(ob); + bb = *BKE_mesh_boundbox_get(ob); for (a=0; a<8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0e56839a6e9..2a8a4ebc34b 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -863,7 +863,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]); /* for conversion from BU area / pixel area to reference screen size */ - mesh_get_texspace(me, 0, 0, size); + BKE_mesh_texspace_get(me, 0, 0, size); fac= ((size[0] + size[1] + size[2])/3.0f)/part->simplify_refsize; fac= fac*fac; @@ -3385,7 +3385,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m /* ugly hack to use non-transformed orcos, since only those * give symmetric results for mirroring in particle mode */ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX)) - transform_mesh_orco_verts(ob->data, v, 3, 1); + BKE_mesh_orco_verts_transform(ob->data, v, 3, 1); } else { dm->getVertCo(dm, mface->v1, v[0]); @@ -3414,7 +3414,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData /* see psys_face_mat for why this function is called */ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX)) - transform_mesh_orco_verts(ob->data, &orco, 1, 1); + BKE_mesh_orco_verts_transform(ob->data, &orco, 1, 1); copy_v3_v3(hairmat[3], orco); } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e5c95c116fd..950298f3824 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -772,7 +772,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch int w, maxw; psys_particle_on_dm(ctx->dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, orco1, 0); - transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1); maxw = BLI_kdtree_find_n_nearest(ctx->tree, 3, orco1, NULL, ptn); for (w=0; wnum, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co1, nor1, NULL, NULL, orco1, NULL); - transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1); maxw = BLI_kdtree_find_n_nearest(ctx->tree, 4, orco1, NULL, ptn); maxd=ptn[maxw-1].dist; @@ -1086,7 +1086,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0, pa=psys->particles; pfrom, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, orco, ornor); - transform_mesh_orco_verts((Mesh*)ob->data, &orco, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco, 1, 1); BLI_kdtree_insert(tree, p, orco, ornor); } @@ -1107,7 +1107,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } /* we need orco for consistent distributions */ - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); + DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob)); if (from == PART_FROM_VERT) { MVert *mv= dm->getVertDataArray(dm, CD_MVERT); @@ -1119,7 +1119,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0; pdata, &co, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co, 1, 1); } else copy_v3_v3(co, mv[p].co); @@ -1166,12 +1166,12 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D copy_v3_v3(co1, orcodata[mf->v1]); copy_v3_v3(co2, orcodata[mf->v2]); copy_v3_v3(co3, orcodata[mf->v3]); - transform_mesh_orco_verts((Mesh*)ob->data, &co1, 1, 1); - transform_mesh_orco_verts((Mesh*)ob->data, &co2, 1, 1); - transform_mesh_orco_verts((Mesh*)ob->data, &co3, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co1, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co2, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co3, 1, 1); if (mf->v4) { copy_v3_v3(co4, orcodata[mf->v4]); - transform_mesh_orco_verts((Mesh*)ob->data, &co4, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co4, 1, 1); } } else { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index b3b704bf2a2..857a0c86349 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -244,7 +244,7 @@ static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct ML int j, nverts = mpoly[fi].totloop; for (j = 0; j < nverts; j++) { - for (nv = v = get_uv_map_vert(vmap, ml[j].v); v; v = v->next) { + for (nv = v = BKE_mesh_uv_vert_map_get_vert(vmap, ml[j].v); v; v = v->next) { if (v->separate) nv = v; if (v->f == fi) @@ -273,7 +273,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ limit[0] = limit[1] = STD_UV_CONNECT_LIMIT; - vmap = make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit); + vmap = BKE_mesh_uv_vert_map_make(mpoly, mloop, mloopuv, totface, totvert, 0, limit); if (!vmap) return 0; @@ -281,16 +281,16 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, /* create vertices */ for (i = 0; i < totvert; i++) { - if (!get_uv_map_vert(vmap, i)) + if (!BKE_mesh_uv_vert_map_get_vert(vmap, i)) continue; - for (v = get_uv_map_vert(vmap, i)->next; v; v = v->next) + for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i)->next; v; v = v->next) if (v->separate) break; seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED); - for (v = get_uv_map_vert(vmap, i); v; v = v->next) { + for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) { if (v->separate) { CCGVert *ssv; int loopid = mpoly[v->f].loopstart + v->tfindex; @@ -358,7 +358,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, BLI_array_free(fverts); - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); ccgSubSurf_processSync(ss); return 1; diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 8ab55f9ac85..4ad350c7786 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -35,8 +35,8 @@ #include "BLI_pbvh.h" #include "BKE_DerivedMesh.h" -#include "BKE_mesh.h" /* for mesh_calc_normals */ -#include "BKE_global.h" /* for mesh_calc_normals */ +#include "BKE_mesh.h" /* for BKE_mesh_calc_normals */ +#include "BKE_global.h" /* for BKE_mesh_calc_normals */ #include "BKE_paint.h" #include "BKE_subsurf.h" @@ -1743,7 +1743,7 @@ void BLI_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3]) } /* coordinates are new -- normals should also be updated */ - mesh_calc_normals_tessface(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL); + BKE_mesh_calc_normals_tessface(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL); for (a= 0; a < pbvh->totnode; ++a) BLI_pbvh_node_mark_update(&pbvh->nodes[a]); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 637bb085aa2..7e27106a82f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3809,7 +3809,7 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte * overwritten with the correct value in * bm_corners_to_loops() */ float gridsize = sqrtf(mdisps[i].totdisp); - mdisps[i].level = (int)(logf(gridsize - 1.0f) / M_LN2) + 1; + mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1; } if ( (fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps) ) { @@ -3908,7 +3908,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) if (mesh->mpoly) { /* be clever and load polygons as mfaces */ - mesh->totface= mesh_mpoly_to_mface(&mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->totface= BKE_mesh_mpoly_to_mface(&mesh->fdata, &mesh->ldata, &mesh->pdata, mesh->totface, mesh->totloop, mesh->totpoly); CustomData_free(&mesh->pdata, mesh->totpoly); @@ -7406,7 +7406,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Curve *cu; for (la= main->lamp.first; la; la= la->id.next) { - if (la->shadow_frustum_size == 0.0) + if (la->shadow_frustum_size == 0.0f) la->shadow_frustum_size= 10.0f; } diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 8b9ff496507..ebbfbd32cb5 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -2360,8 +2360,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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); + for (me = main->mesh.first; me; me = me->id.next) + BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); } if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 64d7fdfe112..759a2ea595f 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -2011,10 +2011,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) for (me=main->mesh.first; me; me= me->id.next) { if (!me->medge) { - make_edges(me, 1); /* 1 = use mface->edcode */ + BKE_mesh_make_edges(me, 1); /* 1 = use mface->edcode */ } else { - mesh_strip_loose_faces(me); + BKE_mesh_strip_loose_faces(me); } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 11f6b972837..dcae11ff2e1 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1784,8 +1784,8 @@ static void write_meshs(WriteData *wd, ListBase *idbase) /* now fill in polys to mfaces*/ - mesh->totface= mesh_mpoly_to_mface(&mesh->fdata, &backup_mesh.ldata, &backup_mesh.pdata, - mesh->totface, backup_mesh.totloop, backup_mesh.totpoly); + mesh->totface = BKE_mesh_mpoly_to_mface(&mesh->fdata, &backup_mesh.ldata, &backup_mesh.pdata, + mesh->totface, backup_mesh.totloop, backup_mesh.totpoly); mesh_update_customdata_pointers(mesh, FALSE); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index ca1f2d2f1be..9ce0ce6c3a2 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -737,7 +737,7 @@ void MeshImporter::bmeshConversion() 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); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } } } @@ -976,7 +976,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) read_faces(mesh, me, new_tris); - make_edges(me, 0); + BKE_mesh_make_edges(me, 0); return true; } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index faf5bbc6bfc..533ead1ff29 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -611,7 +611,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, int do_face_idx buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); if (do_face_idx_array) EDBM_index_arrays_free(em); return NULL; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 668f34c60d3..bc11a627be6 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -808,16 +808,16 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) * contain the normal of the poly the face was tessellated from. */ face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface); - mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, - mesh->totloop, mesh->totpoly, - NULL /* polyNors_r */, - mesh->mface, mesh->totface, - polyindex, face_nors, FALSE); + BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, + mesh->totloop, mesh->totpoly, + NULL /* polyNors_r */, + mesh->mface, mesh->totface, + polyindex, face_nors, FALSE); #else - mesh_calc_normals(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL); + BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL); (void)polyindex; (void)face_nors; #endif @@ -1138,13 +1138,13 @@ void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_calc_normals(Mesh *mesh) { #ifdef USE_BMESH_MPOLY_NORMALS - mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL, NULL, 0, NULL, NULL, FALSE); + BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL, NULL, 0, NULL, NULL, FALSE); #else - mesh_calc_normals(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL); + BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL); #endif } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ef861164c92..9506836ab82 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1241,7 +1241,7 @@ static void curvetomesh(Scene *scene, Object *ob) if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); /* force creation */ - nurbs_to_mesh(ob); /* also does users */ + BKE_mesh_from_nurbs(ob); /* also does users */ if (ob->type == OB_MESH) BKE_object_free_modifiers(ob); @@ -1347,7 +1347,7 @@ static int convert_exec(bContext *C, wmOperator *op) newob = ob; } - mesh_to_curve(scene, newob); + BKE_mesh_from_curve(scene, newob); if (newob->type == OB_CURVE) BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ @@ -1509,7 +1509,7 @@ static int convert_exec(bContext *C, wmOperator *op) for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]); } - mball_to_mesh(&baseob->disp, newob->data); + BKE_mesh_from_metaball(&baseob->disp, newob->data); if (obact->type == OB_MBALL) { basact = basen; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index d6d7342f900..dfc99f09a96 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -749,10 +749,10 @@ static void copy_texture_space(Object *to, Object *ob) /* pass */ } else if (to->type == OB_MBALL) { - BKE_metaball_tex_space_calc(to); + BKE_metaball_texspace_calc(to); } else { - BKE_curve_tex_space_calc(to->data); + BKE_curve_texspace_calc(to->data); } } @@ -1256,7 +1256,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) { if (ob->type == OB_MESH) { - mesh_set_smooth_flag(ob, !clear); + BKE_mesh_smooth_flag_set(ob, !clear); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -1350,7 +1350,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) space = 1.0; if (ob->type == OB_MESH) { float size[3]; - mesh_get_texspace(ob->data, NULL, NULL, size); + BKE_mesh_texspace_get(ob->data, NULL, NULL, size); space = size[0] / size[1]; } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 785b9c0a9b7..4825697f8c3 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -491,7 +491,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } /* update normals */ - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } else if (ob->type == OB_ARMATURE) { ED_armature_apply_transform(ob, mat); @@ -772,11 +772,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_CENTROID) { mesh_center_median(me, cent); } - else { mesh_center_bounds(me, cent); } + else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); } + else { BKE_mesh_center_bounds(me, cent); } negate_v3_v3(cent_neg, cent); - mesh_translate(me, cent_neg, 1); + BKE_mesh_translate(me, cent_neg, 1); tot_change++; me->id.flag |= LIB_DOIT; diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index c96da7d52c6..a3c74b33f9e 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -328,9 +328,9 @@ static int hide_show_exec(bContext *C, wmOperator *op) /* ensure that edges and faces get hidden as well (not used by * sculpt but it looks wrong when entering editmode otherwise) */ if (pbvh_type == PBVH_FACES) { - mesh_flush_hidden_from_verts(me->mvert, me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_hidden_from_verts(me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } ED_region_tag_redraw(ar); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 09c7ecd6b48..cbebbff621f 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2371,7 +2371,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) for (a = 0; a < me->totvert; a++, mvert++) copy_v3_v3(mvert->co, vertCos[a]); - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } /* apply new coords on active key block */ @@ -2604,7 +2604,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) /* Modifiers could depend on mesh normals, so we should update them/ * Note, then if sculpting happens on locked key, normals should be re-calculated * after applying coords from keyblock on base mesh */ - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); } else if (ss->kb) { sculpt_update_keyblock(ob); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c08ed2e85b9..b021608a095 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -276,8 +276,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if (ss->modifiers_active) { Mesh *mesh = ob->data; - mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, - mesh->mface, mesh->totface, NULL); + BKE_mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, + mesh->mface, mesh->totface, NULL); free_sculptsession_deformMats(ss); tag_update |= 1; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 6c941765a57..b1f86fa5e69 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3599,7 +3599,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D finalDM->release(finalDM); } else { - /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ + /* don't create boundbox here with BKE_mesh_boundbox_get(), the derived system will make it, puts deformed bb's OK */ if (me->totpoly <= 4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb) ? ob->bb : me->bb)) { glsl = draw_glsl_material(scene, ob, v3d, dt); check_alpha = check_alpha_pass(base); @@ -6153,7 +6153,7 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) BoundBox *bb = NULL; if (ob->type == OB_MESH) { - bb = mesh_get_bb(ob); + bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { bb = ob->bb ? ob->bb : ( (Curve *)ob->data)->bb; @@ -6187,7 +6187,7 @@ static void drawtexspace(Object *ob) float vec[8][3], loc[3], size[3]; if (ob->type == OB_MESH) { - mesh_get_texspace(ob->data, loc, NULL, size); + BKE_mesh_texspace_get(ob->data, loc, NULL, size); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { Curve *cu = ob->data; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index a62ee6d78d1..96ec37d8fa0 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -205,7 +205,7 @@ static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), Po Curve *cu = (Curve*)ptr->data; if (cu->texflag & CU_AUTOSPACE) - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); } static int rna_Curve_texspace_editable(PointerRNA *ptr) @@ -219,7 +219,7 @@ static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values) Curve *cu = (Curve *)ptr->data; if (!cu->bb) - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); copy_v3_v3(values, cu->loc); } @@ -236,7 +236,7 @@ static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values) Curve *cu = (Curve *)ptr->data; if (!cu->bb) - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); copy_v3_v3(values, cu->size); } diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 0ecfa311913..436b6938e05 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -222,7 +222,7 @@ static float rna_MeshPolygon_area_get(PointerRNA *ptr) Mesh *me = (Mesh*)ptr->id.data; MPoly *mp = (MPoly*)ptr->data; - return mesh_calc_poly_area(mp, me->mloop+mp->loopstart, me->mvert, NULL); + return BKE_mesh_calc_poly_area(mp, me->mloop+mp->loopstart, me->mvert, NULL); } static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values) diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 41b232fdf8b..c0a9d19360d 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -42,7 +42,7 @@ #ifdef RNA_RUNTIME const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2) { - const char *ret = mesh_cmp(mesh, mesh2, FLT_EPSILON*60); + const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON*60); if (!ret) ret = "Same"; diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index e95e49e8150..f7531e1b556 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -110,9 +110,9 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ copycu->editfont = NULL; copycu->editnurb = NULL; - nurbs_to_mesh(tmpobj); + BKE_mesh_from_nurbs(tmpobj); - /* nurbs_to_mesh changes the type to a mesh, check it worked */ + /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked */ if (tmpobj->type != OB_MESH) { BKE_libblock_free_us(&(G.main->object), tmpobj); BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?"); @@ -136,11 +136,11 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ if (render) { ListBase disp = {NULL, NULL}; makeDispListMBall_forRender(sce, ob, &disp); - mball_to_mesh(&disp, tmpmesh); + BKE_mesh_from_metaball(&disp, tmpmesh); freedisplist(&disp); } else - mball_to_mesh(&ob->disp, tmpmesh); + BKE_mesh_from_metaball(&ob->disp, tmpmesh); break; } diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 57268d04947..df3f78b7f11 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -103,12 +103,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, cddm->getVertArray(cddm), mdisps); - mesh_flush_hidden_from_verts(cddm->getVertArray(cddm), - cddm->getLoopArray(cddm), - cddm->getEdgeArray(cddm), - cddm->getNumEdges(cddm), - cddm->getPolyArray(cddm), - cddm->getNumPolys(cddm)); + BKE_mesh_flush_hidden_from_verts(cddm->getVertArray(cddm), + cddm->getLoopArray(cddm), + cddm->getEdgeArray(cddm), + cddm->getNumEdges(cddm), + cddm->getPolyArray(cddm), + cddm->getNumPolys(cddm)); } } diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 6a173362ade..2e8faaae5bf 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -207,7 +207,7 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (* } if (orco) - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); + DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob)); } else if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { dm= CDDM_from_curve(ob); diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index ef8cf24987c..4e9e980e8b7 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -325,7 +325,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, float best_dot; /* get the untransformed face normal */ - mesh_calc_poly_normal_coords(mp, mloop + mp->loopstart, (const float (*)[3])coords, face_no); + BKE_mesh_calc_poly_normal_coords(mp, mloop + mp->loopstart, (const float (*)[3])coords, face_no); /* find the projector which the face points at most directly * (projector normal with largest dot product is best) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 75901008d9f..8d2456b3001 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -401,7 +401,7 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me) if (obr->totvert==0) return; - mesh_get_texspace(me, loc, NULL, size); + BKE_mesh_texspace_get(me, loc, NULL, size); accum= MEM_callocN(2*sizeof(float)*obr->totvert, "temp accum for stress"); From 2554a6788925b52a70ec9f90e33a57a373b1d04f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 01:03:51 +0000 Subject: [PATCH 088/143] Deleting action constraints (and a few others) now adjusts the usercounts of their referenced data correctly --- source/blender/blenkernel/intern/constraint.c | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 66209e8a924..0ce3807fecb 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4318,17 +4318,31 @@ bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con) /* ---------- Data Management ------- */ +/* helper function for free_constraint_data() - unlinks references */ +static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData)) +{ + if (*idpoin && isReference) + id_us_min(*idpoin); +} + /* Free data of a specific constraint if it has any info. * be sure to run BIK_clear_data() when freeing an IK constraint, - * unless DAG_scene_sort is called. */ + * unless DAG_scene_sort is called. + */ void free_constraint_data(bConstraint *con) { if (con->data) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - /* perform any special freeing constraint may have */ - if (cti && cti->free_data) - cti->free_data(con); + if (cti) { + /* perform any special freeing constraint may have */ + if (cti->free_data) + cti->free_data(con); + + /* unlink the referenced resources it uses */ + if (cti->id_looper) + cti->id_looper(con, con_unlink_refs_cb, NULL); + } /* free constraint data now */ MEM_freeN(con->data); From 7c58e6a9f2ac2d1022fba5c8df030e5df226583b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 01:27:48 +0000 Subject: [PATCH 089/143] Simplifying constraints code - removed relink_data() callbacks in favour of a more generic system which goes through id_looper(), reducing the maintainance burden for new constraint authors --- source/blender/blenkernel/BKE_constraint.h | 2 - source/blender/blenkernel/intern/constraint.c | 85 ++++--------------- 2 files changed, 17 insertions(+), 70 deletions(-) diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index b12ab538184..35d07e7a7a7 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -87,8 +87,6 @@ typedef struct bConstraintTypeInfo { /* data management function pointers - special handling */ /* free any data that is allocated separately (optional) */ void (*free_data)(struct bConstraint *con); - /* adjust pointer to other ID-data using ID_NEW(), but not to targets (optional) */ - void (*relink_data)(struct bConstraint *con); /* run the provided callback function on all the ID-blocks linked to the constraint */ void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata); /* copy any special data that is allocated separately (optional) */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 0ce3807fecb..9e47d136863 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -648,7 +648,6 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { "ConstrName", /* name */ "bConstrNameConstraint", /* struct name */ constrname_free, /* free data */ - constrname_relink, /* relink data */ constrname_id_looper, /* id looper */ constrname_copy, /* copy data */ constrname_new_data, /* new data */ @@ -874,7 +873,7 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta */ copy_m4_m4(tempmat, cob->matrix); mult_m4_m4m4(cob->matrix, parmat, tempmat); - + /* without this, changes to scale and rotation can change location * of a parentless bone or a disconnected bone. Even though its set * to zero above. */ @@ -892,7 +891,6 @@ static bConstraintTypeInfo CTI_CHILDOF = { "ChildOf", /* name */ "bChildOfConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ childof_id_looper, /* id looper */ NULL, /* copy data */ childof_new_data, /* new data */ @@ -1070,7 +1068,6 @@ static bConstraintTypeInfo CTI_TRACKTO = { "TrackTo", /* name */ "bTrackToConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ trackto_id_looper, /* id looper */ NULL, /* copy data */ trackto_new_data, /* new data */ @@ -1164,7 +1161,6 @@ static bConstraintTypeInfo CTI_KINEMATIC = { "IK", /* name */ "bKinematicConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ kinematic_id_looper, /* id looper */ NULL, /* copy data */ kinematic_new_data, /* new data */ @@ -1350,7 +1346,6 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = { "Follow Path", /* name */ "bFollowPathConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ followpath_id_looper, /* id looper */ NULL, /* copy data */ followpath_new_data, /* new data */ @@ -1399,7 +1394,6 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { "Limit Location", /* name */ "bLocLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1457,7 +1451,6 @@ static bConstraintTypeInfo CTI_ROTLIMIT = { "Limit Rotation", /* name */ "bRotLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1517,7 +1510,6 @@ static bConstraintTypeInfo CTI_SIZELIMIT = { "Limit Scaling", /* name */ "bSizeLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1608,7 +1600,6 @@ static bConstraintTypeInfo CTI_LOCLIKE = { "Copy Location", /* name */ "bLocateLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ loclike_id_looper, /* id looper */ NULL, /* copy data */ loclike_new_data, /* new data */ @@ -1721,7 +1712,6 @@ static bConstraintTypeInfo CTI_ROTLIKE = { "Copy Rotation", /* name */ "bRotateLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ rotlike_id_looper, /* id looper */ NULL, /* copy data */ rotlike_new_data, /* new data */ @@ -1818,7 +1808,6 @@ static bConstraintTypeInfo CTI_SIZELIKE = { "Copy Scale", /* name */ "bSizeLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ sizelike_id_looper, /* id looper */ NULL, /* copy data */ sizelike_new_data, /* new data */ @@ -1880,7 +1869,6 @@ static bConstraintTypeInfo CTI_TRANSLIKE = { "Copy Transforms", /* name */ "bTransLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ translike_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1937,7 +1925,6 @@ static bConstraintTypeInfo CTI_SAMEVOL = { "Maintain Volume", /* name */ "bSameVolumeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ samevolume_new_data, /* new data */ @@ -1961,13 +1948,6 @@ static void pycon_free (bConstraint *con) BLI_freelistN(&data->targets); } -static void pycon_relink (bConstraint *con) -{ - bPythonConstraint *data= con->data; - - ID_NEW(data->text); -} - static void pycon_copy (bConstraint *con, bConstraint *srccon) { bPythonConstraint *pycon = (bPythonConstraint *)con->data; @@ -2076,7 +2056,6 @@ static bConstraintTypeInfo CTI_PYTHON = { "Script", /* name */ "bPythonConstraint", /* struct name */ pycon_free, /* free data */ - pycon_relink, /* relink data */ pycon_id_looper, /* id looper */ pycon_copy, /* copy data */ pycon_new_data, /* new data */ @@ -2088,12 +2067,6 @@ static bConstraintTypeInfo CTI_PYTHON = { /* -------- Action Constraint ----------- */ -static void actcon_relink (bConstraint *con) -{ - bActionConstraint *data= con->data; - ID_NEW(data->act); -} - static void actcon_new_data (void *cdata) { bActionConstraint *data= (bActionConstraint *)cdata; @@ -2248,7 +2221,6 @@ static bConstraintTypeInfo CTI_ACTION = { "Action", /* name */ "bActionConstraint", /* struct name */ NULL, /* free data */ - actcon_relink, /* relink data */ actcon_id_looper, /* id looper */ NULL, /* copy data */ actcon_new_data, /* new data */ @@ -2560,7 +2532,6 @@ static bConstraintTypeInfo CTI_LOCKTRACK = { "Locked Track", /* name */ "bLockTrackConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ locktrack_id_looper, /* id looper */ NULL, /* copy data */ locktrack_new_data, /* new data */ @@ -2685,7 +2656,6 @@ static bConstraintTypeInfo CTI_DISTLIMIT = { "Limit Distance", /* name */ "bDistLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ distlimit_id_looper, /* id looper */ NULL, /* copy data */ distlimit_new_data, /* new data */ @@ -2860,7 +2830,6 @@ static bConstraintTypeInfo CTI_STRETCHTO = { "Stretch To", /* name */ "bStretchToConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ stretchto_id_looper, /* id looper */ NULL, /* copy data */ stretchto_new_data, /* new data */ @@ -3005,7 +2974,6 @@ static bConstraintTypeInfo CTI_MINMAX = { "Floor", /* name */ "bMinMaxConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ minmax_id_looper, /* id looper */ NULL, /* copy data */ minmax_new_data, /* new data */ @@ -3066,7 +3034,6 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = { "Rigid Body Joint", /* name */ "bRigidBodyJointConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ rbj_id_looper, /* id looper */ NULL, /* copy data */ rbj_new_data, /* new data */ @@ -3242,7 +3209,6 @@ static bConstraintTypeInfo CTI_CLAMPTO = { "Clamp To", /* name */ "bClampToConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ clampto_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -3389,7 +3355,6 @@ static bConstraintTypeInfo CTI_TRANSFORM = { "Transform", /* name */ "bTransformConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ transform_id_looper, /* id looper */ NULL, /* copy data */ transform_new_data, /* new data */ @@ -3547,7 +3512,6 @@ static bConstraintTypeInfo CTI_SHRINKWRAP = { "Shrinkwrap", /* name */ "bShrinkwrapConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ shrinkwrap_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -3675,7 +3639,6 @@ static bConstraintTypeInfo CTI_DAMPTRACK = { "Damped Track", /* name */ "bDampTrackConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ damptrack_id_looper, /* id looper */ NULL, /* copy data */ damptrack_new_data, /* new data */ @@ -3773,7 +3736,6 @@ static bConstraintTypeInfo CTI_SPLINEIK = { "Spline IK", /* name */ "bSplineIKConstraint", /* struct name */ splineik_free, /* free data */ - NULL, /* relink data */ splineik_id_looper, /* id looper */ splineik_copy, /* copy data */ splineik_new_data, /* new data */ @@ -3898,7 +3860,6 @@ static bConstraintTypeInfo CTI_PIVOT = { "Pivot", /* name */ "bPivotConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ pivotcon_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ // XXX: might be needed to get 'normal' pivot behavior... @@ -4092,7 +4053,6 @@ static bConstraintTypeInfo CTI_FOLLOWTRACK = { "Follow Track", /* name */ "bFollowTrackConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ followtrack_id_looper, /* id looper */ NULL, /* copy data */ followtrack_new_data, /* new data */ @@ -4147,7 +4107,6 @@ static bConstraintTypeInfo CTI_CAMERASOLVER = { "Camera Solver", /* name */ "bCameraSolverConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ camerasolver_id_looper, /* id looper */ NULL, /* copy data */ camerasolver_new_data, /* new data */ @@ -4221,7 +4180,6 @@ static bConstraintTypeInfo CTI_OBJECTSOLVER = { "Object Solver", /* name */ "bObjectSolverConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ objectsolver_id_looper, /* id looper */ NULL, /* copy data */ objectsolver_new_data, /* new data */ @@ -4501,36 +4459,27 @@ bConstraint *add_ob_constraint(Object *ob, const char *name, short type) /* ......... */ +/* helper for relink_constraints() - call ID_NEW() on every ID reference the constraint has */ +static void con_relink_id_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userdata)) +{ + /* ID_NEW() expects a struct with inline "id" member as first + * since we've got the actual ID block, let's just inline this + * code. + * + * See ID_NEW(a) in BKE_utildefines.h + */ + if ((*idpoin) && (*idpoin)->newid) + (*idpoin) = (void *)(*idpoin)->newid; +} + /* Reassign links that constraints have to other data (called during file loading?) */ void relink_constraints(ListBase *conlist) { - bConstraint *con; - bConstraintTarget *ct; - - for (con= conlist->first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - - if (cti) { - /* relink any targets */ - if (cti->get_constraint_targets) { - ListBase targets = {NULL, NULL}; - - cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { - ID_NEW(ct->tar); - } - - if (cti->flush_constraint_targets) - cti->flush_constraint_targets(con, &targets, 0); - } - - /* relink any other special data */ - if (cti->relink_data) - cti->relink_data(con); - } - } + /* just a wrapper around ID-loop for just calling ID_NEW() on all ID refs */ + id_loop_constraints(conlist, con_relink_id_cb, NULL); } + /* Run the given callback on all ID-blocks in list of constraints */ void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdata) { From 5d02292d3cbdc1eb8657a2e186de7ac38bc226b7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 04:18:13 +0000 Subject: [PATCH 090/143] Bugfixes for Motion Path drawing/updating in light of the recent changes: * Added proper "update" operators in place of the abuse of the calculate operators, so now the display ranges won't get overwritten everytime (with the default values) you go to update the paths. * Display range settings in properties editor now actually work. Before, the "In Range" mode only displayed the entire paths. --- .../startup/bl_ui/properties_animviz.py | 6 +-- .../editors/armature/armature_intern.h | 1 + .../blender/editors/armature/armature_ops.c | 1 + source/blender/editors/armature/poseobject.c | 36 +++++++++++++ source/blender/editors/object/object_edit.c | 34 +++++++++++++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + .../editors/space_view3d/drawanimviz.c | 50 ++++++++++++------- 8 files changed, 107 insertions(+), 23 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py index 3f25006766e..1f798f46590 100644 --- a/release/scripts/startup/bl_ui/properties_animviz.py +++ b/release/scripts/startup/bl_ui/properties_animviz.py @@ -65,12 +65,10 @@ class MotionPathButtonsPanel(): sub.prop(mpath, "frame_start", text="From") sub.prop(mpath, "frame_end", text="To") - sub = col.column() # align=True - sub.operator_context = 'EXEC_DEFAULT' if bones: - col.operator("pose.paths_calculate", text="Update", icon='BONE_DATA') + col.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA') else: - col.operator("object.paths_calculate", text="Update", icon='OBJECT_DATA') + col.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA') else: col.label(text="Not available yet...", icon='ERROR') col.label(text="Calculate Paths first", icon='INFO') diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 72d261ec187..11129f34f3e 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -117,6 +117,7 @@ void POSE_OT_group_select(struct wmOperatorType *ot); void POSE_OT_group_deselect(struct wmOperatorType *ot); void POSE_OT_paths_calculate(struct wmOperatorType *ot); +void POSE_OT_paths_update(struct wmOperatorType *ot); void POSE_OT_paths_clear(struct wmOperatorType *ot); void POSE_OT_autoside_names(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 9a15a100179..d7814e1eb4c 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -133,6 +133,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_group_deselect); WM_operatortype_append(POSE_OT_paths_calculate); + WM_operatortype_append(POSE_OT_paths_update); WM_operatortype_append(POSE_OT_paths_clear); WM_operatortype_append(POSE_OT_autoside_names); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 15d2d32c073..2ed5421e8ba 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -197,6 +197,7 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -291,6 +292,41 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) /* --------- */ +static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + + if (ELEM(NULL, ob, scene)) + return OPERATOR_CANCELLED; + + /* calculate the bones that now have motionpaths... */ + // TODO: only make for the selected bones? + ED_pose_recalculate_paths(scene, ob); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + + return OPERATOR_FINISHED; +} + +void POSE_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Bone Paths"; + ot->idname = "POSE_OT_paths_update"; + ot->description = "Recalculate paths for bones that already have them"; + + /* api callbakcs */ + ot->exec = pose_update_paths_exec; + ot->poll = ED_operator_posemode; /* TODO: this should probably check for active bone and/or existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + /* for the object with pose/action: clear path curves for selected bones only */ static void ED_pose_clear_paths(Object *ob) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index dfc99f09a96..96099d51dc9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1125,6 +1125,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -1200,6 +1201,39 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) /* --------- */ +static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + + if (scene == NULL) + return OPERATOR_CANCELLED; + + /* calculate the paths for objects that have them (and are tagged to get refreshed) */ + ED_objects_recalculate_paths(C, scene); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Object Paths"; + ot->idname = "OBJECT_OT_paths_update"; + ot->description = "Recalculate paths for selected objects"; + + /* api callbakcs */ + ot->exec = object_update_paths_exec; + ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + /* Clear motion paths for selected objects only */ void ED_objects_clear_paths(bContext *C) { diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ee9d776ea3b..e834c93b0d8 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -84,6 +84,7 @@ void OBJECT_OT_proxy_make(struct wmOperatorType *ot); void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); void OBJECT_OT_shade_flat(struct wmOperatorType *ot); void OBJECT_OT_paths_calculate(struct wmOperatorType *ot); +void OBJECT_OT_paths_update(struct wmOperatorType *ot); void OBJECT_OT_paths_clear(struct wmOperatorType *ot); void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index feb7c075264..b7dc3fd7bea 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -77,6 +77,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_shade_smooth); WM_operatortype_append(OBJECT_OT_shade_flat); WM_operatortype_append(OBJECT_OT_paths_calculate); + WM_operatortype_append(OBJECT_OT_paths_update); WM_operatortype_append(OBJECT_OT_paths_clear); WM_operatortype_append(OBJECT_OT_forcefield_toggle); diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index a9801012d67..f8d942b4fd1 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -88,38 +88,50 @@ void draw_motion_path_instance(Scene *scene, //RegionView3D *rv3d= ar->regiondata; bMotionPathVert *mpv, *mpv_start; int i, stepsize = avs->path_step; - int sfra, efra, len; - + int sfra, efra, sind, len; /* get frame ranges */ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) { - int sind; - /* With "Around Current", we only choose frames from around - * the current frame to draw. However, this range is still - * restricted by the limits of the original path. + * the current frame to draw. */ sfra = CFRA - avs->path_bc; efra = CFRA + avs->path_ac; - if (sfra < mpath->start_frame) sfra = mpath->start_frame; - if (efra > mpath->end_frame) efra = mpath->end_frame; - - len = efra - sfra; - - sind = sfra - mpath->start_frame; - mpv_start = (mpath->points + sind); } else { - sfra = mpath->start_frame; - efra = sfra + mpath->length; - len = mpath->length; - mpv_start = mpath->points; + /* Use the current display range */ + sfra = avs->path_sf; + efra = avs->path_ef; } - + + /* no matter what, we can only show what is in the cache and no more + * - abort if whole range is past ends of path + * - otherwise clamp endpoints to extents of path + */ + if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) { + /* whole path is out of bounds */ + return; + } + + if (sfra < mpath->start_frame) { + /* start clamp */ + sfra = mpath->start_frame; + } + if (efra > mpath->end_frame) { + /* end clamp */ + efra = mpath->end_frame; + } + + len = efra - sfra; + if (len <= 0) { return; } - + + /* get pointers to parts of path */ + sind = sfra - mpath->start_frame; + mpv_start = (mpath->points + sind); + /* draw curve-line of path */ glShadeModel(GL_SMOOTH); From 364388b9f2a2ddc838f8182537c1ddf3f0ea0f0b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 04:50:04 +0000 Subject: [PATCH 091/143] Removing the old armature 'deform' settings (use vertex groups/envelopes/quats). As far as I could tell, these were really only still used for "virtual modifiers", though we really don't use these anymore. Instead, most of the time, people need to set these settings in armature modifiers directly (these didn't even get copied over in that case). This was a source of confusion and redundancy, so removing these now. This change can be reverted if these were actually of some use out there... --- .../startup/bl_ui/properties_data_armature.py | 10 +++---- source/blender/blenkernel/intern/modifier.c | 1 + source/blender/collada/SkinInfo.cpp | 5 ++-- source/blender/makesrna/intern/rna_armature.c | 26 +------------------ 4 files changed, 8 insertions(+), 34 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 63dc64190bb..529d7c5f981 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -65,14 +65,10 @@ class DATA_PT_skeleton(ArmatureButtonsPanel, Panel): col.label(text="Protected Layers:") col.prop(arm, "layers_protected", text="") - layout.label(text="Deform:") - flow = layout.column_flow() - flow.prop(arm, "use_deform_vertex_groups", text="Vertex Groups") - flow.prop(arm, "use_deform_envelopes", text="Envelopes") - flow.prop(arm, "use_deform_preserve_volume", text="Quaternion") - if context.scene.render.engine == 'BLENDER_GAME': - layout.row().prop(arm, "deform_method", expand=True) + col = layout.column() + col.label(text="Deform:") + col.prop(arm, "deform_method", expand=True) class DATA_PT_display(ArmatureButtonsPanel, Panel): diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 98cbc957201..5b824c04836 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -416,6 +416,7 @@ ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, in return tmp_md; } +/* NOTE: these aren't used anymore */ ModifierData *modifiers_getVirtualModifierList(Object *ob) { /* Kinda hacky, but should be fine since we are never diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index f7cb7dc96c2..edc8981deab 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -218,7 +218,8 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapobject = ob_arm; + ArmatureModifierData *amd = (ArmatureModifierData *)md; + amd->object = ob_arm; copy_m4_m4(ob->obmat, bind_shape_matrix); BKE_object_apply_mat4(ob, ob->obmat, 0, 0); @@ -239,7 +240,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapdata)->deformflag = ARM_DEF_VGROUP; + amd->deformflag = ARM_DEF_VGROUP; // create all vertex groups std::vector::iterator it; diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 79b776572cf..c97a4751135 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -894,7 +894,7 @@ static void rna_def_armature(BlenderRNA *brna) prop = RNA_def_property(srna, "deform_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "gevertdeformer"); RNA_def_property_enum_items(prop, prop_vdeformer); - RNA_def_property_ui_text(prop, "Vertex Deformer", ""); + RNA_def_property_ui_text(prop, "Vertex Deformer", "Vertex Deformer Method (Game Engine only)"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); @@ -973,30 +973,6 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); /* XXX depreceated ....... old animviz for armatures only */ - - /* deformflag */ - prop = RNA_def_property(srna, "use_deform_vertex_groups", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); - RNA_def_property_ui_text(prop, "Deform Vertex Groups", "Enable Vertex Groups when defining deform"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - - prop = RNA_def_property(srna, "use_deform_envelopes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); - RNA_def_property_ui_text(prop, "Deform Envelopes", "Enable Bone Envelopes when defining deform"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - - prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION); - RNA_def_property_ui_text(prop, "Use Dual Quaternion Deformation", "Enable deform rotation with Quaternions"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - -#if 0 - prop = RNA_def_property(srna, "deform_invert_vertexgroups", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); - RNA_def_property_ui_text(prop, "Invert Vertex Group Influence", - "Invert Vertex Group influence (only for Modifiers)"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); -#endif /* Number fields */ /* XXX depreceated ....... old animviz for armatures only */ From 6f09dffa367944f1f6c13a71b6494b2c41633a2b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 05:03:58 +0000 Subject: [PATCH 092/143] Bugfix: While testing the other my previous commit (removing deformflag stuff), I noticed that trying to change set a parent object for the current object (via the Object Properties) would cause the current object to "blow up", and for cyclic dependency warnings to be spewed to the console. Adding a dummy usage of one of the vars here seems to solve it. Perhaps a case of weirdo compiler optimisations? --- source/blender/makesrna/intern/rna_object.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 38f0b7e26cb..ca18eac8e60 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -383,8 +383,11 @@ static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object*)ptr->data; Object *par = (Object*)value.data; - - ED_object_parent(ob, par, ob->partype, ob->parsubstr); + + /* NOTE: this dummy check here prevents this method causing weird runtime errors on mingw 4.6.2 */ + if (ob) { + ED_object_parent(ob, par, ob->partype, ob->parsubstr); + } } static void rna_Object_parent_type_set(PointerRNA *ptr, int value) From 8ce144b8562f936fd7b2499b1018173747c7cedd Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Sun, 6 May 2012 05:50:50 +0000 Subject: [PATCH 093/143] typo, agle -> angle --- .../BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h index 4fdac113378..ab745ca5ad6 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h @@ -354,7 +354,7 @@ public: //! Calcs global transform of the offsets /*! - Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies. + Calcs the global transform for the joint offset for body A an B, and also calcs the angle differences between the bodies. \sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofConstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleInfo */ void calculateTransforms(const btTransform& transA,const btTransform& transB); From 1cf2c099f7a88338b278304b08036dba71a0b522 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 06:37:07 +0000 Subject: [PATCH 094/143] Bugfix [#31297] Transform menu often showed operators which didn't make sense for the contexts they appeared in The VIEW3D_MT_transform menu was being used everywhere, although not all the operators there applied to the current mode (e.g. the pivot point, animated transforms to deltas, and a few others were Object-mode only). Split off the offending parts into separate menus for the specific modes, and made these extend the basic menu type. --- release/scripts/startup/bl_ui/space_view3d.py | 63 +++++++++++++++---- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 8070b60126a..4e044eb243f 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -135,7 +135,9 @@ class ShowHideMenu(): layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True -class VIEW3D_MT_transform(Menu): +# Standard transforms which apply to all cases +# NOTE: this doesn't seem to be able to be used directly +class VIEW3D_MT_transform_base(Menu): bl_label = "Transform" # TODO: get rid of the custom text strings? @@ -156,22 +158,38 @@ class VIEW3D_MT_transform(Menu): layout.operator("transform.warp", text="Warp") layout.operator("transform.push_pull", text="Push/Pull") + +# Generic transform menu - geometry types +class VIEW3D_MT_transform(VIEW3D_MT_transform_base): + def draw(self, context): + # base menu + VIEW3D_MT_transform_base.draw(self, context) + + # generic... + layout = self.layout layout.separator() layout.operator("transform.translate", text="Move Texture Space").texture_space = True layout.operator("transform.resize", text="Scale Texture Space").texture_space = True + +# Object-specific extensions to Transform menu +class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base): + def draw(self, context): + # base menu + VIEW3D_MT_transform_base.draw(self, context) + + # object-specific option follow... + layout = self.layout layout.separator() - obj = context.object - if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and obj.data.draw_type in {'BBONE', 'ENVELOPE'}: - layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE' - - if context.edit_object and context.edit_object.type == 'ARMATURE': - layout.operator("armature.align") - else: - layout.operator_context = 'EXEC_REGION_WIN' - layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working + layout.operator("transform.translate", text="Move Texture Space").texture_space = True + layout.operator("transform.resize", text="Scale Texture Space").texture_space = True + + layout.separator() + + layout.operator_context = 'EXEC_REGION_WIN' + layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working layout.separator() @@ -191,6 +209,25 @@ class VIEW3D_MT_transform(Menu): layout.operator("object.anim_transforms_to_deltas") +# Armature EditMode extensions to Transform menu +class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base): + def draw(self, context): + # base menu + VIEW3D_MT_transform_base.draw(self, context) + + # armature specific extensions follow... + layout = self.layout + layout.separator() + + obj = context.object + if (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and + obj.data.draw_type in {'BBONE', 'ENVELOPE'}): + layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE' + + if context.edit_object and context.edit_object.type == 'ARMATURE': + layout.operator("armature.align") + + class VIEW3D_MT_mirror(Menu): bl_label = "Mirror" @@ -704,7 +741,7 @@ class VIEW3D_MT_object(Menu): layout.separator() - layout.menu("VIEW3D_MT_transform") + layout.menu("VIEW3D_MT_transform_object") layout.menu("VIEW3D_MT_mirror") layout.menu("VIEW3D_MT_object_clear") layout.menu("VIEW3D_MT_object_apply") @@ -1322,7 +1359,7 @@ class VIEW3D_MT_pose(Menu): layout.separator() - layout.menu("VIEW3D_MT_transform") + layout.menu("VIEW3D_MT_transform_armature") layout.menu("VIEW3D_MT_pose_transform") layout.menu("VIEW3D_MT_pose_apply") @@ -2077,7 +2114,7 @@ class VIEW3D_MT_edit_armature(Menu): edit_object = context.edit_object arm = edit_object.data - layout.menu("VIEW3D_MT_transform") + layout.menu("VIEW3D_MT_transform_armature") layout.menu("VIEW3D_MT_mirror") layout.menu("VIEW3D_MT_snap") layout.menu("VIEW3D_MT_edit_armature_roll") From d2d272711dd795d502ff773de890d8bf3f715cfa Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 06:57:02 +0000 Subject: [PATCH 095/143] Timeline Header: Only show the "use active keyingset only" toggle (beside the autokey button) if autokeying is enabled. This was only useful when the latter was actually enabled. --- release/scripts/startup/bl_ui/space_time.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 7720fddb084..8fb587e2634 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -81,10 +81,12 @@ class TIME_HT_header(Header): row = layout.row(align=True) row.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True) - row.prop(toolsettings, "use_keyframe_insert_keyingset", text="", toggle=True) - if screen.is_animation_playing and toolsettings.use_keyframe_insert_auto: - subsub = row.row() - subsub.prop(toolsettings, "use_record_with_nla", toggle=True) + if toolsettings.use_keyframe_insert_auto: + row.prop(toolsettings, "use_keyframe_insert_keyingset", text="", toggle=True) + + if screen.is_animation_playing: + subsub = row.row() + subsub.prop(toolsettings, "use_record_with_nla", toggle=True) row = layout.row(align=True) row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="") From b65cc42145f8f32b165fa46b799a6d7081c15957 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 6 May 2012 07:59:37 +0000 Subject: [PATCH 096/143] Fix for [#31327] Text editor menu incorrect (Patch attached) Patch by Justin Dailey, thx! --- release/scripts/startup/bl_ui/space_text.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index dd752431df9..d1daa4a5554 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -277,8 +277,10 @@ class TEXT_MT_edit(Menu): layout.separator() - layout.operator("text.move_lines_up") - layout.operator("text.move_lines_down") + layout.operator("text.move_lines", + text="Move line(s) up").direction = 'UP' + layout.operator("text.move_lines", + text="Move line(s) down").direction = 'DOWN' layout.separator() From 1755dc74773cfeee5ca190410b9cc6393c093009 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 09:41:38 +0000 Subject: [PATCH 097/143] Bugfix [#31330] Shape Key Editor does not switch to assigned Key Action --- source/blender/editors/animation/anim_filter.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 180953ea017..2f0f396eb10 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -137,7 +137,7 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) if (ac->obact && ac->obact->adt) saction->action = ac->obact->adt->action; else - saction->action= NULL; + saction->action = NULL; } ac->datatype= ANIMCONT_ACTION; @@ -150,6 +150,16 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) ac->datatype= ANIMCONT_SHAPEKEY; ac->data= actedit_get_shapekeys(ac); + /* if not pinned, sync with active object */ + if (/*saction->pin == 0*/1) { + Key *key = (Key *)ac->data; + + if (key && key->adt) + saction->action = key->adt->action; + else + saction->action = NULL; + } + ac->mode= saction->mode; return 1; From e17a708dce17c2d85cfecb1330278a47b4d1be19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 12:13:45 +0000 Subject: [PATCH 098/143] add back pose specials menu, also add back the ability to clear user transforms on all bones (not just selected - mango request - was possible in 2.4x). - rename only_select op property to only_selected (both were used). - only do mingw workaround when building with FREE_WINDOWS defined. --- release/scripts/startup/bl_ui/space_view3d.py | 18 ++++++++++++++++++ source/blender/blenkernel/intern/library.c | 3 ++- source/blender/editors/armature/armature_ops.c | 3 +++ source/blender/editors/armature/poseobject.c | 8 ++++++-- source/blender/editors/mesh/editmesh_knife.c | 4 ++-- source/blender/editors/mesh/mesh_ops.c | 4 ++-- source/blender/makesrna/intern/rna_object.c | 5 ++++- 7 files changed, 37 insertions(+), 8 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 4e044eb243f..629a2ec323d 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1538,6 +1538,24 @@ class VIEW3D_MT_pose_apply(Menu): layout.operator("pose.visual_transform_apply") +class VIEW3D_MT_pose_specials(Menu): + bl_label = "Specials" + + def draw(self, context): + layout = self.layout + layout.operator("pose.select_constraint_target") + layout.operator("pose.flip_names") + layout.operator("pose.paths_calculate") + layout.operator("pose.paths_clear") + layout.operator("pose.user_transforms_clear") + layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False + layout.operator("pose.relax") + + layout.separator() + + layout.operator_menu_enum("pose.autoside_names", "axis") + + class BoneOptions: def draw(self, context): layout = self.layout diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 20444045c1c..bdd314f52f5 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -945,7 +945,8 @@ void free_main(Main *mainvar) ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or "MA" etc */ { - ListBase *lb= which_libbase(G.main, type); + ListBase *lb = which_libbase(G.main, type); + BLI_assert(lb != NULL); return BLI_findstring(lb, name, offsetof(ID, name) + 2); } diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index d7814e1eb4c..ab8bfb2b98a 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -402,5 +402,8 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "POSE_OT_push", EKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "POSE_OT_relax", EKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_breakdown", EKEY, KM_PRESS, KM_SHIFT, 0); + + /* menus */ + WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_specials", WKEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 2ed5421e8ba..8cc0251e024 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -2302,11 +2302,12 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot) /* ********************************************** */ /* Clear User Transforms */ -static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_clear_user_transforms_exec (bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); float cframe = (float)CFRA; + const short only_select = RNA_boolean_get(op->ptr, "only_selected"); if ((ob->adt) && (ob->adt->action)) { /* XXX: this is just like this to avoid contaminating anything else; @@ -2329,7 +2330,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) /* copy back values, but on selected bones only */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { - pose_bone_do_paste(ob, pchan, 1, 0); + pose_bone_do_paste(ob, pchan, only_select, 0); } /* free temp data - free manually as was copied without constraints */ @@ -2373,5 +2374,8 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "only_selected", TRUE, "Only Selected", "Only visible/selected bones"); } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 57d7869d3db..5a99ddb9332 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2785,7 +2785,7 @@ static int knifetool_init(bContext *C, wmOperator *op, int UNUSED(do_cut)) DerivedMesh *cage, *final; SmallHash shash; void *data[3]; - const short only_select = RNA_boolean_get(op->ptr, "only_select"); + const short only_select = RNA_boolean_get(op->ptr, "only_selected"); /* alloc new customdata */ kcd = op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), "knifetool Modal Op Data"); @@ -3086,5 +3086,5 @@ void MESH_OT_knife_tool(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_boolean(ot->srna, "use_occlude_geometry", TRUE, "Occlude Geometry", "Only cut the front most geometry"); - RNA_def_boolean(ot->srna, "only_select", FALSE, "Only Selected", "Only cut selected geometry"); + RNA_def_boolean(ot->srna, "only_selected", FALSE, "Only Selected", "Only cut selected geometry"); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index e57285cca25..9789fd03222 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -353,11 +353,11 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", TRUE); - RNA_boolean_set(kmi->ptr, "only_select", FALSE); + RNA_boolean_set(kmi->ptr, "only_selected", FALSE); kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", FALSE); - RNA_boolean_set(kmi->ptr, "only_select", TRUE); + RNA_boolean_set(kmi->ptr, "only_selected", TRUE); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index ca18eac8e60..3a1bf78ea29 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -384,8 +384,11 @@ static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value) Object *ob = (Object*)ptr->data; Object *par = (Object*)value.data; +#ifdef FREE_WINDOWS /* NOTE: this dummy check here prevents this method causing weird runtime errors on mingw 4.6.2 */ - if (ob) { + if (ob) +#endif + { ED_object_parent(ob, par, ob->partype, ob->parsubstr); } } From eae05ff5413c07b8b3bb2eb3b3640af96af8ef39 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 May 2012 12:37:19 +0000 Subject: [PATCH 099/143] Bugfix [#31003] Animation data (e.g. actions, drivers) from the active material of a material nodetree was not visible in the Animation Editors --- .../blender/editors/animation/anim_filter.c | 112 +++++++++++------- 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 2f0f396eb10..d9f735f0559 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1475,51 +1475,83 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data return items; } + +static size_t animdata_filter_ds_material (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Material *ma, int filter_mode) +{ + ListBase tmp_data = {NULL, NULL}; + size_t tmp_items = 0; + size_t items = 0; + + /* add material's animation data to temp collection */ + BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) + { + /* material's animation data */ + tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); + + /* textures */ + if (!(ads->filterflag & ADS_FILTER_NOTEX)) + tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); + + /* nodes */ + if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) + tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); + } + END_ANIMFILTER_SUBCHANNELS; + + /* did we find anything? */ + if (tmp_items) { + /* include material-expand widget first */ + // hmm... do we need to store the index of this material in the array anywhere? + if (filter_mode & ANIMFILTER_LIST_CHANNELS) { + /* check if filtering by active status */ + if (ANIMCHANNEL_ACTIVEOK(ma)) { + ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); + } + } + + /* now add the list of collected channels */ + BLI_movelisttolist(anim_data, &tmp_data); + BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + items += tmp_items; + } + + return items; +} + static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { - size_t items=0; - int a=0; + short has_nested = 0; + size_t items = 0; + int a = 0; - /* firstly check that we actuallly have some materials, by gathering all materials in a temp list */ - for (a=1; a <= ob->totcol; a++) { - Material *ma= give_current_material(ob, a); - ListBase tmp_data = {NULL, NULL}; - size_t tmp_items = 0; + /* first pass: take the materials referenced via the Material slots of the object */ + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); - /* if no material returned, skip - so that we don't get weird blank entries... */ - if (ma == NULL) continue; - - /* add material's animation data to temp collection */ - BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) - { - /* material's animation data */ - tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); - - /* textures */ - if (!(ads->filterflag & ADS_FILTER_NOTEX)) - tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); - - /* nodes */ - if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) - tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); - } - END_ANIMFILTER_SUBCHANNELS; - - /* did we find anything? */ - if (tmp_items) { - /* include material-expand widget first */ - // hmm... do we need to store the index of this material in the array anywhere? - if (filter_mode & ANIMFILTER_LIST_CHANNELS) { - /* check if filtering by active status */ - if (ANIMCHANNEL_ACTIVEOK(ma)) { - ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); - } - } + /* if material is valid, try to add relevant contents from here */ + if (ma) { + /* add channels */ + items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); - /* now add the list of collected channels */ - BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); - items += tmp_items; + /* for optimising second pass - check if there's a nested material here to come back for */ + if (has_nested == 0) + has_nested = give_node_material(ma) != NULL; + } + } + + /* second pass: go through a second time looking for "nested" materials (material.material references) + * + * NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to why these are + * disappearing/not available, since the relationships between these is not that clear + */ + if (has_nested) { + for (a = 1; a <= ob->totcol; a++) { + Material *base = give_current_material(ob, a); + Material *ma = give_node_material(base); + + /* add channels from the nested material if it exists */ + if (ma) + items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); } } From 71028de93b329a6568090606ebe4d7c6a9ec1034 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 12:52:42 +0000 Subject: [PATCH 100/143] fix for error in MOD_weightvgmix.c caused by confusion without braces. CustomData_add_layer_named would run even when the dvert layer was found. --- source/blender/modifiers/intern/MOD_weightvgmix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index b7bbc717981..adcabc23efb 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -258,7 +258,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ - if (!dvert) + if (!dvert) { /* If not affecting all vertices, just return. */ if (wmd->mix_set != MOD_WVG_SET_ALL) return dm; @@ -268,7 +268,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Ultimate security check. */ if (!dvert) return dm; - + } /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); tdw1 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw1"); From 900c8a91548ab867391aa8d130cd03ff2d0e3d21 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 13:00:56 +0000 Subject: [PATCH 101/143] fix for same bug as r46346, incorrect code was copied. --- source/blender/modifiers/intern/MOD_weightvgedit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index b8961870043..0ef27ed992e 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -211,7 +211,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ - if (!dvert) + if (!dvert) { /* If this modifier is not allowed to add vertices, just return. */ if (!do_add) return dm; @@ -221,6 +221,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Ultimate security check. */ if (!dvert) return dm; + } /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); From 3d8e58751c3801a6ad2e00ed7c35059e827059b2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 13:38:33 +0000 Subject: [PATCH 102/143] style cleanup: modifiers --- .../blender/modifiers/intern/MOD_armature.c | 68 +-- source/blender/modifiers/intern/MOD_array.c | 101 ++-- source/blender/modifiers/intern/MOD_bevel.c | 72 +-- source/blender/modifiers/intern/MOD_boolean.c | 82 +-- .../modifiers/intern/MOD_boolean_util.c | 148 ++--- .../modifiers/intern/MOD_boolean_util.h | 3 +- source/blender/modifiers/intern/MOD_build.c | 70 +-- source/blender/modifiers/intern/MOD_cast.c | 75 ++- source/blender/modifiers/intern/MOD_cloth.c | 30 +- .../blender/modifiers/intern/MOD_collision.c | 30 +- source/blender/modifiers/intern/MOD_curve.c | 86 +-- .../blender/modifiers/intern/MOD_decimate.c | 74 +-- .../blender/modifiers/intern/MOD_displace.c | 58 +- .../modifiers/intern/MOD_dynamicpaint.c | 57 +- .../blender/modifiers/intern/MOD_edgesplit.c | 34 +- source/blender/modifiers/intern/MOD_explode.c | 562 +++++++++--------- .../blender/modifiers/intern/MOD_fluidsim.c | 41 +- .../modifiers/intern/MOD_fluidsim_util.c | 96 +-- source/blender/modifiers/intern/MOD_hook.c | 50 +- source/blender/modifiers/intern/MOD_lattice.c | 40 +- source/blender/modifiers/intern/MOD_mask.c | 82 +-- .../blender/modifiers/intern/MOD_meshdeform.c | 220 +++---- source/blender/modifiers/intern/MOD_mirror.c | 38 +- .../blender/modifiers/intern/MOD_multires.c | 26 +- source/blender/modifiers/intern/MOD_none.c | 4 +- source/blender/modifiers/intern/MOD_ocean.c | 138 ++--- .../modifiers/intern/MOD_particleinstance.c | 220 +++---- .../modifiers/intern/MOD_particlesystem.c | 76 +-- source/blender/modifiers/intern/MOD_remesh.c | 67 ++- source/blender/modifiers/intern/MOD_screw.c | 464 ++++++++------- .../blender/modifiers/intern/MOD_shapekey.c | 58 +- .../blender/modifiers/intern/MOD_shrinkwrap.c | 107 ++-- .../modifiers/intern/MOD_simpledeform.c | 128 ++-- source/blender/modifiers/intern/MOD_smoke.c | 48 +- source/blender/modifiers/intern/MOD_smooth.c | 54 +- .../blender/modifiers/intern/MOD_softbody.c | 16 +- .../blender/modifiers/intern/MOD_solidify.c | 286 ++++----- source/blender/modifiers/intern/MOD_subsurf.c | 44 +- source/blender/modifiers/intern/MOD_surface.c | 34 +- source/blender/modifiers/intern/MOD_util.c | 46 +- .../blender/modifiers/intern/MOD_uvproject.c | 118 ++-- source/blender/modifiers/intern/MOD_warp.c | 124 ++-- source/blender/modifiers/intern/MOD_wave.c | 146 +++-- .../modifiers/intern/MOD_weightvg_util.c | 106 ++-- .../modifiers/intern/MOD_weightvgedit.c | 36 +- .../modifiers/intern/MOD_weightvgmix.c | 186 +++--- .../modifiers/intern/MOD_weightvgproximity.c | 66 +- 47 files changed, 2371 insertions(+), 2344 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index fd9730238f5..ce4d726e072 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -56,15 +56,15 @@ static void initData(ModifierData *md) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; amd->deformflag = ARM_DEF_ENVELOPE | ARM_DEF_VGROUP; } static void copyData(ModifierData *md, ModifierData *target) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - ArmatureModifierData *tamd = (ArmatureModifierData*) target; + ArmatureModifierData *amd = (ArmatureModifierData *) md; + ArmatureModifierData *tamd = (ArmatureModifierData *) target; tamd->object = amd->object; tamd->deformflag = amd->deformflag; @@ -84,27 +84,27 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; return !amd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; walk(userData, ob, &amd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; if (amd->object) { DagNode *curNode = dag_get_node(forest, amd->object); @@ -115,31 +115,31 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ob, derivedData, vertexCos, NULL, - numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); /* free cache */ if (amd->prevCos) { MEM_freeN(amd->prevCos); - amd->prevCos= NULL; + amd->prevCos = NULL; } } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); @@ -147,23 +147,23 @@ static void deformVertsEM( modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, - numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); /* free cache */ if (amd->prevCos) { MEM_freeN(amd->prevCos); - amd->prevCos= NULL; + amd->prevCos = NULL; } if (!derivedData) dm->release(dm); } static void deformMatricesEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], + float (*defMats)[3][3], int numVerts) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); @@ -175,12 +175,12 @@ static void deformMatricesEM( } static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; - if (!derivedData) dm = CDDM_from_mesh((Mesh*)ob->data, ob); + if (!derivedData) dm = CDDM_from_mesh((Mesh *)ob->data, ob); armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name); @@ -193,8 +193,8 @@ ModifierTypeInfo modifierType_Armature = { /* structName */ "ArmatureModifierData", /* structSize */ sizeof(ArmatureModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 6f1f379987d..482f330275b 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -63,7 +63,7 @@ static void initData(ModifierData *md) { - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; /* default to 2 duplicates distributed along the x-axis by an * offset of 1 object-width @@ -82,8 +82,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - ArrayModifierData *amd = (ArrayModifierData*) md; - ArrayModifierData *tamd = (ArrayModifierData*) target; + ArrayModifierData *amd = (ArrayModifierData *) md; + ArrayModifierData *tamd = (ArrayModifierData *) target; tamd->start_cap = amd->start_cap; tamd->end_cap = amd->end_cap; @@ -100,11 +100,11 @@ static void copyData(ModifierData *md, ModifierData *target) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; walk(userData, ob, &amd->start_cap); walk(userData, ob, &amd->end_cap); @@ -113,9 +113,9 @@ static void foreachObjectLink( } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) + struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; if (amd->start_cap) { DagNode *curNode = dag_get_node(forest, amd->start_cap); @@ -163,8 +163,8 @@ static float vertarray_size(MVert *mvert, int numVerts, int axis) } static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, - const ArrayModifierData *amd, - int *index_map_length) + const ArrayModifierData *amd, + int *index_map_length) { BMOperator find_op; BMOIter oiter; @@ -173,8 +173,8 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, int *index_map, i; BMO_op_initf(bm, &find_op, - "finddoubles verts=%av dist=%f keepverts=%s", - amd->merge_dist, dupe_op, "geom"); + "finddoubles verts=%av dist=%f keepverts=%s", + amd->merge_dist, dupe_op, "geom"); BMO_op_exec(bm, &find_op); @@ -214,11 +214,11 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, * * All verts will be tagged on exit. */ -static void bm_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4], - const ArrayModifierData *amd, - BMOperator *dupe_op, - const char *dupe_slot_name, - BMOperator *weld_op) +static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], + const ArrayModifierData *amd, + BMOperator *dupe_op, + const char *dupe_slot_name, + BMOperator *weld_op) { BMVert *v, *v2; BMIter iter; @@ -232,9 +232,9 @@ static void bm_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4], BMOperator find_op; BMO_op_initf(bm, &find_op, - "finddoubles verts=%Hv dist=%f keepverts=%s", - BM_ELEM_TAG, amd->merge_dist, - dupe_op, dupe_slot_name); + "finddoubles verts=%Hv dist=%f keepverts=%s", + BM_ELEM_TAG, amd->merge_dist, + dupe_op, dupe_slot_name); /* append the dupe's geom to the findop input verts */ BMO_slot_buffer_append(&find_op, "verts", dupe_op, dupe_slot_name); @@ -268,20 +268,20 @@ static void bm_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4], } } -static void merge_first_last(BMesh* bm, - const ArrayModifierData *amd, - BMOperator *dupe_first, - BMOperator *dupe_last, - BMOperator *weld_op) +static void merge_first_last(BMesh *bm, + const ArrayModifierData *amd, + BMOperator *dupe_first, + BMOperator *dupe_last, + BMOperator *weld_op) { BMOperator find_op; BMOIter oiter; BMVert *v, *v2; BMO_op_initf(bm, &find_op, - "finddoubles verts=%s dist=%f keepverts=%s", - dupe_first, "geom", amd->merge_dist, - dupe_first, "geom"); + "finddoubles verts=%s dist=%f keepverts=%s", + dupe_first, "geom", amd->merge_dist, + dupe_first, "geom"); /* append the last dupe's geom to the findop input verts */ BMO_slot_buffer_append(&find_op, "verts", dupe_last, "newout"); @@ -331,8 +331,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, add_v3_v3v3(offset[3], offset[3], amd->offset); if (amd->offset_type & MOD_ARR_OFF_RELATIVE) { for (j = 0; j < 3; j++) - offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, - maxVerts, j); + offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, maxVerts, j); } if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) { @@ -364,7 +363,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, makeDispListCurveTypes(scene, amd->curve_ob, 0); } if (cu->path) - length = scale*cu->path->totdist; + length = scale * cu->path->totdist; } } @@ -388,7 +387,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /* calculate the offset matrix of the final copy (for merging) */ unit_m4(final_offset); - for (j=0; j < count - 1; j++) { + for (j = 0; j < count - 1; j++) { mult_m4_m4m4(tmp_mat, offset, final_offset); copy_m4_m4(final_offset, tmp_mat); } @@ -408,7 +407,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMO_op_initf(em->bm, &dupe_op, "dupe geom=%avef"); first_dupe_op = dupe_op; - for (j=0; j < count - 1; j++) { + for (j = 0; j < count - 1; j++) { BMVert *v, *v2, *v3; BMOpSlot *geom_slot; BMOpSlot *newout_slot; @@ -422,7 +421,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, newout_slot = BMO_slot_get(&dupe_op, "newout"); if ((amd->flags & MOD_ARR_MERGEFINAL) && j == 0) { - int first_geom_bytes = sizeof(BMVert*) * geom_slot->len; + int first_geom_bytes = sizeof(BMVert *) * geom_slot->len; /* make a copy of the initial geometry ordering so the * last duplicate can be merged into it */ @@ -439,17 +438,17 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /*calculate merge mapping*/ if (j == 0) { indexMap = find_doubles_index_map(em->bm, &dupe_op, - amd, &indexLen); + amd, &indexLen); } #define _E(s, i) ((BMVert **)(s)->data.buf)[i] - for (i=0; ilen); - v2 = _E(geom_slot, indexMap[i]-1); + v2 = _E(geom_slot, indexMap[i] - 1); /* check in case the target vertex (v2) is already marked * for merging */ @@ -493,14 +492,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float startoffset[4][4]; invert_m4_m4(startoffset, offset); bm_merge_dm_transform(em->bm, start_cap, startoffset, amd, - &first_dupe_op, "geom", &weld_op); + &first_dupe_op, "geom", &weld_op); } if (end_cap) { float endoffset[4][4]; mult_m4_m4m4(endoffset, offset, final_offset); bm_merge_dm_transform(em->bm, end_cap, endoffset, amd, - &dupe_op, count == 1 ? "geom" : "newout", &weld_op); + &dupe_op, count == 1 ? "geom" : "newout", &weld_op); } } /* done capping */ @@ -542,12 +541,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *dm, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *result; - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; result = arrayModifier_doArray(amd, md->scene, ob, dm, 0); @@ -558,8 +557,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *dm) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *dm) { return applyModifier(md, ob, dm, 0, 1); } @@ -570,11 +569,11 @@ ModifierTypeInfo modifierType_Array = { /* structName */ "ArrayModifierData", /* structSize */ sizeof(ArrayModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 613dfee8997..042dd5c3f2b 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -50,7 +50,7 @@ static void initData(ModifierData *md) { - BevelModifierData *bmd = (BevelModifierData*) md; + BevelModifierData *bmd = (BevelModifierData *) md; bmd->value = 0.1f; bmd->res = 1; @@ -64,8 +64,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - BevelModifierData *bmd = (BevelModifierData*) md; - BevelModifierData *tbmd = (BevelModifierData*) target; + BevelModifierData *bmd = (BevelModifierData *) md; + BevelModifierData *tbmd = (BevelModifierData *) target; tbmd->value = bmd->value; tbmd->res = bmd->res; @@ -88,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -#define EDGE_MARK 1 +#define EDGE_MARK 1 #ifdef USE_BM_BEVEL_OP_AS_MOD @@ -115,7 +115,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BMEditMesh *em; BMIter iter; BMEdge *e; - BevelModifierData *bmd = (BevelModifierData*) md; + BevelModifierData *bmd = (BevelModifierData *) md; float threshold = cos((bmd->bevel_angle + 0.00001) * M_PI / 180.0); em = DM_to_editbmesh(dm, NULL, FALSE); @@ -128,8 +128,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* check for 1 edge having 2 face users */ BMLoop *l1, *l2; - if ( (l1= e->l) && - (l2= e->l->radial_next) != l1) + if ((l1 = e->l) && + (l2 = e->l->radial_next) != l1) { if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { BMO_elem_flag_enable(bm, e, EDGE_MARK); @@ -160,16 +160,16 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), #else /* from trunk, see note above */ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *result; BMEditMesh *em; /*bDeformGroup *def;*/ int /*i,*/ options, defgrp_index = -1; - BevelModifierData *bmd = (BevelModifierData*) md; + BevelModifierData *bmd = (BevelModifierData *) md; options = bmd->flags | bmd->val_flags | bmd->lim_flags | bmd->e_flags; @@ -199,37 +199,37 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), #endif static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } ModifierTypeInfo modifierType_Bevel = { - /* name */ "Bevel", - /* structName */ "BevelModifierData", - /* structSize */ sizeof(BevelModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* name */ "Bevel", + /* structName */ "BevelModifierData", + /* structSize */ sizeof(BevelModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ applyModifierEM, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index c11d6fc50af..cf4605c3b40 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -52,8 +52,8 @@ static void copyData(ModifierData *md, ModifierData *target) { - BooleanModifierData *bmd = (BooleanModifierData*) md; - BooleanModifierData *tbmd = (BooleanModifierData*) target; + BooleanModifierData *bmd = (BooleanModifierData *) md; + BooleanModifierData *tbmd = (BooleanModifierData *) target; tbmd->object = bmd->object; tbmd->operation = bmd->operation; @@ -61,27 +61,27 @@ static void copyData(ModifierData *md, ModifierData *target) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; return !bmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; walk(userData, ob, &bmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; if (bmd->object) { DagNode *curNode = dag_get_node(forest, bmd->object); @@ -118,11 +118,11 @@ static DerivedMesh *get_quick_derivedMesh(DerivedMesh *derivedData, DerivedMesh } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; DerivedMesh *dm; if (!bmd->object) @@ -146,7 +146,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, // TIMEIT_START(NewBooleanDerivedMesh) result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, - 1 + bmd->operation); + 1 + bmd->operation); // TIMEIT_END(NewBooleanDerivedMesh) } @@ -163,9 +163,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } #else // WITH_MOD_BOOLEAN static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { return derivedData; } @@ -182,28 +182,28 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( ModifierTypeInfo modifierType_Boolean = { - /* name */ "Boolean", - /* structName */ "BooleanModifierData", - /* structSize */ sizeof(BooleanModifierData), - /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache, + /* name */ "Boolean", + /* structName */ "BooleanModifierData", + /* structSize */ sizeof(BooleanModifierData), + /* type */ eModifierTypeType_Nonconstructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_UsesPointCache, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ NULL, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ NULL, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 369b8ed9b0e..39344aad5a9 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -70,7 +70,7 @@ typedef struct { * These describe a blender mesh to the CSG module. */ -static void VertexIt_Destruct(CSG_VertexIteratorDescriptor * iterator) +static void VertexIt_Destruct(CSG_VertexIteratorDescriptor *iterator) { if (iterator->it) { // deallocate memory for iterator @@ -87,23 +87,23 @@ static void VertexIt_Destruct(CSG_VertexIteratorDescriptor * iterator) static int VertexIt_Done(CSG_IteratorPtr it) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; return(iterator->pos >= iterator->dm->getNumVerts(iterator->dm)); } static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; MVert *verts = iterator->dm->getVertArray(iterator->dm); float global_pos[3]; /* boolean happens in global space, transform both with obmat */ mul_v3_m4v3( - global_pos, - iterator->ob->obmat, - verts[iterator->pos].co - ); + global_pos, + iterator->ob->obmat, + verts[iterator->pos].co + ); vert->position[0] = global_pos[0]; vert->position[1] = global_pos[1]; @@ -112,13 +112,13 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) static void VertexIt_Step(CSG_IteratorPtr it) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; iterator->pos++; } static void VertexIt_Reset(CSG_IteratorPtr it) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; iterator->pos = 0; } @@ -139,7 +139,7 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh it->pos = 0; - // assign iterator function pointers. + // assign iterator function pointers. output->Step = VertexIt_Step; output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; @@ -159,7 +159,7 @@ typedef struct { int flip; } FaceIt; -static void FaceIt_Destruct(CSG_FaceIteratorDescriptor * iterator) +static void FaceIt_Destruct(CSG_FaceIteratorDescriptor *iterator) { MEM_freeN(iterator->it); iterator->Done = NULL; @@ -172,7 +172,7 @@ static void FaceIt_Destruct(CSG_FaceIteratorDescriptor * iterator) static int FaceIt_Done(CSG_IteratorPtr it) { // assume CSG_IteratorPtr is of the correct type. - FaceIt * iterator = (FaceIt *)it; + FaceIt *iterator = (FaceIt *)it; return(iterator->pos >= iterator->dm->getNumTessFaces(iterator->dm)); } @@ -185,9 +185,9 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) /* reverse face vertices if necessary */ face->vertex_index[1] = mface->v2; - if ( face_it->flip == 0 ) { - face->vertex_index[0] = mface->v1; - face->vertex_index[2] = mface->v3; + if (face_it->flip == 0) { + face->vertex_index[0] = mface->v1; + face->vertex_index[2] = mface->v3; } else { face->vertex_index[2] = mface->v1; @@ -206,18 +206,18 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) static void FaceIt_Step(CSG_IteratorPtr it) { - FaceIt * face_it = (FaceIt *)it; + FaceIt *face_it = (FaceIt *)it; face_it->pos++; } static void FaceIt_Reset(CSG_IteratorPtr it) { - FaceIt * face_it = (FaceIt *)it; + FaceIt *face_it = (FaceIt *)it; face_it->pos = 0; } static void FaceIt_Construct( - CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) + CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) { FaceIt *it; if (output == 0) return; @@ -277,35 +277,35 @@ 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= BKE_object_copy(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 // number of users, so decrement it here. - old_me= ob_new->data; + old_me = ob_new->data; old_me->id.us--; // Now create a new base to add into the linked list of // vase objects. - basen= MEM_mallocN(sizeof(Base), "duplibase"); - *basen= *base; - BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ - basen->object= ob_new; + basen = MEM_mallocN(sizeof(Base), "duplibase"); + *basen = *base; + BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ + basen->object = ob_new; basen->flag &= ~SELECT; // Initialize the mesh data associated with this object. - ob_new->data= BKE_mesh_add("Mesh"); + ob_new->data = BKE_mesh_add("Mesh"); // Finally assign the object type. - ob_new->type= OB_MESH; + ob_new->type = OB_MESH; return ob_new; } static void InterpCSGFace( - DerivedMesh *dm, DerivedMesh *orig_dm, int index, int orig_index, int nr, - float mapmat[][4]) + DerivedMesh *dm, DerivedMesh *orig_dm, int index, int orig_index, int nr, + float mapmat[][4]) { float obco[3], *co[4], *orig_co[4], w[4][4]; MFace *mface, *orig_mface; @@ -318,13 +318,13 @@ static void InterpCSGFace( orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; - orig_co[3] = (orig_mface->v4)? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co: NULL; + orig_co[3] = (orig_mface->v4) ? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co : NULL; // get the vertex coordinates from the new derivedmesh co[0] = CDDM_get_vert(dm, mface->v1)->co; co[1] = CDDM_get_vert(dm, mface->v2)->co; co[2] = CDDM_get_vert(dm, mface->v3)->co; - co[3] = (nr == 4)? CDDM_get_vert(dm, mface->v4)->co: NULL; + co[3] = (nr == 4) ? CDDM_get_vert(dm, mface->v4)->co : NULL; for (j = 0; j < nr; j++) { // get coordinate into the space of the original mesh @@ -336,35 +336,35 @@ static void InterpCSGFace( interp_weights_face_v3(w[j], orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco); } - CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); + CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float *)w, 1, index); } /* Iterate over the CSG Output Descriptors and create a new DerivedMesh * from them */ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( - CSG_FaceIteratorDescriptor *face_it, - CSG_VertexIteratorDescriptor *vertex_it, - float parinv[][4], - float mapmat[][4], - Material **mat, - int *totmat, - DerivedMesh *dm1, - Object *ob1, - DerivedMesh *dm2, - Object *ob2) + CSG_FaceIteratorDescriptor *face_it, + CSG_VertexIteratorDescriptor *vertex_it, + float parinv[][4], + float mapmat[][4], + Material **mat, + int *totmat, + DerivedMesh *dm1, + Object *ob1, + DerivedMesh *dm2, + Object *ob2) { DerivedMesh *result, *orig_dm; GHash *material_hash = NULL; - Mesh *me1= (Mesh*)ob1->data; - Mesh *me2= (Mesh*)ob2->data; + Mesh *me1 = (Mesh *)ob1->data; + Mesh *me2 = (Mesh *)ob2->data; int i, *origindex_layer; // create a new DerivedMesh result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements, 0, 0); CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), - CD_DEFAULT, face_it->num_elements); + CD_DEFAULT, face_it->num_elements); CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), - CD_DEFAULT, face_it->num_elements); + CD_DEFAULT, face_it->num_elements); // step through the vertex iterators: for (i = 0; !vertex_it->Done(vertex_it->it); i++) { @@ -402,10 +402,10 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( face_it->Step(face_it->it); // find the original mesh and data - orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1))? ob1: ob2; - orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1))? dm1: dm2; - orig_me = (orig_ob == ob1)? me1: me2; - orig_index = (orig_ob == ob1)? csgface.orig_face: csgface.orig_face - dm1->getNumTessFaces(dm1); + orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? ob1 : ob2; + orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? dm1 : dm2; + orig_me = (orig_ob == ob1) ? me1 : me2; + orig_index = (orig_ob == ob1) ? csgface.orig_face : csgface.orig_face - dm1->getNumTessFaces(dm1); // copy all face layers, including mface CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); @@ -415,7 +415,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mface->v1 = csgface.vertex_index[0]; mface->v2 = csgface.vertex_index[1]; mface->v3 = csgface.vertex_index[2]; - mface->v4 = (csgface.vertex_number == 4)? csgface.vertex_index[3]: 0; + mface->v4 = (csgface.vertex_number == 4) ? csgface.vertex_index[3] : 0; // set material, based on lookup in hash table orig_mat = give_current_material(orig_ob, mface->mat_nr + 1); @@ -459,7 +459,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mface->mat_nr = 0; InterpCSGFace(result, orig_dm, i, orig_index, csgface.vertex_number, - (orig_me == me2)? mapmat: NULL); + (orig_me == me2) ? mapmat : NULL); test_index_face(mface, &result->faceData, i, csgface.vertex_number); @@ -490,27 +490,27 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( } static void BuildMeshDescriptors( - struct DerivedMesh *dm, - struct Object *ob, - int face_offset, - struct CSG_FaceIteratorDescriptor * face_it, - struct CSG_VertexIteratorDescriptor * vertex_it) + struct DerivedMesh *dm, + struct Object *ob, + int face_offset, + struct CSG_FaceIteratorDescriptor *face_it, + struct CSG_VertexIteratorDescriptor *vertex_it) { VertexIt_Construct(vertex_it, dm, ob); FaceIt_Construct(face_it, dm, face_offset, ob); } static void FreeMeshDescriptors( - struct CSG_FaceIteratorDescriptor *face_it, - struct CSG_VertexIteratorDescriptor *vertex_it) + struct CSG_FaceIteratorDescriptor *face_it, + struct CSG_VertexIteratorDescriptor *vertex_it) { VertexIt_Destruct(vertex_it); FaceIt_Destruct(face_it); } static DerivedMesh *NewBooleanDerivedMesh_intern( - DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type, Material **mat, int *totmat) + DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, + int int_op_type, Material **mat, int *totmat) { float inv_mat[4][4]; @@ -543,11 +543,11 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( // work out the operation they chose and pick the appropriate // enum from the csg module. switch (int_op_type) { - case 1 : op_type = e_csg_intersection; break; - case 2 : op_type = e_csg_union; break; - case 3 : op_type = e_csg_difference; break; - case 4 : op_type = e_csg_classify; break; - default : op_type = e_csg_intersection; + case 1: op_type = e_csg_intersection; break; + case 2: op_type = e_csg_union; break; + case 3: op_type = e_csg_difference; break; + case 4: op_type = e_csg_classify; break; + default: op_type = e_csg_intersection; } BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); @@ -566,7 +566,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( // iterate through results of operation and insert // into new object result = ConvertCSGDescriptorsToDerivedMesh( - &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); + &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); // free up the memory CSG_FreeVertexDescriptor(&vd_o); @@ -587,20 +587,20 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) { Mesh *me_new; - int a, maxmat, totmat= 0; + int a, maxmat, totmat = 0; Object *ob_new, *ob, *ob_select; Material **mat; DerivedMesh *result; DerivedMesh *dm_select; DerivedMesh *dm; - ob= base->object; - ob_select= base_select->object; + ob = base->object; + ob_select = base_select->object; dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); dm_select = mesh_create_derived_view(scene, ob_select, 0); // no modifiers in editmode ?? - maxmat= ob->totcol + ob_select->totcol; + maxmat = ob->totcol + ob_select->totcol; mat = (Material **)MEM_mallocN(sizeof(Material *) * maxmat, "NewBooleanMeshMat"); /* put some checks in for nice user feedback */ @@ -613,7 +613,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) return -1; } - result= NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, mat, &totmat); + result = NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, mat, &totmat); if (result == NULL) { MEM_freeN(mat); @@ -621,8 +621,8 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) } /* create a new blender mesh object - using 'base' as a template */ - ob_new= AddNewBlenderMesh(scene, base_select); - me_new= ob_new->data; + ob_new = AddNewBlenderMesh(scene, base_select); + me_new = ob_new->data; DM_to_mesh(result, me_new, ob_new); result->release(result); @@ -643,7 +643,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) } DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type) + int int_op_type) { return NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, NULL, NULL); } diff --git a/source/blender/modifiers/intern/MOD_boolean_util.h b/source/blender/modifiers/intern/MOD_boolean_util.h index 6ba4940a4e9..b996dc6d6ba 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.h +++ b/source/blender/modifiers/intern/MOD_boolean_util.h @@ -48,6 +48,7 @@ int NewBooleanMesh(struct Scene *scene, struct Base *base, struct Base *base_sel * are in fact mesh object. On success returns a DerivedMesh. On failure * returns NULL and reports an error. */ -struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, int int_op_type); +struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, + struct DerivedMesh *dm_select, struct Object *ob_select, int int_op_type); #endif // MOD_BOOLEAN_UTILS diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 8e23555ea12..67a290017f7 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -53,7 +53,7 @@ static void initData(ModifierData *md) { - BuildModifierData *bmd = (BuildModifierData*) md; + BuildModifierData *bmd = (BuildModifierData *) md; bmd->start = 1.0; bmd->length = 100.0; @@ -61,8 +61,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - BuildModifierData *bmd = (BuildModifierData*) md; - BuildModifierData *tbmd = (BuildModifierData*) target; + BuildModifierData *bmd = (BuildModifierData *) md; + BuildModifierData *tbmd = (BuildModifierData *) target; tbmd->start = bmd->start; tbmd->length = bmd->length; @@ -82,7 +82,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), { DerivedMesh *dm = derivedData; DerivedMesh *result; - BuildModifierData *bmd = (BuildModifierData*) md; + BuildModifierData *bmd = (BuildModifierData *) md; int i, j, k; int numFaces_dst, numEdges_dst, numLoops_dst = 0; int *vertMap, *edgeMap, *faceMap; @@ -141,7 +141,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), mp = mpoly + faceMap[i]; ml = mloop + mp->loopstart; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(ml->v))) BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(ml->v), SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); @@ -157,8 +157,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), for (i = 0; i < numEdge_src; i++) { MEdge *me = medge + i; - if ( BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1)) && - BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) + if (BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1)) && + BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) { j = BLI_ghash_size(edgeHash); @@ -225,17 +225,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), BLI_ghash_size(edgeHash), 0, numLoops_dst, numFaces_dst); /* copy the vertices across */ - for ( hashIter = BLI_ghashIterator_new(vertHash); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter) - ) + for (hashIter = BLI_ghashIterator_new(vertHash); + !BLI_ghashIterator_isDone(hashIter); + BLI_ghashIterator_step(hashIter) + ) { MVert source; MVert *dest; int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - source = mvert_src [oldIndex]; + source = mvert_src[oldIndex]; dest = CDDM_get_vert(result, newIndex); DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); @@ -278,7 +278,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DM_copy_loop_data(dm, result, source->loopstart, dest->loopstart, dest->totloop); ml_src = mloop_src + source->loopstart; - for (j=0; jtotloop; j++, k++, ml_src++, ml_dst++) { + for (j = 0; j < source->totloop; j++, k++, ml_src++, ml_dst++) { ml_dst->v = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(ml_src->v))); ml_dst->e = GET_INT_FROM_POINTER(BLI_ghash_lookup(edgeHash2, SET_INT_IN_POINTER(ml_src->e))); } @@ -297,27 +297,27 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), ModifierTypeInfo modifierType_Build = { - /* name */ "Build", - /* structName */ "BuildModifierData", - /* structSize */ sizeof(BuildModifierData), - /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ NULL, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Build", + /* structName */ "BuildModifierData", + /* structSize */ sizeof(BuildModifierData), + /* type */ eModifierTypeType_Nonconstructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 8ad5b72204b..16ed508d42e 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -52,13 +52,12 @@ static void initData(ModifierData *md) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; cmd->fac = 0.5f; cmd->radius = 0.0f; cmd->size = 0.0f; - cmd->flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z - | MOD_CAST_SIZE_FROM_RADIUS; + cmd->flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z | MOD_CAST_SIZE_FROM_RADIUS; cmd->type = MOD_CAST_TYPE_SPHERE; cmd->defgrp_name[0] = '\0'; cmd->object = NULL; @@ -67,8 +66,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - CastModifierData *cmd = (CastModifierData*) md; - CastModifierData *tcmd = (CastModifierData*) target; + CastModifierData *cmd = (CastModifierData *) md; + CastModifierData *tcmd = (CastModifierData *) target; tcmd->fac = cmd->fac; tcmd->radius = cmd->radius; @@ -81,10 +80,10 @@ static void copyData(ModifierData *md, ModifierData *target) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; short flag; - flag = cmd->flag & (MOD_CAST_X|MOD_CAST_Y|MOD_CAST_Z); + flag = cmd->flag & (MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z); if ((cmd->fac == 0.0f) || flag == 0) return 1; @@ -103,33 +102,33 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; - walk (userData, ob, &cmd->object); + walk(userData, ob, &cmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; if (cmd->object) { DagNode *curNode = dag_get_node(forest, cmd->object); dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Cast Modifier"); + "Cast Modifier"); } } static void sphere_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + CastModifierData *cmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; @@ -200,7 +199,7 @@ static void sphere_do( * with or w/o a vgroup. With lots of if's in the code below, * further optimization's are possible, if needed */ if (dvert) { /* with a vgroup */ - MDeformVert *dv= dvert; + MDeformVert *dv = dvert; float fac_orig = fac; for (i = 0; i < numVerts; i++, dv++) { float tmp_co[3]; @@ -225,7 +224,7 @@ static void sphere_do( if (len_v3(vec) > cmd->radius) continue; } - weight= defvert_find_weight(dv, defgrp_index); + weight = defvert_find_weight(dv, defgrp_index); if (weight <= 0.0f) continue; fac = fac_orig * weight; @@ -234,11 +233,11 @@ static void sphere_do( normalize_v3(vec); if (flag & MOD_CAST_X) - tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; + tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0]; if (flag & MOD_CAST_Y) - tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1]; + tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1]; if (flag & MOD_CAST_Z) - tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2]; + tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2]; if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { @@ -280,11 +279,11 @@ static void sphere_do( normalize_v3(vec); if (flag & MOD_CAST_X) - tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; + tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0]; if (flag & MOD_CAST_Y) - tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1]; + tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1]; if (flag & MOD_CAST_Z) - tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2]; + tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2]; if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { @@ -300,8 +299,8 @@ static void sphere_do( } static void cuboid_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + CastModifierData *cmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; Object *ctrl_ob = NULL; @@ -579,11 +578,11 @@ static void cuboid_do( } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = NULL; CastModifierData *cmd = (CastModifierData *)md; @@ -602,8 +601,8 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); CastModifierData *cmd = (CastModifierData *)md; @@ -625,8 +624,8 @@ ModifierTypeInfo modifierType_Cast = { /* structName */ "CastModifierData", /* structSize */ sizeof(CastModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 1bc23ab5040..d3ced63fb57 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -54,7 +54,7 @@ static void initData(ModifierData *md) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); @@ -64,15 +64,15 @@ static void initData(ModifierData *md) if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) return; - cloth_init (clmd); + cloth_init(clmd); } static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], - int UNUSED(numVerts), int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + int UNUSED(numVerts), int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { DerivedMesh *dm; - ClothModifierData *clmd = (ClothModifierData*) md; - DerivedMesh *result=NULL; + ClothModifierData *clmd = (ClothModifierData *) md; + DerivedMesh *result = NULL; /* check for alloc failing */ if (!clmd->sim_parms || !clmd->coll_parms) { @@ -102,13 +102,13 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; Base *base; if (clmd) { - for (base = scene->base.first; base; base= base->next) { - Object *ob1= base->object; + for (base = scene->base.first; base; base = base->next) { + Object *ob1 = base->object; if (ob1 != ob) { CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); if (coll_clmd) { @@ -123,7 +123,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Ob static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { CustomDataMask dataMask = 0; - ClothModifierData *clmd = (ClothModifierData*)md; + ClothModifierData *clmd = (ClothModifierData *)md; if (cloth_uses_vgroup(clmd)) dataMask |= CD_MASK_MDEFORMVERT; @@ -136,8 +136,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - ClothModifierData *clmd = (ClothModifierData*) md; - ClothModifierData *tclmd = (ClothModifierData*) target; + ClothModifierData *clmd = (ClothModifierData *) md; + ClothModifierData *tclmd = (ClothModifierData *) target; if (tclmd->sim_parms) { if (tclmd->sim_parms->effector_weights) @@ -166,13 +166,13 @@ static int dependsOnTime(ModifierData *UNUSED(md)) static void freeData(ModifierData *md) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; if (clmd) { if (G.rt > 0) printf("clothModifier_freeData\n"); - cloth_free_modifier_extern (clmd); + cloth_free_modifier_extern(clmd); if (clmd->sim_parms) { if (clmd->sim_parms->effector_weights) @@ -188,9 +188,9 @@ static void freeData(ModifierData *md) } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; if (clmd->coll_parms) { walk(userData, ob, (ID **)&clmd->coll_parms->group); diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index e0b9939d152..eb4511ddaec 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -55,7 +55,7 @@ static void initData(ModifierData *md) { - CollisionModifierData *collmd = (CollisionModifierData*) md; + CollisionModifierData *collmd = (CollisionModifierData *) md; collmd->x = NULL; collmd->xnew = NULL; @@ -69,7 +69,7 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { - CollisionModifierData *collmd = (CollisionModifierData*) md; + CollisionModifierData *collmd = (CollisionModifierData *) md; if (collmd) { if (collmd->bvhtree) @@ -105,13 +105,13 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - CollisionModifierData *collmd = (CollisionModifierData*) md; + CollisionModifierData *collmd = (CollisionModifierData *) md; DerivedMesh *dm = NULL; MVert *tempVert = NULL; @@ -136,7 +136,7 @@ static void deformVerts(ModifierData *md, Object *ob, if (G.rt > 0) printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew); - numverts = dm->getNumVerts (dm); + numverts = dm->getNumVerts(dm); if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; @@ -177,15 +177,15 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->xnew = tempVert; collmd->time_x = collmd->time_xnew; - memcpy(collmd->xnew, dm->getVertArray(dm), numverts*sizeof(MVert)); + memcpy(collmd->xnew, dm->getVertArray(dm), numverts * sizeof(MVert)); for (i = 0; i < numverts; i++) { // we save global positions mul_m4_v3(ob->obmat, collmd->xnew[i].co); } - memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert)); - memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert)); + memcpy(collmd->current_xnew, collmd->x, numverts * sizeof(MVert)); + memcpy(collmd->current_x, collmd->x, numverts * sizeof(MVert)); /* check if GUI setting has changed for bvh */ if (collmd->bvhtree) { @@ -202,7 +202,7 @@ static void deformVerts(ModifierData *md, Object *ob, } else { // recalc static bounding boxes - bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); + bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1); } collmd->time_xnew = current_time; @@ -232,8 +232,8 @@ ModifierTypeInfo modifierType_Collision = { /* structName */ "CollisionModifierData", /* structSize */ sizeof(CollisionModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_Single, /* copyData */ NULL, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index f516f971dc0..ce3e0452970 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -52,15 +52,15 @@ static void initData(ModifierData *md) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; cmd->defaxis = MOD_CURVE_POSX; } static void copyData(ModifierData *md, ModifierData *target) { - CurveModifierData *cmd = (CurveModifierData*) md; - CurveModifierData *tcmd = (CurveModifierData*) target; + CurveModifierData *cmd = (CurveModifierData *) md; + CurveModifierData *tcmd = (CurveModifierData *) target; tcmd->defaxis = cmd->defaxis; tcmd->object = cmd->object; @@ -80,27 +80,27 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; return !cmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; walk(userData, ob, &cmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; if (cmd->object) { DagNode *curNode = dag_get_node(forest, cmd->object); @@ -111,23 +111,23 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; /* silly that defaxis and curve_deform_verts are off by 1 * but leave for now to save having to call do_versions */ curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts, - cmd->name, cmd->defaxis-1); + cmd->name, cmd->defaxis - 1); } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -140,28 +140,28 @@ static void deformVertsEM( ModifierTypeInfo modifierType_Curve = { - /* name */ "Curve", - /* structName */ "CurveModifierData", - /* structSize */ sizeof(CurveModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* name */ "Curve", + /* structName */ "CurveModifierData", + /* structSize */ sizeof(CurveModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs + | eModifierTypeFlag_SupportsEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index e1a8e221476..b28a4a942ac 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -56,26 +56,26 @@ static void initData(ModifierData *md) { - DecimateModifierData *dmd = (DecimateModifierData*) md; + DecimateModifierData *dmd = (DecimateModifierData *) md; dmd->percent = 1.0; } static void copyData(ModifierData *md, ModifierData *target) { - DecimateModifierData *dmd = (DecimateModifierData*) md; - DecimateModifierData *tdmd = (DecimateModifierData*) target; + DecimateModifierData *dmd = (DecimateModifierData *) md; + DecimateModifierData *tdmd = (DecimateModifierData *) target; tdmd->percent = dmd->percent; } #ifdef WITH_MOD_DECIMATE static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - DecimateModifierData *dmd = (DecimateModifierData*) md; + DecimateModifierData *dmd = (DecimateModifierData *) md; DerivedMesh *dm = derivedData, *result = NULL; MVert *mvert; MFace *mface; @@ -91,59 +91,59 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), totface = dm->getNumTessFaces(dm); numTris = 0; - for (a=0; av4) numTris++; } - if (numTris<3) { + if (numTris < 3) { modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces (triangles).")); dm = CDDM_copy(dm); return dm; } - lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*totvert, "vertices"); - lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*totvert, "normals"); - lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*numTris, "trias"); - lod.vertex_num= totvert; - lod.face_num= numTris; + lod.vertex_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "vertices"); + lod.vertex_normal_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "normals"); + lod.triangle_index_buffer = MEM_mallocN(3 * sizeof(int) * numTris, "trias"); + lod.vertex_num = totvert; + lod.face_num = numTris; - for (a=0; aco); normal_short_to_float_v3(vbNo, mv->no); } numTris = 0; - for (a=0; av1; - tri[1]= mf->v2; - tri[2]= mf->v3; + int *tri = &lod.triangle_index_buffer[3 * numTris++]; + tri[0] = mf->v1; + tri[1] = mf->v2; + tri[2] = mf->v3; if (mf->v4) { - tri = &lod.triangle_index_buffer[3*numTris++]; - tri[0]= mf->v1; - tri[1]= mf->v3; - tri[2]= mf->v4; + tri = &lod.triangle_index_buffer[3 * numTris++]; + tri[0] = mf->v1; + tri[1] = mf->v3; + tri[2] = mf->v4; } } dmd->faceCount = 0; if (LOD_LoadMesh(&lod) ) { - if ( LOD_PreprocessMesh(&lod) ) { + if (LOD_PreprocessMesh(&lod) ) { /* we assume the decim_faces tells how much to reduce */ - while (lod.face_num > numTris*dmd->percent) { - if ( LOD_CollapseEdge(&lod) == 0) break; + while (lod.face_num > numTris * dmd->percent) { + if (LOD_CollapseEdge(&lod) == 0) break; } - if (lod.vertex_num>2) { + if (lod.vertex_num > 2) { result = CDDM_new(lod.vertex_num, 0, lod.face_num, 0, 0); dmd->faceCount = lod.face_num; } @@ -151,18 +151,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), result = CDDM_new(lod.vertex_num, 0, 0, 0, 0); mvert = CDDM_get_verts(result); - for (a=0; aco, vbCo); } - if (lod.vertex_num>2) { + if (lod.vertex_num > 2) { mface = CDDM_get_tessfaces(result); for (a = 0; a < lod.face_num; a++) { MFace *mf = &mface[a]; - int *tri = &lod.triangle_index_buffer[a*3]; + int *tri = &lod.triangle_index_buffer[a * 3]; mf->v1 = tri[0]; mf->v2 = tri[1]; mf->v3 = tri[2]; @@ -195,9 +195,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), } #else // WITH_MOD_DECIMATE static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { return derivedData; } diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 4d9b8de061e..fd3ebada170 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -58,7 +58,7 @@ static void initData(ModifierData *md) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; dmd->texture = NULL; dmd->strength = 1; @@ -68,8 +68,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - DisplaceModifierData *tdmd = (DisplaceModifierData*) target; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; + DisplaceModifierData *tdmd = (DisplaceModifierData *) target; tdmd->texture = dmd->texture; tdmd->strength = dmd->strength; @@ -114,17 +114,17 @@ static int dependsOnNormals(ModifierData *md) } static void foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; walk(userData, ob, &dmd->map_object); } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; walk(userData, ob, (ID **)&dmd->texture); @@ -132,24 +132,24 @@ static void foreachIDLink(ModifierData *md, Object *ob, } static void foreachTexLink(ModifierData *md, Object *ob, - TexWalkFunc walk, void *userData) + TexWalkFunc walk, void *userData) { walk(userData, ob, md, "texture"); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; return (!dmd->texture || dmd->strength == 0.0f); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; if (dmd->map_object && dmd->texmapping == MOD_DISP_MAP_OBJECT) { DagNode *curNode = dag_get_node(forest, dmd->map_object); @@ -167,15 +167,15 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, /* dm must be a CDDerivedMesh */ static void displaceModifier_do( - DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, float (*vertexCos)[3], int numVerts) + DisplaceModifierData *dmd, Object *ob, + DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { int i; MVert *mvert; MDeformVert *dvert; int defgrp_index; float (*tex_co)[3]; - float weight= 1.0f; /* init value unused but some compilers may complain */ + float weight = 1.0f; /* init value unused but some compilers may complain */ if (!dmd->texture) return; if (dmd->strength == 0.0f) return; @@ -184,7 +184,7 @@ static void displaceModifier_do( modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index); tex_co = MEM_callocN(sizeof(*tex_co) * numVerts, - "displaceModifier_do tex_co"); + "displaceModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts); modifier_init_texture(dmd->modifier.scene, dmd->texture); @@ -194,7 +194,7 @@ static void displaceModifier_do( float delta = 0, strength = dmd->strength; if (dvert) { - weight= defvert_find_weight(dvert + i, defgrp_index); + weight = defvert_find_weight(dvert + i, defgrp_index); if (weight == 0.0f) continue; } @@ -235,13 +235,13 @@ static void displaceModifier_do( } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - DerivedMesh *dm= get_cddm(ob, NULL, derivedData, vertexCos); + DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos); displaceModifier_do((DisplaceModifierData *)md, ob, dm, vertexCos, numVerts); @@ -251,10 +251,10 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm= get_cddm(ob, editData, derivedData, vertexCos); + DerivedMesh *dm = get_cddm(ob, editData, derivedData, vertexCos); displaceModifier_do((DisplaceModifierData *)md, ob, dm, vertexCos, numVerts); @@ -269,8 +269,8 @@ ModifierTypeInfo modifierType_Displace = { /* structName */ "DisplaceModifierData", /* structSize */ sizeof(DisplaceModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 5005e2c010d..7f8e476790f 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -47,7 +47,7 @@ static void initData(ModifierData *md) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; pmd->canvas = NULL; pmd->brush = NULL; @@ -56,34 +56,34 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*)md; - DynamicPaintModifierData *tpmd = (DynamicPaintModifierData*)target; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; + DynamicPaintModifierData *tpmd = (DynamicPaintModifierData *)target; dynamicPaint_Modifier_copy(pmd, tpmd); } static void freeData(ModifierData *md) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; dynamicPaint_Modifier_free(pmd); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*)md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; CustomDataMask dataMask = 0; if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; - for (; surface; surface=surface->next) { + for (; surface; surface = surface->next) { /* tface */ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ || - surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) { + surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) { dataMask |= (1 << CD_MTFACE); } /* mcol */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT || - surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) { + surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) { dataMask |= (1 << CD_MCOL); } /* CD_MDEFORMVERT */ @@ -102,32 +102,33 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *dm, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; return dynamicPaint_Modifier_do(pmd, md->scene, ob, dm); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *scene, - Object *ob, - DagNode *obNode) + struct Scene *scene, + Object *ob, + DagNode *obNode) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; /* add relation from canvases to all brush objects */ if (pmd && pmd->canvas) { Base *base = scene->base.first; for (; base; base = base->next) { - DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint); + DynamicPaintModifierData *pmd2 = + (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint); - if (pmd2 && pmd2->brush && ob!=base->object) { + if (pmd2 && pmd2->brush && ob != base->object) { DagNode *brushNode = dag_get_node(forest, base->object); - dag_add_relation(forest, brushNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Dynamic Paint Brush"); + dag_add_relation(forest, brushNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Dynamic Paint Brush"); } } } @@ -139,14 +140,14 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; - for (; surface; surface=surface->next) { + for (; surface; surface = surface->next) { walk(userData, ob, (ID **)&surface->brush_group); walk(userData, ob, (ID **)&surface->init_texture); } @@ -157,7 +158,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, } static void foreachTexLink(ModifierData *UNUSED(md), Object *UNUSED(ob), - TexWalkFunc UNUSED(walk), void *UNUSED(userData)) + TexWalkFunc UNUSED(walk), void *UNUSED(userData)) { //walk(userData, ob, md, ""); /* re-enable when possible */ } @@ -167,11 +168,11 @@ ModifierTypeInfo modifierType_DynamicPaint = { /* structName */ "DynamicPaintModifierData", /* structSize */ sizeof(DynamicPaintModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh -/* |eModifierTypeFlag_SupportsMapping*/ - |eModifierTypeFlag_UsesPointCache - |eModifierTypeFlag_Single - |eModifierTypeFlag_UsesPreview, + /* flags */ eModifierTypeFlag_AcceptsMesh | +/* eModifierTypeFlag_SupportsMapping |*/ + eModifierTypeFlag_UsesPointCache | + eModifierTypeFlag_Single | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 3e399707040..794ee6204ed 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -55,7 +55,7 @@ * note: this code is very close to MOD_bevel.c */ -#define EDGE_MARK 1 +#define EDGE_MARK 1 static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Object *UNUSED(ob)) { @@ -76,8 +76,8 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* check for 1 edge having 2 face users */ BMLoop *l1, *l2; - if ( (l1= e->l) && - (l2= e->l->radial_next) != l1) + if ((l1 = e->l) && + (l2 = e->l->radial_next) != l1) { if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { BMO_elem_flag_enable(bm, e, EDGE_MARK); @@ -115,7 +115,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj static void initData(ModifierData *md) { - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; + EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md; /* default to 30-degree split angle, sharpness from both angle & flag */ emd->split_angle = 30; @@ -124,15 +124,15 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; - EdgeSplitModifierData *temd = (EdgeSplitModifierData*) target; + EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md; + EdgeSplitModifierData *temd = (EdgeSplitModifierData *) target; temd->split_angle = emd->split_angle; temd->flags = emd->flags; } static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd, - Object *ob, DerivedMesh *dm) + Object *ob, DerivedMesh *dm) { if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG))) return dm; @@ -141,11 +141,11 @@ static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd, } static DerivedMesh *applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + ModifierData *md, Object *ob, DerivedMesh *derivedData, + int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { DerivedMesh *result; - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; + EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md; result = edgesplitModifier_do(emd, ob, derivedData); @@ -156,8 +156,8 @@ static DerivedMesh *applyModifier( } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } @@ -168,11 +168,11 @@ ModifierTypeInfo modifierType_EdgeSplit = { /* structName */ "EdgeSplitModifierData", /* structSize */ sizeof(EdgeSplitModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 429369d6650..39932b5673c 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -59,21 +59,21 @@ static void initData(ModifierData *md) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; + ExplodeModifierData *emd = (ExplodeModifierData *) md; - emd->facepa= NULL; - emd->flag |= eExplodeFlag_Unborn+eExplodeFlag_Alive+eExplodeFlag_Dead; + emd->facepa = NULL; + emd->flag |= eExplodeFlag_Unborn + eExplodeFlag_Alive + eExplodeFlag_Dead; } static void freeData(ModifierData *md) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; + ExplodeModifierData *emd = (ExplodeModifierData *) md; if (emd->facepa) MEM_freeN(emd->facepa); } static void copyData(ModifierData *md, ModifierData *target) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; - ExplodeModifierData *temd= (ExplodeModifierData*) target; + ExplodeModifierData *emd = (ExplodeModifierData *) md; + ExplodeModifierData *temd = (ExplodeModifierData *) target; temd->facepa = NULL; temd->flag = emd->flag; @@ -86,7 +86,7 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; + ExplodeModifierData *emd = (ExplodeModifierData *) md; CustomDataMask dataMask = 0; if (emd->vgroup) @@ -96,48 +96,48 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void createFacepa(ExplodeModifierData *emd, - ParticleSystemModifierData *psmd, - DerivedMesh *dm) + ParticleSystemModifierData *psmd, + DerivedMesh *dm) { - ParticleSystem *psys=psmd->psys; - MFace *fa=NULL, *mface=NULL; + ParticleSystem *psys = psmd->psys; + MFace *fa = NULL, *mface = NULL; MVert *mvert = NULL; ParticleData *pa; KDTree *tree; float center[3], co[3]; - int *facepa=NULL, *vertpa=NULL, totvert=0, totface=0, totpart=0; - int i, p, v1, v2, v3, v4=0; + int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0; + int i, p, v1, v2, v3, v4 = 0; mvert = dm->getVertArray(dm); mface = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); - totvert= dm->getNumVerts(dm); - totpart= psmd->psys->totpart; + totface = dm->getNumTessFaces(dm); + totvert = dm->getNumVerts(dm); + totpart = psmd->psys->totpart; BLI_srandom(psys->seed); if (emd->facepa) MEM_freeN(emd->facepa); - facepa = emd->facepa = MEM_callocN(sizeof(int)*totface, "explode_facepa"); + facepa = emd->facepa = MEM_callocN(sizeof(int) * totface, "explode_facepa"); - vertpa = MEM_callocN(sizeof(int)*totvert, "explode_vertpa"); + vertpa = MEM_callocN(sizeof(int) * totvert, "explode_vertpa"); /* initialize all faces & verts to no particle */ - for (i=0; ivgroup) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert) { - const int defgrp_index= emd->vgroup-1; - for (i=0; ivgroup - 1; + for (i = 0; i < totvert; i++, dvert++) { float val = BLI_frand(); - val = (1.0f-emd->protect)*val + emd->protect*0.5f; + val = (1.0f - emd->protect) * val + emd->protect * 0.5f; if (val < defvert_find_weight(dvert, defgrp_index)) vertpa[i] = -1; } @@ -145,15 +145,15 @@ static void createFacepa(ExplodeModifierData *emd, } /* make tree of emitter locations */ - tree=BLI_kdtree_new(totpart); - for (p=0, pa=psys->particles; pparticles; p < totpart; p++, pa++) { psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL, NULL); BLI_kdtree_insert(tree, p, co, NULL); } BLI_kdtree_balance(tree); /* set face-particle-indexes to nearest particle to face center */ - for (i=0, fa=mface; iv1].co, mvert[fa->v2].co); add_v3_v3(center, mvert[fa->v3].co); if (fa->v4) { @@ -163,21 +163,21 @@ static void createFacepa(ExplodeModifierData *emd, else mul_v3_fl(center, 0.3333f); - p= BLI_kdtree_find_nearest(tree, center, NULL, NULL); + p = BLI_kdtree_find_nearest(tree, center, NULL, NULL); - v1=vertpa[fa->v1]; - v2=vertpa[fa->v2]; - v3=vertpa[fa->v3]; + v1 = vertpa[fa->v1]; + v2 = vertpa[fa->v2]; + v3 = vertpa[fa->v3]; if (fa->v4) - v4=vertpa[fa->v4]; + v4 = vertpa[fa->v4]; - if (v1>=0 && v2>=0 && v3>=0 && (fa->v4==0 || v4>=0)) - facepa[i]=p; + if (v1 >= 0 && v2 >= 0 && v3 >= 0 && (fa->v4 == 0 || v4 >= 0)) + facepa[i] = p; - if (v1>=0) vertpa[fa->v1]=p; - if (v2>=0) vertpa[fa->v2]=p; - if (v3>=0) vertpa[fa->v3]=p; - if (fa->v4 && v4>=0) vertpa[fa->v4]=p; + if (v1 >= 0) vertpa[fa->v1] = p; + if (v2 >= 0) vertpa[fa->v2] = p; + if (v3 >= 0) vertpa[fa->v3] = p; + if (fa->v4 && v4 >= 0) vertpa[fa->v4] = p; } if (vertpa) MEM_freeN(vertpa); @@ -195,7 +195,7 @@ static const short add_faces[24] = { 0, 0, 2, 0, 1, 2, 2, 0, 2, 1, 2, 2, 2, 2, 3, 0, 0, 0, 1, 0, 1, 1, 2 - }; +}; static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFace *mf) { @@ -206,11 +206,11 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa } #define SET_VERTS(a, b, c, d) \ - v[0] = mf->v##a; uv[0]=a-1; \ - v[1] = mf->v##b; uv[1]=b-1; \ - v[2] = mf->v##c; uv[2]=c-1; \ - v[3] = mf->v##d; uv[3]=d-1; \ - (void)0 + v[0] = mf->v##a; uv[0] = a - 1; \ + v[1] = mf->v##b; uv[1] = b - 1; \ + v[2] = mf->v##c; uv[2] = c - 1; \ + v[3] = mf->v##d; uv[3] = d - 1; \ + (void)0 #define GET_ES(v1, v2) edgecut_get(eh, v1, v2) #define INT_UV(uvf, c0, c1) interp_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1], 0.5f) @@ -218,8 +218,8 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa static void remap_faces_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -228,14 +228,14 @@ static void remap_faces_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, MFace *mf, df1->v4 = v3; df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = 0; df2->flag &= ~ME_FACE_SEL; - facepa[cur+2] = vertpa[v1]; + facepa[cur + 2] = vertpa[v1]; df3->v1 = v1; df3->v2 = v3; df3->v3 = v4; @@ -248,9 +248,9 @@ static void remap_uvs_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, int numlayer MTFace *mf, *df1, *df2, *df3; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; df3 = df1 + 2; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); @@ -274,7 +274,7 @@ static void remap_uvs_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, int numlayer static void remap_faces_5_10(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -283,7 +283,7 @@ static void remap_faces_5_10(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int df1->v4 = GET_ES(v1, v4); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v3]; + facepa[cur + 1] = vertpa[v3]; df2->v1 = GET_ES(v1, v4); df2->v2 = GET_ES(v2, v3); df2->v3 = v3; @@ -296,9 +296,9 @@ static void remap_uvs_5_10(DerivedMesh *dm, DerivedMesh *split, int numlayer, in MTFace *mf, *df1, *df2; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); mf += i; @@ -319,9 +319,9 @@ static void remap_uvs_5_10(DerivedMesh *dm, DerivedMesh *split, int numlayer, in static void remap_faces_15(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); - MFace *df4 = get_dface(dm, split, cur+3, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); + MFace *df4 = get_dface(dm, split, cur + 3, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -330,21 +330,21 @@ static void remap_faces_15(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int * df1->v4 = GET_ES(v1, v4); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = GET_ES(v1, v3); df2->flag |= ME_FACE_SEL; - facepa[cur+2] = vertpa[v3]; + facepa[cur + 2] = vertpa[v3]; df3->v1 = GET_ES(v1, v3); df3->v2 = GET_ES(v2, v3); df3->v3 = v3; df3->v4 = GET_ES(v3, v4); df3->flag |= ME_FACE_SEL; - facepa[cur+3] = vertpa[v4]; + facepa[cur + 3] = vertpa[v4]; df4->v1 = GET_ES(v1, v4); df4->v2 = GET_ES(v1, v3); df4->v3 = GET_ES(v3, v4); @@ -357,9 +357,9 @@ static void remap_uvs_15(DerivedMesh *dm, DerivedMesh *split, int numlayer, int MTFace *mf, *df1, *df2, *df3, *df4; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; df3 = df1 + 2; df4 = df1 + 3; @@ -391,8 +391,8 @@ static void remap_uvs_15(DerivedMesh *dm, DerivedMesh *split, int numlayer, int static void remap_faces_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -401,14 +401,14 @@ static void remap_faces_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, MFace *m df1->v4 = GET_ES(v1, v4); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = 0; df2->flag &= ~ME_FACE_SEL; - facepa[cur+2] = vertpa[v4]; + facepa[cur + 2] = vertpa[v4]; df3->v1 = GET_ES(v1, v4); df3->v2 = GET_ES(v2, v3); df3->v3 = v3; @@ -421,9 +421,9 @@ static void remap_uvs_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, int numlay MTFace *mf, *df1, *df2, *df3; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; df3 = df1 + 2; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); @@ -448,7 +448,7 @@ static void remap_uvs_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, int numlay static void remap_faces_19_21_22(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -457,7 +457,7 @@ static void remap_faces_19_21_22(DerivedMesh *dm, DerivedMesh *split, MFace *mf, df1->v4 = 0; df1->flag &= ~ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = v3; @@ -470,9 +470,9 @@ static void remap_uvs_19_21_22(DerivedMesh *dm, DerivedMesh *split, int numlayer MTFace *mf, *df1, *df2; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); mf += i; @@ -491,8 +491,8 @@ static void remap_uvs_19_21_22(DerivedMesh *dm, DerivedMesh *split, int numlayer static void remap_faces_23(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -501,14 +501,14 @@ static void remap_faces_23(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int * df1->v4 = GET_ES(v1, v3); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = 0; df2->flag &= ~ME_FACE_SEL; - facepa[cur+2] = vertpa[v3]; + facepa[cur + 2] = vertpa[v3]; df3->v1 = GET_ES(v1, v3); df3->v2 = GET_ES(v2, v3); df3->v3 = v3; @@ -521,9 +521,9 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int MTFace *mf, *df1, *df2; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); mf += i; @@ -543,63 +543,63 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int } } -static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) +static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) { DerivedMesh *splitdm; - MFace *mf=NULL, *df1=NULL; - MFace *mface=dm->getTessFaceArray(dm); + MFace *mf = NULL, *df1 = NULL; + MFace *mface = dm->getTessFaceArray(dm); MVert *dupve, *mv; EdgeHash *edgehash; EdgeHashIterator *ehi; - int totvert=dm->getNumVerts(dm); - int totface=dm->getNumTessFaces(dm); + int totvert = dm->getNumVerts(dm); + int totface = dm->getNumTessFaces(dm); - int *facesplit = MEM_callocN(sizeof(int)*totface, "explode_facesplit"); - int *vertpa = MEM_callocN(sizeof(int)*totvert, "explode_vertpa2"); + int *facesplit = MEM_callocN(sizeof(int) * totface, "explode_facesplit"); + int *vertpa = MEM_callocN(sizeof(int) * totvert, "explode_vertpa2"); int *facepa = emd->facepa; - int *fs, totesplit=0, totfsplit=0, curdupface=0; + int *fs, totesplit = 0, totfsplit = 0, curdupface = 0; int i, v1, v2, v3, v4, esplit, v[4] = {0, 0, 0, 0}, /* To quite gcc barking... */ uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */ int numlayer; unsigned int ed_v1, ed_v2; - edgehash= BLI_edgehash_new(); + edgehash = BLI_edgehash_new(); /* recreate vertpa from facepa calculation */ - for (i=0, mf=mface; iv1]=facepa[i]; - vertpa[mf->v2]=facepa[i]; - vertpa[mf->v3]=facepa[i]; + for (i = 0, mf = mface; i < totface; i++, mf++) { + vertpa[mf->v1] = facepa[i]; + vertpa[mf->v2] = facepa[i]; + vertpa[mf->v3] = facepa[i]; if (mf->v4) - vertpa[mf->v4]=facepa[i]; + vertpa[mf->v4] = facepa[i]; } /* mark edges for splitting and how to split faces */ - for (i=0, mf=mface, fs=facesplit; iv1]; - v2=vertpa[mf->v2]; - v3=vertpa[mf->v3]; + for (i = 0, mf = mface, fs = facesplit; i < totface; i++, mf++, fs++) { + v1 = vertpa[mf->v1]; + v2 = vertpa[mf->v2]; + v3 = vertpa[mf->v3]; - if (v1!=v2) { + if (v1 != v2) { BLI_edgehash_insert(edgehash, mf->v1, mf->v2, NULL); (*fs) |= 1; } - if (v2!=v3) { + if (v2 != v3) { BLI_edgehash_insert(edgehash, mf->v2, mf->v3, NULL); (*fs) |= 2; } if (mf->v4) { - v4=vertpa[mf->v4]; + v4 = vertpa[mf->v4]; - if (v3!=v4) { + if (v3 != v4) { BLI_edgehash_insert(edgehash, mf->v3, mf->v4, NULL); (*fs) |= 4; } - if (v1!=v4) { + if (v1 != v4) { BLI_edgehash_insert(edgehash, mf->v1, mf->v4, NULL); (*fs) |= 8; } @@ -611,7 +611,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) else { (*fs) |= 16; /* mark face as tri */ - if (v1!=v3) { + if (v1 != v3) { BLI_edgehash_insert(edgehash, mf->v1, mf->v3, NULL); (*fs) |= 4; } @@ -619,8 +619,8 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) } /* count splits & create indexes for new verts */ - ehi= BLI_edgehashIterator_new(edgehash); - totesplit=totvert; + ehi = BLI_edgehashIterator_new(edgehash); + totesplit = totvert; for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totesplit)); totesplit++; @@ -628,14 +628,14 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) BLI_edgehashIterator_free(ehi); /* count new faces due to splitting */ - for (i=0, fs=facesplit; ifaceData, CD_MTFACE); /* copy new faces & verts (is it really this painful with custom data??) */ - for (i=0; igetVert(dm, i, &source); @@ -651,23 +651,23 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) * later interpreted as tri's, for this to work right I think we probably * have to stop using tessface - campbell */ - facepa= MEM_callocN(sizeof(int)*(totface+(totfsplit * 2)), "explode_facepa"); + facepa = MEM_callocN(sizeof(int) * (totface + (totfsplit * 2)), "explode_facepa"); //memcpy(facepa, emd->facepa, totface*sizeof(int)); - emd->facepa=facepa; + emd->facepa = facepa; /* create new verts */ - ehi= BLI_edgehashIterator_new(edgehash); + ehi = BLI_edgehashIterator_new(edgehash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2); - esplit= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - mv=CDDM_get_vert(splitdm, ed_v2); - dupve=CDDM_get_vert(splitdm, esplit); + esplit = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); + mv = CDDM_get_vert(splitdm, ed_v2); + dupve = CDDM_get_vert(splitdm, esplit); DM_copy_vert_data(splitdm, splitdm, ed_v2, esplit, 1); - *dupve=*mv; + *dupve = *mv; - mv=CDDM_get_vert(splitdm, ed_v1); + mv = CDDM_get_vert(splitdm, ed_v1); add_v3_v3(dupve->co, mv->co); mul_v3_fl(dupve->co, 0.5f); @@ -675,99 +675,99 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) BLI_edgehashIterator_free(ehi); /* create new faces */ - curdupface=0;//=totface; + curdupface = 0; //=totface; //curdupin=totesplit; - for (i=0, fs=facesplit; igetTessFaceData(dm, i, CD_MFACE); switch (*fs) { - case 3: - case 10: - case 11: - case 15: - SET_VERTS(1, 2, 3, 4); - break; - case 5: - case 6: - case 7: - SET_VERTS(2, 3, 4, 1); - break; - case 9: - case 13: - SET_VERTS(4, 1, 2, 3); - break; - case 12: - case 14: - SET_VERTS(3, 4, 1, 2); - break; - case 21: - case 23: - SET_VERTS(1, 2, 3, 4); - break; - case 19: - SET_VERTS(2, 3, 1, 4); - break; - case 22: - SET_VERTS(3, 1, 2, 4); - break; + case 3: + case 10: + case 11: + case 15: + SET_VERTS(1, 2, 3, 4); + break; + case 5: + case 6: + case 7: + SET_VERTS(2, 3, 4, 1); + break; + case 9: + case 13: + SET_VERTS(4, 1, 2, 3); + break; + case 12: + case 14: + SET_VERTS(3, 4, 1, 2); + break; + case 21: + case 23: + SET_VERTS(1, 2, 3, 4); + break; + case 19: + SET_VERTS(2, 3, 1, 4); + break; + case 22: + SET_VERTS(3, 1, 2, 4); + break; } switch (*fs) { - case 3: - case 6: - case 9: - case 12: - remap_faces_3_6_9_12(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_3_6_9_12(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 5: - case 10: - remap_faces_5_10(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_5_10(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 15: - remap_faces_15(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_15(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 7: - case 11: - case 13: - case 14: - remap_faces_7_11_13_14(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_7_11_13_14(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 19: - case 21: - case 22: - remap_faces_19_21_22(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); - if (numlayer) - remap_uvs_19_21_22(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); - break; - case 23: - remap_faces_23(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); - if (numlayer) - remap_uvs_23(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); - break; - case 0: - case 16: - df1 = get_dface(dm, splitdm, curdupface, i, mf); - facepa[curdupface] = vertpa[mf->v1]; + case 3: + case 6: + case 9: + case 12: + remap_faces_3_6_9_12(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_3_6_9_12(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 5: + case 10: + remap_faces_5_10(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_5_10(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 15: + remap_faces_15(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_15(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 7: + case 11: + case 13: + case 14: + remap_faces_7_11_13_14(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_7_11_13_14(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 19: + case 21: + case 22: + remap_faces_19_21_22(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); + if (numlayer) + remap_uvs_19_21_22(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); + break; + case 23: + remap_faces_23(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); + if (numlayer) + remap_uvs_23(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); + break; + case 0: + case 16: + df1 = get_dface(dm, splitdm, curdupface, i, mf); + facepa[curdupface] = vertpa[mf->v1]; - if (df1->v4) - df1->flag |= ME_FACE_SEL; - else - df1->flag &= ~ME_FACE_SEL; - break; + if (df1->v4) + df1->flag |= ME_FACE_SEL; + else + df1->flag &= ~ME_FACE_SEL; + break; } - curdupface += add_faces[*fs]+1; + curdupface += add_faces[*fs] + 1; } - for (i=0; ifaceData, i, (mf->flag & ME_FACE_SEL ? 4 : 3)); } @@ -781,46 +781,46 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) return splitdm; } -static DerivedMesh * explodeMesh(ExplodeModifierData *emd, - ParticleSystemModifierData *psmd, Scene *scene, Object *ob, - DerivedMesh *to_explode) +static DerivedMesh *explodeMesh(ExplodeModifierData *emd, + ParticleSystemModifierData *psmd, Scene *scene, Object *ob, + DerivedMesh *to_explode) { - DerivedMesh *explode, *dm=to_explode; - MFace *mf= NULL, *mface; + DerivedMesh *explode, *dm = to_explode; + MFace *mf = NULL, *mface; /* ParticleSettings *part=psmd->psys->part; */ /* UNUSED */ - ParticleSimulationData sim= {NULL}; - ParticleData *pa=NULL, *pars=psmd->psys->particles; + ParticleSimulationData sim = {NULL}; + ParticleData *pa = NULL, *pars = psmd->psys->particles; ParticleKey state, birth; EdgeHash *vertpahash; EdgeHashIterator *ehi; - float *vertco= NULL, imat[4][4]; + float *vertco = NULL, imat[4][4]; float rot[4]; float cfra; /* float timestep; */ - int *facepa=emd->facepa; - int totdup=0, totvert=0, totface=0, totpart=0, delface=0; + int *facepa = emd->facepa; + int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0; int i, v, u; - unsigned int ed_v1, ed_v2, mindex=0; + unsigned int ed_v1, ed_v2, mindex = 0; MTFace *mtface = NULL, *mtf; - totface= dm->getNumTessFaces(dm); - totvert= dm->getNumVerts(dm); - mface= dm->getTessFaceArray(dm); - totpart= psmd->psys->totpart; + totface = dm->getNumTessFaces(dm); + totvert = dm->getNumVerts(dm); + mface = dm->getTessFaceArray(dm); + totpart = psmd->psys->totpart; - sim.scene= scene; - sim.ob= ob; - sim.psys= psmd->psys; - sim.psmd= psmd; + sim.scene = scene; + sim.ob = ob; + sim.psys = psmd->psys; + sim.psmd = psmd; /* timestep= psys_get_timestep(&sim); */ - cfra= BKE_scene_frame_get(scene); + cfra = BKE_scene_frame_get(scene); /* hash table for vertice <-> particle relations */ - vertpahash= BLI_edgehash_new(); + vertpahash = BLI_edgehash_new(); - for (i=0; itime) - mindex = totvert+totpart; + if (facepa[i] == totpart || cfra < (pars + facepa[i])->time) + mindex = totvert + totpart; else - mindex = totvert+facepa[i]; + mindex = totvert + facepa[i]; - mf= &mface[i]; + mf = &mface[i]; /* set face vertices to exist in particle group */ BLI_edgehash_insert(vertpahash, mf->v1, mindex, NULL); @@ -851,7 +851,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, } /* make new vertice indexes & count total vertices after duplication */ - ehi= BLI_edgehashIterator_new(vertpahash); + ehi = BLI_edgehashIterator_new(vertpahash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totdup)); totdup++; @@ -859,7 +859,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, BLI_edgehashIterator_free(ehi); /* the final duplicated vertices */ - explode= CDDM_from_template(dm, totdup, 0, totface-delface, 0, 0); + explode = CDDM_from_template(dm, totdup, 0, totface - delface, 0, 0); mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname); /*dupvert= CDDM_get_verts(explode);*/ @@ -869,7 +869,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, psmd->psys->lattice = psys_get_lattice(&sim); /* duplicate & displace vertices */ - ehi= BLI_edgehashIterator_new(vertpahash); + ehi = BLI_edgehashIterator_new(vertpahash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { MVert source; MVert *dest; @@ -877,7 +877,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* get particle + vertex from hash */ BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2); ed_v2 -= totvert; - v= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); + v = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); dm->getVert(dm, ed_v1, &source); dest = CDDM_get_vert(explode, v); @@ -887,14 +887,14 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, if (ed_v2 != totpart) { /* get particle */ - pa= pars + ed_v2; + pa = pars + ed_v2; psys_get_birth_coordinates(&sim, pa, &birth, 0, 0); - state.time=cfra; + state.time = cfra; psys_get_particle_state(&sim, ed_v2, &state, 1); - vertco=CDDM_get_vert(explode, v)->co; + vertco = CDDM_get_vert(explode, v)->co; mul_m4_v3(ob->obmat, vertco); sub_v3_v3(vertco, birth.co); @@ -914,27 +914,27 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, BLI_edgehashIterator_free(ehi); /*map new vertices to faces*/ - for (i=0, u=0; ialive==PARS_UNBORN && (emd->flag&eExplodeFlag_Unborn)==0) continue; - if (pa->alive==PARS_ALIVE && (emd->flag&eExplodeFlag_Alive)==0) continue; - if (pa->alive==PARS_DEAD && (emd->flag&eExplodeFlag_Dead)==0) continue; + if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) continue; + if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) continue; + if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) continue; } dm->getTessFace(dm, i, &source); - mf=CDDM_get_tessface(explode, u); + mf = CDDM_get_tessface(explode, u); orig_v4 = source.v4; - if (facepa[i]!=totpart && cfra < pa->time) - mindex = totvert+totpart; + if (facepa[i] != totpart && cfra < pa->time) + mindex = totvert + totpart; else - mindex = totvert+facepa[i]; + mindex = totvert + facepa[i]; source.v1 = edgecut_get(vertpahash, source.v1, mindex); source.v2 = edgecut_get(vertpahash, source.v2, mindex); @@ -948,7 +948,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* override uv channel for particle age */ if (mtface) { - float age = (cfra - pa->time)/pa->lifetime; + float age = (cfra - pa->time) / pa->lifetime; /* Clamp to this range to avoid flipping to the other side of the coordinates. */ CLAMP(age, 0.001f, 0.999f); @@ -972,45 +972,45 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, if (psmd->psys->lattice) { end_latt_deform(psmd->psys->lattice); - psmd->psys->lattice= NULL; + psmd->psys->lattice = NULL; } return explode; } -static ParticleSystemModifierData * findPrecedingParticlesystem(Object *ob, ModifierData *emd) +static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, ModifierData *emd) { ModifierData *md; - ParticleSystemModifierData *psmd= NULL; + ParticleSystemModifierData *psmd = NULL; - for (md=ob->modifiers.first; emd!=md; md=md->next) { - if (md->type==eModifierType_ParticleSystem) - psmd= (ParticleSystemModifierData*) md; + for (md = ob->modifiers.first; emd != md; md = md->next) { + if (md->type == eModifierType_ParticleSystem) + psmd = (ParticleSystemModifierData *) md; } return psmd; } -static DerivedMesh * applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) +static DerivedMesh *applyModifier(ModifierData *md, Object *ob, + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = derivedData; - ExplodeModifierData *emd= (ExplodeModifierData*) md; - ParticleSystemModifierData *psmd=findPrecedingParticlesystem(ob, md); + ExplodeModifierData *emd = (ExplodeModifierData *) md; + ParticleSystemModifierData *psmd = findPrecedingParticlesystem(ob, md); DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ if (psmd) { - ParticleSystem * psys=psmd->psys; + ParticleSystem *psys = psmd->psys; - if (psys==NULL || psys->totpart==0) return derivedData; - if (psys->part==NULL || psys->particles==NULL) return derivedData; - if (psmd->dm==NULL) return derivedData; + if (psys == NULL || psys->totpart == 0) return derivedData; + if (psys->part == NULL || psys->particles == NULL) return derivedData; + if (psmd->dm == NULL) return derivedData; /* 1. find faces to be exploded if needed */ if (emd->facepa == NULL || - psmd->flag&eParticleSystemFlag_Pars || - emd->flag&eExplodeFlag_CalcFaces || + psmd->flag & eParticleSystemFlag_Pars || + emd->flag & eExplodeFlag_CalcFaces || MEM_allocN_len(emd->facepa) / sizeof(int) != dm->getNumTessFaces(dm)) { if (psmd->flag & eParticleSystemFlag_Pars) @@ -1028,7 +1028,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, DerivedMesh *explode = explodeMesh(emd, psmd, md->scene, ob, splitdm); MEM_freeN(emd->facepa); - emd->facepa=facepa; + emd->facepa = facepa; splitdm->release(splitdm); return explode; } @@ -1040,26 +1040,26 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, ModifierTypeInfo modifierType_Explode = { - /* name */ "Explode", - /* structName */ "ExplodeModifierData", - /* structSize */ sizeof(ExplodeModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Explode", + /* structName */ "ExplodeModifierData", + /* structSize */ sizeof(ExplodeModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index 55182578938..4cd88370f4a 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -52,21 +52,21 @@ /* Fluidsim */ static void initData(ModifierData *md) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; fluidsim_init(fluidmd); } static void freeData(ModifierData *md) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; fluidsim_free(fluidmd); } static void copyData(ModifierData *md, ModifierData *target) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - FluidsimModifierData *tfluidmd= (FluidsimModifierData*) target; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; + FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target; if (tfluidmd->fss) MEM_freeN(tfluidmd->fss); @@ -77,11 +77,11 @@ static void copyData(ModifierData *md, ModifierData *target) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int useRenderParams, - int isFinalCalc) + DerivedMesh *dm, + int useRenderParams, + int isFinalCalc) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; DerivedMesh *result = NULL; /* check for alloc failing */ @@ -93,29 +93,30 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } - result= fluidsimModifier_do(fluidmd, md->scene, ob, dm, useRenderParams, isFinalCalc); + result = fluidsimModifier_do(fluidmd, md->scene, ob, dm, useRenderParams, isFinalCalc); return result ? result : dm; } static void updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) + ModifierData *md, DagForest *forest, Scene *scene, + Object *ob, DagNode *obNode) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; Base *base; if (fluidmd && fluidmd->fss) { if (fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) { - for (base = scene->base.first; base; base= base->next) { - Object *ob1= base->object; + for (base = scene->base.first; base; base = base->next) { + Object *ob1 = base->object; if (ob1 != ob) { - FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim); + FluidsimModifierData *fluidmdtmp = + (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim); /* only put dependencies from NON-DOMAIN fluids in here */ - if (fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type!=OB_FLUIDSIM_DOMAIN)) { + if (fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type != OB_FLUIDSIM_DOMAIN)) { DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Fluidsim Object"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Fluidsim Object"); } } } @@ -135,9 +136,9 @@ ModifierTypeInfo modifierType_Fluidsim = { /* structSize */ sizeof(FluidsimModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_RequiresOriginalData - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_RequiresOriginalData | + eModifierTypeFlag_Single, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 80c48062635..a33d80bcd35 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -177,7 +177,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam float no[3]; const short mp_mat_nr = mp_example->mat_nr; - const char mp_flag = mp_example->flag; + const char mp_flag = mp_example->flag; // ------------------------------------------------ // get numverts + numfaces first @@ -231,7 +231,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam // read vertex position from file mv = CDDM_get_verts(dm); - for (i=0; ico, sizeof(float) * 3); // should be the same as numverts @@ -243,7 +243,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals" ); + normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals"); if (!normals) { if (dm) dm->release(dm); @@ -252,7 +252,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam } // read normals from file (but don't save them yet) - for (i=numverts, no_s= normals; i>0; i--, no_s += 3) { + for (i = numverts, no_s = normals; i > 0; i--, no_s += 3) { gotBytes = gzread(gzf, no, sizeof(float) * 3); normal_float_to_short_v3(no_s, no); } @@ -260,7 +260,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam /* read no. of triangles */ gotBytes = gzread(gzf, &wri, sizeof(wri)); - if (wri!=numfaces) { + if (wri != numfaces) { printf("Fluidsim: error in reading data from file.\n"); if (dm) dm->release(dm); @@ -272,7 +272,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam // read triangles from file mp = CDDM_get_polys(dm); ml = CDDM_get_loops(dm); - for (i=0; i < numfaces; i++, mp++, ml += 3) { + for (i = 0; i < numfaces; i++, mp++, ml += 3) { int face[3]; gotBytes = gzread(gzf, face, sizeof(int) * 3); @@ -303,10 +303,10 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], - /*RET*/ float start[3], /*RET*/ float size[3] ) + /*RET*/ float start[3], /*RET*/ float size[3]) { - float bbsx=0.0, bbsy=0.0, bbsz=0.0; - float bbex=1.0, bbey=1.0, bbez=1.0; + float bbsx = 0.0, bbsy = 0.0, bbsz = 0.0; + float bbex = 1.0, bbey = 1.0, bbez = 1.0; int i; float vec[3]; @@ -325,12 +325,12 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], copy_v3_v3(vec, mvert[i].co); mul_m4_v3(obmat, vec); - if (vec[0] < bbsx) { bbsx= vec[0]; } - if (vec[1] < bbsy) { bbsy= vec[1]; } - if (vec[2] < bbsz) { bbsz= vec[2]; } - if (vec[0] > bbex) { bbex= vec[0]; } - if (vec[1] > bbey) { bbey= vec[1]; } - if (vec[2] > bbez) { bbez= vec[2]; } + if (vec[0] < bbsx) { bbsx = vec[0]; } + if (vec[1] < bbsy) { bbsy = vec[1]; } + if (vec[2] < bbsz) { bbsz = vec[2]; } + if (vec[0] > bbex) { bbex = vec[0]; } + if (vec[1] > bbey) { bbey = vec[1]; } + if (vec[2] > bbez) { bbez = vec[2]; } } // return values... @@ -340,9 +340,9 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], start[2] = bbsz; } if (size) { - size[0] = bbex-bbsx; - size[1] = bbey-bbsy; - size[2] = bbez-bbsz; + size[0] = bbex - bbsx; + size[1] = bbey - bbsy; + size[2] = bbez - bbsz; } } @@ -354,11 +354,11 @@ void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value) { Mesh *mesh; - value[0]= '\0'; + value[0] = '\0'; if (ob->type == OB_MESH) { /* use mesh bounding box and object scaling */ - mesh= ob->data; + mesh = ob->data; fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); elbeemEstimateMemreq(fss->resolutionxyz, fss->bbSize[0], fss->bbSize[1], fss->bbSize[2], fss->maxRefine, value); @@ -386,18 +386,18 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * return; } - if (fss->domainNovecgen>0) return; + if (fss->domainNovecgen > 0) return; - fss->meshVelocities = MEM_callocN(sizeof(FluidVertexVelocity)*dm->getNumVerts(dm), "Fluidsim_velocities"); + fss->meshVelocities = MEM_callocN(sizeof(FluidVertexVelocity) * dm->getNumVerts(dm), "Fluidsim_velocities"); fss->totvert = totvert; velarray = fss->meshVelocities; // .bobj.gz, correct filename // 87654321 - filename[len-6] = 'v'; - filename[len-5] = 'e'; - filename[len-4] = 'l'; + filename[len - 6] = 'v'; + filename[len - 5] = 'e'; + filename[len - 4] = 'l'; gzf = BLI_gzopen(filename, "rb"); if (!gzf) { @@ -413,8 +413,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * return; } - for (i=0; ir.sfra*/; /* start with 0 at start frame */ @@ -441,17 +442,17 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim } switch (displaymode) { - case 1: - /* just display original object */ - return NULL; - case 2: - /* use preview mesh */ - BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME); - break; - default: /* 3 */ - /* 3. use final mesh */ - BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); - break; + case 1: + /* just display original object */ + return NULL; + case 2: + /* use preview mesh */ + BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME); + break; + default: /* 3 */ + /* 3. use final mesh */ + BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); + break; } /* offset baked frame */ @@ -474,11 +475,12 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim // switch, abort background rendering when fluidsim mesh is missing const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp - if (G.background==1) { + if (G.background == 1) { if (getenv(strEnvName2)) { int elevel = atoi(getenv(strEnvName2)); - if (elevel>0) { - printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n", strEnvName2, targetFile); + if (elevel > 0) { + printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n", + strEnvName2, targetFile); exit(1); } } @@ -491,7 +493,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim // load vertex velocities, if they exist... // TODO? use generate flag as loading flag as well? // warning, needs original .bobj.gz mesh loading filename - if (displaymode==3) { + if (displaymode == 3) { fluidsim_read_vel_cache(fluidmd, dm, targetFile); } else { @@ -506,16 +508,16 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim #endif // WITH_MOD_FLUID DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, - Object *ob, - DerivedMesh *dm, - int useRenderParams, int UNUSED(isFinalCalc)) + Object *ob, + DerivedMesh *dm, + int useRenderParams, int UNUSED(isFinalCalc)) { #ifdef WITH_MOD_FLUID DerivedMesh *result = NULL; int framenr; FluidsimSettings *fss = NULL; - framenr= (int)scene->r.cfra; + framenr = (int)scene->r.cfra; // only handle fluidsim domains if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 0b0a276c4a0..9acf556fc37 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -54,15 +54,15 @@ static void initData(ModifierData *md) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; - hmd->force= 1.0; + hmd->force = 1.0; } static void copyData(ModifierData *md, ModifierData *target) { - HookModifierData *hmd = (HookModifierData*) md; - HookModifierData *thmd = (HookModifierData*) target; + HookModifierData *hmd = (HookModifierData *) md; + HookModifierData *thmd = (HookModifierData *) target; copy_v3_v3(thmd->cent, hmd->cent); thmd->falloff = hmd->falloff; @@ -89,34 +89,34 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static void freeData(ModifierData *md) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; if (hmd->indexar) MEM_freeN(hmd->indexar); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; return !hmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; walk(userData, ob, &hmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; if (hmd->object) { DagNode *curNode = dag_get_node(forest, hmd->object); @@ -146,10 +146,10 @@ 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= BKE_pose_channel_find_name(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 */ + const float falloff_squared = hmd->falloff * hmd->falloff; /* for faster comparisons */ MDeformVert *dvert; int defgrp_index, max_dvert; @@ -168,7 +168,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, NULL, NULL, NULL, NULL, NULL); modifier_get_vgroup(ob, dm, hmd->name, &dvert, &defgrp_index); - max_dvert = (dvert)? numVerts: 0; + max_dvert = (dvert) ? numVerts : 0; /* Regarding index range checking below. * @@ -182,13 +182,13 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, /* do nothing, avoid annoying checks in the loop */ } else if (hmd->indexar) { /* vertex indices? */ - const float fac_orig= hmd->force; + const float fac_orig = hmd->force; float fac; const int *origindex_ar; /* if DerivedMesh is present and has original index data, use it */ - if (dm && (origindex_ar= dm->getVertDataArray(dm, CD_ORIGINDEX))) { - for (i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) { + if (dm && (origindex_ar = dm->getVertDataArray(dm, CD_ORIGINDEX))) { + for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { if (*index_pt < numVerts) { int j; @@ -226,7 +226,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } } } - else if (dvert) { /* vertex group hook */ + else if (dvert) { /* vertex group hook */ const float fac_orig = hmd->force; for (i = 0; i < max_dvert; i++, dvert++) { @@ -248,7 +248,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; DerivedMesh *dm = derivedData; /* We need a valid dm for meshes when a vgroup is set... */ if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0') @@ -263,7 +263,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; DerivedMesh *dm = derivedData; /* We need a valid dm for meshes when a vgroup is set... */ if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0') @@ -281,8 +281,8 @@ ModifierTypeInfo modifierType_Hook = { /* structName */ "HookModifierData", /* structSize */ sizeof(HookModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index ca700d4d8f2..a1ff0ba3012 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -50,14 +50,14 @@ static void initData(ModifierData *md) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; lmd->strength = 1.0f; } static void copyData(ModifierData *md, ModifierData *target) { - LatticeModifierData *lmd = (LatticeModifierData*) md; - LatticeModifierData *tlmd = (LatticeModifierData*) target; + LatticeModifierData *lmd = (LatticeModifierData *) md; + LatticeModifierData *tlmd = (LatticeModifierData *) target; tlmd->object = lmd->object; BLI_strncpy(tlmd->name, lmd->name, sizeof(tlmd->name)); @@ -76,27 +76,27 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; return !lmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; walk(userData, ob, &lmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; if (lmd->object) { DagNode *latNode = dag_get_node(forest, lmd->object); @@ -107,13 +107,13 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -123,8 +123,8 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index aa7d0446a36..8940c4fd079 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -57,8 +57,8 @@ static void copyData(ModifierData *md, ModifierData *target) { - MaskModifierData *mmd = (MaskModifierData*) md; - MaskModifierData *tmmd = (MaskModifierData*) target; + MaskModifierData *mmd = (MaskModifierData *) md; + MaskModifierData *tmmd = (MaskModifierData *) target; BLI_strncpy(tmmd->vgroup, mmd->vgroup, sizeof(tmmd->vgroup)); tmmd->flag = mmd->flag; @@ -70,18 +70,18 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { MaskModifierData *mmd = (MaskModifierData *)md; walk(userData, ob, &mmd->ob_arm); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { MaskModifierData *mmd = (MaskModifierData *)md; @@ -93,16 +93,16 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - MaskModifierData *mmd= (MaskModifierData *)md; - DerivedMesh *dm= derivedData, *result= NULL; - GHash *vertHash=NULL, *edgeHash, *polyHash; + MaskModifierData *mmd = (MaskModifierData *)md; + DerivedMesh *dm = derivedData, *result = NULL; + GHash *vertHash = NULL, *edgeHash, *polyHash; GHashIterator *hashIter; - MDeformVert *dvert= NULL, *dv; - int numPolys=0, numLoops=0, numEdges=0, numVerts=0; + MDeformVert *dvert = NULL, *dv; + int numPolys = 0, numLoops = 0, numEdges = 0, numVerts = 0; int maxVerts, maxEdges, maxPolys; int i; @@ -124,15 +124,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, */ /* get original number of verts, edges, and faces */ - maxVerts= dm->getNumVerts(dm); - maxEdges= dm->getNumEdges(dm); - maxPolys= dm->getNumPolys(dm); + maxVerts = dm->getNumVerts(dm); + maxEdges = dm->getNumEdges(dm); + maxPolys = dm->getNumPolys(dm); /* check if we can just return the original mesh * - must have verts and therefore verts assigned to vgroups to do anything useful */ - if ( !(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) || - (maxVerts == 0) || (ob->defbase.first == NULL) ) + if (!(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) || + (maxVerts == 0) || (ob->defbase.first == NULL) ) { return derivedData; } @@ -140,35 +140,35 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* if mode is to use selected armature bones, aggregate the bone groups */ if (mmd->mode == MOD_MASK_MODE_ARM) { /* --- using selected bones --- */ GHash *vgroupHash; - Object *oba= mmd->ob_arm; + Object *oba = mmd->ob_arm; bPoseChannel *pchan; bDeformGroup *def; char *bone_select_array; - int bone_select_tot= 0; - const int defbase_tot= BLI_countlist(&ob->defbase); + 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"); + bone_select_array = MEM_mallocN(defbase_tot * sizeof(char), "mask array"); for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { 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_array[i] = TRUE; bone_select_tot++; } else { - bone_select_array[i]= FALSE; + bone_select_array[i] = FALSE; } } /* hashes for finding mapping of: - * - vgroups to indices -> vgroupHash (string, int) - * - bones to vgroup indices -> boneHash (index of vgroup, dummy) + * - vgroups to indices -> vgroupHash (string, int) + * - bones to vgroup indices -> boneHash (index of vgroup, dummy) */ - vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); + vgroupHash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); /* build mapping of names of vertex groups to indices */ for (i = 0, def = ob->defbase.first; def; def = def->next, i++) @@ -183,7 +183,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* repeat the previous check, but for dverts */ - dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT); + dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert == NULL) { BLI_ghash_free(vgroupHash, NULL, NULL); MEM_freeN(bone_select_array); @@ -192,14 +192,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); + vertHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); /* add vertices which exist in vertexgroups into vertHash for filtering */ - for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - MDeformWeight *dw= dv->dw; + for (i = 0, dv = dvert; i < maxVerts; i++, dv++) { + MDeformWeight *dw = dv->dw; int j; - for (j= dv->totweight; j > 0; j--, dw++) { + for (j = dv->totweight; j > 0; j--, dw++) { if (dw->def_nr < defbase_tot) { if (bone_select_array[dw->def_nr]) { if (dw->weight != 0.0f) { @@ -228,7 +228,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, BLI_ghash_free(vgroupHash, NULL, NULL); MEM_freeN(bone_select_array); } - else { /* --- Using Nominated VertexGroup only --- */ + else { /* --- Using Nominated VertexGroup only --- */ int defgrp_index = defgroup_name_index(ob, mmd->vgroup); /* get dverts */ @@ -240,11 +240,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return dm; /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); + vertHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); /* add vertices which exist in vertexgroup into ghash for filtering */ - for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - const int weight_set= defvert_find_weight(dv, defgrp_index) != 0.0f; + for (i = 0, dv = dvert; i < maxVerts; i++, dv++) { + const int weight_set = defvert_find_weight(dv, defgrp_index) != 0.0f; /* check if include vert in vertHash */ if (mmd->flag & MOD_MASK_INV) { @@ -263,8 +263,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - edgeHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask ed2 gh"); - polyHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask fa2 gh"); + edgeHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask ed2 gh"); + polyHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask fa2 gh"); mpoly = dm->getPolyArray(dm); mloop = dm->getLoopArray(dm); diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 1bcafc2918e..c6f53b49175 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -57,14 +57,14 @@ static void initData(ModifierData *md) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; - mmd->gridsize= 5; + mmd->gridsize = 5; } static void freeData(ModifierData *md) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; if (mmd->bindinfluences) MEM_freeN(mmd->bindinfluences); if (mmd->bindoffsets) MEM_freeN(mmd->bindoffsets); @@ -72,14 +72,14 @@ static void freeData(ModifierData *md) if (mmd->dyngrid) MEM_freeN(mmd->dyngrid); if (mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); if (mmd->dynverts) MEM_freeN(mmd->dynverts); - if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ - if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ + if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ + if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ } static void copyData(ModifierData *md, ModifierData *target) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - MeshDeformModifierData *tmmd = (MeshDeformModifierData*) target; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; + MeshDeformModifierData *tmmd = (MeshDeformModifierData *) target; tmmd->gridsize = mmd->gridsize; tmmd->object = mmd->object; @@ -98,34 +98,34 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; return !mmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; walk(userData, ob, &mmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; if (mmd->object) { DagNode *curNode = dag_get_node(forest, mmd->object); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_OB_OB, - "Mesh Deform Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA | DAG_RL_DATA_OB | DAG_RL_OB_OB, + "Mesh Deform Modifier"); } } @@ -138,40 +138,40 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 int i, j, a, x, y, z, size; zero_v3(co); - totweight= 0.0f; - size= mmd->dyngridsize; + totweight = 0.0f; + size = mmd->dyngridsize; - for (i=0; i<3; i++) { - gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; + 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]; } - for (i=0; i<8; 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]; } + 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]; } + 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]; } + else { z = ivec[2]; wz = 1.0f - dvec[2]; } 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; + a = x + y * size + z * size * size; + weight = wx * wy * wz; - cell= &mmd->dyngrid[a]; - inf= mmd->dyninfluences + cell->offset; - for (j=0; jtotinfluence; j++, inf++) { - cageco= dco[inf->vertex]; - cageweight= weight*inf->weight; - co[0] += cageweight*cageco[0]; - co[1] += cageweight*cageco[1]; - co[2] += cageweight*cageco[2]; + cell = &mmd->dyngrid[a]; + inf = mmd->dyninfluences + cell->offset; + for (j = 0; j < cell->totinfluence; j++, inf++) { + cageco = dco[inf->vertex]; + cageweight = weight * inf->weight; + co[0] += cageweight * cageco[0]; + co[1] += cageweight * cageco[1]; + co[2] += cageweight * cageco[2]; totweight += cageweight; } } @@ -182,11 +182,11 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 } static void meshdeformModifier_do( - ModifierData *md, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - struct Mesh *me= (mmd->object)? mmd->object->data: NULL; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; + struct Mesh *me = (mmd->object) ? mmd->object->data : NULL; BMEditMesh *em = me ? me->edit_btmesh : NULL; DerivedMesh *tmpdm, *cagedm; MDeformVert *dvert = NULL; @@ -202,19 +202,19 @@ static void meshdeformModifier_do( /* get cage derivedmesh */ if (em) { - tmpdm= editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0); + tmpdm = editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0); if (tmpdm) tmpdm->release(tmpdm); } else - cagedm= mmd->object->derivedFinal; + cagedm = mmd->object->derivedFinal; /* if we don't have one computed, use derivedmesh from data * without any modifiers */ if (!cagedm) { - cagedm= get_dm(mmd->object, NULL, NULL, NULL, 0); + cagedm = get_dm(mmd->object, NULL, NULL, NULL, 0); if (cagedm) - cagedm->needsFree= 1; + cagedm->needsFree = 1; } if (!cagedm) { @@ -236,14 +236,14 @@ static void meshdeformModifier_do( /* progress bar redraw can make this recursive .. */ if (!recursive) { recursive = 1; - mmd->bindfunc(md->scene, mmd, (float*)vertexCos, numVerts, cagemat); + mmd->bindfunc(md->scene, mmd, (float *)vertexCos, numVerts, cagemat); recursive = 0; } } /* verify we have compatible weights */ - totvert= numVerts; - totcagevert= cagedm->getNumVerts(cagedm); + totvert = numVerts; + totcagevert = cagedm->getNumVerts(cagedm); if (mmd->totvert != totvert) { modifier_setError(md, TIP_("Verts changed from %d to %d."), mmd->totvert, totvert); @@ -261,16 +261,16 @@ static void meshdeformModifier_do( return; } - cagecos= MEM_callocN(sizeof(*cagecos)*totcagevert, "meshdeformModifier vertCos"); + cagecos = MEM_callocN(sizeof(*cagecos) * totcagevert, "meshdeformModifier vertCos"); /* setup deformation data */ cagedm->getVertCos(cagedm, cagecos); - influences= mmd->bindinfluences; - offsets= mmd->bindoffsets; - bindcagecos= (float(*)[3])mmd->bindcagecos; + influences = mmd->bindinfluences; + offsets = mmd->bindoffsets; + bindcagecos = (float(*)[3])mmd->bindcagecos; - dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco"); - for (a=0; adefgrp_name, &dvert, &defgrp_index); /* do deformation */ - fac= 1.0f; + fac = 1.0f; - for (b=0; bflag & MOD_MDEF_DYNAMIC_BIND) if (!mmd->dynverts[b]) continue; if (dvert) { - fac= defvert_find_weight(&dvert[b], defgrp_index); + fac = defvert_find_weight(&dvert[b], defgrp_index); if (mmd->flag & MOD_MDEF_INVERT_VGROUP) { - fac= 1.0f - fac; + fac = 1.0f - fac; } if (fac <= 0.0f) { @@ -308,14 +308,14 @@ static void meshdeformModifier_do( if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { /* transform coordinate into cage's local space */ mul_v3_m4v3(co, cagemat, vertexCos[b]); - totweight= meshdeform_dynamic_bind(mmd, dco, co); + totweight = meshdeform_dynamic_bind(mmd, dco, co); } else { - totweight= 0.0f; + totweight = 0.0f; zero_v3(co); for (a = offsets[b]; a < offsets[b + 1]; a++) { - weight= influences[a].weight; + weight = influences[a].weight; madd_v3_v3fl(co, dco[influences[a].vertex], weight); totweight += weight; } @@ -338,13 +338,13 @@ static void meshdeformModifier_do( } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - DerivedMesh *dm= get_dm(ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -355,12 +355,12 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts) { - DerivedMesh *dm= get_dm(ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); meshdeformModifier_do(md, ob, dm, vertexCos, numVerts); @@ -372,21 +372,21 @@ static void deformVertsEM(ModifierData *md, Object *ob, void modifier_mdef_compact_influences(ModifierData *md) { - MeshDeformModifierData *mmd= (MeshDeformModifierData*)md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; float weight, *weights, totweight; int totinfluence, totvert, totcagevert, a, b; - weights= mmd->bindweights; + weights = mmd->bindweights; if (!weights) return; - totvert= mmd->totvert; - totcagevert= mmd->totcagevert; + totvert = mmd->totvert; + totcagevert = mmd->totcagevert; /* count number of influences above threshold */ - for (b=0; b MESHDEFORM_MIN_INFLUENCE) mmd->totinfluence++; @@ -398,23 +398,23 @@ void modifier_mdef_compact_influences(ModifierData *md) mmd->bindoffsets = MEM_callocN(sizeof(int) * (totvert + 1), "MDefBindOffset"); /* write influences */ - totinfluence= 0; + totinfluence = 0; - for (b=0; bbindoffsets[b]= totinfluence; - totweight= 0.0f; + for (b = 0; b < totvert; b++) { + mmd->bindoffsets[b] = totinfluence; + totweight = 0.0f; /* sum total weight */ - for (a=0; a MESHDEFORM_MIN_INFLUENCE) totweight += weight; } /* assign weights normalized */ - for (a=0; a MESHDEFORM_MIN_INFLUENCE) { mmd->bindinfluences[totinfluence].weight = weight / totweight; @@ -424,36 +424,36 @@ void modifier_mdef_compact_influences(ModifierData *md) } } - mmd->bindoffsets[b]= totinfluence; + mmd->bindoffsets[b] = totinfluence; /* free */ MEM_freeN(mmd->bindweights); - mmd->bindweights= NULL; + mmd->bindweights = NULL; } ModifierTypeInfo modifierType_MeshDeform = { - /* name */ "MeshDeform", - /* structName */ "MeshDeformModifierData", - /* structSize */ sizeof(MeshDeformModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* name */ "MeshDeform", + /* structName */ "MeshDeformModifierData", + /* structSize */ sizeof(MeshDeformModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 2df0bd17eaf..7cbf2718d86 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; mmd->flag |= (MOD_MIR_AXIS_X | MOD_MIR_VGROUP); mmd->tolerance = 0.001; @@ -60,8 +60,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - MirrorModifierData *mmd = (MirrorModifierData*) md; - MirrorModifierData *tmmd = (MirrorModifierData*) target; + MirrorModifierData *mmd = (MirrorModifierData *) md; + MirrorModifierData *tmmd = (MirrorModifierData *) target; tmmd->flag = mmd->flag; tmmd->tolerance = mmd->tolerance; @@ -72,7 +72,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; walk(userData, ob, &mmd->mirror_ob); } @@ -82,7 +82,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Object *UNUSED(ob), DagNode *obNode) { - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; if (mmd->mirror_ob) { DagNode *latNode = dag_get_node(forest, mmd->mirror_ob); @@ -138,7 +138,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, mult_m4_m4m4(mtx, itmp, mtx); } - result = CDDM_from_template(dm, maxVerts*2, maxEdges*2, 0, maxLoops*2, maxPolys*2); + result = CDDM_from_template(dm, maxVerts * 2, maxEdges * 2, 0, maxLoops * 2, maxPolys * 2); /*copy customdata to original geometry*/ DM_copy_vert_data(dm, result, 0, 0, maxVerts); @@ -249,8 +249,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, /* handle uvs, * let tessface recalc handle updating the MTFace data */ if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V)) { - const int do_mirr_u= (mmd->flag & MOD_MIR_MIRROR_U) != 0; - const int do_mirr_v= (mmd->flag & MOD_MIR_MIRROR_V) != 0; + const int do_mirr_u = (mmd->flag & MOD_MIR_MIRROR_U) != 0; + const int do_mirr_v = (mmd->flag & MOD_MIR_MIRROR_V) != 0; const int totuv = CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); @@ -258,7 +258,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, MLoopUV *dmloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, a); int j = maxLoops; dmloopuv += j; /* second set of loops only */ - for ( ; i-- > 0; dmloopuv++) { + for (; i-- > 0; dmloopuv++) { if (do_mirr_u) dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0]; if (do_mirr_v) dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1]; } @@ -268,9 +268,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, /* handle vgroup stuff */ if ((mmd->flag & MOD_MIR_VGROUP) && CustomData_has_layer(&result->vertData, CD_MDEFORMVERT)) { MDeformVert *dvert = (MDeformVert *) CustomData_get_layer(&result->vertData, CD_MDEFORMVERT) + maxVerts; - int *flip_map= NULL, flip_map_len= 0; + int *flip_map = NULL, flip_map_len = 0; - flip_map= defgroup_flip_map(ob, &flip_map_len, FALSE); + flip_map = defgroup_flip_map(ob, &flip_map_len, FALSE); if (flip_map) { for (i = 0; i < maxVerts; dvert++, i++) { @@ -309,12 +309,12 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, if (mmd->flag & MOD_MIR_AXIS_Y) { DerivedMesh *tmp = result; result = doMirrorOnAxis(mmd, ob, result, 1); - if (tmp != dm) tmp->release(tmp); /* free intermediate results */ + if (tmp != dm) tmp->release(tmp); /* free intermediate results */ } if (mmd->flag & MOD_MIR_AXIS_Z) { DerivedMesh *tmp = result; result = doMirrorOnAxis(mmd, ob, result, 2); - if (tmp != dm) tmp->release(tmp); /* free intermediate results */ + if (tmp != dm) tmp->release(tmp); /* free intermediate results */ } return result; @@ -326,7 +326,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, int UNUSED(isFinalCalc)) { DerivedMesh *result; - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; result = mirrorModifier__doMirror(mmd, ob, derivedData); @@ -349,11 +349,11 @@ ModifierTypeInfo modifierType_Mirror = { /* structName */ "MirrorModifierData", /* structSize */ sizeof(MirrorModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index df3f78b7f11..42ba66719da 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -49,7 +49,7 @@ static void initData(ModifierData *md) { - MultiresModifierData *mmd = (MultiresModifierData*)md; + MultiresModifierData *mmd = (MultiresModifierData *)md; mmd->lvl = 0; mmd->sculptlvl = 0; @@ -59,8 +59,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - MultiresModifierData *mmd = (MultiresModifierData*) md; - MultiresModifierData *tmmd = (MultiresModifierData*) target; + MultiresModifierData *mmd = (MultiresModifierData *) md; + MultiresModifierData *tmmd = (MultiresModifierData *) target; tmmd->lvl = mmd->lvl; tmmd->sculptlvl = mmd->sculptlvl; @@ -71,11 +71,11 @@ static void copyData(ModifierData *md, ModifierData *target) } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, - int useRenderParams, int isFinalCalc) + int useRenderParams, int isFinalCalc) { - MultiresModifierData *mmd = (MultiresModifierData*)md; + MultiresModifierData *mmd = (MultiresModifierData *)md; DerivedMesh *result; - Mesh *me= (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; if (mmd->totlvl) { if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) { @@ -92,7 +92,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, if (useRenderParams || !isFinalCalc) { DerivedMesh *cddm; - cddm= CDDM_copy(result); + cddm = CDDM_copy(result); /* copy hidden flag to vertices */ if (!useRenderParams) { @@ -100,8 +100,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); if (mdisps) { subsurf_copy_grid_hidden(result, me->mpoly, - cddm->getVertArray(cddm), - mdisps); + cddm->getVertArray(cddm), + mdisps); BKE_mesh_flush_hidden_from_verts(cddm->getVertArray(cddm), cddm->getLoopArray(cddm), @@ -113,7 +113,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, } result->release(result); - result= cddm; + result = cddm; } return result; @@ -125,9 +125,9 @@ ModifierTypeInfo modifierType_Multires = { /* structName */ "MultiresModifierData", /* structSize */ sizeof(MultiresModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_RequiresOriginalData, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_RequiresOriginalData, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index 967532adf3c..7bdff12b348 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -53,8 +53,8 @@ ModifierTypeInfo modifierType_None = { /* structName */ "ModifierData", /* structSize */ sizeof(ModifierData), /* type */ eModifierTypeType_None, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs, /* copyData */ NULL, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index fd8691991ff..0bf4d46f975 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -50,7 +50,7 @@ #ifdef WITH_OCEANSIM static void init_cache_data(Object *ob, struct OceanModifierData *omd) { - const char *relbase= modifier_path_relbase(ob); + const char *relbase = modifier_path_relbase(ob); omd->oceancache = BKE_init_ocean_cache(omd->cachepath, relbase, omd->bakestart, omd->bakeend, omd->wave_scale, @@ -77,7 +77,8 @@ static void init_ocean_modifier(struct OceanModifierData *omd) do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); BKE_free_ocean_data(omd->ocean); - BKE_init_ocean(omd->ocean, omd->resolution*omd->resolution, omd->resolution*omd->resolution, omd->spatial_size, omd->spatial_size, + BKE_init_ocean(omd->ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution, + omd->spatial_size, omd->spatial_size, omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, omd->depth, omd->time, do_heightfield, do_chop, do_normals, do_jacobian, @@ -99,7 +100,7 @@ static void simulate_ocean_modifier(struct OceanModifierData *omd) static void initData(ModifierData *md) { #ifdef WITH_OCEANSIM - OceanModifierData *omd = (OceanModifierData*) md; + OceanModifierData *omd = (OceanModifierData *) md; omd->resolution = 7; omd->spatial_size = 50; @@ -109,7 +110,7 @@ static void initData(ModifierData *md) omd->damp = 0.5; omd->smallest_wave = 0.01; - omd->wave_direction= 0.0; + omd->wave_direction = 0.0; omd->depth = 200.0; omd->wave_scale = 1.0; @@ -134,13 +135,13 @@ static void initData(ModifierData *md) omd->bakeend = 250; omd->oceancache = NULL; omd->foam_fade = 0.98; - omd->foamlayername[0] = '\0'; /* layer name empty by default */ + omd->foamlayername[0] = '\0'; /* layer name empty by default */ omd->ocean = BKE_add_ocean(); init_ocean_modifier(omd); simulate_ocean_modifier(omd); #else // WITH_OCEANSIM - /* unused */ + /* unused */ (void)md; #endif // WITH_OCEANSIM } @@ -148,7 +149,7 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { #ifdef WITH_OCEANSIM - OceanModifierData *omd = (OceanModifierData*) md; + OceanModifierData *omd = (OceanModifierData *) md; BKE_free_ocean(omd->ocean); if (omd->oceancache) @@ -162,8 +163,8 @@ static void freeData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { #ifdef WITH_OCEANSIM - OceanModifierData *omd = (OceanModifierData*) md; - OceanModifierData *tomd = (OceanModifierData*) target; + OceanModifierData *omd = (OceanModifierData *) md; + OceanModifierData *tomd = (OceanModifierData *) target; tomd->resolution = omd->resolution; tomd->spatial_size = omd->spatial_size; @@ -232,22 +233,22 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, float *oy) { /* get bounding box of underlying dm */ - int v, totvert=dm->getNumVerts(dm); + int v, totvert = dm->getNumVerts(dm); float min[3], max[3], delta[3]; - MVert *mvert = dm->getVertDataArray(dm,0); + MVert *mvert = dm->getVertDataArray(dm, 0); copy_v3_v3(min, mvert->co); copy_v3_v3(max, mvert->co); - for (v=1; vco[0]); - min[1]=MIN2(min[1],mvert->co[1]); - min[2]=MIN2(min[2],mvert->co[2]); + for (v = 1; v < totvert; v++, mvert++) { + min[0] = MIN2(min[0], mvert->co[0]); + min[1] = MIN2(min[1], mvert->co[1]); + min[2] = MIN2(min[2], mvert->co[2]); - max[0]=MAX2(max[0],mvert->co[0]); - max[1]=MAX2(max[1],mvert->co[1]); - max[2]=MAX2(max[2],mvert->co[2]); + max[0] = MAX2(max[0], mvert->co[0]); + max[1] = MAX2(max[1], mvert->co[1]); + max[2] = MAX2(max[2], mvert->co[2]); } sub_v3_v3v3(delta, max, min); @@ -263,7 +264,7 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa #ifdef WITH_OCEANSIM -#define OMP_MIN_RES 18 +#define OMP_MIN_RES 18 static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) { DerivedMesh *result; @@ -275,8 +276,8 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) int cdlayer; - const int rx = omd->resolution*omd->resolution; - const int ry = omd->resolution*omd->resolution; + const int rx = omd->resolution * omd->resolution; + const int ry = omd->resolution * omd->resolution; const int res_x = rx * omd->repeat_x; const int res_y = ry * omd->repeat_y; @@ -303,17 +304,17 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) mloops = CDDM_get_loops(result); #if 0 // trunk - origindex= result->getFaceDataArray(result, CD_ORIGINDEX); + origindex = result->getFaceDataArray(result, CD_ORIGINDEX); #else // bmesh - origindex= CustomData_get_layer(&result->polyData, CD_ORIGINDEX); + origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX); #endif /* create vertices */ #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y+1; y++) { - for (x=0; x < res_x+1; x++) { - const int i = y*(res_x+1) + x; - float *co= mverts[i].co; + for (y = 0; y < res_y + 1; y++) { + for (x = 0; x < res_x + 1; x++) { + const int i = y * (res_x + 1) + x; + float *co = mverts[i].co; co[0] = ox + (x * sx); co[1] = oy + (y * sy); co[2] = 0; @@ -322,12 +323,12 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) /* create faces */ #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y; y++) { - for (x=0; x < res_x; x++) { - const int fi = y*res_x + x; - const int vi = y*(res_x+1) + x; - MPoly *mp= &mpolys[fi]; - MLoop *ml= &mloops[fi * 4]; + for (y = 0; y < res_y; y++) { + for (x = 0; x < res_x; x++) { + const int fi = y * res_x + x; + const int vi = y * (res_x + 1) + x; + MPoly *mp = &mpolys[fi]; + MLoop *ml = &mloops[fi * 4]; ml->v = vi; ml++; @@ -338,8 +339,8 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) ml->v = vi + res_x + 1; ml++; - mp->loopstart= fi * 4; - mp->totloop= 4; + mp->loopstart = fi * 4; + mp->totloop = 4; mp->flag |= ME_SMOOTH; @@ -351,7 +352,7 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) CDDM_calc_edges(result); /* add uvs */ - cdlayer= CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); + cdlayer = CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); if (cdlayer < MAX_MTFACE) { MLoopUV *mloopuvs = CustomData_add_layer(&result->loopData, CD_MLOOPUV, CD_CALLOC, NULL, num_faces * 4); CustomData_add_layer(&result->polyData, CD_MTEXPOLY, CD_CALLOC, NULL, num_faces); @@ -360,25 +361,25 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) ix = 1.0 / rx; iy = 1.0 / ry; #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y; y++) { - for (x=0; x < res_x; x++) { - const int i = y*res_x + x; - MLoopUV *luv= &mloopuvs[i * 4]; + for (y = 0; y < res_y; y++) { + for (x = 0; x < res_x; x++) { + const int i = y * res_x + x; + MLoopUV *luv = &mloopuvs[i * 4]; luv->uv[0] = x * ix; luv->uv[1] = y * iy; luv++; - luv->uv[0] = (x+1) * ix; + luv->uv[0] = (x + 1) * ix; luv->uv[1] = y * iy; luv++; - luv->uv[0] = (x+1) * ix; - luv->uv[1] = (y+1) * iy; + luv->uv[0] = (x + 1) * ix; + luv->uv[1] = (y + 1) * iy; luv++; luv->uv[0] = x * ix; - luv->uv[1] = (y+1) * iy; + luv->uv[1] = (y + 1) * iy; luv++; } @@ -393,9 +394,9 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams)) { - OceanModifierData *omd = (OceanModifierData*) md; + OceanModifierData *omd = (OceanModifierData *) md; - DerivedMesh *dm=NULL; + DerivedMesh *dm = NULL; OceanResult ocr; MVert *mverts, *mv; @@ -414,7 +415,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, * (axis / (omd->size * omd->spatial_size)) + 0.5f) */ #define OCEAN_CO(_size_co_inv, _v) ((_v * _size_co_inv) + 0.5f) - const float size_co_inv= 1.0f / (omd->size * omd->spatial_size); + const float size_co_inv = 1.0f / (omd->size * omd->spatial_size); /* update modifier */ if (omd->refresh & MOD_OCEAN_REFRESH_ADD) @@ -443,7 +444,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, cfra = md->scene->r.cfra; CLAMP(cfra, omd->bakestart, omd->bakeend); - cfra -= omd->bakestart; // shift to 0 based + cfra -= omd->bakestart; // shift to 0 based num_verts = dm->getNumVerts(dm); num_faces = dm->getNumPolys(dm); @@ -454,30 +455,31 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, /* add vcols before displacement - allows lookup based on position */ if (omd->flag & MOD_OCEAN_GENERATE_FOAM) { - int cdlayer= CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL); + int cdlayer = CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL); if (cdlayer < MAX_MCOL) { - MLoopCol *mloopcols= CustomData_add_layer_named(&dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_faces * 4, omd->foamlayername); + MLoopCol *mloopcols = CustomData_add_layer_named(&dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, + num_faces * 4, omd->foamlayername); if (mloopcols) { /* unlikely to fail */ MLoopCol *mlcol; - MPoly *mpolys= dm->getPolyArray(dm); + MPoly *mpolys = dm->getPolyArray(dm); MPoly *mp; float foam; - for (i = 0, mp= mpolys; i < num_faces; i++, mp++) { - j= mp->totloop - 1; + for (i = 0, mp = mpolys; i < num_faces; i++, mp++) { + j = mp->totloop - 1; /* highly unlikely */ if (j <= 0) continue; do { - const float *co= mverts[mloops[mp->loopstart + j].v].co; + const float *co = mverts[mloops[mp->loopstart + j].v].co; const float u = OCEAN_CO(size_co_inv, co[0]); const float v = OCEAN_CO(size_co_inv, co[1]); - if (omd->oceancache && omd->cached==TRUE) { + if (omd->oceancache && omd->cached == TRUE) { BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); foam = ocr.foam; CLAMP(foam, 0.0f, 1.0f); @@ -487,7 +489,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage); } - mlcol= &mloopcols[mp->loopstart + j]; + mlcol = &mloopcols[mp->loopstart + j]; mlcol->r = mlcol->g = mlcol->b = (char)(foam * 255); /* mc->a = 255; */ /* no need to set */ } while (j--); @@ -500,11 +502,11 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, /* displace the geometry */ //#pragma omp parallel for private(i, ocr) if (omd->resolution > OMP_MIN_RES) - for (i=0, mv= mverts; i< num_verts; i++, mv++) { + for (i = 0, mv = mverts; i < num_verts; i++, mv++) { const float u = OCEAN_CO(size_co_inv, mv->co[0]); const float v = OCEAN_CO(size_co_inv, mv->co[1]); - if (omd->oceancache && omd->cached==TRUE) + if (omd->oceancache && omd->cached == TRUE) BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); else BKE_ocean_eval_uv(omd->ocean, &ocr, u, v); @@ -523,8 +525,8 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, } #else // WITH_OCEANSIM static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams)) { /* unused */ (void)md; @@ -533,9 +535,9 @@ static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob), #endif // WITH_OCEANSIM static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *result; @@ -548,8 +550,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } @@ -561,9 +563,9 @@ ModifierTypeInfo modifierType_Ocean = { /* structName */ "OceanModifierData", /* structSize */ sizeof(OceanModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 3af1351cbdb..fd48afec5cd 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -55,10 +55,10 @@ static void initData(ModifierData *md) { - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; - pimd->flag = eParticleInstanceFlag_Parents|eParticleInstanceFlag_Unborn| - eParticleInstanceFlag_Alive|eParticleInstanceFlag_Dead; + pimd->flag = eParticleInstanceFlag_Parents | eParticleInstanceFlag_Unborn | + eParticleInstanceFlag_Alive | eParticleInstanceFlag_Dead; pimd->psys = 1; pimd->position = 1.0f; pimd->axis = 2; @@ -66,8 +66,8 @@ static void initData(ModifierData *md) } static void copyData(ModifierData *md, ModifierData *target) { - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; - ParticleInstanceModifierData *tpimd= (ParticleInstanceModifierData*) target; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; + ParticleInstanceModifierData *tpimd = (ParticleInstanceModifierData *) target; tpimd->ob = pimd->ob; tpimd->psys = pimd->psys; @@ -82,71 +82,71 @@ static int dependsOnTime(ModifierData *UNUSED(md)) return 0; } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; if (pimd->ob) { DagNode *curNode = dag_get_node(forest, pimd->ob); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Particle Instance Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, + "Particle Instance Modifier"); } } static void foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; walk(userData, ob, &pimd->ob); } -static DerivedMesh * applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) +static DerivedMesh *applyModifier(ModifierData *md, Object *ob, + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = derivedData, *result; - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; ParticleSimulationData sim; - ParticleSystem *psys= NULL; - ParticleData *pa= NULL, *pars= NULL; + ParticleSystem *psys = NULL; + ParticleData *pa = NULL, *pars = NULL; MFace *mface, *orig_mface; MVert *mvert, *orig_mvert; - int i, totvert, totpart=0, totface, maxvert, maxface, first_particle=0; - short track=ob->trackflag%3, trackneg, axis = pimd->axis; - float max_co=0.0, min_co=0.0, temp_co[3], cross[3]; - float *size=NULL; + int i, totvert, totpart = 0, totface, maxvert, maxface, first_particle = 0; + short track = ob->trackflag % 3, trackneg, axis = pimd->axis; + float max_co = 0.0, min_co = 0.0, temp_co[3], cross[3]; + float *size = NULL; DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ - trackneg=((ob->trackflag>2)?1:0); + trackneg = ((ob->trackflag > 2) ? 1 : 0); - if (pimd->ob==ob) { - pimd->ob= NULL; + if (pimd->ob == ob) { + pimd->ob = NULL; return derivedData; } if (pimd->ob) { - psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys-1); - if (psys==NULL || psys->totpart==0) + psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1); + if (psys == NULL || psys->totpart == 0) return derivedData; } else return derivedData; if (pimd->flag & eParticleInstanceFlag_Parents) - totpart+=psys->totpart; + totpart += psys->totpart; if (pimd->flag & eParticleInstanceFlag_Children) { - if (totpart==0) - first_particle=psys->totpart; - totpart+=psys->totchild; + if (totpart == 0) + first_particle = psys->totpart; + totpart += psys->totchild; } - if (totpart==0) + if (totpart == 0) return derivedData; sim.scene = md->scene; @@ -160,62 +160,64 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, si = size = MEM_callocN(totpart * sizeof(float), "particle size array"); if (pimd->flag & eParticleInstanceFlag_Parents) { - for (p=0, pa= psys->particles; ptotpart; p++, pa++, si++) + for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) *si = pa->size; } if (pimd->flag & eParticleInstanceFlag_Children) { ChildParticle *cpa = psys->child; - for (p=0; ptotchild; p++, cpa++, si++) { + for (p = 0; p < psys->totchild; p++, cpa++, si++) { *si = psys_get_child_size(psys, cpa, 0.0f, NULL); } } } - pars=psys->particles; + pars = psys->particles; - totvert=dm->getNumVerts(dm); - totface=dm->getNumTessFaces(dm); + totvert = dm->getNumVerts(dm); + totface = dm->getNumTessFaces(dm); - maxvert=totvert*totpart; - maxface=totface*totpart; + maxvert = totvert * totpart; + maxface = totface * totpart; - psys->lattice=psys_get_lattice(&sim); + psys->lattice = psys_get_lattice(&sim); - if (psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) { + if (psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) { float min_r[3], max_r[3]; INIT_MINMAX(min_r, max_r); dm->getMinMax(dm, min_r, max_r); - min_co=min_r[track]; - max_co=max_r[track]; + min_co = min_r[track]; + max_co = max_r[track]; } - result = CDDM_from_template(dm, maxvert, dm->getNumEdges(dm)*totpart, maxface, 0, 0); + result = CDDM_from_template(dm, maxvert, dm->getNumEdges(dm) * totpart, maxface, 0, 0); - mvert=result->getVertArray(result); - orig_mvert=dm->getVertArray(dm); + mvert = result->getVertArray(result); + orig_mvert = dm->getVertArray(dm); - for (i=0; ico); - mv->co[axis]=temp_co[track]; - mv->co[(axis+1)%3]=temp_co[(track+1)%3]; - mv->co[(axis+2)%3]=temp_co[(track+2)%3]; + mv->co[axis] = temp_co[track]; + mv->co[(axis + 1) % 3] = temp_co[(track + 1) % 3]; + mv->co[(axis + 2) % 3] = temp_co[(track + 2) % 3]; - if ((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path) { + if ((psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && + (pimd->flag & eParticleInstanceFlag_Path)) + { float ran = 0.0f; if (pimd->random_position != 0.0f) { - BLI_srandom(psys->seed + (i/totvert)%totpart); + BLI_srandom(psys->seed + (i / totvert) % totpart); ran = pimd->random_position * BLI_frand(); } @@ -223,15 +225,15 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, state.time = pimd->position * (1.0f - ran); } else { - state.time=(mv->co[axis]-min_co)/(max_co-min_co) * pimd->position * (1.0f - ran); + state.time = (mv->co[axis] - min_co) / (max_co - min_co) * pimd->position * (1.0f - ran); if (trackneg) - state.time=1.0f-state.time; + state.time = 1.0f - state.time; mv->co[axis] = 0.0; } - psys_get_particle_on_path(&sim, first_particle + i/totvert, &state, 1); + psys_get_particle_on_path(&sim, first_particle + i / totvert, &state, 1); normalize_v3(state.vel); @@ -252,60 +254,60 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, } else { - state.time=-1.0; - psys_get_particle_state(&sim, first_particle + i/totvert, &state, 1); + state.time = -1.0; + psys_get_particle_state(&sim, first_particle + i / totvert, &state, 1); } mul_qt_v3(state.rot, mv->co); if (pimd->flag & eParticleInstanceFlag_UseSize) - mul_v3_fl(mv->co, size[i/totvert]); + mul_v3_fl(mv->co, size[i / totvert]); add_v3_v3(mv->co, state.co); } - mface=result->getTessFaceArray(result); - orig_mface=dm->getTessFaceArray(dm); + mface = result->getTessFaceArray(result); + orig_mface = dm->getTessFaceArray(dm); - for (i=0; iflag & eParticleInstanceFlag_Parents) { - if (i/totface>=psys->totpart) { - if (psys->part->childtype==PART_CHILD_PARTICLES) { - pa=psys->particles+(psys->child+i/totface-psys->totpart)->parent; + if (i / totface >= psys->totpart) { + if (psys->part->childtype == PART_CHILD_PARTICLES) { + pa = psys->particles + (psys->child + i / totface - psys->totpart)->parent; } else { - pa= NULL; + pa = NULL; } } else { - pa=pars+i/totface; + pa = pars + i / totface; } } else { - if (psys->part->childtype==PART_CHILD_PARTICLES) { - pa=psys->particles+(psys->child+i/totface)->parent; + if (psys->part->childtype == PART_CHILD_PARTICLES) { + pa = psys->particles + (psys->child + i / totface)->parent; } else { - pa= NULL; + pa = NULL; } } if (pa) { - if (pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue; - if (pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue; - if (pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue; + if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) continue; + if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) continue; + if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) continue; } - inMF = orig_mface + i%totface; - DM_copy_poly_data(dm, result, i%totface, i, 1); + inMF = orig_mface + i % totface; + DM_copy_poly_data(dm, result, i % totface, i, 1); *mf = *inMF; - mf->v1+=(i/totface)*totvert; - mf->v2+=(i/totface)*totvert; - mf->v3+=(i/totface)*totvert; + mf->v1 += (i / totface) * totvert; + mf->v2 += (i / totface) * totvert; + mf->v3 += (i / totface) * totvert; if (mf->v4) { - mf->v4+=(i/totface)*totvert; + mf->v4 += (i / totface) * totvert; } } @@ -313,7 +315,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, if (psys->lattice) { end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; } if (size) @@ -325,38 +327,38 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, return result; } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } ModifierTypeInfo modifierType_ParticleInstance = { - /* name */ "ParticleInstance", - /* structName */ "ParticleInstanceModifierData", - /* structSize */ sizeof(ParticleInstanceModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* name */ "ParticleInstance", + /* structName */ "ParticleInstanceModifierData", + /* structSize */ sizeof(ParticleInstanceModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ applyModifierEM, - /* initData */ initData, - /* requiredDataMask */ NULL, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 5ac1e2786d6..71c77621dfa 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -50,14 +50,14 @@ static void initData(ModifierData *md) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - psmd->psys= NULL; - psmd->dm= NULL; - psmd->totdmvert= psmd->totdmedge= psmd->totdmface= 0; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; + psmd->psys = NULL; + psmd->dm = NULL; + psmd->totdmvert = psmd->totdmedge = psmd->totdmface = 0; } static void freeData(ModifierData *md) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; if (psmd->dm) { psmd->dm->needsFree = 1; @@ -72,8 +72,8 @@ static void freeData(ModifierData *md) } static void copyData(ModifierData *md, ModifierData *target) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - ParticleSystemModifierData *tpsmd= (ParticleSystemModifierData*) target; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; + ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *) target; tpsmd->dm = NULL; tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0; @@ -85,7 +85,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; CustomDataMask dataMask = 0; MTex *mtex; int i; @@ -93,7 +93,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) if (!psmd->psys->part) return 0; - for (i=0; ipsys->part->mtex[i]; if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV)) dataMask |= CD_MASK_MTFACE; @@ -103,7 +103,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) dataMask |= CD_MASK_MTFACE; /* ask for vertexgroups if we need them */ - for (i=0; ipsys->vgroup[i]) { dataMask |= CD_MASK_MDEFORMVERT; break; @@ -112,7 +112,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) /* particles only need this if they are after a non deform modifier, and * the modifier stack will only create them in that case. */ - dataMask |= CD_MASK_ORIGSPACE_MLOOP|CD_MASK_ORIGINDEX; + dataMask |= CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORIGINDEX; dataMask |= CD_MASK_ORCO; @@ -121,32 +121,32 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) /* saves the current emitter state for a particle system and calculates particles */ static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = derivedData; - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - ParticleSystem * psys= NULL; - int needsFree=0; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; + ParticleSystem *psys = NULL; + int needsFree = 0; if (ob->particlesystem.first) - psys=psmd->psys; + psys = psmd->psys; else return; if (!psys_check_enabled(ob, psys)) return; - if (dm==NULL) { - dm= get_dm(ob, NULL, NULL, vertexCos, 1); + if (dm == NULL) { + dm = get_dm(ob, NULL, NULL, vertexCos, 1); if (!dm) return; - needsFree= 1; + needsFree = 1; } /* clear old dm */ @@ -164,7 +164,7 @@ static void deformVerts(ModifierData *md, Object *ob, } /* make new dm */ - psmd->dm=CDDM_copy(dm); + psmd->dm = CDDM_copy(dm); CDDM_apply_vert_coords(psmd->dm, vertexCos); CDDM_calc_normals(psmd->dm); @@ -177,15 +177,15 @@ static void deformVerts(ModifierData *md, Object *ob, psmd->dm->needsFree = 0; /* report change in mesh structure */ - if (psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert || - psmd->dm->getNumEdges(psmd->dm)!=psmd->totdmedge || - psmd->dm->getNumTessFaces(psmd->dm)!=psmd->totdmface) { - + if (psmd->dm->getNumVerts(psmd->dm) != psmd->totdmvert || + psmd->dm->getNumEdges(psmd->dm) != psmd->totdmedge || + psmd->dm->getNumTessFaces(psmd->dm) != psmd->totdmface) + { psys->recalc |= PSYS_RECALC_RESET; - psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm); - psmd->totdmedge= psmd->dm->getNumEdges(psmd->dm); - psmd->totdmface= psmd->dm->getNumTessFaces(psmd->dm); + psmd->totdmvert = psmd->dm->getNumVerts(psmd->dm); + psmd->totdmedge = psmd->dm->getNumEdges(psmd->dm); + psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm); } if (psys) { @@ -199,8 +199,8 @@ static void deformVerts(ModifierData *md, Object *ob, * updates is coded */ #if 0 static void deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, EditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -218,11 +218,11 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* structName */ "ParticleSystemModifierData", /* structSize */ sizeof(ParticleSystemModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_UsesPointCache /* - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode */, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_UsesPointCache /* | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode */, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 56b6493eda6..741014ebc7f 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -50,7 +50,7 @@ static void initData(ModifierData *md) { - RemeshModifierData *rmd = (RemeshModifierData*) md; + RemeshModifierData *rmd = (RemeshModifierData *) md; rmd->scale = 0.9; rmd->depth = 4; @@ -62,8 +62,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - RemeshModifierData *rmd = (RemeshModifierData*) md; - RemeshModifierData *trmd = (RemeshModifierData*) target; + RemeshModifierData *rmd = (RemeshModifierData *) md; + RemeshModifierData *trmd = (RemeshModifierData *) target; trmd->threshold = rmd->threshold; trmd->scale = rmd->scale; @@ -79,11 +79,11 @@ static void init_dualcon_mesh(DualConInput *mesh, DerivedMesh *dm) { memset(mesh, 0, sizeof(DualConInput)); - mesh->co = (void*)dm->getVertArray(dm); + mesh->co = (void *)dm->getVertArray(dm); mesh->co_stride = sizeof(MVert); mesh->totco = dm->getNumVerts(dm); - mesh->faces = (void*)dm->getTessFaceArray(dm); + mesh->faces = (void *)dm->getTessFaceArray(dm); mesh->face_stride = sizeof(MFace); mesh->totface = dm->getNumTessFaces(dm); @@ -108,7 +108,7 @@ static void *dualcon_alloc_output(int totvert, int totquad) return NULL; } - output->dm = CDDM_new(totvert, 0, 0, 4*totquad, totquad); + output->dm = CDDM_new(totvert, 0, 0, 4 * totquad, totquad); return output; } @@ -145,10 +145,10 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4]) } static DerivedMesh *applyModifier(ModifierData *md, - Object *UNUSED(ob), - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + Object *UNUSED(ob), + DerivedMesh *dm, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { RemeshModifierData *rmd; DualConOutput *output; @@ -159,7 +159,7 @@ static DerivedMesh *applyModifier(ModifierData *md, DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ - rmd = (RemeshModifierData*)md; + rmd = (RemeshModifierData *)md; init_dualcon_mesh(&input, dm); @@ -167,27 +167,27 @@ static DerivedMesh *applyModifier(ModifierData *md, flags |= DUALCON_FLOOD_FILL; switch (rmd->mode) { - case MOD_REMESH_CENTROID: - mode = DUALCON_CENTROID; - break; - case MOD_REMESH_MASS_POINT: - mode = DUALCON_MASS_POINT; - break; - case MOD_REMESH_SHARP_FEATURES: - mode = DUALCON_SHARP_FEATURES; - break; + case MOD_REMESH_CENTROID: + mode = DUALCON_CENTROID; + break; + case MOD_REMESH_MASS_POINT: + mode = DUALCON_MASS_POINT; + break; + case MOD_REMESH_SHARP_FEATURES: + mode = DUALCON_SHARP_FEATURES; + break; } output = dualcon(&input, - dualcon_alloc_output, - dualcon_add_vert, - dualcon_add_quad, - flags, - mode, - rmd->threshold, - rmd->hermite_num, - rmd->scale, - rmd->depth); + dualcon_alloc_output, + dualcon_add_vert, + dualcon_add_quad, + flags, + mode, + rmd->threshold, + rmd->hermite_num, + rmd->scale, + rmd->depth); result = output->dm; MEM_freeN(output); @@ -199,9 +199,9 @@ static DerivedMesh *applyModifier(ModifierData *md, #else /* !WITH_MOD_REMESH */ static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { return derivedData; } @@ -213,7 +213,8 @@ ModifierTypeInfo modifierType_Remesh = { /* structName */ "RemeshModifierData", /* structSize */ sizeof(RemeshModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ NULL, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 60eed4abcb1..e6cff1c042f 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -59,8 +59,8 @@ typedef struct ScrewVertConnect { } ScrewVertConnect; typedef struct ScrewVertIter { - ScrewVertConnect * v_array; - ScrewVertConnect * v_poin; + ScrewVertConnect *v_array; + ScrewVertConnect *v_poin; int v; int v_other; MEdge *e; @@ -78,8 +78,8 @@ static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, in iter->e = iter->v_poin->e[!dir]; } else { - iter->v_poin= NULL; - iter->e= NULL; + iter->v_poin = NULL; + iter->e = NULL; } } @@ -87,82 +87,82 @@ static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, in static void screwvert_iter_step(ScrewVertIter *iter) { if (iter->v_poin->v[0] == iter->v_other) { - iter->v_other= iter->v; - iter->v= iter->v_poin->v[1]; + iter->v_other = iter->v; + iter->v = iter->v_poin->v[1]; } else if (iter->v_poin->v[1] == iter->v_other) { - iter->v_other= iter->v; - iter->v= iter->v_poin->v[0]; + iter->v_other = iter->v; + iter->v = iter->v_poin->v[0]; } - if (iter->v >= 0) { - iter->v_poin= &iter->v_array[iter->v]; - iter->e= iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; + if (iter->v >= 0) { + iter->v_poin = &iter->v_array[iter->v]; + iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; } else { - iter->e= NULL; - iter->v_poin= NULL; + iter->e = NULL; + iter->v_poin = NULL; } } static void initData(ModifierData *md) { - ScrewModifierData *ltmd= (ScrewModifierData*) md; - ltmd->ob_axis= NULL; - ltmd->angle= M_PI * 2.0; - ltmd->axis= 2; - ltmd->flag= 0; - ltmd->steps= 16; - ltmd->render_steps= 16; - ltmd->iter= 1; + ScrewModifierData *ltmd = (ScrewModifierData *) md; + ltmd->ob_axis = NULL; + ltmd->angle = M_PI * 2.0; + ltmd->axis = 2; + ltmd->flag = 0; + ltmd->steps = 16; + ltmd->render_steps = 16; + ltmd->iter = 1; } static void copyData(ModifierData *md, ModifierData *target) { - ScrewModifierData *sltmd= (ScrewModifierData*) md; - ScrewModifierData *tltmd= (ScrewModifierData*) target; + ScrewModifierData *sltmd = (ScrewModifierData *) md; + ScrewModifierData *tltmd = (ScrewModifierData *) target; - tltmd->ob_axis= sltmd->ob_axis; - tltmd->angle= sltmd->angle; - tltmd->axis= sltmd->axis; - tltmd->flag= sltmd->flag; - tltmd->steps= sltmd->steps; - tltmd->render_steps= sltmd->render_steps; - tltmd->screw_ofs= sltmd->screw_ofs; - tltmd->iter= sltmd->iter; + tltmd->ob_axis = sltmd->ob_axis; + tltmd->angle = sltmd->angle; + tltmd->axis = sltmd->axis; + tltmd->flag = sltmd->flag; + tltmd->steps = sltmd->steps; + tltmd->render_steps = sltmd->render_steps; + tltmd->screw_ofs = sltmd->screw_ofs; + tltmd->iter = sltmd->iter; } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int useRenderParams, + int UNUSED(isFinalCalc)) { - DerivedMesh *dm= derivedData; + DerivedMesh *dm = derivedData; DerivedMesh *result; - ScrewModifierData *ltmd= (ScrewModifierData*) md; + ScrewModifierData *ltmd = (ScrewModifierData *) md; int *origindex; - int mpoly_index=0; + int mpoly_index = 0; int step; int i, j; unsigned int i1, i2; - int step_tot= useRenderParams ? ltmd->render_steps : ltmd->steps; + int step_tot = useRenderParams ? ltmd->render_steps : ltmd->steps; const int do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0; - int maxVerts=0, maxEdges=0, maxPolys=0; - const unsigned int totvert= dm->getNumVerts(dm); - const unsigned int totedge= dm->getNumEdges(dm); + int maxVerts = 0, maxEdges = 0, maxPolys = 0; + const unsigned int totvert = dm->getNumVerts(dm); + const unsigned int totedge = dm->getNumEdges(dm); - char axis_char= 'X', close; - float angle= ltmd->angle; - float screw_ofs= ltmd->screw_ofs; - float axis_vec[3]= {0.0f, 0.0f, 0.0f}; + char axis_char = 'X', close; + float angle = ltmd->angle; + float screw_ofs = ltmd->screw_ofs; + float axis_vec[3] = {0.0f, 0.0f, 0.0f}; float tmp_vec1[3], tmp_vec2[3]; float mat3[3][3]; float mtx_tx[4][4]; /* transform the coords by an object relative to this objects transformation */ float mtx_tx_inv[4][4]; /* inverted */ float mtx_tmp_a[4][4]; - int vc_tot_linked= 0; + int vc_tot_linked = 0; short other_axis_1, other_axis_2; float *tmpf1, *tmpf2; @@ -173,28 +173,28 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new; MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base; - ScrewVertConnect *vc, *vc_tmp, *vert_connect= NULL; + ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL; /* don't do anything? */ if (!totvert) return CDDM_from_template(dm, 0, 0, 0, 0, 0); switch (ltmd->axis) { - case 0: - other_axis_1=1; - other_axis_2=2; - break; - case 1: - other_axis_1=0; - other_axis_2=2; - break; - default: /* 2, use default to quiet warnings */ - other_axis_1=0; - other_axis_2=1; - break; + case 0: + other_axis_1 = 1; + other_axis_2 = 2; + break; + case 1: + other_axis_1 = 0; + other_axis_2 = 2; + break; + default: /* 2, use default to quiet warnings */ + other_axis_1 = 0; + other_axis_2 = 1; + break; } - axis_vec[ltmd->axis]= 1.0f; + axis_vec[ltmd->axis] = 1.0f; if (ltmd->ob_axis) { /* calc the matrix relative to the axis object */ @@ -212,23 +212,23 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, float totlen = len_v3(mtx_tx[3]); if (totlen != 0.0f) { - float zero[3]={0.0f, 0.0f, 0.0f}; + float zero[3] = {0.0f, 0.0f, 0.0f}; float cp[3]; - screw_ofs= closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); + screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); } else { - screw_ofs= 0.0f; + screw_ofs = 0.0f; } } /* angle */ -#if 0 // cant incluide this, not predictable enough, though quite fun,. +#if 0 // cant incluide this, not predictable enough, though quite fun,. if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { float mtx3_tx[3][3]; copy_m3_m4(mtx3_tx, mtx_tx); - float vec[3] = {0,1,0}; + float vec[3] = {0, 1, 0}; float cross1[3]; float cross2[3]; cross_v3_v3v3(cross1, vec, axis_vec); @@ -243,13 +243,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, cross_v3_v3v3(c2, axis_vec, c1); - angle= angle_v3v3(cross1, c2); + angle = angle_v3v3(cross1, c2); cross_v3_v3v3(axis_tmp, cross1, c2); normalize_v3(axis_tmp); if (len_v3v3(axis_tmp, axis_vec) > 1.0f) - angle= -angle; + angle = -angle; } } @@ -261,7 +261,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* useful to be able to use the axis vec in some cases still */ zero_v3(axis_vec); - axis_vec[ltmd->axis]= 1.0f; + axis_vec[ltmd->axis] = 1.0f; } /* apply the multiplier */ @@ -273,38 +273,40 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* will the screw be closed? * Note! smaller then FLT_EPSILON*100 gives problems with float precision so its never closed. */ - if (fabsf(screw_ofs) <= (FLT_EPSILON*100.0f) && fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON*100.0f)) { - close= 1; + if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) && + fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) + { + close = 1; step_tot--; - if (step_tot < 3) step_tot= 3; + if (step_tot < 3) step_tot = 3; - maxVerts = totvert * step_tot; /* -1 because we're joining back up */ - maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ - (totedge * step_tot); /* -1 because vert edges join */ - maxPolys = totedge * step_tot; + maxVerts = totvert * step_tot; /* -1 because we're joining back up */ + maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ + (totedge * step_tot); /* -1 because vert edges join */ + maxPolys = totedge * step_tot; - screw_ofs= 0.0f; + screw_ofs = 0.0f; } else { - close= 0; - if (step_tot < 3) step_tot= 3; + close = 0; + if (step_tot < 3) step_tot = 3; - maxVerts = totvert * step_tot; /* -1 because we're joining back up */ - maxEdges = (totvert * (step_tot-1)) + /* these are the edges between new verts */ - (totedge * step_tot); /* -1 because vert edges join */ - maxPolys = totedge * (step_tot-1); + maxVerts = totvert * step_tot; /* -1 because we're joining back up */ + maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */ + (totedge * step_tot); /* -1 because vert edges join */ + maxPolys = totedge * (step_tot - 1); } - result= CDDM_from_template(dm, maxVerts, maxEdges, 0, maxPolys * 4, maxPolys); + result = CDDM_from_template(dm, maxVerts, maxEdges, 0, maxPolys * 4, maxPolys); /* copy verts from mesh */ - mvert_orig = dm->getVertArray(dm); - medge_orig = dm->getEdgeArray(dm); + mvert_orig = dm->getVertArray(dm); + medge_orig = dm->getEdgeArray(dm); - mvert_new = result->getVertArray(result); - mpoly_new = result->getPolyArray(result); - mloop_new = result->getLoopArray(result); - medge_new = result->getEdgeArray(result); + mvert_new = result->getVertArray(result); + mpoly_new = result->getPolyArray(result); + mloop_new = result->getLoopArray(result); + medge_new = result->getEdgeArray(result); if (!CustomData_has_layer(&result->polyData, CD_ORIGINDEX)) { CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, maxPolys); @@ -320,17 +322,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* Set the locations of the first set of verts */ - mv_new= mvert_new; - mv_orig= mvert_orig; + mv_new = mvert_new; + mv_orig = mvert_orig; /* Copy the first set of edges */ - med_orig= medge_orig; - med_new= medge_new; - for (i=0; i < totedge; i++, med_orig++, med_new++) { - med_new->v1= med_orig->v1; - med_new->v2= med_orig->v2; - med_new->crease= med_orig->crease; - med_new->flag= med_orig->flag & ~ME_LOOSEEDGE; + med_orig = medge_orig; + med_new = medge_new; + for (i = 0; i < totedge; i++, med_orig++, med_new++) { + med_new->v1 = med_orig->v1; + med_new->v2 = med_orig->v2; + med_new->crease = med_orig->crease; + med_new->flag = med_orig->flag & ~ME_LOOSEEDGE; } if (ltmd->flag & MOD_SCREW_NORMAL_CALC) { @@ -358,14 +360,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * This makes the modifier faster with one less alloc. */ - vert_connect= MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); + vert_connect = MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); //vert_connect= (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */ - vc= vert_connect; + vc = vert_connect; /* Copy Vert Locations */ /* - We can do this in a later loop - only do here if no normal calc */ if (!totedge) { - for (i=0; i < totvert; i++, mv_orig++, mv_new++) { + for (i = 0; i < totvert; i++, mv_orig++, mv_new++) { copy_v3_v3(mv_new->co, mv_orig->co); normalize_v3_v3(vc->no, mv_new->co); /* no edges- this is really a dummy normal */ } @@ -373,93 +375,95 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, else { /*printf("\n\n\n\n\nStarting Modifier\n");*/ /* set edge users */ - med_new= medge_new; - mv_new= mvert_new; + med_new = medge_new; + mv_new = mvert_new; if (ltmd->ob_axis) { /*mtx_tx is initialized early on */ - for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0]= mv_new->co[0]= mv_orig->co[0]; - vc->co[1]= mv_new->co[1]= mv_orig->co[1]; - vc->co[2]= mv_new->co[2]= mv_orig->co[2]; + for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { + vc->co[0] = mv_new->co[0] = mv_orig->co[0]; + vc->co[1] = mv_new->co[1] = mv_orig->co[1]; + vc->co[2] = mv_new->co[2] = mv_orig->co[2]; - vc->flag= 0; - vc->e[0]= vc->e[1]= NULL; - vc->v[0]= vc->v[1]= -1; + vc->flag = 0; + vc->e[0] = vc->e[1] = NULL; + vc->v[0] = vc->v[1] = -1; mul_m4_v3(mtx_tx, vc->co); /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + - vc->co[other_axis_2]*vc->co[other_axis_2]; + vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->co[other_axis_2] * vc->co[other_axis_2]; /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ } } else { - for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0]= mv_new->co[0]= mv_orig->co[0]; - vc->co[1]= mv_new->co[1]= mv_orig->co[1]; - vc->co[2]= mv_new->co[2]= mv_orig->co[2]; + for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { + vc->co[0] = mv_new->co[0] = mv_orig->co[0]; + vc->co[1] = mv_new->co[1] = mv_orig->co[1]; + vc->co[2] = mv_new->co[2] = mv_orig->co[2]; - vc->flag= 0; - vc->e[0]= vc->e[1]= NULL; - vc->v[0]= vc->v[1]= -1; + vc->flag = 0; + vc->e[0] = vc->e[1] = NULL; + vc->v[0] = vc->v[1] = -1; /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + - vc->co[other_axis_2]*vc->co[other_axis_2]; + vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->co[other_axis_2] * vc->co[other_axis_2]; /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ } } /* this loop builds connectivity info for verts */ - for (i=0; iv1]; + for (i = 0; i < totedge; i++, med_new++) { + vc = &vert_connect[med_new->v1]; if (vc->v[0] == -1) { /* unused */ - vc->v[0]= med_new->v2; - vc->e[0]= med_new; + vc->v[0] = med_new->v2; + vc->e[0] = med_new; } else if (vc->v[1] == -1) { - vc->v[1]= med_new->v2; - vc->e[1]= med_new; + vc->v[1] = med_new->v2; + vc->e[1] = med_new; } else { - vc->v[0]= vc->v[1]= -2; /* erro value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */ } - vc= &vert_connect[med_new->v2]; + vc = &vert_connect[med_new->v2]; /* same as above but swap v1/2 */ if (vc->v[0] == -1) { /* unused */ - vc->v[0]= med_new->v1; - vc->e[0]= med_new; + vc->v[0] = med_new->v1; + vc->e[0] = med_new; } else if (vc->v[1] == -1) { - vc->v[1]= med_new->v1; - vc->e[1]= med_new; + vc->v[1] = med_new->v1; + vc->e[1] = med_new; } else { - vc->v[0]= vc->v[1]= -2; /* erro value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */ } } /* find the first vert */ - vc= vert_connect; - for (i=0; i < totvert; i++, vc++) { + vc = vert_connect; + for (i = 0; i < totvert; i++, vc++) { /* Now do search for connected verts, order all edges and flip them * so resulting faces are flipped the right way */ - vc_tot_linked= 0; /* count the number of linked verts for this loop */ + vc_tot_linked = 0; /* count the number of linked verts for this loop */ if (vc->flag == 0) { - int v_best=-1, ed_loop_closed=0; /* vert and vert new */ + int v_best = -1, ed_loop_closed = 0; /* vert and vert new */ ScrewVertIter lt_iter; - int ed_loop_flip= 0; /* compiler complains if not initialized, but it should be initialized below */ - float fl= -1.0f; + float fl = -1.0f; + + /* compiler complains if not initialized, but it should be initialized below */ + int ed_loop_flip = 0; /*printf("Loop on connected vert: %i\n", i);*/ - for (j=0; j<2; j++) { + for (j = 0; j < 2; j++) { /*printf("\tSide: %i\n", j);*/ screwvert_iter_init(<_iter, vert_connect, i, j); if (j == 1) { @@ -470,15 +474,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (lt_iter.v_poin->flag) { /*printf("\t\t\tBreaking Found end\n");*/ //endpoints[0]= endpoints[1]= -1; - ed_loop_closed= 1; /* circle */ + ed_loop_closed = 1; /* circle */ break; } - lt_iter.v_poin->flag= 1; + lt_iter.v_poin->flag = 1; vc_tot_linked++; /*printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist);*/ if (fl <= lt_iter.v_poin->dist) { - fl= lt_iter.v_poin->dist; - v_best= lt_iter.v; + fl = lt_iter.v_poin->dist; + v_best = lt_iter.v; /*printf("\t\t\tVERT BEST: %i\n", v_best);*/ } screwvert_iter_step(<_iter); @@ -495,13 +499,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/ - if (vc_tot_linked>1) { + if (vc_tot_linked > 1) { float vf_1, vf_2, vf_best; - vc_tmp= &vert_connect[v_best]; + vc_tmp = &vert_connect[v_best]; - tmpf1= vert_connect[vc_tmp->v[0]].co; - tmpf2= vert_connect[vc_tmp->v[1]].co; + tmpf1 = vert_connect[vc_tmp->v[0]].co; + tmpf2 = vert_connect[vc_tmp->v[1]].co; /* edge connects on each side! */ @@ -509,15 +513,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ /* find out which is higher */ - vf_1= tmpf1[ltmd->axis]; - vf_2= tmpf2[ltmd->axis]; - vf_best= vc_tmp->co[ltmd->axis]; + vf_1 = tmpf1[ltmd->axis]; + vf_2 = tmpf2[ltmd->axis]; + vf_best = vc_tmp->co[ltmd->axis]; if (vf_1 < vf_best && vf_best < vf_2) { - ed_loop_flip= 0; + ed_loop_flip = 0; } else if (vf_1 > vf_best && vf_best > vf_2) { - ed_loop_flip= 1; + ed_loop_flip = 1; } else { /* not so simple to work out which edge is higher */ @@ -527,20 +531,20 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, normalize_v3(tmp_vec2); if (tmp_vec1[ltmd->axis] < tmp_vec2[ltmd->axis]) { - ed_loop_flip= 1; + ed_loop_flip = 1; } else { - ed_loop_flip= 0; + ed_loop_flip = 0; } } } else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ - ed_loop_flip= 1; + ed_loop_flip = 1; } else { /* best is below or even... in even case we cant know whet to do. */ - ed_loop_flip= 0; + ed_loop_flip = 0; } } @@ -557,31 +561,31 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * note: flip is now done at face level so copying vgroup slizes is easier */ #if 0 if (do_flip) - ed_loop_flip= !ed_loop_flip; + ed_loop_flip = !ed_loop_flip; #endif if (angle < 0.0f) - ed_loop_flip= !ed_loop_flip; + ed_loop_flip = !ed_loop_flip; /* if its closed, we only need 1 loop */ - for (j=ed_loop_closed; j<2; j++) { + for (j = ed_loop_closed; j < 2; j++) { /*printf("Ordering Side J %i\n", j);*/ screwvert_iter_init(<_iter, vert_connect, v_best, j); /*printf("\n\nStarting - Loop\n");*/ - lt_iter.v_poin->flag= 1; /* so a non loop will traverse the other side */ + lt_iter.v_poin->flag = 1; /* so a non loop will traverse the other side */ /* If this is the vert off the best vert and * the best vert has 2 edges connected too it * then swap the flip direction */ if (j == 1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) - ed_loop_flip= !ed_loop_flip; + ed_loop_flip = !ed_loop_flip; while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/ - lt_iter.v_poin->flag= 2; + lt_iter.v_poin->flag = 2; if (lt_iter.e) { if (lt_iter.v == lt_iter.e->v1) { if (ed_loop_flip == 0) { @@ -589,8 +593,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2); } /* else { - printf("\t\t\tFlipping Not 0\n"); - }*/ + printf("\t\t\tFlipping Not 0\n"); + }*/ } else if (lt_iter.v == lt_iter.e->v2) { if (ed_loop_flip == 1) { @@ -598,16 +602,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2); } /* else { - printf("\t\t\tFlipping Not 1\n"); - }*/ + printf("\t\t\tFlipping Not 1\n"); + }*/ } /* else { - printf("\t\tIncorrect edge topology"); - }*/ + printf("\t\tIncorrect edge topology"); + }*/ } /* else { - printf("\t\tNo Edge at this point\n"); - }*/ + printf("\t\tNo Edge at this point\n"); + }*/ screwvert_iter_step(<_iter); } } @@ -676,23 +680,23 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } else { - mv_orig= mvert_orig; - mv_new= mvert_new; + mv_orig = mvert_orig; + mv_new = mvert_new; - for (i=0; i < totvert; i++, mv_new++, mv_orig++) { + for (i = 0; i < totvert; i++, mv_new++, mv_orig++) { copy_v3_v3(mv_new->co, mv_orig->co); } } /* done with edge connectivity based normal flipping */ /* Add Faces */ - for (step=1; step < step_tot; step++) { - const int varray_stride= totvert * step; + for (step = 1; step < step_tot; step++) { + const int varray_stride = totvert * step; float step_angle; float nor_tx[3]; float mat[4][4]; /* Rotation Matrix */ - step_angle= (angle / (step_tot - (!close))) * step; + step_angle = (angle / (step_tot - (!close))) * step; if (ltmd->ob_axis) { axis_angle_to_mat3(mat3, axis_vec, step_angle); @@ -705,15 +709,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (screw_ofs) - madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot-1))); + madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1))); /* copy a slice */ DM_copy_vert_data(dm, result, 0, varray_stride, totvert); - mv_new_base= mvert_new; - mv_new= &mvert_new[varray_stride]; /* advance to the next slice */ + mv_new_base = mvert_new; + mv_new = &mvert_new[varray_stride]; /* advance to the next slice */ - for (j=0; jv1= varray_stride + j; - med_new->v2= med_new->v1 - totvert; - med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; + med_new->v1 = varray_stride + j; + med_new->v2 = med_new->v1 - totvert; + med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; med_new++; } } @@ -750,34 +754,34 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* we can avoid if using vert alloc trick */ if (vert_connect) { MEM_freeN(vert_connect); - vert_connect= NULL; + vert_connect = NULL; } if (close) { /* last loop of edges, previous loop dosnt account for the last set of edges */ - const int varray_stride= (step_tot - 1) * totvert; + const int varray_stride = (step_tot - 1) * totvert; - for (i=0; iv1= i; - med_new->v2= varray_stride + i; - med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; + for (i = 0; i < totvert; i++) { + med_new->v1 = i; + med_new->v2 = varray_stride + i; + med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; med_new++; } } - mp_new= mpoly_new; - ml_new= mloop_new; - med_new_firstloop= medge_new; + mp_new = mpoly_new; + ml_new = mloop_new; + med_new_firstloop = medge_new; /* more of an offset in this case */ edge_offset = totedge + (totvert * (step_tot - (close ? 0 : 1))); - for (i=0; i < totedge; i++, med_new_firstloop++) { + for (i = 0; i < totedge; i++, med_new_firstloop++) { /* for each edge, make a cylinder of quads */ - i1= med_new_firstloop->v1; - i2= med_new_firstloop->v2; + i1 = med_new_firstloop->v1; + i2 = med_new_firstloop->v2; - for (step=0; step < step_tot-1; step++) { + for (step = 0; step < step_tot - 1; step++) { /* new face */ if (do_flip) { @@ -806,18 +810,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp_new->loopstart = mpoly_index * 4; mp_new->totloop = 4; - mp_new->flag= ME_SMOOTH; - origindex[mpoly_index]= ORIGINDEX_NONE; + mp_new->flag = ME_SMOOTH; + origindex[mpoly_index] = ORIGINDEX_NONE; mp_new++; ml_new += 4; mpoly_index++; /* new vertical edge */ if (step) { /* The first set is already dome */ - med_new->v1= i1; - med_new->v2= i2; - med_new->flag= med_new_firstloop->flag; - med_new->crease= med_new_firstloop->crease; + med_new->v1 = i1; + med_new->v2 = i2; + med_new->flag = med_new_firstloop->flag; + med_new->crease = med_new_firstloop->crease; med_new++; } i1 += totvert; @@ -851,18 +855,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp_new->loopstart = mpoly_index * 4; mp_new->totloop = 4; - mp_new->flag= ME_SMOOTH; - origindex[mpoly_index]= ORIGINDEX_NONE; + mp_new->flag = ME_SMOOTH; + origindex[mpoly_index] = ORIGINDEX_NONE; mp_new++; ml_new += 4; mpoly_index++; } /* new vertical edge */ - med_new->v1= i1; - med_new->v2= i2; - med_new->flag= med_new_firstloop->flag & ~ME_LOOSEEDGE; - med_new->crease= med_new_firstloop->crease; + med_new->v1 = i1; + med_new->v2 = i2; + med_new->flag = med_new_firstloop->flag & ~ME_LOOSEEDGE; + med_new->crease = med_new_firstloop->crease; med_new++; } @@ -871,7 +875,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, { i = 0; printf("\n"); - for ( ; i < maxPolys * 4; i += 4) { + for (; i < maxPolys * 4; i += 4) { int ii; ml_new = mloop_new + i; ii = findEd(medge_new, maxEdges, ml_new[0].v, ml_new[1].v); @@ -904,37 +908,37 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ScrewModifierData *ltmd= (ScrewModifierData*) md; + ScrewModifierData *ltmd = (ScrewModifierData *) md; if (ltmd->ob_axis) { - DagNode *curNode= dag_get_node(forest, ltmd->ob_axis); + DagNode *curNode = dag_get_node(forest, ltmd->ob_axis); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Screw Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, + "Screw Modifier"); } } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - ScrewModifierData *ltmd= (ScrewModifierData*) md; + ScrewModifierData *ltmd = (ScrewModifierData *) md; walk(userData, ob, <md->ob_axis); } /* This dosnt work with material*/ static DerivedMesh *applyModifierEM( - ModifierData *md, - Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + ModifierData *md, + Object *ob, + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } @@ -951,10 +955,10 @@ ModifierTypeInfo modifierType_Screw = { /* structSize */ sizeof(ScrewModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index a91019b0228..0f67eb4dd1a 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -49,40 +49,40 @@ #include "MEM_guardedalloc.h" static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *UNUSED(derivedData), - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *UNUSED(derivedData), + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - KeyBlock *kb= ob_get_keyblock(ob); + KeyBlock *kb = ob_get_keyblock(ob); float (*deformedVerts)[3]; if (kb && kb->totelem == numVerts) { - deformedVerts= (float(*)[3])do_ob_key(md->scene, ob); + deformedVerts = (float(*)[3])do_ob_key(md->scene, ob); if (deformedVerts) { - memcpy(vertexCos, deformedVerts, sizeof(float)*3*numVerts); + memcpy(vertexCos, deformedVerts, sizeof(float) * 3 * numVerts); MEM_freeN(deformedVerts); } } } static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { - Key *key= ob_get_key(ob); - KeyBlock *kb= ob_get_keyblock(ob); + Key *key = ob_get_key(ob); + KeyBlock *kb = ob_get_keyblock(ob); float scale[3][3]; (void)vertexCos; /* unused */ - if (kb && kb->totelem==numVerts && kb!=key->refkey) { + if (kb && kb->totelem == numVerts && kb != key->refkey) { int a; if (ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1); else scale_m3_fl(scale, kb->curval); - for (a=0; atype == KEY_RELATIVE) deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0); } static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *UNUSED(derivedData), - float (*vertexCos)[3], - float (*defMats)[3][3], - int numVerts) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *UNUSED(derivedData), + float (*vertexCos)[3], + float (*defMats)[3][3], + int numVerts) { - Key *key= ob_get_key(ob); - KeyBlock *kb= ob_get_keyblock(ob); + Key *key = ob_get_key(ob); + KeyBlock *kb = ob_get_keyblock(ob); float scale[3][3]; (void)vertexCos; /* unused */ - if (kb && kb->totelem==numVerts && kb!=key->refkey) { + if (kb && kb->totelem == numVerts && kb != key->refkey) { int a; scale_m3_fl(scale, kb->curval); - for (a=0; ashrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE; smd->shrinkOpts = MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR; - smd->keepDist = 0.0f; + smd->keepDist = 0.0f; - smd->target = NULL; - smd->auxTarget = NULL; + smd->target = NULL; + smd->auxTarget = NULL; } static void copyData(ModifierData *md, ModifierData *target) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*)md; - ShrinkwrapModifierData *tsmd = (ShrinkwrapModifierData*)target; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; + ShrinkwrapModifierData *tsmd = (ShrinkwrapModifierData *)target; - tsmd->target = smd->target; + tsmd->target = smd->target; tsmd->auxTarget = smd->auxTarget; BLI_strncpy(tsmd->vgroup_name, smd->vgroup_name, sizeof(tsmd->vgroup_name)); - tsmd->keepDist = smd->keepDist; - tsmd->shrinkType= smd->shrinkType; - tsmd->shrinkOpts= smd->shrinkOpts; + tsmd->keepDist = smd->keepDist; + tsmd->shrinkType = smd->shrinkType; + tsmd->shrinkOpts = smd->shrinkOpts; tsmd->projAxis = smd->projAxis; tsmd->subsurfLevels = smd->subsurfLevels; } @@ -97,94 +97,97 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; return !smd->target; } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; walk(userData, ob, &smd->target); walk(userData, ob, &smd->auxTarget); } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); /* ensure we get a CDDM with applied vertex coords */ if (dataMask) - dm= get_cddm(ob, NULL, dm, vertexCos); + dm = get_cddm(ob, NULL, dm, vertexCos); - shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts); + shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); } -static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); /* ensure we get a CDDM with applied vertex coords */ if (dataMask) - dm= get_cddm(ob, editData, dm, vertexCos); + dm = get_cddm(ob, editData, dm, vertexCos); - shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts); + shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; if (smd->target) - dag_add_relation(forest, dag_get_node(forest, smd->target), obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); + dag_add_relation(forest, dag_get_node(forest, smd->target), obNode, + DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); if (smd->auxTarget) - dag_add_relation(forest, dag_get_node(forest, smd->auxTarget), obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); + dag_add_relation(forest, dag_get_node(forest, smd->auxTarget), obNode, + DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); } ModifierTypeInfo modifierType_Shrinkwrap = { - /* name */ "Shrinkwrap", - /* structName */ "ShrinkwrapModifierData", - /* structSize */ sizeof(ShrinkwrapModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* name */ "Shrinkwrap", + /* structName */ "ShrinkwrapModifierData", + /* structSize */ sizeof(ShrinkwrapModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 5ac52a97315..d2ef75bfa42 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -68,10 +68,10 @@ static void axis_limit(int axis, const float limits[2], float co[3], float dcut[ static void simpleDeform_taper(const float factor, const float dcut[3], float *co) { float x = co[0], y = co[1], z = co[2]; - float scale = z*factor; + float scale = z * factor; - co[0] = x + x*scale; - co[1] = y + y*scale; + co[0] = x + x * scale; + co[1] = y + y * scale; co[2] = z; if (dcut) { @@ -86,11 +86,11 @@ static void simpleDeform_stretch(const float factor, const float dcut[3], float float x = co[0], y = co[1], z = co[2]; float scale; - scale = (z*z*factor-factor + 1.0f); + scale = (z * z * factor - factor + 1.0f); - co[0] = x*scale; - co[1] = y*scale; - co[2] = z*(1.0f+factor); + co[0] = x * scale; + co[1] = y * scale; + co[2] = z * (1.0f + factor); if (dcut) { co[0] += dcut[0]; @@ -104,12 +104,12 @@ static void simpleDeform_twist(const float factor, const float *dcut, float *co) float x = co[0], y = co[1], z = co[2]; float theta, sint, cost; - theta = z*factor; + theta = z * factor; sint = sin(theta); cost = cos(theta); - co[0] = x*cost - y*sint; - co[1] = x*sint + y*cost; + co[0] = x * cost - y * sint; + co[1] = x * sint + y * cost; co[2] = z; if (dcut) { @@ -124,19 +124,19 @@ static void simpleDeform_bend(const float factor, const float dcut[3], float *co float x = co[0], y = co[1], z = co[2]; float theta, sint, cost; - theta = x*factor; + theta = x * factor; sint = sin(theta); cost = cos(theta); if (fabsf(factor) > 1e-7f) { - co[0] = -(y-1.0f/factor)*sint; - co[1] = (y-1.0f/factor)*cost + 1.0f/factor; + co[0] = -(y - 1.0f / factor) * sint; + co[1] = (y - 1.0f / factor) * cost + 1.0f / factor; co[2] = z; } if (dcut) { - co[0] += cost*dcut[0]; - co[1] += sint*dcut[0]; + co[0] += cost * dcut[0]; + co[1] += sint * dcut[0]; co[2] += dcut[2]; } @@ -144,7 +144,8 @@ static void simpleDeform_bend(const float factor, const float dcut[3], float *co /* simple deform modifier */ -static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts) +static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { static const float lock_axis[2] = {0.0f, 0.0f}; @@ -152,17 +153,17 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object int limit_axis = 0; float smd_limit[2], smd_factor; SpaceTransform *transf = NULL, tmp_transf; - void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; //Mode callback + void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; /* Mode callback */ int vgroup; MDeformVert *dvert; - //Safe-check - if (smd->origin == ob) smd->origin = NULL; //No self references + /* Safe-check */ + if (smd->origin == ob) smd->origin = NULL; /* No self references */ if (smd->limit[0] < 0.0f) smd->limit[0] = 0.0f; if (smd->limit[0] > 1.0f) smd->limit[0] = 1.0f; - smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); //Upper limit >= than lower limit + smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */ //Calculate matrixs do convert between coordinate spaces if (smd->origin) { @@ -185,7 +186,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object float lower = FLT_MAX; float upper = -FLT_MAX; - for (i=0; ilimit[1]; - smd_limit[0] = lower + (upper-lower)*smd->limit[0]; + /* SMD values are normalized to the BV, calculate the absolut values */ + smd_limit[1] = lower + (upper - lower) * smd->limit[1]; + smd_limit[0] = lower + (upper - lower) * smd->limit[0]; - smd_factor = smd->factor / MAX2(FLT_EPSILON, smd_limit[1]-smd_limit[0]); + smd_factor = smd->factor / MAX2(FLT_EPSILON, smd_limit[1] - smd_limit[0]); } modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup); switch (smd->mode) { - case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; - case MOD_SIMPLEDEFORM_MODE_BEND: simpleDeform_callback = simpleDeform_bend; break; - case MOD_SIMPLEDEFORM_MODE_TAPER: simpleDeform_callback = simpleDeform_taper; break; - case MOD_SIMPLEDEFORM_MODE_STRETCH: simpleDeform_callback = simpleDeform_stretch; break; + case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; + case MOD_SIMPLEDEFORM_MODE_BEND: simpleDeform_callback = simpleDeform_bend; break; + case MOD_SIMPLEDEFORM_MODE_TAPER: simpleDeform_callback = simpleDeform_taper; break; + case MOD_SIMPLEDEFORM_MODE_STRETCH: simpleDeform_callback = simpleDeform_stretch; break; default: - return; //No simpledeform mode? + return; /* No simpledeform mode? */ } - for (i=0; imode = MOD_SIMPLEDEFORM_MODE_TWIST; smd->axis = 0; @@ -260,14 +261,14 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; - SimpleDeformModifierData *tsmd = (SimpleDeformModifierData*)target; + SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; + SimpleDeformModifierData *tsmd = (SimpleDeformModifierData *)target; - tsmd->mode = smd->mode; + tsmd->mode = smd->mode; tsmd->axis = smd->axis; - tsmd->origin= smd->origin; - tsmd->originOpts= smd->originOpts; - tsmd->factor= smd->factor; + tsmd->origin = smd->origin; + tsmd->originOpts = smd->originOpts; + tsmd->factor = smd->factor; memcpy(tsmd->limit, smd->limit, sizeof(tsmd->limit)); BLI_strncpy(tsmd->vgroup_name, smd->vgroup_name, sizeof(tsmd->vgroup_name)); } @@ -284,29 +285,30 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +static void foreachObjectLink(ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; + SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; walk(userData, ob, &smd->origin); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; + SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; if (smd->origin) dag_add_relation(forest, dag_get_node(forest, smd->origin), obNode, DAG_RL_OB_DATA, "SimpleDeform Modifier"); } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); @@ -314,19 +316,19 @@ static void deformVerts(ModifierData *md, Object *ob, /* we implement requiredDataMask but thats not really useful since * mesh_calc_modifiers pass a NULL derivedData */ if (dataMask) - dm= get_dm(ob, NULL, dm, NULL, 0); + dm = get_dm(ob, NULL, dm, NULL, 0); - SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); } static void deformVertsEM(ModifierData *md, Object *ob, - struct BMEditMesh *editData, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts) + struct BMEditMesh *editData, + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); @@ -334,9 +336,9 @@ static void deformVertsEM(ModifierData *md, Object *ob, /* we implement requiredDataMask but thats not really useful since * mesh_calc_modifiers pass a NULL derivedData */ if (dataMask) - dm= get_dm(ob, editData, dm, NULL, 0); + dm = get_dm(ob, editData, dm, NULL, 0); - SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); @@ -349,10 +351,10 @@ ModifierTypeInfo modifierType_SimpleDeform = { /* structSize */ sizeof(SimpleDeformModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 706c9817a0a..843f92bbbe8 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -57,7 +57,7 @@ static void initData(ModifierData *md) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; smd->domain = NULL; smd->flow = NULL; @@ -68,27 +68,27 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SmokeModifierData *smd = (SmokeModifierData*)md; - SmokeModifierData *tsmd = (SmokeModifierData*)target; + SmokeModifierData *smd = (SmokeModifierData *)md; + SmokeModifierData *tsmd = (SmokeModifierData *)target; smokeModifier_copy(smd, tsmd); } static void freeData(ModifierData *md) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; - smokeModifier_free (smd); + smokeModifier_free(smd); } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos); smokeModifier_do(smd, md->scene, ob, dm); @@ -103,9 +103,9 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *scene, - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *scene, + Object *UNUSED(ob), + DagNode *obNode) { SmokeModifierData *smd = (SmokeModifierData *) md; @@ -121,7 +121,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, // check for initialized smoke object if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Flow"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow"); } } } @@ -134,7 +134,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, // check for initialized smoke object if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Coll"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Coll"); } } } @@ -142,12 +142,12 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, else { Base *base = scene->base.first; - for ( ; base; base = base->next) { + for (; base; base = base->next) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(base->object, eModifierType_Smoke); if (smd2 && (((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) || ((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll))) { DagNode *curNode = dag_get_node(forest, base->object); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Flow/Coll"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow/Coll"); } } } @@ -155,11 +155,11 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; - if (smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + if (smd->type == MOD_SMOKE_TYPE_DOMAIN && smd->domain) { walk(userData, ob, (ID **)&smd->domain->coll_group); walk(userData, ob, (ID **)&smd->domain->fluid_group); walk(userData, ob, (ID **)&smd->domain->eff_group); @@ -175,9 +175,9 @@ ModifierTypeInfo modifierType_Smoke = { /* structName */ "SmokeModifierData", /* structSize */ sizeof(SmokeModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_UsesPointCache | + eModifierTypeFlag_Single, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index b909e1f6512..ac0eb2a369b 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - SmoothModifierData *smd = (SmoothModifierData*) md; + SmoothModifierData *smd = (SmoothModifierData *) md; smd->fac = 0.5f; smd->repeat = 1; @@ -61,8 +61,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SmoothModifierData *smd = (SmoothModifierData*) md; - SmoothModifierData *tsmd = (SmoothModifierData*) target; + SmoothModifierData *smd = (SmoothModifierData *) md; + SmoothModifierData *tsmd = (SmoothModifierData *) target; tsmd->fac = smd->fac; tsmd->repeat = smd->repeat; @@ -72,10 +72,10 @@ static void copyData(ModifierData *md, ModifierData *target) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - SmoothModifierData *smd = (SmoothModifierData*) md; + SmoothModifierData *smd = (SmoothModifierData *) md; short flag; - flag = smd->flag & (MOD_SMOOTH_X|MOD_SMOOTH_Y|MOD_SMOOTH_Z); + flag = smd->flag & (MOD_SMOOTH_X | MOD_SMOOTH_Y | MOD_SMOOTH_Z); /* disable if modifier is off for X, Y and Z or if factor is 0 */ if ((smd->fac == 0.0f) || flag == 0) return 1; @@ -95,8 +95,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void smoothModifier_do( - SmoothModifierData *smd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + SmoothModifierData *smd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; MEdge *medges = NULL; @@ -105,11 +105,11 @@ static void smoothModifier_do( unsigned char *uctmp; float *ftmp, fac, facm; - ftmp = (float*)MEM_callocN(3*sizeof(float)*numVerts, - "smoothmodifier_f"); + ftmp = (float *)MEM_callocN(3 * sizeof(float) * numVerts, + "smoothmodifier_f"); if (!ftmp) return; - uctmp = (unsigned char*)MEM_callocN(sizeof(unsigned char)*numVerts, - "smoothmodifier_uc"); + uctmp = (unsigned char *)MEM_callocN(sizeof(unsigned char) * numVerts, + "smoothmodifier_uc"); if (!uctmp) { if (ftmp) MEM_freeN(ftmp); return; @@ -139,8 +139,8 @@ static void smoothModifier_do( mid_v3_v3v3(fvec, v1, v2); - v1 = &ftmp[idx1*3]; - v2 = &ftmp[idx2*3]; + v1 = &ftmp[idx1 * 3]; + v2 = &ftmp[idx2 * 3]; if (uctmp[idx1] < 255) { uctmp[idx1]++; @@ -153,16 +153,16 @@ static void smoothModifier_do( } if (dvert) { - MDeformVert *dv= dvert; + MDeformVert *dv = dvert; for (i = 0; i < numVerts; i++, dv++) { float f, fm, facw, *fp, *v; short flag = smd->flag; v = vertexCos[i]; - fp = &ftmp[i*3]; + fp = &ftmp[i * 3]; - f= defvert_find_weight(dv, defgrp_index); + f = defvert_find_weight(dv, defgrp_index); if (f <= 0.0f) continue; f *= fac; @@ -187,7 +187,7 @@ static void smoothModifier_do( short flag = smd->flag; v = vertexCos[i]; - fp = &ftmp[i*3]; + fp = &ftmp[i * 3]; /* fp is the sum of uctmp[i] verts, so must be averaged */ facw = 0.0f; @@ -204,8 +204,8 @@ static void smoothModifier_do( } - memset(ftmp, 0, 3*sizeof(float)*numVerts); - memset(uctmp, 0, sizeof(unsigned char)*numVerts); + memset(ftmp, 0, 3 * sizeof(float) * numVerts); + memset(uctmp, 0, sizeof(unsigned char) * numVerts); } MEM_freeN(ftmp); @@ -213,10 +213,10 @@ static void smoothModifier_do( } static void deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + ModifierData *md, Object *ob, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - DerivedMesh *dm= get_dm(ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); smoothModifier_do((SmoothModifierData *)md, ob, dm, vertexCos, numVerts); @@ -226,10 +226,10 @@ static void deformVerts( } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm= get_dm(ob, editData, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); smoothModifier_do((SmoothModifierData *)md, ob, dm, vertexCos, numVerts); @@ -244,8 +244,8 @@ ModifierTypeInfo modifierType_Smooth = { /* structName */ "SmoothModifierData", /* structSize */ sizeof(SmoothModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 01b1b0b52af..5d428aedf8c 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -45,11 +45,11 @@ #include "MOD_modifiertypes.h" static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *UNUSED(derivedData), - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *UNUSED(derivedData), + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { sbObjectStep(md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts); } @@ -65,9 +65,9 @@ ModifierTypeInfo modifierType_Softbody = { /* structName */ "SoftbodyModifierData", /* structSize */ sizeof(SoftbodyModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_RequiresOriginalData - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_RequiresOriginalData | + eModifierTypeFlag_Single, /* copyData */ NULL, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 71839312cf5..96c84f5abbe 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -66,7 +66,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) float (*face_nors)[3]; float *f_no; - int calc_face_nors= 0; + int calc_face_nors = 0; numVerts = dm->getNumVerts(dm); numEdges = dm->getNumEdges(dm); @@ -124,15 +124,18 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) f_no = face_nors[i]; if (calc_face_nors) - mesh_calc_poly_normal(mp, mloop+mp->loopstart, mvert, f_no); + mesh_calc_poly_normal(mp, mloop + mp->loopstart, mvert, f_no); ml = mloop + mp->loopstart; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(ml->v, ME_POLY_LOOP_NEXT(mloop, mp, j)->v); } } - for (edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) { + for (edge_iter = BLI_edgehashIterator_new(edge_hash); + !BLI_edgehashIterator_isDone(edge_iter); + BLI_edgehashIterator_step(edge_iter)) + { /* Get the edge vert indices, and edge value (the face indices that use it)*/ BLI_edgehashIterator_getKey(edge_iter, &ed_v1, &ed_v2); edge_ref = BLI_edgehashIterator_getValue(edge_iter); @@ -148,7 +151,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) /* only one face attached to that edge */ /* an edge without another attached- the weight on this is * undefined, M_PI/2 is 90d in radians and that seems good enough */ - mul_v3_v3fl(edge_normal, face_nors[edge_ref->f1], M_PI/2); + mul_v3_v3fl(edge_normal, face_nors[edge_ref->f1], M_PI / 2); } add_v3_v3(temp_nors[ed_v1], edge_normal); add_v3_v3(temp_nors[ed_v2], edge_normal); @@ -168,7 +171,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) static void initData(ModifierData *md) { - SolidifyModifierData *smd = (SolidifyModifierData*) md; + SolidifyModifierData *smd = (SolidifyModifierData *) md; smd->offset = 0.01f; smd->offset_fac = -1.0f; smd->flag = MOD_SOLIDIFY_RIM; @@ -176,8 +179,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SolidifyModifierData *smd = (SolidifyModifierData*) md; - SolidifyModifierData *tsmd = (SolidifyModifierData*) target; + SolidifyModifierData *smd = (SolidifyModifierData *) md; + SolidifyModifierData *tsmd = (SolidifyModifierData *) target; tsmd->offset = smd->offset; tsmd->offset_fac = smd->offset_fac; tsmd->crease_inner = smd->crease_inner; @@ -189,7 +192,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - SolidifyModifierData *smd = (SolidifyModifierData*) md; + SolidifyModifierData *smd = (SolidifyModifierData *) md; CustomDataMask dataMask = 0; /* ask for vertexgroups if we need them */ @@ -200,13 +203,13 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *dm, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { int i; DerivedMesh *result; - const SolidifyModifierData *smd = (SolidifyModifierData*) md; + const SolidifyModifierData *smd = (SolidifyModifierData *) md; MVert *mv, *mvert, *orig_mvert; MEdge *ed, *medge, *orig_medge; @@ -215,36 +218,36 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, const int numVerts = dm->getNumVerts(dm); const int numEdges = dm->getNumEdges(dm); const int numFaces = dm->getNumPolys(dm); - int numLoops=0, newLoops=0, newFaces=0, newEdges=0; + int numLoops = 0, newLoops = 0, newFaces = 0, newEdges = 0; int j; /* only use material offsets if we have 2 or more materials */ - const short mat_nr_max= ob->totcol > 1 ? ob->totcol - 1 : 0; - const short mat_ofs= mat_nr_max ? smd->mat_ofs : 0; - const short mat_ofs_rim= mat_nr_max ? smd->mat_ofs_rim : 0; + const short mat_nr_max = ob->totcol > 1 ? ob->totcol - 1 : 0; + const short mat_ofs = mat_nr_max ? smd->mat_ofs : 0; + const short mat_ofs_rim = mat_nr_max ? smd->mat_ofs_rim : 0; /* use for edges */ - int *new_vert_arr= NULL; + int *new_vert_arr = NULL; BLI_array_declare(new_vert_arr); - int *new_edge_arr= NULL; + int *new_edge_arr = NULL; BLI_array_declare(new_edge_arr); - int *old_vert_arr = MEM_callocN(sizeof(int)*numVerts, "old_vert_arr in solidify"); + int *old_vert_arr = MEM_callocN(sizeof(int) * numVerts, "old_vert_arr in solidify"); - int *edge_users= NULL; - char *edge_order= NULL; + int *edge_users = NULL; + char *edge_order = NULL; int *edge_origIndex; - float (*vert_nors)[3]= NULL; + float (*vert_nors)[3] = NULL; float (*face_nors_result)[3] = NULL; - const float ofs_orig= - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); - const float ofs_new= smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); - const float offset_fac_vg= smd->offset_fac_vg; - const float offset_fac_vg_inv= 1.0f - smd->offset_fac_vg; + const float ofs_orig = -(((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float ofs_new = smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float offset_fac_vg = smd->offset_fac_vg; + const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg; /* weights */ - MDeformVert *dvert, *dv= NULL; + MDeformVert *dvert, *dv = NULL; const int defgrp_invert = ((smd->flag & MOD_SOLIDIFY_VGROUP_INV) != 0); int defgrp_index; @@ -264,11 +267,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, unsigned int v1, v2; int eidx; - for (i=0, mv=orig_mvert; iflag &= ~ME_VERT_TMP_TAG; } - for (i=0, ed=orig_medge; iv1, ed->v2, SET_INT_IN_POINTER(i)); } @@ -291,14 +294,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } - edge_users= MEM_mallocN(sizeof(int) * numEdges, "solid_mod edges"); - edge_order= MEM_mallocN(sizeof(char) * numEdges, "solid_mod eorder"); + edge_users = MEM_mallocN(sizeof(int) * numEdges, "solid_mod edges"); + edge_order = MEM_mallocN(sizeof(char) * numEdges, "solid_mod eorder"); fill_vn_i(edge_users, numEdges, INVALID_UNUSED); - for (i=0, mp=orig_mpoly; iloopstart, j=0; jtotloop; ml++, j++) { + for (ml = orig_mloop + mp->loopstart, j = 0; j < mp->totloop; ml++, j++) { ADD_EDGE_USER(ml->v, ME_POLY_LOOP_NEXT(orig_mloop, mp, j)->v, j); } } @@ -307,9 +310,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, #undef INVALID_UNUSED #undef INVALID_PAIR - ehi= BLI_edgehashIterator_new(edgehash); + ehi = BLI_edgehashIterator_new(edgehash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - eidx= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); + eidx = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); if (edge_users[eidx] >= 0) { BLI_edgehashIterator_getKey(ehi, &v1, &v2); orig_mvert[v1].flag |= ME_VERT_TMP_TAG; @@ -321,7 +324,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } BLI_edgehashIterator_free(ehi); - for (i=0, mv=orig_mvert; iflag & ME_VERT_TMP_TAG) { old_vert_arr[i] = BLI_array_count(new_vert_arr); BLI_array_append(new_vert_arr, i); @@ -335,11 +338,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { - vert_nors= MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq"); + vert_nors = MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq"); dm_calc_normal(dm, vert_nors); } - result = CDDM_from_template(dm, numVerts * 2, (numEdges * 2) + newEdges, 0, (numLoops*2) + newLoops, (numFaces * 2) + newFaces); + result = CDDM_from_template(dm, numVerts * 2, (numEdges * 2) + newEdges, 0, + (numLoops * 2) + newLoops, (numFaces * 2) + newFaces); mpoly = CDDM_get_polys(result); mloop = CDDM_get_loops(result); @@ -363,14 +367,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*flip normals*/ mp = mpoly + numFaces; - for (i=0; inumPolyData; i++, mp++) { + for (i = 0; i < dm->numPolyData; i++, mp++) { MLoop *ml2; int e; ml2 = mloop + mp->loopstart + dm->numLoopData; - for (j=0; jtotloop; j++) { - CustomData_copy_data(&dm->loopData, &result->loopData, mp->loopstart+j, - mp->loopstart+(mp->totloop-j-1)+dm->numLoopData, 1); + for (j = 0; j < mp->totloop; j++) { + CustomData_copy_data(&dm->loopData, &result->loopData, mp->loopstart + j, + mp->loopstart + (mp->totloop - j - 1) + dm->numLoopData, 1); } if (mat_ofs) { @@ -379,14 +383,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } e = ml2[0].e; - for (j=0; jtotloop-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 += dm->numLoopData; - for (j=0; jtotloop; j++) { + for (j = 0; j < mp->totloop; j++) { ml2[j].e += numEdges; ml2[j].v += numVerts; } @@ -396,7 +400,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } - for (i=0, ed=medge+numEdges; iv1 += numVerts; ed->v2 += numVerts; } @@ -409,14 +413,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (ofs_new != 0.0f) { - scalar_short= scalar_short_vgroup= ofs_new / 32767.0f; - mv= mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts); - dv= dvert; - for (i=0; i= ofs_orig) ? 0 : numVerts); + dv = dvert; + for (i = 0; i < numVerts; i++, mv++) { if (dv) { - if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); - else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); - scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; + if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); + else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; dv++; } VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup); @@ -424,14 +428,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (ofs_orig != 0.0f) { - scalar_short= scalar_short_vgroup= ofs_orig / 32767.0f; - mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */ - dv= dvert; - for (i=0; i= ofs_orig) ? numVerts : 0); /* as above but swapped, intentional use 'ofs_new' */ + dv = dvert; + for (i = 0; i < numVerts; i++, mv++) { if (dv) { - if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); - else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); - scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; + if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); + else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; dv++; } VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup); @@ -442,11 +446,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, else { /* make a face normal layer if not present */ float (*face_nors)[3]; - int face_nors_calc= 0; + int face_nors_calc = 0; /* same as EM_solidify() in editmesh_lib.c */ - float *vert_angles= MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */ - float *vert_accum= vert_angles + numVerts; + float *vert_angles = MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */ + float *vert_accum = vert_angles + numVerts; float *face_angles = NULL; BLI_array_staticdeclare(face_angles, 16); /* BM_NGON_STACK_SIZE */ int j, vidx; @@ -454,23 +458,23 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL); if (!face_nors) { face_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData); - face_nors_calc= 1; + face_nors_calc = 1; } - if (vert_nors==NULL) { - vert_nors= MEM_mallocN(sizeof(float) * numVerts * 3, "mod_solid_vno"); - for (i=0, mv=mvert; ino); } } - for (i=0, mp=mpoly; iloopstart], mvert, face_nors[i]); /* just added, calc the normal */ BLI_array_empty(face_angles); - for (j=0, ml=mloop+mp->loopstart; jtotloop; j++, ml++) { + for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { MLoop *ml_prev = ME_POLY_LOOP_PREV(mloop, mp, j); MLoop *ml_next = ME_POLY_LOOP_NEXT(mloop, mp, j); @@ -482,10 +486,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, BLI_array_append(face_angles, angle); } - for (j=0, ml=mloop+mp->loopstart; jtotloop; j++, ml++) { + for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { vidx = ml->v; vert_accum[vidx] += face_angles[j]; - vert_angles[vidx]+= shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * face_angles[j]; + vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * + face_angles[j]; } } @@ -495,27 +500,27 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (dvert) { float scalar; - dv= dvert; + dv = dvert; if (defgrp_invert) { - for (i=0; i= ofs_orig) ? 0 : numVerts); + mv = mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts); - for (i=0; ico, vert_nors[i], ofs_new * (vert_angles[i] / vert_accum[i])); } @@ -523,9 +528,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (ofs_orig) { - mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */ + /* same as above but swapped, intentional use of 'ofs_new' */ + mv = mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); - for (i=0; ico, vert_nors[i], ofs_orig * (vert_angles[i] / vert_accum[i])); } @@ -539,46 +545,48 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MEM_freeN(vert_nors); /* flip vertex normals for copied verts */ - mv= mvert + numVerts; - for (i=0; ino[0]= -mv->no[0]; - mv->no[1]= -mv->no[1]; - mv->no[2]= -mv->no[2]; + mv = mvert + numVerts; + for (i = 0; i < numVerts; i++, mv++) { + mv->no[0] = -mv->no[0]; + mv->no[1] = -mv->no[1]; + mv->no[2] = -mv->no[2]; } if (smd->flag & MOD_SOLIDIFY_RIM) { int *origindex; /* bugger, need to re-calculate the normals for the new edge faces. - * This could be done in many ways, but probably the quickest way is to calculate the average normals for side faces only. + * This could be done in many ways, but probably the quickest way + * is to calculate the average normals for side faces only. * Then blend them with the normals of the edge verts. * - * at the moment its easiest to allocate an entire array for every vertex, even though we only need edge verts - campbell + * at the moment its easiest to allocate an entire array for every vertex, + * even though we only need edge verts - campbell */ #define SOLIDIFY_SIDE_NORMALS #ifdef SOLIDIFY_SIDE_NORMALS /* annoying to allocate these since we only need the edge verts, */ - float (*edge_vert_nos)[3]= MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos"); + float (*edge_vert_nos)[3] = MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos"); float nor[3]; #endif - const unsigned char crease_rim= smd->crease_rim * 255.0f; - const unsigned char crease_outer= smd->crease_outer * 255.0f; - const unsigned char crease_inner= smd->crease_inner * 255.0f; + const unsigned char crease_rim = smd->crease_rim * 255.0f; + const unsigned char crease_outer = smd->crease_outer * 255.0f; + const unsigned char crease_inner = smd->crease_inner * 255.0f; /* add faces & edges */ - origindex= result->getEdgeDataArray(result, CD_ORIGINDEX); - ed= medge + (numEdges * 2); - for (i=0; iv1= new_vert_arr[i]; - ed->v2= new_vert_arr[i] + numVerts; + origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); + ed = medge + (numEdges * 2); + for (i = 0; i < newEdges; i++, ed++) { + ed->v1 = new_vert_arr[i]; + ed->v2 = new_vert_arr[i] + numVerts; ed->flag |= ME_EDGEDRAW; - origindex[numEdges * 2 + i]= ORIGINDEX_NONE; + origindex[numEdges * 2 + i] = ORIGINDEX_NONE; if (crease_rim) - ed->crease= crease_rim; + ed->crease = crease_rim; } /* faces */ @@ -588,24 +596,24 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp = mpoly + (numFaces * 2); ml = mloop + (numLoops * 2); j = 0; - for (i=0; i= numFaces) { fidx -= numFaces; - flip= 1; + flip = 1; } else { - flip= 0; + flip = 0; } - ed= medge + eidx; + ed = medge + eidx; /* copy most of the face settings */ DM_copy_poly_data(dm, result, fidx, (numFaces * 2) + i, 1); - mp->loopstart = j+numLoops*2; + mp->loopstart = j + numLoops * 2; mp->flag = mpoly[fidx].flag; /* notice we use 'mp->totloop' which is later overwritten, @@ -616,33 +624,33 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp->totloop = 4; - CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops*2+j+0, 1); - CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops*2+j+1, 1); - CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops*2+j+2, 1); - CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops*2+j+3, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 0, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 1, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 2, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 3, 1); if (flip) { ml[j].v = ed->v1; ml[j++].e = eidx; ml[j].v = ed->v2; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v2]; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2]; - ml[j].v = ed->v2+numVerts; - ml[j++].e = eidx+numEdges; + ml[j].v = ed->v2 + numVerts; + ml[j++].e = eidx + numEdges; - ml[j].v = ed->v1+numVerts; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v1]; + ml[j].v = ed->v1 + numVerts; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v1]; } else { ml[j].v = ed->v2; ml[j++].e = eidx; ml[j].v = ed->v1; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v1]; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v1]; - ml[j].v = ed->v1+numVerts; - ml[j++].e = eidx+numEdges; + 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]; @@ -660,9 +668,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (crease_outer) { /* crease += crease_outer; without wrapping */ - unsigned char *cr= (unsigned char *)&(ed->crease); - int tcr= *cr + crease_outer; - *cr= tcr > 255 ? 255 : tcr; + unsigned char *cr = (unsigned char *)&(ed->crease); + int tcr = *cr + crease_outer; + *cr = tcr > 255 ? 255 : tcr; } if (crease_inner) { @@ -674,9 +682,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, #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); + 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); @@ -688,8 +696,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } #ifdef SOLIDIFY_SIDE_NORMALS - ed= medge + (numEdges * 2); - for (i=0; iv1]); - for (j=0; j<2; j++) { /* loop over both verts of the edge */ - nor_short= mvert[*(&ed->v1 + j)].no; + for (j = 0; j < 2; j++) { /* loop over both verts of the edge */ + nor_short = mvert[*(&ed->v1 + j)].no; normal_short_to_float_v3(nor, nor_short); add_v3_v3(nor, nor_cpy); normalize_v3(nor); @@ -729,9 +737,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, #undef SOLIDIFY_SIDE_NORMALS static DerivedMesh *applyModifierEM(ModifierData *md, - Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + Object *ob, + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } @@ -743,11 +751,11 @@ ModifierTypeInfo modifierType_Solidify = { /* structSize */ sizeof(SolidifyModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index be1ceeee317..ebd95992090 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; smd->levels = 1; smd->renderLevels = 2; @@ -60,8 +60,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - SubsurfModifierData *tsmd = (SubsurfModifierData*) target; + SubsurfModifierData *smd = (SubsurfModifierData *) md; + SubsurfModifierData *tsmd = (SubsurfModifierData *) target; tsmd->flags = smd->flags; tsmd->levels = smd->levels; @@ -71,7 +71,7 @@ static void copyData(ModifierData *md, ModifierData *target) static void freeData(ModifierData *md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; if (smd->mCache) { ccgSubSurf_free(smd->mCache); @@ -83,41 +83,41 @@ static void freeData(ModifierData *md) static int isDisabled(ModifierData *md, int useRenderParams) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - int levels= (useRenderParams)? smd->renderLevels: smd->levels; + SubsurfModifierData *smd = (SubsurfModifierData *) md; + int levels = (useRenderParams) ? smd->renderLevels : smd->levels; return get_render_subsurf_level(&md->scene->r, levels) == 0; } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, - int isFinalCalc) + DerivedMesh *derivedData, + int useRenderParams, + int isFinalCalc) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; DerivedMesh *result; result = subsurf_make_derived_from_derived(derivedData, smd, - useRenderParams, NULL, isFinalCalc, 0, (ob->flag & OB_MODE_EDIT)); + useRenderParams, NULL, isFinalCalc, 0, (ob->flag & OB_MODE_EDIT)); if (useRenderParams || !isFinalCalc) { - DerivedMesh *cddm= CDDM_copy(result); + DerivedMesh *cddm = CDDM_copy(result); result->release(result); - result= cddm; + result = cddm; } return result; } static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob), - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; DerivedMesh *result; result = subsurf_make_derived_from_derived(derivedData, smd, 0, - NULL, 0, 1, 1); + NULL, 0, 1, 1); return result; } @@ -128,11 +128,11 @@ ModifierTypeInfo modifierType_Subsurf = { /* structName */ "SubsurfModifierData", /* structSize */ sizeof(SubsurfModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index 86e11aca5b7..9483dede73d 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -51,14 +51,14 @@ static void initData(ModifierData *md) { - SurfaceModifierData *surmd = (SurfaceModifierData*) md; + SurfaceModifierData *surmd = (SurfaceModifierData *) md; surmd->bvhtree = NULL; } static void freeData(ModifierData *md) { - SurfaceModifierData *surmd = (SurfaceModifierData*) md; + SurfaceModifierData *surmd = (SurfaceModifierData *) md; if (surmd) { if (surmd->bvhtree) { @@ -86,13 +86,13 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - SurfaceModifierData *surmd = (SurfaceModifierData*) md; + SurfaceModifierData *surmd = (SurfaceModifierData *) md; if (surmd->dm) surmd->dm->release(surmd->dm); @@ -115,9 +115,13 @@ static void deformVerts(ModifierData *md, Object *ob, CDDM_apply_vert_coords(surmd->dm, vertexCos); CDDM_calc_normals(surmd->dm); - numverts = surmd->dm->getNumVerts ( surmd->dm ); + numverts = surmd->dm->getNumVerts(surmd->dm); - if (numverts != surmd->numverts || surmd->x == NULL || surmd->v == NULL || md->scene->r.cfra != surmd->cfra+1) { + if (numverts != surmd->numverts || + surmd->x == NULL || + surmd->v == NULL || + md->scene->r.cfra != surmd->cfra + 1) + { if (surmd->x) { MEM_freeN(surmd->x); surmd->x = NULL; @@ -136,7 +140,7 @@ static void deformVerts(ModifierData *md, Object *ob, } /* convert to global coordinates and calculate velocity */ - for (i = 0, x = surmd->x, v = surmd->v; ix, v = surmd->v; i < numverts; i++, x++, v++) { vec = CDDM_get_vert(surmd->dm, i)->co; mul_m4_v3(ob->obmat, vec); @@ -168,8 +172,8 @@ ModifierTypeInfo modifierType_Surface = { /* structName */ "SurfaceModifierData", /* structSize */ sizeof(SurfaceModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_NoUserAdd, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_NoUserAdd, /* copyData */ NULL, /* deformVerts */ deformVerts, @@ -186,6 +190,6 @@ ModifierTypeInfo modifierType_Surface = { /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 2e8faaae5bf..2d8656e127b 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -82,7 +82,7 @@ void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) */ if (result_type & TEX_RGB) texres->tin = (0.35f * texres->tr + 0.45f * texres->tg - + 0.2f * texres->tb); + + 0.2f * texres->tb); else texres->tr = texres->tg = texres->tb = texres->tin; } @@ -120,11 +120,11 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, /* verts are given the UV from the first face that uses them */ for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp) { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; if (done[vidx] == 0) { /* remap UVs from [0, 1] to [-1, 1] */ @@ -145,26 +145,26 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, for (i = 0; i < numVerts; ++i, ++co, ++texco) { switch (texmapping) { - case MOD_DISP_MAP_LOCAL: - copy_v3_v3(*texco, *co); - break; - case MOD_DISP_MAP_GLOBAL: - mul_v3_m4v3(*texco, ob->obmat, *co); - break; - case MOD_DISP_MAP_OBJECT: - mul_v3_m4v3(*texco, ob->obmat, *co); - mul_m4_v3(mapob_imat, *texco); - break; + case MOD_DISP_MAP_LOCAL: + copy_v3_v3(*texco, *co); + break; + case MOD_DISP_MAP_GLOBAL: + mul_v3_m4v3(*texco, ob->obmat, *co); + break; + case MOD_DISP_MAP_OBJECT: + mul_v3_m4v3(*texco, ob->obmat, *co); + mul_m4_v3(mapob_imat, *texco); + break; } } } void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3]) { - while ((md=md->next) && md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if (amd->multi && amd->prevCos==NULL) - amd->prevCos= MEM_dupallocN(vertexCos); + while ((md = md->next) && md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *) md; + if (amd->multi && amd->prevCos == NULL) + amd->prevCos = MEM_dupallocN(vertexCos); else break; } @@ -178,10 +178,10 @@ DerivedMesh *get_cddm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float return dm; if (!dm) { - dm= get_dm(ob, em, dm, vertexCos, 0); + dm = get_dm(ob, em, dm, vertexCos, 0); } else { - dm= CDDM_copy(dm); + dm = CDDM_copy(dm); CDDM_apply_vert_coords(dm, vertexCos); } @@ -197,8 +197,8 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (* if (dm) return dm; - if (ob->type==OB_MESH) { - if (em) dm= CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); + if (ob->type == OB_MESH) { + if (em) dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob); if (vertexCos) { @@ -210,7 +210,7 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (* DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob)); } else if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - dm= CDDM_from_curve(ob); + dm = CDDM_from_curve(ob); } return dm; diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 4e9e980e8b7..ccfda6af59f 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -58,7 +58,7 @@ static void initData(ModifierData *md) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; int i; for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) @@ -72,8 +72,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; - UVProjectModifierData *tumd = (UVProjectModifierData*) target; + UVProjectModifierData *umd = (UVProjectModifierData *) md; + UVProjectModifierData *tumd = (UVProjectModifierData *) target; int i; for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) @@ -99,9 +99,9 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( } static void foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; int i; for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) @@ -109,22 +109,22 @@ static void foreachObjectLink(ModifierData *md, Object *ob, } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; walk(userData, ob, (ID **)&umd->image); foreachObjectLink(md, ob, (ObjectWalkFunc)walk, - userData); + userData); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; int i; for (i = 0; i < umd->num_projectors; ++i) { @@ -132,20 +132,20 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, DagNode *curNode = dag_get_node(forest, umd->projectors[i]); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "UV Project Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "UV Project Modifier"); } } } typedef struct Projector { - Object *ob; /* object this projector is derived from */ - float projmat[4][4]; /* projection matrix */ - float normal[3]; /* projector normal in world space */ - void *uci; /* optional uv-project info (panorama projection) */ + Object *ob; /* object this projector is derived from */ + float projmat[4][4]; /* projection matrix */ + float normal[3]; /* projector normal in world space */ + void *uci; /* optional uv-project info (panorama projection) */ } Projector; static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, - Object *ob, DerivedMesh *dm) + Object *ob, DerivedMesh *dm) { float (*coords)[3], (*co)[3]; MLoopUV *mloop_uv; @@ -159,11 +159,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, int num_projectors = 0; float aspect; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; - float aspx= umd->aspectx ? umd->aspectx : 1.0f; - float aspy= umd->aspecty ? umd->aspecty : 1.0f; - float scax= umd->scalex ? umd->scalex : 1.0f; - float scay= umd->scaley ? umd->scaley : 1.0f; - int free_uci= 0; + float aspx = umd->aspectx ? umd->aspectx : 1.0f; + float aspy = umd->aspecty ? umd->aspecty : 1.0f; + float scax = umd->scalex ? umd->scalex : 1.0f; + float scay = umd->scaley ? umd->scaley : 1.0f; + int free_uci = 0; aspect = aspx / aspy; @@ -188,23 +188,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* calculate projection matrix */ invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); - projectors[i].uci= NULL; + projectors[i].uci = NULL; if (projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; if (cam->type == CAM_PANO) { - projectors[i].uci= BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy); + 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; + free_uci = 1; } else { - 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 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; - if (sensor_fit==CAMERA_SENSOR_FIT_HOR) { + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { xmax = 0.5f * scale; ymax = xmax / aspect; } @@ -248,12 +248,12 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, offsetmat[3][1] -= cam->shifty; } else if (aspx < aspy) { - offsetmat[3][0] -=(cam->shiftx * aspy/aspx); + offsetmat[3][0] -= (cam->shiftx * aspy / aspx); offsetmat[3][1] -= cam->shifty; } else { offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -=(cam->shifty * aspx/aspy); + offsetmat[3][1] -= (cam->shifty * aspx / aspy); } } @@ -271,16 +271,16 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* make sure we are not modifying the original UV map */ mloop_uv = CustomData_duplicate_referenced_layer_named(&dm->loopData, - CD_MLOOPUV, uvname, numLoops); + CD_MLOOPUV, uvname, numLoops); /* can be NULL */ mt = mtexpoly = CustomData_duplicate_referenced_layer_named(&dm->polyData, - CD_MTEXPOLY, uvname, numPolys); + CD_MTEXPOLY, uvname, numPolys); numVerts = dm->getNumVerts(dm); coords = MEM_callocN(sizeof(*coords) * numVerts, - "uvprojectModifier_do coords"); + "uvprojectModifier_do coords"); dm->getVertCos(dm, coords); /* convert coords to world space */ @@ -288,7 +288,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, mul_m4_v3(ob->obmat, *co); /* if only one projector, project coords to UVs */ - if (num_projectors == 1 && projectors[0].uci==NULL) + if (num_projectors == 1 && projectors[0].uci == NULL) for (i = 0, co = coords; i < numVerts; ++i, ++co) mul_project_m4_v3(projectors[0].projmat, *co); @@ -300,19 +300,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if (override_image || !image || (mtexpoly == NULL || mt->tpage == image)) { if (num_projectors == 1) { if (projectors[0].uci) { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci); } while (fidx--); } else { /* apply transformed coords as UVs */ - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; copy_v2_v2(mloop_uv[lidx].uv, coords[vidx]); } while (fidx--); } @@ -335,7 +335,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, for (j = 1; j < num_projectors; ++j) { float tmp_dot = dot_v3v3(projectors[j].normal, - face_no); + face_no); if (tmp_dot > best_dot) { best_dot = tmp_dot; best_projector = &projectors[j]; @@ -343,18 +343,18 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } if (best_projector->uci) { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci); } while (fidx--); } else { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; float tco[3]; copy_v3_v3(tco, coords[vidx]); @@ -389,12 +389,12 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { DerivedMesh *result; - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; result = uvprojectModifier_do(umd, ob, derivedData); @@ -402,8 +402,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { return applyModifier(md, ob, derivedData, 0, 1); } @@ -414,10 +414,10 @@ ModifierTypeInfo modifierType_UVProject = { /* structName */ "UVProjectModifierData", /* structSize */ sizeof(UVProjectModifierData), /* type */ eModifierTypeType_NonGeometrical, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 5ee8103630d..1a654351ea8 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); wmd->texture = NULL; @@ -63,8 +63,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - WarpModifierData *wmd = (WarpModifierData*) md; - WarpModifierData *twmd = (WarpModifierData*) target; + WarpModifierData *wmd = (WarpModifierData *) md; + WarpModifierData *twmd = (WarpModifierData *) target; twmd->object_from = wmd->object_from; twmd->object_to = wmd->object_to; @@ -79,7 +79,7 @@ static void copyData(ModifierData *md, ModifierData *target) twmd->texture = wmd->texture; twmd->map_object = wmd->map_object; BLI_strncpy(twmd->uvlayer_name, wmd->uvlayer_name, sizeof(twmd->uvlayer_name)); - twmd->texmapping= wmd->texmapping; + twmd->texmapping = wmd->texmapping; } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) @@ -118,14 +118,14 @@ static void freeData(ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; return !(wmd->object_from && wmd->object_to); } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; walk(userData, ob, &wmd->object_from); walk(userData, ob, &wmd->object_to); @@ -134,7 +134,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; walk(userData, ob, (ID **)&wmd->texture); @@ -151,7 +151,7 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; if (wmd->object_from && wmd->object_to) { DagNode *fromNode = dag_get_node(forest, wmd->object_from); @@ -183,9 +183,9 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, float fac = 1.0f, weight; int i; int defgrp_index; - MDeformVert *dvert, *dv= NULL; + MDeformVert *dvert, *dv = NULL; - float (*tex_co)[3]= NULL; + float (*tex_co)[3] = NULL; if (!(wmd->object_from && wmd->object_to)) return; @@ -217,7 +217,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, negate_v3_v3(mat_final[3], loc); } - weight= strength; + weight = strength; if (wmd->texture) { tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, "warpModifier_do tex_co"); @@ -231,7 +231,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, 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))) + (fac = (wmd->falloff_radius - fac) / wmd->falloff_radius))) { /* skip if no vert group found */ if (dvert && defgrp_index >= 0) { @@ -247,30 +247,30 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, /* closely match PROP_SMOOTH and similar */ switch (wmd->falloff_type) { - case eWarp_Falloff_None: - fac = 1.0f; - break; - case eWarp_Falloff_Curve: - fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac); - break; - case eWarp_Falloff_Sharp: - fac = fac*fac; - break; - case eWarp_Falloff_Smooth: - fac = 3.0f*fac*fac - 2.0f*fac*fac*fac; - break; - case eWarp_Falloff_Root: - fac = (float)sqrt(fac); - break; - case eWarp_Falloff_Linear: - /* pass */ - break; - case eWarp_Falloff_Const: - fac = 1.0f; - break; - case eWarp_Falloff_Sphere: - fac = (float)sqrt(2*fac - fac * fac); - break; + case eWarp_Falloff_None: + fac = 1.0f; + break; + case eWarp_Falloff_Curve: + fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac); + break; + case eWarp_Falloff_Sharp: + fac = fac * fac; + break; + case eWarp_Falloff_Smooth: + fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; + break; + case eWarp_Falloff_Root: + fac = (float)sqrt(fac); + break; + case eWarp_Falloff_Linear: + /* pass */ + break; + case eWarp_Falloff_Const: + fac = 1.0f; + break; + case eWarp_Falloff_Sphere: + fac = (float)sqrt(2 * fac - fac * fac); + break; } fac *= weight; @@ -319,11 +319,11 @@ static int warp_needs_dm(WarpModifierData *wmd) static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - DerivedMesh *dm= NULL; - int use_dm= warp_needs_dm((WarpModifierData *)md); + DerivedMesh *dm = NULL; + int use_dm = warp_needs_dm((WarpModifierData *)md); if (use_dm) { - dm= get_cddm(ob, NULL, derivedData, vertexCos); + dm = get_cddm(ob, NULL, derivedData, vertexCos); } warpModifier_do((WarpModifierData *)md, ob, dm, vertexCos, numVerts); @@ -337,7 +337,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - int use_dm= warp_needs_dm((WarpModifierData *)md); + int use_dm = warp_needs_dm((WarpModifierData *)md); if (use_dm) { if (!derivedData) @@ -353,27 +353,27 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD ModifierTypeInfo modifierType_Warp = { - /* name */ "Warp", - /* structName */ "WarpModifierData", - /* structSize */ sizeof(WarpModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ 0, - /* applyModifierEM */ 0, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Warp", + /* structName */ "WarpModifierData", + /* structSize */ sizeof(WarpModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ 0, + /* applyModifierEM */ 0, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ foreachIDLink, - /* foreachTexLink */ foreachTexLink, + /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ foreachTexLink, }; diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index db5538aba51..042401ee26f 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -58,29 +58,29 @@ static void initData(ModifierData *md) { - WaveModifierData *wmd = (WaveModifierData*) md; // whadya know, moved here from Iraq + WaveModifierData *wmd = (WaveModifierData *) md; // whadya know, moved here from Iraq - wmd->flag |= (MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL - | MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z); + wmd->flag |= (MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL | + MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z); wmd->objectcenter = NULL; wmd->texture = NULL; wmd->map_object = NULL; - wmd->height= 0.5f; - wmd->width= 1.5f; - wmd->speed= 0.25f; - wmd->narrow= 1.5f; - wmd->lifetime= 0.0f; - wmd->damp= 10.0f; - wmd->falloff= 0.0f; + wmd->height = 0.5f; + wmd->width = 1.5f; + wmd->speed = 0.25f; + wmd->narrow = 1.5f; + wmd->lifetime = 0.0f; + wmd->damp = 10.0f; + wmd->falloff = 0.0f; wmd->texmapping = MOD_DISP_MAP_LOCAL; wmd->defgrp_name[0] = 0; } static void copyData(ModifierData *md, ModifierData *target) { - WaveModifierData *wmd = (WaveModifierData*) md; - WaveModifierData *twmd = (WaveModifierData*) target; + WaveModifierData *wmd = (WaveModifierData *) md; + WaveModifierData *twmd = (WaveModifierData *) target; twmd->damp = wmd->damp; twmd->flag = wmd->flag; @@ -106,19 +106,19 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void foreachObjectLink( - ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ModifierData *md, Object *ob, + ObjectWalkFunc walk, void *userData) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; walk(userData, ob, &wmd->objectcenter); walk(userData, ob, &wmd->map_object); } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; walk(userData, ob, (ID **)&wmd->texture); @@ -126,30 +126,30 @@ static void foreachIDLink(ModifierData *md, Object *ob, } static void foreachTexLink(ModifierData *md, Object *ob, - TexWalkFunc walk, void *userData) + TexWalkFunc walk, void *userData) { walk(userData, ob, md, "texture"); } static void updateDepgraph(ModifierData *md, DagForest *forest, - Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; if (wmd->objectcenter) { DagNode *curNode = dag_get_node(forest, wmd->objectcenter); dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Wave Modifier"); + "Wave Modifier"); } if (wmd->map_object) { DagNode *curNode = dag_get_node(forest, wmd->map_object); dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Wave Modifer"); + "Wave Modifer"); } } @@ -171,21 +171,20 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void waveModifier_do(WaveModifierData *md, - Scene *scene, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + Scene *scene, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; MVert *mvert = NULL; MDeformVert *dvert; int defgrp_index; float ctime = BKE_scene_frame_get(scene); - float minfac = - (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); + float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); float lifefac = wmd->height; float (*tex_co)[3] = NULL; - const int wmd_axis= wmd->flag & (MOD_WAVE_X|MOD_WAVE_Y); - const float falloff= wmd->falloff; - float falloff_fac= 1.0f; /* when falloff == 0.0f this stays at 1.0f */ + const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y); + const float falloff = wmd->falloff; + float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */ if (wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH) mvert = dm->getVertArray(dm); @@ -212,14 +211,13 @@ static void waveModifier_do(WaveModifierData *md, lifefac = x - wmd->lifetime; if (lifefac > wmd->damp) lifefac = 0.0; - else lifefac = - (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); + else lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); } } if (wmd->texture) { tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, - "waveModifier_do tex_co"); + "waveModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts); modifier_init_texture(wmd->modifier.scene, wmd->texture); @@ -227,19 +225,19 @@ static void waveModifier_do(WaveModifierData *md, if (lifefac != 0.0f) { /* avoid divide by zero checks within the loop */ - float falloff_inv= falloff ? 1.0f / falloff : 1.0f; + float falloff_inv = falloff ? 1.0f / falloff : 1.0f; int i; for (i = 0; i < numVerts; i++) { float *co = vertexCos[i]; float x = co[0] - wmd->startx; float y = co[1] - wmd->starty; - float amplit= 0.0f; - float def_weight= 1.0f; + float amplit = 0.0f; + float def_weight = 1.0f; /* get weights */ if (dvert) { - def_weight= defvert_find_weight(&dvert[i], defgrp_index); + def_weight = defvert_find_weight(&dvert[i], defgrp_index); /* if this vert isn't in the vgroup, don't deform it */ if (def_weight == 0.0f) { @@ -248,38 +246,38 @@ static void waveModifier_do(WaveModifierData *md, } switch (wmd_axis) { - case MOD_WAVE_X|MOD_WAVE_Y: - amplit = sqrtf(x*x + y*y); - break; - case MOD_WAVE_X: - amplit = x; - break; - case MOD_WAVE_Y: - amplit = y; - break; + case MOD_WAVE_X | MOD_WAVE_Y: + amplit = sqrtf(x * x + y * y); + break; + case MOD_WAVE_X: + amplit = x; + break; + case MOD_WAVE_Y: + amplit = y; + break; } /* this way it makes nice circles */ amplit -= (ctime - wmd->timeoffs) * wmd->speed; if (wmd->flag & MOD_WAVE_CYCL) { - amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) - + wmd->width; + amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) + + wmd->width; } if (falloff != 0.0f) { float dist = 0.0f; switch (wmd_axis) { - case MOD_WAVE_X|MOD_WAVE_Y: - dist = sqrtf(x*x + y*y); - break; - case MOD_WAVE_X: - dist = fabsf(x); - break; - case MOD_WAVE_Y: - dist = fabsf(y); - break; + case MOD_WAVE_X | MOD_WAVE_Y: + dist = sqrtf(x * x + y * y); + break; + case MOD_WAVE_X: + dist = fabsf(x); + break; + case MOD_WAVE_Y: + dist = fabsf(y); + break; } falloff_fac = (1.0f - (dist * falloff_inv)); @@ -326,19 +324,19 @@ static void waveModifier_do(WaveModifierData *md, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + int UNUSED(useRenderParams), + int UNUSED(isFinalCalc)) { - DerivedMesh *dm= derivedData; + DerivedMesh *dm = derivedData; WaveModifierData *wmd = (WaveModifierData *)md; if (wmd->flag & MOD_WAVE_NORM) - dm= get_cddm(ob, NULL, dm, vertexCos); + dm = get_cddm(ob, NULL, dm, vertexCos); else if (wmd->texture || wmd->defgrp_name[0]) - dm= get_dm(ob, NULL, dm, NULL, 0); + dm = get_dm(ob, NULL, dm, NULL, 0); waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts); @@ -347,16 +345,16 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm= derivedData; + DerivedMesh *dm = derivedData; WaveModifierData *wmd = (WaveModifierData *)md; if (wmd->flag & MOD_WAVE_NORM) - dm= get_cddm(ob, editData, dm, vertexCos); + dm = get_cddm(ob, editData, dm, vertexCos); else if (wmd->texture || wmd->defgrp_name[0]) - dm= get_dm(ob, editData, dm, NULL, 0); + dm = get_dm(ob, editData, dm, NULL, 0); waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts); @@ -370,8 +368,8 @@ ModifierTypeInfo modifierType_Wave = { /* structName */ "WaveModifierData", /* structSize */ sizeof(WaveModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 1f886812ab7..5097ae8c742 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -80,28 +80,28 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm /* Code borrowed from the warp modifier. */ /* Closely matches PROP_SMOOTH and similar. */ switch (falloff_type) { - case MOD_WVG_MAPPING_CURVE: - fac = curvemapping_evaluateF(cmap, 0, fac); - break; - case MOD_WVG_MAPPING_SHARP: - fac = fac*fac; - break; - case MOD_WVG_MAPPING_SMOOTH: - fac = 3.0f*fac*fac - 2.0f*fac*fac*fac; - break; - case MOD_WVG_MAPPING_ROOT: - fac = (float)sqrt(fac); - break; - case MOD_WVG_MAPPING_SPHERE: - fac = (float)sqrt(2*fac - fac * fac); - break; - case MOD_WVG_MAPPING_RANDOM: - BLI_srand(BLI_rand()); /* random seed */ - fac = BLI_frand()*fac; - break; - case MOD_WVG_MAPPING_STEP: - fac = (fac >= 0.5f)?1.0f:0.0f; - break; + case MOD_WVG_MAPPING_CURVE: + fac = curvemapping_evaluateF(cmap, 0, fac); + break; + case MOD_WVG_MAPPING_SHARP: + fac = fac * fac; + break; + case MOD_WVG_MAPPING_SMOOTH: + fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; + break; + case MOD_WVG_MAPPING_ROOT: + fac = (float)sqrt(fac); + break; + case MOD_WVG_MAPPING_SPHERE: + fac = (float)sqrt(2 * fac - fac * fac); + break; + case MOD_WVG_MAPPING_RANDOM: + BLI_srand(BLI_rand()); /* random seed */ + fac = BLI_frand() * fac; + break; + case MOD_WVG_MAPPING_STEP: + fac = (fac >= 0.5f) ? 1.0f : 0.0f; + break; } new_w[i] = fac; @@ -160,36 +160,36 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne get_texture_value(texture, tex_co[idx], &texres); /* Get the good channel value... */ switch (tex_use_channel) { - case MOD_WVG_MASK_TEX_USE_INT: - org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact))); - break; - case MOD_WVG_MASK_TEX_USE_RED: - org_w[i] = (new_w[i] * texres.tr * fact) + (org_w[i] * (1.0f - (texres.tr*fact))); - break; - case MOD_WVG_MASK_TEX_USE_GREEN: - org_w[i] = (new_w[i] * texres.tg * fact) + (org_w[i] * (1.0f - (texres.tg*fact))); - break; - case MOD_WVG_MASK_TEX_USE_BLUE: - org_w[i] = (new_w[i] * texres.tb * fact) + (org_w[i] * (1.0f - (texres.tb*fact))); - break; - case MOD_WVG_MASK_TEX_USE_HUE: - rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); - org_w[i] = (new_w[i] * h * fact) + (org_w[i] * (1.0f - (h*fact))); - break; - case MOD_WVG_MASK_TEX_USE_SAT: - rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); - org_w[i] = (new_w[i] * s * fact) + (org_w[i] * (1.0f - (s*fact))); - break; - case MOD_WVG_MASK_TEX_USE_VAL: - rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); - org_w[i] = (new_w[i] * v * fact) + (org_w[i] * (1.0f - (v*fact))); - break; - case MOD_WVG_MASK_TEX_USE_ALPHA: - org_w[i] = (new_w[i] * texres.ta * fact) + (org_w[i] * (1.0f - (texres.ta*fact))); - break; - default: - org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact))); - break; + case MOD_WVG_MASK_TEX_USE_INT: + org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin * fact))); + break; + case MOD_WVG_MASK_TEX_USE_RED: + org_w[i] = (new_w[i] * texres.tr * fact) + (org_w[i] * (1.0f - (texres.tr * fact))); + break; + case MOD_WVG_MASK_TEX_USE_GREEN: + org_w[i] = (new_w[i] * texres.tg * fact) + (org_w[i] * (1.0f - (texres.tg * fact))); + break; + case MOD_WVG_MASK_TEX_USE_BLUE: + org_w[i] = (new_w[i] * texres.tb * fact) + (org_w[i] * (1.0f - (texres.tb * fact))); + break; + case MOD_WVG_MASK_TEX_USE_HUE: + rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); + org_w[i] = (new_w[i] * h * fact) + (org_w[i] * (1.0f - (h * fact))); + break; + case MOD_WVG_MASK_TEX_USE_SAT: + rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); + org_w[i] = (new_w[i] * s * fact) + (org_w[i] * (1.0f - (s * fact))); + break; + case MOD_WVG_MASK_TEX_USE_VAL: + rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); + org_w[i] = (new_w[i] * v * fact) + (org_w[i] * (1.0f - (v * fact))); + break; + case MOD_WVG_MASK_TEX_USE_ALPHA: + org_w[i] = (new_w[i] * texres.ta * fact) + (org_w[i] * (1.0f - (texres.ta * fact))); + break; + default: + org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin * fact))); + break; } } @@ -213,7 +213,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne for (i = 0; i < num; i++) { int idx = indices ? indices[i] : i; const float f = defvert_find_weight(&dvert[idx], ref_didx) * fact; - org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f-f)); + org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f)); /* If that vertex is not in ref vgroup, assume null factor, and hence do nothing! */ } } diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 0ef27ed992e..639b8bb2593 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -55,7 +55,7 @@ **************************************/ static void initData(ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; wmd->edit_flags = 0; wmd->falloff_type = MOD_WVG_MAPPING_NONE; wmd->default_weight = 0.0f; @@ -73,14 +73,14 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; curvemapping_free(wmd->cmap_curve); } static void copyData(ModifierData *md, ModifierData *target) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; - WeightVGEditModifierData *twmd = (WeightVGEditModifierData*) target; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; + WeightVGEditModifierData *twmd = (WeightVGEditModifierData *) target; BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name)); @@ -104,7 +104,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; CustomDataMask dataMask = 0; /* We need vertex groups! */ @@ -121,7 +121,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int dependsOnTime(ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; if (wmd->mask_texture) return BKE_texture_dependsOnTime(wmd->mask_texture); @@ -132,13 +132,13 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; walk(userData, ob, &wmd->mask_tex_map_obj); } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; walk(userData, ob, (ID **)&wmd->mask_texture); @@ -153,24 +153,24 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; DagNode *curNode; 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, "WeightVGEdit 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, "WeightVGEdit Modifier"); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; /* If no vertex group, bypass. */ return (wmd->defgrp_name[0] == '\0'); } @@ -178,7 +178,7 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; DerivedMesh *dm = derivedData; MDeformVert *dvert = NULL; MDeformWeight **dw = NULL; @@ -226,7 +226,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); new_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, new_w"); - dw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGEdit Modifier, dw"); + dw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGEdit Modifier, dw"); for (i = 0; i < numVerts; i++) { dw[i] = defvert_find_index(&dvert[i], defgrp_idx); if (dw[i]) { @@ -280,10 +280,10 @@ ModifierTypeInfo modifierType_WeightVGEdit = { /* structName */ "WeightVGEditModifierData", /* structSize */ sizeof(WeightVGEditModifierData), /* 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, diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index adcabc23efb..cf11e9d98b0 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -61,26 +61,26 @@ static float mix_weight(float weight, float weight2, char mix_mode) */ switch (mix_mode) { - case MOD_WVG_MIX_ADD: - return (weight + weight2); - case MOD_WVG_MIX_SUB: - return (weight - weight2); - case MOD_WVG_MIX_MUL: - return (weight * weight2); - case MOD_WVG_MIX_DIV: - /* Avoid dividing by zero (or really small values). */ - if (0.0 <= weight2 < MOD_WVG_ZEROFLOOR) - weight2 = MOD_WVG_ZEROFLOOR; - else if (-MOD_WVG_ZEROFLOOR < weight2) - weight2 = -MOD_WVG_ZEROFLOOR; - return (weight / weight2); - case MOD_WVG_MIX_DIF: - return (weight < weight2 ? weight2 - weight : weight - weight2); - case MOD_WVG_MIX_AVG: - return (weight + weight2) / 2.0; - case MOD_WVG_MIX_SET: - default: - return weight2; + case MOD_WVG_MIX_ADD: + return (weight + weight2); + case MOD_WVG_MIX_SUB: + return (weight - weight2); + case MOD_WVG_MIX_MUL: + return (weight * weight2); + case MOD_WVG_MIX_DIV: + /* Avoid dividing by zero (or really small values). */ + if (0.0 <= weight2 < MOD_WVG_ZEROFLOOR) + weight2 = MOD_WVG_ZEROFLOOR; + else if (-MOD_WVG_ZEROFLOOR < weight2) + weight2 = -MOD_WVG_ZEROFLOOR; + return (weight / weight2); + case MOD_WVG_MIX_DIF: + return (weight < weight2 ? weight2 - weight : weight - weight2); + case MOD_WVG_MIX_AVG: + return (weight + weight2) / 2.0; + case MOD_WVG_MIX_SET: + default: + return weight2; } #endif if (mix_mode == MOD_WVG_MIX_SET) @@ -111,7 +111,7 @@ static float mix_weight(float weight, float weight2, char mix_mode) **************************************/ static void initData(ModifierData *md) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; wmd->default_weight_a = 0.0f; wmd->default_weight_b = 0.0f; @@ -125,8 +125,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; - WeightVGMixModifierData *twmd = (WeightVGMixModifierData*) target; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; + WeightVGMixModifierData *twmd = (WeightVGMixModifierData *) target; BLI_strncpy(twmd->defgrp_name_a, wmd->defgrp_name_a, sizeof(twmd->defgrp_name_a)); BLI_strncpy(twmd->defgrp_name_b, wmd->defgrp_name_b, sizeof(twmd->defgrp_name_b)); @@ -146,7 +146,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; CustomDataMask dataMask = 0; /* We need vertex groups! */ @@ -163,7 +163,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int dependsOnTime(ModifierData *md) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; if (wmd->mask_texture) return BKE_texture_dependsOnTime(wmd->mask_texture); @@ -174,13 +174,13 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; walk(userData, ob, &wmd->mask_tex_map_obj); } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; walk(userData, ob, (ID **)&wmd->mask_texture); @@ -195,24 +195,24 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; DagNode *curNode; 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, "WeightVGMix 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, "WeightVGMix Modifier"); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; /* If no vertex group, bypass. */ return (wmd->defgrp_name_a[0] == '\0'); } @@ -220,7 +220,7 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; DerivedMesh *dm = derivedData; MDeformVert *dvert = NULL; MDeformWeight **dw1, **tdw1, **dw2, **tdw2; @@ -271,64 +271,64 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der } /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); - tdw1 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw1"); - tdw2 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw2"); + tdw1 = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGMix Modifier, tdw1"); + tdw2 = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGMix Modifier, tdw2"); switch (wmd->mix_set) { - case MOD_WVG_SET_A: - /* All vertices in first vgroup. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx); - if (dw) { - tdw1[numIdx] = dw; - tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2); - tidx[numIdx++] = i; + case MOD_WVG_SET_A: + /* All vertices in first vgroup. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx); + if (dw) { + tdw1[numIdx] = dw; + tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2); + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_B: - /* All vertices in second vgroup. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2); - if (dw) { - tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx); - tdw2[numIdx] = dw; - tidx[numIdx++] = i; + break; + case MOD_WVG_SET_B: + /* All vertices in second vgroup. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2); + if (dw) { + tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx); + tdw2[numIdx] = dw; + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_OR: - /* All vertices in one vgroup or the other. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); - MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); - if (adw || bdw) { - tdw1[numIdx] = adw; - tdw2[numIdx] = bdw; - tidx[numIdx++] = i; + break; + case MOD_WVG_SET_OR: + /* All vertices in one vgroup or the other. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + if (adw || bdw) { + tdw1[numIdx] = adw; + tdw2[numIdx] = bdw; + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_AND: - /* All vertices in both vgroups. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); - MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); - if (adw && bdw) { - tdw1[numIdx] = adw; - tdw2[numIdx] = bdw; - tidx[numIdx++] = i; + break; + case MOD_WVG_SET_AND: + /* All vertices in both vgroups. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + if (adw && bdw) { + tdw1[numIdx] = adw; + tdw2[numIdx] = bdw; + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_ALL: - default: - /* Use all vertices. */ - for (i = 0; i < numVerts; i++) { - tdw1[i] = defvert_find_index(&dvert[i], defgrp_idx); - tdw2[i] = defvert_find_index(&dvert[i], defgrp_idx2); - } - numIdx = -1; - break; + break; + case MOD_WVG_SET_ALL: + default: + /* Use all vertices. */ + for (i = 0; i < numVerts; i++) { + tdw1[i] = defvert_find_index(&dvert[i], defgrp_idx); + tdw2[i] = defvert_find_index(&dvert[i], defgrp_idx2); + } + numIdx = -1; + break; } if (numIdx == 0) { /* Use no vertices! Hence, return org data. */ @@ -340,11 +340,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (numIdx != -1) { indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGMix Modifier, indices"); memcpy(indices, tidx, sizeof(int) * numIdx); - dw1 = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGMix Modifier, dw1"); - memcpy(dw1, tdw1, sizeof(MDeformWeight*) * numIdx); + dw1 = MEM_mallocN(sizeof(MDeformWeight *) * numIdx, "WeightVGMix Modifier, dw1"); + memcpy(dw1, tdw1, sizeof(MDeformWeight *) * numIdx); MEM_freeN(tdw1); - dw2 = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGMix Modifier, dw2"); - memcpy(dw2, tdw2, sizeof(MDeformWeight*) * numIdx); + dw2 = MEM_mallocN(sizeof(MDeformWeight *) * numIdx, "WeightVGMix Modifier, dw2"); + memcpy(dw2, tdw2, sizeof(MDeformWeight *) * numIdx); MEM_freeN(tdw2); } else { @@ -411,10 +411,10 @@ ModifierTypeInfo modifierType_WeightVGMix = { /* structName */ "WeightVGMixModifierData", /* structSize */ sizeof(WeightVGMixModifierData), /* 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, diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 31cd20e7f97..0c130731c05 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -73,9 +73,9 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3], BVHTreeFromMesh treeData_v = NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData_e = NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData_f = NULL_BVHTreeFromMesh; - BVHTreeNearest nearest_v = NULL_BVHTreeNearest; - BVHTreeNearest nearest_e = NULL_BVHTreeNearest; - BVHTreeNearest nearest_f = NULL_BVHTreeNearest; + BVHTreeNearest nearest_v = NULL_BVHTreeNearest; + BVHTreeNearest nearest_e = NULL_BVHTreeNearest; + BVHTreeNearest nearest_f = NULL_BVHTreeNearest; if (dist_v) { /* Create a bvh-tree of the given target's verts. */ @@ -159,11 +159,11 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3], * Note that it works in final world space (i.e. with constraints etc. applied). */ static void get_vert2ob_distance(int numVerts, float (*v_cos)[3], float *dist, - Object* ob, Object* obr) + Object *ob, Object *obr) { /* Vertex and ref object coordinates. */ float v_wco[3]; - unsigned int i= numVerts; + unsigned int i = numVerts; while (i-- > 0) { /* Get world-coordinates of the vertex (constraints and anim included). */ @@ -177,7 +177,7 @@ static void get_vert2ob_distance(int numVerts, float (*v_cos)[3], float *dist, * Returns the real distance between an object and another reference object. * Note that it works in final world space (i.e. with constraints etc. applied). */ -static float get_ob2ob_distance(const Object* ob, const Object* obr) +static float get_ob2ob_distance(const Object *ob, const Object *obr) { return len_v3v3(ob->obmat[3], obr->obmat[3]); } @@ -187,8 +187,8 @@ static float get_ob2ob_distance(const Object* ob, const Object* obr) */ void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode) { - const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */ - unsigned int i= nidx; + const float range_inv = 1.0f / (max_d - min_d); /* invert since multiplication is faster */ + unsigned int i = nidx; if (max_d == min_d) { while (i-- > 0) { weights[i] = (weights[i] >= max_d) ? 1.0f : 0.0f; /* "Step" behavior... */ @@ -196,16 +196,16 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d } else if (max_d > min_d) { while (i-- > 0) { - if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */ - else if (weights[i] <= min_d) weights[i]= 0.0f; - else weights[i]= (weights[i] - min_d) * range_inv; + if (weights[i] >= max_d) weights[i] = 1.0f; /* most likely case first */ + else if (weights[i] <= min_d) weights[i] = 0.0f; + else weights[i] = (weights[i] - min_d) * range_inv; } } else { while (i-- > 0) { - if (weights[i] <= max_d) weights[i]= 1.0f; /* most likely case first */ - else if (weights[i] >= min_d) weights[i]= 0.0f; - else weights[i]= (weights[i] - min_d) * range_inv; + if (weights[i] <= max_d) weights[i] = 1.0f; /* most likely case first */ + else if (weights[i] >= min_d) weights[i] = 0.0f; + else weights[i] = (weights[i] - min_d) * range_inv; } } @@ -219,7 +219,7 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d **************************************/ static void initData(ModifierData *md) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; wmd->proximity_mode = MOD_WVG_PROXIMITY_OBJECT; wmd->proximity_flags = MOD_WVG_PROXIMITY_GEOM_VERTS; @@ -234,8 +234,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; - WeightVGProximityModifierData *twmd = (WeightVGProximityModifierData*) target; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; + WeightVGProximityModifierData *twmd = (WeightVGProximityModifierData *) target; BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name)); twmd->proximity_mode = wmd->proximity_mode; @@ -257,7 +257,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; CustomDataMask dataMask = 0; /* We need vertex groups! */ @@ -274,7 +274,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int dependsOnTime(ModifierData *md) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; if (wmd->mask_texture) return BKE_texture_dependsOnTime(wmd->mask_texture); @@ -285,14 +285,14 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; walk(userData, ob, &wmd->proximity_ob_target); walk(userData, ob, &wmd->mask_tex_map_obj); } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; walk(userData, ob, (ID **)&wmd->mask_texture); @@ -307,12 +307,12 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; DagNode *curNode; if (wmd->proximity_ob_target) { curNode = dag_get_node(forest, wmd->proximity_ob_target); - 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"); } @@ -330,7 +330,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; /* If no vertex group, bypass. */ if (wmd->defgrp_name[0] == '\0') return 1; /* If no target object, bypass. */ @@ -340,7 +340,7 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; DerivedMesh *dm = derivedData; MDeformVert *dvert = NULL; MDeformWeight **dw, **tdw; @@ -350,7 +350,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der int defgrp_idx; float *tw = NULL; float *org_w = NULL; - float *new_w =NULL; + float *new_w = NULL; int *tidx, *indices = NULL; int numIdx = 0; int i; @@ -392,7 +392,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGProximity Modifier, tidx"); tw = MEM_mallocN(sizeof(float) * numVerts, "WeightVGProximity Modifier, tw"); - tdw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGProximity Modifier, tdw"); + tdw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGProximity Modifier, tdw"); for (i = 0; i < numVerts; i++) { MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_idx); if (_dw) { @@ -413,8 +413,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der memcpy(indices, tidx, sizeof(int) * numIdx); org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, org_w"); memcpy(org_w, tw, sizeof(float) * numIdx); - dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGProximity Modifier, dw"); - memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx); + dw = MEM_mallocN(sizeof(MDeformWeight *) * numIdx, "WeightVGProximity Modifier, dw"); + memcpy(dw, tdw, sizeof(MDeformWeight *) * numIdx); MEM_freeN(tw); MEM_freeN(tdw); } @@ -458,7 +458,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (ELEM3(obr->type, OB_CURVE, OB_SURF, OB_FONT)) target_dm = CDDM_from_curve(obr); else if (obr->type == OB_MESH) { - Mesh *me = (Mesh*)obr->data; + Mesh *me = (Mesh *)obr->data; if (me->edit_btmesh) target_dm = CDDM_from_BMEditMesh(me->edit_btmesh, me, FALSE, FALSE); else @@ -470,9 +470,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* We must check that we do have a valid target_dm! */ if (target_dm) { SpaceTransform loc2trgt; - float *dists_v = use_trgt_verts ? MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, dists_v") : NULL; - float *dists_e = use_trgt_edges ? MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, dists_e") : NULL; - float *dists_f = use_trgt_faces ? MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, dists_f") : NULL; + float *dists_v = use_trgt_verts ? MEM_mallocN(sizeof(float) * numIdx, "dists_v") : NULL; + float *dists_e = use_trgt_edges ? MEM_mallocN(sizeof(float) * numIdx, "dists_e") : NULL; + float *dists_f = use_trgt_faces ? MEM_mallocN(sizeof(float) * numIdx, "dists_f") : NULL; space_transform_setup(&loc2trgt, ob, obr); get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f, From fbf06d0f5d5f2990256c89598c825b4dfa7da063 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 13:41:27 +0000 Subject: [PATCH 103/143] update for recent RNA change --- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 503229f5593..f220ec19bfe 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -145,10 +145,10 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, Panel): row = col.row(align=True) props = row.operator("mesh.knife_tool", text="Knife") props.use_occlude_geometry = True - props.only_select = False + props.only_selected = False props = row.operator("mesh.knife_tool", text="Select") props.use_occlude_geometry = False - props.only_select = True + props.only_selected = True col = layout.column(align=True) col.label(text="Remove:") From 53b221960acaa63cc50bd8095d0ea11f9de539e1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 6 May 2012 15:03:31 +0000 Subject: [PATCH 104/143] =?UTF-8?q?Last=20part=20of=20fix=20for=20[#31157]?= =?UTF-8?q?:=20Some=20(actually,=20172)=20operators=20have=20no=20tooltip.?= =?UTF-8?q?=20Only=20remaining=20undocumented=20one=20is=20IMAGE=5FOT=5Fre?= =?UTF-8?q?cord=5Fcomposite=20(not=20sure=20what=20it=20actually=20does,?= =?UTF-8?q?=20nor=20even=20whether=20it=E2=80=99s=20actually=20working=20o?= =?UTF-8?q?r=20not...).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that I didn’t bother with operators flagged as OPTYPE_INTERNAL! --- .../blender/editors/armature/editarmature_sketch.c | 8 ++++++++ .../blender/editors/physics/physics_pointcache.c | 1 + source/blender/editors/screen/screen_ops.c | 3 +++ source/blender/editors/screen/screendump.c | 6 ++++-- source/blender/editors/sculpt_paint/paint_vertex.c | 2 ++ source/blender/editors/sculpt_paint/sculpt.c | 5 ++++- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 14 ++++++++++++++ source/blender/windowmanager/intern/wm_operators.c | 4 +++- 8 files changed, 39 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 09b0226c58c..9b32c7a090e 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2595,6 +2595,7 @@ void SKETCH_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name = "Delete"; ot->idname = "SKETCH_OT_delete"; + ot->description = "Delete a sketch stroke"; /* api callbacks */ ot->invoke = sketch_delete; @@ -2610,6 +2611,7 @@ void SKETCH_OT_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select"; ot->idname = "SKETCH_OT_select"; + ot->description = "Select a sketch stroke"; /* api callbacks */ ot->invoke = sketch_select; @@ -2625,6 +2627,7 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "Cancel Stroke"; ot->idname = "SKETCH_OT_cancel_stroke"; + ot->description = "Cancel the current sketch stroke"; /* api callbacks */ ot->invoke = sketch_cancel; @@ -2640,6 +2643,7 @@ void SKETCH_OT_convert(wmOperatorType *ot) /* identifiers */ ot->name = "Convert"; ot->idname = "SKETCH_OT_convert"; + ot->description = "Convert the selected sketch strokes to bone chains"; /* api callbacks */ ot->invoke = sketch_convert; @@ -2655,6 +2659,7 @@ void SKETCH_OT_finish_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "End Stroke"; ot->idname = "SKETCH_OT_finish_stroke"; + ot->description = "End and keep the current sketch stroke"; /* api callbacks */ ot->invoke = sketch_finish; @@ -2670,6 +2675,7 @@ void SKETCH_OT_draw_preview(wmOperatorType *ot) /* identifiers */ ot->name = "Draw Preview"; ot->idname = "SKETCH_OT_draw_preview"; + ot->description = "Draw preview of current sketch stroke (internal use)"; /* api callbacks */ ot->invoke = sketch_draw_preview; @@ -2687,6 +2693,7 @@ void SKETCH_OT_draw_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "Draw Stroke"; ot->idname = "SKETCH_OT_draw_stroke"; + ot->description = "Start to draw a sketch stroke"; /* api callbacks */ ot->invoke = sketch_draw_stroke; @@ -2706,6 +2713,7 @@ void SKETCH_OT_gesture(wmOperatorType *ot) /* identifiers */ ot->name = "Gesture"; ot->idname = "SKETCH_OT_gesture"; + ot->description = "Start to draw a gesture stroke"; /* api callbacks */ ot->invoke = sketch_draw_gesture; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 6573647aaee..c935cb7da82 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -173,6 +173,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) /* identifiers */ ot->name = "Free All Physics Bakes"; ot->idname = "PTCACHE_OT_free_bake_all"; + ot->description = "Free all baked caches of all objects in the current scene"; /* api callbacks */ ot->exec = ptcache_free_bake_all_exec; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1f30fe691c1..bb534d2b916 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1834,6 +1834,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) { ot->name = "Frame Offset"; ot->idname = "SCREEN_OT_frame_offset"; + ot->description = "Move current frame forward/backward by a given number"; ot->exec = frame_offset_exec; @@ -2703,6 +2704,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) /* identifiers */ ot->name = "Flip Region"; ot->idname = "SCREEN_OT_region_flip"; + ot->description = "Toggle the region's alignment (left/right or top/bottom)"; /* api callbacks */ ot->exec = region_flip_exec; @@ -2752,6 +2754,7 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) /* identifiers */ ot->name = "Flip Header Region"; ot->idname = "SCREEN_OT_header_flip"; + ot->description = "Toggle the header over/below the main window area"; /* api callbacks */ ot->exec = header_flip_exec; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 4f2433977e0..d4078fe7c33 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -255,6 +255,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) { ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */ ot->idname = "SCREEN_OT_screenshot"; + ot->description = "Capture a picture of the active area or whole Blender window"; ot->invoke = screenshot_invoke; ot->check = screenshot_check; @@ -266,7 +267,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->flag = 0; WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screenshot the whole Blender window"); } /* *************** screenshot movie job ************************* */ @@ -433,6 +434,7 @@ void SCREEN_OT_screencast(wmOperatorType *ot) { ot->name = "Make Screencast"; ot->idname = "SCREEN_OT_screencast"; + ot->description = "Capture a video of the active area or whole Blender window"; ot->invoke = WM_operator_confirm; ot->exec = screencast_exec; @@ -441,7 +443,7 @@ void SCREEN_OT_screencast(wmOperatorType *ot) ot->flag = 0; RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screencast the whole Blender window"); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9a572a24847..03817eeb6c4 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -3047,6 +3047,8 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) /* identifiers */ ot->name = "Weight from Bones"; ot->idname = "PAINT_OT_weight_from_bones"; + ot->description = "Set the weights of the groups matching the attached armature's selected bones, " + "using the distance between the vertices and the bones"; /* api callbacks */ ot->exec = weight_from_bones_exec; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index cbebbff621f..921b52d89a3 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3621,8 +3621,9 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) }; /* identifiers */ - ot->name = "Sculpt Mode"; + ot->name = "Sculpt"; ot->idname = "SCULPT_OT_brush_stroke"; + ot->description = "Sculpt a stroke into the geometry"; /* api callbacks */ ot->invoke = sculpt_brush_stroke_invoke; @@ -3668,6 +3669,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) /* identifiers */ ot->name = "Set Persistent Base"; ot->idname = "SCULPT_OT_set_persistent_base"; + ot->description = "Reset the copy of the mesh that is being sculpted on"; /* api callbacks */ ot->exec = sculpt_set_persistent_base; @@ -3746,6 +3748,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Sculpt Mode"; ot->idname = "SCULPT_OT_sculptmode_toggle"; + ot->description = "Toggle sculpt mode in 3D view"; /* api callbacks */ ot->exec = sculpt_toggle_mode; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index f9db8b5423b..a856f5f34c3 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -744,6 +744,8 @@ void UV_OT_pack_islands(wmOperatorType *ot) /* identifiers */ ot->name = "Pack Islands"; ot->idname = "UV_OT_pack_islands"; + ot->description = "Transform all islands so that they fill up the UV space as much as possible"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -784,6 +786,8 @@ void UV_OT_average_islands_scale(wmOperatorType *ot) /* identifiers */ ot->name = "Average Islands Scale"; ot->idname = "UV_OT_average_islands_scale"; + ot->description = "Average the size of separate UV islands, based on their area in 3D space"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1324,6 +1328,8 @@ void UV_OT_from_view(wmOperatorType *ot) /* identifiers */ ot->name = "Project From View"; ot->idname = "UV_OT_project_from_view"; + ot->description = "Project the UV vertices of the mesh as seen in current 3D view"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1363,6 +1369,8 @@ void UV_OT_reset(wmOperatorType *ot) /* identifiers */ ot->name = "Reset"; ot->idname = "UV_OT_reset"; + ot->description = "Reset UV projection"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1464,6 +1472,8 @@ void UV_OT_sphere_project(wmOperatorType *ot) /* identifiers */ ot->name = "Sphere Projection"; ot->idname = "UV_OT_sphere_project"; + ot->description = "Project the UV vertices of the mesh over the curved surface of a sphere"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1537,6 +1547,8 @@ void UV_OT_cylinder_project(wmOperatorType *ot) /* identifiers */ ot->name = "Cylinder Projection"; ot->idname = "UV_OT_cylinder_project"; + ot->description = "Project the UV vertices of the mesh over the curved wall of a cylinder"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1615,6 +1627,8 @@ void UV_OT_cube_project(wmOperatorType *ot) /* identifiers */ ot->name = "Cube Projection"; ot->idname = "UV_OT_cube_project"; + ot->description = "Project the UV vertices of the mesh over the six faces of a cube"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 36bacd34dfe..1a9a5ff2cb6 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1454,7 +1454,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_ static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) @@ -1488,6 +1488,7 @@ static void WM_OT_search_menu(wmOperatorType *ot) { ot->name = "Search Menu"; ot->idname = "WM_OT_search_menu"; + ot->description = "Pop-up a search menu over all available operators in current context"; ot->invoke = wm_search_menu_invoke; ot->exec = wm_search_menu_exec; @@ -3431,6 +3432,7 @@ static void WM_OT_radial_control(wmOperatorType *ot) { ot->name = "Radial Control"; ot->idname = "WM_OT_radial_control"; + ot->description = "Set some size property (like e.g. brush size) with mouse wheel"; ot->invoke = radial_control_invoke; ot->modal = radial_control_modal; From c93d7a193ab450f89664a70e0204c14531be4877 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 15:15:33 +0000 Subject: [PATCH 105/143] style cleanup: BKE_*.c files which deal with library functions --- source/blender/blenkernel/intern/action.c | 632 ++--- source/blender/blenkernel/intern/armature.c | 318 +-- source/blender/blenkernel/intern/brush.c | 689 ++--- source/blender/blenkernel/intern/camera.c | 284 +-- source/blender/blenkernel/intern/curve.c | 2356 +++++++++--------- source/blender/blenkernel/intern/font.c | 607 +++-- source/blender/blenkernel/intern/gpencil.c | 140 +- source/blender/blenkernel/intern/group.c | 184 +- source/blender/blenkernel/intern/image.c | 1255 +++++----- source/blender/blenkernel/intern/ipo.c | 838 +++---- source/blender/blenkernel/intern/lamp.c | 106 +- source/blender/blenkernel/intern/lattice.c | 432 ++-- source/blender/blenkernel/intern/material.c | 1106 ++++---- source/blender/blenkernel/intern/mball.c | 1590 ++++++------ source/blender/blenkernel/intern/mesh.c | 1063 ++++---- source/blender/blenkernel/intern/movieclip.c | 42 +- source/blender/blenkernel/intern/object.c | 1422 +++++------ source/blender/blenkernel/intern/particle.c | 1958 +++++++-------- source/blender/blenkernel/intern/scene.c | 506 ++-- source/blender/blenkernel/intern/screen.c | 156 +- source/blender/blenkernel/intern/sound.c | 126 +- source/blender/blenkernel/intern/speaker.c | 36 +- source/blender/blenkernel/intern/text.c | 1636 ++++++------ source/blender/blenkernel/intern/texture.c | 939 +++---- source/blender/blenkernel/intern/world.c | 94 +- 25 files changed, 9260 insertions(+), 9255 deletions(-) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 90cfb9a1d82..9e46d03a3ab 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -83,7 +83,7 @@ bAction *add_empty_action(const char name[]) { bAction *act; - act= BKE_libblock_alloc(&G.main->action, ID_AC, name); + act = BKE_libblock_alloc(&G.main->action, ID_AC, name); return act; } @@ -105,8 +105,8 @@ static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr) tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; if (adt->action == mlac->act) { - if (id->lib) mlac->is_lib= TRUE; - else mlac->is_local= TRUE; + if (id->lib) mlac->is_lib = TRUE; + else mlac->is_local = TRUE; } } @@ -129,25 +129,25 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) void BKE_action_make_local(bAction *act) { tMakeLocalActionContext mlac = {act, NULL, FALSE, FALSE}; - Main *bmain= G.main; + Main *bmain = G.main; - if (act->id.lib==NULL) + if (act->id.lib == NULL) return; // XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default - if ((act->id.flag & LIB_FAKEUSER) && (act->id.us<=1)) { + if ((act->id.flag & LIB_FAKEUSER) && (act->id.us <= 1)) { id_clear_lib_data(bmain, &act->id); return; } BKE_animdata_main_cb(bmain, make_localact_init_cb, &mlac); - if (mlac.is_local && mlac.is_lib==FALSE) { + if (mlac.is_local && mlac.is_lib == FALSE) { id_clear_lib_data(bmain, &act->id); } else if (mlac.is_local && mlac.is_lib) { - mlac.act_new= BKE_action_copy(act); - mlac.act_new->id.us= 0; + 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); @@ -177,7 +177,7 @@ void BKE_action_free(bAction *act) /* .................................. */ -bAction *BKE_action_copy (bAction *src) +bAction *BKE_action_copy(bAction *src) { bAction *dst = NULL; bActionGroup *dgrp, *sgrp; @@ -185,29 +185,29 @@ bAction *BKE_action_copy (bAction *src) if (src == NULL) return NULL; - dst= BKE_libblock_copy(&src->id); + dst = BKE_libblock_copy(&src->id); /* duplicate the lists of groups and markers */ BLI_duplicatelist(&dst->groups, &src->groups); BLI_duplicatelist(&dst->markers, &src->markers); /* copy F-Curves, fixing up the links as we go */ - dst->curves.first= dst->curves.last= NULL; + dst->curves.first = dst->curves.last = NULL; - for (sfcu= src->curves.first; sfcu; sfcu= sfcu->next) { + for (sfcu = src->curves.first; sfcu; sfcu = sfcu->next) { /* duplicate F-Curve */ - dfcu= copy_fcurve(sfcu); + dfcu = copy_fcurve(sfcu); BLI_addtail(&dst->curves, dfcu); /* fix group links (kindof bad list-in-list search, but this is the most reliable way) */ - for (dgrp=dst->groups.first, sgrp=src->groups.first; dgrp && sgrp; dgrp=dgrp->next, sgrp=sgrp->next) { + for (dgrp = dst->groups.first, sgrp = src->groups.first; dgrp && sgrp; dgrp = dgrp->next, sgrp = sgrp->next) { if (sfcu->grp == sgrp) { - dfcu->grp= dgrp; + dfcu->grp = dgrp; if (dgrp->channels.first == sfcu) - dgrp->channels.first= dfcu; + dgrp->channels.first = dfcu; if (dgrp->channels.last == sfcu) - dgrp->channels.last= dfcu; + dgrp->channels.last = dfcu; break; } @@ -220,12 +220,12 @@ bAction *BKE_action_copy (bAction *src) /* *************** Action Groups *************** */ /* Get the active action-group for an Action */ -bActionGroup *get_active_actiongroup (bAction *act) +bActionGroup *get_active_actiongroup(bAction *act) { - bActionGroup *agrp= NULL; + bActionGroup *agrp = NULL; if (act && act->groups.first) { - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->flag & AGRP_ACTIVE) break; } @@ -244,8 +244,8 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) return; /* Deactive all others */ - for (grp= act->groups.first; grp; grp= grp->next) { - if ((grp==agrp) && (select)) + for (grp = act->groups.first; grp; grp = grp->next) { + if ((grp == agrp) && (select)) grp->flag |= AGRP_ACTIVE; else grp->flag &= ~AGRP_ACTIVE; @@ -253,7 +253,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) } /* Add a new action group with the given name to the action */ -bActionGroup *action_groups_add_new (bAction *act, const char name[]) +bActionGroup *action_groups_add_new(bAction *act, const char name[]) { bActionGroup *agrp; @@ -303,7 +303,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) * the lists will be in sync after linking */ if (agrp->channels.last == act->curves.last) - act->curves.last= fcurve; + act->curves.last = fcurve; /* link in the given F-Curve after the last F-Curve in the group, * which means that it should be able to fit in with the rest of the @@ -320,7 +320,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) agrp->channels.first = agrp->channels.last = fcurve; /* step through the groups preceding this one, finding the F-Curve there to attach this one after */ - for (grp= agrp->prev; grp; grp= grp->prev) { + for (grp = agrp->prev; grp; grp = grp->prev) { /* if this group has F-Curves, we want weave the given one in right after the last channel there, * but via the Action's list not this group's list * - this is so that the F-Curve is in the right place in the Action, @@ -342,7 +342,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) } /* set the F-Curve's new group */ - fcurve->grp= agrp; + fcurve->grp = agrp; } /* Remove the given channel from all groups */ @@ -354,28 +354,28 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu) /* check if any group used this directly */ if (fcu->grp) { - bActionGroup *agrp= fcu->grp; + bActionGroup *agrp = fcu->grp; if (agrp->channels.first == agrp->channels.last) { if (agrp->channels.first == fcu) { - agrp->channels.first= NULL; - agrp->channels.last= NULL; + agrp->channels.first = NULL; + agrp->channels.last = NULL; } } else if (agrp->channels.first == fcu) { - if ((fcu->next) && (fcu->next->grp==agrp)) - agrp->channels.first= fcu->next; + if ((fcu->next) && (fcu->next->grp == agrp)) + agrp->channels.first = fcu->next; else - agrp->channels.first= NULL; + agrp->channels.first = NULL; } else if (agrp->channels.last == fcu) { - if ((fcu->prev) && (fcu->prev->grp==agrp)) - agrp->channels.last= fcu->prev; + if ((fcu->prev) && (fcu->prev->grp == agrp)) + agrp->channels.last = fcu->prev; else - agrp->channels.last= NULL; + agrp->channels.last = NULL; } - fcu->grp= NULL; + fcu->grp = NULL; } /* now just remove from list */ @@ -383,7 +383,7 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu) } /* Find a group with the given name */ -bActionGroup *BKE_action_group_find_name (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)) @@ -431,7 +431,7 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) return NULL; /* See if this channel exists */ - chan= BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name)); + chan = BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name)); if (chan) { return chan; } @@ -445,13 +445,13 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) unit_axis_angle(chan->rotAxis, &chan->rotAngle); chan->size[0] = chan->size[1] = chan->size[2] = 1.0f; - chan->limitmin[0]= chan->limitmin[1]= chan->limitmin[2]= -180.0f; - chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f; - chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f; + chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -180.0f; + chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = 180.0f; + chan->stiffness[0] = chan->stiffness[1] = chan->stiffness[2] = 0.0f; chan->ikrotweight = chan->iklinweight = 0.0f; unit_m4(chan->constinv); - chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */ + chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */ BLI_addtail(&pose->chanbase, chan); BKE_pose_channels_hash_free(pose); @@ -460,9 +460,9 @@ bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) } /* Find the active posechannel for an object (we can't just use pose, as layer info is in armature) */ -bPoseChannel *BKE_pose_channel_active (Object *ob) +bPoseChannel *BKE_pose_channel_active(Object *ob) { - bArmature *arm= (ob) ? ob->data : NULL; + bArmature *arm = (ob) ? ob->data : NULL; bPoseChannel *pchan; if (ELEM3(NULL, ob, ob->pose, arm)) { @@ -470,7 +470,7 @@ bPoseChannel *BKE_pose_channel_active (Object *ob) } /* find active */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer)) return pchan; } @@ -482,10 +482,10 @@ const char *BKE_pose_ikparam_get_name(bPose *pose) { if (pose) { switch (pose->iksolver) { - case IKSOLVER_LEGACY: - return NULL; - case IKSOLVER_ITASC: - return "bItasc"; + case IKSOLVER_LEGACY: + return NULL; + case IKSOLVER_ITASC: + return "bItasc"; } } return NULL; @@ -498,17 +498,17 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) ListBase listb; if (!src) { - *dst=NULL; + *dst = NULL; return; } - if (*dst==src) { + if (*dst == src) { printf("BKE_pose_copy_data source and target are the same\n"); - *dst=NULL; + *dst = NULL; return; } - outPose= MEM_callocN(sizeof(bPose), "pose"); + outPose = MEM_callocN(sizeof(bPose), "pose"); BLI_duplicatelist(&outPose->chanbase, &src->chanbase); @@ -516,16 +516,16 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) outPose->ikdata = NULL; outPose->ikparam = MEM_dupallocN(src->ikparam); - for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) { // TODO: rename this argument... if (copycon) { copy_constraints(&listb, &pchan->constraints, TRUE); // copy_constraints NULLs listb - pchan->constraints= listb; - pchan->mpath= NULL; /* motion paths should not get copied yet... */ + pchan->constraints = listb; + pchan->mpath = NULL; /* motion paths should not get copied yet... */ } if (pchan->prop) { - pchan->prop= IDP_CopyProperty(pchan->prop); + pchan->prop = IDP_CopyProperty(pchan->prop); } } @@ -533,7 +533,7 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) if (copycon) BLI_duplicatelist(&outPose->agroups, &src->agroups); - *dst=outPose; + *dst = outPose; } void BKE_pose_itasc_init(bItasc *itasc) @@ -545,7 +545,7 @@ void BKE_pose_itasc_init(bItasc *itasc) itasc->numiter = 100; itasc->numstep = 4; itasc->precision = 0.005f; - itasc->flag = ITASC_AUTO_STEP|ITASC_INITIAL_REITERATION; + itasc->flag = ITASC_AUTO_STEP | ITASC_INITIAL_REITERATION; itasc->feedback = 20.0f; itasc->maxvel = 50.0f; itasc->solver = ITASC_SOLVER_SDLS; @@ -557,15 +557,15 @@ void BKE_pose_ikparam_init(bPose *pose) { bItasc *itasc; switch (pose->iksolver) { - case IKSOLVER_ITASC: - itasc = MEM_callocN(sizeof(bItasc), "itasc"); - BKE_pose_itasc_init(itasc); - pose->ikparam = itasc; - break; - case IKSOLVER_LEGACY: - default: - pose->ikparam = NULL; - break; + case IKSOLVER_ITASC: + itasc = MEM_callocN(sizeof(bItasc), "itasc"); + BKE_pose_itasc_init(itasc); + pose->ikparam = itasc; + break; + case IKSOLVER_LEGACY: + default: + pose->ikparam = NULL; + break; } } @@ -574,8 +574,8 @@ void BKE_pose_channels_hash_make(bPose *pose) if (!pose->chanhash) { bPoseChannel *pchan; - pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); - for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) + pose->chanhash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) BLI_ghash_insert(pose->chanhash, pchan->name, pchan); } } @@ -584,7 +584,7 @@ void BKE_pose_channels_hash_free(bPose *pose) { if (pose->chanhash) { BLI_ghash_free(pose->chanhash, NULL, NULL); - pose->chanhash= NULL; + pose->chanhash = NULL; } } @@ -594,7 +594,7 @@ void BKE_pose_channel_free(bPoseChannel *pchan) if (pchan->mpath) { animviz_free_motionpath(pchan->mpath); - pchan->mpath= NULL; + pchan->mpath = NULL; } free_constraints(&pchan->constraints); @@ -610,7 +610,7 @@ void BKE_pose_channels_free(bPose *pose) bPoseChannel *pchan; if (pose->chanbase.first) { - for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) BKE_pose_channel_free(pchan); BLI_freelistN(&pose->chanbase); @@ -649,17 +649,17 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan copy_v3_v3(pchan->size, chan->size); copy_v3_v3(pchan->eul, chan->eul); copy_v3_v3(pchan->rotAxis, chan->rotAxis); - pchan->rotAngle= chan->rotAngle; + pchan->rotAngle = chan->rotAngle; copy_qt_qt(pchan->quat, chan->quat); - pchan->rotmode= chan->rotmode; + pchan->rotmode = chan->rotmode; copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat); copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat); - pchan->flag= chan->flag; + pchan->flag = chan->flag; - con= chan->constraints.first; - for (pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) { - pcon->enforce= con->enforce; - pcon->headtail= con->headtail; + con = chan->constraints.first; + for (pcon = pchan->constraints.first; pcon && con; pcon = pcon->next, con = con->next) { + pcon->enforce = con->enforce; + pcon->headtail = con->headtail; } } @@ -675,16 +675,16 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f pchan->rotmode = pchan_from->rotmode; /* copy bone group */ - pchan->agrp_index= pchan_from->agrp_index; + pchan->agrp_index = pchan_from->agrp_index; /* ik (dof) settings */ pchan->ikflag = pchan_from->ikflag; copy_v3_v3(pchan->limitmin, pchan_from->limitmin); copy_v3_v3(pchan->limitmax, pchan_from->limitmax); copy_v3_v3(pchan->stiffness, pchan_from->stiffness); - pchan->ikstretch= pchan_from->ikstretch; - pchan->ikrotweight= pchan_from->ikrotweight; - pchan->iklinweight= pchan_from->iklinweight; + pchan->ikstretch = pchan_from->ikstretch; + pchan->ikrotweight = pchan_from->ikrotweight; + pchan->iklinweight = pchan_from->iklinweight; /* constraints */ copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE); @@ -694,14 +694,14 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f /* unlikely but possible it exists */ IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); - pchan->prop= NULL; + pchan->prop = NULL; } if (pchan_from->prop) { - pchan->prop= IDP_CopyProperty(pchan_from->prop); + pchan->prop = IDP_CopyProperty(pchan_from->prop); } /* custom shape */ - pchan->custom= pchan_from->custom; + pchan->custom = pchan_from->custom; } @@ -715,39 +715,39 @@ void BKE_pose_update_constraint_flags(bPose *pose) bConstraint *con; /* clear */ - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { - pchan->constflag= 0; + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + pchan->constflag = 0; } pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND; /* detect */ - for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data = (bKinematicConstraint*)con->data; + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = (bKinematicConstraint *)con->data; pchan->constflag |= PCHAN_HAS_IK; - if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)) + if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) pchan->constflag |= PCHAN_HAS_TARGET; /* negative rootbone = recalc rootbone index. used in do_versions */ - if (data->rootbone<0) { - data->rootbone= 0; + if (data->rootbone < 0) { + data->rootbone = 0; - if (data->flag & CONSTRAINT_IK_TIP) parchan= pchan; - else parchan= pchan->parent; + if (data->flag & CONSTRAINT_IK_TIP) parchan = pchan; + else parchan = pchan->parent; while (parchan) { data->rootbone++; - if ((parchan->bone->flag & BONE_CONNECTED)==0) + if ((parchan->bone->flag & BONE_CONNECTED) == 0) break; - parchan= parchan->parent; + parchan = parchan->parent; } } } else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { - bFollowPathConstraint *data= (bFollowPathConstraint *)con->data; + bFollowPathConstraint *data = (bFollowPathConstraint *)con->data; /* for drawing constraint colors when color set allows this */ pchan->constflag |= PCHAN_HAS_CONST; @@ -755,7 +755,7 @@ void BKE_pose_update_constraint_flags(bPose *pose) /* if we have a valid target, make sure that this will get updated on frame-change * (needed for when there is no anim-data for this pose) */ - if ((data->tar) && (data->tar->type==OB_CURVE)) + if ((data->tar) && (data->tar->type == OB_CURVE)) pose->flag |= POSE_CONSTRAINTS_TIMEDEPEND; } else if (con->type == CONSTRAINT_TYPE_SPLINEIK) @@ -778,10 +778,10 @@ void framechange_poses_clear_unkeyed(void) /* This needs to be done for each object that has a pose */ // TODO: proxies may/may not be correctly handled here... (this needs checking) - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* we only need to do this on objects with a pose */ - if ( (pose= ob->pose) ) { - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + if ( (pose = ob->pose) ) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone) pchan->bone->flag &= ~BONE_UNKEYED; } @@ -794,24 +794,24 @@ void framechange_poses_clear_unkeyed(void) /* Adds a new bone-group */ void BKE_pose_add_group(Object *ob) { - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bActionGroup *grp; if (ELEM(NULL, ob, ob->pose)) return; - grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup"); + grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup"); BLI_strncpy(grp->name, "Group", sizeof(grp->name)); BLI_addtail(&pose->agroups, grp); BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); - pose->active_group= BLI_countlist(&pose->agroups); + pose->active_group = BLI_countlist(&pose->agroups); } /* Remove the active bone-group */ void BKE_pose_remove_group(Object *ob) { - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bActionGroup *grp = NULL; bPoseChannel *pchan; @@ -822,15 +822,15 @@ void BKE_pose_remove_group(Object *ob) return; /* get group to remove */ - grp= BLI_findlink(&pose->agroups, pose->active_group-1); + grp = BLI_findlink(&pose->agroups, pose->active_group - 1); if (grp) { /* adjust group references (the trouble of using indices!): * - firstly, make sure nothing references it * - also, make sure that those after this item get corrected */ - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->agrp_index == pose->active_group) - pchan->agrp_index= 0; + pchan->agrp_index = 0; else if (pchan->agrp_index > pose->active_group) pchan->agrp_index--; } @@ -839,7 +839,7 @@ void BKE_pose_remove_group(Object *ob) BLI_freelinkN(&pose->agroups, grp); pose->active_group--; if (pose->active_group < 0 || pose->agroups.first == NULL) { - pose->active_group= 0; + pose->active_group = 0; } } } @@ -853,7 +853,7 @@ short action_has_motion(const bAction *act) /* return on the first F-Curve that has some keyframes/samples defined */ if (act) { - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { if (fcu->totvert) return 1; } @@ -867,11 +867,11 @@ short action_has_motion(const bAction *act) void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers) { FCurve *fcu; - float min=999999999.0f, max=-999999999.0f; - short foundvert=0, foundmod=0; + float min = 999999999.0f, max = -999999999.0f; + short foundvert = 0, foundmod = 0; if (act) { - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { /* if curve has keyframes, consider them first */ if (fcu->totvert) { float nmin, nmax; @@ -881,65 +881,65 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE); /* compare to the running tally */ - min= MIN2(min, nmin); - max= MAX2(max, nmax); + min = MIN2(min, nmin); + max = MAX2(max, nmax); - foundvert= 1; + foundvert = 1; } /* if incl_modifiers is enabled, need to consider modifiers too * - only really care about the last modifier */ if ((incl_modifiers) && (fcu->modifiers.last)) { - FModifier *fcm= fcu->modifiers.last; + FModifier *fcm = fcu->modifiers.last; /* only use the maximum sensible limits of the modifiers if they are more extreme */ switch (fcm->type) { case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */ { - FMod_Limits *fmd= (FMod_Limits *)fcm->data; + FMod_Limits *fmd = (FMod_Limits *)fcm->data; if (fmd->flag & FCM_LIMIT_XMIN) { - min= MIN2(min, fmd->rect.xmin); + min = MIN2(min, fmd->rect.xmin); } if (fmd->flag & FCM_LIMIT_XMAX) { - max= MAX2(max, fmd->rect.xmax); + max = MAX2(max, fmd->rect.xmax); } } - break; + break; case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */ { - FMod_Cycles *fmd= (FMod_Cycles *)fcm->data; + FMod_Cycles *fmd = (FMod_Cycles *)fcm->data; if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) - min= MINAFRAMEF; + min = MINAFRAMEF; if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) - max= MAXFRAMEF; + max = MAXFRAMEF; } - break; + break; // TODO: function modifier may need some special limits default: /* all other standard modifiers are on the infinite range... */ - min= MINAFRAMEF; - max= MAXFRAMEF; + min = MINAFRAMEF; + max = MAXFRAMEF; break; } - foundmod= 1; + foundmod = 1; } } } if (foundvert || foundmod) { - if (min==max) max+= 1.0f; - *start= min; - *end= max; + if (min == max) max += 1.0f; + *start = min; + *end = max; } else { - *start= 0.0f; - *end= 1.0f; + *start = 0.0f; + *end = 1.0f; } } @@ -950,8 +950,8 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, { PointerRNA ptr; FCurve *fcu; - char *basePath=NULL; - short flags=0; + char *basePath = NULL; + short flags = 0; /* build PointerRNA from provided data to obtain the paths to use */ if (pchan) @@ -962,15 +962,15 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, return 0; /* get the basic path to the properties of interest */ - basePath= RNA_path_from_ID_to_struct(&ptr); + basePath = RNA_path_from_ID_to_struct(&ptr); if (basePath == NULL) return 0; /* search F-Curves for the given properties * - we cannot use the groups, since they may not be grouped in that way... */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { - char *bPtr=NULL, *pPtr=NULL; + for (fcu = act->curves.first; fcu; fcu = fcu->next) { + char *bPtr = NULL, *pPtr = NULL; /* if enough flags have been found, we can stop checking unless we're also getting the curves */ if ((flags == ACT_TRANS_ALL) && (curves == NULL)) @@ -981,7 +981,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, continue; /* step 1: check for matching base path */ - bPtr= strstr(fcu->rna_path, basePath); + bPtr = strstr(fcu->rna_path, basePath); if (bPtr) { /* we must add len(basePath) bytes to the match so that we are at the end of the @@ -991,13 +991,13 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, /* step 2: check for some property with transforms * - to speed things up, only check for the ones not yet found - * unless we're getting the curves too + * unless we're getting the curves too * - if we're getting the curves, the BLI_genericNodeN() creates a LinkData * node wrapping the F-Curve, which then gets added to the list * - once a match has been found, the curve cannot possibly be any other one */ if ((curves) || (flags & ACT_TRANS_LOC) == 0) { - pPtr= strstr(bPtr, "location"); + pPtr = strstr(bPtr, "location"); if (pPtr) { flags |= ACT_TRANS_LOC; @@ -1008,7 +1008,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, } if ((curves) || (flags & ACT_TRANS_SCALE) == 0) { - pPtr= strstr(bPtr, "scale"); + pPtr = strstr(bPtr, "scale"); if (pPtr) { flags |= ACT_TRANS_SCALE; @@ -1019,7 +1019,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, } if ((curves) || (flags & ACT_TRANS_ROT) == 0) { - pPtr= strstr(bPtr, "rotation"); + pPtr = strstr(bPtr, "rotation"); if (pPtr) { flags |= ACT_TRANS_ROT; @@ -1031,7 +1031,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, if ((curves) || (flags & ACT_TRANS_PROP) == 0) { /* custom properties only */ - pPtr= strstr(bPtr, "[\""); /* extra '"' comment here to keep my texteditor functionlist working :) */ + pPtr = strstr(bPtr, "[\""); /* extra '"' comment here to keep my texteditor functionlist working :) */ if (pPtr) { flags |= ACT_TRANS_PROP; @@ -1059,14 +1059,14 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, void extract_pose_from_pose(bPose *pose, const bPose *src) { const bPoseChannel *schan; - bPoseChannel *pchan= pose->chanbase.first; + bPoseChannel *pchan = pose->chanbase.first; - if (pose==src) { + if (pose == src) { printf("extract_pose_from_pose source and target are the same\n"); return; } - for (schan=src->chanbase.first; (schan && pchan); schan=schan->next, pchan= pchan->next) { + for (schan = src->chanbase.first; (schan && pchan); schan = schan->next, pchan = pchan->next) { copy_pose_channel_data(pchan, schan); } } @@ -1082,14 +1082,14 @@ void BKE_pose_rest(bPose *pose) memset(pose->stride_offset, 0, sizeof(pose->stride_offset)); memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset)); - for (pchan=pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { zero_v3(pchan->loc); zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); - pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f; + pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; - pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); + pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); } } @@ -1098,19 +1098,19 @@ void BKE_pose_copy_result(bPose *to, bPose *from) { bPoseChannel *pchanto, *pchanfrom; - if (to==NULL || from==NULL) { + if (to == NULL || from == NULL) { printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); // debug temp return; } - if (to==from) { + if (to == from) { printf("BKE_pose_copy_result source and target are the same\n"); return; } - for (pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) { - pchanto= BKE_pose_channel_find_name(to, pchanfrom->name); + for (pchanfrom = from->chanbase.first; pchanfrom; pchanfrom = pchanfrom->next) { + 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); @@ -1124,9 +1124,9 @@ void BKE_pose_copy_result(bPose *to, bPose *from) copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head); copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail); - pchanto->rotmode= pchanfrom->rotmode; - pchanto->flag= pchanfrom->flag; - pchanto->protectflag= pchanfrom->protectflag; + pchanto->rotmode = pchanfrom->rotmode; + pchanto->flag = pchanfrom->flag; + pchanto->protectflag = pchanfrom->protectflag; } } } @@ -1136,7 +1136,7 @@ void BKE_pose_copy_result(bPose *to, bPose *from) */ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { - bActionGroup *agrp= BKE_action_group_find_name(act, groupname); + bActionGroup *agrp = BKE_action_group_find_name(act, groupname); /* clear workob */ BKE_object_workob_clear(workob); @@ -1145,22 +1145,22 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c copy_m4_m4(workob->obmat, ob->obmat); copy_m4_m4(workob->parentinv, ob->parentinv); copy_m4_m4(workob->constinv, ob->constinv); - workob->parent= ob->parent; + workob->parent = ob->parent; - workob->rotmode= ob->rotmode; + workob->rotmode = ob->rotmode; - workob->trackflag= ob->trackflag; - workob->upflag= ob->upflag; + workob->trackflag = ob->trackflag; + workob->upflag = ob->upflag; - workob->partype= ob->partype; - workob->par1= ob->par1; - workob->par2= ob->par2; - workob->par3= ob->par3; + workob->partype = ob->partype; + workob->par1 = ob->par1; + workob->par2 = ob->par2; + workob->par3 = ob->par3; workob->constraints.first = ob->constraints.first; workob->constraints.last = ob->constraints.last; - workob->pose= pose; /* need to set pose too, since this is used for both types of Action Constraint */ + workob->pose = pose; /* need to set pose too, since this is used for both types of Action Constraint */ BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); BLI_strncpy(workob->id.name, "OB", sizeof(workob->id.name)); /* we don't use real object name, otherwise RNA screws with the real thing */ @@ -1177,13 +1177,13 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe); } else { - AnimData adt= {NULL}; + AnimData adt = {NULL}; /* init animdata, and attach to workob */ - workob->adt= &adt; + workob->adt = &adt; - adt.recalc= ADT_RECALC_ANIM; - adt.action= act; + adt.recalc = ADT_RECALC_ANIM; + adt.action = act; /* execute effects of Action on to workob (or it's PoseChannels) */ BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM); @@ -1207,7 +1207,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo case ACTSTRIPMODE_ADD: dstweight = 1.0F; break; - default : + default: dstweight = 1.0F; } @@ -1238,30 +1238,30 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, /* matching offset bones */ /* take dst offset, and put src on on that location */ - if (strip->offs_bone[0]==0) + if (strip->offs_bone[0] == 0) return; /* are we also blending with matching bones? */ - if (strip->prev && strip->start>=strip->prev->start) { - bPoseChannel *dpchan= BKE_pose_channel_find_name(dst, strip->offs_bone); + if (strip->prev && strip->start >= strip->prev->start) { + bPoseChannel *dpchan = BKE_pose_channel_find_name(dst, strip->offs_bone); if (dpchan) { - bPoseChannel *spchan= BKE_pose_channel_find_name(src, strip->offs_bone); + bPoseChannel *spchan = BKE_pose_channel_find_name(src, strip->offs_bone); if (spchan) { float vec[3]; /* dst->ctime has the internal strip->prev action time */ /* map this time to nla time */ - float ctime= get_actionstrip_frame(strip, src->ctime, 1); + float ctime = get_actionstrip_frame(strip, src->ctime, 1); - if ( ctime > strip->prev->end) { + if (ctime > strip->prev->end) { bActionChannel *achan; /* add src to dest, minus the position of src on strip->prev->end */ - ctime= get_actionstrip_frame(strip, strip->prev->end, 0); + ctime = get_actionstrip_frame(strip, strip->prev->end, 0); - achan= get_action_channel(strip->act, strip->offs_bone); + achan = get_action_channel(strip->act, strip->offs_bone); if (achan && achan->ipo) { bPoseChannel pchan; /* Evaluates and sets the internal ipo value */ @@ -1298,63 +1298,63 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, */ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip, Path *path, float pathdist, float *stride_offset) { - bAction *act= strip->act; - const char *name= strip->stridechannel; - bActionChannel *achan= get_action_channel(act, name); - int stride_axis= strip->stride_axis; + bAction *act = strip->act; + const char *name = strip->stridechannel; + bActionChannel *achan = get_action_channel(act, name); + int stride_axis = strip->stride_axis; if (achan && achan->ipo) { - IpoCurve *icu= NULL; - float minx=0.0f, maxx=0.0f, miny=0.0f, maxy=0.0f; - int foundvert= 0; - - if (stride_axis==0) stride_axis= AC_LOC_X; - else if (stride_axis==1) stride_axis= AC_LOC_Y; - else stride_axis= AC_LOC_Z; + IpoCurve *icu = NULL; + float minx = 0.0f, maxx = 0.0f, miny = 0.0f, maxy = 0.0f; + int foundvert = 0; + + if (stride_axis == 0) stride_axis = AC_LOC_X; + else if (stride_axis == 1) stride_axis = AC_LOC_Y; + else stride_axis = AC_LOC_Z; /* calculate the min/max */ - for (icu=achan->ipo->curve.first; icu; icu=icu->next) { - if (icu->adrcode==stride_axis) { - if (icu->totvert>1) { - foundvert= 1; - minx= icu->bezt[0].vec[1][0]; - maxx= icu->bezt[icu->totvert-1].vec[1][0]; + for (icu = achan->ipo->curve.first; icu; icu = icu->next) { + if (icu->adrcode == stride_axis) { + if (icu->totvert > 1) { + foundvert = 1; + minx = icu->bezt[0].vec[1][0]; + maxx = icu->bezt[icu->totvert - 1].vec[1][0]; - miny= icu->bezt[0].vec[1][1]; - maxy= icu->bezt[icu->totvert-1].vec[1][1]; + miny = icu->bezt[0].vec[1][1]; + maxy = icu->bezt[icu->totvert - 1].vec[1][1]; } break; } } - if (foundvert && miny!=maxy) { - float stridelen= sizecorr*fabs(maxy-miny), striptime; + if (foundvert && miny != maxy) { + float stridelen = sizecorr * fabs(maxy - miny), striptime; float actiondist, pdist, pdistNewNormalized, offs; float vec1[4], vec2[4], dir[3]; /* internal cycling, actoffs is in frames */ - offs= stridelen*strip->actoffs/(maxx-minx); + offs = stridelen * strip->actoffs / (maxx - minx); /* amount path moves object */ - pdist = (float)fmod (pathdist+offs, stridelen); - striptime= pdist/stridelen; + pdist = (float)fmod(pathdist + offs, stridelen); + striptime = pdist / stridelen; /* amount stride bone moves */ - actiondist= sizecorr*eval_icu(icu, minx + striptime*(maxx-minx)) - miny; + actiondist = sizecorr * eval_icu(icu, minx + striptime * (maxx - minx)) - miny; pdist = fabs(actiondist) - pdist; - pdistNewNormalized = (pathdist+pdist)/path->totdist; + pdistNewNormalized = (pathdist + pdist) / path->totdist; /* now we need to go pdist further (or less) on cu path */ - where_on_path(ob, (pathdist)/path->totdist, vec1, dir); /* vec needs size 4 */ + where_on_path(ob, (pathdist) / path->totdist, vec1, dir); /* vec needs size 4 */ if (pdistNewNormalized <= 1) { // search for correction in positive path-direction - where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ + where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ sub_v3_v3v3(stride_offset, vec2, vec1); } else { // we reached the end of the path, search backwards instead - where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */ + where_on_path(ob, (pathdist - pdist) / path->totdist, vec2, dir); /* vec needs size 4 */ sub_v3_v3v3(stride_offset, vec1, vec2); } mul_mat3_m4_v3(ob->obmat, stride_offset); @@ -1368,52 +1368,52 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float { /* only called when strip has cyclic, so >= 1.0f works... */ if (time >= 1.0f) { - bActionChannel *achan= get_action_channel(strip->act, strip->offs_bone); + bActionChannel *achan = get_action_channel(strip->act, strip->offs_bone); if (achan && achan->ipo) { - IpoCurve *icu= NULL; + IpoCurve *icu = NULL; Bone *bone; - float min[3]={0.0f, 0.0f, 0.0f}, max[3]={0.0f, 0.0f, 0.0f}; - int index=0, foundvert= 0; + float min[3] = {0.0f, 0.0f, 0.0f}, max[3] = {0.0f, 0.0f, 0.0f}; + int index = 0, foundvert = 0; /* calculate the min/max */ - for (icu=achan->ipo->curve.first; icu; icu=icu->next) { - if (icu->totvert>1) { + for (icu = achan->ipo->curve.first; icu; icu = icu->next) { + if (icu->totvert > 1) { - if (icu->adrcode==AC_LOC_X) - index= 0; - else if (icu->adrcode==AC_LOC_Y) - index= 1; - else if (icu->adrcode==AC_LOC_Z) - index= 2; + if (icu->adrcode == AC_LOC_X) + index = 0; + else if (icu->adrcode == AC_LOC_Y) + index = 1; + else if (icu->adrcode == AC_LOC_Z) + index = 2; else continue; - foundvert= 1; - min[index]= icu->bezt[0].vec[1][1]; - max[index]= icu->bezt[icu->totvert-1].vec[1][1]; + foundvert = 1; + min[index] = icu->bezt[0].vec[1][1]; + max[index] = icu->bezt[icu->totvert - 1].vec[1][1]; } } if (foundvert) { /* bring it into armature space */ sub_v3_v3v3(min, max, min); - bone= BKE_armature_find_bone_name(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 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]; - if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2]= time*min[2]; + 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]; + if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2] = time * min[2]; } else { - if ( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2])) - pose->cyclic_offset[0]= time*min[0]; - else if ( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2])) - pose->cyclic_offset[1]= time*min[1]; + if (fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2])) + pose->cyclic_offset[0] = time * min[0]; + else if (fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2])) + pose->cyclic_offset[1] = time * min[1]; else - pose->cyclic_offset[2]= time*min[2]; + pose->cyclic_offset[2] = time * min[2]; } } } @@ -1427,13 +1427,13 @@ static Object *get_parent_path(Object *ob) { bConstraint *con; - if (ob->parent && ob->parent->type==OB_CURVE) + if (ob->parent && ob->parent->type == OB_CURVE) return ob->parent; - for (con = ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) { - if (con->enforce>0.5f) { - bFollowPathConstraint *data= con->data; + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { + if (con->enforce > 0.5f) { + bFollowPathConstraint *data = con->data; return data->tar; } } @@ -1447,71 +1447,71 @@ static Object *get_parent_path(Object *ob) static void do_nla(Scene *scene, Object *ob, int blocktype) { - bPose *tpose= NULL; - Key *key= NULL; - ListBase tchanbase={NULL, NULL}, chanbase={NULL, NULL}; - bActionStrip *strip, *striplast=NULL, *stripfirst=NULL; + bPose *tpose = NULL; + Key *key = NULL; + ListBase tchanbase = {NULL, NULL}, chanbase = {NULL, NULL}; + bActionStrip *strip, *striplast = NULL, *stripfirst = NULL; float striptime, frametime, length, actlength; float blendfac, stripframe; - float scene_cfra= BKE_scene_frame_get(scene); - int doit, dostride; + float scene_cfra = BKE_scene_frame_get(scene); + int doit, dostride; - if (blocktype==ID_AR) { + if (blocktype == ID_AR) { BKE_pose_copy_data(&tpose, ob->pose, 1); - BKE_pose_rest(ob->pose); // potentially destroying current not-keyed pose + BKE_pose_rest(ob->pose); // potentially destroying current not-keyed pose } else { - key= ob_get_key(ob); + key = ob_get_key(ob); } /* check on extend to left or right, when no strip is hit by 'cfra' */ - for (strip=ob->nlastrips.first; strip; strip=strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { /* escape loop on a hit */ - if ( scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */ + if (scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */ break; if (scene_cfra < strip->start) { - if (stripfirst==NULL) - stripfirst= strip; + if (stripfirst == NULL) + stripfirst = strip; else if (stripfirst->start > strip->start) - stripfirst= strip; + stripfirst = strip; } else if (scene_cfra > strip->end) { - if (striplast==NULL) - striplast= strip; + if (striplast == NULL) + striplast = strip; else if (striplast->end < strip->end) - striplast= strip; + striplast = strip; } } - if (strip==NULL) { /* extend */ + if (strip == NULL) { /* extend */ if (striplast) - scene_cfra= striplast->end; + scene_cfra = striplast->end; else if (stripfirst) - scene_cfra= stripfirst->start; + scene_cfra = stripfirst->start; } /* and now go over all strips */ - for (strip=ob->nlastrips.first; strip; strip=strip->next) { - doit=dostride= 0; + for (strip = ob->nlastrips.first; strip; strip = strip->next) { + doit = dostride = 0; - if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */ + if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */ /* Determine if the current frame is within the strip's range */ - length = strip->end-strip->start; - actlength = strip->actend-strip->actstart; + length = strip->end - strip->start; + actlength = strip->actend - strip->actstart; striptime = (scene_cfra - strip->start) / length; stripframe = (scene_cfra - strip->start); - if (striptime>=0.0) { + if (striptime >= 0.0) { - if (blocktype==ID_AR) + if (blocktype == ID_AR) 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) { + if (striptime < 1.0f + 0.1f / length) { /* Handle path */ - if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype==ID_AR) && (ob->ipoflag & OB_DISABLE_PATH)==0) { - Object *parent= get_parent_path(ob); + if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype == ID_AR) && (ob->ipoflag & OB_DISABLE_PATH) == 0) { + Object *parent = get_parent_path(ob); if (parent) { Curve *cu = parent->data; @@ -1519,43 +1519,43 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (cu->flag & CU_PATH) { /* Ensure we have a valid path */ - if (cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0); + if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(scene, parent, 0); if (cu->path) { /* Find the position on the path */ - ctime= bsystem_time(scene, ob, scene_cfra, 0.0); + ctime = bsystem_time(scene, ob, scene_cfra, 0.0); - if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) { + if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime) == 0) { /* correct for actions not starting on zero */ - ctime= (ctime - strip->actstart)/cu->pathlen; + ctime = (ctime - strip->actstart) / cu->pathlen; CLAMP(ctime, 0.0, 1.0); } - pdist = ctime*cu->path->totdist; + pdist = ctime * cu->path->totdist; if (tpose && strip->stridechannel[0]) { - striptime= stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset); + striptime = stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset); } else { if (strip->stridelen) { striptime = pdist / strip->stridelen; - striptime = (float)fmod (striptime+strip->actoffs, 1.0); + striptime = (float)fmod(striptime + strip->actoffs, 1.0); } else striptime = 0; } frametime = (striptime * actlength) + strip->actstart; - frametime= bsystem_time(scene, ob, frametime, 0.0); + frametime = bsystem_time(scene, ob, frametime, 0.0); - if (blocktype==ID_AR) { - extract_pose_from_action (tpose, strip->act, frametime); + if (blocktype == ID_AR) { + extract_pose_from_action(tpose, strip->act, frametime); } - else if (blocktype==ID_OB) { + else if (blocktype == ID_OB) { extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); if (key) extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); } - doit=dostride= 1; + doit = dostride = 1; } } } @@ -1564,29 +1564,29 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) else { /* Mod to repeat */ - if (strip->repeat!=1.0f) { - float cycle= striptime*strip->repeat; + if (strip->repeat != 1.0f) { + float cycle = striptime * strip->repeat; - striptime = (float)fmod (cycle, 1.0f + 0.1f/length); - cycle-= striptime; + striptime = (float)fmod(cycle, 1.0f + 0.1f / length); + cycle -= striptime; - if (blocktype==ID_AR) + if (blocktype == ID_AR) cyclic_offs_bone(ob, tpose, strip, cycle); } frametime = (striptime * actlength) + strip->actstart; - frametime= nla_time(scene, frametime, (float)strip->repeat); + frametime = nla_time(scene, frametime, (float)strip->repeat); - if (blocktype==ID_AR) { - extract_pose_from_action (tpose, strip->act, frametime); + if (blocktype == ID_AR) { + extract_pose_from_action(tpose, strip->act, frametime); } - else if (blocktype==ID_OB) { + else if (blocktype == ID_OB) { extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); if (key) extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); } - doit=1; + doit = 1; } } /* Handle extend */ @@ -1594,25 +1594,25 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (strip->flag & ACTSTRIP_HOLDLASTFRAME) { /* we want the strip to hold on the exact fraction of the repeat value */ - frametime = actlength * (strip->repeat-(int)strip->repeat); - if (frametime<=0.000001f) frametime= actlength; /* rounding errors... */ - frametime= bsystem_time(scene, ob, frametime+strip->actstart, 0.0); - - if (blocktype==ID_AR) - extract_pose_from_action (tpose, strip->act, frametime); - else if (blocktype==ID_OB) { + frametime = actlength * (strip->repeat - (int)strip->repeat); + if (frametime <= 0.000001f) frametime = actlength; /* rounding errors... */ + frametime = bsystem_time(scene, ob, frametime + strip->actstart, 0.0); + + if (blocktype == ID_AR) + extract_pose_from_action(tpose, strip->act, frametime); + else if (blocktype == ID_OB) { extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); if (key) extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); } /* handle cycle hold */ - if (strip->repeat!=1.0f) { - if (blocktype==ID_AR) - cyclic_offs_bone(ob, tpose, strip, strip->repeat-1.0f); + if (strip->repeat != 1.0f) { + if (blocktype == ID_AR) + cyclic_offs_bone(ob, tpose, strip, strip->repeat - 1.0f); } - doit=1; + doit = 1; } } @@ -1620,22 +1620,22 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (doit) { /* Handle blendin */ - if (strip->blendin>0.0 && stripframe<=strip->blendin && scene_cfra>=strip->start) { - blendfac = stripframe/strip->blendin; + if (strip->blendin > 0.0 && stripframe <= strip->blendin && scene_cfra >= strip->start) { + blendfac = stripframe / strip->blendin; } - else if (strip->blendout>0.0 && stripframe>=(length-strip->blendout) && scene_cfra<=strip->end) { - blendfac = (length-stripframe)/(strip->blendout); + else if (strip->blendout > 0.0 && stripframe >= (length - strip->blendout) && scene_cfra <= strip->end) { + blendfac = (length - stripframe) / (strip->blendout); } else blendfac = 1; - if (blocktype==ID_AR) {/* Blend this pose with the accumulated pose */ + if (blocktype == ID_AR) { /* Blend this pose with the accumulated pose */ /* offset bone, for matching cycles */ - blend_pose_offset_bone (strip, ob->pose, tpose, blendfac, strip->mode); + blend_pose_offset_bone(strip, ob->pose, tpose, blendfac, strip->mode); - blend_poses (ob->pose, tpose, blendfac, strip->mode); + blend_poses(ob->pose, tpose, blendfac, strip->mode); if (dostride) - blend_pose_strides (ob->pose, tpose, blendfac, strip->mode); + blend_pose_strides(ob->pose, tpose, blendfac, strip->mode); } else { blend_ipochannels(&chanbase, &tchanbase, blendfac, strip->mode); @@ -1646,10 +1646,10 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) } } - if (blocktype==ID_OB) { + if (blocktype == ID_OB) { execute_ipochannels(&chanbase); } - else if (blocktype==ID_AR) { + else if (blocktype == ID_AR) { /* apply stride offset to object */ add_v3_v3(ob->obmat[3], ob->pose->stride_offset); } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 814e9d53503..59ac1604e29 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -79,8 +79,8 @@ bArmature *BKE_armature_add(const char *name) { bArmature *arm; - arm = BKE_libblock_alloc (&G.main->armature, ID_AR, name); - arm->deformflag = ARM_DEF_VGROUP|ARM_DEF_ENVELOPE; + 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; return arm; @@ -179,7 +179,7 @@ void BKE_armature_make_local(bArmature *arm) } } -static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, Bone **newActBone) +static void copy_bonechildren(Bone *newBone, Bone *oldBone, Bone *actBone, Bone **newActBone) { Bone *curBone, *newChildBone; @@ -205,7 +205,7 @@ bArmature *BKE_armature_copy(bArmature *arm) { bArmature *newArm; Bone *oldBone, *newBone; - Bone *newActBone= NULL; + Bone *newActBone = NULL; newArm = BKE_libblock_copy(&arm->id); BLI_duplicatelist(&newArm->bonebase, &arm->bonebase); @@ -340,27 +340,27 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a while (change) { /* remove extensions */ change = 0; - if (len > 2 && basename[len-2] == '.') { - if (basename[len-1] == 'L' || basename[len-1] == 'R') { /* L R */ - basename[len-2] = '\0'; + if (len > 2 && basename[len - 2] == '.') { + if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */ + basename[len - 2] = '\0'; len -= 2; change = 1; } } - else if (len > 3 && basename[len-3] == '.') { - if ((basename[len-2] == 'F' && basename[len-1] == 'r') || /* Fr */ - (basename[len-2] == 'B' && basename[len-1] == 'k')) /* Bk */ + else if (len > 3 && basename[len - 3] == '.') { + if ((basename[len - 2] == 'F' && basename[len - 1] == 'r') || /* Fr */ + (basename[len - 2] == 'B' && basename[len - 1] == 'k')) /* Bk */ { - basename[len-3] = '\0'; + basename[len - 3] = '\0'; len -= 3; change = 1; } } - else if (len > 4 && basename[len-4] == '.') { - if ((basename[len-3] == 'T' && basename[len-2] == 'o' && basename[len-1] == 'p') || /* Top */ - (basename[len-3] == 'B' && basename[len-2] == 'o' && basename[len-1] == 't')) /* Bot */ + else if (len > 4 && basename[len - 4] == '.') { + if ((basename[len - 3] == 'T' && basename[len - 2] == 'o' && basename[len - 1] == 'p') || /* Top */ + (basename[len - 3] == 'B' && basename[len - 2] == 'o' && basename[len - 1] == 't')) /* Bot */ { - basename[len-4] = '\0'; + basename[len - 4] = '\0'; len -= 4; change = 1; } @@ -368,7 +368,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a } if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */ - strncpy(name, basename, len-strlen(extension)); + strncpy(name, basename, len - strlen(extension)); } BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension); @@ -382,44 +382,44 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a /* ************* B-Bone support ******************* */ -#define MAX_BBONE_SUBDIV 32 +#define MAX_BBONE_SUBDIV 32 /* data has MAX_BBONE_SUBDIV+1 interpolated points, will become desired amount with equal distances */ static void equalize_bezier(float *data, int desired) { float *fp, totdist, ddist, dist, fac1, fac2; - float pdist[MAX_BBONE_SUBDIV+1]; - float temp[MAX_BBONE_SUBDIV+1][4]; + float pdist[MAX_BBONE_SUBDIV + 1]; + float temp[MAX_BBONE_SUBDIV + 1][4]; int a, nr; pdist[0] = 0.0f; for (a = 0, fp = data; a < MAX_BBONE_SUBDIV; a++, fp += 4) { copy_qt_qt(temp[a], fp); - pdist[a+1] = pdist[a] + len_v3v3(fp, fp+4); + pdist[a + 1] = pdist[a] + len_v3v3(fp, fp + 4); } /* do last point */ copy_qt_qt(temp[a], fp); totdist = pdist[a]; /* go over distances and calculate new points */ - ddist = totdist/((float)desired); + ddist = totdist / ((float)desired); nr = 1; - for (a = 1, fp = data+4; a < desired; a++, fp += 4) { - dist = ((float)a)*ddist; + for (a = 1, fp = data + 4; a < desired; a++, fp += 4) { + dist = ((float)a) * ddist; /* we're looking for location (distance) 'dist' in the array */ while ((dist >= pdist[nr]) && nr < MAX_BBONE_SUBDIV) nr++; - fac1 = pdist[nr] - pdist[nr-1]; + fac1 = pdist[nr] - pdist[nr - 1]; fac2 = pdist[nr] - dist; fac1 = fac2 / fac1; fac2 = 1.0f - fac1; - fp[0] = fac1*temp[nr-1][0] + fac2*temp[nr][0]; - fp[1] = fac1*temp[nr-1][1] + fac2*temp[nr][1]; - fp[2] = fac1*temp[nr-1][2] + fac2*temp[nr][2]; - fp[3] = fac1*temp[nr-1][3] + fac2*temp[nr][3]; + fp[0] = fac1 * temp[nr - 1][0] + fac2 * temp[nr][0]; + fp[1] = fac1 * temp[nr - 1][1] + fac2 * temp[nr][1]; + fp[2] = fac1 * temp[nr - 1][2] + fac2 * temp[nr][2]; + fp[3] = fac1 * temp[nr - 1][3] + fac2 * temp[nr][3]; } /* set last point, needed for orientation calculus */ copy_qt_qt(fp, temp[MAX_BBONE_SUBDIV]); @@ -436,7 +436,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) Bone *bone = pchan->bone; float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2; float mat3[3][3], imat[4][4], posemat[4][4], scalemat[4][4], iscalemat[4][4]; - float data[MAX_BBONE_SUBDIV+1][4], *fp; + float data[MAX_BBONE_SUBDIV + 1][4], *fp; int a, doscale = 0; length = bone->length; @@ -459,8 +459,8 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) } } - hlength1 = bone->ease1*length*0.390464f; /* 0.5*sqrt(2)*kappa, the handle length for near-perfect circles */ - hlength2 = bone->ease2*length*0.390464f; + hlength1 = bone->ease1 * length * 0.390464f; /* 0.5*sqrt(2)*kappa, the handle length for near-perfect circles */ + hlength2 = bone->ease2 * length * 0.390464f; /* evaluate next and prev bones */ if (bone->flag & BONE_CONNECTED) @@ -494,7 +494,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) copy_v3_v3(h1, prev->pose_head); mul_m4_v3(imat, h1); - if (prev->bone->segments>1) { + if (prev->bone->segments > 1) { /* if previous bone is B-bone too, use average handle direction */ h1[1] -= length; roll1 = 0.0f; @@ -534,10 +534,10 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) mul_m4_v3(imat, h2); /* if next bone is B-bone too, use average handle direction */ - if (next->bone->segments>1) + if (next->bone->segments > 1) ; else - h2[1]-= length; + h2[1] -= length; normalize_v3(h2); /* find the next roll to interpolate as well */ @@ -579,7 +579,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) /* make transformation matrices for the segments for drawing */ for (a = 0, fp = data[0]; a < bone->segments; a++, fp += 4) { - sub_v3_v3v3(h1, fp+4, fp); + sub_v3_v3v3(h1, fp + 4, fp); vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */ copy_m4_m3(result_array[a].mat, mat3); @@ -613,11 +613,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info int a; /* allocate b_bone matrices and dual quats */ - b_bone_mats = MEM_mallocN((1+bone->segments)*sizeof(Mat4), "BBone defmats"); + b_bone_mats = MEM_mallocN((1 + bone->segments) * sizeof(Mat4), "BBone defmats"); pdef_info->b_bone_mats = b_bone_mats; if (use_quaternion) { - b_bone_dual_quats = MEM_mallocN((bone->segments)*sizeof(DualQuat), "BBone dqs"); + b_bone_dual_quats = MEM_mallocN((bone->segments) * sizeof(DualQuat), "BBone dqs"); pdef_info->b_bone_dual_quats = b_bone_dual_quats; } @@ -634,11 +634,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info for (a = 0; a < bone->segments; a++) { invert_m4_m4(tmat, b_bone_rest[a].mat); - mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, + mul_serie_m4(b_bone_mats[a + 1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL); if (use_quaternion) - mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a+1].mat); + mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a + 1].mat); } } @@ -650,24 +650,24 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D int a; /* need to transform co back to bonespace, only need y */ - y = mat[0][1]*co[0] + mat[1][1]*co[1] + mat[2][1]*co[2] + mat[3][1]; + y = mat[0][1] * co[0] + mat[1][1] * co[1] + mat[2][1] * co[2] + mat[3][1]; /* now calculate which of the b_bones are deforming this */ - segment = bone->length/((float)bone->segments); - a = (int)(y/segment); + segment = bone->length / ((float)bone->segments); + a = (int)(y / segment); /* note; by clamping it extends deform at endpoints, goes best with * straight joints in restpos. */ - CLAMP(a, 0, bone->segments-1); + CLAMP(a, 0, bone->segments - 1); if (dq) { copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]); } else { - mul_m4_v3(b_bone[a+1].mat, co); + mul_m4_v3(b_bone[a + 1].mat, co); if (defmat) { - copy_m3_m4(defmat, b_bone[a+1].mat); + copy_m3_m4(defmat, b_bone[a + 1].mat); } } } @@ -699,27 +699,27 @@ float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3 rad = rad2; } else { - dist = (hsqr - (a*a)); + dist = (hsqr - (a * a)); if (l != 0.0f) { - rad = a/l; - rad = rad*rad2 + (1.0f-rad)*rad1; + rad = a / l; + rad = rad * rad2 + (1.0f - rad) * rad1; } else rad = rad1; } - a = rad*rad; + a = rad * rad; if (dist < a) return 1.0f; else { - l = rad+rdist; + l = rad + rdist; l *= l; if (rdist == 0.0f || dist >= l) return 0.0f; else { - a = sqrtf(dist)-rad; - return 1.0f-( a*a )/( rdist*rdist ); + a = sqrtf(dist) - rad; + return 1.0f - (a * a) / (rdist * rdist); } } } @@ -796,15 +796,15 @@ static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, f copy_v3_v3(cop, co); if (vec) { - if (pchan->bone->segments>1) + if (pchan->bone->segments > 1) /* applies on cop and bbonemat */ b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL); else mul_m4_v3(pchan->chan_mat, cop); - vec[0] += (cop[0]-co[0])*weight; - vec[1] += (cop[1]-co[1])*weight; - vec[2] += (cop[2]-co[2])*weight; + vec[0] += (cop[0] - co[0]) * weight; + vec[1] += (cop[1] - co[1]) * weight; + vec[2] += (cop[2] - co[2]) * weight; if (mat) pchan_deform_mat_add(pchan, weight, bbonemat, mat); @@ -856,10 +856,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float totchan = BLI_countlist(&armOb->pose->chanbase); if (use_quaternion) { - dualquats = MEM_callocN(sizeof(DualQuat)*totchan, "dualquats"); + dualquats = MEM_callocN(sizeof(DualQuat) * totchan, "dualquats"); } - pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform)*totchan, "bPoseChanDeform"); + pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform) * totchan, "bPoseChanDeform"); totchan = 0; pdef_info = pdef_info_array; @@ -891,7 +891,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float Lattice *lt = target->data; dverts = lt->dvert; if (dverts) - target_totvert = lt->pntsu*lt->pntsv*lt->pntsw; + target_totvert = lt->pntsu * lt->pntsv * lt->pntsw; } } @@ -963,7 +963,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float armature_weight = defvert_find_weight(dvert, armature_def_nr); if (invert_vgroup) - armature_weight = 1.0f-armature_weight; + armature_weight = 1.0f - armature_weight; /* hackish: the blending factor can be used for blending with prevCos too */ if (prevCos) { @@ -1039,7 +1039,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float smat = summat; } else { - mul_v3_fl(vec, armature_weight/contrib); + mul_v3_fl(vec, armature_weight / contrib); add_v3_v3v3(co, vec, co); } @@ -1051,7 +1051,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float copy_m3_m3(tmpmat, defMats[i]); if (!use_quaternion) /* quaternion already is scale corrected */ - mul_m3_fl(smat, armature_weight/contrib); + mul_m3_fl(smat, armature_weight / contrib); mul_serie_m3(defMats[i], tmpmat, pre, smat, post, NULL, NULL, NULL, NULL); } @@ -1063,9 +1063,9 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float /* interpolate with previous modifier position using weight group */ if (prevCos) { float mw = 1.0f - prevco_weight; - vertexCos[i][0] = prevco_weight*vertexCos[i][0] + mw*co[0]; - vertexCos[i][1] = prevco_weight*vertexCos[i][1] + mw*co[1]; - vertexCos[i][2] = prevco_weight*vertexCos[i][2] + mw*co[2]; + vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0]; + vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1]; + vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2]; } } @@ -1090,7 +1090,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float /* ************ END Armature Deform ******************* */ -void get_objectspace_bone_matrix(struct Bone* bone, float M_accumulatedMatrix[][4], int UNUSED(root), +void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][4], int UNUSED(root), int UNUSED(posed)) { copy_m4_m4(M_accumulatedMatrix, bone->arm_mat); @@ -1229,7 +1229,7 @@ void BKE_pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float l mult_m4_m4m4(loc_mat, bone_loc, tmat4); } /* Those flags do not affect position, use plain parent transform space! */ - else if (bone->flag & (BONE_HINGE|BONE_NO_SCALE)) { + else if (bone->flag & (BONE_HINGE | BONE_NO_SCALE)) { mult_m4_m4m4(loc_mat, parchan->pose_mat, offs_bone); } /* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */ @@ -1576,10 +1576,10 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected BKE_pose_rest(frompose); /* copy over all of the proxy's bone groups */ - /* TODO for later - * - implement 'local' bone groups as for constraints - * Note: this isn't trivial, as bones reference groups by index not by pointer, - * so syncing things correctly needs careful attention */ + /* TODO for later + * - implement 'local' bone groups as for constraints + * Note: this isn't trivial, as bones reference groups by index not by pointer, + * so syncing things correctly needs careful attention */ BLI_freelistN(&pose->agroups); BLI_duplicatelist(&pose->agroups, &frompose->agroups); pose->active_group = frompose->active_group; @@ -1739,7 +1739,7 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm) BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */ /* the sorting */ - if (counter>1) + if (counter > 1) DAG_pose_sort(ob); ob->pose->flag &= ~POSE_RECALC; @@ -1792,7 +1792,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos if ((ikData->tar == NULL) || (ikData->tar->type != OB_CURVE)) continue; /* skip if disabled */ - if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF))) + if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))) continue; /* otherwise, constraint is ok... */ @@ -1831,7 +1831,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos if (segcount == 0) return; else - pchanRoot = pchanChain[segcount-1]; + pchanRoot = pchanChain[segcount - 1]; /* perform binding step if required */ if ((ikData->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) { @@ -1841,8 +1841,8 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos /* setup new empty array for the points list */ if (ikData->points) MEM_freeN(ikData->points); - ikData->numpoints = ikData->chainlen+1; - ikData->points = MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding"); + ikData->numpoints = ikData->chainlen + 1; + ikData->points = MEM_callocN(sizeof(float) * ikData->numpoints, "Spline IK Binding"); /* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */ ikData->points[0] = 1.0f; @@ -1856,13 +1856,13 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos */ if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) { /* 1) equi-spaced joints */ - ikData->points[i+1] = ikData->points[i] - segmentLen; + ikData->points[i + 1] = ikData->points[i] - segmentLen; } else { /* 2) to find this point on the curve, we take a step from the previous joint * a distance given by the proportion that this bone takes */ - ikData->points[i+1] = ikData->points[i] - (boneLengths[i] / totLength); + ikData->points[i + 1] = ikData->points[i] - (boneLengths[i] / totLength); } } @@ -1916,8 +1916,8 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos tree->chainlen = segcount; /* copy over the array of links to bones in the chain (from tip to root) */ - tree->chain = MEM_callocN(sizeof(bPoseChannel*)*segcount, "SplineIK Chain"); - memcpy(tree->chain, pchanChain, sizeof(bPoseChannel*)*segcount); + tree->chain = MEM_callocN(sizeof(bPoseChannel *) * segcount, "SplineIK Chain"); + memcpy(tree->chain, pchanChain, sizeof(bPoseChannel *) * segcount); /* store reference to joint position array */ tree->points = jointPoints; @@ -1956,7 +1956,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o { bSplineIKConstraint *ikData = tree->ikData; float poseHead[3], poseTail[3], poseMat[4][4]; - float splineVec[3], scaleFac, radius =1.0f; + float splineVec[3], scaleFac, radius = 1.0f; /* firstly, calculate the bone matrix the standard way, since this is needed for roll control */ BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); @@ -1970,14 +1970,14 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o float tailBlendFac = 1.0f; /* determine if the bone should still be affected by SplineIK */ - if (tree->points[index+1] >= 1.0f) { + if (tree->points[index + 1] >= 1.0f) { /* spline doesn't affect the bone anymore, so done... */ pchan->flag |= POSE_DONE; return; } - else if ((tree->points[index] >= 1.0f) && (tree->points[index+1] < 1.0f)) { + else if ((tree->points[index] >= 1.0f) && (tree->points[index + 1] < 1.0f)) { /* blending factor depends on the amount of the bone still left on the chain */ - tailBlendFac = (1.0f - tree->points[index+1]) / (tree->points[index] - tree->points[index+1]); + tailBlendFac = (1.0f - tree->points[index + 1]) / (tree->points[index] - tree->points[index + 1]); } /* tail endpoint */ @@ -1997,7 +1997,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } /* head endpoint */ - if (where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad, NULL)) { + if (where_on_path(ikData->tar, tree->points[index + 1], vec, dir, NULL, &rad, NULL)) { /* apply curve's object-mode transforms to the position * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root) */ @@ -2009,7 +2009,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o copy_v3_v3(poseHead, vec); /* set the new radius (it should be the average value) */ - radius = (radius+rad) / 2; + radius = (radius + rad) / 2; } } @@ -2083,7 +2083,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o scale = len_v3(pchan->pose_mat[2]); mul_v3_fl(poseMat[2], scale); } - break; + break; case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC: { /* 'volume preservation' */ @@ -2106,7 +2106,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o mul_v3_fl(poseMat[0], scale); mul_v3_fl(poseMat[2], scale); } - break; + break; } /* finally, multiply the x and z scaling by the radius of the curve too, @@ -2164,7 +2164,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_ * - the chain is traversed in the opposite order to storage order (i.e. parent to children) * so that dependencies are correct */ - for (i = tree->chainlen-1; i >= 0; i--) { + for (i = tree->chainlen - 1; i >= 0; i--) { bPoseChannel *pchan = tree->chain[i]; splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime); } @@ -2241,116 +2241,116 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha { bActionModifier *amod; bActionStrip *strip, *strip2; - float scene_cfra= (float)scene->r.cfra; + float scene_cfra = (float)scene->r.cfra; int do_modif; - for (strip=armob->nlastrips.first; strip; strip=strip->next) { - do_modif=0; + for (strip = armob->nlastrips.first; strip; strip = strip->next) { + do_modif = 0; - if (scene_cfra>=strip->start && scene_cfra<=strip->end) - do_modif=1; + if (scene_cfra >= strip->start && scene_cfra <= strip->end) + do_modif = 1; if ((scene_cfra > strip->end) && (strip->flag & ACTSTRIP_HOLDLASTFRAME)) { - do_modif=1; + do_modif = 1; /* if there are any other strips active, ignore modifiers for this strip - * 'hold' option should only hold action modifiers if there are * no other active strips */ - for (strip2=strip->next; strip2; strip2=strip2->next) { + for (strip2 = strip->next; strip2; strip2 = strip2->next) { if (strip2 == strip) continue; - if (scene_cfra>=strip2->start && scene_cfra<=strip2->end) { + if (scene_cfra >= strip2->start && scene_cfra <= strip2->end) { if (!(strip2->flag & ACTSTRIP_MUTE)) - do_modif=0; + do_modif = 0; } } /* if there are any later, activated, strips with 'hold' set, they take precedence, * so ignore modifiers for this strip */ - for (strip2=strip->next; strip2; strip2=strip2->next) { + for (strip2 = strip->next; strip2; strip2 = strip2->next) { if (scene_cfra < strip2->start) continue; if ((strip2->flag & ACTSTRIP_HOLDLASTFRAME) && !(strip2->flag & ACTSTRIP_MUTE)) { - do_modif=0; + do_modif = 0; } } } if (do_modif) { /* temporal solution to prevent 2 strips accumulating */ - if (scene_cfra==strip->end && strip->next && strip->next->start==scene_cfra) + if (scene_cfra == strip->end && strip->next && strip->next->start == scene_cfra) continue; - for (amod= strip->modifiers.first; amod; amod= amod->next) { + for (amod = strip->modifiers.first; amod; amod = amod->next) { switch (amod->type) { - case ACTSTRIP_MOD_DEFORM: - { - /* validate first */ - if (amod->ob && amod->ob->type==OB_CURVE && amod->channel[0]) { + case ACTSTRIP_MOD_DEFORM: + { + /* validate first */ + if (amod->ob && amod->ob->type == OB_CURVE && amod->channel[0]) { - if ( strcmp(pchan->name, amod->channel)==0 ) { - float mat4[4][4], mat3[3][3]; + if (strcmp(pchan->name, amod->channel) == 0) { + float mat4[4][4], mat3[3][3]; - curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); - copy_m4_m4(mat4, pchan->pose_mat); - mul_m4_m3m4(pchan->pose_mat, mat3, mat4); + curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); + copy_m4_m4(mat4, pchan->pose_mat); + mul_m4_m3m4(pchan->pose_mat, mat3, mat4); + } } } - } break; - case ACTSTRIP_MOD_NOISE: - { - if ( strcmp(pchan->name, amod->channel)==0 ) { - float nor[3], loc[3], ofs; - float eul[3], size[3], eulo[3], sizeo[3]; + case ACTSTRIP_MOD_NOISE: + { + if (strcmp(pchan->name, amod->channel) == 0) { + float nor[3], loc[3], ofs; + float eul[3], size[3], eulo[3], sizeo[3]; - /* calculate turbulance */ - ofs = amod->turbul / 200.0f; + /* calculate turbulance */ + ofs = amod->turbul / 200.0f; - /* make a copy of starting conditions */ - copy_v3_v3(loc, pchan->pose_mat[3]); - mat4_to_eul(eul, pchan->pose_mat); - mat4_to_size(size, pchan->pose_mat); - copy_v3_v3(eulo, eul); - copy_v3_v3(sizeo, size); + /* make a copy of starting conditions */ + copy_v3_v3(loc, pchan->pose_mat[3]); + mat4_to_eul(eul, pchan->pose_mat); + mat4_to_size(size, pchan->pose_mat); + copy_v3_v3(eulo, eul); + copy_v3_v3(sizeo, size); - /* apply noise to each set of channels */ - if (amod->channels & 4) { - /* for scaling */ - nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs; - nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs; - nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs; - add_v3_v3(size, nor); + /* apply noise to each set of channels */ + if (amod->channels & 4) { + /* for scaling */ + nor[0] = BLI_gNoise(amod->noisesize, size[0] + ofs, size[1], size[2], 0, 0) - ofs; + nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1] + ofs, size[2], 0, 0) - ofs; + nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2] + ofs, 0, 0) - ofs; + add_v3_v3(size, nor); - if (sizeo[0] != 0) - mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); - if (sizeo[1] != 0) - mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]); - if (sizeo[2] != 0) - mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]); - } - if (amod->channels & 2) { - /* for rotation */ - nor[0] = BLI_gNoise(amod->noisesize, eul[0]+ofs, eul[1], eul[2], 0, 0) - ofs; - nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1]+ofs, eul[2], 0, 0) - ofs; - nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs; + if (sizeo[0] != 0) + mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); + if (sizeo[1] != 0) + mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]); + if (sizeo[2] != 0) + mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]); + } + if (amod->channels & 2) { + /* for rotation */ + nor[0] = BLI_gNoise(amod->noisesize, eul[0] + ofs, eul[1], eul[2], 0, 0) - ofs; + nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1] + ofs, eul[2], 0, 0) - ofs; + nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2] + ofs, 0, 0) - ofs; - compatible_eul(nor, eulo); - add_v3_v3(eul, nor); - compatible_eul(eul, eulo); + compatible_eul(nor, eulo); + add_v3_v3(eul, nor); + compatible_eul(eul, eulo); - loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); - } - if (amod->channels & 1) { - /* for location */ - nor[0] = BLI_gNoise(amod->noisesize, loc[0]+ofs, loc[1], loc[2], 0, 0) - ofs; - nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs; - nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs; + loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); + } + if (amod->channels & 1) { + /* for location */ + nor[0] = BLI_gNoise(amod->noisesize, loc[0] + ofs, loc[1], loc[2], 0, 0) - ofs; + nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1] + ofs, loc[2], 0, 0) - ofs; + nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2] + ofs, 0, 0) - ofs; - add_v3_v3v3(pchan->pose_mat[3], loc, nor); + add_v3_v3v3(pchan->pose_mat[3], loc, nor); + } } } - } break; } } @@ -2394,7 +2394,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float } if (do_extra) { -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ /* do NLA strip modifiers - i.e. curve follow */ do_strip_modifiers(scene, ob, bone, pchan); #endif @@ -2413,7 +2413,7 @@ void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cob = constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); /* Solve PoseChannel's Constraints */ - solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */ + solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */ /* cleanup after Constraint Solving * - applies matrix back to pchan, and frees temporary struct used @@ -2470,7 +2470,7 @@ void BKE_pose_where_is(Scene *scene, Object *ob) /* 1. clear flags */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - pchan->flag &= ~(POSE_DONE|POSE_CHAIN|POSE_IKTREE|POSE_IKSPLINE); + pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE); } /* 2a. construct the IK tree (standard IK) */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index a1e8a11e9ff..dc13404dfaf 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -75,49 +75,49 @@ static void brush_defaults(Brush *brush) brush->ob_mode = OB_MODE_ALL_PAINT; /* BRUSH SCULPT TOOL SETTINGS */ - brush->weight= 1.0f; /* weight of brush 0 - 1.0 */ - brush->size= 35; /* radius of the brush in pixels */ - brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ - brush->autosmooth_factor= 0.0f; - brush->crease_pinch_factor= 0.5f; + brush->weight = 1.0f; /* weight of brush 0 - 1.0 */ + brush->size = 35; /* radius of the brush in pixels */ + brush->alpha = 0.5f; /* brush strength/intensity probably variable should be renamed? */ + brush->autosmooth_factor = 0.0f; + brush->crease_pinch_factor = 0.5f; brush->sculpt_plane = SCULPT_DISP_DIR_AREA; - brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */ - brush->plane_trim= 0.5f; - brush->clone.alpha= 0.5f; - brush->normal_weight= 0.0f; + brush->plane_offset = 0.0f; /* how far above or below the plane that is found by averaging the faces */ + brush->plane_trim = 0.5f; + brush->clone.alpha = 0.5f; + brush->normal_weight = 0.0f; brush->flag |= BRUSH_ALPHA_PRESSURE; /* BRUSH PAINT TOOL SETTINGS */ - brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */ - brush->rgb[1]= 1.0f; - brush->rgb[2]= 1.0f; + brush->rgb[0] = 1.0f; /* default rgb color of the brush when painting - white */ + brush->rgb[1] = 1.0f; + brush->rgb[2] = 1.0f; /* BRUSH STROKE SETTINGS */ - brush->flag |= (BRUSH_SPACE|BRUSH_SPACE_ATTEN); - brush->spacing= 10; /* how far each brush dot should be spaced as a percentage of brush diameter */ + brush->flag |= (BRUSH_SPACE | BRUSH_SPACE_ATTEN); + brush->spacing = 10; /* how far each brush dot should be spaced as a percentage of brush diameter */ - brush->smooth_stroke_radius= 75; - brush->smooth_stroke_factor= 0.9f; + brush->smooth_stroke_radius = 75; + brush->smooth_stroke_factor = 0.9f; - brush->rate= 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */ + brush->rate = 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */ - brush->jitter= 0.0f; + brush->jitter = 0.0f; /* BRUSH TEXTURE SETTINGS */ default_mtex(&brush->mtex); - brush->texture_sample_bias= 0; /* value to added to texture samples */ - brush->texture_overlay_alpha= 33; + brush->texture_sample_bias = 0; /* value to added to texture samples */ + brush->texture_overlay_alpha = 33; /* brush appearance */ - brush->add_col[0]= 1.00; /* add mode color is light red */ - brush->add_col[1]= 0.39; - brush->add_col[2]= 0.39; + brush->add_col[0] = 1.00; /* add mode color is light red */ + brush->add_col[1] = 0.39; + brush->add_col[2] = 0.39; - brush->sub_col[0]= 0.39; /* subtract mode color is light blue */ - brush->sub_col[1]= 0.39; - brush->sub_col[2]= 1.00; + brush->sub_col[0] = 0.39; /* subtract mode color is light blue */ + brush->sub_col[1] = 0.39; + brush->sub_col[2] = 1.00; } /* Datablock add/copy/free/make_local */ @@ -126,7 +126,7 @@ Brush *BKE_brush_add(const char *name) { Brush *brush; - brush= BKE_libblock_alloc(&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; @@ -135,7 +135,7 @@ Brush *BKE_brush_add(const char *name) brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ - /* the default alpha falloff curve */ + /* the default alpha falloff curve */ BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH); return brush; @@ -145,17 +145,17 @@ Brush *BKE_brush_copy(Brush *brush) { Brush *brushn; - brushn= BKE_libblock_copy(&brush->id); + brushn = BKE_libblock_copy(&brush->id); if (brush->mtex.tex) - id_us_plus((ID*)brush->mtex.tex); + id_us_plus((ID *)brush->mtex.tex); if (brush->icon_imbuf) - brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); + brushn->icon_imbuf = IMB_dupImBuf(brush->icon_imbuf); brushn->preview = NULL; - brushn->curve= curvemapping_copy(brush->curve); + brushn->curve = curvemapping_copy(brush->curve); /* enable fake user by default */ if (!(brushn->id.flag & LIB_FAKEUSER)) { @@ -194,11 +194,11 @@ void BKE_brush_make_local(Brush *brush) * - mixed: make copy */ - Main *bmain= G.main; + Main *bmain = G.main; Scene *scene; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; - if (brush->id.lib==NULL) return; + if (brush->id.lib == NULL) return; if (brush->clone.image) { /* special case: ima always local immediately. Clone image should only @@ -207,10 +207,10 @@ void BKE_brush_make_local(Brush *brush) extern_local_brush(brush); } - for (scene= bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene=scene->id.next) { - if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) { - if (scene->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (scene = bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene = scene->id.next) { + if (paint_brush(&scene->toolsettings->imapaint.paint) == brush) { + if (scene->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -225,16 +225,16 @@ void BKE_brush_make_local(Brush *brush) } } else if (is_local && is_lib) { - Brush *brush_new= BKE_brush_copy(brush); - brush_new->id.us= 1; /* only keep fake user */ + Brush *brush_new = BKE_brush_copy(brush); + brush_new->id.us = 1; /* only keep fake user */ brush_new->id.flag |= LIB_FAKEUSER; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id); - for (scene= bmain->scene.first; scene; scene=scene->id.next) { - if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) { - if (scene->id.lib==NULL) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { + if (paint_brush(&scene->toolsettings->imapaint.paint) == brush) { + if (scene->id.lib == NULL) { paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new); } } @@ -245,16 +245,16 @@ void BKE_brush_make_local(Brush *brush) void BKE_brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ - Brush def= {{NULL}}; + Brush def = {{NULL}}; brush_defaults(&def); #define BR_TEST(field, t) \ if (br->field != def.field) \ printf("br->" #field " = %" #t ";\n", br->field) -#define BR_TEST_FLAG(_f) \ +#define BR_TEST_FLAG(_f) \ if ((br->flag & _f) && !(def.flag & _f)) \ - printf("br->flag |= " #_f ";\n"); \ + printf("br->flag |= " #_f ";\n"); \ else if (!(br->flag & _f) && (def.flag & _f)) \ printf("br->flag &= ~" #_f ";\n") @@ -339,77 +339,77 @@ void BKE_brush_sculpt_reset(Brush *br) BKE_brush_curve_preset(br, CURVE_PRESET_SMOOTH); switch (br->sculpt_tool) { - case SCULPT_TOOL_CLAY: - br->flag |= BRUSH_FRONTFACE; - break; - case SCULPT_TOOL_CREASE: - br->flag |= BRUSH_DIR_IN; - br->alpha = 0.25; - break; - case SCULPT_TOOL_FILL: - br->add_col[1] = 1; - br->sub_col[0] = 0.25; - br->sub_col[1] = 1; - break; - case SCULPT_TOOL_FLATTEN: - br->add_col[1] = 1; - br->sub_col[0] = 0.25; - br->sub_col[1] = 1; - break; - case SCULPT_TOOL_INFLATE: - br->add_col[0] = 0.750000; - br->add_col[1] = 0.750000; - br->add_col[2] = 0.750000; - br->sub_col[0] = 0.250000; - br->sub_col[1] = 0.250000; - br->sub_col[2] = 0.250000; - break; - case SCULPT_TOOL_NUDGE: - br->add_col[0] = 0.250000; - br->add_col[1] = 1.000000; - br->add_col[2] = 0.250000; - break; - case SCULPT_TOOL_PINCH: - br->add_col[0] = 0.750000; - br->add_col[1] = 0.750000; - br->add_col[2] = 0.750000; - br->sub_col[0] = 0.250000; - br->sub_col[1] = 0.250000; - br->sub_col[2] = 0.250000; - break; - case SCULPT_TOOL_SCRAPE: - br->add_col[1] = 1.000000; - br->sub_col[0] = 0.250000; - br->sub_col[1] = 1.000000; - break; - case SCULPT_TOOL_ROTATE: - br->alpha = 1.0; - break; - case SCULPT_TOOL_SMOOTH: - br->flag &= ~BRUSH_SPACE_ATTEN; - br->spacing = 5; - br->add_col[0] = 0.750000; - br->add_col[1] = 0.750000; - br->add_col[2] = 0.750000; - break; - case SCULPT_TOOL_GRAB: - case SCULPT_TOOL_SNAKE_HOOK: - case SCULPT_TOOL_THUMB: - br->size = 75; - br->flag &= ~BRUSH_ALPHA_PRESSURE; - br->flag &= ~BRUSH_SPACE; - br->flag &= ~BRUSH_SPACE_ATTEN; - br->add_col[0] = 0.250000; - br->add_col[1] = 1.000000; - br->add_col[2] = 0.250000; - break; - default: - break; + case SCULPT_TOOL_CLAY: + br->flag |= BRUSH_FRONTFACE; + break; + case SCULPT_TOOL_CREASE: + br->flag |= BRUSH_DIR_IN; + br->alpha = 0.25; + break; + case SCULPT_TOOL_FILL: + br->add_col[1] = 1; + br->sub_col[0] = 0.25; + br->sub_col[1] = 1; + break; + case SCULPT_TOOL_FLATTEN: + br->add_col[1] = 1; + br->sub_col[0] = 0.25; + br->sub_col[1] = 1; + break; + case SCULPT_TOOL_INFLATE: + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 0.250000; + br->sub_col[2] = 0.250000; + break; + case SCULPT_TOOL_NUDGE: + br->add_col[0] = 0.250000; + br->add_col[1] = 1.000000; + br->add_col[2] = 0.250000; + break; + case SCULPT_TOOL_PINCH: + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 0.250000; + br->sub_col[2] = 0.250000; + break; + case SCULPT_TOOL_SCRAPE: + br->add_col[1] = 1.000000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 1.000000; + break; + case SCULPT_TOOL_ROTATE: + br->alpha = 1.0; + break; + case SCULPT_TOOL_SMOOTH: + br->flag &= ~BRUSH_SPACE_ATTEN; + br->spacing = 5; + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + break; + case SCULPT_TOOL_GRAB: + case SCULPT_TOOL_SNAKE_HOOK: + case SCULPT_TOOL_THUMB: + br->size = 75; + br->flag &= ~BRUSH_ALPHA_PRESSURE; + br->flag &= ~BRUSH_SPACE; + br->flag &= ~BRUSH_SPACE_ATTEN; + br->add_col[0] = 0.250000; + br->add_col[1] = 1.000000; + br->add_col[2] = 0.250000; + break; + default: + break; } } /* Library Operations */ -void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) +void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/ int preset) { CurveMap *cm = NULL; @@ -426,20 +426,20 @@ void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) int BKE_brush_texture_set_nr(Brush *brush, int nr) { - ID *idtest, *id=NULL; + ID *idtest, *id = NULL; - id= (ID *)brush->mtex.tex; + id = (ID *)brush->mtex.tex; - idtest= (ID*)BLI_findlink(&G.main->tex, nr-1); - if (idtest==NULL) { /* new tex */ - if (id) idtest= (ID *)BKE_texture_copy((Tex *)id); - else idtest= (ID *)add_texture("Tex"); + idtest = (ID *)BLI_findlink(&G.main->tex, nr - 1); + if (idtest == NULL) { /* new tex */ + if (id) idtest = (ID *)BKE_texture_copy((Tex *)id); + else idtest = (ID *)add_texture("Tex"); idtest->us--; } - if (idtest!=id) { + if (idtest != id) { BKE_brush_texture_delete(brush); - brush->mtex.tex= (Tex*)idtest; + brush->mtex.tex = (Tex *)idtest; id_us_plus(idtest); return 1; @@ -459,13 +459,13 @@ int BKE_brush_texture_delete(Brush *brush) 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); + Image *ima = (Image *)BLI_findlink(&G.main->image, nr - 1); if (ima) { BKE_brush_clone_image_delete(brush); - brush->clone.image= ima; + brush->clone.image = ima; id_us_plus(&ima->id); - brush->clone.offset[0]= brush->clone.offset[1]= 0.0f; + brush->clone.offset[0] = brush->clone.offset[1] = 0.0f; return 1; } @@ -478,7 +478,7 @@ int BKE_brush_clone_image_delete(Brush *brush) { if (brush && brush->clone.image) { brush->clone.image->id.us--; - brush->clone.image= NULL; + brush->clone.image = NULL; return 1; } @@ -488,34 +488,34 @@ int BKE_brush_clone_image_delete(Brush *brush) /* Brush Sampling */ void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) { - MTex *mtex= &brush->mtex; + MTex *mtex = &brush->mtex; if (mtex && mtex->tex) { float co[3], tin, tr, tg, tb, ta; int hasrgb; - const int radius= BKE_brush_size_get(scene, brush); + const int radius = BKE_brush_size_get(scene, brush); - co[0]= xy[0]/radius; - co[1]= xy[1]/radius; - co[2]= 0.0f; + co[0] = xy[0] / radius; + co[1] = xy[1] / radius; + co[2] = 0.0f; - hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread); + hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread); if (hasrgb) { - rgba[0]= tr; - rgba[1]= tg; - rgba[2]= tb; - rgba[3]= ta; + rgba[0] = tr; + rgba[1] = tg; + rgba[2] = tb; + rgba[3] = ta; } else { - rgba[0]= tin; - rgba[1]= tin; - rgba[2]= tin; - rgba[3]= 1.0f; + rgba[0] = tin; + rgba[1] = tin; + rgba[2] = tin; + rgba[3] = 1.0f; } } else { - rgba[0]= rgba[1]= rgba[2]= rgba[3]= 1.0f; + rgba[0] = rgba[1] = rgba[2] = rgba[3] = 1.0f; } } @@ -525,20 +525,20 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf ImBuf *ibuf; float xy[2], rgba[4], *dstf; int x, y, rowbytes, xoff, yoff, imbflag; - const int radius= BKE_brush_size_get(scene, brush); + const int radius = BKE_brush_size_get(scene, brush); unsigned char *dst, crgb[3]; - const float alpha= BKE_brush_alpha_get(scene, brush); + const float alpha = BKE_brush_alpha_get(scene, brush); float brush_rgb[3]; - imbflag= (flt)? IB_rectfloat: IB_rect; - xoff = -bufsize/2.0f + 0.5f; - yoff = -bufsize/2.0f + 0.5f; - rowbytes= bufsize*4; + imbflag = (flt) ? IB_rectfloat : IB_rect; + xoff = -bufsize / 2.0f + 0.5f; + yoff = -bufsize / 2.0f + 0.5f; + rowbytes = bufsize * 4; if (*outbuf) - ibuf= *outbuf; + ibuf = *outbuf; else - ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag); + ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag); if (flt) { copy_v3_v3(brush_rgb, brush->rgb); @@ -546,16 +546,16 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb); } - for (y=0; y < ibuf->y; y++) { - dstf = ibuf->rect_float + y*rowbytes; + for (y = 0; y < ibuf->y; y++) { + dstf = ibuf->rect_float + y * rowbytes; - for (x=0; x < ibuf->x; x++, dstf+=4) { + for (x = 0; x < ibuf->x; x++, dstf += 4) { xy[0] = x + xoff; xy[1] = y + yoff; if (texfall == 0) { copy_v3_v3(dstf, brush_rgb); - dstf[3]= alpha*BKE_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) { BKE_brush_sample_tex(scene, brush, xy, dstf, 0); @@ -563,7 +563,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf else { BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3v3(dstf, rgba, brush_rgb); - dstf[3] = rgba[3]*alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3] = rgba[3] *alpha *BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } } } @@ -572,10 +572,10 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf float alpha_f; /* final float alpha to convert to char */ rgb_float_to_uchar(crgb, brush->rgb); - for (y=0; y < ibuf->y; y++) { - dst = (unsigned char *)ibuf->rect + y*rowbytes; + for (y = 0; y < ibuf->y; y++) { + dst = (unsigned char *)ibuf->rect + y * rowbytes; - for (x=0; x < ibuf->x; x++, dst+=4) { + for (x = 0; x < ibuf->x; x++, dst += 4) { xy[0] = x + xoff; xy[1] = y + yoff; @@ -594,7 +594,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf else if (texfall == 2) { BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3(rgba, brush->rgb); - alpha_f = rgba[3] * alpha * BKE_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); @@ -602,7 +602,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf } else { BKE_brush_sample_tex(scene, brush, xy, rgba, 0); - alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + alpha_f = rgba[3] *alpha *BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -613,7 +613,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf } } - *outbuf= ibuf; + *outbuf = ibuf; } /* Unified Size and Strength */ @@ -636,9 +636,9 @@ void BKE_brush_size_set(Scene *scene, Brush *brush, int size) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; if (ups->flag & UNIFIED_PAINT_SIZE) - ups->size= size; + ups->size = size; else - brush->size= size; + brush->size = size; } int BKE_brush_size_get(const Scene *scene, Brush *brush) @@ -653,8 +653,8 @@ int BKE_brush_use_locked_size(const Scene *scene, Brush *brush) const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_SIZE) ? - (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) : - (brush->flag & BRUSH_LOCK_SIZE); + (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) : + (brush->flag & BRUSH_LOCK_SIZE); } int BKE_brush_use_size_pressure(const Scene *scene, Brush *brush) @@ -662,8 +662,8 @@ int BKE_brush_use_size_pressure(const Scene *scene, Brush *brush) const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_SIZE) ? - (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) : - (brush->flag & BRUSH_SIZE_PRESSURE); + (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) : + (brush->flag & BRUSH_SIZE_PRESSURE); } int BKE_brush_use_alpha_pressure(const Scene *scene, Brush *brush) @@ -671,8 +671,8 @@ int BKE_brush_use_alpha_pressure(const Scene *scene, Brush *brush) const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_ALPHA) ? - (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) : - (brush->flag & BRUSH_ALPHA_PRESSURE); + (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) : + (brush->flag & BRUSH_ALPHA_PRESSURE); } void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius) @@ -680,9 +680,9 @@ void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojec UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; if (ups->flag & UNIFIED_PAINT_SIZE) - ups->unprojected_radius= unprojected_radius; + ups->unprojected_radius = unprojected_radius; else - brush->unprojected_radius= unprojected_radius; + brush->unprojected_radius = unprojected_radius; } float BKE_brush_unprojected_radius_get(const Scene *scene, Brush *brush) @@ -690,8 +690,8 @@ float BKE_brush_unprojected_radius_get(const Scene *scene, Brush *brush) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_SIZE) ? - ups->unprojected_radius : - brush->unprojected_radius; + ups->unprojected_radius : + brush->unprojected_radius; } static void brush_alpha_set(Scene *scene, Brush *brush, float alpha) @@ -699,9 +699,9 @@ static void brush_alpha_set(Scene *scene, Brush *brush, float alpha) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; if (ups->flag & UNIFIED_PAINT_ALPHA) - ups->alpha= alpha; + ups->alpha = alpha; else - brush->alpha= alpha; + brush->alpha = alpha; } float BKE_brush_alpha_get(const Scene *scene, Brush *brush) @@ -722,7 +722,7 @@ void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - if(ups->flag & UNIFIED_PAINT_WEIGHT) + if (ups->flag & UNIFIED_PAINT_WEIGHT) ups->weight = value; else brush->weight = value; @@ -749,7 +749,7 @@ void BKE_brush_scale_size(int *BKE_brush_size_get, /* avoid division by zero */ if (old_unprojected_radius != 0) scale /= new_unprojected_radius; - (*BKE_brush_size_get)= (int)((float)(*BKE_brush_size_get) * scale); + (*BKE_brush_size_get) = (int)((float)(*BKE_brush_size_get) * scale); } /* Brush Painting */ @@ -757,9 +757,9 @@ void BKE_brush_scale_size(int *BKE_brush_size_get, typedef struct BrushPainterCache { short enabled; - 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 */ + 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 */ int lastsize; float lastalpha; @@ -774,18 +774,18 @@ struct BrushPainter { Scene *scene; Brush *brush; - float lastmousepos[2]; /* mouse position of last paint call */ + float lastmousepos[2]; /* mouse position of last paint call */ - float accumdistance; /* accumulated distance of brush since last paint op */ - float lastpaintpos[2]; /* position of last paint op */ + float accumdistance; /* accumulated distance of brush since last paint op */ + float lastpaintpos[2]; /* position of last paint op */ float startpaintpos[2]; /* position of first paint */ - double accumtime; /* accumulated time since last paint op (airbrush) */ - double lasttime; /* time of last update */ + double accumtime; /* accumulated time since last paint op (airbrush) */ + double lasttime; /* time of last update */ float lastpressure; - short firsttouch; /* first paint op */ + short firsttouch; /* first paint op */ float startsize; float startalpha; @@ -797,12 +797,12 @@ struct BrushPainter { BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush) { - BrushPainter *painter= MEM_callocN(sizeof(BrushPainter), "BrushPainter"); + BrushPainter *painter = MEM_callocN(sizeof(BrushPainter), "BrushPainter"); - painter->brush= brush; - painter->scene= scene; - painter->firsttouch= 1; - painter->cache.lastsize= -1; /* force ibuf create in refresh */ + painter->brush = brush; + painter->scene = scene; + painter->firsttouch = 1; + painter->cache.lastsize = -1; /* force ibuf create in refresh */ painter->startsize = BKE_brush_size_get(scene, brush); painter->startalpha = BKE_brush_alpha_get(scene, brush); @@ -815,23 +815,24 @@ BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush) 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)) { + ((painter->cache.texonly != texonly) && texonly)) + { if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf); if (painter->cache.maskibuf) IMB_freeImBuf(painter->cache.maskibuf); - painter->cache.ibuf= painter->cache.maskibuf= NULL; - painter->cache.lastsize= -1; /* force ibuf create in refresh */ + painter->cache.ibuf = painter->cache.maskibuf = NULL; + painter->cache.lastsize = -1; /* force ibuf create in refresh */ } if (painter->cache.flt != flt) { if (painter->cache.texibuf) IMB_freeImBuf(painter->cache.texibuf); - painter->cache.texibuf= NULL; - painter->cache.lastsize= -1; /* force ibuf create in refresh */ + painter->cache.texibuf = NULL; + painter->cache.lastsize = -1; /* force ibuf create in refresh */ } - painter->cache.size= size; - painter->cache.flt= flt; - painter->cache.texonly= texonly; - painter->cache.enabled= 1; + painter->cache.size = size; + painter->cache.flt = flt; + painter->cache.texonly = texonly; + painter->cache.enabled = 1; } void BKE_brush_painter_free(BrushPainter *painter) @@ -853,13 +854,13 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, int x, int y, int w, int h, int xt, int yt, const float pos[2]) { - Scene *scene= painter->scene; - Brush *brush= painter->brush; + Scene *scene = painter->scene; + Brush *brush = painter->brush; ImBuf *ibuf, *maskibuf, *texibuf; - 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= BKE_brush_size_get(painter->scene, brush); + 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 = BKE_brush_size_get(painter->scene, brush); xoff = -radius + 0.5f; yoff = -radius + 0.5f; @@ -880,14 +881,14 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, if (painter->cache.flt) { for (; y < h; y++) { - bf = ibuf->rect_float + (y*ibuf->x + origx)*4; - tf = texibuf->rect_float + (y*texibuf->x + origx)*4; - mf = maskibuf->rect_float + (y*maskibuf->x + origx)*4; + bf = ibuf->rect_float + (y * ibuf->x + origx) * 4; + tf = texibuf->rect_float + (y * texibuf->x + origx) * 4; + mf = maskibuf->rect_float + (y * maskibuf->x + origx) * 4; if (dotexold) - otf = oldtexibuf->rect_float + ((y - origy + yt)*oldtexibuf->x + xt)*4; + otf = oldtexibuf->rect_float + ((y - origy + yt) * oldtexibuf->x + xt) * 4; - for (x=origx; x < w; x++, bf+=4, mf+=4, tf+=4) { + for (x = origx; x < w; x++, bf += 4, mf += 4, tf += 4) { if (dotexold) { copy_v3_v3(tf, otf); tf[3] = otf[3]; @@ -900,23 +901,23 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, BKE_brush_sample_tex(scene, brush, xy, tf, 0); } - bf[0] = tf[0]*mf[0]; - bf[1] = tf[1]*mf[1]; - bf[2] = tf[2]*mf[2]; - bf[3] = tf[3]*mf[3]; + bf[0] = tf[0] * mf[0]; + bf[1] = tf[1] * mf[1]; + bf[2] = tf[2] * mf[2]; + bf[3] = tf[3] * mf[3]; } } } else { for (; y < h; y++) { - b = (unsigned char *)ibuf->rect + (y*ibuf->x + origx)*4; - t = (unsigned char *)texibuf->rect + (y*texibuf->x + origx)*4; - m = (unsigned char *)maskibuf->rect + (y*maskibuf->x + origx)*4; + b = (unsigned char *)ibuf->rect + (y * ibuf->x + origx) * 4; + t = (unsigned char *)texibuf->rect + (y * texibuf->x + origx) * 4; + m = (unsigned char *)maskibuf->rect + (y * maskibuf->x + origx) * 4; if (dotexold) - ot = (unsigned char *)oldtexibuf->rect + ((y - origy + yt)*oldtexibuf->x + xt)*4; + ot = (unsigned char *)oldtexibuf->rect + ((y - origy + yt) * oldtexibuf->x + xt) * 4; - for (x=origx; x < w; x++, b+=4, m+=4, t+=4) { + for (x = origx; x < w; x++, b += 4, m += 4, t += 4) { if (dotexold) { t[0] = ot[0]; t[1] = ot[1]; @@ -932,10 +933,10 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, rgba_float_to_uchar(t, rgba); } - b[0] = t[0]*m[0]/255; - b[1] = t[1]*m[1]/255; - b[2] = t[2]*m[2]/255; - b[3] = t[3]*m[3]/255; + b[0] = t[0] * m[0] / 255; + b[1] = t[1] * m[1] / 255; + b[2] = t[2] * m[2] / 255; + b[3] = t[3] * m[3] / 255; } } } @@ -943,40 +944,40 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const float pos[2]) { - const Scene *scene= painter->scene; - Brush *brush= painter->brush; - BrushPainterCache *cache= &painter->cache; + const Scene *scene = painter->scene; + Brush *brush = painter->brush; + BrushPainterCache *cache = &painter->cache; ImBuf *oldtexibuf, *ibuf; int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2; - const int diameter= 2*BKE_brush_size_get(scene, brush); + const int diameter = 2 * BKE_brush_size_get(scene, brush); - imbflag= (cache->flt)? IB_rectfloat: IB_rect; + imbflag = (cache->flt) ? IB_rectfloat : IB_rect; if (!cache->ibuf) - cache->ibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag); - ibuf= cache->ibuf; + cache->ibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag); + ibuf = cache->ibuf; - oldtexibuf= cache->texibuf; - cache->texibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag); + oldtexibuf = cache->texibuf; + cache->texibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag); if (oldtexibuf) { - srcx= srcy= 0; - destx= (int)painter->lastpaintpos[0] - (int)pos[0]; - desty= (int)painter->lastpaintpos[1] - (int)pos[1]; - w= oldtexibuf->x; - h= oldtexibuf->y; + srcx = srcy = 0; + destx = (int)painter->lastpaintpos[0] - (int)pos[0]; + desty = (int)painter->lastpaintpos[1] - (int)pos[1]; + w = oldtexibuf->x; + h = oldtexibuf->y; IMB_rectclip(cache->texibuf, oldtexibuf, &destx, &desty, &srcx, &srcy, &w, &h); } else { - srcx= srcy= 0; - destx= desty= 0; - w= h= 0; + srcx = srcy = 0; + destx = desty = 0; + w = h = 0; } - x1= destx; - y1= desty; - x2= destx+w; - y2= desty+h; + x1 = destx; + y1 = desty; + x2 = destx + w; + y2 = desty + h; /* blend existing texture in new position */ if ((x1 < x2) && (y1 < y2)) @@ -998,30 +999,30 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2], int use_color_correction) { - const Scene *scene= painter->scene; - Brush *brush= painter->brush; - BrushPainterCache *cache= &painter->cache; - MTex *mtex= &brush->mtex; + const Scene *scene = painter->scene; + Brush *brush = painter->brush; + BrushPainterCache *cache = &painter->cache; + MTex *mtex = &brush->mtex; int size; short flt; - const int diameter= 2*BKE_brush_size_get(scene, brush); - const float alpha= BKE_brush_alpha_get(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 || - brush->jitter != cache->lastjitter) + alpha != cache->lastalpha || + brush->jitter != cache->lastjitter) { if (cache->ibuf) { IMB_freeImBuf(cache->ibuf); - cache->ibuf= NULL; + cache->ibuf = NULL; } if (cache->maskibuf) { IMB_freeImBuf(cache->maskibuf); - cache->maskibuf= NULL; + cache->maskibuf = NULL; } - flt= cache->flt; - size= (cache->size)? cache->size: diameter; + flt = cache->flt; + size = (cache->size) ? cache->size : diameter; if (brush->flag & BRUSH_FIXED_TEX) { BKE_brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); @@ -1030,9 +1031,9 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 else BKE_brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); - cache->lastsize= diameter; - cache->lastalpha= alpha; - cache->lastjitter= brush->jitter; + cache->lastsize = diameter; + cache->lastalpha = alpha; + cache->lastjitter = brush->jitter; } else if ((brush->flag & BRUSH_FIXED_TEX) && mtex && mtex->tex) { int dx = (int)painter->lastpaintpos[0] - (int)pos[0]; @@ -1045,42 +1046,42 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 void BKE_brush_painter_break_stroke(BrushPainter *painter) { - painter->firsttouch= 1; + painter->firsttouch = 1; } static void brush_pressure_apply(BrushPainter *painter, Brush *brush, float pressure) { if (BKE_brush_use_alpha_pressure(painter->scene, brush)) - brush_alpha_set(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure)); + 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)); + 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); + brush->jitter = MAX2(0.0f, painter->startjitter * pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) - brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure)); + brush->spacing = MAX2(1.0f, painter->startspacing * (1.5f - pressure)); } void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) { - int use_jitter= brush->jitter != 0; + int use_jitter = brush->jitter != 0; /* jitter-ed brush gives weird and unpredictable result for this * kinds of stroke, so manyally disable jitter usage (sergey) */ - use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH|BRUSH_ANCHORED)) == 0; + use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH | BRUSH_ANCHORED)) == 0; if (use_jitter) { float rand_pos[2]; - const int radius= BKE_brush_size_get(scene, brush); - const int diameter= 2*radius; + const int radius = BKE_brush_size_get(scene, brush); + const int diameter = 2 * radius; // find random position within a circle of diameter 1 do { - rand_pos[0] = BLI_frand()-0.5f; - rand_pos[1] = BLI_frand()-0.5f; + rand_pos[0] = BLI_frand() - 0.5f; + rand_pos[1] = BLI_frand() - 0.5f; } while (len_v2(rand_pos) > 0.5f); - jitterpos[0] = pos[0] + 2*rand_pos[0]*diameter*brush->jitter; - jitterpos[1] = pos[1] + 2*rand_pos[1]*diameter*brush->jitter; + jitterpos[0] = pos[0] + 2 * rand_pos[0] * diameter * brush->jitter; + jitterpos[1] = pos[1] + 2 * rand_pos[1] * diameter * brush->jitter; } else { copy_v2_v2(jitterpos, pos); @@ -1090,92 +1091,92 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, 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) { - Scene *scene= painter->scene; - Brush *brush= painter->brush; - int totpaintops= 0; + Scene *scene = painter->scene; + Brush *brush = painter->brush; + int totpaintops = 0; if (pressure == 0.0f) { if (painter->lastpressure) // XXX - hack, operator misses - pressure= painter->lastpressure; + pressure = painter->lastpressure; else - pressure = 1.0f; /* zero pressure == not using tablet */ + pressure = 1.0f; /* zero pressure == not using tablet */ } if (painter->firsttouch) { /* paint exactly once on first touch */ - painter->startpaintpos[0]= pos[0]; - painter->startpaintpos[1]= pos[1]; + painter->startpaintpos[0] = pos[0]; + painter->startpaintpos[1] = pos[1]; 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); - painter->lasttime= time; - painter->firsttouch= 0; - painter->lastpaintpos[0]= pos[0]; - painter->lastpaintpos[1]= pos[1]; + painter->lasttime = time; + painter->firsttouch = 0; + painter->lastpaintpos[0] = pos[0]; + painter->lastpaintpos[1] = pos[1]; } #if 0 else if (painter->brush->flag & BRUSH_AIRBRUSH) { float spacing, step, paintpos[2], dmousepos[2], len; - double starttime, curtime= time; + double starttime, curtime = time; /* compute brush spacing adapted to brush size */ - spacing= brush->rate; //radius*brush->spacing*0.01f; + spacing = brush->rate; //radius*brush->spacing*0.01f; /* setup starting time, direction vector and accumulated time */ - starttime= painter->accumtime; + starttime = painter->accumtime; sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); - len= normalize_v2(dmousepos); + len = normalize_v2(dmousepos); painter->accumtime += curtime - painter->lasttime; /* do paint op over unpainted time distance */ while (painter->accumtime >= spacing) { - step= (spacing - starttime)*len; - paintpos[0]= painter->lastmousepos[0] + dmousepos[0]*step; - paintpos[1]= painter->lastmousepos[1] + dmousepos[1]*step; + step = (spacing - starttime) * len; + paintpos[0] = painter->lastmousepos[0] + dmousepos[0] * step; + paintpos[1] = painter->lastmousepos[1] + dmousepos[1] * step; if (painter->cache.enabled) brush_painter_refresh_cache(painter); totpaintops += func(user, painter->cache.ibuf, - painter->lastpaintpos, paintpos); + painter->lastpaintpos, paintpos); - painter->lastpaintpos[0]= paintpos[0]; - painter->lastpaintpos[1]= paintpos[1]; + painter->lastpaintpos[0] = paintpos[0]; + painter->lastpaintpos[1] = paintpos[1]; painter->accumtime -= spacing; starttime -= spacing; } - painter->lasttime= curtime; + painter->lasttime = curtime; } #endif else { float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; - const int radius= BKE_brush_size_get(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_pressure_apply(painter, brush, painter->lastpressure); - spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; + spacing = MAX2(1.0f, radius) * brush->spacing * 0.01f; /* setup starting distance, direction vector and accumulated distance */ - startdistance= painter->accumdistance; + startdistance = painter->accumdistance; sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); - len= normalize_v2(dmousepos); + len = normalize_v2(dmousepos); painter->accumdistance += len; if (brush->flag & BRUSH_SPACE) { /* do paint op over unpainted distance */ while ((len > 0.0f) && (painter->accumdistance >= spacing)) { - step= spacing - startdistance; - paintpos[0]= painter->lastmousepos[0] + dmousepos[0]*step; - paintpos[1]= painter->lastmousepos[1] + dmousepos[1]*step; + step = spacing - startdistance; + paintpos[0] = painter->lastmousepos[0] + dmousepos[0] * step; + paintpos[1] = painter->lastmousepos[1] + dmousepos[1] * step; - t = step/len; - press= (1.0f-t)*painter->lastpressure + t*pressure; + t = step / len; + press = (1.0f - t) * painter->lastpressure + t * pressure; brush_pressure_apply(painter, brush, press); - spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; + spacing = MAX2(1.0f, radius) * brush->spacing * 0.01f; BKE_brush_jitter_pos(scene, brush, paintpos, finalpos); @@ -1183,10 +1184,10 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p brush_painter_refresh_cache(painter, finalpos, use_color_correction); totpaintops += - func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos); + func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos); - painter->lastpaintpos[0]= paintpos[0]; - painter->lastpaintpos[1]= paintpos[1]; + painter->lastpaintpos[0] = paintpos[0]; + painter->lastpaintpos[1] = paintpos[1]; painter->accumdistance -= spacing; startdistance -= spacing; } @@ -1199,21 +1200,21 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p totpaintops += func(user, painter->cache.ibuf, pos, finalpos); - painter->lastpaintpos[0]= pos[0]; - painter->lastpaintpos[1]= pos[1]; - painter->accumdistance= 0; + painter->lastpaintpos[0] = pos[0]; + painter->lastpaintpos[1] = pos[1]; + painter->accumdistance = 0; } /* do airbrush paint ops, based on the number of paint ops left over * from regular painting. this is a temporary solution until we have * accurate time stamps for mouse move events */ if (brush->flag & BRUSH_AIRBRUSH) { - double curtime= time; - double painttime= brush->rate*totpaintops; + double curtime = time; + double painttime = brush->rate * totpaintops; painter->accumtime += curtime - painter->lasttime; if (painter->accumtime <= painttime) - painter->accumtime= 0.0; + painter->accumtime = 0.0; else painter->accumtime -= painttime; @@ -1226,17 +1227,17 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p brush_painter_refresh_cache(painter, finalpos, use_color_correction); totpaintops += - func(user, painter->cache.ibuf, painter->lastmousepos, finalpos); + func(user, painter->cache.ibuf, painter->lastmousepos, finalpos); painter->accumtime -= (double)brush->rate; } - painter->lasttime= curtime; + painter->lasttime = curtime; } } - painter->lastmousepos[0]= pos[0]; - painter->lastmousepos[1]= pos[1]; - painter->lastpressure= pressure; + painter->lastmousepos[0] = pos[0]; + painter->lastmousepos[1] = pos[1]; + painter->lastpressure = pressure; brush_alpha_set(scene, brush, painter->startalpha); BKE_brush_size_set(scene, brush, painter->startsize); @@ -1249,12 +1250,12 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p /* Uses the brush curve control to find a strength value between 0 and 1 */ float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) { - if (p >= len) return 0; - else p= p/len; + if (p >= len) return 0; + else p = p / len; - p= curvemapping_evaluateF(br->curve, 0, p); - if (p < 0.0f) p= 0.0f; - else if (p > 1.0f) p= 1.0f; + p = curvemapping_evaluateF(br->curve, 0, p); + if (p < 0.0f) p = 0.0f; + else if (p > 1.0f) p = 1.0f; return p; } /* same as above but can return negative values if the curve enables @@ -1262,9 +1263,9 @@ float BKE_brush_curve_strength_clamp(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; + p = 1.0f; else - p= p/len; + p = p / len; return curvemapping_evaluateF(br->curve, 0, p); } @@ -1274,7 +1275,7 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) { unsigned int *texcache = NULL; MTex *mtex = &br->mtex; - TexResult texres= {0}; + TexResult texres = {0}; int hasrgb, ix, iy; int side = half_side * 2; @@ -1286,11 +1287,11 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) BKE_image_get_ibuf(mtex->tex->ima, NULL); /*do normalized cannonical view coords for texture*/ - for (y=-1.0, iy=0; iytex, co, NULL, NULL, 0, &texres); @@ -1301,13 +1302,13 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) */ if (hasrgb & TEX_RGB) texres.tin = (0.35f * texres.tr + 0.45f * - texres.tg + 0.2f * texres.tb); + texres.tg + 0.2f * texres.tb); texres.tin = texres.tin * 255.0f; - ((char*)texcache)[(iy*side+ix)*4] = (char)texres.tin; - ((char*)texcache)[(iy*side+ix)*4+1] = (char)texres.tin; - ((char*)texcache)[(iy*side+ix)*4+2] = (char)texres.tin; - ((char*)texcache)[(iy*side+ix)*4+3] = (char)texres.tin; + ((char *)texcache)[(iy * side + ix) * 4] = (char)texres.tin; + ((char *)texcache)[(iy * side + ix) * 4 + 1] = (char)texres.tin; + ((char *)texcache)[(iy * side + ix) * 4 + 2] = (char)texres.tin; + ((char *)texcache)[(iy * side + ix) * 4 + 3] = (char)texres.tin; } } } @@ -1328,19 +1329,19 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br) 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]= BKE_brush_curve_strength_clamp(br, magn, half); + for (i = 0; i < side; ++i) { + for (j = 0; j < side; ++j) { + float magn = sqrt(pow(i - half, 2) + pow(j - half, 2)); + im->rect_float[i * side + j] = BKE_brush_curve_strength_clamp(br, magn, half); } } /* Modulate curve with texture */ if (texcache) { - for (i=0; irect_float[i*side+j]*= (((char*)&col)[0]+((char*)&col)[1]+((char*)&col)[2])/3.0f/255.0f; + for (i = 0; i < side; ++i) { + for (j = 0; j < side; ++j) { + const int col = texcache[i * side + j]; + im->rect_float[i * side + j] *= (((char *)&col)[0] + ((char *)&col)[1] + ((char *)&col)[2]) / 3.0f / 255.0f; } } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index efede6bbae7..e1cfcee1367 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -54,15 +54,15 @@ void *BKE_camera_add(const char *name) { Camera *cam; - cam= BKE_libblock_alloc(&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; - cam->sensor_y= 18.0f; - cam->clipsta= 0.1f; - cam->clipend= 100.0f; - cam->drawsize= 0.5f; - cam->ortho_scale= 6.0; + cam->lens = 35.0f; + cam->sensor_x = 32.0f; + cam->sensor_y = 18.0f; + cam->clipsta = 0.1f; + cam->clipend = 100.0f; + cam->drawsize = 0.5f; + cam->ortho_scale = 6.0; cam->flag |= CAM_SHOWPASSEPARTOUT; cam->passepartalpha = 0.5f; @@ -73,7 +73,7 @@ Camera *BKE_camera_copy(Camera *cam) { Camera *camn; - camn= BKE_libblock_copy(&cam->id); + camn = BKE_libblock_copy(&cam->id); id_lib_extern((ID *)camn->dof_ob); @@ -82,25 +82,25 @@ Camera *BKE_camera_copy(Camera *cam) void BKE_camera_make_local(Camera *cam) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (cam->id.lib==NULL) return; - if (cam->id.us==1) { + if (cam->id.lib == NULL) return; + if (cam->id.us == 1) { id_clear_lib_data(bmain, &cam->id); return; } - for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { - if (ob->data==cam) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { + if (ob->data == cam) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -108,17 +108,17 @@ void BKE_camera_make_local(Camera *cam) id_clear_lib_data(bmain, &cam->id); } else if (is_local && is_lib) { - Camera *cam_new= BKE_camera_copy(cam); + Camera *cam_new = BKE_camera_copy(cam); - cam_new->id.us= 0; + cam_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->data == cam) { - if (ob->id.lib==NULL) { - ob->data= cam_new; + if (ob->id.lib == NULL) { + ob->data = cam_new; cam_new->id.us++; cam->id.us--; } @@ -136,10 +136,10 @@ void BKE_camera_free(Camera *ca) void BKE_camera_object_mode(RenderData *rd, Object *cam_ob) { - rd->mode &= ~(R_ORTHO|R_PANORAMA); + rd->mode &= ~(R_ORTHO | R_PANORAMA); - if (cam_ob && cam_ob->type==OB_CAMERA) { - Camera *cam= cam_ob->data; + if (cam_ob && cam_ob->type == OB_CAMERA) { + Camera *cam = cam_ob->data; if (cam->type == CAM_ORTHO) rd->mode |= R_ORTHO; if (cam->type == CAM_PANO) rd->mode |= R_PANORAMA; } @@ -193,11 +193,11 @@ void BKE_camera_params_init(CameraParams *params) memset(params, 0, sizeof(CameraParams)); /* defaults */ - params->sensor_x= DEFAULT_SENSOR_WIDTH; - params->sensor_y= DEFAULT_SENSOR_HEIGHT; - params->sensor_fit= CAMERA_SENSOR_FIT_AUTO; + params->sensor_x = DEFAULT_SENSOR_WIDTH; + params->sensor_y = DEFAULT_SENSOR_HEIGHT; + params->sensor_fit = CAMERA_SENSOR_FIT_AUTO; - params->zoom= 1.0f; + params->zoom = 1.0f; } void BKE_camera_params_from_object(CameraParams *params, Object *ob) @@ -205,73 +205,73 @@ void BKE_camera_params_from_object(CameraParams *params, Object *ob) if (!ob) return; - if (ob->type==OB_CAMERA) { + if (ob->type == OB_CAMERA) { /* camera object */ - Camera *cam= ob->data; + Camera *cam = ob->data; if (cam->type == CAM_ORTHO) - params->is_ortho= TRUE; - params->lens= cam->lens; - params->ortho_scale= cam->ortho_scale; + params->is_ortho = TRUE; + params->lens = cam->lens; + params->ortho_scale = cam->ortho_scale; - params->shiftx= cam->shiftx; - params->shifty= cam->shifty; + params->shiftx = cam->shiftx; + params->shifty = cam->shifty; - params->sensor_x= cam->sensor_x; - params->sensor_y= cam->sensor_y; - params->sensor_fit= cam->sensor_fit; + params->sensor_x = cam->sensor_x; + params->sensor_y = cam->sensor_y; + params->sensor_fit = cam->sensor_fit; - params->clipsta= cam->clipsta; - params->clipend= cam->clipend; + params->clipsta = cam->clipsta; + params->clipend = cam->clipend; } - else if (ob->type==OB_LAMP) { + else if (ob->type == OB_LAMP) { /* lamp object */ - Lamp *la= ob->data; - float fac= cosf((float)M_PI*la->spotsize/360.0f); - float phi= acos(fac); + Lamp *la = ob->data; + float fac = cosf((float)M_PI * la->spotsize / 360.0f); + float phi = acos(fac); - params->lens= 16.0f*fac/sinf(phi); - if (params->lens==0.0f) - params->lens= 35.0f; + params->lens = 16.0f * fac / sinf(phi); + if (params->lens == 0.0f) + params->lens = 35.0f; - params->clipsta= la->clipsta; - params->clipend= la->clipend; + params->clipsta = la->clipsta; + params->clipend = la->clipend; } } void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d) { /* common */ - params->lens= v3d->lens; - params->clipsta= v3d->near; - params->clipend= v3d->far; + params->lens = v3d->lens; + params->clipsta = v3d->near; + params->clipend = v3d->far; - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp == RV3D_CAMOB) { /* camera view */ BKE_camera_params_from_object(params, v3d->camera); - params->zoom= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); + params->zoom = BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); - params->offsetx= 2.0f*rv3d->camdx*params->zoom; - params->offsety= 2.0f*rv3d->camdy*params->zoom; + params->offsetx = 2.0f * rv3d->camdx * params->zoom; + params->offsety = 2.0f * rv3d->camdy * params->zoom; params->shiftx *= params->zoom; params->shifty *= params->zoom; - params->zoom= 1.0f/params->zoom; + params->zoom = 1.0f / params->zoom; } - else if (rv3d->persp==RV3D_ORTHO) { + else if (rv3d->persp == RV3D_ORTHO) { /* orthographic view */ - params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality - params->clipsta= - params->clipend; + params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality + params->clipsta = -params->clipend; - params->is_ortho= TRUE; + params->is_ortho = TRUE; params->ortho_scale = rv3d->dist; - params->zoom= 2.0f; + params->zoom = 2.0f; } else { /* perspective view */ - params->zoom= 2.0f; + params->zoom = 2.0f; } } @@ -282,28 +282,28 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win int sensor_fit; /* fields rendering */ - params->ycor= yasp/xasp; + params->ycor = yasp / xasp; if (params->use_fields) params->ycor *= 2.0f; if (params->is_ortho) { /* orthographic camera */ /* scale == 1.0 means exact 1 to 1 mapping */ - pixsize= params->ortho_scale; + pixsize = params->ortho_scale; } else { /* perspective camera */ - sensor_size= BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); - pixsize= (sensor_size * params->clipsta)/params->lens; + 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 = BKE_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; + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) + viewfac = winx; else - viewfac= params->ycor * winy; + viewfac = params->ycor * winy; pixsize /= viewfac; @@ -312,14 +312,14 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win /* compute view plane: * fully centered, zbuffer fills in jittered between -.5 and +.5 */ - viewplane.xmin = -0.5f*(float)winx; - viewplane.ymin = -0.5f*params->ycor*(float)winy; - viewplane.xmax = 0.5f*(float)winx; - viewplane.ymax = 0.5f*params->ycor*(float)winy; + viewplane.xmin = -0.5f * (float)winx; + viewplane.ymin = -0.5f * params->ycor * (float)winy; + viewplane.xmax = 0.5f * (float)winx; + viewplane.ymax = 0.5f * params->ycor * (float)winy; /* lens shift and offset */ - dx= params->shiftx*viewfac + winx*params->offsetx; - dy= params->shifty*viewfac + winy*params->offsety; + dx = params->shiftx * viewfac + winx * params->offsetx; + dy = params->shifty * viewfac + winy * params->offsety; viewplane.xmin += dx; viewplane.ymin += dy; @@ -329,12 +329,12 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win /* fields offset */ if (params->field_second) { if (params->field_odd) { - viewplane.ymin-= 0.5f * params->ycor; - viewplane.ymax-= 0.5f * params->ycor; + viewplane.ymin -= 0.5f * params->ycor; + viewplane.ymax -= 0.5f * params->ycor; } else { - viewplane.ymin+= 0.5f * params->ycor; - viewplane.ymax+= 0.5f * params->ycor; + viewplane.ymin += 0.5f * params->ycor; + viewplane.ymax += 0.5f * params->ycor; } } @@ -345,9 +345,9 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win viewplane.ymin *= pixsize; viewplane.ymax *= pixsize; - params->viewdx= pixsize; - params->viewdy= params->ycor * pixsize; - params->viewplane= viewplane; + params->viewdx = pixsize; + params->viewdy = params->ycor * pixsize; + params->viewplane = viewplane; } /* viewplane is assumed to be already computed */ @@ -374,61 +374,61 @@ void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, cons /* aspect correcton */ if (scene) { - float aspx= (float) scene->r.xsch*scene->r.xasp; - float aspy= (float) scene->r.ysch*scene->r.yasp; - int sensor_fit= BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy); + float aspx = (float) scene->r.xsch * scene->r.xasp; + float aspy = (float) scene->r.ysch * scene->r.yasp; + int sensor_fit = BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy); - if (sensor_fit==CAMERA_SENSOR_FIT_HOR) { - r_asp[0]= 1.0; - r_asp[1]= aspy / aspx; + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { + r_asp[0] = 1.0; + r_asp[1] = aspy / aspx; } else { - r_asp[0]= aspx / aspy; - r_asp[1]= 1.0; + r_asp[0] = aspx / aspy; + r_asp[1] = 1.0; } } else { - r_asp[0]= 1.0f; - r_asp[1]= 1.0f; + r_asp[0] = 1.0f; + r_asp[1] = 1.0f; } - if (camera->type==CAM_ORTHO) { - facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0]; - facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1]; - r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0]; - r_shift[1]= camera->shifty * camera->ortho_scale * scale[1]; - depth= do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : - drawsize * camera->ortho_scale * scale[2]; + if (camera->type == CAM_ORTHO) { + facx = 0.5f * camera->ortho_scale * r_asp[0] * scale[0]; + facy = 0.5f * camera->ortho_scale * r_asp[1] * scale[1]; + r_shift[0] = camera->shiftx * camera->ortho_scale * scale[0]; + r_shift[1] = camera->shifty * camera->ortho_scale * scale[1]; + depth = do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : -drawsize * camera->ortho_scale * scale[2]; - *r_drawsize= 0.5f * camera->ortho_scale; + *r_drawsize = 0.5f * camera->ortho_scale; } else { /* that way it's always visible - clipsta+0.1 */ float fac; - float half_sensor= 0.5f*((camera->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x)); + float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x)); - *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); + *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); if (do_clip) { /* fixed depth, variable size (avoids exceeding clipping range) */ depth = -(camera->clipsta + 0.1f); - fac = depth / (camera->lens/(-half_sensor) * scale[2]); + fac = depth / (camera->lens / (-half_sensor) * scale[2]); } else { /* fixed size, variable depth (stays a reasonable size in the 3D view) */ - depth= *r_drawsize * camera->lens/(-half_sensor) * scale[2]; - fac= *r_drawsize; + depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2]; + fac = *r_drawsize; } - facx= fac * r_asp[0] * scale[0]; - facy= fac * r_asp[1] * scale[1]; - r_shift[0]= camera->shiftx*fac*2 * scale[0]; - r_shift[1]= camera->shifty*fac*2 * scale[1]; + facx = fac * r_asp[0] * scale[0]; + facy = fac * r_asp[1] * scale[1]; + r_shift[0] = camera->shiftx * fac * 2 * scale[0]; + r_shift[1] = camera->shifty * fac * 2 * scale[1]; } - r_vec[0][0]= r_shift[0] + facx; r_vec[0][1]= r_shift[1] + facy; r_vec[0][2]= depth; - r_vec[1][0]= r_shift[0] + facx; r_vec[1][1]= r_shift[1] - facy; r_vec[1][2]= depth; - r_vec[2][0]= r_shift[0] - facx; r_vec[2][1]= r_shift[1] - facy; r_vec[2][2]= depth; - r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth; + r_vec[0][0] = r_shift[0] + facx; r_vec[0][1] = r_shift[1] + facy; r_vec[0][2] = depth; + r_vec[1][0] = r_shift[0] + facx; r_vec[1][1] = r_shift[1] - facy; r_vec[1][2] = depth; + r_vec[2][0] = r_shift[0] - facx; r_vec[2][1] = r_shift[1] - facy; r_vec[2][2] = depth; + r_vec[3][0] = r_shift[0] - facx; r_vec[3][1] = r_shift[1] + facy; r_vec[3][2] = depth; } void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) @@ -436,10 +436,10 @@ 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}; + const float dummy_scale[3] = {1.0f, 1.0f, 1.0f}; BKE_camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, - dummy_asp, dummy_shift, &dummy_drawsize, r_vec); + dummy_asp, dummy_shift, &dummy_drawsize, r_vec); } @@ -452,13 +452,13 @@ typedef struct CameraViewFrameData { static void BKE_camera_to_frame_view_cb(const float co[3], void *user_data) { - CameraViewFrameData *data= (CameraViewFrameData *)user_data; + CameraViewFrameData *data = (CameraViewFrameData *)user_data; unsigned int i; - for (i= 0; i < 4; i++) { - float nd= dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]); + for (i = 0; i < 4; i++) { + float nd = dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]); if (nd < data->dist_vals[i]) { - data->dist_vals[i]= nd; + data->dist_vals[i] = nd; } } @@ -472,7 +472,7 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object float shift[2]; float plane_tx[4][3]; float rot_obmat[3][3]; - const float zero[3]= {0, 0, 0}; + const float zero[3] = {0, 0, 0}; CameraViewFrameData data_cb; unsigned int i; @@ -482,36 +482,36 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object copy_m3_m4(rot_obmat, camera_ob->obmat); normalize_m3(rot_obmat); - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { /* normalize so Z is always 1.0f*/ - mul_v3_fl(data_cb.frame_tx[i], 1.0f/data_cb.frame_tx[i][2]); + mul_v3_fl(data_cb.frame_tx[i], 1.0f / data_cb.frame_tx[i][2]); } /* get the shift back out of the frame */ - shift[0]= (data_cb.frame_tx[0][0] + - data_cb.frame_tx[1][0] + - data_cb.frame_tx[2][0] + - data_cb.frame_tx[3][0]) / 4.0f; - shift[1]= (data_cb.frame_tx[0][1] + - data_cb.frame_tx[1][1] + - data_cb.frame_tx[2][1] + - data_cb.frame_tx[3][1]) / 4.0f; + shift[0] = (data_cb.frame_tx[0][0] + + data_cb.frame_tx[1][0] + + data_cb.frame_tx[2][0] + + data_cb.frame_tx[3][0]) / 4.0f; + shift[1] = (data_cb.frame_tx[0][1] + + data_cb.frame_tx[1][1] + + data_cb.frame_tx[2][1] + + data_cb.frame_tx[3][1]) / 4.0f; - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { mul_m3_v3(rot_obmat, data_cb.frame_tx[i]); } - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { normal_tri_v3(data_cb.normal_tx[i], zero, data_cb.frame_tx[i], data_cb.frame_tx[(i + 1) % 4]); } /* initialize callback data */ - data_cb.dist_vals[0]= - data_cb.dist_vals[1]= - data_cb.dist_vals[2]= - data_cb.dist_vals[3]= FLT_MAX; - data_cb.tot= 0; + data_cb.dist_vals[0] = + data_cb.dist_vals[1] = + data_cb.dist_vals[2] = + data_cb.dist_vals[3] = FLT_MAX; + data_cb.tot = 0; /* run callback on all visible points */ BKE_scene_foreach_display_point(scene, v3d, BA_SELECT, BKE_camera_to_frame_view_cb, &data_cb); @@ -526,7 +526,7 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object float plane_isect_pt_1[3], plane_isect_pt_2[3]; /* apply the dist-from-plane's to the transformed plane points */ - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { mul_v3_v3fl(plane_tx[i], data_cb.normal_tx[i], data_cb.dist_vals[i]); } @@ -547,14 +547,14 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object return FALSE; } else { - float cam_plane_no[3]= {0.0f, 0.0f, -1.0f}; + float cam_plane_no[3] = {0.0f, 0.0f, -1.0f}; float plane_isect_delta[3]; float plane_isect_delta_len; mul_m3_v3(rot_obmat, cam_plane_no); sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1); - plane_isect_delta_len= len_v3(plane_isect_delta); + plane_isect_delta_len = len_v3(plane_isect_delta); if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) { copy_v3_v3(r_co, plane_isect_pt_1); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 0f12b79e05d..190d9f654f6 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -74,31 +74,31 @@ void BKE_curve_unlink(Curve *cu) { int a; - for (a=0; atotcol; a++) { + for (a = 0; a < cu->totcol; a++) { if (cu->mat[a]) cu->mat[a]->id.us--; - cu->mat[a]= NULL; + cu->mat[a] = NULL; } if (cu->vfont) cu->vfont->id.us--; - cu->vfont= NULL; + cu->vfont = NULL; if (cu->vfontb) cu->vfontb->id.us--; - cu->vfontb= NULL; + cu->vfontb = NULL; if (cu->vfonti) cu->vfonti->id.us--; - cu->vfonti= NULL; + cu->vfonti = NULL; if (cu->vfontbi) cu->vfontbi->id.us--; - cu->vfontbi= NULL; + cu->vfontbi = NULL; if (cu->key) cu->key->id.us--; - cu->key= NULL; + cu->key = NULL; } /* frees editcurve entirely */ void BKE_curve_editfont_free(Curve *cu) { if (cu->editfont) { - EditFont *ef= cu->editfont; + EditFont *ef = cu->editfont; if (ef->oldstr) MEM_freeN(ef->oldstr); if (ef->oldstrinfo) MEM_freeN(ef->oldstrinfo); @@ -108,7 +108,7 @@ void BKE_curve_editfont_free(Curve *cu) if (ef->copybufinfo) MEM_freeN(ef->copybufinfo); MEM_freeN(ef); - cu->editfont= NULL; + cu->editfont = NULL; } } @@ -118,7 +118,7 @@ void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb) return; } BLI_ghash_free(editnurb->keyindex, NULL, (GHashValFreeFP)MEM_freeN); - editnurb->keyindex= NULL; + editnurb->keyindex = NULL; } void BKE_curve_editNurb_free(Curve *cu) @@ -127,7 +127,7 @@ void BKE_curve_editNurb_free(Curve *cu) BKE_nurbList_free(&cu->editnurb->nurbs); BKE_curve_editNurb_keyIndex_free(cu->editnurb); MEM_freeN(cu->editnurb); - cu->editnurb= NULL; + cu->editnurb = NULL; } } @@ -157,32 +157,32 @@ Curve *BKE_curve_add(const char *name, int type) 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; - cu->resolu= cu->resolv= (type == OB_SURF) ? 4 : 12; - cu->width= 1.0; + cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS; + cu->pathlen = 100; + cu->resolu = cu->resolv = (type == OB_SURF) ? 4 : 12; + cu->width = 1.0; cu->wordspace = 1.0; - cu->spacing= cu->linedist= 1.0; - cu->fsize= 1.0; + cu->spacing = cu->linedist = 1.0; + cu->fsize = 1.0; cu->ulheight = 0.05; - cu->texflag= CU_AUTOSPACE; - 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= BKE_boundbox_alloc_unit(); - - if (type==OB_FONT) { - cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= BKE_vfont_builtin_get(); - cu->vfont->id.us+=4; - cu->str= MEM_mallocN(12, "str"); + cu->texflag = CU_AUTOSPACE; + 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 = BKE_boundbox_alloc_unit(); + + if (type == OB_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); - cu->len= cu->pos= 4; - cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo new"); - cu->totbox= cu->actbox= 1; - cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox"); + cu->len = cu->pos = 4; + cu->strinfo = MEM_callocN(12 * sizeof(CharInfo), "strinfo new"); + cu->totbox = cu->actbox = 1; + cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "textbox"); cu->tb[0].w = cu->tb[0].h = 0.0; } @@ -194,34 +194,34 @@ Curve *BKE_curve_copy(Curve *cu) Curve *cun; int a; - cun= BKE_libblock_copy(&cu->id); - cun->nurb.first= cun->nurb.last= NULL; + cun = BKE_libblock_copy(&cu->id); + cun->nurb.first = cun->nurb.last = NULL; BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); - cun->mat= MEM_dupallocN(cu->mat); - for (a=0; atotcol; a++) { + cun->mat = MEM_dupallocN(cu->mat); + for (a = 0; a < cun->totcol; a++) { id_us_plus((ID *)cun->mat[a]); } - cun->str= MEM_dupallocN(cu->str); - cun->strinfo= MEM_dupallocN(cu->strinfo); - cun->tb= MEM_dupallocN(cu->tb); - cun->bb= MEM_dupallocN(cu->bb); - - cun->key= BKE_key_copy(cu->key); - if (cun->key) cun->key->from= (ID *)cun; - - cun->disp.first= cun->disp.last= NULL; - cun->bev.first= cun->bev.last= NULL; - cun->path= NULL; + cun->str = MEM_dupallocN(cu->str); + cun->strinfo = MEM_dupallocN(cu->strinfo); + cun->tb = MEM_dupallocN(cu->tb); + cun->bb = MEM_dupallocN(cu->bb); - cun->editnurb= NULL; - cun->editfont= NULL; - cun->selboxes= NULL; + cun->key = BKE_key_copy(cu->key); + if (cun->key) cun->key->from = (ID *)cun; -#if 0 // XXX old animation system + cun->disp.first = cun->disp.last = NULL; + cun->bev.first = cun->bev.last = NULL; + cun->path = NULL; + + cun->editnurb = NULL; + cun->editfont = NULL; + cun->selboxes = NULL; + +#if 0 // XXX old animation system /* single user ipo too */ - if (cun->ipo) cun->ipo= copy_ipo(cun->ipo); + if (cun->ipo) cun->ipo = copy_ipo(cun->ipo); #endif // XXX old animation system id_us_plus((ID *)cun->vfont); @@ -246,27 +246,27 @@ static void extern_local_curve(Curve *cu) void BKE_curve_make_local(Curve *cu) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - when there are only lib users: don't do * - when there are only local users: set flag * - mixed: do a copy */ - if (cu->id.lib==NULL) return; + if (cu->id.lib == NULL) return; - if (cu->id.us==1) { + if (cu->id.us == 1) { id_clear_lib_data(bmain, &cu->id); extern_local_curve(cu); return; } - for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { if (ob->data == cu) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -275,15 +275,15 @@ void BKE_curve_make_local(Curve *cu) extern_local_curve(cu); } else if (is_local && is_lib) { - Curve *cu_new= BKE_curve_copy(cu); - cu_new->id.us= 0; + Curve *cu_new = BKE_curve_copy(cu); + cu_new->id.us = 0; BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { - if (ob->data==cu) { - if (ob->id.lib==NULL) { - ob->data= cu_new; + for (ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->data == cu) { + if (ob->id.lib == NULL) { + ob->data = cu_new; cu_new->id.us++; cu->id.us--; } @@ -305,18 +305,18 @@ ListBase *BKE_curve_editNurbs_get(Curve *cu) short BKE_curve_type_get(Curve *cu) { Nurb *nu; - int type= cu->type; + int type = cu->type; if (cu->vfont) { return OB_FONT; } if (!cu->type) { - type= OB_CURVE; + type = OB_CURVE; - for (nu= cu->nurb.first; nu; nu= nu->next) { - if (nu->pntsv>1) { - type= OB_SURF; + for (nu = cu->nurb.first; nu; nu = nu->next) { + if (nu->pntsv > 1) { + type = OB_SURF; } } } @@ -326,16 +326,16 @@ short BKE_curve_type_get(Curve *cu) void BKE_curve_curve_dimension_update(Curve *cu) { - ListBase *nurbs= BKE_curve_nurbs_get(cu); - Nurb *nu= nurbs->first; + ListBase *nurbs = BKE_curve_nurbs_get(cu); + Nurb *nu = nurbs->first; - if (cu->flag&CU_3D) { - for ( ; nu; nu= nu->next) { + if (cu->flag & CU_3D) { + for (; nu; nu = nu->next) { nu->flag &= ~CU_2D; } } else { - for ( ; nu; nu= nu->next) { + for (; nu; nu = nu->next) { nu->flag |= CU_2D; BKE_nurb_test2D(nu); @@ -348,9 +348,9 @@ void BKE_curve_curve_dimension_update(Curve *cu) void BKE_curve_type_test(Object *ob) { - ob->type= BKE_curve_type_get(ob->data); + ob->type = BKE_curve_type_get(ob->data); - if (ob->type==OB_CURVE) + if (ob->type == OB_CURVE) BKE_curve_curve_dimension_update((Curve *)ob->data); } @@ -359,25 +359,25 @@ void BKE_curve_texspace_calc(Curve *cu) DispList *dl; BoundBox *bb; float *fp, min[3], max[3]; - int tot, doit= 0; + int tot, doit = 0; - if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= cu->bb; + if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = cu->bb; INIT_MINMAX(min, max); - dl= cu->disp.first; + dl = cu->disp.first; while (dl) { tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts; - if (tot) doit= 1; - fp= dl->verts; + if (tot) doit = 1; + fp = dl->verts; while (tot--) { DO_MINMAX(fp, min, max); fp += 3; } - dl= dl->next; + dl = dl->next; } if (!doit) { @@ -389,23 +389,23 @@ void BKE_curve_texspace_calc(Curve *cu) if (cu->texflag & CU_AUTOSPACE) { mid_v3_v3v3(cu->loc, min, max); - cu->size[0]= (max[0]-min[0])/2.0f; - cu->size[1]= (max[1]-min[1])/2.0f; - cu->size[2]= (max[2]-min[2])/2.0f; + cu->size[0] = (max[0] - min[0]) / 2.0f; + cu->size[1] = (max[1] - min[1]) / 2.0f; + cu->size[2] = (max[2] - min[2]) / 2.0f; zero_v3(cu->rot); - if (cu->size[0]==0.0f) cu->size[0]= 1.0f; - else if (cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f; - else if (cu->size[0]<0.0f && cu->size[0]> -0.00001f) cu->size[0]= -0.00001f; - - if (cu->size[1]==0.0f) cu->size[1]= 1.0f; - else if (cu->size[1]>0.0f && cu->size[1]<0.00001f) cu->size[1]= 0.00001f; - else if (cu->size[1]<0.0f && cu->size[1]> -0.00001f) cu->size[1]= -0.00001f; - - if (cu->size[2]==0.0f) cu->size[2]= 1.0f; - else if (cu->size[2]>0.0f && cu->size[2]<0.00001f) cu->size[2]= 0.00001f; - else if (cu->size[2]<0.0f && cu->size[2]> -0.00001f) cu->size[2]= -0.00001f; + if (cu->size[0] == 0.0f) cu->size[0] = 1.0f; + else if (cu->size[0] > 0.0f && cu->size[0] < 0.00001f) cu->size[0] = 0.00001f; + else if (cu->size[0] < 0.0f && cu->size[0] > -0.00001f) cu->size[0] = -0.00001f; + + if (cu->size[1] == 0.0f) cu->size[1] = 1.0f; + else if (cu->size[1] > 0.0f && cu->size[1] < 0.00001f) cu->size[1] = 0.00001f; + else if (cu->size[1] < 0.0f && cu->size[1] > -0.00001f) cu->size[1] = -0.00001f; + + if (cu->size[2] == 0.0f) cu->size[2] = 1.0f; + else if (cu->size[2] > 0.0f && cu->size[2] < 0.00001f) cu->size[2] = 0.00001f; + else if (cu->size[2] < 0.0f && cu->size[2] > -0.00001f) cu->size[2] = -0.00001f; } } @@ -413,14 +413,14 @@ void BKE_curve_texspace_calc(Curve *cu) int BKE_nurbList_verts_count(ListBase *nurb) { Nurb *nu; - int tot=0; + int tot = 0; - nu= nurb->first; + nu = nurb->first; while (nu) { - if (nu->bezt) tot+= 3*nu->pntsu; - else if (nu->bp) tot+= nu->pntsu*nu->pntsv; + if (nu->bezt) tot += 3 * nu->pntsu; + else if (nu->bp) tot += nu->pntsu * nu->pntsv; - nu= nu->next; + nu = nu->next; } return tot; } @@ -428,14 +428,14 @@ int BKE_nurbList_verts_count(ListBase *nurb) int BKE_nurbList_verts_count_without_handles(ListBase *nurb) { Nurb *nu; - int tot=0; + int tot = 0; - nu= nurb->first; + nu = nurb->first; while (nu) { - if (nu->bezt) tot+= nu->pntsu; - else if (nu->bp) tot+= nu->pntsu*nu->pntsv; + if (nu->bezt) tot += nu->pntsu; + else if (nu->bp) tot += nu->pntsu * nu->pntsv; - nu= nu->next; + nu = nu->next; } return tot; } @@ -445,16 +445,16 @@ int BKE_nurbList_verts_count_without_handles(ListBase *nurb) void BKE_nurb_free(Nurb *nu) { - if (nu==NULL) return; + if (nu == NULL) return; if (nu->bezt) MEM_freeN(nu->bezt); - nu->bezt= NULL; + nu->bezt = NULL; if (nu->bp) MEM_freeN(nu->bp); - nu->bp= NULL; + nu->bp = NULL; if (nu->knotsu) MEM_freeN(nu->knotsu); - nu->knotsu= NULL; + nu->knotsu = NULL; if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv= NULL; + nu->knotsv = NULL; /* if (nu->trim.first) freeNurblist(&(nu->trim)); */ MEM_freeN(nu); @@ -466,15 +466,15 @@ void BKE_nurbList_free(ListBase *lb) { Nurb *nu, *next; - if (lb==NULL) return; + if (lb == NULL) return; - nu= lb->first; + nu = lb->first; while (nu) { - next= nu->next; + next = nu->next; BKE_nurb_free(nu); - nu= next; + nu = next; } - lb->first= lb->last= NULL; + lb->first = lb->last = NULL; } Nurb *BKE_nurb_duplicate(Nurb *nu) @@ -482,35 +482,35 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) Nurb *newnu; int len; - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "duplicateNurb"); - if (newnu==NULL) return NULL; + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "duplicateNurb"); + if (newnu == NULL) return NULL; memcpy(newnu, nu, sizeof(Nurb)); if (nu->bezt) { - newnu->bezt= - (BezTriple*)MEM_mallocN((nu->pntsu)* sizeof(BezTriple), "duplicateNurb2"); - memcpy(newnu->bezt, nu->bezt, nu->pntsu*sizeof(BezTriple)); + newnu->bezt = + (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "duplicateNurb2"); + memcpy(newnu->bezt, nu->bezt, nu->pntsu * sizeof(BezTriple)); } else { - len= nu->pntsu*nu->pntsv; - newnu->bp= - (BPoint*)MEM_mallocN((len)* sizeof(BPoint), "duplicateNurb3"); - memcpy(newnu->bp, nu->bp, len*sizeof(BPoint)); + len = nu->pntsu * nu->pntsv; + newnu->bp = + (BPoint *)MEM_mallocN((len) * sizeof(BPoint), "duplicateNurb3"); + memcpy(newnu->bp, nu->bp, len * sizeof(BPoint)); - newnu->knotsu= newnu->knotsv= NULL; + newnu->knotsu = newnu->knotsv = NULL; if (nu->knotsu) { - len= KNOTSU(nu); + len = KNOTSU(nu); if (len) { - newnu->knotsu= MEM_mallocN(len*sizeof(float), "duplicateNurb4"); - memcpy(newnu->knotsu, nu->knotsu, sizeof(float)*len); + newnu->knotsu = MEM_mallocN(len * sizeof(float), "duplicateNurb4"); + memcpy(newnu->knotsu, nu->knotsu, sizeof(float) * len); } } - if (nu->pntsv>1 && nu->knotsv) { - len= KNOTSV(nu); + if (nu->pntsv > 1 && nu->knotsv) { + len = KNOTSV(nu); if (len) { - newnu->knotsv= MEM_mallocN(len*sizeof(float), "duplicateNurb5"); - memcpy(newnu->knotsv, nu->knotsv, sizeof(float)*len); + newnu->knotsv = MEM_mallocN(len * sizeof(float), "duplicateNurb5"); + memcpy(newnu->knotsv, nu->knotsv, sizeof(float) * len); } } } @@ -523,12 +523,12 @@ void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2) BKE_nurbList_free(lb1); - nu= lb2->first; + nu = lb2->first; while (nu) { - nun= BKE_nurb_duplicate(nu); + nun = BKE_nurb_duplicate(nu); BLI_addtail(lb1, nun); - nu= nu->next; + nu = nu->next; } } @@ -538,24 +538,24 @@ void BKE_nurb_test2D(Nurb *nu) BPoint *bp; int a; - if ((nu->flag & CU_2D)==0) + if ((nu->flag & CU_2D) == 0) return; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - bezt->vec[0][2]= 0.0; - bezt->vec[1][2]= 0.0; - bezt->vec[2][2]= 0.0; + bezt->vec[0][2] = 0.0; + bezt->vec[1][2] = 0.0; + bezt->vec[2][2] = 0.0; bezt++; } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - bp->vec[2]= 0.0; + bp->vec[2] = 0.0; bp++; } } @@ -568,8 +568,8 @@ void BKE_nurb_minmax(Nurb *nu, float *min, float *max) int a; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { DO_MINMAX(bezt->vec[0], min, max); DO_MINMAX(bezt->vec[1], min, max); @@ -578,8 +578,8 @@ void BKE_nurb_minmax(Nurb *nu, float *min, float *max) } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { DO_MINMAX(bp->vec, min, max); bp++; @@ -590,9 +590,9 @@ void BKE_nurb_minmax(Nurb *nu, float *min, float *max) /* be sure to call makeknots after this */ void BKE_nurb_points_add(Nurb *nu, int number) { - BPoint *tmp= nu->bp; + BPoint *tmp = nu->bp; int i; - nu->bp= (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add"); + nu->bp = (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add"); if (tmp) { memmove(nu->bp, tmp, nu->pntsu * sizeof(BPoint)); @@ -601,8 +601,8 @@ void BKE_nurb_points_add(Nurb *nu, int number) memset(nu->bp + nu->pntsu, 0, number * sizeof(BPoint)); - for (i=0, tmp= nu->bp + nu->pntsu; i < number; i++, tmp++) { - tmp->radius= 1.0f; + for (i = 0, tmp = nu->bp + nu->pntsu; i < number; i++, tmp++) { + tmp->radius = 1.0f; } nu->pntsu += number; @@ -610,9 +610,9 @@ void BKE_nurb_points_add(Nurb *nu, int number) void BKE_nurb_bezierPoints_add(Nurb *nu, int number) { - BezTriple *tmp= nu->bezt; + BezTriple *tmp = nu->bezt; int i; - nu->bezt= (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add"); + nu->bezt = (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add"); if (tmp) { memmove(nu->bezt, tmp, nu->pntsu * sizeof(BezTriple)); @@ -621,8 +621,8 @@ void BKE_nurb_bezierPoints_add(Nurb *nu, int number) memset(nu->bezt + nu->pntsu, 0, number * sizeof(BezTriple)); - for (i=0, tmp= nu->bezt + nu->pntsu; i < number; i++, tmp++) { - tmp->radius= 1.0f; + for (i = 0, tmp = nu->bezt + nu->pntsu; i < number; i++, tmp++) { + tmp->radius = 1.0f; } nu->pntsu += number; @@ -634,44 +634,44 @@ void BKE_nurb_bezierPoints_add(Nurb *nu, int number) static void calcknots(float *knots, const short pnts, const short order, const short flag) { /* knots: number of pnts NOT corrected for cyclic */ - const int pnts_order= pnts + order; + const int pnts_order = pnts + order; float k; int a; - switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) { - case CU_NURB_ENDPOINT: - k= 0.0; - for (a=1; a <= pnts_order; a++) { - knots[a-1]= k; - if (a >= order && a <= pnts) k+= 1.0f; - } - break; - case CU_NURB_BEZIER: - /* Warning, the order MUST be 2 or 4, - * if this is not enforced, the displist will be corrupt */ - if (order==4) { - k= 0.34; - for (a=0; a < pnts_order; a++) { - knots[a]= floorf(k); - k+= (1.0f/3.0f); + switch (flag & (CU_NURB_ENDPOINT | CU_NURB_BEZIER)) { + case CU_NURB_ENDPOINT: + k = 0.0; + for (a = 1; a <= pnts_order; a++) { + knots[a - 1] = k; + if (a >= order && a <= pnts) k += 1.0f; } - } - else if (order==3) { - k= 0.6f; - for (a=0; a < pnts_order; a++) { - if (a >= order && a <= pnts) k+= 0.5f; - knots[a]= floorf(k); + break; + case CU_NURB_BEZIER: + /* Warning, the order MUST be 2 or 4, + * if this is not enforced, the displist will be corrupt */ + if (order == 4) { + k = 0.34; + for (a = 0; a < pnts_order; a++) { + knots[a] = floorf(k); + k += (1.0f / 3.0f); + } } - } - else { - printf("bez nurb curve order is not 3 or 4, should never happen\n"); - } - break; - default: - for (a=0; a < pnts_order; a++) { - knots[a]= (float)a; - } - break; + else if (order == 3) { + k = 0.6f; + for (a = 0; a < pnts_order; a++) { + if (a >= order && a <= pnts) k += 0.5f; + knots[a] = floorf(k); + } + } + else { + printf("bez nurb curve order is not 3 or 4, should never happen\n"); + } + break; + default: + for (a = 0; a < pnts_order; a++) { + knots[a] = (float)a; + } + break; } } @@ -680,23 +680,23 @@ static void makecyclicknots(float *knots, short pnts, short order) { int a, b, order2, c; - if (knots==NULL) return; + if (knots == NULL) return; - order2=order-1; + order2 = order - 1; /* do first long rows (order -1), remove identical knots at endpoints */ - if (order>2) { - b= pnts+order2; - for (a=1; a 2) { + b = pnts + order2; + for (a = 1; a < order2; a++) { + if (knots[b] != knots[b - a]) break; } - if (a==order2) knots[pnts+order-2]+= 1.0f; + if (a == order2) knots[pnts + order - 2] += 1.0f; } - b= order; - c=pnts + order + order2; - for (a=pnts+order2; aknotsu) MEM_freeN(nu->knotsu); if (BKE_nurb_check_valid_u(nu)) { - nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots"); + nu->knotsu = MEM_callocN(4 + sizeof(float) * KNOTSU(nu), "makeknots"); if (nu->flagu & CU_NURB_CYCLIC) { calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu); @@ -718,13 +718,13 @@ static void makeknots(Nurb *nu, short uv) calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu); } } - else nu->knotsu= NULL; + else nu->knotsu = NULL; } else if (uv == 2) { if (nu->knotsv) MEM_freeN(nu->knotsv); if (BKE_nurb_check_valid_v(nu)) { - nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots"); + nu->knotsv = MEM_callocN(4 + sizeof(float) * KNOTSV(nu), "makeknots"); if (nu->flagv & CU_NURB_CYCLIC) { calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv); @@ -733,7 +733,7 @@ static void makeknots(Nurb *nu, short uv) calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv); } } - else nu->knotsv= NULL; + else nu->knotsv = NULL; } } } @@ -753,59 +753,59 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas float d, e; int i, i1 = 0, i2 = 0, j, orderpluspnts, opp2, o2; - orderpluspnts= order+pnts; - opp2 = orderpluspnts-1; + orderpluspnts = order + pnts; + opp2 = orderpluspnts - 1; /* this is for float inaccuracy */ - if (t < knots[0]) t= knots[0]; - else if (t > knots[opp2]) t= knots[opp2]; + if (t < knots[0]) t = knots[0]; + else if (t > knots[opp2]) t = knots[opp2]; /* this part is order '1' */ - o2 = order + 1; - for (i=0;i= knots[i] && t<=knots[i+1]) { - basis[i]= 1.0; - i1= i-o2; - if (i1<0) i1= 0; - i2= i; + o2 = order + 1; + for (i = 0; i < opp2; i++) { + if (knots[i] != knots[i + 1] && t >= knots[i] && t <= knots[i + 1]) { + basis[i] = 1.0; + i1 = i - o2; + if (i1 < 0) i1 = 0; + i2 = i; i++; - while (i= orderpluspnts) i2= opp2-j; + if (i2 + j >= orderpluspnts) i2 = opp2 - j; - for (i= i1; i<=i2; i++) { - if (basis[i]!=0.0f) - d= ((t-knots[i])*basis[i]) / (knots[i+j-1]-knots[i]); + for (i = i1; i <= i2; i++) { + if (basis[i] != 0.0f) + d = ((t - knots[i]) * basis[i]) / (knots[i + j - 1] - knots[i]); else - d= 0.0f; + d = 0.0f; - if (basis[i+1] != 0.0f) - e= ((knots[i+j]-t)*basis[i+1]) / (knots[i+j]-knots[i+1]); + if (basis[i + 1] != 0.0f) + e = ((knots[i + j] - t) * basis[i + 1]) / (knots[i + j] - knots[i + 1]); else - e= 0.0; + e = 0.0; - basis[i]= d+e; + basis[i] = d + e; } } - *start= 1000; - *end= 0; + *start = 1000; + *end = 0; - for (i=i1; i<=i2; i++) { + for (i = i1; i <= i2; i++) { if (basis[i] > 0.0f) { - *end= i; - if (*start==1000) *start= i; + *end = i; + if (*start == 1000) *start = i; } } } @@ -820,150 +820,150 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int i, j, iofs, jofs, cycl, len, curu, curv; int istart, iend, jsta, jen, *jstart, *jend, ratcomp; - int totu = nu->pntsu*resolu, totv = nu->pntsv*resolv; + int totu = nu->pntsu * resolu, totv = nu->pntsv * resolv; - if (nu->knotsu==NULL || nu->knotsv==NULL) return; - if (nu->orderu>nu->pntsu) return; - if (nu->orderv>nu->pntsv) return; - if (coord_array==NULL) return; + if (nu->knotsu == NULL || nu->knotsv == NULL) return; + if (nu->orderu > nu->pntsu) return; + if (nu->orderv > nu->pntsv) return; + if (coord_array == NULL) return; /* allocate and initialize */ len = totu * totv; - if (len==0) return; + if (len == 0) return; - sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbfaces1"); + sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbfaces1"); - len= totu*totv; - if (len==0) { + len = totu * totv; + if (len == 0) { MEM_freeN(sum); return; } - bp= nu->bp; - i= nu->pntsu*nu->pntsv; - ratcomp=0; + bp = nu->bp; + i = nu->pntsu * nu->pntsv; + ratcomp = 0; while (i--) { if (bp->vec[3] != 1.0f) { - ratcomp= 1; + ratcomp = 1; break; } bp++; } - fp= nu->knotsu; - ustart= fp[nu->orderu-1]; - if (nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; - else uend= fp[nu->pntsu]; - ustep= (uend-ustart)/((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1); - - basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbfaces3"); + fp = nu->knotsu; + ustart = fp[nu->orderu - 1]; + if (nu->flagu & CU_NURB_CYCLIC) uend = fp[nu->pntsu + nu->orderu - 1]; + else uend = fp[nu->pntsu]; + ustep = (uend - ustart) / ((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1); - fp= nu->knotsv; - vstart= fp[nu->orderv-1]; - - if (nu->flagv & CU_NURB_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1]; - else vend= fp[nu->pntsv]; - vstep= (vend-vstart)/((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1); - - len= KNOTSV(nu); - basisv= (float *)MEM_mallocN(sizeof(float)*len*totv, "makeNurbfaces3"); - jstart= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces4"); - jend= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces5"); + basisu = (float *)MEM_mallocN(sizeof(float) * KNOTSU(nu), "makeNurbfaces3"); + + fp = nu->knotsv; + vstart = fp[nu->orderv - 1]; + + if (nu->flagv & CU_NURB_CYCLIC) vend = fp[nu->pntsv + nu->orderv - 1]; + else vend = fp[nu->pntsv]; + vstep = (vend - vstart) / ((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1); + + len = KNOTSV(nu); + basisv = (float *)MEM_mallocN(sizeof(float) * len * totv, "makeNurbfaces3"); + jstart = (int *)MEM_mallocN(sizeof(float) * totv, "makeNurbfaces4"); + jend = (int *)MEM_mallocN(sizeof(float) * totv, "makeNurbfaces5"); /* precalculation of basisv and jstart, jend */ - if (nu->flagv & CU_NURB_CYCLIC) cycl= nu->orderv-1; - else cycl= 0; - v= vstart; - basis= basisv; - curv= totv; + if (nu->flagv & CU_NURB_CYCLIC) cycl = nu->orderv - 1; + else cycl = 0; + v = vstart; + basis = basisv; + curv = totv; while (curv--) { - basisNurb(v, nu->orderv, (short)(nu->pntsv+cycl), nu->knotsv, basis, jstart+curv, jend+curv); - basis+= KNOTSV(nu); - v+= vstep; + basisNurb(v, nu->orderv, (short)(nu->pntsv + cycl), nu->knotsv, basis, jstart + curv, jend + curv); + basis += KNOTSV(nu); + v += vstep; } - if (nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1; - else cycl= 0; - in= coord_array; - u= ustart; - curu= totu; + if (nu->flagu & CU_NURB_CYCLIC) cycl = nu->orderu - 1; + else cycl = 0; + in = coord_array; + u = ustart; + curu = totu; while (curu--) { - basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend); + basisNurb(u, nu->orderu, (short)(nu->pntsu + cycl), nu->knotsu, basisu, &istart, &iend); - basis= basisv; - curv= totv; + basis = basisv; + curv = totv; while (curv--) { - jsta= jstart[curv]; - jen= jend[curv]; + jsta = jstart[curv]; + jen = jend[curv]; /* calculate sum */ - sumdiv= 0.0; - fp= sum; + sumdiv = 0.0; + fp = sum; - for (j= jsta; j<=jen; j++) { + for (j = jsta; j <= jen; j++) { - if (j>=nu->pntsv) jofs= (j - nu->pntsv); - else jofs= j; - bp= nu->bp+ nu->pntsu*jofs+istart-1; + if (j >= nu->pntsv) jofs = (j - nu->pntsv); + else jofs = j; + bp = nu->bp + nu->pntsu * jofs + istart - 1; - for (i= istart; i<=iend; i++, fp++) { + for (i = istart; i <= iend; i++, fp++) { - if (i>= nu->pntsu) { - iofs= i- nu->pntsu; - bp= nu->bp+ nu->pntsu*jofs+iofs; + if (i >= nu->pntsu) { + iofs = i - nu->pntsu; + bp = nu->bp + nu->pntsu * jofs + iofs; } else bp++; if (ratcomp) { - *fp= basisu[i]*basis[j]*bp->vec[3]; - sumdiv+= *fp; + *fp = basisu[i] * basis[j] * bp->vec[3]; + sumdiv += *fp; } - else *fp= basisu[i]*basis[j]; + else *fp = basisu[i] * basis[j]; } } if (ratcomp) { - fp= sum; - for (j= jsta; j<=jen; j++) { - for (i= istart; i<=iend; i++, fp++) { - *fp/= sumdiv; + fp = sum; + for (j = jsta; j <= jen; j++) { + for (i = istart; i <= iend; i++, fp++) { + *fp /= sumdiv; } } } /* one! (1.0) real point now */ - fp= sum; - for (j= jsta; j<=jen; j++) { + fp = sum; + for (j = jsta; j <= jen; j++) { - if (j>=nu->pntsv) jofs= (j - nu->pntsv); - else jofs= j; - bp= nu->bp+ nu->pntsu*jofs+istart-1; + if (j >= nu->pntsv) jofs = (j - nu->pntsv); + else jofs = j; + bp = nu->bp + nu->pntsu * jofs + istart - 1; - for (i= istart; i<=iend; i++, fp++) { + for (i = istart; i <= iend; i++, fp++) { - if (i>= nu->pntsu) { - iofs= i- nu->pntsu; - bp= nu->bp+ nu->pntsu*jofs+iofs; + if (i >= nu->pntsu) { + iofs = i - nu->pntsu; + bp = nu->bp + nu->pntsu * jofs + iofs; } else bp++; if (*fp != 0.0f) { - in[0]+= (*fp) * bp->vec[0]; - in[1]+= (*fp) * bp->vec[1]; - in[2]+= (*fp) * bp->vec[2]; + in[0] += (*fp) * bp->vec[0]; + in[1] += (*fp) * bp->vec[1]; + in[2] += (*fp) * bp->vec[2]; } } } - in+=3; - basis+= KNOTSV(nu); + in += 3; + basis += KNOTSV(nu); } - u+= ustep; - if (rowstride!=0) in = (float*) (((unsigned char*) in) + (rowstride - 3*totv*sizeof(*in))); + u += ustep; + if (rowstride != 0) in = (float *) (((unsigned char *) in) + (rowstride - 3 * totv * sizeof(*in))); } /* free */ @@ -981,73 +981,73 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * BPoint *bp; float u, ustart, uend, ustep, sumdiv; float *basisu, *sum, *fp; - float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array, *weight_fp= weight_array; + float *coord_fp = coord_array, *tilt_fp = tilt_array, *radius_fp = radius_array, *weight_fp = weight_array; int i, len, istart, iend, cycl; - if (nu->knotsu==NULL) return; - if (nu->orderu>nu->pntsu) return; - if (coord_array==NULL) return; + if (nu->knotsu == NULL) return; + if (nu->orderu > nu->pntsu) return; + if (coord_array == NULL) return; /* allocate and initialize */ - len= nu->pntsu; - if (len==0) return; - sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1"); + len = nu->pntsu; + if (len == 0) return; + sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbcurve1"); - resolu= (resolu*SEGMENTSU(nu)); + resolu = (resolu * SEGMENTSU(nu)); - if (resolu==0) { + if (resolu == 0) { MEM_freeN(sum); return; } - fp= nu->knotsu; - ustart= fp[nu->orderu-1]; - if (nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; - else uend= fp[nu->pntsu]; - ustep= (uend-ustart)/(resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1)); + fp = nu->knotsu; + ustart = fp[nu->orderu - 1]; + if (nu->flagu & CU_NURB_CYCLIC) uend = fp[nu->pntsu + nu->orderu - 1]; + else uend = fp[nu->pntsu]; + ustep = (uend - ustart) / (resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1)); - basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3"); + basisu = (float *)MEM_mallocN(sizeof(float) * KNOTSU(nu), "makeNurbcurve3"); - if (nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1; - else cycl= 0; + if (nu->flagu & CU_NURB_CYCLIC) cycl = nu->orderu - 1; + else cycl = 0; - u= ustart; + u = ustart; while (resolu--) { - basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend); + basisNurb(u, nu->orderu, (short)(nu->pntsu + cycl), nu->knotsu, basisu, &istart, &iend); /* calc sum */ - sumdiv= 0.0; - fp= sum; - bp= nu->bp+ istart-1; - for (i= istart; i<=iend; i++, fp++) { + sumdiv = 0.0; + fp = sum; + bp = nu->bp + istart - 1; + for (i = istart; i <= iend; i++, fp++) { - if (i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu); + if (i >= nu->pntsu) bp = nu->bp + (i - nu->pntsu); else bp++; - *fp= basisu[i]*bp->vec[3]; - sumdiv+= *fp; + *fp = basisu[i] * bp->vec[3]; + sumdiv += *fp; } if (sumdiv != 0.0f) if (sumdiv < 0.999f || sumdiv > 1.001f) { - /* is normalizing needed? */ - fp= sum; - for (i= istart; i<=iend; i++, fp++) { - *fp/= sumdiv; + /* is normalizing needed? */ + fp = sum; + for (i = istart; i <= iend; i++, fp++) { + *fp /= sumdiv; + } } - } /* one! (1.0) real point */ - fp= sum; - bp= nu->bp+ istart-1; - for (i= istart; i<=iend; i++, fp++) { + fp = sum; + bp = nu->bp + istart - 1; + for (i = istart; i <= iend; i++, fp++) { - if (i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu); + if (i >= nu->pntsu) bp = nu->bp + (i - nu->pntsu); else bp++; if (*fp != 0.0f) { - coord_fp[0]+= (*fp) * bp->vec[0]; - coord_fp[1]+= (*fp) * bp->vec[1]; - coord_fp[2]+= (*fp) * bp->vec[2]; + coord_fp[0] += (*fp) * bp->vec[0]; + coord_fp[1] += (*fp) * bp->vec[1]; + coord_fp[2] += (*fp) * bp->vec[2]; if (tilt_fp) (*tilt_fp) += (*fp) * bp->alfa; @@ -1063,11 +1063,11 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * coord_fp = (float *)(((char *)coord_fp) + stride); - if (tilt_fp) tilt_fp = (float *)(((char *)tilt_fp) + stride); - if (radius_fp) radius_fp = (float *)(((char *)radius_fp) + stride); - if (weight_fp) weight_fp = (float *)(((char *)weight_fp) + stride); + if (tilt_fp) tilt_fp = (float *)(((char *)tilt_fp) + stride); + if (radius_fp) radius_fp = (float *)(((char *)radius_fp) + stride); + if (weight_fp) weight_fp = (float *)(((char *)weight_fp) + stride); - u+= ustep; + u += ustep; } /* free */ @@ -1081,25 +1081,25 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float float rt0, rt1, rt2, rt3, f; int a; - f= (float)it; - rt0= q0; - rt1= 3.0f*(q1-q0)/f; - f*= f; - rt2= 3.0f*(q0-2.0f*q1+q2)/f; - f*= it; - rt3= (q3-q0+3.0f*(q1-q2))/f; + f = (float)it; + rt0 = q0; + rt1 = 3.0f * (q1 - q0) / f; + f *= f; + rt2 = 3.0f * (q0 - 2.0f * q1 + q2) / f; + f *= it; + rt3 = (q3 - q0 + 3.0f * (q1 - q2)) / f; - q0= rt0; - q1= rt1+rt2+rt3; - q2= 2*rt2+6*rt3; - q3= 6*rt3; + q0 = rt0; + q1 = rt1 + rt2 + rt3; + q2 = 2 * rt2 + 6 * rt3; + q3 = 6 * rt3; - for (a=0; a<=it; a++) { - *p= q0; - p = (float *)(((char *)p)+stride); - q0+= q1; - q1+= q2; - q2+= q3; + for (a = 0; a <= it; a++) { + *p = q0; + p = (float *)(((char *)p) + stride); + q0 += q1; + q1 += q2; + q2 += q3; } } @@ -1110,15 +1110,15 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float * * This could also be optimized like forward_diff_bezier */ int a; - for (a=0; a<=it; a++) { + for (a = 0; a <= it; a++) { float t = (float)a / (float)it; int i; - for (i=0; i<3; i++) { - p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i]; + for (i = 0; i < 3; i++) { + p[i] = (-6 * t + 6) * p0[i] + (18 * t - 12) * p1[i] + (-18 * t + 6) * p2[i] + (6 * t) * p3[i]; } normalize_v3(p); - p = (float *)(((char *)p)+stride); + p = (float *)(((char *)p) + stride); } } @@ -1128,15 +1128,15 @@ float *BKE_curve_surf_make_orco(Object *ob) { /* Note: this function is used in convertblender only atm, so * suppose nonzero curve's render resolution should always be used */ - Curve *cu= ob->data; + Curve *cu = ob->data; Nurb *nu; - int a, b, tot=0; + int a, b, tot = 0; int sizeu, sizev; int resolu, resolv; float *fp, *coord_array; /* first calculate the size of the datablock */ - nu= cu->nurb.first; + nu = cu->nurb.first; while (nu) { /* as we want to avoid the seam in a cyclic nurbs * texture wrapping, reserve extra orco data space to save these extra needed @@ -1147,85 +1147,85 @@ float *BKE_curve_surf_make_orco(Object *ob) * See also convertblender.c: init_render_surf() */ - resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu; - resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv; + resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; + resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; - sizeu = nu->pntsu*resolu; - sizev = nu->pntsv*resolv; + sizeu = nu->pntsu * resolu; + sizev = nu->pntsv * resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; - if (nu->pntsv>1) tot+= sizeu * sizev; + if (nu->pntsv > 1) tot += sizeu * sizev; - nu= nu->next; + nu = nu->next; } /* makeNurbfaces wants zeros */ - fp= coord_array= MEM_callocN(3*sizeof(float)*tot, "make_orco"); + fp = coord_array = MEM_callocN(3 * sizeof(float) * tot, "make_orco"); - nu= cu->nurb.first; + nu = cu->nurb.first; while (nu) { - resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu; - resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv; + resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; + resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; - if (nu->pntsv>1) { - sizeu = nu->pntsu*resolu; - sizev = nu->pntsv*resolv; + if (nu->pntsv > 1) { + sizeu = nu->pntsu * resolu; + sizev = nu->pntsv * resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; if (cu->flag & CU_UV_ORCO) { - for (b=0; b< sizeu; b++) { - for (a=0; a< sizev; a++) { + for (b = 0; b < sizeu; b++) { + for (a = 0; a < sizev; a++) { - if (sizev <2) fp[0]= 0.0f; - else fp[0]= -1.0f + 2.0f*((float)a)/(sizev - 1); + if (sizev < 2) fp[0] = 0.0f; + else fp[0] = -1.0f + 2.0f * ((float)a) / (sizev - 1); - if (sizeu <2) fp[1]= 0.0f; - else fp[1]= -1.0f + 2.0f*((float)b)/(sizeu - 1); + if (sizeu < 2) fp[1] = 0.0f; + else fp[1] = -1.0f + 2.0f * ((float)b) / (sizeu - 1); - fp[2]= 0.0; + fp[2] = 0.0; - fp+= 3; + fp += 3; } } } else { - float *_tdata= MEM_callocN((nu->pntsu*resolu) * (nu->pntsv*resolv) *3*sizeof(float), "temp data"); - float *tdata= _tdata; + float *_tdata = MEM_callocN((nu->pntsu * resolu) * (nu->pntsv * resolv) * 3 * sizeof(float), "temp data"); + float *tdata = _tdata; BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv); - for (b=0; bflagu & CU_NURB_CYCLIC)) - use_b= 0; - - for (a=0; aflagv & CU_NURB_CYCLIC)) - use_a= 0; - - tdata = _tdata + 3 * (use_b * (nu->pntsv*resolv) + use_a); - - fp[0]= (tdata[0]-cu->loc[0])/cu->size[0]; - fp[1]= (tdata[1]-cu->loc[1])/cu->size[1]; - fp[2]= (tdata[2]-cu->loc[2])/cu->size[2]; - fp+= 3; + for (b = 0; b < sizeu; b++) { + int use_b = b; + if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC)) + use_b = 0; + + for (a = 0; a < sizev; a++) { + int use_a = a; + if (a == sizev - 1 && (nu->flagv & CU_NURB_CYCLIC)) + use_a = 0; + + tdata = _tdata + 3 * (use_b * (nu->pntsv * resolv) + use_a); + + fp[0] = (tdata[0] - cu->loc[0]) / cu->size[0]; + fp[1] = (tdata[1] - cu->loc[1]) / cu->size[1]; + fp[2] = (tdata[2] - cu->loc[2]) / cu->size[2]; + fp += 3; } } MEM_freeN(_tdata); } } - nu= nu->next; + nu = nu->next; } return coord_array; } - /* NOTE: This routine is tied to the order of vertex - * built by displist and as passed to the renderer. - */ +/* NOTE: This routine is tied to the order of vertex + * built by displist and as passed to the renderer. + */ float *BKE_curve_make_orco(Scene *scene, Object *ob) { Curve *cu = ob->data; @@ -1237,43 +1237,43 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) makeDispListCurveTypes_forOrco(scene, ob, &disp); numVerts = 0; - for (dl=disp.first; dl; dl=dl->next) { - if (dl->type==DL_INDEX3) { + for (dl = disp.first; dl; dl = dl->next) { + if (dl->type == DL_INDEX3) { numVerts += dl->nr; } - else if (dl->type==DL_SURF) { + else if (dl->type == DL_SURF) { /* convertblender.c uses the Surface code for creating renderfaces when cyclic U only (closed circle beveling) */ if (dl->flag & DL_CYCL_U) { if (dl->flag & DL_CYCL_V) - numVerts += (dl->parts+1)*(dl->nr+1); + numVerts += (dl->parts + 1) * (dl->nr + 1); else - numVerts += dl->parts*(dl->nr+1); + numVerts += dl->parts * (dl->nr + 1); } else - numVerts += dl->parts*dl->nr; + numVerts += dl->parts * dl->nr; } } - fp= coord_array= MEM_mallocN(3*sizeof(float)*numVerts, "cu_orco"); - for (dl=disp.first; dl; dl=dl->next) { - if (dl->type==DL_INDEX3) { - for (u=0; unr; u++, fp+=3) { + fp = coord_array = MEM_mallocN(3 * sizeof(float) * numVerts, "cu_orco"); + for (dl = disp.first; dl; dl = dl->next) { + if (dl->type == DL_INDEX3) { + for (u = 0; u < dl->nr; u++, fp += 3) { if (cu->flag & CU_UV_ORCO) { - fp[0]= 2.0f*u/(dl->nr-1) - 1.0f; - fp[1]= 0.0; - fp[2]= 0.0; + fp[0] = 2.0f * u / (dl->nr - 1) - 1.0f; + fp[1] = 0.0; + fp[2] = 0.0; } else { - copy_v3_v3(fp, &dl->verts[u*3]); + copy_v3_v3(fp, &dl->verts[u * 3]); - fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; - fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; - fp[2]= (fp[2]-cu->loc[2])/cu->size[2]; + fp[0] = (fp[0] - cu->loc[0]) / cu->size[0]; + fp[1] = (fp[1] - cu->loc[1]) / cu->size[1]; + fp[2] = (fp[2] - cu->loc[2]) / cu->size[2]; } } } - else if (dl->type==DL_SURF) { - int sizeu= dl->nr, sizev= dl->parts; + else if (dl->type == DL_SURF) { + int sizeu = dl->nr, sizev = dl->parts; /* exception as handled in convertblender.c too */ if (dl->flag & DL_CYCL_U) { @@ -1282,24 +1282,24 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) sizev++; } - for (u=0; uflag & CU_UV_ORCO) { - fp[0]= 2.0f*u/(sizev - 1) - 1.0f; - fp[1]= 2.0f*v/(sizeu - 1) - 1.0f; - fp[2]= 0.0; + fp[0] = 2.0f * u / (sizev - 1) - 1.0f; + fp[1] = 2.0f * v / (sizeu - 1) - 1.0f; + fp[2] = 0.0; } else { float *vert; - int realv= v % dl->nr; - int realu= u % dl->parts; + int realv = v % dl->nr; + int realu = u % dl->parts; - vert= dl->verts + 3*(dl->nr*realu + realv); + vert = dl->verts + 3 * (dl->nr * realu + realv); copy_v3_v3(fp, vert); - fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; - fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; - fp[2]= (fp[2]-cu->loc[2])/cu->size[2]; + fp[0] = (fp[0] - cu->loc[0]) / cu->size[0]; + fp[1] = (fp[1] - cu->loc[1]) / cu->size[1]; + fp[2] = (fp[2] - cu->loc[2]) / cu->size[2]; } } } @@ -1321,99 +1321,99 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende float *fp, facx, facy, angle, dangle; int nr, a; - cu= ob->data; + cu = ob->data; disp->first = disp->last = NULL; /* if a font object is being edited, then do nothing */ // XXX if ( ob == obedit && ob->type == OB_FONT ) return; if (cu->bevobj) { - if (cu->bevobj->type!=OB_CURVE) return; + if (cu->bevobj->type != OB_CURVE) return; - bevcu= cu->bevobj->data; - if (bevcu->ext1==0.0f && bevcu->ext2==0.0f) { - ListBase bevdisp= {NULL, NULL}; - facx= cu->bevobj->size[0]; - facy= cu->bevobj->size[1]; + bevcu = cu->bevobj->data; + if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) { + ListBase bevdisp = {NULL, NULL}; + facx = cu->bevobj->size[0]; + facy = cu->bevobj->size[1]; if (forRender) { makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); - dl= bevdisp.first; + dl = bevdisp.first; } else { - dl= cu->bevobj->disp.first; - if (dl==NULL) { + dl = cu->bevobj->disp.first; + if (dl == NULL) { makeDispListCurveTypes(scene, cu->bevobj, 0); - dl= cu->bevobj->disp.first; + dl = cu->bevobj->disp.first; } } while (dl) { if (ELEM(dl->type, DL_POLY, DL_SEGM)) { - dlnew= MEM_mallocN(sizeof(DispList), "makebevelcurve1"); - *dlnew= *dl; - dlnew->verts= MEM_mallocN(3*sizeof(float)*dl->parts*dl->nr, "makebevelcurve1"); - memcpy(dlnew->verts, dl->verts, 3*sizeof(float)*dl->parts*dl->nr); + dlnew = MEM_mallocN(sizeof(DispList), "makebevelcurve1"); + *dlnew = *dl; + dlnew->verts = MEM_mallocN(3 * sizeof(float) * dl->parts * dl->nr, "makebevelcurve1"); + memcpy(dlnew->verts, dl->verts, 3 * sizeof(float) * dl->parts * dl->nr); - if (dlnew->type==DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE|DL_BACK_CURVE); + if (dlnew->type == DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE); BLI_addtail(disp, dlnew); - fp= dlnew->verts; - nr= dlnew->parts*dlnew->nr; + fp = dlnew->verts; + nr = dlnew->parts * dlnew->nr; while (nr--) { - fp[2]= fp[1]*facy; - fp[1]= -fp[0]*facx; - fp[0]= 0.0; - fp+= 3; + fp[2] = fp[1] * facy; + fp[1] = -fp[0] * facx; + fp[0] = 0.0; + fp += 3; } } - dl= dl->next; + dl = dl->next; } freedisplist(&bevdisp); } } - else if (cu->ext1==0.0f && cu->ext2==0.0f) { + else if (cu->ext1 == 0.0f && cu->ext2 == 0.0f) { ; } - else if (cu->ext2==0.0f) { - dl= MEM_callocN(sizeof(DispList), "makebevelcurve2"); - dl->verts= MEM_mallocN(2*3*sizeof(float), "makebevelcurve2"); + else if (cu->ext2 == 0.0f) { + dl = MEM_callocN(sizeof(DispList), "makebevelcurve2"); + dl->verts = MEM_mallocN(2 * 3 * sizeof(float), "makebevelcurve2"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->flag= DL_FRONT_CURVE|DL_BACK_CURVE; - dl->nr= 2; - - fp= dl->verts; - fp[0]= fp[1]= 0.0; - fp[2]= -cu->ext1; - fp[3]= fp[4]= 0.0; - fp[5]= cu->ext1; + dl->type = DL_SEGM; + dl->parts = 1; + dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE; + dl->nr = 2; + + fp = dl->verts; + fp[0] = fp[1] = 0.0; + fp[2] = -cu->ext1; + fp[3] = fp[4] = 0.0; + fp[5] = cu->ext1; } - else if ( (cu->flag & (CU_FRONT|CU_BACK))==0 && cu->ext1==0.0f) { // we make a full round bevel in that case + else if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0 && cu->ext1 == 0.0f) { // we make a full round bevel in that case - nr= 4+ 2*cu->bevresol; + nr = 4 + 2 * cu->bevresol; - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1"); + dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1"); BLI_addtail(disp, dl); - dl->type= DL_POLY; - dl->parts= 1; - dl->flag= DL_BACK_CURVE; - dl->nr= nr; + dl->type = DL_POLY; + dl->parts = 1; + dl->flag = DL_BACK_CURVE; + dl->nr = nr; /* a circle */ - fp= dl->verts; - dangle= (2.0f*(float)M_PI/(nr)); - angle= -(nr-1)*dangle; - - for (a=0; aext2)); - fp[2]= (sinf(angle)*(cu->ext2)) - cu->ext1; - angle+= dangle; - fp+= 3; + fp = dl->verts; + dangle = (2.0f * (float)M_PI / (nr)); + angle = -(nr - 1) * dangle; + + for (a = 0; a < nr; a++) { + fp[0] = 0.0; + fp[1] = (cosf(angle) * (cu->ext2)); + fp[2] = (sinf(angle) * (cu->ext2)) - cu->ext1; + angle += dangle; + fp += 3; } } else { @@ -1423,87 +1423,87 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende /* part 1, back */ if ((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) { - dnr= nr= 2+ cu->bevresol; - if ( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; + dnr = nr = 2 + cu->bevresol; + if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) + nr = 3 + 2 * cu->bevresol; - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1"); + dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->flag= DL_BACK_CURVE; - dl->nr= nr; + dl->type = DL_SEGM; + dl->parts = 1; + dl->flag = DL_BACK_CURVE; + dl->nr = nr; /* half a circle */ - fp= dl->verts; - dangle= (0.5*M_PI/(dnr-1)); - angle= -(nr-1)*dangle; + fp = dl->verts; + dangle = (0.5 * M_PI / (dnr - 1)); + angle = -(nr - 1) * dangle; - for (a=0; aext2)); - fp[2]= (float)(sinf(angle)*(cu->ext2)) - cu->ext1; - angle+= dangle; - fp+= 3; + for (a = 0; a < nr; a++) { + fp[0] = 0.0; + fp[1] = (float)(cosf(angle) * (cu->ext2)); + fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1; + angle += dangle; + fp += 3; } } /* part 2, sidefaces */ - if (cu->ext1!=0.0f) { - nr= 2; + if (cu->ext1 != 0.0f) { + nr = 2; - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p2"); - dl->verts= MEM_callocN(nr*3*sizeof(float), "makebevelcurve p2"); + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p2"); + dl->verts = MEM_callocN(nr * 3 * sizeof(float), "makebevelcurve p2"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->nr= nr; - - fp= dl->verts; - fp[1]= cu->ext2; - fp[2]= -cu->ext1; - fp[4]= cu->ext2; - fp[5]= cu->ext1; - - if ( (cu->flag & (CU_FRONT|CU_BACK))==0) { - dl= MEM_dupallocN(dl); - dl->verts= MEM_dupallocN(dl->verts); + dl->type = DL_SEGM; + dl->parts = 1; + dl->nr = nr; + + fp = dl->verts; + fp[1] = cu->ext2; + fp[2] = -cu->ext1; + fp[4] = cu->ext2; + fp[5] = cu->ext1; + + if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) { + dl = MEM_dupallocN(dl); + dl->verts = MEM_dupallocN(dl->verts); BLI_addtail(disp, dl); - fp= dl->verts; - fp[1]= -fp[1]; - fp[2]= -fp[2]; - fp[4]= -fp[4]; - fp[5]= -fp[5]; + fp = dl->verts; + fp[1] = -fp[1]; + fp[2] = -fp[2]; + fp[4] = -fp[4]; + fp[5] = -fp[5]; } } /* part 3, front */ if ((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) { - dnr= nr= 2+ cu->bevresol; - if ( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; + dnr = nr = 2 + cu->bevresol; + if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) + nr = 3 + 2 * cu->bevresol; - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p3"); + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p3"); + dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p3"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->flag= DL_FRONT_CURVE; - dl->parts= 1; - dl->nr= nr; + dl->type = DL_SEGM; + dl->flag = DL_FRONT_CURVE; + dl->parts = 1; + dl->nr = nr; /* half a circle */ - fp= dl->verts; - angle= 0.0; - dangle= (0.5*M_PI/(dnr-1)); + fp = dl->verts; + angle = 0.0; + dangle = (0.5 * M_PI / (dnr - 1)); - for (a=0; aext2)); - fp[2]= (float)(sinf(angle)*(cu->ext2)) + cu->ext1; - angle+= dangle; - fp+= 3; + for (a = 0; a < nr; a++) { + fp[0] = 0.0; + fp[1] = (float)(cosf(angle) * (cu->ext2)); + fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1; + angle += dangle; + fp += 3; } } } @@ -1521,25 +1521,25 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c */ float deler; - deler= (v1[cox]-v2[cox])*(v3[coy]-v4[coy])-(v3[cox]-v4[cox])*(v1[coy]-v2[coy]); - if (deler==0.0f) return -1; + deler = (v1[cox] - v2[cox]) * (v3[coy] - v4[coy]) - (v3[cox] - v4[cox]) * (v1[coy] - v2[coy]); + if (deler == 0.0f) return -1; - *labda= (v1[coy]-v3[coy])*(v3[cox]-v4[cox])-(v1[cox]-v3[cox])*(v3[coy]-v4[coy]); - *labda= -(*labda/deler); + *labda = (v1[coy] - v3[coy]) * (v3[cox] - v4[cox]) - (v1[cox] - v3[cox]) * (v3[coy] - v4[coy]); + *labda = -(*labda / deler); - deler= v3[coy]-v4[coy]; - if (deler==0) { - deler=v3[cox]-v4[cox]; - *mu= -(*labda*(v2[cox]-v1[cox])+v1[cox]-v3[cox])/deler; + deler = v3[coy] - v4[coy]; + if (deler == 0) { + deler = v3[cox] - v4[cox]; + *mu = -(*labda * (v2[cox] - v1[cox]) + v1[cox] - v3[cox]) / deler; } else { - *mu= -(*labda*(v2[coy]-v1[coy])+v1[coy]-v3[coy])/deler; + *mu = -(*labda * (v2[coy] - v1[coy]) + v1[coy] - v3[coy]) / deler; } - vec[cox]= *labda*(v2[cox]-v1[cox])+v1[cox]; - vec[coy]= *labda*(v2[coy]-v1[coy])+v1[coy]; + vec[cox] = *labda * (v2[cox] - v1[cox]) + v1[cox]; + vec[coy] = *labda * (v2[coy] - v1[coy]) + v1[coy]; - if (*labda>=0.0f && *labda<=1.0f && *mu>=0.0f && *mu<=1.0f) { - if (*labda==0.0f || *labda==1.0f || *mu==0.0f || *mu==1.0f) return 1; + if (*labda >= 0.0f && *labda <= 1.0f && *mu >= 0.0f && *mu <= 1.0f) { + if (*labda == 0.0f || *labda == 1.0f || *mu == 0.0f || *mu == 1.0f) return 1; return 2; } return 0; @@ -1552,45 +1552,45 @@ static short bevelinside(BevList *bl1, BevList *bl2) /* returns '1' if correct hole */ BevPoint *bevp, *prevbevp; float min, max, vec[3], hvec1[3], hvec2[3], lab, mu; - int nr, links=0, rechts=0, mode; + int nr, links = 0, rechts = 0, mode; /* take first vertex of possible hole */ - bevp= (BevPoint *)(bl2+1); - hvec1[0]= bevp->vec[0]; - hvec1[1]= bevp->vec[1]; - hvec1[2]= 0.0; + bevp = (BevPoint *)(bl2 + 1); + hvec1[0] = bevp->vec[0]; + hvec1[1] = bevp->vec[1]; + hvec1[2] = 0.0; copy_v3_v3(hvec2, hvec1); - hvec2[0]+=1000; + hvec2[0] += 1000; /* test it with all edges of potential surounding poly */ /* count number of transitions left-right */ - bevp= (BevPoint *)(bl1+1); - nr= bl1->nr; - prevbevp= bevp+(nr-1); + bevp = (BevPoint *)(bl1 + 1); + nr = bl1->nr; + prevbevp = bevp + (nr - 1); while (nr--) { - min= prevbevp->vec[1]; - max= bevp->vec[1]; - if (maxvec[1]; + min = prevbevp->vec[1]; + max = bevp->vec[1]; + if (max < min) { + min = max; + max = prevbevp->vec[1]; } - if (min!=max) { - if (min<=hvec1[1] && max>=hvec1[1]) { + if (min != max) { + if (min <= hvec1[1] && max >= hvec1[1]) { /* there's a transition, calc intersection point */ - mode= cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec); + mode = cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec); /* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition * only allow for one situation: we choose lab= 1.0 */ if (mode >= 0 && lab != 0.0f) { - if (vec[0]left > x2->left ) return 1; - else if ( x1->left < x2->left) return -1; + if (x1->left > x2->left) return 1; + else if (x1->left < x2->left) return -1; return 0; } @@ -1620,37 +1620,37 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si { float t01, t02, x3, y3; - t01= (float)sqrt(x1*x1+y1*y1); - t02= (float)sqrt(x2*x2+y2*y2); - if (t01==0.0f) t01= 1.0f; - if (t02==0.0f) t02= 1.0f; + t01 = (float)sqrt(x1 * x1 + y1 * y1); + t02 = (float)sqrt(x2 * x2 + y2 * y2); + if (t01 == 0.0f) t01 = 1.0f; + if (t02 == 0.0f) t02 = 1.0f; - x1/=t01; - y1/=t01; - x2/=t02; - y2/=t02; + x1 /= t01; + y1 /= t01; + x2 /= t02; + y2 /= t02; - t02= x1*x2+y1*y2; - if (fabs(t02)>=1.0) t02= .5*M_PI; - else t02= (saacos(t02))/2.0f; + t02 = x1 * x2 + y1 * y2; + if (fabs(t02) >= 1.0) t02 = .5 * M_PI; + else t02 = (saacos(t02)) / 2.0f; - t02= (float)sin(t02); - if (t02==0.0f) t02= 1.0f; + t02 = (float)sin(t02); + if (t02 == 0.0f) t02 = 1.0f; - x3= x1-x2; - y3= y1-y2; - if (x3==0 && y3==0) { - x3= y1; - y3= -x1; + x3 = x1 - x2; + y3 = y1 - y2; + if (x3 == 0 && y3 == 0) { + x3 = y1; + y3 = -x1; } else { - t01= (float)sqrt(x3*x3+y3*y3); - x3/=t01; - y3/=t01; + t01 = (float)sqrt(x3 * x3 + y3 * y3); + x3 /= t01; + y3 /= t01; } - *sina= -y3/t02; - *cosa= x3/t02; + *sina = -y3 / t02; + *cosa = x3 / t02; } @@ -1660,55 +1660,55 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float * float fac, dfac, t[4]; int a; - if (tilt_array==NULL && radius_array==NULL) + if (tilt_array == NULL && radius_array == NULL) return; - last= nu->bezt+(nu->pntsu-1); + last = nu->bezt + (nu->pntsu - 1); /* returns a point */ - if (prevbezt==nu->bezt) { - if (nu->flagu & CU_NURB_CYCLIC) pprev= last; - else pprev= prevbezt; + if (prevbezt == nu->bezt) { + if (nu->flagu & CU_NURB_CYCLIC) pprev = last; + else pprev = prevbezt; } - else pprev= prevbezt-1; + else pprev = prevbezt - 1; /* next point */ - if (bezt==last) { - if (nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; - else next= bezt; + if (bezt == last) { + if (nu->flagu & CU_NURB_CYCLIC) next = nu->bezt; + else next = bezt; } - else next= bezt+1; + else next = bezt + 1; - fac= 0.0; - dfac= 1.0f/(float)resolu; + fac = 0.0; + dfac = 1.0f / (float)resolu; - for (a=0; atilt_interp==KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */ - *tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + if (nu->tilt_interp == KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */ + *tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { key_curve_position_weights(fac, t, nu->tilt_interp); - *tilt_array= t[0]*pprev->alfa + t[1]*prevbezt->alfa + t[2]*bezt->alfa + t[3]*next->alfa; + *tilt_array = t[0] * pprev->alfa + t[1] * prevbezt->alfa + t[2] * bezt->alfa + t[3] * next->alfa; } tilt_array = (float *)(((char *)tilt_array) + stride); } if (radius_array) { - if (nu->radius_interp==KEY_CU_EASE) { + if (nu->radius_interp == KEY_CU_EASE) { /* Support 2.47 ease interp * Note! - this only takes the 2 points into account, * giving much more localized results to changes in radius, sometimes you want that */ - *radius_array = prevbezt->radius + (bezt->radius - prevbezt->radius)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + *radius_array = prevbezt->radius + (bezt->radius - prevbezt->radius) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { /* reuse interpolation from tilt if we can */ - if (tilt_array==NULL || nu->tilt_interp != nu->radius_interp) { + if (tilt_array == NULL || nu->tilt_interp != nu->radius_interp) { key_curve_position_weights(fac, t, nu->radius_interp); } - *radius_array= t[0]*pprev->radius + t[1]*prevbezt->radius + t[2]*bezt->radius + t[3]*next->radius; + *radius_array = t[0] * pprev->radius + t[1] * prevbezt->radius + t[2] * bezt->radius + t[3] * next->radius; } radius_array = (float *)(((char *)radius_array) + stride); @@ -1716,7 +1716,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float * if (weight_array) { /* basic interpolation for now, could copy tilt interp too */ - *weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + *weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight) * (3.0f * fac * fac - 2.0f * fac * fac * fac); weight_array = (float *)(((char *)weight_array) + stride); } @@ -1732,14 +1732,14 @@ static void bevel_list_cyclic_fix_3D(BevList *bl) { BevPoint *bevp, *bevp1; - bevp= (BevPoint *)(bl+1); - bevp1= bevp+1; + bevp = (BevPoint *)(bl + 1); + bevp1 = bevp + 1; copy_qt_qt(bevp->quat, bevp1->quat); copy_v3_v3(bevp->dir, bevp1->dir); copy_v3_v3(bevp->tan, bevp1->tan); - bevp= (BevPoint *)(bl+1); - bevp+= (bl->nr-1); - bevp1= bevp-1; + bevp = (BevPoint *)(bl + 1); + bevp += (bl->nr - 1); + bevp1 = bevp - 1; copy_qt_qt(bevp->quat, bevp1->quat); copy_v3_v3(bevp->dir, bevp1->dir); copy_v3_v3(bevp->tan, bevp1->tan); @@ -1750,17 +1750,17 @@ static void bevel_list_calc_bisect(BevList *bl) BevPoint *bevp2, *bevp1, *bevp0; int nr; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { /* totally simple */ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1769,17 +1769,17 @@ static void bevel_list_flip_tangents(BevList *bl) BevPoint *bevp2, *bevp1, *bevp0; int nr; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { if (RAD2DEGF(angle_v2v2(bevp0->tan, bevp1->tan)) > 90.0f) negate_v3(bevp1->tan); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1790,16 +1790,16 @@ static void bevel_list_apply_tilt(BevList *bl) int nr; float q[4]; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); - nr= bl->nr; + nr = bl->nr; while (nr--) { axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); normalize_qt(bevp1->quat); - bevp1= bevp2; + bevp1 = bevp2; bevp2++; } } @@ -1813,23 +1813,23 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) float bevp0_quat[4]; int a; - for (a=0; a < smooth_iter; a++) { + for (a = 0; a < smooth_iter; a++) { - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; - if (bl->poly== -1) { /* check its not cyclic */ + if (bl->poly == -1) { /* check its not cyclic */ /* skip the first point */ /* bevp0= bevp1; */ - bevp1= bevp2; + bevp1 = bevp2; bevp2++; nr--; - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; nr--; @@ -1855,7 +1855,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) /* bevp0= bevp1; */ /* UNUSED */ - bevp1= bevp2; + bevp1 = bevp2; bevp2++; } } @@ -1866,18 +1866,18 @@ static void make_bevel_list_3D_zup(BevList *bl) BevPoint *bevp2, *bevp1, *bevp0; /* standard for all make_bevel_list_3D_* funcs */ int nr; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { /* totally simple */ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1890,18 +1890,18 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) bevel_list_calc_bisect(bl); - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - if (nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ + if (nr + 4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); } else { - float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir); + float angle = angle_normalized_v3v3(bevp0->dir, bevp1->dir); if (angle > 0.0f) { /* otherwise we can keep as is */ float cross_tmp[3]; @@ -1914,8 +1914,8 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) } } - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } @@ -1932,14 +1932,14 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) * * this is why we compare last with second last * */ - float vec_1[3]= {0, 1, 0}, vec_2[3]= {0, 1, 0}, angle, ang_fac, cross_tmp[3]; + float vec_1[3] = {0, 1, 0}, vec_2[3] = {0, 1, 0}, angle, ang_fac, cross_tmp[3]; BevPoint *bevp_first; BevPoint *bevp_last; - bevp_first= (BevPoint *)(bl+1); - bevp_first+= bl->nr-1; + bevp_first = (BevPoint *)(bl + 1); + bevp_first += bl->nr - 1; bevp_last = bevp_first; bevp_last--; @@ -1950,7 +1950,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) normalize_v3(vec_2); /* align the vector, can avoid this and it looks 98% OK but - * better to align the angle quat roll's before comparing */ + * better to align the angle quat roll's before comparing */ { cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir); angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir); @@ -1958,7 +1958,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) mul_qt_v3(q, vec_2); } - angle= angle_normalized_v3v3(vec_1, vec_2); + angle = angle_normalized_v3v3(vec_1, vec_2); /* flip rotation if needs be */ cross_v3_v3v3(cross_tmp, vec_1, vec_2); @@ -1966,19 +1966,19 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) if (angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f)) angle = -angle; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */ + ang_fac = angle * (1.0f - ((float)nr / bl->nr)); /* also works */ axis_angle_to_quat(q, bevp1->dir, ang_fac); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1992,36 +1992,36 @@ static void make_bevel_list_3D_tangent(BevList *bl) float bevp0_tan[3], cross_tmp[3]; bevel_list_calc_bisect(bl); - if (bl->poly== -1) /* check its not cyclic */ - bevel_list_cyclic_fix_3D(bl); // XXX - run this now so tangents will be right before doing the flipping + if (bl->poly == -1) /* check its not cyclic */ + bevel_list_cyclic_fix_3D(bl); // XXX - run this now so tangents will be right before doing the flipping bevel_list_flip_tangents(bl); /* correct the tangents */ - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir); normalize_v3(bevp1->tan); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } /* now for the real twist calc */ - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; copy_v3_v3(bevp0_tan, bevp0->tan); - nr= bl->nr; + nr = bl->nr; while (nr--) { /* make perpendicular, modify tan in place, is ok */ @@ -2033,7 +2033,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) tri_to_quat(bevp1->quat, zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ /* bevp0= bevp1; */ /* UNUSED */ - bevp1= bevp2; + bevp1 = bevp2; bevp2++; } } @@ -2041,17 +2041,17 @@ static void make_bevel_list_3D_tangent(BevList *bl) static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode) { switch (twist_mode) { - case CU_TWIST_TANGENT: - make_bevel_list_3D_tangent(bl); - break; - case CU_TWIST_MINIMUM: - make_bevel_list_3D_minimum_twist(bl); - break; - default: /* CU_TWIST_Z_UP default, pre 2.49c */ - make_bevel_list_3D_zup(bl); + case CU_TWIST_TANGENT: + make_bevel_list_3D_tangent(bl); + break; + case CU_TWIST_MINIMUM: + make_bevel_list_3D_minimum_twist(bl); + break; + default: /* CU_TWIST_Z_UP default, pre 2.49c */ + make_bevel_list_3D_zup(bl); } - if (bl->poly== -1) /* check its not cyclic */ + if (bl->poly == -1) /* check its not cyclic */ bevel_list_cyclic_fix_3D(bl); if (smooth_iter) @@ -2067,8 +2067,8 @@ static void make_bevel_list_segment_3D(BevList *bl) { float q[4]; - BevPoint *bevp2= (BevPoint *)(bl+1); - BevPoint *bevp1= bevp2+1; + BevPoint *bevp2 = (BevPoint *)(bl + 1); + BevPoint *bevp1 = bevp2 + 1; /* simple quat/dir */ sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec); @@ -2105,7 +2105,7 @@ void BKE_curve_bevelList_make(Object *ob) int do_tilt, do_radius, do_weight; /* this function needs an object, because of tflag and upflag */ - cu= ob->data; + cu = ob->data; /* do we need to calculate the radius for each point? */ /* do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 : 1; */ @@ -2113,8 +2113,8 @@ void BKE_curve_bevelList_make(Object *ob) /* STEP 1: MAKE POLYS */ BLI_freelistN(&(cu->bev)); - if (cu->editnurb && ob->type!=OB_FONT) { - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + if (cu->editnurb && ob->type != OB_FONT) { + ListBase *nurbs = BKE_curve_editNurbs_get(cu); nu = nurbs->first; } else { @@ -2131,78 +2131,78 @@ void BKE_curve_bevelList_make(Object *ob) /* check we are a single point? also check we are not a surface and that the orderu is sane, * enforced in the UI but can go wrong possibly */ if (!BKE_nurb_check_valid_u(nu)) { - bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList1"); + bl = MEM_callocN(sizeof(BevList) + 1 * sizeof(BevPoint), "makeBevelList1"); BLI_addtail(&(cu->bev), bl); - bl->nr= 0; + bl->nr = 0; } else { - if (G.rendering && cu->resolu_ren!=0) - resolu= cu->resolu_ren; + if (G.rendering && cu->resolu_ren != 0) + resolu = cu->resolu_ren; else - resolu= nu->resolu; + resolu = nu->resolu; if (nu->type == CU_POLY) { - len= nu->pntsu; - bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList2"); + len = nu->pntsu; + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList2"); BLI_addtail(&(cu->bev), bl); - if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; - else bl->poly= -1; - bl->nr= len; - bl->dupe_nr= 0; - bevp= (BevPoint *)(bl+1); - bp= nu->bp; + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; + else bl->poly = -1; + bl->nr = len; + bl->dupe_nr = 0; + bevp = (BevPoint *)(bl + 1); + bp = nu->bp; while (len--) { copy_v3_v3(bevp->vec, bp->vec); - bevp->alfa= bp->alfa; - bevp->radius= bp->radius; - bevp->weight= bp->weight; - bevp->split_tag= TRUE; + bevp->alfa = bp->alfa; + bevp->radius = bp->radius; + bevp->weight = bp->weight; + bevp->split_tag = TRUE; bevp++; bp++; } } else if (nu->type == CU_BEZIER) { - len= resolu*(nu->pntsu+ (nu->flagu & CU_NURB_CYCLIC) -1)+1; /* in case last point is not cyclic */ - bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelBPoints"); + len = resolu * (nu->pntsu + (nu->flagu & CU_NURB_CYCLIC) - 1) + 1; /* in case last point is not cyclic */ + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelBPoints"); BLI_addtail(&(cu->bev), bl); - if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; - else bl->poly= -1; - bevp= (BevPoint *)(bl+1); + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; + else bl->poly = -1; + bevp = (BevPoint *)(bl + 1); - a= nu->pntsu-1; - bezt= nu->bezt; + a = nu->pntsu - 1; + bezt = nu->bezt; if (nu->flagu & CU_NURB_CYCLIC) { a++; - prevbezt= nu->bezt+(nu->pntsu-1); + prevbezt = nu->bezt + (nu->pntsu - 1); } else { - prevbezt= bezt; + prevbezt = bezt; bezt++; } while (a--) { - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) { + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { copy_v3_v3(bevp->vec, prevbezt->vec[1]); - bevp->alfa= prevbezt->alfa; - bevp->radius= prevbezt->radius; - bevp->weight= prevbezt->weight; - bevp->split_tag= TRUE; - bevp->dupe_tag= FALSE; + bevp->alfa = prevbezt->alfa; + bevp->radius = prevbezt->radius; + bevp->weight = prevbezt->weight; + bevp->split_tag = TRUE; + bevp->dupe_tag = FALSE; bevp++; bl->nr++; - bl->dupe_nr= 1; + bl->dupe_nr = 1; } else { /* always do all three, to prevent data hanging around */ int j; /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */ - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], bezt->vec[1][j], &(bevp->vec[j]), resolu, sizeof(BevPoint)); @@ -2210,52 +2210,52 @@ void BKE_curve_bevelList_make(Object *ob) /* if both arrays are NULL do nothiong */ alfa_bezpart(prevbezt, bezt, nu, - do_tilt ? &bevp->alfa : NULL, - do_radius ? &bevp->radius : NULL, - do_weight ? &bevp->weight : NULL, + do_tilt ? &bevp->alfa : NULL, + do_radius ? &bevp->radius : NULL, + do_weight ? &bevp->weight : NULL, resolu, sizeof(BevPoint)); - if (cu->twist_mode==CU_TWIST_TANGENT) { + if (cu->twist_mode == CU_TWIST_TANGENT) { forward_diff_bezier_cotangent(prevbezt->vec[1], prevbezt->vec[2], bezt->vec[0], bezt->vec[1], bevp->tan, resolu, sizeof(BevPoint)); } /* indicate with handlecodes double points */ - if (prevbezt->h1==prevbezt->h2) { - if (prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE; + if (prevbezt->h1 == prevbezt->h2) { + if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) bevp->split_tag = TRUE; } else { - if (prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE; - else if (prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->split_tag= TRUE; + if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) bevp->split_tag = TRUE; + else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) bevp->split_tag = TRUE; } - bl->nr+= resolu; - bevp+= resolu; + bl->nr += resolu; + bevp += resolu; } - prevbezt= bezt; + prevbezt = bezt; bezt++; } - if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic: endpoint */ + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic: endpoint */ copy_v3_v3(bevp->vec, prevbezt->vec[1]); - bevp->alfa= prevbezt->alfa; - bevp->radius= prevbezt->radius; - bevp->weight= prevbezt->weight; + bevp->alfa = prevbezt->alfa; + bevp->radius = prevbezt->radius; + bevp->weight = prevbezt->weight; bl->nr++; } } else if (nu->type == CU_NURBS) { - if (nu->pntsv==1) { - len= (resolu*SEGMENTSU(nu)); + if (nu->pntsv == 1) { + len = (resolu * SEGMENTSU(nu)); - bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList3"); + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList3"); BLI_addtail(&(cu->bev), bl); - bl->nr= len; - bl->dupe_nr= 0; - if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; - else bl->poly= -1; - bevp= (BevPoint *)(bl+1); + bl->nr = len; + bl->dupe_nr = 0; + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; + else bl->poly = -1; + bevp = (BevPoint *)(bl + 1); BKE_nurb_makeCurve(nu, &bevp->vec[0], do_tilt ? &bevp->alfa : NULL, @@ -2265,47 +2265,47 @@ void BKE_curve_bevelList_make(Object *ob) } } } - nu= nu->next; + nu = nu->next; } /* STEP 2: DOUBLE POINTS AND AUTOMATIC RESOLUTION, REDUCE DATABLOCKS */ - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { if (bl->nr) { /* null bevel items come from single points */ - nr= bl->nr; - bevp1= (BevPoint *)(bl+1); - bevp0= bevp1+(nr-1); + nr = bl->nr; + bevp1 = (BevPoint *)(bl + 1); + bevp0 = bevp1 + (nr - 1); nr--; while (nr--) { - if ( fabs(bevp0->vec[0]-bevp1->vec[0])<0.00001 ) { - if ( fabs(bevp0->vec[1]-bevp1->vec[1])<0.00001 ) { - if ( fabs(bevp0->vec[2]-bevp1->vec[2])<0.00001 ) { - bevp0->dupe_tag= TRUE; + if (fabs(bevp0->vec[0] - bevp1->vec[0]) < 0.00001) { + if (fabs(bevp0->vec[1] - bevp1->vec[1]) < 0.00001) { + if (fabs(bevp0->vec[2] - bevp1->vec[2]) < 0.00001) { + bevp0->dupe_tag = TRUE; bl->dupe_nr++; } } } - bevp0= bevp1; + bevp0 = bevp1; bevp1++; } } - bl= bl->next; + bl = bl->next; } - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { - blnext= bl->next; + blnext = bl->next; if (bl->nr && bl->dupe_nr) { - nr= bl->nr- bl->dupe_nr+1; /* +1 because vectorbezier sets flag too */ - blnew= MEM_mallocN(sizeof(BevList)+nr*sizeof(BevPoint), "makeBevelList4"); + nr = bl->nr - bl->dupe_nr + 1; /* +1 because vectorbezier sets flag too */ + blnew = MEM_mallocN(sizeof(BevList) + nr * sizeof(BevPoint), "makeBevelList4"); memcpy(blnew, bl, sizeof(BevList)); - blnew->nr= 0; + blnew->nr = 0; BLI_remlink(&(cu->bev), bl); - BLI_insertlinkbefore(&(cu->bev), blnext, blnew); /* to make sure bevlijst is tuned with nurblist */ - bevp0= (BevPoint *)(bl+1); - bevp1= (BevPoint *)(blnew+1); - nr= bl->nr; + BLI_insertlinkbefore(&(cu->bev), blnext, blnew); /* to make sure bevlijst is tuned with nurblist */ + bevp0 = (BevPoint *)(bl + 1); + bevp1 = (BevPoint *)(blnew + 1); + nr = bl->nr; while (nr--) { - if (bevp0->dupe_tag==0) { + if (bevp0->dupe_tag == 0) { memcpy(bevp1, bevp0, sizeof(BevPoint)); bevp1++; blnew->nr++; @@ -2313,84 +2313,84 @@ void BKE_curve_bevelList_make(Object *ob) bevp0++; } MEM_freeN(bl); - blnew->dupe_nr= 0; + blnew->dupe_nr = 0; } - bl= blnext; + bl = blnext; } /* STEP 3: POLYS COUNT AND AUTOHOLE */ - bl= cu->bev.first; - poly= 0; + bl = cu->bev.first; + poly = 0; while (bl) { - if (bl->nr && bl->poly>=0) { + if (bl->nr && bl->poly >= 0) { poly++; - bl->poly= poly; - bl->hole= 0; + bl->poly = poly; + bl->hole = 0; } - bl= bl->next; + bl = bl->next; } /* find extreme left points, also test (turning) direction */ - if (poly>0) { - sd= sortdata= MEM_mallocN(sizeof(struct bevelsort)*poly, "makeBevelList5"); - bl= cu->bev.first; + if (poly > 0) { + sd = sortdata = MEM_mallocN(sizeof(struct bevelsort) * poly, "makeBevelList5"); + bl = cu->bev.first; while (bl) { - if (bl->poly>0) { + if (bl->poly > 0) { - min= 300000.0; - bevp= (BevPoint *)(bl+1); - nr= bl->nr; + min = 300000.0; + bevp = (BevPoint *)(bl + 1); + nr = bl->nr; while (nr--) { - if (min>bevp->vec[0]) { - min= bevp->vec[0]; - bevp1= bevp; + if (min > bevp->vec[0]) { + min = bevp->vec[0]; + bevp1 = bevp; } bevp++; } - sd->bl= bl; - sd->left= min; + sd->bl = bl; + sd->left = min; - bevp= (BevPoint *)(bl+1); - if (bevp1== bevp) bevp0= bevp+ (bl->nr-1); - else bevp0= bevp1-1; - bevp= bevp+ (bl->nr-1); - if (bevp1== bevp) bevp2= (BevPoint *)(bl+1); - else bevp2= bevp1+1; + bevp = (BevPoint *)(bl + 1); + if (bevp1 == bevp) bevp0 = bevp + (bl->nr - 1); + else bevp0 = bevp1 - 1; + bevp = bevp + (bl->nr - 1); + if (bevp1 == bevp) bevp2 = (BevPoint *)(bl + 1); + else bevp2 = bevp1 + 1; - inp= (bevp1->vec[0]- bevp0->vec[0]) * (bevp0->vec[1]- bevp2->vec[1]) + (bevp0->vec[1]- bevp1->vec[1]) * (bevp0->vec[0]- bevp2->vec[0]); + inp = (bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) + (bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]); - if (inp > 0.0f) sd->dir= 1; - else sd->dir= 0; + if (inp > 0.0f) sd->dir = 1; + else sd->dir = 0; sd++; } - bl= bl->next; + bl = bl->next; } qsort(sortdata, poly, sizeof(struct bevelsort), vergxcobev); - sd= sortdata+1; - for (a=1; abl; /* is bl a hole? */ - sd1= sortdata+ (a-1); - for (b=a-1; b>=0; b--, sd1--) { /* all polys to the left */ + sd = sortdata + 1; + for (a = 1; a < poly; a++, sd++) { + bl = sd->bl; /* is bl a hole? */ + sd1 = sortdata + (a - 1); + for (b = a - 1; b >= 0; b--, sd1--) { /* all polys to the left */ if (bevelinside(sd1->bl, bl)) { - bl->hole= 1- sd1->bl->hole; + bl->hole = 1 - sd1->bl->hole; break; } } } /* turning direction */ - if ((cu->flag & CU_3D)==0) { - sd= sortdata; - for (a=0; abl->hole==sd->dir) { - bl= sd->bl; - bevp1= (BevPoint *)(bl+1); - bevp2= bevp1+ (bl->nr-1); - nr= bl->nr/2; + if ((cu->flag & CU_3D) == 0) { + sd = sortdata; + for (a = 0; a < poly; a++, sd++) { + if (sd->bl->hole == sd->dir) { + bl = sd->bl; + bevp1 = (BevPoint *)(bl + 1); + bevp2 = bevp1 + (bl->nr - 1); + nr = bl->nr / 2; while (nr--) { SWAP(BevPoint, *bevp1, *bevp2); bevp1++; @@ -2403,40 +2403,40 @@ void BKE_curve_bevelList_make(Object *ob) } /* STEP 4: 2D-COSINES or 3D ORIENTATION */ - if ((cu->flag & CU_3D)==0) { + if ((cu->flag & CU_3D) == 0) { /* note: bevp->dir and bevp->quat are not needed for beveling but are * used when making a path from a 2D curve, therefor they need to be set - Campbell */ - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { if (bl->nr < 2) { /* do nothing */ } - else if (bl->nr==2) { /* 2 pnt, treat separate */ - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+1; + else if (bl->nr == 2) { /* 2 pnt, treat separate */ + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + 1; - x1= bevp1->vec[0]- bevp2->vec[0]; - y1= bevp1->vec[1]- bevp2->vec[1]; + x1 = bevp1->vec[0] - bevp2->vec[0]; + y1 = bevp1->vec[1] - bevp2->vec[1]; calc_bevel_sin_cos(x1, y1, -x1, -y1, &(bevp1->sina), &(bevp1->cosa)); - bevp2->sina= bevp1->sina; - bevp2->cosa= bevp1->cosa; + bevp2->sina = bevp1->sina; + bevp2->cosa = bevp1->cosa; /* fill in dir & quat */ make_bevel_list_segment_3D(bl); } else { - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - x1= bevp1->vec[0]- bevp0->vec[0]; - x2= bevp1->vec[0]- bevp2->vec[0]; - y1= bevp1->vec[1]- bevp0->vec[1]; - y2= bevp1->vec[1]- bevp2->vec[1]; + x1 = bevp1->vec[0] - bevp0->vec[0]; + x2 = bevp1->vec[0] - bevp2->vec[0]; + y1 = bevp1->vec[1] - bevp0->vec[1]; + y2 = bevp1->vec[1] - bevp2->vec[1]; calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa)); @@ -2446,44 +2446,44 @@ void BKE_curve_bevelList_make(Object *ob) vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); /* done with inline make_bevel_list_3D_zup */ - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } /* correct non-cyclic cases */ - if (bl->poly== -1) { - bevp= (BevPoint *)(bl+1); - bevp1= bevp+1; - bevp->sina= bevp1->sina; - bevp->cosa= bevp1->cosa; - bevp= (BevPoint *)(bl+1); - bevp+= (bl->nr-1); - bevp1= bevp-1; - bevp->sina= bevp1->sina; - bevp->cosa= bevp1->cosa; + if (bl->poly == -1) { + bevp = (BevPoint *)(bl + 1); + bevp1 = bevp + 1; + bevp->sina = bevp1->sina; + bevp->cosa = bevp1->cosa; + bevp = (BevPoint *)(bl + 1); + bevp += (bl->nr - 1); + bevp1 = bevp - 1; + bevp->sina = bevp1->sina; + bevp->cosa = bevp1->cosa; /* correct for the dir/quat, see above why its needed */ bevel_list_cyclic_fix_3D(bl); } } - bl= bl->next; + bl = bl->next; } } else { /* 3D Curves */ - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { if (bl->nr < 2) { /* do nothing */ } - else if (bl->nr==2) { /* 2 pnt, treat separate */ + else if (bl->nr == 2) { /* 2 pnt, treat separate */ make_bevel_list_segment_3D(bl); } else { - make_bevel_list_3D(bl, (int)(resolu*cu->twist_smooth), cu->twist_mode); + make_bevel_list_3D(bl, (int)(resolu * cu->twist_smooth), cu->twist_mode); } - bl= bl->next; + bl = bl->next; } } } @@ -2501,111 +2501,111 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n float *p1, *p2, *p3, pt[3]; float dvec_a[3], dvec_b[3]; float len, len_a, len_b; - const float eps= 1e-5; + const float eps = 1e-5; - if (bezt->h1==0 && bezt->h2==0) { + if (bezt->h1 == 0 && bezt->h2 == 0) { return; } - p2= bezt->vec[1]; + p2 = bezt->vec[1]; - if (prev==NULL) { - p3= next->vec[1]; - pt[0]= 2.0f*p2[0] - p3[0]; - pt[1]= 2.0f*p2[1] - p3[1]; - pt[2]= 2.0f*p2[2] - p3[2]; - p1= pt; + if (prev == NULL) { + p3 = next->vec[1]; + pt[0] = 2.0f * p2[0] - p3[0]; + pt[1] = 2.0f * p2[1] - p3[1]; + pt[2] = 2.0f * p2[2] - p3[2]; + p1 = pt; } else { - p1= prev->vec[1]; + p1 = prev->vec[1]; } - if (next==NULL) { - pt[0]= 2.0f*p2[0] - p1[0]; - pt[1]= 2.0f*p2[1] - p1[1]; - pt[2]= 2.0f*p2[2] - p1[2]; - p3= pt; + if (next == NULL) { + pt[0] = 2.0f * p2[0] - p1[0]; + pt[1] = 2.0f * p2[1] - p1[1]; + pt[2] = 2.0f * p2[2] - p1[2]; + p3 = pt; } else { - p3= next->vec[1]; + p3 = next->vec[1]; } sub_v3_v3v3(dvec_a, p2, p1); sub_v3_v3v3(dvec_b, p3, p2); if (mode != 0) { - len_a= dvec_a[0]; - len_b= dvec_b[0]; + len_a = dvec_a[0]; + len_b = dvec_b[0]; } else { - len_a= len_v3(dvec_a); - len_b= len_v3(dvec_b); + len_a = len_v3(dvec_a); + len_b = len_v3(dvec_b); } - if (len_a==0.0f) len_a=1.0f; - if (len_b==0.0f) len_b=1.0f; + if (len_a == 0.0f) len_a = 1.0f; + if (len_b == 0.0f) len_b = 1.0f; if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ float tvec[3]; - tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a; - tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a; - tvec[2]= dvec_b[2]/len_b + dvec_a[2]/len_a; - len= len_v3(tvec) * 2.5614f; + tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a; + tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a; + tvec[2] = dvec_b[2] / len_b + dvec_a[2] / len_a; + len = len_v3(tvec) * 2.5614f; - if (len!=0.0f) { - int leftviolate=0, rightviolate=0; /* for mode==2 */ + if (len != 0.0f) { + int leftviolate = 0, rightviolate = 0; /* for mode==2 */ - if (len_a>5.0f*len_b) len_a= 5.0f*len_b; - if (len_b>5.0f*len_a) len_b= 5.0f*len_a; + if (len_a > 5.0f * len_b) len_a = 5.0f * len_b; + if (len_b > 5.0f * len_a) len_b = 5.0f * len_a; if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { - len_a/=len; - madd_v3_v3v3fl(p2-3, p2, tvec, -len_a); + len_a /= len; + madd_v3_v3v3fl(p2 - 3, p2, tvec, -len_a); - if ((bezt->h1==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ - float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; - float ydiff2= next->vec[1][1] - bezt->vec[1][1]; + if ((bezt->h1 == HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ + float ydiff1 = prev->vec[1][1] - bezt->vec[1][1]; + float ydiff2 = next->vec[1][1] - bezt->vec[1][1]; if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { - bezt->vec[0][1]= bezt->vec[1][1]; + bezt->vec[0][1] = bezt->vec[1][1]; } else { /* handles should not be beyond y coord of two others */ if (ydiff1 <= 0.0f) { if (prev->vec[1][1] > bezt->vec[0][1]) { - bezt->vec[0][1]= prev->vec[1][1]; - leftviolate= 1; + bezt->vec[0][1] = prev->vec[1][1]; + leftviolate = 1; } } else { if (prev->vec[1][1] < bezt->vec[0][1]) { - bezt->vec[0][1]= prev->vec[1][1]; - leftviolate= 1; + bezt->vec[0][1] = prev->vec[1][1]; + leftviolate = 1; } } } } } if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { - len_b/=len; - madd_v3_v3v3fl(p2+3, p2, tvec, len_b); + len_b /= len; + madd_v3_v3v3fl(p2 + 3, p2, tvec, len_b); - if ((bezt->h2==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ - float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; - float ydiff2= next->vec[1][1] - bezt->vec[1][1]; + if ((bezt->h2 == HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ + float ydiff1 = prev->vec[1][1] - bezt->vec[1][1]; + float ydiff2 = next->vec[1][1] - bezt->vec[1][1]; if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { - bezt->vec[2][1]= bezt->vec[1][1]; + bezt->vec[2][1] = bezt->vec[1][1]; } else { /* andles should not be beyond y coord of two others */ if (ydiff1 <= 0.0f) { if (next->vec[1][1] < bezt->vec[2][1]) { - bezt->vec[2][1]= next->vec[1][1]; - rightviolate= 1; + bezt->vec[2][1] = next->vec[1][1]; + rightviolate = 1; } } else { if (next->vec[1][1] > bezt->vec[2][1]) { - bezt->vec[2][1]= next->vec[1][1]; - rightviolate= 1; + bezt->vec[2][1] = next->vec[1][1]; + rightviolate = 1; } } } @@ -2615,32 +2615,32 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n float h1[3], h2[3]; float dot; - sub_v3_v3v3(h1, p2-3, p2); - sub_v3_v3v3(h2, p2, p2+3); + sub_v3_v3v3(h1, p2 - 3, p2); + sub_v3_v3v3(h2, p2, p2 + 3); - len_a= normalize_v3(h1); - len_b= normalize_v3(h2); + len_a = normalize_v3(h1); + len_b = normalize_v3(h2); - dot= dot_v3v3(h1, h2); + dot = dot_v3v3(h1, h2); if (leftviolate) { mul_v3_fl(h1, dot * len_b); - sub_v3_v3v3(p2+3, p2, h1); + sub_v3_v3v3(p2 + 3, p2, h1); } else { mul_v3_fl(h2, dot * len_a); - add_v3_v3v3(p2-3, p2, h2); + add_v3_v3v3(p2 - 3, p2, h2); } } } } - if (bezt->h1==HD_VECT) { /* vector */ - madd_v3_v3v3fl(p2-3, p2, dvec_a, -1.0f/3.0f); + if (bezt->h1 == HD_VECT) { /* vector */ + madd_v3_v3v3fl(p2 - 3, p2, dvec_a, -1.0f / 3.0f); } - if (bezt->h2==HD_VECT) { - madd_v3_v3v3fl(p2+3, p2, dvec_b, 1.0f/3.0f); + if (bezt->h2 == HD_VECT) { + madd_v3_v3v3fl(p2 + 3, p2, dvec_b, 1.0f / 3.0f); } if (skip_align) { @@ -2650,44 +2650,44 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n return; } - len_b= len_v3v3(p2, p2+3); - len_a= len_v3v3(p2, p2-3); - if (len_a==0.0f) len_a= 1.0f; - if (len_b==0.0f) len_b= 1.0f; + len_b = len_v3v3(p2, p2 + 3); + len_a = len_v3v3(p2, p2 - 3); + if (len_a == 0.0f) len_a = 1.0f; + if (len_b == 0.0f) len_b = 1.0f; if (bezt->f1 & SELECT) { /* order of calculation */ - if (bezt->h2==HD_ALIGN) { /* aligned */ - if (len_a>eps) { - len= len_b/len_a; - p2[3]= p2[0]+len*(p2[0] - p2[-3]); - p2[4]= p2[1]+len*(p2[1] - p2[-2]); - p2[5]= p2[2]+len*(p2[2] - p2[-1]); + if (bezt->h2 == HD_ALIGN) { /* aligned */ + if (len_a > eps) { + len = len_b / len_a; + p2[3] = p2[0] + len * (p2[0] - p2[-3]); + p2[4] = p2[1] + len * (p2[1] - p2[-2]); + p2[5] = p2[2] + len * (p2[2] - p2[-1]); } } - if (bezt->h1==HD_ALIGN) { - if (len_b>eps) { - len= len_a/len_b; - p2[-3]= p2[0]+len*(p2[0] - p2[3]); - p2[-2]= p2[1]+len*(p2[1] - p2[4]); - p2[-1]= p2[2]+len*(p2[2] - p2[5]); + if (bezt->h1 == HD_ALIGN) { + if (len_b > eps) { + len = len_a / len_b; + p2[-3] = p2[0] + len * (p2[0] - p2[3]); + p2[-2] = p2[1] + len * (p2[1] - p2[4]); + p2[-1] = p2[2] + len * (p2[2] - p2[5]); } } } else { - if (bezt->h1==HD_ALIGN) { - if (len_b>eps) { - len= len_a/len_b; - p2[-3]= p2[0]+len*(p2[0] - p2[3]); - p2[-2]= p2[1]+len*(p2[1] - p2[4]); - p2[-1]= p2[2]+len*(p2[2] - p2[5]); + if (bezt->h1 == HD_ALIGN) { + if (len_b > eps) { + len = len_a / len_b; + p2[-3] = p2[0] + len * (p2[0] - p2[3]); + p2[-2] = p2[1] + len * (p2[1] - p2[4]); + p2[-1] = p2[2] + len * (p2[2] - p2[5]); } } - if (bezt->h2==HD_ALIGN) { /* aligned */ - if (len_a>eps) { - len= len_b/len_a; - p2[3]= p2[0]+len*(p2[0] - p2[-3]); - p2[4]= p2[1]+len*(p2[1] - p2[-2]); - p2[5]= p2[2]+len*(p2[2] - p2[-1]); + if (bezt->h2 == HD_ALIGN) { /* aligned */ + if (len_a > eps) { + len = len_b / len_a; + p2[3] = p2[0] + len * (p2[0] - p2[-3]); + p2[4] = p2[1] + len * (p2[1] - p2[-2]); + p2[5] = p2[2] + len * (p2[2] - p2[-1]); } } } @@ -2699,20 +2699,20 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align) short a; if (nu->type != CU_BEZIER) return; - if (nu->pntsu<2) return; + if (nu->pntsu < 2) return; - a= nu->pntsu; - bezt= nu->bezt; - if (nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1); - else prev= NULL; - next= bezt+1; + a = nu->pntsu; + bezt = nu->bezt; + if (nu->flagu & CU_NURB_CYCLIC) prev = bezt + (a - 1); + else prev = NULL; + next = bezt + 1; while (a--) { calchandleNurb_intern(bezt, prev, next, 0, skip_align); - prev= bezt; - if (a==1) { - if (nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; - else next= NULL; + prev = bezt; + if (a == 1) { + if (nu->flagu & CU_NURB_CYCLIC) next = nu->bezt; + else next = NULL; } else next++; @@ -2745,27 +2745,27 @@ void BKE_nurb_handles_test(Nurb *nu) if (nu->type != CU_BEZIER) return; - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - flag= 0; + flag = 0; if (bezt->f1 & SELECT) flag++; if (bezt->f2 & SELECT) flag += 2; if (bezt->f3 & SELECT) flag += 4; - if ( !(flag==0 || flag==7) ) { + if (!(flag == 0 || flag == 7) ) { if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ - bezt->h1= HD_ALIGN; + bezt->h1 = HD_ALIGN; } if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ - bezt->h2= HD_ALIGN; + bezt->h2 = HD_ALIGN; } - if (bezt->h1==HD_VECT) { /* vector */ - if (flag < 4) bezt->h1= 0; + if (bezt->h1 == HD_VECT) { /* vector */ + if (flag < 4) bezt->h1 = 0; } - if (bezt->h2==HD_VECT) { /* vector */ - if ( flag > 3) bezt->h2= 0; + if (bezt->h2 == HD_VECT) { /* vector */ + if (flag > 3) bezt->h2 = 0; } } bezt++; @@ -2781,64 +2781,64 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) BezTriple *bezt2, *bezt1, *bezt0; int i, align, leftsmall, rightsmall; - if (nu==NULL || nu->bezt==NULL) return; + if (nu == NULL || nu->bezt == NULL) return; bezt2 = nu->bezt; - bezt1 = bezt2 + (nu->pntsu-1); + bezt1 = bezt2 + (nu->pntsu - 1); bezt0 = bezt1 - 1; i = nu->pntsu; while (i--) { - align= leftsmall= rightsmall= 0; + align = leftsmall = rightsmall = 0; /* left handle: */ - if (flag==0 || (bezt1->f1 & flag) ) { - bezt1->h1= 0; + if (flag == 0 || (bezt1->f1 & flag) ) { + bezt1->h1 = 0; /* distance too short: vectorhandle */ if (len_v3v3(bezt1->vec[1], bezt0->vec[1]) < 0.0001f) { - bezt1->h1= HD_VECT; - leftsmall= 1; + bezt1->h1 = HD_VECT; + leftsmall = 1; } else { /* aligned handle? */ if (dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001f) { - align= 1; - bezt1->h1= HD_ALIGN; + align = 1; + bezt1->h1 = HD_ALIGN; } /* or vector handle? */ if (dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f) - bezt1->h1= HD_VECT; + bezt1->h1 = HD_VECT; } } /* right handle: */ - if (flag==0 || (bezt1->f3 & flag) ) { - bezt1->h2= 0; + if (flag == 0 || (bezt1->f3 & flag) ) { + bezt1->h2 = 0; /* distance too short: vectorhandle */ if (len_v3v3(bezt1->vec[1], bezt2->vec[1]) < 0.0001f) { - bezt1->h2= HD_VECT; - rightsmall= 1; + bezt1->h2 = HD_VECT; + rightsmall = 1; } else { /* aligned handle? */ - if (align) bezt1->h2= HD_ALIGN; + if (align) bezt1->h2 = HD_ALIGN; /* or vector handle? */ if (dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f) - bezt1->h2= HD_VECT; + bezt1->h2 = HD_VECT; } } - if (leftsmall && bezt1->h2==HD_ALIGN) bezt1->h2= 0; - if (rightsmall && bezt1->h1==HD_ALIGN) bezt1->h1= 0; + if (leftsmall && bezt1->h2 == HD_ALIGN) bezt1->h2 = 0; + if (rightsmall && bezt1->h1 == HD_ALIGN) bezt1->h1 = 0; /* undesired combination: */ - if (bezt1->h1==HD_ALIGN && bezt1->h2==HD_VECT) bezt1->h1= 0; - if (bezt1->h2==HD_ALIGN && bezt1->h1==HD_VECT) bezt1->h2= 0; + if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT) bezt1->h1 = 0; + if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT) bezt1->h2 = 0; - bezt0= bezt1; - bezt1= bezt2; + bezt0 = bezt1; + bezt1 = bezt2; bezt2++; } @@ -2849,10 +2849,10 @@ void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag) { Nurb *nu; - nu= editnurb->first; + nu = editnurb->first; while (nu) { BKE_nurb_handles_autocalc(nu, flag); - nu= nu->next; + nu = nu->next; } } @@ -2866,19 +2866,19 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) /* code==6: Clear align, like 3 but no toggle */ Nurb *nu; BezTriple *bezt; - short a, ok=0; + short a, ok = 0; - if (code==1 || code==2) { - nu= editnurb->first; + if (code == 1 || code == 2) { + nu = editnurb->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= code; - if (bezt->f3 & SELECT) bezt->h2= code; - if (bezt->h1!=bezt->h2) { + if (bezt->f1 & SELECT) bezt->h1 = code; + if (bezt->f3 & SELECT) bezt->h2 = code; + if (bezt->h1 != bezt->h2) { if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO)) bezt->h1 = HD_FREE; if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO)) bezt->h2 = HD_FREE; } @@ -2887,13 +2887,13 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) } BKE_nurb_handles_calc(nu); } - nu= nu->next; + nu = nu->next; } } else { /* there is 1 handle not FREE: FREE it all, else make ALIGNED */ - nu= editnurb->first; + nu = editnurb->first; if (code == 5) { ok = HD_ALIGN; } @@ -2904,34 +2904,34 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) /* Toggle */ while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if ((bezt->f1 & SELECT) && bezt->h1) ok= 1; - if ((bezt->f3 & SELECT) && bezt->h2) ok= 1; + if ((bezt->f1 & SELECT) && bezt->h1) ok = 1; + if ((bezt->f3 & SELECT) && bezt->h2) ok = 1; if (ok) break; bezt++; } } - nu= nu->next; + nu = nu->next; } - if (ok) ok= HD_FREE; - else ok= HD_ALIGN; + if (ok) ok = HD_FREE; + else ok = HD_ALIGN; } - nu= editnurb->first; + nu = editnurb->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->f1 & SELECT) bezt->h1= ok; - if (bezt->f3 & SELECT) bezt->h2= ok; + if (bezt->f1 & SELECT) bezt->h1 = ok; + if (bezt->f3 & SELECT) bezt->h2 = ok; bezt++; } BKE_nurb_handles_calc(nu); } - nu= nu->next; + nu = nu->next; } } } @@ -2939,9 +2939,9 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) static void swapdata(void *adr1, void *adr2, int len) { - if (len<=0) return; + if (len <= 0) return; - if (len<65) { + if (len < 65) { char adr[64]; memcpy(adr, adr1, len); @@ -2951,7 +2951,7 @@ static void swapdata(void *adr1, void *adr2, int len) else { char *adr; - adr= (char *)MEM_mallocN(len, "curve swap"); + adr = (char *)MEM_mallocN(len, "curve swap"); memcpy(adr, adr1, len); memcpy(adr1, adr2, len); memcpy(adr2, adr, len); @@ -2966,44 +2966,44 @@ void BKE_nurb_direction_switch(Nurb *nu) float *fp1, *fp2, *tempf; int a, b; - if (nu->pntsu==1 && nu->pntsv==1) return; + if (nu->pntsu == 1 && nu->pntsv == 1) return; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt1= nu->bezt; - bezt2= bezt1+(a-1); - if (a & 1) a+= 1; /* if odd, also swap middle content */ - a/= 2; - while (a>0) { - if (bezt1!=bezt2) SWAP(BezTriple, *bezt1, *bezt2); + a = nu->pntsu; + bezt1 = nu->bezt; + bezt2 = bezt1 + (a - 1); + if (a & 1) a += 1; /* if odd, also swap middle content */ + a /= 2; + while (a > 0) { + if (bezt1 != bezt2) SWAP(BezTriple, *bezt1, *bezt2); swapdata(bezt1->vec[0], bezt1->vec[2], 12); - if (bezt1!=bezt2) swapdata(bezt2->vec[0], bezt2->vec[2], 12); + if (bezt1 != bezt2) swapdata(bezt2->vec[0], bezt2->vec[2], 12); SWAP(char, bezt1->h1, bezt1->h2); SWAP(short, bezt1->f1, bezt1->f3); - if (bezt1!=bezt2) { + if (bezt1 != bezt2) { SWAP(char, bezt2->h1, bezt2->h2); SWAP(short, bezt2->f1, bezt2->f3); - bezt1->alfa= -bezt1->alfa; - bezt2->alfa= -bezt2->alfa; + bezt1->alfa = -bezt1->alfa; + bezt2->alfa = -bezt2->alfa; } a--; bezt1++; bezt2--; } } - else if (nu->pntsv==1) { - a= nu->pntsu; - bp1= nu->bp; - bp2= bp1+(a-1); - a/= 2; - while (bp1!=bp2 && a>0) { + else if (nu->pntsv == 1) { + a = nu->pntsu; + bp1 = nu->bp; + bp2 = bp1 + (a - 1); + a /= 2; + while (bp1 != bp2 && a > 0) { SWAP(BPoint, *bp1, *bp2); a--; - bp1->alfa= -bp1->alfa; - bp2->alfa= -bp2->alfa; + bp1->alfa = -bp1->alfa; + bp2->alfa = -bp2->alfa; bp1++; bp2--; } @@ -3011,33 +3011,33 @@ void BKE_nurb_direction_switch(Nurb *nu) /* no knots for too short paths */ if (nu->knotsu) { /* inverse knots */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2= fp1+(a-1); - a/= 2; - while (fp1!=fp2 && a>0) { + a = KNOTSU(nu); + fp1 = nu->knotsu; + fp2 = fp1 + (a - 1); + a /= 2; + while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; fp1++; fp2--; } /* and make in increasing order again */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); + a = KNOTSU(nu); + fp1 = nu->knotsu; + fp2 = tempf = MEM_mallocN(sizeof(float) * a, "switchdirect"); while (a--) { - fp2[0]= fabs(fp1[1]-fp1[0]); + fp2[0] = fabs(fp1[1] - fp1[0]); fp1++; fp2++; } - a= KNOTSU(nu)-1; - fp1= nu->knotsu; - fp2= tempf; - fp1[0]= 0.0; + a = KNOTSU(nu) - 1; + fp1 = nu->knotsu; + fp2 = tempf; + fp1[0] = 0.0; fp1++; while (a--) { - fp1[0]= fp1[-1]+fp2[0]; + fp1[0] = fp1[-1] + fp2[0]; fp1++; fp2++; } @@ -3047,14 +3047,14 @@ void BKE_nurb_direction_switch(Nurb *nu) } else { - for (b=0; bpntsv; b++) { + for (b = 0; b < nu->pntsv; b++) { - bp1= nu->bp+b*nu->pntsu; - a= nu->pntsu; - bp2= bp1+(a-1); - a/= 2; + bp1 = nu->bp + b * nu->pntsu; + a = nu->pntsu; + bp2 = bp1 + (a - 1); + a /= 2; - while (bp1!=bp2 && a>0) { + while (bp1 != bp2 && a > 0) { SWAP(BPoint, *bp1, *bp2); a--; bp1++; @@ -3065,28 +3065,28 @@ void BKE_nurb_direction_switch(Nurb *nu) } -float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3] +float (*BKE_curve_vertexCos_get(Curve * UNUSED(cu), ListBase * lb, int *numVerts_r))[3] { int i, numVerts = *numVerts_r = BKE_nurbList_verts_count(lb); - float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); + float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos) * numVerts, "cu_vcos"); Nurb *nu; co = cos[0]; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - copy_v3_v3(co, bezt->vec[0]); co+=3; - copy_v3_v3(co, bezt->vec[1]); co+=3; - copy_v3_v3(co, bezt->vec[2]); co+=3; + for (i = 0; i < nu->pntsu; i++, bezt++) { + copy_v3_v3(co, bezt->vec[0]); co += 3; + copy_v3_v3(co, bezt->vec[1]); co += 3; + copy_v3_v3(co, bezt->vec[2]); co += 3; } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - copy_v3_v3(co, bp->vec); co+=3; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + copy_v3_v3(co, bp->vec); co += 3; } } } @@ -3100,21 +3100,21 @@ void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos Nurb *nu; int i; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - copy_v3_v3(bezt->vec[0], co); co+=3; - copy_v3_v3(bezt->vec[1], co); co+=3; - copy_v3_v3(bezt->vec[2], co); co+=3; + for (i = 0; i < nu->pntsu; i++, bezt++) { + copy_v3_v3(bezt->vec[0], co); co += 3; + copy_v3_v3(bezt->vec[1], co); co += 3; + copy_v3_v3(bezt->vec[2], co); co += 3; } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - copy_v3_v3(bp->vec, co); co+=3; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + copy_v3_v3(bp->vec, co); co += 3; } } @@ -3122,29 +3122,29 @@ void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos } } -float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key))[3] +float (*BKE_curve_keyVertexCos_get(Curve * UNUSED(cu), ListBase * lb, float *key))[3] { int i, numVerts = BKE_nurbList_verts_count(lb); - float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); + float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos) * numVerts, "cu_vcos"); Nurb *nu; co = cos[0]; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - copy_v3_v3(co, key); co+=3; key+=3; - copy_v3_v3(co, key); co+=3; key+=3; - copy_v3_v3(co, key); co+=3; key+=3; - key+=3; /* skip tilt */ + for (i = 0; i < nu->pntsu; i++, bezt++) { + copy_v3_v3(co, key); co += 3; key += 3; + copy_v3_v3(co, key); co += 3; key += 3; + copy_v3_v3(co, key); co += 3; key += 3; + key += 3; /* skip tilt */ } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - copy_v3_v3(co, key); co+=3; key+=3; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + copy_v3_v3(co, key); co += 3; key += 3; key++; /* skip tilt */ } } @@ -3158,22 +3158,22 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) Nurb *nu; int i; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - key+=3*3; - bezt->alfa= *key; - key+=3; + for (i = 0; i < nu->pntsu; i++, bezt++) { + key += 3 * 3; + bezt->alfa = *key; + key += 3; } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - key+=3; - bp->alfa= *key; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + key += 3; + bp->alfa = *key; key++; } } @@ -3182,31 +3182,31 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) int BKE_nurb_check_valid_u(struct Nurb *nu) { - if (nu==NULL) return 0; - if (nu->pntsu <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ - - if (nu->pntsu < nu->orderu) return 0; - if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ - if (nu->orderu==4) { - if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */ + if (nu == NULL) return 0; + if (nu->pntsu <= 1) return 0; + if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ + + if (nu->pntsu < nu->orderu) return 0; + if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ + if (nu->orderu == 4) { + if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */ } - else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */ + else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */ } return 1; } int BKE_nurb_check_valid_v(struct Nurb *nu) { - if (nu==NULL) return 0; - if (nu->pntsv <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ - - if (nu->pntsv < nu->orderv) return 0; - if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ - if (nu->orderv==4) { - if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */ + if (nu == NULL) return 0; + if (nu->pntsv <= 1) return 0; + if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ + + if (nu->pntsv < nu->orderv) return 0; + if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ + if (nu->orderv == 4) { + if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */ } - else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */ + else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */ } return 1; } @@ -3214,13 +3214,13 @@ int BKE_nurb_check_valid_v(struct Nurb *nu) int BKE_nurb_order_clamp_u(struct Nurb *nu) { int change = 0; - if (nu->pntsuorderu) { - nu->orderu= nu->pntsu; - change= 1; + if (nu->pntsu < nu->orderu) { + nu->orderu = nu->pntsu; + change = 1; } - if (((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { + if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { CLAMP(nu->orderu, 3, 4); - change= 1; + change = 1; } return change; } @@ -3228,13 +3228,13 @@ int BKE_nurb_order_clamp_u(struct Nurb *nu) int BKE_nurb_order_clamp_v(struct Nurb *nu) { int change = 0; - if (nu->pntsvorderv) { - nu->orderv= nu->pntsv; - change= 1; + if (nu->pntsv < nu->orderv) { + nu->orderv = nu->pntsv; + change = 1; } - if (((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { + if (((nu->flagv & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { CLAMP(nu->orderv, 3, 4); - change= 1; + change = 1; } return change; } @@ -3253,10 +3253,10 @@ ListBase *BKE_curve_nurbs_get(Curve *cu) /* basic vertex data functions */ int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) { - ListBase *nurb_lb= BKE_curve_nurbs_get(cu); + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; - for (nu= nurb_lb->first; nu; nu= nu->next) + for (nu = nurb_lb->first; nu; nu = nu->next) BKE_nurb_minmax(nu, min, max); return (nurb_lb->first != NULL); @@ -3264,20 +3264,20 @@ int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) int BKE_curve_center_median(Curve *cu, float cent[3]) { - ListBase *nurb_lb= BKE_curve_nurbs_get(cu); + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; - int total= 0; + int total = 0; zero_v3(cent); - for (nu= nurb_lb->first; nu; nu= nu->next) { + for (nu = nurb_lb->first; nu; nu = nu->next) { int i; if (nu->type == CU_BEZIER) { BezTriple *bezt; - i= nu->pntsu; + i = nu->pntsu; total += i * 3; - for (bezt= nu->bezt; i--; bezt++) { + for (bezt = nu->bezt; i--; bezt++) { add_v3_v3(cent, bezt->vec[0]); add_v3_v3(cent, bezt->vec[1]); add_v3_v3(cent, bezt->vec[2]); @@ -3285,15 +3285,15 @@ int BKE_curve_center_median(Curve *cu, float cent[3]) } else { BPoint *bp; - i= nu->pntsu*nu->pntsv; + i = nu->pntsu * nu->pntsv; total += i; - for (bp= nu->bp; i--; bp++) { + for (bp = nu->bp; i--; bp++) { add_v3_v3(cent, bp->vec); } } } - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); return (total != 0); } @@ -3312,25 +3312,25 @@ int BKE_curve_center_bounds(Curve *cu, float cent[3]) void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) { - ListBase *nurb_lb= BKE_curve_nurbs_get(cu); + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; int i; - for (nu= nurb_lb->first; nu; nu= nu->next) { + for (nu = nurb_lb->first; nu; nu = nu->next) { BezTriple *bezt; BPoint *bp; if (nu->type == CU_BEZIER) { - i= nu->pntsu; - for (bezt= nu->bezt; i--; bezt++) { + i = nu->pntsu; + for (bezt = nu->bezt; i--; bezt++) { add_v3_v3(bezt->vec[0], offset); add_v3_v3(bezt->vec[1], offset); add_v3_v3(bezt->vec[2], offset); } } else { - i= nu->pntsu*nu->pntsv; - for (bp= nu->bp; i--; bp++) { + i = nu->pntsu * nu->pntsv; + for (bp = nu->bp; i--; bp++) { add_v3_v3(bp->vec, offset); } } @@ -3338,9 +3338,9 @@ void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) if (do_keys && cu->key) { KeyBlock *kb; - for (kb=cu->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; - for (i= kb->totelem; i--; fp+=3) { + for (kb = cu->key->block.first; kb; kb = kb->next) { + float *fp = kb->data; + for (i = kb->totelem; i--; fp += 3) { add_v3_v3(fp, offset); } } @@ -3349,13 +3349,13 @@ void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) void BKE_curve_delete_material_index(Curve *cu, int index) { - const int curvetype= BKE_curve_type_get(cu); + const int curvetype = BKE_curve_type_get(cu); if (curvetype == OB_FONT) { - struct CharInfo *info= cu->strinfo; + struct CharInfo *info = cu->strinfo; int i; - for (i= cu->len-1; i >= 0; i--, info++) { - if (info->mat_nr && info->mat_nr>=index) { + for (i = cu->len - 1; i >= 0; i--, info++) { + if (info->mat_nr && info->mat_nr >= index) { info->mat_nr--; } } @@ -3363,8 +3363,8 @@ void BKE_curve_delete_material_index(Curve *cu, int index) else { Nurb *nu; - for (nu= cu->nurb.first; nu; nu= nu->next) { - if (nu->mat_nr && nu->mat_nr>=index) { + for (nu = cu->nurb.first; nu; nu = nu->next) { + if (nu->mat_nr && nu->mat_nr >= index) { nu->mat_nr--; if (curvetype == OB_CURVE) nu->charidx--; } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index fa57cc7ce44..0ec0c16073b 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -60,7 +60,7 @@ #include "BKE_curve.h" #include "BKE_displist.h" -static ListBase ttfdata= {NULL, NULL}; +static ListBase ttfdata = {NULL, NULL}; /* The vfont code */ void BKE_vfont_free(struct VFont *vf) @@ -90,13 +90,13 @@ void BKE_vfont_free(struct VFont *vf) } } -static void *builtin_font_data= NULL; -static int builtin_font_size= 0; +static void *builtin_font_data = NULL; +static int builtin_font_size = 0; void BKE_vfont_builtin_register(void *mem, int size) { - builtin_font_data= mem; - builtin_font_size= size; + builtin_font_data = mem; + builtin_font_size = size; } static PackedFile *get_builtin_packedfile(void) @@ -107,7 +107,7 @@ static PackedFile *get_builtin_packedfile(void) return NULL; } else { - void *mem= MEM_mallocN(builtin_font_size, "vfd_builtin"); + void *mem = MEM_mallocN(builtin_font_size, "vfd_builtin"); memcpy(mem, builtin_font_data, builtin_font_size); @@ -119,10 +119,10 @@ void BKE_vfont_free_global_ttf(void) { struct TmpFont *tf; - for (tf= ttfdata.first; tf; tf= tf->next) { - if (tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */ - tf->pf= NULL; - tf->vfont= NULL; + for (tf = ttfdata.first; tf; tf = tf->next) { + if (tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */ + tf->pf = NULL; + tf->vfont = NULL; } BLI_freelistN(&ttfdata); } @@ -131,7 +131,7 @@ struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont) { struct TmpFont *tmpfnt = NULL; - if (vfont==NULL) return NULL; + if (vfont == NULL) return NULL; // Try finding the font from font list tmpfnt = ttfdata.first; @@ -148,7 +148,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) struct TmpFont *tmpfnt = NULL; PackedFile *tpf; - if (vfont==NULL) return NULL; + if (vfont == NULL) return NULL; // Try finding the font from font list tmpfnt = BKE_vfont_find_tmpfont(vfont); @@ -157,37 +157,37 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (!vfont->data) { PackedFile *pf; - if (strcmp(vfont->name, FO_BUILTIN_NAME)==0) { - pf= get_builtin_packedfile(); + if (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) { + pf = get_builtin_packedfile(); } else { if (vfont->packedfile) { - pf= vfont->packedfile; + pf = vfont->packedfile; // We need to copy a tmp font to memory unless it is already there if (!tmpfnt) { - tpf= MEM_callocN(sizeof(*tpf), "PackedFile"); - tpf->data= MEM_mallocN(pf->size, "packFile"); - tpf->size= pf->size; + tpf = MEM_callocN(sizeof(*tpf), "PackedFile"); + tpf->data = MEM_mallocN(pf->size, "packFile"); + tpf->size = pf->size; memcpy(tpf->data, pf->data, pf->size); // Add temporary packed file to globals - tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf= tpf; - tmpfnt->vfont= vfont; + tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); + tmpfnt->pf = tpf; + tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); } } else { - pf= newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); + pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); if (!tmpfnt) { - tpf= newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); + tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); // Add temporary packed file to globals - tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf= tpf; - tmpfnt->vfont= vfont; + tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); + tmpfnt->pf = tpf; + tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); } } @@ -195,12 +195,12 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) printf("Font file doesn't exist: %s\n", vfont->name); strcpy(vfont->name, FO_BUILTIN_NAME); - pf= get_builtin_packedfile(); + pf = get_builtin_packedfile(); } } if (pf) { - vfont->data= BLI_vfontdata_from_freetypefont(pf); + vfont->data = BLI_vfontdata_from_freetypefont(pf); if (pf != vfont->packedfile) { freePackedFile(pf); } @@ -213,17 +213,17 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) VFont *BKE_vfont_load(Main *bmain, const char *name) { char filename[FILE_MAXFILE]; - VFont *vfont= NULL; + VFont *vfont = NULL; PackedFile *pf; PackedFile *tpf = NULL; int is_builtin; struct TmpFont *tmpfnt; - if (strcmp(name, FO_BUILTIN_NAME)==0) { + if (strcmp(name, FO_BUILTIN_NAME) == 0) { BLI_strncpy(filename, name, sizeof(filename)); - pf= get_builtin_packedfile(); - is_builtin= 1; + pf = get_builtin_packedfile(); + is_builtin = 1; } else { char dir[FILE_MAXDIR]; @@ -231,23 +231,23 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) BLI_strncpy(dir, name, sizeof(dir)); BLI_splitdirstring(dir, filename); - pf= newPackedFile(NULL, name, bmain->name); - tpf= newPackedFile(NULL, name, bmain->name); + pf = newPackedFile(NULL, name, bmain->name); + tpf = newPackedFile(NULL, name, bmain->name); - is_builtin= 0; + is_builtin = 0; } if (pf) { VFontData *vfd; - vfd= BLI_vfontdata_from_freetypefont(pf); + vfd = BLI_vfontdata_from_freetypefont(pf); if (vfd) { vfont = BKE_libblock_alloc(&bmain->vfont, ID_VF, filename); vfont->data = vfd; /* if there's a font name, use it for the ID name */ if (vfd->name[0] != '\0') { - BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2); + BLI_strncpy(vfont->id.name + 2, vfd->name, sizeof(vfont->id.name) - 2); } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); @@ -258,9 +258,9 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) // Do not add FO_BUILTIN_NAME to temporary listbase if (strcmp(filename, FO_BUILTIN_NAME)) { - tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf= tpf; - tmpfnt->vfont= vfont; + tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); + tmpfnt->pf = tpf; + tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); } } @@ -278,12 +278,12 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) static VFont *which_vfont(Curve *cu, CharInfo *info) { - switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { + switch (info->flag & (CU_CHINFO_BOLD | CU_CHINFO_ITALIC)) { case CU_CHINFO_BOLD: if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); case CU_CHINFO_ITALIC: if (cu->vfonti) return(cu->vfonti); else return(cu->vfont); - case (CU_CHINFO_BOLD|CU_CHINFO_ITALIC): + case (CU_CHINFO_BOLD | CU_CHINFO_ITALIC): if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont); default: return(cu->vfont); @@ -294,8 +294,8 @@ VFont *BKE_vfont_builtin_get(void) { VFont *vf; - for (vf= G.main->vfont.first; vf; vf= vf->id.next) - if (strcmp(vf->name, FO_BUILTIN_NAME)==0) + for (vf = G.main->vfont.first; vf; vf = vf->id.next) + if (strcmp(vf->name, FO_BUILTIN_NAME) == 0) return vf; return BKE_vfont_load(G.main, FO_BUILTIN_NAME); @@ -303,7 +303,7 @@ VFont *BKE_vfont_builtin_get(void) static VChar *find_vfont_char(VFontData *vfd, intptr_t character) { - VChar *che= NULL; + VChar *che = NULL; for (che = vfd->characters.first; che; che = che->next) { if (che->index == character) @@ -317,21 +317,21 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i Nurb *nu2; BPoint *bp; - nu2 =(Nurb*) MEM_callocN(sizeof(Nurb), "underline_nurb"); + nu2 = (Nurb *) MEM_callocN(sizeof(Nurb), "underline_nurb"); if (nu2 == NULL) return; - nu2->resolu= cu->resolu; + nu2->resolu = cu->resolu; nu2->bezt = NULL; nu2->knotsu = nu2->knotsv = NULL; - nu2->flag= CU_2D; - nu2->charidx = charidx+1000; - if (mat_nr > 0) nu2->mat_nr= mat_nr-1; + nu2->flag = CU_2D; + nu2->charidx = charidx + 1000; + if (mat_nr > 0) nu2->mat_nr = mat_nr - 1; nu2->pntsu = 4; nu2->pntsv = 1; nu2->orderu = 4; nu2->orderv = 1; nu2->flagu = CU_NURB_CYCLIC; - bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint), "underline_bp"); + bp = (BPoint *)MEM_callocN(4 * sizeof(BPoint), "underline_bp"); if (bp == NULL) { MEM_freeN(nu2); return; @@ -368,27 +368,27 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo VChar *che = NULL; int i; - vfd= vfont_get_data(bmain, which_vfont(cu, info)); + vfd = vfont_get_data(bmain, which_vfont(cu, info)); if (!vfd) return; #if 0 if (cu->selend < cu->selstart) { - if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart-2))) - sel= 1; + if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart - 2))) + sel = 1; } else { - if ((charidx >= (cu->selstart-1)) && (charidx <= (cu->selend-1))) - sel= 1; + if ((charidx >= (cu->selstart - 1)) && (charidx <= (cu->selend - 1))) + sel = 1; } #endif /* make a copy at distance ofsx, ofsy with shear*/ - fsize= cu->fsize; - shear= cu->shear; - si= (float)sin(rot); - co= (float)cos(rot); + fsize = cu->fsize; + shear = cu->shear; + si = (float)sin(rot); + co = (float)cos(rot); - che= find_vfont_char(vfd, character); + che = find_vfont_char(vfd, character); // Select the glyph data if (che) @@ -398,25 +398,25 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo while (nu1) { bezt1 = nu1->bezt; if (bezt1) { - nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb), "duplichar_nurb"); + nu2 = (Nurb *) MEM_mallocN(sizeof(Nurb), "duplichar_nurb"); if (nu2 == NULL) break; memcpy(nu2, nu1, sizeof(struct Nurb)); - nu2->resolu= cu->resolu; + nu2->resolu = cu->resolu; nu2->bp = NULL; nu2->knotsu = nu2->knotsv = NULL; - nu2->flag= CU_SMOOTH; + nu2->flag = CU_SMOOTH; nu2->charidx = charidx; if (info->mat_nr > 0) { - nu2->mat_nr= info->mat_nr-1; + nu2->mat_nr = info->mat_nr - 1; } else { - nu2->mat_nr= 0; + nu2->mat_nr = 0; } /* nu2->trim.first = 0; */ /* nu2->trim.last = 0; */ i = nu2->pntsu; - bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple), "duplichar_bezt2"); + bezt2 = (BezTriple *)MEM_mallocN(i * sizeof(BezTriple), "duplichar_bezt2"); if (bezt2 == NULL) { MEM_freeN(nu2); break; @@ -427,7 +427,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo if (shear != 0.0f) { bezt2 = nu2->bezt; - for (i= nu2->pntsu; i > 0; i--) { + for (i = nu2->pntsu; i > 0; i--) { bezt2->vec[0][0] += shear * bezt2->vec[0][1]; bezt2->vec[1][0] += shear * bezt2->vec[1][1]; bezt2->vec[2][0] += shear * bezt2->vec[2][1]; @@ -435,19 +435,19 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } } if (rot != 0.0f) { - bezt2= nu2->bezt; - for (i=nu2->pntsu; i > 0; i--) { - fp= bezt2->vec[0]; - - x= fp[0]; - fp[0]= co*x + si*fp[1]; - fp[1]= -si*x + co*fp[1]; - x= fp[3]; - fp[3]= co*x + si*fp[4]; - fp[4]= -si*x + co*fp[4]; - x= fp[6]; - fp[6]= co*x + si*fp[7]; - fp[7]= -si*x + co*fp[7]; + bezt2 = nu2->bezt; + for (i = nu2->pntsu; i > 0; i--) { + fp = bezt2->vec[0]; + + x = fp[0]; + fp[0] = co * x + si * fp[1]; + fp[1] = -si * x + co * fp[1]; + x = fp[3]; + fp[3] = co * x + si * fp[4]; + fp[4] = -si * x + co * fp[4]; + x = fp[6]; + fp[6] = co * x + si * fp[7]; + fp[7] = -si * x + co * fp[7]; bezt2++; } @@ -455,9 +455,9 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo bezt2 = nu2->bezt; if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) { - const float sca= cu->smallcaps_scale; - for (i= nu2->pntsu; i > 0; i--) { - fp= bezt2->vec[0]; + const float sca = cu->smallcaps_scale; + for (i = nu2->pntsu; i > 0; i--) { + fp = bezt2->vec[0]; fp[0] *= sca; fp[1] *= sca; fp[3] *= sca; @@ -469,14 +469,14 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } bezt2 = nu2->bezt; - for (i= nu2->pntsu; i > 0; i--) { - fp= bezt2->vec[0]; - fp[0]= (fp[0]+ofsx)*fsize; - fp[1]= (fp[1]+ofsy)*fsize; - fp[3]= (fp[3]+ofsx)*fsize; - fp[4]= (fp[4]+ofsy)*fsize; - fp[6]= (fp[6]+ofsx)*fsize; - fp[7]= (fp[7]+ofsy)*fsize; + for (i = nu2->pntsu; i > 0; i--) { + fp = bezt2->vec[0]; + fp[0] = (fp[0] + ofsx) * fsize; + fp[1] = (fp[1] + ofsy) * fsize; + fp[3] = (fp[3] + ofsx) * fsize; + fp[4] = (fp[4] + ofsy) * fsize; + fp[6] = (fp[6] + ofsx) * fsize; + fp[7] = (fp[7] + ofsy) * fsize; bezt2++; } @@ -489,19 +489,19 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo int BKE_vfont_select_get(Object *ob, int *start, int *end) { - Curve *cu= ob->data; + Curve *cu = ob->data; - if (cu->editfont==NULL || ob->type != OB_FONT) return 0; + if (cu->editfont == NULL || ob->type != OB_FONT) return 0; if (cu->selstart == 0) return 0; if (cu->selstart <= cu->selend) { - *start = cu->selstart-1; - *end = cu->selend-1; + *start = cu->selstart - 1; + *end = cu->selend - 1; return 1; } else { *start = cu->selend; - *end = cu->selstart-2; + *end = cu->selstart - 2; return -1; } } @@ -520,32 +520,31 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) } } -struct chartrans *BKE_vfont_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; + VFontData *vfd = NULL; Curve *cu; CharInfo *info = NULL, *custrinfo; TextBox *tb; VChar *che; - struct chartrans *chartransdata=NULL, *ct; + struct chartrans *chartransdata = NULL, *ct; float *f, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4; - float twidth, maxlen= 0; + float twidth, maxlen = 0; int i, slen, j; int curbox; int selstart, selend; int utf8len; - short cnr=0, lnr=0, wsnr= 0; + short cnr = 0, lnr = 0, wsnr = 0; wchar_t *mem, *tmp, ascii; /* renark: do calculations including the trailing '\0' of a string * because the cursor can be at that location */ - if (ob->type!=OB_FONT) return NULL; + if (ob->type != OB_FONT) return NULL; // Set font data - cu= (Curve *) ob->data; - vfont= cu->vfont; + cu = (Curve *) ob->data; + vfont = cu->vfont; if (cu->str == NULL) return NULL; if (vfont == NULL) return NULL; @@ -562,17 +561,17 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int if (cu->ulheight == 0.0f) cu->ulheight = 0.05f; - if (cu->strinfo==NULL) /* old file */ - cu->strinfo = MEM_callocN((slen+4) * sizeof(CharInfo), "strinfo compat"); + if (cu->strinfo == NULL) /* old file */ + cu->strinfo = MEM_callocN((slen + 4) * sizeof(CharInfo), "strinfo compat"); - custrinfo= cu->strinfo; + custrinfo = cu->strinfo; if (cu->editfont) - custrinfo= cu->editfont->textbufinfo; + custrinfo = cu->editfont->textbufinfo; - if (cu->tb==NULL) - cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBox compat"); + if (cu->tb == NULL) + cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat"); - vfd= vfont_get_data(bmain, vfont); + vfd = vfont_get_data(bmain, vfont); /* The VFont Data can not be found */ if (!vfd) { @@ -583,7 +582,7 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int /* calc offset and rotation of each char */ ct = chartransdata = - (struct chartrans*)MEM_callocN((slen+1)* sizeof(struct chartrans), "buildtext"); + (struct chartrans *)MEM_callocN((slen + 1) * sizeof(struct chartrans), "buildtext"); /* We assume the worst case: 1 character per line (is freed at end anyway) */ @@ -592,57 +591,57 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int linedata3 = MEM_callocN(sizeof(float) * (slen * 2 + 1), "buildtext4"); linedata4 = MEM_callocN(sizeof(float) * (slen * 2 + 1), "buildtext5"); - linedist= cu->linedist; + linedist = cu->linedist; - xof= cu->xof + (cu->tb[0].x/cu->fsize); - yof= cu->yof + (cu->tb[0].y/cu->fsize); + xof = cu->xof + (cu->tb[0].x / cu->fsize); + yof = cu->yof + (cu->tb[0].y / cu->fsize); - xtrax= 0.5f*cu->spacing-0.5f; + xtrax = 0.5f * cu->spacing - 0.5f; oldvfont = NULL; - for (i=0; iselboxes) MEM_freeN(cu->selboxes); cu->selboxes = NULL; if (BKE_vfont_select_get(ob, &selstart, &selend)) - cu->selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes"); + cu->selboxes = MEM_callocN((selend - selstart + 1) * sizeof(SelBox), "font selboxes"); tb = &(cu->tb[0]); - curbox= 0; - for (i = 0 ; i<=slen ; i++) { - makebreak: + curbox = 0; + for (i = 0; i <= slen; i++) { +makebreak: // Characters in the list info = &(custrinfo[i]); ascii = mem[i]; if (info->flag & CU_CHINFO_SMALLCAPS) { ascii = towupper(ascii); if (mem[i] != ascii) { - mem[i]= ascii; + mem[i] = ascii; info->flag |= CU_CHINFO_SMALLCAPS_CHECK; } } vfont = which_vfont(cu, info); - if (vfont==NULL) break; + if (vfont == NULL) break; - che= find_vfont_char(vfd, ascii); + che = find_vfont_char(vfd, ascii); /* * The character wasn't in the current curve base so load it * But if the font is FO_BUILTIN_NAME then do not try loading since * whole font is in the memory already */ - if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { + if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { BLI_vfontchar_from_freetypefont(vfont, ascii); } /* Try getting the character again from the list */ - che= find_vfont_char(vfd, ascii); + che = find_vfont_char(vfd, ascii); /* No VFont found */ - if (vfont==NULL) { + if (vfont == NULL) { if (mem) MEM_freeN(mem); MEM_freeN(chartransdata); @@ -650,7 +649,7 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int } if (vfont != oldvfont) { - vfd= vfont_get_data(bmain, vfont); + vfd = vfont_get_data(bmain, vfont); oldvfont = vfont; } @@ -665,24 +664,24 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int twidth = char_width(cu, che, info); // Calculate positions - if ((tb->w != 0.0f) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) { - // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); - for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) { - if (mem[j]==' ' || mem[j]=='-') { - ct -= (i-(j-1)); - cnr -= (i-(j-1)); + if ((tb->w != 0.0f) && (ct->dobreak == 0) && ((xof - (tb->x / cu->fsize) + twidth) * cu->fsize) > tb->w + cu->xof * cu->fsize) { + // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); + for (j = i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak == 0); j--) { + if (mem[j] == ' ' || mem[j] == '-') { + ct -= (i - (j - 1)); + cnr -= (i - (j - 1)); if (mem[j] == ' ') wsnr--; if (mem[j] == '-') wsnr++; - i = j-1; + i = j - 1; xof = ct->xof; ct[1].dobreak = 1; - custrinfo[i+1].flag |= CU_CHINFO_WRAP; + custrinfo[i + 1].flag |= CU_CHINFO_WRAP; goto makebreak; } if (chartransdata[j].dobreak) { - // fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]); - ct->dobreak= 1; - custrinfo[i+1].flag |= CU_CHINFO_WRAP; + // fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]); + ct->dobreak = 1; + custrinfo[i + 1].flag |= CU_CHINFO_WRAP; ct -= 1; cnr -= 1; i--; @@ -691,27 +690,27 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int } } } - if (ascii== '\n' || ascii== '\r' || ascii==0 || ct->dobreak) { - ct->xof= xof; - ct->yof= yof; - ct->linenr= lnr; - ct->charnr= cnr; - - yof-= linedist; - - maxlen= MAX2(maxlen, (xof-tb->x/cu->fsize)); - linedata[lnr]= xof-tb->x/cu->fsize; - linedata2[lnr]= cnr; - linedata3[lnr]= tb->w/cu->fsize; - linedata4[lnr]= wsnr; + if (ascii == '\n' || ascii == '\r' || ascii == 0 || ct->dobreak) { + ct->xof = xof; + ct->yof = yof; + ct->linenr = lnr; + ct->charnr = cnr; + + yof -= linedist; + + maxlen = MAX2(maxlen, (xof - tb->x / cu->fsize)); + linedata[lnr] = xof - tb->x / cu->fsize; + linedata2[lnr] = cnr; + linedata3[lnr] = tb->w / cu->fsize; + linedata4[lnr] = wsnr; if ( (tb->h != 0.0f) && - ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize)) - cu->yof) && - (cu->totbox > (curbox+1)) ) { - maxlen= 0; + ((-(yof - (tb->y / cu->fsize))) > ((tb->h / cu->fsize) - (linedist * cu->fsize)) - cu->yof) && + (cu->totbox > (curbox + 1)) ) { + maxlen = 0; tb++; curbox++; - yof= cu->yof + tb->y/cu->fsize; + yof = cu->yof + tb->y / cu->fsize; } /* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */ @@ -719,43 +718,43 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int if (ascii == '\n' || ascii == '\r') xof = cu->xof; else - xof= cu->xof + (tb->x/cu->fsize); + xof = cu->xof + (tb->x / cu->fsize); #else - xof= cu->xof + (tb->x/cu->fsize); + xof = cu->xof + (tb->x / cu->fsize); #endif lnr++; - cnr= 0; - wsnr= 0; + cnr = 0; + wsnr = 0; } - else if (ascii==9) { /* TAB */ + else if (ascii == 9) { /* TAB */ float tabfac; - ct->xof= xof; - ct->yof= yof; - ct->linenr= lnr; - ct->charnr= cnr++; + ct->xof = xof; + ct->yof = yof; + ct->linenr = lnr; + ct->charnr = cnr++; - tabfac= (xof-cu->xof+0.01f); - tabfac= 2.0f*ceilf(tabfac/2.0f); - xof= cu->xof+tabfac; + tabfac = (xof - cu->xof + 0.01f); + tabfac = 2.0f * ceilf(tabfac / 2.0f); + xof = cu->xof + tabfac; } else { - SelBox *sb= NULL; + SelBox *sb = NULL; float wsfac; - ct->xof= xof; - ct->yof= yof; - ct->linenr= lnr; - ct->charnr= cnr++; + ct->xof = xof; + ct->yof = yof; + ct->linenr = lnr; + ct->charnr = cnr++; - if (cu->selboxes && (i>=selstart) && (i<=selend)) { - sb = &(cu->selboxes[i-selstart]); - sb->y = yof*cu->fsize-linedist*cu->fsize*0.1f; - sb->h = linedist*cu->fsize; - sb->w = xof*cu->fsize; + if (cu->selboxes && (i >= selstart) && (i <= selend)) { + sb = &(cu->selboxes[i - selstart]); + sb->y = yof * cu->fsize - linedist * cu->fsize * 0.1f; + sb->h = linedist * cu->fsize; + sb->w = xof * cu->fsize; } - if (ascii==32) { + if (ascii == 32) { wsfac = cu->wordspace; wsnr++; } @@ -764,20 +763,20 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int // Set the width of the character twidth = char_width(cu, che, info); - xof += (twidth*wsfac*(1.0f+(info->kern/40.0f)) ) + xtrax; + xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax; if (sb) - sb->w = (xof*cu->fsize) - sb->w; + sb->w = (xof * cu->fsize) - sb->w; } ct++; } - cu->lines= 1; - ct= chartransdata; + cu->lines = 1; + ct = chartransdata; tmp = mem; - for (i= 0; i<=slen; i++, tmp++, ct++) { + for (i = 0; i <= slen; i++, tmp++, ct++) { ascii = *tmp; - if (ascii== '\n' || ascii== '\r' || ct->dobreak) cu->lines++; + if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++; } // linedata is now: width of line @@ -785,55 +784,55 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int // linedata3 is now: maxlen of that line // linedata4 is now: number of whitespaces of line - if (cu->spacemode!=CU_LEFT) { - ct= chartransdata; + if (cu->spacemode != CU_LEFT) { + ct = chartransdata; - if (cu->spacemode==CU_RIGHT) { - for (i=0;ixof+= linedata[ct->linenr]; + if (cu->spacemode == CU_RIGHT) { + for (i = 0; i < lnr; i++) linedata[i] = linedata3[i] - linedata[i]; + for (i = 0; i <= slen; i++) { + ct->xof += linedata[ct->linenr]; ct++; } } - else if (cu->spacemode==CU_MIDDLE) { - for (i=0;ixof+= linedata[ct->linenr]; + else if (cu->spacemode == CU_MIDDLE) { + for (i = 0; i < lnr; i++) linedata[i] = (linedata3[i] - linedata[i]) / 2; + for (i = 0; i <= slen; i++) { + ct->xof += linedata[ct->linenr]; ct++; } } - else if ((cu->spacemode==CU_FLUSH) && - (cu->tb[0].w != 0.0f)) { - for (i=0;i1) - linedata[i]= (linedata3[i]-linedata[i])/(linedata2[i]-1); - for (i=0; i<=slen; i++) { - for (j=i; (!ELEM3(mem[j], '\0', '\n', '\r')) && (chartransdata[j].dobreak == 0) && (j < slen); j++) { + else if ((cu->spacemode == CU_FLUSH) && + (cu->tb[0].w != 0.0f)) { + for (i = 0; i < lnr; i++) + if (linedata2[i] > 1) + linedata[i] = (linedata3[i] - linedata[i]) / (linedata2[i] - 1); + for (i = 0; i <= slen; i++) { + for (j = i; (!ELEM3(mem[j], '\0', '\n', '\r')) && (chartransdata[j].dobreak == 0) && (j < slen); j++) { /* do nothing */ } // if ((mem[j]!='\r') && (mem[j]!='\n') && (mem[j])) { - ct->xof+= ct->charnr*linedata[ct->linenr]; + ct->xof += ct->charnr * linedata[ct->linenr]; // } ct++; } } - else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { + else if ((cu->spacemode == CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { float curofs = 0.0f; for (i = 0; i <= slen; i++) { - for (j=i; (mem[j]) && (mem[j]!='\n') && - (mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen); + for (j = i; (mem[j]) && (mem[j] != '\n') && + (mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen); j++) { /* pass */ } - if ((mem[j]!='\r') && (mem[j]!='\n') && - ((chartransdata[j].dobreak!=0))) { - if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr]; - ct->xof+= curofs; + if ((mem[j] != '\r') && (mem[j] != '\n') && + ((chartransdata[j].dobreak != 0))) { + if (mem[i] == ' ') curofs += (linedata3[ct->linenr] - linedata[ct->linenr]) / linedata4[ct->linenr]; + ct->xof += curofs; } - if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0; + if (mem[i] == '\n' || mem[i] == '\r' || chartransdata[i].dobreak) curofs = 0; ct++; } } @@ -841,13 +840,13 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int /* TEXT ON CURVE */ /* Note: Only OB_CURVE objects could have a path */ - if (cu->textoncurve && cu->textoncurve->type==OB_CURVE) { - Curve *cucu= cu->textoncurve->data; - int oldflag= cucu->flag; + if (cu->textoncurve && cu->textoncurve->type == OB_CURVE) { + Curve *cucu = cu->textoncurve->data; + int oldflag = cucu->flag; - cucu->flag |= (CU_PATH+CU_FOLLOW); + cucu->flag |= (CU_PATH + CU_FOLLOW); - if (cucu->path==NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0); + if (cucu->path == NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0); if (cucu->path) { float distfac, imat[4][4], imat3[3][3], cmat[3][3]; float minx, maxx, miny, maxy; @@ -858,116 +857,116 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int copy_m3_m4(cmat, cu->textoncurve->obmat); mul_m3_m3m3(cmat, cmat, imat3); - sizefac= normalize_v3(cmat[0])/cu->fsize; + sizefac = normalize_v3(cmat[0]) / cu->fsize; - minx=miny= 1.0e20f; - maxx=maxy= -1.0e20f; - ct= chartransdata; - for (i=0; i<=slen; i++, ct++) { - if (minx>ct->xof) minx= ct->xof; - if (maxxxof) maxx= ct->xof; - if (miny>ct->yof) miny= ct->yof; - if (maxyyof) maxy= ct->yof; + minx = miny = 1.0e20f; + maxx = maxy = -1.0e20f; + ct = chartransdata; + for (i = 0; i <= slen; i++, ct++) { + if (minx > ct->xof) minx = ct->xof; + if (maxx < ct->xof) maxx = ct->xof; + if (miny > ct->yof) miny = ct->yof; + if (maxy < ct->yof) maxy = ct->yof; } /* we put the x-coordinaat exact at the curve, the y is rotated */ /* length correction */ - distfac= sizefac*cucu->path->totdist/(maxx-minx); - timeofs= 0.0f; + distfac = sizefac * cucu->path->totdist / (maxx - minx); + timeofs = 0.0f; if (distfac > 1.0f) { /* path longer than text: spacemode involves */ - distfac= 1.0f/distfac; + distfac = 1.0f / distfac; - if (cu->spacemode==CU_RIGHT) { - timeofs= 1.0f-distfac; + if (cu->spacemode == CU_RIGHT) { + timeofs = 1.0f - distfac; } - else if (cu->spacemode==CU_MIDDLE) { - timeofs= (1.0f-distfac)/2.0f; + else if (cu->spacemode == CU_MIDDLE) { + timeofs = (1.0f - distfac) / 2.0f; } - else if (cu->spacemode==CU_FLUSH) distfac= 1.0f; + else if (cu->spacemode == CU_FLUSH) distfac = 1.0f; } - else distfac= 1.0; + else distfac = 1.0; - distfac/= (maxx-minx); + distfac /= (maxx - minx); - timeofs+= distfac*cu->xof; /* not cyclic */ + timeofs += distfac * cu->xof; /* not cyclic */ - ct= chartransdata; - for (i=0; i<=slen; i++, ct++) { + ct = chartransdata; + for (i = 0; i <= slen; i++, ct++) { float ctime, dtime, vec[4], tvec[4], rotvec[3]; float si, co; /* rotate around center character */ ascii = mem[i]; - che= find_vfont_char(vfd, ascii); + che = find_vfont_char(vfd, ascii); twidth = char_width(cu, che, info); - dtime= distfac*0.5f*twidth; + dtime = distfac * 0.5f * twidth; - ctime= timeofs + distfac*( ct->xof - minx); + ctime = timeofs + distfac * (ct->xof - minx); CLAMP(ctime, 0.0f, 1.0f); /* calc the right loc AND the right rot separately */ /* vec, tvec need 4 items */ where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL, NULL); - where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL, NULL); + where_on_path(cu->textoncurve, ctime + dtime, tvec, rotvec, NULL, NULL, NULL); mul_v3_fl(vec, sizefac); - ct->rot= (float)(M_PI-atan2(rotvec[1], rotvec[0])); + ct->rot = (float)(M_PI - atan2(rotvec[1], rotvec[0])); - si= (float)sin(ct->rot); - co= (float)cos(ct->rot); + si = (float)sin(ct->rot); + co = (float)cos(ct->rot); - yof= ct->yof; + yof = ct->yof; - ct->xof= vec[0] + si*yof; - ct->yof= vec[1] + co*yof; + ct->xof = vec[0] + si * yof; + ct->yof = vec[1] + co * yof; } - cucu->flag= oldflag; + cucu->flag = oldflag; } } if (cu->selboxes) { - ct= chartransdata; - for (i=0; i<=selend; i++, ct++) { - if (i>=selstart) { - cu->selboxes[i-selstart].x = ct->xof*cu->fsize; - cu->selboxes[i-selstart].y = ct->yof*cu->fsize; + ct = chartransdata; + for (i = 0; i <= selend; i++, ct++) { + if (i >= selstart) { + cu->selboxes[i - selstart].x = ct->xof * cu->fsize; + cu->selboxes[i - selstart].y = ct->yof * cu->fsize; } } } - if (mode==FO_CURSUP || mode==FO_CURSDOWN || mode==FO_PAGEUP || mode==FO_PAGEDOWN) { + if (mode == FO_CURSUP || mode == FO_CURSDOWN || mode == FO_PAGEUP || mode == FO_PAGEDOWN) { /* 2: curs up * 3: curs down */ - ct= chartransdata+cu->pos; + ct = chartransdata + cu->pos; - if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0); - else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr); + if ((mode == FO_CURSUP || mode == FO_PAGEUP) && ct->linenr == 0) ; + else if ((mode == FO_CURSDOWN || mode == FO_PAGEDOWN) && ct->linenr == lnr) ; else { switch (mode) { - case FO_CURSUP: lnr= ct->linenr-1; break; - case FO_CURSDOWN: lnr= ct->linenr+1; break; - case FO_PAGEUP: lnr= ct->linenr-10; break; - case FO_PAGEDOWN: lnr= ct->linenr+10; break; + case FO_CURSUP: lnr = ct->linenr - 1; break; + case FO_CURSDOWN: lnr = ct->linenr + 1; break; + case FO_PAGEUP: lnr = ct->linenr - 10; break; + case FO_PAGEDOWN: lnr = ct->linenr + 10; break; } - cnr= ct->charnr; + cnr = ct->charnr; /* seek for char with lnr en cnr */ - cu->pos= 0; - ct= chartransdata; - for (i= 0; ilinenr==lnr) { - if (ct->charnr==cnr) break; - if ( (ct+1)->charnr==0) break; + cu->pos = 0; + ct = chartransdata; + for (i = 0; i < slen; i++) { + if (ct->linenr == lnr) { + if (ct->charnr == cnr) break; + if ( (ct + 1)->charnr == 0) break; } - else if (ct->linenr>lnr) break; + else if (ct->linenr > lnr) break; cu->pos++; ct++; } @@ -978,23 +977,23 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int if (cu->editfont) { float si, co; - ct= chartransdata+cu->pos; - si= (float)sin(ct->rot); - co= (float)cos(ct->rot); + ct = chartransdata + cu->pos; + si = (float)sin(ct->rot); + co = (float)cos(ct->rot); - f= cu->editfont->textcurs[0]; + f = cu->editfont->textcurs[0]; - f[0]= cu->fsize*(-0.1f*co + ct->xof); - f[1]= cu->fsize*(0.1f*si + ct->yof); + f[0] = cu->fsize * (-0.1f * co + ct->xof); + f[1] = cu->fsize * (0.1f * si + ct->yof); - f[2]= cu->fsize*(0.1f*co + ct->xof); - f[3]= cu->fsize*(-0.1f*si + ct->yof); + f[2] = cu->fsize * (0.1f * co + ct->xof); + f[3] = cu->fsize * (-0.1f * si + ct->yof); - f[4]= cu->fsize*( 0.1f*co + 0.8f*si + ct->xof); - f[5]= cu->fsize*(-0.1f*si + 0.8f*co + ct->yof); + f[4] = cu->fsize * (0.1f * co + 0.8f * si + ct->xof); + f[5] = cu->fsize * (-0.1f * si + 0.8f * co + ct->yof); - f[6]= cu->fsize*(-0.1f*co + 0.8f*si + ct->xof); - f[7]= cu->fsize*( 0.1f*si + 0.8f*co + ct->yof); + f[6] = cu->fsize * (-0.1f * co + 0.8f * si + ct->xof); + f[7] = cu->fsize * (0.1f * si + 0.8f * co + ct->yof); } @@ -1013,9 +1012,9 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int /* make nurbdata */ BKE_nurbList_free(&cu->nurb); - ct= chartransdata; - if (cu->sepchar==0) { - for (i= 0; isepchar == 0) { + for (i = 0; i < slen; i++) { unsigned long cha = (uintptr_t) mem[i]; info = &(custrinfo[i]); if (info->mat_nr > (ob->totcol)) { @@ -1027,42 +1026,42 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i); if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { - float ulwidth, uloverlap= 0.0f; + float ulwidth, uloverlap = 0.0f; - if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') && - ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0) - ) { + if ( (i < (slen - 1)) && (mem[i + 1] != '\n') && (mem[i + 1] != '\r') && + ((mem[i + 1] != ' ') || (custrinfo[i + 1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i + 1].flag & CU_CHINFO_WRAP) == 0) + ) { uloverlap = xtrax + 0.1f; } // Find the character, the characters has to be in the memory already // since character checking has been done earlier already. - che= find_vfont_char(vfd, cha); + che = find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); - ulwidth = cu->fsize * ((twidth* (1.0f+(info->kern/40.0f)))+uloverlap); - build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize, - ct->xof*cu->fsize + ulwidth, - ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize - cu->ulheight*cu->fsize, - i, info->mat_nr); + ulwidth = cu->fsize * ((twidth * (1.0f + (info->kern / 40.0f))) + uloverlap); + build_underline(cu, ct->xof * cu->fsize, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize, + ct->xof * cu->fsize + ulwidth, + ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize - cu->ulheight * cu->fsize, + i, info->mat_nr); } ct++; } } else { int outta = 0; - for (i= 0; (isepchar == (i+1)) { + if (cu->sepchar == (i + 1)) { float vecyo[3]; - vecyo[0]= ct->xof; - vecyo[1]= ct->yof; - vecyo[2]= 0.0f; + vecyo[0] = ct->xof; + vecyo[1] = ct->yof; + vecyo[2] = 0.0f; mem[0] = ascii; mem[1] = 0; - custrinfo[0]= *info; + custrinfo[0] = *info; cu->pos = 1; cu->len = 1; mul_v3_m4v3(ob->loc, ob->obmat, vecyo); @@ -1074,7 +1073,7 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int } } - if (mode==FO_DUPLI) { + if (mode == FO_DUPLI) { MEM_freeN(mem); return chartransdata; } diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index da3acce9228..6ec19018ab5 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -62,8 +62,8 @@ void free_gpencil_strokes(bGPDframe *gpf) if (gpf == NULL) return; /* free strokes */ - for (gps= gpf->strokes.first; gps; gps= gpsn) { - gpsn= gps->next; + for (gps = gpf->strokes.first; gps; gps = gpsn) { + gpsn = gps->next; /* free stroke memory arrays, then stroke itself */ if (gps->points) MEM_freeN(gps->points); @@ -80,8 +80,8 @@ void free_gpencil_frames(bGPDlayer *gpl) if (gpl == NULL) return; /* free frames */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; /* free strokes and their associated memory */ free_gpencil_strokes(gpf); @@ -98,8 +98,8 @@ void free_gpencil_layers(ListBase *list) if (list == NULL) return; /* delete layers*/ - for (gpl= list->first; gpl; gpl= gpln) { - gpln= gpl->next; + for (gpl = list->first; gpl; gpl = gpln) { + gpln = gpl->next; /* free layers and their data */ free_gpencil_frames(gpl); @@ -117,32 +117,32 @@ void BKE_gpencil_free(bGPdata *gpd) /* -------- Container Creation ---------- */ /* add a new gp-frame to the given layer */ -bGPDframe *gpencil_frame_addnew (bGPDlayer *gpl, int cframe) +bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe) { bGPDframe *gpf, *gf; - short state=0; + short state = 0; /* error checking */ if ((gpl == NULL) || (cframe <= 0)) return NULL; /* allocate memory for this frame */ - gpf= MEM_callocN(sizeof(bGPDframe), "bGPDframe"); - gpf->framenum= cframe; + gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe"); + gpf->framenum = cframe; /* find appropriate place to add frame */ if (gpl->frames.first) { - for (gf= gpl->frames.first; gf; gf= gf->next) { + for (gf = gpl->frames.first; gf; gf = gf->next) { /* check if frame matches one that is supposed to be added */ if (gf->framenum == cframe) { - state= -1; + state = -1; break; } /* if current frame has already exceeded the frame to add, add before */ if (gf->framenum > cframe) { BLI_insertlinkbefore(&gpl->frames, gf, gpf); - state= 1; + state = 1; break; } } @@ -163,7 +163,7 @@ bGPDframe *gpencil_frame_addnew (bGPDlayer *gpl, int cframe) } /* add a new gp-layer and make it the active layer */ -bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) +bGPDlayer *gpencil_layer_addnew(bGPdata *gpd) { bGPDlayer *gpl; @@ -172,13 +172,13 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) return NULL; /* allocate memory for frame and add to end of list */ - gpl= MEM_callocN(sizeof(bGPDlayer), "bGPDlayer"); + gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer"); /* add to datablock */ BLI_addtail(&gpd->layers, gpl); /* set basic settings */ - gpl->color[3]= 0.9f; + gpl->color[3] = 0.9f; gpl->thickness = 3; /* auto-name */ @@ -193,15 +193,15 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) } /* add a new gp-datablock */ -bGPdata *gpencil_data_addnew (const char name[]) +bGPdata *gpencil_data_addnew(const char name[]) { bGPdata *gpd; /* allocate memory for a new block */ - gpd= BKE_libblock_alloc(&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); + gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND); /* for now, stick to view is also enabled by default * since this is more useful... @@ -214,7 +214,7 @@ bGPdata *gpencil_data_addnew (const char name[]) /* -------- Data Duplication ---------- */ /* make a copy of a given gpencil frame */ -bGPDframe *gpencil_frame_duplicate (bGPDframe *src) +bGPDframe *gpencil_frame_duplicate(bGPDframe *src) { bGPDstroke *gps, *gpsd; bGPDframe *dst; @@ -224,15 +224,15 @@ bGPDframe *gpencil_frame_duplicate (bGPDframe *src) return NULL; /* make a copy of the source frame */ - dst= MEM_dupallocN(src); - dst->prev= dst->next= NULL; + dst = MEM_dupallocN(src); + dst->prev = dst->next = NULL; /* copy strokes */ - dst->strokes.first = dst->strokes.last= NULL; - for (gps= src->strokes.first; gps; gps= gps->next) { + dst->strokes.first = dst->strokes.last = NULL; + for (gps = src->strokes.first; gps; gps = gps->next) { /* make copy of source stroke, then adjust pointer to points too */ - gpsd= MEM_dupallocN(gps); - gpsd->points= MEM_dupallocN(gps->points); + gpsd = MEM_dupallocN(gps); + gpsd->points = MEM_dupallocN(gps->points); BLI_addtail(&dst->strokes, gpsd); } @@ -242,7 +242,7 @@ bGPDframe *gpencil_frame_duplicate (bGPDframe *src) } /* make a copy of a given gpencil layer */ -bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src) +bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src) { bGPDframe *gpf, *gpfd; bGPDlayer *dst; @@ -252,19 +252,19 @@ bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src) return NULL; /* make a copy of source layer */ - dst= MEM_dupallocN(src); - dst->prev= dst->next= NULL; + dst = MEM_dupallocN(src); + dst->prev = dst->next = NULL; /* copy frames */ - dst->frames.first= dst->frames.last= NULL; - for (gpf= src->frames.first; gpf; gpf= gpf->next) { + dst->frames.first = dst->frames.last = NULL; + for (gpf = src->frames.first; gpf; gpf = gpf->next) { /* make a copy of source frame */ - gpfd= gpencil_frame_duplicate(gpf); + gpfd = gpencil_frame_duplicate(gpf); BLI_addtail(&dst->frames, gpfd); /* if source frame was the current layer's 'active' frame, reassign that too */ if (gpf == dst->actframe) - dst->actframe= gpfd; + dst->actframe = gpfd; } /* return new layer */ @@ -272,7 +272,7 @@ bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src) } /* make a copy of a given gpencil datablock */ -bGPdata *gpencil_data_duplicate (bGPdata *src) +bGPdata *gpencil_data_duplicate(bGPdata *src) { bGPDlayer *gpl, *gpld; bGPdata *dst; @@ -282,13 +282,13 @@ bGPdata *gpencil_data_duplicate (bGPdata *src) return NULL; /* make a copy of the base-data */ - dst= MEM_dupallocN(src); + dst = MEM_dupallocN(src); /* copy layers */ - dst->layers.first= dst->layers.last= NULL; - for (gpl= src->layers.first; gpl; gpl= gpl->next) { + dst->layers.first = dst->layers.last = NULL; + for (gpl = src->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ - gpld= gpencil_layer_duplicate(gpl); + gpld = gpencil_layer_duplicate(gpl); BLI_addtail(&dst->layers, gpld); } @@ -301,7 +301,7 @@ bGPdata *gpencil_data_duplicate (bGPdata *src) /* delete the last stroke of the given frame */ void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf) { - bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; + bGPDstroke *gps = (gpf) ? gpf->strokes.last : NULL; int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */ /* error checking */ @@ -325,7 +325,7 @@ void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf) * - this sets the layer's actframe var (if allowed to) * - extension beyond range (if first gp-frame is after all frame in interest and cannot add) */ -bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) +bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew) { bGPDframe *gpf = NULL; short found = 0; @@ -336,12 +336,12 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* check if there is already an active frame */ if (gpl->actframe) { - gpf= gpl->actframe; + gpf = gpl->actframe; /* do not allow any changes to layer's active frame if layer is locked from changes * or if the layer has been set to stay on the current frame */ - if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_FRAMELOCK)) + if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_FRAMELOCK)) return gpf; /* do not allow any changes to actframe if frame has painting tag attached to it */ if (gpf->flag & GP_FRAME_PAINT) @@ -349,13 +349,13 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* try to find matching frame */ if (gpf->framenum < cframe) { - for (; gpf; gpf= gpf->next) { + for (; gpf; gpf = gpf->next) { if (gpf->framenum == cframe) { - found= 1; + found = 1; break; } else if ((gpf->next) && (gpf->next->framenum > cframe)) { - found= 1; + found = 1; break; } } @@ -363,19 +363,19 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* set the appropriate frame */ if (addnew) { if ((found) && (gpf->framenum == cframe)) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); } else if (found) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpl->frames.last; + gpl->actframe = gpl->frames.last; } else { - for (; gpf; gpf= gpf->prev) { + for (; gpf; gpf = gpf->prev) { if (gpf->framenum <= cframe) { - found= 1; + found = 1; break; } } @@ -383,35 +383,35 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* set the appropriate frame */ if (addnew) { if ((found) && (gpf->framenum == cframe)) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); } else if (found) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpl->frames.first; + gpl->actframe = gpl->frames.first; } } else if (gpl->frames.first) { /* check which of the ends to start checking from */ - const int first= ((bGPDframe *)(gpl->frames.first))->framenum; - const int last= ((bGPDframe *)(gpl->frames.last))->framenum; + const int first = ((bGPDframe *)(gpl->frames.first))->framenum; + const int last = ((bGPDframe *)(gpl->frames.last))->framenum; - if (abs(cframe-first) > abs(cframe-last)) { + if (abs(cframe - first) > abs(cframe - last)) { /* find gp-frame which is less than or equal to cframe */ - for (gpf= gpl->frames.last; gpf; gpf= gpf->prev) { + for (gpf = gpl->frames.last; gpf; gpf = gpf->prev) { if (gpf->framenum <= cframe) { - found= 1; + found = 1; break; } } } else { /* find gp-frame which is less than or equal to cframe */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->framenum <= cframe) { - found= 1; + found = 1; break; } } @@ -420,12 +420,12 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* set the appropriate frame */ if (addnew) { if ((found) && (gpf->framenum == cframe)) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); } else if (found) - gpl->actframe= gpf; + gpl->actframe = gpf; else { /* unresolved errogenous situation! */ printf("Error: cannot find appropriate gp-frame\n"); @@ -435,7 +435,7 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) else { /* currently no frames (add if allowed to) */ if (addnew) - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); else { /* don't do anything... this may be when no frames yet! */ /* gpl->actframe should still be NULL */ @@ -460,7 +460,7 @@ void gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf) } /* get the active gp-layer for editing */ -bGPDlayer *gpencil_layer_getactive (bGPdata *gpd) +bGPDlayer *gpencil_layer_getactive(bGPdata *gpd) { bGPDlayer *gpl; @@ -469,7 +469,7 @@ bGPDlayer *gpencil_layer_getactive (bGPdata *gpd) return NULL; /* loop over layers until found (assume only one active) */ - for (gpl=gpd->layers.first; gpl; gpl=gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpl->flag & GP_LAYER_ACTIVE) return gpl; } @@ -488,7 +488,7 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active) return; /* loop over layers deactivating all */ - for (gpl=gpd->layers.first; gpl; gpl=gpl->next) + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) gpl->flag &= ~GP_LAYER_ACTIVE; /* set as active one */ @@ -498,7 +498,7 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active) /* delete the active gp-layer */ void gpencil_layer_delactive(bGPdata *gpd) { - bGPDlayer *gpl= gpencil_layer_getactive(gpd); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); /* error checking */ if (ELEM(NULL, gpd, gpl)) diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index c722522250c..2fc436ab4de 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -66,7 +66,7 @@ void BKE_group_free(Group *group) GroupObject *go; while (group->gobject.first) { - go= group->gobject.first; + go = group->gobject.first; BLI_remlink(&group->gobject, go); free_group_object(go); } @@ -74,67 +74,67 @@ void BKE_group_free(Group *group) void BKE_group_unlink(Group *group) { - Main *bmain= G.main; + Main *bmain = G.main; Material *ma; Object *ob; Scene *sce; SceneRenderLayer *srl; ParticleSystem *psys; - for (ma= bmain->mat.first; ma; ma= ma->id.next) { - if (ma->group==group) - ma->group= NULL; + for (ma = bmain->mat.first; ma; ma = ma->id.next) { + if (ma->group == group) + ma->group = NULL; } - for (ma= bmain->mat.first; ma; ma= ma->id.next) { - if (ma->group==group) - ma->group= NULL; + for (ma = bmain->mat.first; ma; ma = ma->id.next) { + if (ma->group == group) + ma->group = NULL; } - for (sce= bmain->scene.first; sce; sce= sce->id.next) { - Base *base= sce->base.first; + for (sce = bmain->scene.first; sce; sce = sce->id.next) { + Base *base = sce->base.first; /* ensure objects are not in this group */ - for (; base; base= base->next) { - if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) { + for (; base; base = base->next) { + if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL) == NULL) { base->object->flag &= ~OB_FROMGROUP; base->flag &= ~OB_FROMGROUP; } } - for (srl= sce->r.layers.first; srl; srl= srl->next) { - if (srl->light_override==group) - srl->light_override= NULL; + for (srl = sce->r.layers.first; srl; srl = srl->next) { + if (srl->light_override == group) + srl->light_override = NULL; } } - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob->dup_group==group) { - ob->dup_group= NULL; -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ + if (ob->dup_group == group) { + ob->dup_group = NULL; +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ { bActionStrip *strip; /* duplicator strips use a group object, we remove it */ - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) - strip->object= NULL; + strip->object = NULL; } } #endif } - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - if (psys->part->dup_group==group) - psys->part->dup_group= NULL; -#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ - if (psys->part->eff_group==group) - psys->part->eff_group= NULL; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part->dup_group == group) + psys->part->dup_group = NULL; +#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ + if (psys->part->eff_group == group) + psys->part->eff_group = NULL; #endif } } /* group stays in library, but no members */ BKE_group_free(group); - group->id.us= 0; + group->id.us = 0; } Group *add_group(const char *name) @@ -142,7 +142,7 @@ Group *add_group(const char *name) Group *group; group = BKE_libblock_alloc(&G.main->group, ID_GR, name); - group->layer= (1<<20)-1; + group->layer = (1 << 20) - 1; return group; } @@ -150,7 +150,7 @@ Group *BKE_group_copy(Group *group) { Group *groupn; - groupn= MEM_dupallocN(group); + groupn = MEM_dupallocN(group); BLI_duplicatelist(&groupn->gobject, &group->gobject); return groupn; @@ -161,17 +161,17 @@ static int add_to_group_internal(Group *group, Object *ob) { GroupObject *go; - if (group==NULL || ob==NULL) return 0; + if (group == NULL || ob == NULL) return 0; /* check if the object has been added already */ - for (go= group->gobject.first; go; go= go->next) { - if (go->ob==ob) return 0; + for (go = group->gobject.first; go; go = go->next) { + if (go->ob == ob) return 0; } - go= MEM_callocN(sizeof(GroupObject), "groupobject"); + go = MEM_callocN(sizeof(GroupObject), "groupobject"); BLI_addtail(&group->gobject, go); - go->ob= ob; + go->ob = ob; return 1; } @@ -179,10 +179,10 @@ static int add_to_group_internal(Group *group, Object *ob) int add_to_group(Group *group, Object *object, Scene *scene, Base *base) { if (add_to_group_internal(group, object)) { - if ((object->flag & OB_FROMGROUP)==0) { + if ((object->flag & OB_FROMGROUP) == 0) { - if (scene && base==NULL) - base= BKE_scene_base_find(scene, object); + if (scene && base == NULL) + base = BKE_scene_base_find(scene, object); object->flag |= OB_FROMGROUP; @@ -201,18 +201,18 @@ static int rem_from_group_internal(Group *group, Object *ob) { GroupObject *go, *gon; int removed = 0; - if (group==NULL) return 0; + if (group == NULL) return 0; - go= group->gobject.first; + go = group->gobject.first; while (go) { - gon= go->next; - if (go->ob==ob) { + gon = go->next; + if (go->ob == ob) { BLI_remlink(&group->gobject, go); free_group_object(go); removed = 1; /* should break here since an object being in a group twice cant happen? */ } - go= gon; + go = gon; } return removed; } @@ -222,8 +222,8 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) if (rem_from_group_internal(group, object)) { /* object can be NULL */ if (object && find_group(object, NULL) == NULL) { - if (scene && base==NULL) - base= BKE_scene_base_find(scene, object); + if (scene && base == NULL) + base = BKE_scene_base_find(scene, object); object->flag &= ~OB_FROMGROUP; @@ -241,10 +241,10 @@ int object_in_group(Object *ob, Group *group) { GroupObject *go; - if (group==NULL || ob==NULL) return 0; + if (group == NULL || ob == NULL) return 0; - for (go= group->gobject.first; go; go= go->next) { - if (go->ob==ob) + for (go = group->gobject.first; go; go = go->next) { + if (go->ob == ob) return 1; } return 0; @@ -253,14 +253,14 @@ int object_in_group(Object *ob, Group *group) Group *find_group(Object *ob, Group *group) { if (group) - group= group->id.next; + group = group->id.next; else - group= G.main->group.first; + group = G.main->group.first; while (group) { if (object_in_group(ob, group)) return group; - group= group->id.next; + group = group->id.next; } return NULL; } @@ -269,11 +269,11 @@ void group_tag_recalc(Group *group) { GroupObject *go; - if (group==NULL) return; + if (group == NULL) return; - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; } } @@ -286,7 +286,7 @@ int group_is_animated(Object *UNUSED(parent), Group *group) return 1; #endif - for (go= group->gobject.first; go; go= go->next) + for (go = group->gobject.first; go; go = go->next) if (go->ob && go->ob->proxy) return 1; @@ -298,38 +298,38 @@ int group_is_animated(Object *UNUSED(parent), Group *group) /* keep checking nla.c though, in case internal structure of strip changes */ static void group_replaces_nla(Object *parent, Object *target, char mode) { - static ListBase nlastrips={NULL, NULL}; - static bAction *action= NULL; - static int done= 0; + static ListBase nlastrips = {NULL, NULL}; + static bAction *action = NULL; + static int done = 0; bActionStrip *strip, *nstrip; - if (mode=='s') { + if (mode == 's') { - for (strip= parent->nlastrips.first; strip; strip= strip->next) { - if (strip->object==target) { - if (done==0) { + for (strip = parent->nlastrips.first; strip; strip = strip->next) { + if (strip->object == target) { + if (done == 0) { /* clear nla & action from object */ - nlastrips= target->nlastrips; - target->nlastrips.first= target->nlastrips.last= NULL; - action= target->action; - target->action= NULL; + nlastrips = target->nlastrips; + target->nlastrips.first = target->nlastrips.last = NULL; + action = target->action; + target->action = NULL; target->nlaflag |= OB_NLA_OVERRIDE; - done= 1; + done = 1; } - nstrip= MEM_dupallocN(strip); + nstrip = MEM_dupallocN(strip); BLI_addtail(&target->nlastrips, nstrip); } } } - else if (mode=='e') { + else if (mode == 'e') { if (done) { BLI_freelistN(&target->nlastrips); - target->nlastrips= nlastrips; - target->action= action; + target->nlastrips = nlastrips; + target->action = action; - nlastrips.first= nlastrips.last= NULL; /* not needed, but yah... :) */ - action= NULL; - done= 0; + nlastrips.first = nlastrips.last = NULL; /* not needed, but yah... :) */ + action = NULL; + done = 0; } } } @@ -353,30 +353,30 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group int cfrao; /* switch to local time */ - cfrao= scene->r.cfra; + cfrao = scene->r.cfra; /* we need a DAG per group... */ - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob && go->recalc) { - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; group_replaces_nla(parent, go->ob, 's'); 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 */ - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; } } /* restore */ - scene->r.cfra= cfrao; + scene->r.cfra = cfrao; } else #endif { /* only do existing tags, as set by regular depsgraph */ - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { if (go->ob->recalc) { BKE_object_handle_update(scene, go->ob); @@ -391,17 +391,17 @@ Object *group_get_member_with_action(Group *group, bAction *act) { GroupObject *go; - if (group==NULL || act==NULL) return NULL; + if (group == NULL || act == NULL) return NULL; - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { - if (go->ob->action==act) + if (go->ob->action == act) return go->ob; if (go->ob->nlastrips.first) { bActionStrip *strip; - for (strip= go->ob->nlastrips.first; strip; strip= strip->next) { - if (strip->act==act) + for (strip = go->ob->nlastrips.first; strip; strip = strip->next) { + if (strip->act == act) return go->ob; } } @@ -418,21 +418,21 @@ void group_relink_nla_objects(Object *ob) GroupObject *go; bActionStrip *strip; - if (ob==NULL || ob->dup_group==NULL) return; - group= ob->dup_group; + if (ob == NULL || ob->dup_group == NULL) return; + group = ob->dup_group; - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { - if (strcmp(go->ob->id.name, strip->object->id.name)==0) + if (strcmp(go->ob->id.name, strip->object->id.name) == 0) break; } } if (go) - strip->object= go->ob; + strip->object = go->ob; else - strip->object= NULL; + strip->object = NULL; } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 88cfa63e3e7..aff1e65224b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -92,18 +92,18 @@ #include "BLO_sys_types.h" // for intptr_t support /* max int, to indicate we don't store sequences in ibuf */ -#define IMA_NO_INDEX 0x7FEFEFEF +#define IMA_NO_INDEX 0x7FEFEFEF /* quick lookup: supports 1 million frames, thousand passes */ -#define IMA_MAKE_INDEX(frame, index) ((frame)<<10)+index -#define IMA_INDEX_FRAME(index) (index>>10) -#define IMA_INDEX_PASS(index) (index & ~1023) +#define IMA_MAKE_INDEX(frame, index) ((frame) << 10) + index +#define IMA_INDEX_FRAME(index) (index >> 10) +#define IMA_INDEX_PASS(index) (index & ~1023) /* ******** IMAGE PROCESSING ************* */ -static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ +static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { - struct ImBuf * tbuf1, * tbuf2; + struct ImBuf *tbuf1, *tbuf2; if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; @@ -129,9 +129,9 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ ibuf->y /= 2; } -static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ +static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ { - struct ImBuf * tbuf1, * tbuf2; + struct ImBuf *tbuf1, *tbuf2; if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; @@ -159,7 +159,7 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ void BKE_image_de_interlace(Image *ima, int odd) { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); if (ibuf) { if (odd) de_interlace_st(ibuf); @@ -185,16 +185,16 @@ static void image_free_buffers(Image *ima) } if (ima->anim) IMB_free_anim(ima->anim); - ima->anim= NULL; + ima->anim = NULL; if (ima->rr) { RE_FreeRenderResult(ima->rr); - ima->rr= NULL; + ima->rr = NULL; } GPU_free_image(ima); - ima->ok= IMA_OK; + ima->ok = IMA_OK; } /* called by library too, do not free ima itself */ @@ -212,10 +212,10 @@ void BKE_image_free(Image *ima) BKE_previewimg_free(&ima->preview); - for (a=0; arenders[a]) { RE_FreeRenderResult(ima->renders[a]); - ima->renders[a]= NULL; + ima->renders[a] = NULL; } } } @@ -225,17 +225,17 @@ static Image *image_alloc(const char *name, short source, short type) { Image *ima; - ima= BKE_libblock_alloc(&G.main->image, ID_IM, name); + ima = BKE_libblock_alloc(&G.main->image, ID_IM, name); if (ima) { - ima->ok= IMA_OK; + ima->ok = IMA_OK; - ima->xrep= ima->yrep= 1; - ima->aspx= ima->aspy= 1.0; - ima->gen_x= 1024; ima->gen_y= 1024; - ima->gen_type= 1; /* no defines yet? */ + ima->xrep = ima->yrep = 1; + ima->aspx = ima->aspy = 1.0; + ima->gen_x = 1024; ima->gen_y = 1024; + ima->gen_type = 1; /* no defines yet? */ - ima->source= source; - ima->type= type; + ima->source = source; + ima->type = type; } return ima; } @@ -246,14 +246,14 @@ static ImBuf *image_get_ibuf(Image *ima, int index, int frame) /* this function is intended to be thread safe. with IMA_NO_INDEX this * should be OK, but when iterating over the list this is more tricky * */ - if (index==IMA_NO_INDEX) + if (index == IMA_NO_INDEX) return ima->ibufs.first; else { ImBuf *ibuf; - index= IMA_MAKE_INDEX(frame, index); - for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) - if (ibuf->index==index) + index = IMA_MAKE_INDEX(frame, index); + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) + if (ibuf->index == index) return ibuf; return NULL; @@ -276,15 +276,15 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) if (ibuf) { ImBuf *link; - if (index!=IMA_NO_INDEX) - index= IMA_MAKE_INDEX(frame, index); + if (index != IMA_NO_INDEX) + index = IMA_MAKE_INDEX(frame, index); /* insert based on index */ - for (link= ima->ibufs.first; link; link= link->next) - if (link->index>=index) + for (link = ima->ibufs.first; link; link = link->next) + if (link->index >= index) break; - ibuf->index= index; + ibuf->index = index; if (ima->flag & IMA_CM_PREDIVIDE) ibuf->flags |= IB_cm_predivide; else @@ -294,7 +294,7 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) BLI_insertlinkbefore(&ima->ibufs, link, ibuf); /* now we don't want copies? */ - if (link && ibuf->index==link->index) + if (link && ibuf->index == link->index) image_remove_ibuf(ima, link); } } @@ -302,21 +302,21 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) /* empty image block, of similar type and filename */ Image *BKE_image_copy(Image *ima) { - Image *nima= image_alloc(ima->id.name+2, ima->source, ima->type); + Image *nima = image_alloc(ima->id.name + 2, ima->source, ima->type); BLI_strncpy(nima->name, ima->name, sizeof(ima->name)); - nima->flag= ima->flag; - nima->tpageflag= ima->tpageflag; + nima->flag = ima->flag; + nima->tpageflag = ima->tpageflag; - nima->gen_x= ima->gen_x; - nima->gen_y= ima->gen_y; - nima->gen_type= ima->gen_type; + nima->gen_x = ima->gen_x; + nima->gen_y = ima->gen_y; + nima->gen_type = ima->gen_type; - nima->animspeed= ima->animspeed; + nima->animspeed = ima->animspeed; - nima->aspx= ima->aspx; - nima->aspy= ima->aspy; + nima->aspx = ima->aspx; + nima->aspy = ima->aspy; return nima; } @@ -329,54 +329,54 @@ static void extern_local_image(Image *UNUSED(ima)) void BKE_image_make_local(struct Image *ima) { - Main *bmain= G.main; + Main *bmain = G.main; Tex *tex; Brush *brush; Mesh *me; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (ima->id.lib==NULL) return; + if (ima->id.lib == NULL) return; /* Can't take short cut here: must check meshes at least because of bogus * texface ID refs. - z0r */ #if 0 - if (ima->id.us==1) { + if (ima->id.us == 1) { id_clear_lib_data(bmain, &ima->id); extern_local_image(ima); return; } #endif - for (tex= bmain->tex.first; tex; tex= tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->ima == ima) { - if (tex->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (tex->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - for (brush= bmain->brush.first; brush; brush= brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->clone.image == ima) { - if (brush->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (brush->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - for (me= bmain->mesh.first; me; me= me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if (me->mtface) { MTFace *tface; int a, i; - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; + tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) { + for (a = 0; a < me->totface; a++, tface++) { if (tface->tpage == ima) { - if (me->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (me->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } @@ -387,14 +387,14 @@ void BKE_image_make_local(struct Image *ima) MTexPoly *mtpoly; int a, i; - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - mtpoly= (MTexPoly*)me->pdata.layers[i].data; + mtpoly = (MTexPoly *)me->pdata.layers[i].data; - for (a=0; atotpoly; a++, mtpoly++) { + for (a = 0; a < me->totpoly; a++, mtpoly++) { if (mtpoly->tpage == ima) { - if (me->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (me->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } @@ -408,55 +408,55 @@ void BKE_image_make_local(struct Image *ima) extern_local_image(ima); } else if (is_local && is_lib) { - Image *ima_new= BKE_image_copy(ima); + Image *ima_new = BKE_image_copy(ima); - ima_new->id.us= 0; + ima_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, ima->id.lib, &ima_new->id); - tex= bmain->tex.first; + tex = bmain->tex.first; while (tex) { - if (tex->id.lib==NULL) { - if (tex->ima==ima) { + if (tex->id.lib == NULL) { + if (tex->ima == ima) { tex->ima = ima_new; ima_new->id.us++; ima->id.us--; } } - tex= tex->id.next; + tex = tex->id.next; } - brush= bmain->brush.first; + brush = bmain->brush.first; while (brush) { - if (brush->id.lib==NULL) { - if (brush->clone.image==ima) { + if (brush->id.lib == NULL) { + if (brush->clone.image == ima) { brush->clone.image = ima_new; ima_new->id.us++; ima->id.us--; } } - brush= brush->id.next; + brush = brush->id.next; } /* Transfer references in texfaces. Texfaces don't add to image ID * user count *unless* there are no other users. See * readfile.c:lib_link_mtface. */ - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { if (me->mtface) { MTFace *tface; int a, i; - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; + tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) { + for (a = 0; a < me->totface; a++, tface++) { if (tface->tpage == ima) { tface->tpage = ima_new; if (ima_new->id.us == 0) { - tface->tpage->id.us= 1; + tface->tpage->id.us = 1; } - id_lib_extern((ID*)ima_new); + id_lib_extern((ID *)ima_new); } } } @@ -467,24 +467,24 @@ void BKE_image_make_local(struct Image *ima) MTexPoly *mtpoly; int a, i; - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - mtpoly= (MTexPoly*)me->pdata.layers[i].data; + mtpoly = (MTexPoly *)me->pdata.layers[i].data; - for (a=0; atotpoly; a++, mtpoly++) { + for (a = 0; a < me->totpoly; a++, mtpoly++) { if (mtpoly->tpage == ima) { mtpoly->tpage = ima_new; if (ima_new->id.us == 0) { - mtpoly->tpage->id.us= 1; + mtpoly->tpage->id.us = 1; } - id_lib_extern((ID*)ima_new); + id_lib_extern((ID *)ima_new); } } } } } - me= me->id.next; + me = me->id.next; } } } @@ -494,9 +494,9 @@ void BKE_image_merge(Image *dest, Image *source) ImBuf *ibuf; /* sanity check */ - if (dest && source && dest!=source) { + if (dest && source && dest != source) { - while ((ibuf= source->ibufs.first)) { + while ((ibuf = source->ibufs.first)) { BLI_remlink(&source->ibufs, ibuf); image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index)); } @@ -516,21 +516,21 @@ Image *BKE_image_load(const char *filepath) BLI_path_abs(str, G.main->name); /* exists? */ - file= BLI_open(str, O_BINARY|O_RDONLY, 0); - if (file== -1) return NULL; + file = BLI_open(str, O_BINARY | O_RDONLY, 0); + if (file == -1) return NULL; close(file); /* create a short library name */ - len= strlen(filepath); + len = strlen(filepath); while (len > 0 && filepath[len - 1] != '/' && filepath[len - 1] != '\\') len--; - libname= filepath+len; + libname = filepath + len; - ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); + 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; + ima->source = IMA_SRC_MOVIE; return ima; } @@ -548,17 +548,17 @@ Image *BKE_image_load_exists(const char *filepath) BLI_path_abs(str, G.main->name); /* 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) { + for (ima = G.main->image.first; ima; ima = ima->id.next) { + if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); BLI_path_abs(strtest, G.main->name); - if (BLI_path_cmp(strtest, str)==0) { - if (ima->anim==NULL || ima->id.us==0) { - 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; + if (BLI_path_cmp(strtest, str) == 0) { + if (ima->anim == NULL || ima->id.us == 0) { + 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; /* RETURN! */ return ima; } @@ -572,30 +572,30 @@ Image *BKE_image_load_exists(const char *filepath) static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; - unsigned char *rect= NULL; - float *rect_float= NULL; + unsigned char *rect = NULL; + float *rect_float = NULL; if (floatbuf) { - ibuf= IMB_allocImBuf(width, height, depth, IB_rectfloat); - rect_float= (float*)ibuf->rect_float; + ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); + rect_float = (float *)ibuf->rect_float; } else { - ibuf= IMB_allocImBuf(width, height, depth, IB_rect); - rect= (unsigned char*)ibuf->rect; + ibuf = IMB_allocImBuf(width, height, depth, IB_rect); + rect = (unsigned char *)ibuf->rect; } BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; switch (uvtestgrid) { - case 1: - BKE_image_buf_fill_checker(rect, rect_float, width, height); - break; - case 2: - BKE_image_buf_fill_checker_color(rect, rect_float, width, height); - break; - default: - BKE_image_buf_fill_color(rect, rect_float, width, height, color); + case 1: + BKE_image_buf_fill_checker(rect, rect_float, width, height); + break; + case 2: + BKE_image_buf_fill_checker_color(rect, rect_float, width, height); + break; + default: + BKE_image_buf_fill_color(rect, rect_float, width, height, color); } return ibuf; @@ -605,21 +605,21 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char 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); + Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); if (ima) { ImBuf *ibuf; /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */ - ima->gen_x= width; - ima->gen_y= height; - ima->gen_type= uvtestgrid; + ima->gen_x = width; + ima->gen_y = height; + ima->gen_type = uvtestgrid; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - ibuf= add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); + ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } return ima; @@ -631,12 +631,12 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf) /* on save, type is changed to FILE in editsima.c */ Image *ima; - ima= image_alloc(BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima = image_alloc(BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { BLI_strncpy(ima->name, ibuf->name, FILE_MAX); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } return ima; @@ -645,20 +645,20 @@ Image *BKE_image_add_from_imbuf(ImBuf *ibuf) /* packs rect from memory as PNG */ void BKE_image_memorypack(Image *ima) { - ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ImBuf *ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); - if (ibuf==NULL) + if (ibuf == NULL) return; if (ima->packedfile) { freePackedFile(ima->packedfile); ima->packedfile = NULL; } - ibuf->ftype= PNG; - ibuf->planes= R_IMF_PLANES_RGBA; + ibuf->ftype = PNG; + ibuf->planes = R_IMF_PLANES_RGBA; IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem); - if (ibuf->encodedbuffer==NULL) { + if (ibuf->encodedbuffer == NULL) { printf("memory save for pack error\n"); } else { @@ -666,14 +666,14 @@ void BKE_image_memorypack(Image *ima) pf->data = ibuf->encodedbuffer; pf->size = ibuf->encodedsize; - ima->packedfile= pf; - ibuf->encodedbuffer= NULL; - ibuf->encodedsize= 0; + ima->packedfile = pf; + ibuf->encodedbuffer = NULL; + ibuf->encodedsize = 0; ibuf->userflags &= ~IB_BITMAPDIRTY; - if (ima->source==IMA_SRC_GENERATED) { - ima->source= IMA_SRC_FILE; - ima->type= IMA_TYPE_IMAGE; + if (ima->source == IMA_SRC_GENERATED) { + ima->source = IMA_SRC_FILE; + ima->type = IMA_TYPE_IMAGE; } } } @@ -690,7 +690,7 @@ static void tag_all_images_time() Image *ima; int ctime = (int)PIL_check_seconds_timer(); - ima= G.main->image.first; + ima = G.main->image.first; while (ima) { if (ima->bindcode || ima->repbind || ima->ibufs.first) { ima->lastused = ctime; @@ -718,9 +718,9 @@ void free_old_images(void) lasttime = ctime; - ima= G.main->image.first; + ima = G.main->image.first; while (ima) { - if ((ima->flag & IMA_NOCOLLECT)==0 && ctime - ima->lastused > U.textimeout) { + if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) { /* If it's in GL memory, deallocate and set time tag to current time * This gives textures a "second chance" to be used before dying. */ if (ima->bindcode || ima->repbind) { @@ -742,18 +742,18 @@ static uintptr_t image_mem_size(Image *ima) int level; uintptr_t size = 0; - size= 0; + size = 0; /* viewers have memory depending on other rules, has no valid rect pointer */ - if (ima->source==IMA_SRC_VIEWER) + if (ima->source == IMA_SRC_VIEWER) return 0; - for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) { + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { if (ibuf->rect) size += MEM_allocN_len(ibuf->rect); else if (ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float); - for (level=0; levelmipmap[level]; + for (level = 0; level < IB_MIPMAP_LEVELS; level++) { + ibufm = ibuf->mipmap[level]; if (ibufm) { if (ibufm->rect) size += MEM_allocN_len(ibufm->rect); else if (ibufm->rect_float) size += MEM_allocN_len(ibufm->rect_float); @@ -767,18 +767,18 @@ static uintptr_t image_mem_size(Image *ima) void BKE_image_print_memlist(void) { Image *ima; - uintptr_t size, totsize= 0; + uintptr_t size, totsize = 0; - for (ima= G.main->image.first; ima; ima= ima->id.next) + for (ima = G.main->image.first; ima; ima = ima->id.next) totsize += image_mem_size(ima); - printf("\ntotal image memory len: %.3f MB\n", (double)totsize/(double)(1024*1024)); + printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024)); - for (ima= G.main->image.first; ima; ima= ima->id.next) { - size= image_mem_size(ima); + for (ima = G.main->image.first; ima; ima = ima->id.next) { + size = image_mem_size(ima); if (size) - printf("%s len: %.3f MB\n", ima->id.name+2, (double)size/(double)(1024*1024)); + printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024)); } } @@ -788,30 +788,30 @@ void BKE_image_free_all_textures(void) Image *ima; /* unsigned int totsize= 0; */ - for (ima= G.main->image.first; ima; ima= ima->id.next) + for (ima = G.main->image.first; ima; ima = ima->id.next) ima->id.flag &= ~LIB_DOIT; - for (tex= G.main->tex.first; tex; tex= tex->id.next) + for (tex = G.main->tex.first; tex; tex = tex->id.next) if (tex->ima) tex->ima->id.flag |= LIB_DOIT; - for (ima= G.main->image.first; ima; ima= ima->id.next) { + for (ima = G.main->image.first; ima; ima = ima->id.next) { if (ima->ibufs.first && (ima->id.flag & LIB_DOIT)) { ImBuf *ibuf; - for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) { + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { /* escape when image is painted on */ if (ibuf->userflags & IB_BITMAPDIRTY) break; #if 0 if (ibuf->mipmap[0]) - totsize+= 1.33*ibuf->x*ibuf->y*4; + totsize += 1.33 * ibuf->x * ibuf->y * 4; else - totsize+= ibuf->x*ibuf->y*4; + totsize += ibuf->x * ibuf->y * 4; #endif } - if (ibuf==NULL) + if (ibuf == NULL) image_free_buffers(ima); } } @@ -823,13 +823,13 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame) { ImBuf *ibuf, *nbuf; - for (ibuf= ima->ibufs.first; ibuf; ibuf= nbuf) { - nbuf= ibuf->next; + for (ibuf = ima->ibufs.first; ibuf; ibuf = nbuf) { + nbuf = ibuf->next; if (ibuf->userflags & IB_BITMAPDIRTY) continue; - if (ibuf->index==IMA_NO_INDEX) + if (ibuf->index == IMA_NO_INDEX) continue; - if (except_frame!=IMA_INDEX_FRAME(ibuf->index)) { + if (except_frame != IMA_INDEX_FRAME(ibuf->index)) { BLI_remlink(&ima->ibufs, ibuf); if (ibuf->userdata) { @@ -845,7 +845,7 @@ void BKE_image_all_free_anim_ibufs(int cfra) { Image *ima; - for (ima= G.main->image.first; ima; ima= ima->id.next) + for (ima = G.main->image.first; ima; ima = ima->id.next) if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) BKE_image_free_anim_ibufs(ima, cfra); } @@ -855,47 +855,47 @@ void BKE_image_all_free_anim_ibufs(int cfra) int BKE_imtype_to_ftype(const char imtype) { - if (imtype==R_IMF_IMTYPE_TARGA) + if (imtype == R_IMF_IMTYPE_TARGA) return TGA; - else if (imtype==R_IMF_IMTYPE_RAWTGA) + else if (imtype == R_IMF_IMTYPE_RAWTGA) return RAWTGA; - else if (imtype== R_IMF_IMTYPE_IRIS) + else if (imtype == R_IMF_IMTYPE_IRIS) return IMAGIC; #ifdef WITH_HDR - else if (imtype==R_IMF_IMTYPE_RADHDR) + else if (imtype == R_IMF_IMTYPE_RADHDR) return RADHDR; #endif - else if (imtype==R_IMF_IMTYPE_PNG) + else if (imtype == R_IMF_IMTYPE_PNG) return PNG; #ifdef WITH_DDS - else if (imtype==R_IMF_IMTYPE_DDS) + else if (imtype == R_IMF_IMTYPE_DDS) return DDS; #endif - else if (imtype==R_IMF_IMTYPE_BMP) + else if (imtype == R_IMF_IMTYPE_BMP) return BMP; #ifdef WITH_TIFF - else if (imtype==R_IMF_IMTYPE_TIFF) + else if (imtype == R_IMF_IMTYPE_TIFF) return TIF; #endif - else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) + else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) return OPENEXR; #ifdef WITH_CINEON - else if (imtype==R_IMF_IMTYPE_CINEON) + else if (imtype == R_IMF_IMTYPE_CINEON) return CINEON; - else if (imtype==R_IMF_IMTYPE_DPX) + else if (imtype == R_IMF_IMTYPE_DPX) return DPX; #endif #ifdef WITH_OPENJPEG - else if (imtype==R_IMF_IMTYPE_JP2) + else if (imtype == R_IMF_IMTYPE_JP2) return JP2; #endif else - return JPG|90; + return JPG | 90; } char BKE_ftype_to_imtype(const int ftype) { - if (ftype==0) + if (ftype == 0) return R_IMF_IMTYPE_TARGA; else if (ftype == IMAGIC) return R_IMF_IMTYPE_IRIS; @@ -939,15 +939,15 @@ char BKE_ftype_to_imtype(const int ftype) int BKE_imtype_is_movie(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_AVIRAW: - case R_IMF_IMTYPE_AVIJPEG: - case R_IMF_IMTYPE_AVICODEC: - case R_IMF_IMTYPE_QUICKTIME: - case R_IMF_IMTYPE_FFMPEG: - case R_IMF_IMTYPE_H264: - case R_IMF_IMTYPE_THEORA: - case R_IMF_IMTYPE_XVID: - case R_IMF_IMTYPE_FRAMESERVER: + case R_IMF_IMTYPE_AVIRAW: + case R_IMF_IMTYPE_AVIJPEG: + case R_IMF_IMTYPE_AVICODEC: + case R_IMF_IMTYPE_QUICKTIME: + case R_IMF_IMTYPE_FFMPEG: + case R_IMF_IMTYPE_H264: + case R_IMF_IMTYPE_THEORA: + case R_IMF_IMTYPE_XVID: + case R_IMF_IMTYPE_FRAMESERVER: return 1; } return 0; @@ -956,8 +956,8 @@ int BKE_imtype_is_movie(const char imtype) int BKE_imtype_supports_zbuf(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_IRIZ: - case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ + case R_IMF_IMTYPE_IRIZ: + case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ return 1; } return 0; @@ -966,7 +966,7 @@ int BKE_imtype_supports_zbuf(const char imtype) int BKE_imtype_supports_compress(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_PNG: + case R_IMF_IMTYPE_PNG: return 1; } return 0; @@ -975,9 +975,9 @@ int BKE_imtype_supports_compress(const char imtype) int BKE_imtype_supports_quality(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_JPEG90: - case R_IMF_IMTYPE_JP2: - case R_IMF_IMTYPE_AVIJPEG: + case R_IMF_IMTYPE_JPEG90: + case R_IMF_IMTYPE_JP2: + case R_IMF_IMTYPE_AVIJPEG: return 1; } return 0; @@ -985,32 +985,32 @@ int BKE_imtype_supports_quality(const char imtype) char BKE_imtype_valid_channels(const char imtype) { - char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */ + char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */ /* alpha */ switch (imtype) { - case R_IMF_IMTYPE_TARGA: - case R_IMF_IMTYPE_IRIS: - case R_IMF_IMTYPE_PNG: - /* case R_IMF_IMTYPE_BMP: */ /* read but not write */ - case R_IMF_IMTYPE_RADHDR: - case R_IMF_IMTYPE_TIFF: - case R_IMF_IMTYPE_OPENEXR: - case R_IMF_IMTYPE_MULTILAYER: - case R_IMF_IMTYPE_DDS: - case R_IMF_IMTYPE_JP2: - case R_IMF_IMTYPE_QUICKTIME: + case R_IMF_IMTYPE_TARGA: + case R_IMF_IMTYPE_IRIS: + case R_IMF_IMTYPE_PNG: + /* case R_IMF_IMTYPE_BMP: */ /* read but not write */ + case R_IMF_IMTYPE_RADHDR: + case R_IMF_IMTYPE_TIFF: + case R_IMF_IMTYPE_OPENEXR: + case R_IMF_IMTYPE_MULTILAYER: + case R_IMF_IMTYPE_DDS: + case R_IMF_IMTYPE_JP2: + case R_IMF_IMTYPE_QUICKTIME: chan_flag |= IMA_CHAN_FLAG_ALPHA; } /* bw */ switch (imtype) { - case R_IMF_IMTYPE_PNG: - case R_IMF_IMTYPE_JPEG90: - case R_IMF_IMTYPE_TARGA: - case R_IMF_IMTYPE_RAWTGA: - case R_IMF_IMTYPE_TIFF: - case R_IMF_IMTYPE_IRIS: + case R_IMF_IMTYPE_PNG: + case R_IMF_IMTYPE_JPEG90: + case R_IMF_IMTYPE_TARGA: + case R_IMF_IMTYPE_RAWTGA: + case R_IMF_IMTYPE_TIFF: + case R_IMF_IMTYPE_IRIS: chan_flag |= IMA_CHAN_FLAG_BW; } @@ -1020,23 +1020,23 @@ char BKE_imtype_valid_channels(const char imtype) char BKE_imtype_valid_depths(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_RADHDR: - return R_IMF_CHAN_DEPTH_32; - case R_IMF_IMTYPE_TIFF: - return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16; - case R_IMF_IMTYPE_OPENEXR: - return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32; - case R_IMF_IMTYPE_MULTILAYER: - return R_IMF_CHAN_DEPTH_32; - /* eeh, cineone does some strange 10bits per channel */ - case R_IMF_IMTYPE_DPX: - case R_IMF_IMTYPE_CINEON: - return R_IMF_CHAN_DEPTH_12; - case R_IMF_IMTYPE_JP2: - return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; - /* most formats are 8bit only */ - default: - return R_IMF_CHAN_DEPTH_8; + case R_IMF_IMTYPE_RADHDR: + return R_IMF_CHAN_DEPTH_32; + case R_IMF_IMTYPE_TIFF: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16; + case R_IMF_IMTYPE_OPENEXR: + return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32; + case R_IMF_IMTYPE_MULTILAYER: + return R_IMF_CHAN_DEPTH_32; + /* eeh, cineone does some strange 10bits per channel */ + case R_IMF_IMTYPE_DPX: + case R_IMF_IMTYPE_CINEON: + return R_IMF_CHAN_DEPTH_12; + case R_IMF_IMTYPE_JP2: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; + /* most formats are 8bit only */ + default: + return R_IMF_CHAN_DEPTH_8; } } @@ -1083,78 +1083,78 @@ char BKE_imtype_from_arg(const char *imtype_arg) int BKE_add_image_extension(char *string, const char imtype) { - const char *extension= NULL; + const char *extension = NULL; - if (imtype== R_IMF_IMTYPE_IRIS) { + if (imtype == R_IMF_IMTYPE_IRIS) { if (!BLI_testextensie(string, ".rgb")) - extension= ".rgb"; + extension = ".rgb"; } - else if (imtype==R_IMF_IMTYPE_IRIZ) { + else if (imtype == R_IMF_IMTYPE_IRIZ) { if (!BLI_testextensie(string, ".rgb")) - extension= ".rgb"; + extension = ".rgb"; } #ifdef WITH_HDR - else if (imtype==R_IMF_IMTYPE_RADHDR) { + else if (imtype == R_IMF_IMTYPE_RADHDR) { if (!BLI_testextensie(string, ".hdr")) - extension= ".hdr"; + extension = ".hdr"; } #endif else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) { if (!BLI_testextensie(string, ".png")) - extension= ".png"; + extension = ".png"; } #ifdef WITH_DDS - else if (imtype==R_IMF_IMTYPE_DDS) { + else if (imtype == R_IMF_IMTYPE_DDS) { if (!BLI_testextensie(string, ".dds")) - extension= ".dds"; + extension = ".dds"; } #endif - else if (imtype==R_IMF_IMTYPE_RAWTGA) { + else if (imtype == R_IMF_IMTYPE_RAWTGA) { if (!BLI_testextensie(string, ".tga")) - extension= ".tga"; + extension = ".tga"; } - else if (imtype==R_IMF_IMTYPE_BMP) { + else if (imtype == R_IMF_IMTYPE_BMP) { if (!BLI_testextensie(string, ".bmp")) - extension= ".bmp"; + extension = ".bmp"; } #ifdef WITH_TIFF - else if (imtype==R_IMF_IMTYPE_TIFF) { + else if (imtype == R_IMF_IMTYPE_TIFF) { if (!BLI_testextensie(string, ".tif") && !BLI_testextensie(string, ".tiff")) { - extension= ".tif"; + extension = ".tif"; } } #endif #ifdef WITH_OPENEXR else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { if (!BLI_testextensie(string, ".exr")) - extension= ".exr"; + extension = ".exr"; } #endif #ifdef WITH_CINEON - else if (imtype==R_IMF_IMTYPE_CINEON) { + else if (imtype == R_IMF_IMTYPE_CINEON) { if (!BLI_testextensie(string, ".cin")) - extension= ".cin"; + extension = ".cin"; } - else if (imtype==R_IMF_IMTYPE_DPX) { + else if (imtype == R_IMF_IMTYPE_DPX) { if (!BLI_testextensie(string, ".dpx")) - extension= ".dpx"; + extension = ".dpx"; } #endif - else if (imtype==R_IMF_IMTYPE_TARGA) { + else if (imtype == R_IMF_IMTYPE_TARGA) { if (!BLI_testextensie(string, ".tga")) - extension= ".tga"; + extension = ".tga"; } #ifdef WITH_OPENJPEG - else if (imtype==R_IMF_IMTYPE_JP2) { + else if (imtype == R_IMF_IMTYPE_JP2) { if (!BLI_testextensie(string, ".jp2")) - extension= ".jp2"; + extension = ".jp2"; } #endif else { // R_IMF_IMTYPE_AVICODEC, R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc if (!(BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) - extension= ".jpg"; + extension = ".jpg"; } if (extension) { @@ -1186,17 +1186,17 @@ void BKE_imformat_defaults(ImageFormatData *im_format) /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { - char file[512]; - char note[512]; - char date[512]; - char marker[512]; - char time[512]; - char frame[512]; - char camera[64]; - char cameralens[64]; - char scene[64]; - char strip[64]; - char rendertime[64]; + char file[512]; + char note[512]; + char date[512]; + char marker[512]; + char time[512]; + char frame[512]; + char camera[64]; + char cameralens[64]; + char scene[64]; + char strip[64]; + char rendertime[64]; } StampData; static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix) @@ -1206,7 +1206,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d time_t t; if (scene->r.stamp & R_STAMP_FILENAME) { - BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s":"%s", G.relbase_valid ? G.main->name:""); + BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s" : "%s", G.relbase_valid ? G.main->name : ""); } else { stamp_data->file[0] = '\0'; @@ -1223,8 +1223,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_DATE) { t = time(NULL); tl = localtime(&t); - BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); - BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s":"%s", text); + BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year + 1900, tl->tm_mon + 1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); + BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s" : "%s", text); } else { stamp_data->date[0] = '\0'; @@ -1233,10 +1233,10 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_MARKER) { char *name = BKE_scene_find_last_marker_name(scene, CFRA); - if (name) BLI_strncpy(text, name, sizeof(text)); - else BLI_strncpy(text, "", sizeof(text)); + if (name) BLI_strncpy(text, name, sizeof(text)); + else BLI_strncpy(text, "", sizeof(text)); - BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text); + BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s" : "%s", text); } else { stamp_data->marker[0] = '\0'; @@ -1245,8 +1245,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_TIME) { int f = (int)(scene->r.cfra % scene->r.frs_sec); int s = (int)(scene->r.cfra / scene->r.frs_sec); - int h= 0; - int m= 0; + int h = 0; + int m = 0; if (s) { m = (int)(s / 60); @@ -1263,7 +1263,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f); - BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s":"%s", text); + BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s" : "%s", text); } else { stamp_data->time[0] = '\0'; @@ -1271,20 +1271,20 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_FRAME) { char fmtstr[32]; - int digits= 1; + int digits = 1; - if (scene->r.efra>9) - digits= 1 + (int) log10(scene->r.efra); + if (scene->r.efra > 9) + digits = 1 + (int) log10(scene->r.efra); - BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di":"%%0%di", digits); - BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra); + BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di" : "%%0%di", digits); + BLI_snprintf(stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; } if (scene->r.stamp & R_STAMP_CAMERA) { - BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", camera ? camera->id.name+2 : ""); + BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s" : "%s", camera ? camera->id.name + 2 : ""); } else { stamp_data->camera[0] = '\0'; @@ -1294,41 +1294,41 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (camera && camera->type == OB_CAMERA) { BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens); } - else BLI_strncpy(text, "", sizeof(text)); + else BLI_strncpy(text, "", sizeof(text)); - BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text); + BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s" : "%s", text); } else { stamp_data->cameralens[0] = '\0'; } if (scene->r.stamp & R_STAMP_SCENE) { - BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s":"%s", scene->id.name+2); + BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s" : "%s", scene->id.name + 2); } else { stamp_data->scene[0] = '\0'; } if (scene->r.stamp & R_STAMP_SEQSTRIP) { - Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra); + Sequence *seq = seq_foreground_frame_get(scene, scene->r.cfra); - if (seq) BLI_strncpy(text, seq->name+2, sizeof(text)); - else BLI_strncpy(text, "", sizeof(text)); + if (seq) BLI_strncpy(text, seq->name + 2, sizeof(text)); + else BLI_strncpy(text, "", sizeof(text)); - BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text); + BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s" : "%s", text); } else { stamp_data->strip[0] = '\0'; } { - Render *re= RE_GetRender(scene->id.name); - RenderStats *stats= re ? RE_GetStats(re):NULL; + Render *re = RE_GetRender(scene->id.name); + RenderStats *stats = re ? RE_GetStats(re) : NULL; if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { BLI_timestr(stats->lastframetime, text); - BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s":"%s", text); + BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text); } else { stamp_data->rendertime[0] = '\0'; @@ -1342,7 +1342,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec float w, h, pad; int x, y, y_ofs; float h_fixed; - const int mono= blf_mono_font_render; // XXX + const int mono = blf_mono_font_render; // XXX #define BUFF_MARGIN_X 2 #define BUFF_MARGIN_Y 1 @@ -1354,29 +1354,29 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* TODO, do_versions */ if (scene->r.stamp_font_id < 8) - scene->r.stamp_font_id= 12; + scene->r.stamp_font_id = 12; /* set before return */ BLF_size(mono, scene->r.stamp_font_id, 72); BLF_buffer(mono, rectf, rect, width, height, channels); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); - pad= BLF_width_max(mono); + pad = BLF_width_max(mono); /* use 'h_fixed' rather than 'h', aligns better */ - h_fixed= BLF_height_max(mono); + h_fixed = BLF_height_max(mono); y_ofs = -BLF_descender(mono); - x= 0; - y= height; + x = 0; + y = height; if (stamp_data.file[0]) { /* Top left corner */ - BLF_width_and_height(mono, stamp_data.file, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.file, &w, &h); h = h_fixed; y -= h; /* also a little of space to the background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and draw the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1388,11 +1388,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Top left corner, below File */ if (stamp_data.note[0]) { - BLF_width_and_height(mono, stamp_data.note, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.note, &w, &h); h = h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.note); @@ -1403,11 +1403,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - BLF_width_and_height(mono, stamp_data.date, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.date, &w, &h); h = h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.date); @@ -1418,25 +1418,25 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Top left corner, below File, Date or Note */ if (stamp_data.rendertime[0]) { - BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h = h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.rendertime); } - x= 0; - y= 0; + x = 0; + y = 0; /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - BLF_width_and_height(mono, stamp_data.marker, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1448,10 +1448,10 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Left bottom corner */ if (stamp_data.time[0]) { - BLF_width_and_height(mono, stamp_data.time, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed; /* extra space for background */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1462,10 +1462,10 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } if (stamp_data.frame[0]) { - BLF_width_and_height(mono, stamp_data.frame, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1476,10 +1476,10 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } if (stamp_data.camera[0]) { - BLF_width_and_height(mono, stamp_data.camera, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.camera); @@ -1488,37 +1488,37 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } if (stamp_data.cameralens[0]) { - BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); } if (stamp_data.scene[0]) { - BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.scene, &w, &h); h = h_fixed; /* Bottom right corner, with an extra space because blenfont is too strict! */ - x= width - w - 2; + x = width - w - 2; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ - BLF_position(mono, x, y+y_ofs, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.scene); } if (stamp_data.strip[0]) { - BLF_width_and_height(mono, stamp_data.strip, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.strip, &w, &h); h = h_fixed; /* Top right corner, with an extra space because blenfont is too strict! */ - x= width - w - pad; - y= height - h; + x = width - w - pad; + y = height - h; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.strip); @@ -1535,38 +1535,38 @@ void BKE_imbuf_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) { struct StampData stamp_data; - if (!ibuf) return; + if (!ibuf) return; /* fill all the data values, no prefix */ stampdata(scene, camera, &stamp_data, 0); - if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file); - if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note); - if (stamp_data.date[0]) IMB_metadata_change_field (ibuf, "Date", stamp_data.date); - if (stamp_data.marker[0]) IMB_metadata_change_field (ibuf, "Marker", stamp_data.marker); - if (stamp_data.time[0]) IMB_metadata_change_field (ibuf, "Time", stamp_data.time); - if (stamp_data.frame[0]) IMB_metadata_change_field (ibuf, "Frame", stamp_data.frame); - if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); - if (stamp_data.cameralens[0]) IMB_metadata_change_field (ibuf, "Lens", stamp_data.cameralens); - if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); - if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); - if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); + if (stamp_data.file[0]) IMB_metadata_change_field(ibuf, "File", stamp_data.file); + if (stamp_data.note[0]) IMB_metadata_change_field(ibuf, "Note", stamp_data.note); + if (stamp_data.date[0]) IMB_metadata_change_field(ibuf, "Date", stamp_data.date); + if (stamp_data.marker[0]) IMB_metadata_change_field(ibuf, "Marker", stamp_data.marker); + if (stamp_data.time[0]) IMB_metadata_change_field(ibuf, "Time", stamp_data.time); + if (stamp_data.frame[0]) IMB_metadata_change_field(ibuf, "Frame", stamp_data.frame); + if (stamp_data.camera[0]) IMB_metadata_change_field(ibuf, "Camera", stamp_data.camera); + if (stamp_data.cameralens[0]) IMB_metadata_change_field(ibuf, "Lens", stamp_data.cameralens); + if (stamp_data.scene[0]) IMB_metadata_change_field(ibuf, "Scene", stamp_data.scene); + if (stamp_data.strip[0]) IMB_metadata_change_field(ibuf, "Strip", stamp_data.strip); + if (stamp_data.rendertime[0]) IMB_metadata_change_field(ibuf, "RenderTime", stamp_data.rendertime); } int BKE_imbuf_alpha_test(ImBuf *ibuf) { int tot; if (ibuf->rect_float) { - float *buf= ibuf->rect_float; - for (tot= ibuf->x * ibuf->y; tot--; buf+=4) { + float *buf = ibuf->rect_float; + for (tot = ibuf->x * ibuf->y; tot--; buf += 4) { if (buf[3] < 1.0f) { return TRUE; } } } else if (ibuf->rect) { - unsigned char *buf= (unsigned char *)ibuf->rect; - for (tot= ibuf->x * ibuf->y; tot--; buf+=4) { + unsigned char *buf = (unsigned char *)ibuf->rect; + for (tot = ibuf->x * ibuf->y; tot--; buf += 4) { if (buf[3] != 255) { return TRUE; } @@ -1580,73 +1580,73 @@ int BKE_imbuf_alpha_test(ImBuf *ibuf) * are already set */ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) { - char imtype= imf->imtype; - char compress= imf->compress; - char quality= imf->quality; + char imtype = imf->imtype; + char compress = imf->compress; + char quality = imf->quality; int ok; - if (imtype== R_IMF_IMTYPE_IRIS) { - ibuf->ftype= IMAGIC; + if (imtype == R_IMF_IMTYPE_IRIS) { + ibuf->ftype = IMAGIC; } #ifdef WITH_HDR - else if (imtype==R_IMF_IMTYPE_RADHDR) { - ibuf->ftype= RADHDR; + else if (imtype == R_IMF_IMTYPE_RADHDR) { + ibuf->ftype = RADHDR; } #endif else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) { - ibuf->ftype= PNG; + ibuf->ftype = PNG; - if (imtype==R_IMF_IMTYPE_PNG) + if (imtype == R_IMF_IMTYPE_PNG) ibuf->ftype |= compress; } #ifdef WITH_DDS - else if (imtype==R_IMF_IMTYPE_DDS) { - ibuf->ftype= DDS; + else if (imtype == R_IMF_IMTYPE_DDS) { + ibuf->ftype = DDS; } #endif - else if (imtype==R_IMF_IMTYPE_BMP) { - ibuf->ftype= BMP; + else if (imtype == R_IMF_IMTYPE_BMP) { + ibuf->ftype = BMP; } #ifdef WITH_TIFF - else if (imtype==R_IMF_IMTYPE_TIFF) { - ibuf->ftype= TIF; + else if (imtype == R_IMF_IMTYPE_TIFF) { + ibuf->ftype = TIF; if (imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= TIF_16BIT; } #endif #ifdef WITH_OPENEXR - else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) { - ibuf->ftype= OPENEXR; + else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) { + ibuf->ftype = OPENEXR; if (imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= OPENEXR_HALF; ibuf->ftype |= (imf->exr_codec & OPENEXR_COMPRESS); if (!(imf->flag & R_IMF_FLAG_ZBUF)) - ibuf->zbuf_float = NULL; /* signal for exr saving */ + ibuf->zbuf_float = NULL; /* signal for exr saving */ } #endif #ifdef WITH_CINEON - else if (imtype==R_IMF_IMTYPE_CINEON) { + else if (imtype == R_IMF_IMTYPE_CINEON) { ibuf->ftype = CINEON; } - else if (imtype==R_IMF_IMTYPE_DPX) { + else if (imtype == R_IMF_IMTYPE_DPX) { ibuf->ftype = DPX; } #endif - else if (imtype==R_IMF_IMTYPE_TARGA) { - ibuf->ftype= TGA; + else if (imtype == R_IMF_IMTYPE_TARGA) { + ibuf->ftype = TGA; } - else if (imtype==R_IMF_IMTYPE_RAWTGA) { - ibuf->ftype= RAWTGA; + else if (imtype == R_IMF_IMTYPE_RAWTGA) { + ibuf->ftype = RAWTGA; } #ifdef WITH_OPENJPEG - else if (imtype==R_IMF_IMTYPE_JP2) { - if (quality < 10) quality= 90; - ibuf->ftype= JP2|quality; + else if (imtype == R_IMF_IMTYPE_JP2) { + if (quality < 10) quality = 90; + ibuf->ftype = JP2 | quality; if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->ftype |= JP2_16BIT; @@ -1668,8 +1668,8 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) #endif else { /* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */ - if (quality < 10) quality= 90; - ibuf->ftype= JPG|quality; + if (quality < 10) quality = 90; + ibuf->ftype = JPG | quality; } BLI_make_existing_file(name); @@ -1685,21 +1685,21 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) /* same as BKE_imbuf_write() but crappy workaround not to perminantly modify * _some_, values in the imbuf */ int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, - const short save_copy) + const short save_copy) { - ImBuf ibuf_back= *ibuf; + ImBuf ibuf_back = *ibuf; int ok; /* all data is rgba anyway, * this just controls how to save for some formats */ - ibuf->planes= imf->planes; + ibuf->planes = imf->planes; - ok= BKE_imbuf_write(ibuf, name, imf); + ok = BKE_imbuf_write(ibuf, name, imf); if (save_copy) { /* note that we are not restoring _all_ settings */ - ibuf->planes= ibuf_back.planes; - ibuf->ftype= ibuf_back.ftype; + ibuf->planes = ibuf_back.planes; + ibuf->ftype = ibuf_back.ftype; } return ok; @@ -1716,8 +1716,8 @@ int BKE_imbuf_write_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, cons void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, const char imtype, const short use_ext, const short use_frames) { - if (string==NULL) return; - BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ + if (string == NULL) return; + BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ BLI_path_abs(string, relbase); if (use_frames) @@ -1729,8 +1729,7 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int } /* used by sequencer too */ -struct anim *openanim(const char *name, int flags, int streamindex) -{ +struct anim *openanim(const char *name, int flags, int streamindex){ struct anim *anim; struct ImBuf *ibuf; @@ -1778,16 +1777,16 @@ Image *BKE_image_verify_viewer(int type, const char *name) { Image *ima; - for (ima=G.main->image.first; ima; ima= ima->id.next) - if (ima->source==IMA_SRC_VIEWER) - if (ima->type==type) + for (ima = G.main->image.first; ima; ima = ima->id.next) + if (ima->source == IMA_SRC_VIEWER) + if (ima->type == type) break; - if (ima==NULL) - ima= image_alloc(name, IMA_SRC_VIEWER, type); + if (ima == NULL) + ima = image_alloc(name, IMA_SRC_VIEWER, type); /* happens on reload, imagewindow cannot be image user when hidden*/ - if (ima->id.us==0) + if (ima->id.us == 0) id_us_plus(&ima->id); return ima; @@ -1800,78 +1799,78 @@ void BKE_image_assign_ibuf(Image *ima, ImBuf *ibuf) void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) { - if (ima==NULL) + if (ima == NULL) return; switch (signal) { - case IMA_SIGNAL_FREE: - image_free_buffers(ima); - if (iuser) - iuser->ok= 1; - break; - case IMA_SIGNAL_SRC_CHANGE: - if (ima->type == IMA_TYPE_UV_TEST) - if (ima->source != IMA_SRC_GENERATED) - ima->type= IMA_TYPE_IMAGE; + case IMA_SIGNAL_FREE: + image_free_buffers(ima); + if (iuser) + iuser->ok = 1; + break; + case IMA_SIGNAL_SRC_CHANGE: + if (ima->type == IMA_TYPE_UV_TEST) + if (ima->source != IMA_SRC_GENERATED) + ima->type = IMA_TYPE_IMAGE; - if (ima->source==IMA_SRC_GENERATED) { - if (ima->gen_x==0 || ima->gen_y==0) { - ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); - if (ibuf) { - ima->gen_x= ibuf->x; - ima->gen_y= ibuf->y; + if (ima->source == IMA_SRC_GENERATED) { + if (ima->gen_x == 0 || ima->gen_y == 0) { + ImBuf *ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); + if (ibuf) { + ima->gen_x = ibuf->x; + ima->gen_y = ibuf->y; + } } } - } - /* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */ - if (ima->type!=IMA_TYPE_MULTILAYER) - image_free_buffers(ima); - - ima->ok= 1; - if (iuser) - iuser->ok= 1; - break; - - case IMA_SIGNAL_RELOAD: - /* try to repack file */ - if (ima->packedfile) { - PackedFile *pf; - pf = newPackedFile(NULL, ima->name, ID_BLEND_PATH(G.main, &ima->id)); - if (pf) { - freePackedFile(ima->packedfile); - ima->packedfile = pf; + /* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */ + if (ima->type != IMA_TYPE_MULTILAYER) image_free_buffers(ima); - } - else { - printf("ERROR: Image not available. Keeping packed image\n"); - } - } - else - image_free_buffers(ima); - - if (iuser) - iuser->ok= 1; - - break; - case IMA_SIGNAL_USER_NEW_IMAGE: - if (iuser) { - iuser->ok= 1; - if (ima->source==IMA_SRC_FILE || ima->source==IMA_SRC_SEQUENCE) { - if (ima->type==IMA_TYPE_MULTILAYER) { - iuser->multi_index= 0; - iuser->layer= iuser->pass= 0; + + ima->ok = 1; + if (iuser) + iuser->ok = 1; + break; + + case IMA_SIGNAL_RELOAD: + /* try to repack file */ + if (ima->packedfile) { + PackedFile *pf; + pf = newPackedFile(NULL, ima->name, ID_BLEND_PATH(G.main, &ima->id)); + if (pf) { + freePackedFile(ima->packedfile); + ima->packedfile = pf; + image_free_buffers(ima); + } + else { + printf("ERROR: Image not available. Keeping packed image\n"); } } - } - break; + else + image_free_buffers(ima); + + if (iuser) + iuser->ok = 1; + + break; + case IMA_SIGNAL_USER_NEW_IMAGE: + if (iuser) { + iuser->ok = 1; + if (ima->source == IMA_SRC_FILE || ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_MULTILAYER) { + iuser->multi_index = 0; + iuser->layer = iuser->pass = 0; + } + } + } + break; } /* don't use notifiers because they are not 100% sure to succeeded * this also makes sure all scenes are accounted for. */ { Scene *scene; - for (scene= G.main->scene.first; scene; scene= scene->id.next) { + for (scene = G.main->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { nodeUpdateID(scene->nodetree, &ima->id); } @@ -1885,32 +1884,32 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) { RenderLayer *rl; - RenderPass *rpass= NULL; + RenderPass *rpass = NULL; - if (rr==NULL) + if (rr == NULL) return NULL; if (iuser) { - short index= 0, rl_index= 0, rp_index; + short index = 0, rl_index = 0, rp_index; - for (rl= rr->layers.first; rl; rl= rl->next, rl_index++) { - rp_index= 0; - for (rpass= rl->passes.first; rpass; rpass= rpass->next, index++, rp_index++) - if (iuser->layer==rl_index && iuser->pass==rp_index) + for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) { + rp_index = 0; + for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++, rp_index++) + if (iuser->layer == rl_index && iuser->pass == rp_index) break; if (rpass) break; } if (rpass) - iuser->multi_index= index; + iuser->multi_index = index; else - iuser->multi_index= 0; + iuser->multi_index = 0; } - if (rpass==NULL) { - rl= rr->layers.first; + if (rpass == NULL) { + rl = rr->layers.first; if (rl) - rpass= rl->passes.first; + rpass = rl->passes.first; } return rpass; @@ -1921,7 +1920,7 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima) if (ima->rr) { return ima->rr; } - else if (ima->type==IMA_TYPE_R_RESULT) { + else if (ima->type == IMA_TYPE_R_RESULT) { if (ima->render_slot == ima->last_render_slot) return RE_AcquireResultRead(RE_GetRender(scene->id.name)); else @@ -1933,8 +1932,8 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima) void BKE_image_release_renderresult(Scene *scene, Image *ima) { - if (ima->rr); - else if (ima->type==IMA_TYPE_R_RESULT) { + if (ima->rr) ; + else if (ima->type == IMA_TYPE_R_RESULT) { if (ima->render_slot == ima->last_render_slot) RE_ReleaseResult(RE_GetRender(scene->id.name)); } @@ -1944,20 +1943,20 @@ void BKE_image_backup_render(Scene *scene, Image *ima) { /* called right before rendering, ima->renders contains render * result pointers for everything but the current render */ - Render *re= RE_GetRender(scene->id.name); - int slot= ima->render_slot, last= ima->last_render_slot; + Render *re = RE_GetRender(scene->id.name); + int slot = ima->render_slot, last = ima->last_render_slot; if (slot != last) { if (ima->renders[slot]) { RE_FreeRenderResult(ima->renders[slot]); - ima->renders[slot]= NULL; + ima->renders[slot] = NULL; } - ima->renders[last]= NULL; + ima->renders[last] = NULL; RE_SwapResult(re, &ima->renders[last]); } - ima->last_render_slot= slot; + ima->last_render_slot = slot; } /* after imbuf load, openexr type can return with a exrhandle open */ @@ -1965,22 +1964,22 @@ void BKE_image_backup_render(Scene *scene, Image *ima) static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) { - ima->rr= RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); + ima->rr = RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); #ifdef WITH_OPENEXR IMB_exr_close(ibuf->userdata); #endif - ibuf->userdata= NULL; + ibuf->userdata = NULL; if (ima->rr) - ima->rr->framenr= framenr; + ima->rr->framenr = framenr; } /* common stuff to do with images after loading */ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) { /* preview is NULL when it has never been used as an icon before */ - if (G.background==0 && ima->preview==NULL) + if (G.background == 0 && ima->preview == NULL) BKE_icon_changed(BKE_icon_getid(&ima->id)); /* fields */ @@ -1991,7 +1990,7 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) /* timer */ ima->lastused = clock() / CLOCKS_PER_SEC; - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } @@ -2006,14 +2005,14 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) if (ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; - ima->lastframe= frame; + ima->lastframe = frame; BLI_strncpy(name, ima->name, sizeof(name)); BLI_stringdec(name, head, tail, &numlen); BLI_stringenc(name, head, tail, numlen, frame); BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id)); - flag= IB_rect|IB_multilayer; + flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; @@ -2022,21 +2021,21 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) #if 0 if (ibuf) { - printf(AT" loaded %s\n", name); + printf(AT " loaded %s\n", name); } else { - printf(AT" missed %s\n", name); + printf(AT " missed %s\n", name); } #endif if (ibuf) { #ifdef WITH_OPENEXR /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ - if (ibuf->ftype==OPENEXR && ibuf->userdata) { + if (ibuf->ftype == OPENEXR && ibuf->userdata) { image_create_multilayer(ima, ibuf, frame); - ima->type= IMA_TYPE_MULTILAYER; + ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); - ibuf= NULL; + ibuf = NULL; } else { image_initialize_after_load(ima, ibuf); @@ -2048,30 +2047,30 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) #endif } else - ima->ok= 0; + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int frame) { - struct ImBuf *ibuf= NULL; + struct ImBuf *ibuf = NULL; /* either we load from RenderResult, or we have to load a new one */ /* check for new RenderResult */ - if (ima->rr==NULL || frame!=ima->rr->framenr) { + if (ima->rr == NULL || frame != ima->rr->framenr) { /* copy to survive not found multilayer image */ - RenderResult *oldrr= ima->rr; + RenderResult *oldrr = ima->rr; - ima->rr= NULL; + ima->rr = NULL; ibuf = image_load_sequence_file(ima, iuser, frame); if (ibuf) { /* actually an error */ - ima->type= IMA_TYPE_IMAGE; + ima->type = IMA_TYPE_IMAGE; printf("error, multi is normal image\n"); } // printf("loaded new result %p\n", ima->rr); @@ -2081,34 +2080,34 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f if (oldrr) RE_FreeRenderResult(oldrr); } else { - ima->rr= oldrr; + ima->rr = oldrr; } } if (ima->rr) { - RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser); + RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); if (rpass) { // printf("load from pass %s\n", rpass->name); /* since we free render results, we copy the rect */ - ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); - ibuf->rect_float= MEM_dupallocN(rpass->rect); + ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); + ibuf->rect_float = MEM_dupallocN(rpass->rect); ibuf->flags |= IB_rectfloat; - ibuf->mall= IB_rectfloat; - ibuf->channels= rpass->channels; + ibuf->mall = IB_rectfloat; + ibuf->channels = rpass->channels; ibuf->profile = IB_PROFILE_LINEAR_RGB; image_initialize_after_load(ima, ibuf); - image_assign_ibuf(ima, ibuf, iuser?iuser->multi_index:0, frame); + image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame); } // else printf("pass not found\n"); } else - ima->ok= 0; + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } @@ -2116,11 +2115,11 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) { - struct ImBuf *ibuf= NULL; + struct ImBuf *ibuf = NULL; - ima->lastframe= frame; + ima->lastframe = frame; - if (ima->anim==NULL) { + if (ima->anim == NULL) { char str[FILE_MAX]; BLI_strncpy(str, ima->name, FILE_MAX); @@ -2130,35 +2129,35 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) ima->anim = openanim(str, IB_rect, 0); /* let's initialize this user */ - if (ima->anim && iuser && iuser->frames==0) - iuser->frames= IMB_anim_get_duration(ima->anim, - IMB_TC_RECORD_RUN); + if (ima->anim && iuser && iuser->frames == 0) + iuser->frames = IMB_anim_get_duration(ima->anim, + IMB_TC_RECORD_RUN); } if (ima->anim) { int dur = IMB_anim_get_duration(ima->anim, - IMB_TC_RECORD_RUN); - int fra= frame-1; + IMB_TC_RECORD_RUN); + int fra = frame - 1; - if (fra<0) fra = 0; - if (fra>(dur-1)) fra= dur-1; + if (fra < 0) fra = 0; + if (fra > (dur - 1)) fra = dur - 1; ibuf = IMB_makeSingleUser( - IMB_anim_absolute(ima->anim, fra, - IMB_TC_RECORD_RUN, - IMB_PROXY_NONE)); + IMB_anim_absolute(ima->anim, fra, + IMB_TC_RECORD_RUN, + IMB_PROXY_NONE)); if (ibuf) { image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); } else - ima->ok= 0; + ima->ok = 0; } else - ima->ok= 0; + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } @@ -2175,13 +2174,13 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* is there a PackedFile with this image ? */ if (ima->packedfile) { - flag = IB_rect|IB_multilayer; + flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, flag, ""); + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, ""); } else { - flag= IB_rect|IB_multilayer|IB_metadata; + flag = IB_rect | IB_multilayer | IB_metadata; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; @@ -2195,15 +2194,15 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) if (ibuf) { /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ - if (ibuf->ftype==OPENEXR && ibuf->userdata) { + if (ibuf->ftype == OPENEXR && ibuf->userdata) { image_create_multilayer(ima, ibuf, cfra); - ima->type= IMA_TYPE_MULTILAYER; + ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); - ibuf= NULL; + ibuf = NULL; } else { image_initialize_after_load(ima, ibuf); - assign= 1; + assign = 1; /* check if the image is a font image... */ detectBitmapFont(ibuf); @@ -2214,49 +2213,49 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) } } else - ima->ok= 0; + ima->ok = 0; if (assign) image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) { - ImBuf *ibuf= NULL; + ImBuf *ibuf = NULL; - if (ima->rr==NULL) { + if (ima->rr == NULL) { ibuf = image_load_image_file(ima, iuser, 0); if (ibuf) { /* actually an error */ - ima->type= IMA_TYPE_IMAGE; + ima->type = IMA_TYPE_IMAGE; return ibuf; } } if (ima->rr) { - RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser); + RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); if (rpass) { - ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); + ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); image_initialize_after_load(ima, ibuf); - ibuf->rect_float= rpass->rect; + ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; - ibuf->channels= rpass->channels; + ibuf->channels = rpass->channels; ibuf->profile = IB_PROFILE_LINEAR_RGB; - image_assign_ibuf(ima, ibuf, iuser?iuser->multi_index:IMA_NO_INDEX, 0); + image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } } - if (ibuf==NULL) - ima->ok= 0; + if (ibuf == NULL) + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } @@ -2274,7 +2273,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ float dither; int channels, layer, pass; ImBuf *ibuf; - int from_render= (ima->render_slot == ima->last_render_slot); + int from_render = (ima->render_slot == ima->last_render_slot); if (!(iuser && iuser->scene)) return NULL; @@ -2283,18 +2282,18 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if (!lock_r) return NULL; - re= RE_GetRender(iuser->scene->id.name); + re = RE_GetRender(iuser->scene->id.name); - channels= 4; - layer= (iuser)? iuser->layer: 0; - pass= (iuser)? iuser->pass: 0; + channels = 4; + layer = (iuser) ? iuser->layer : 0; + pass = (iuser) ? iuser->pass : 0; if (from_render) { RE_AcquireResultImage(re, &rres); } else if (ima->renders[ima->render_slot]) { - rres= *(ima->renders[ima->render_slot]); - rres.have_combined= rres.rectf != NULL; + rres = *(ima->renders[ima->render_slot]); + rres.have_combined = rres.rectf != NULL; } else memset(&rres, 0, sizeof(RenderResult)); @@ -2308,83 +2307,83 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ /* release is done in BKE_image_release_ibuf using lock_r */ if (from_render) { BLI_lock_thread(LOCK_VIEWER); - *lock_r= re; + *lock_r = re; } /* this gives active layer, composite or seqence result */ - rect= (unsigned int *)rres.rect32; - rectf= rres.rectf; - rectz= rres.rectz; - dither= iuser->scene->r.dither_intensity; + rect = (unsigned int *)rres.rect32; + rectf = rres.rectf; + rectz = rres.rectz; + dither = iuser->scene->r.dither_intensity; /* combined layer gets added as first layer */ - if (rres.have_combined && layer==0); + if (rres.have_combined && layer == 0) ; else if (rres.layers.first) { - RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.have_combined?1:0)); + RenderLayer *rl = BLI_findlink(&rres.layers, layer - (rres.have_combined ? 1 : 0)); if (rl) { RenderPass *rpass; /* there's no combined pass, is in renderlayer itself */ - if (pass==0) { - rectf= rl->rectf; + if (pass == 0) { + rectf = rl->rectf; } else { - rpass= BLI_findlink(&rl->passes, pass-1); + rpass = BLI_findlink(&rl->passes, pass - 1); if (rpass) { - channels= rpass->channels; - rectf= rpass->rect; - dither= 0.0f; /* don't dither passes */ + channels = rpass->channels; + rectf = rpass->rect; + dither = 0.0f; /* don't dither passes */ } } - for (rpass= rl->passes.first; rpass; rpass= rpass->next) + for (rpass = rl->passes.first; rpass; rpass = rpass->next) if (rpass->passtype == SCE_PASS_Z) - rectz= rpass->rect; + rectz = rpass->rect; } } - ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); /* make ibuf if needed, and initialize it */ - if (ibuf==NULL) { - ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0); + if (ibuf == NULL) { + ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, 0); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } - ibuf->x= rres.rectx; - ibuf->y= rres.recty; + ibuf->x = rres.rectx; + ibuf->y = rres.recty; /* free rect buffer if float buffer changes, so it can be recreated with * the updated result, and also in case we got byte buffer from sequencer, * so we don't keep reference to freed buffer */ - if (ibuf->rect_float!=rectf || rect || !rectf) + if (ibuf->rect_float != rectf || rect || !rectf) imb_freerectImBuf(ibuf); if (rect) - ibuf->rect= rect; + ibuf->rect = rect; if (rectf) { - ibuf->rect_float= rectf; + ibuf->rect_float = rectf; ibuf->flags |= IB_rectfloat; - ibuf->channels= channels; + ibuf->channels = channels; } else { - ibuf->rect_float= NULL; + ibuf->rect_float = NULL; ibuf->flags &= ~IB_rectfloat; } if (rectz) { - ibuf->zbuf_float= rectz; + ibuf->zbuf_float = rectz; ibuf->flags |= IB_zbuffloat; } else { - ibuf->zbuf_float= NULL; + ibuf->zbuf_float = NULL; ibuf->flags &= ~IB_zbuffloat; } /* since its possible to access the buffer from the image directly, set the profile [#25073] */ - ibuf->profile= (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; - ibuf->dither= dither; + ibuf->profile = (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; + ibuf->dither = dither; if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) { ibuf->flags |= IB_cm_predivide; @@ -2395,7 +2394,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ima->flag &= ~IMA_CM_PREDIVIDE; } - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; return ibuf; } @@ -2406,18 +2405,18 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame int frame = 0, index = 0; /* see if we already have an appropriate ibuf, with image source and type */ - if (ima->source==IMA_SRC_MOVIE) { - frame= iuser?iuser->framenr:ima->lastframe; - ibuf= image_get_ibuf(ima, 0, frame); + if (ima->source == IMA_SRC_MOVIE) { + frame = iuser ? iuser->framenr : ima->lastframe; + ibuf = image_get_ibuf(ima, 0, frame); /* XXX temp stuff? */ if (ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe = frame; } - else if (ima->source==IMA_SRC_SEQUENCE) { - if (ima->type==IMA_TYPE_IMAGE) { - frame= iuser?iuser->framenr:ima->lastframe; - ibuf= image_get_ibuf(ima, 0, frame); + else if (ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_IMAGE) { + frame = iuser ? iuser->framenr : ima->lastframe; + ibuf = image_get_ibuf(ima, 0, frame); /* XXX temp stuff? */ if (ima->lastframe != frame) { @@ -2425,20 +2424,20 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame } ima->lastframe = frame; } - else if (ima->type==IMA_TYPE_MULTILAYER) { - frame= iuser?iuser->framenr:ima->lastframe; - index= iuser?iuser->multi_index:IMA_NO_INDEX; - ibuf= image_get_ibuf(ima, index, frame); + else if (ima->type == IMA_TYPE_MULTILAYER) { + frame = iuser ? iuser->framenr : ima->lastframe; + index = iuser ? iuser->multi_index : IMA_NO_INDEX; + ibuf = image_get_ibuf(ima, index, frame); } } - else if (ima->source==IMA_SRC_FILE) { - if (ima->type==IMA_TYPE_IMAGE) - ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); - else if (ima->type==IMA_TYPE_MULTILAYER) - ibuf= image_get_ibuf(ima, iuser?iuser->multi_index:IMA_NO_INDEX, 0); + else if (ima->source == IMA_SRC_FILE) { + if (ima->type == IMA_TYPE_IMAGE) + ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); + else if (ima->type == IMA_TYPE_MULTILAYER) + ibuf = image_get_ibuf(ima, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } else if (ima->source == IMA_SRC_GENERATED) { - ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); } else if (ima->source == IMA_SRC_VIEWER) { /* always verify entirely, not that this shouldn't happen @@ -2457,9 +2456,9 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame * if not, use BKE_image_get_ibuf which doesn't require a release */ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) { - ImBuf *ibuf= NULL; + ImBuf *ibuf = NULL; float color[] = {0, 0, 0, 1}; - int frame= 0, index= 0; + int frame = 0, index = 0; /* This function is intended to be thread-safe. It postpones the mutex lock * until it needs to load the image, if the image is already there it @@ -2473,20 +2472,20 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) * 2) set ima/iuser->ok to 0 to IMA_OK_LOADED */ if (lock_r) - *lock_r= NULL; + *lock_r = NULL; /* quick reject tests */ - if (ima==NULL) + if (ima == NULL) return NULL; if (iuser) { - if (iuser->ok==0) + if (iuser->ok == 0) return NULL; } - else if (ima->ok==0) + else if (ima->ok == 0) return NULL; /* try to get the ibuf without locking */ - ibuf= image_get_ibuf_threadsafe(ima, iuser, &frame, &index); + ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); if (ibuf == NULL) { /* couldn't get ibuf and image is not ok, so let's lock and try to @@ -2496,75 +2495,75 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* need to check ok flag and loading ibuf again, because the situation * might have changed in the meantime */ if (iuser) { - if (iuser->ok==0) { + if (iuser->ok == 0) { BLI_unlock_thread(LOCK_IMAGE); return NULL; } } - else if (ima->ok==0) { + else if (ima->ok == 0) { BLI_unlock_thread(LOCK_IMAGE); return NULL; } - ibuf= image_get_ibuf_threadsafe(ima, iuser, &frame, &index); + ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); if (ibuf == NULL) { /* we are sure we have to load the ibuf, using source and type */ - if (ima->source==IMA_SRC_MOVIE) { + if (ima->source == IMA_SRC_MOVIE) { /* source is from single file, use flipbook to store ibuf */ - ibuf= image_load_movie_file(ima, iuser, frame); + ibuf = image_load_movie_file(ima, iuser, frame); } - else if (ima->source==IMA_SRC_SEQUENCE) { - if (ima->type==IMA_TYPE_IMAGE) { + else if (ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_IMAGE) { /* regular files, ibufs in flipbook, allows saving */ - ibuf= image_load_sequence_file(ima, iuser, frame); + ibuf = image_load_sequence_file(ima, iuser, frame); } /* no else; on load the ima type can change */ - if (ima->type==IMA_TYPE_MULTILAYER) { + if (ima->type == IMA_TYPE_MULTILAYER) { /* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */ - ibuf= image_load_sequence_multilayer(ima, iuser, frame); + ibuf = image_load_sequence_multilayer(ima, iuser, frame); } } - else if (ima->source==IMA_SRC_FILE) { + else if (ima->source == IMA_SRC_FILE) { - if (ima->type==IMA_TYPE_IMAGE) - ibuf= image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ + if (ima->type == IMA_TYPE_IMAGE) + ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ /* no else; on load the ima type can change */ - if (ima->type==IMA_TYPE_MULTILAYER) + if (ima->type == IMA_TYPE_MULTILAYER) /* keeps render result, stores ibufs in listbase, allows saving */ - ibuf= image_get_ibuf_multilayer(ima, iuser); + ibuf = image_get_ibuf_multilayer(ima, iuser); } else if (ima->source == IMA_SRC_GENERATED) { /* generated is: ibuf is allocated dynamically */ /* UV testgrid or black or solid etc */ - if (ima->gen_x==0) ima->gen_x= 1024; - if (ima->gen_y==0) ima->gen_y= 1024; - ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color); + if (ima->gen_x == 0) ima->gen_x = 1024; + if (ima->gen_y == 0) ima->gen_y = 1024; + ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } else if (ima->source == IMA_SRC_VIEWER) { - if (ima->type==IMA_TYPE_R_RESULT) { + if (ima->type == IMA_TYPE_R_RESULT) { /* always verify entirely, and potentially * returns pointer to release later */ - ibuf= image_get_render_result(ima, iuser, lock_r); + ibuf = image_get_render_result(ima, iuser, lock_r); } - else if (ima->type==IMA_TYPE_COMPOSITE) { + else if (ima->type == IMA_TYPE_COMPOSITE) { /* requires lock/unlock, otherwise don't return image */ if (lock_r) { /* unlock in BKE_image_release_ibuf */ BLI_lock_thread(LOCK_VIEWER); - *lock_r= ima; + *lock_r = ima; /* XXX anim play for viewer nodes not yet supported */ - frame= 0; // XXX iuser?iuser->framenr:0; - ibuf= image_get_ibuf(ima, 0, frame); + frame = 0; // XXX iuser?iuser->framenr:0; + ibuf = image_get_ibuf(ima, 0, frame); if (!ibuf) { /* Composite Viewer, all handled in compositor */ /* fake ibuf, will be filled in compositor */ - ibuf= IMB_allocImBuf(256, 256, 32, IB_rect); + ibuf = IMB_allocImBuf(256, 256, 32, IB_rect); image_assign_ibuf(ima, ibuf, 0, frame); } } @@ -2601,38 +2600,38 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) { - const int len= (iuser->fie_ima*iuser->frames)/2; + const int len = (iuser->fie_ima * iuser->frames) / 2; - if (len==0) { + if (len == 0) { return 0; } else { int framenr; - cfra= cfra - iuser->sfra+1; + cfra = cfra - iuser->sfra + 1; /* cyclic */ if (iuser->cycl) { - cfra= ((cfra) % len); - if (cfra < 0) cfra+= len; - if (cfra==0) cfra= len; + cfra = ((cfra) % len); + if (cfra < 0) cfra += len; + if (cfra == 0) cfra = len; } - if (cfra<0) cfra= 0; - else if (cfra>len) cfra= len; + if (cfra < 0) cfra = 0; + else if (cfra > len) cfra = len; /* convert current frame to current field */ - cfra= 2*(cfra); + cfra = 2 * (cfra); if (fieldnr) cfra++; /* transform to images space */ - framenr= (cfra+iuser->fie_ima-2)/iuser->fie_ima; - if (framenr>iuser->frames) framenr= iuser->frames; - framenr+= iuser->offset; + framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima; + if (framenr > iuser->frames) framenr = iuser->frames; + framenr += iuser->offset; if (iuser->cycl) { - framenr= ((framenr) % len); - while (framenr < 0) framenr+= len; - if (framenr==0) framenr= len; + framenr = ((framenr) % len); + while (framenr < 0) framenr += len; + if (framenr == 0) framenr = len; } return framenr; @@ -2641,15 +2640,15 @@ int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr) { - const int framenr= BKE_image_user_frame_get(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) - if (framenr!=iuser->framenr) + if (framenr != iuser->framenr) iuser->flag |= IMA_ANIM_REFRESHED; - iuser->framenr= framenr; - if (iuser->ok==0) iuser->ok= 1; + iuser->framenr = framenr; + if (iuser->ok == 0) iuser->ok = 1; } int BKE_image_has_alpha(struct Image *image) @@ -2658,8 +2657,8 @@ int BKE_image_has_alpha(struct Image *image) void *lock; int planes; - ibuf= BKE_image_acquire_ibuf(image, NULL, &lock); - planes = (ibuf?ibuf->planes:0); + ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); + planes = (ibuf ? ibuf->planes : 0); BKE_image_release_ibuf(image, lock); if (planes == 32) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index c2cb45d9f9d..1077b5ad7c3 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -84,10 +84,10 @@ void BKE_ipo_free(Ipo *ipo) { IpoCurve *icu, *icn; - int n= 0; + int n = 0; - for (icu= ipo->curve.first; icu; icu= icn) { - icn= icu->next; + for (icu = ipo->curve.first; icu; icu = icn) { + icn = icu->next; n++; if (icu->bezt) MEM_freeN(icu->bezt); @@ -98,7 +98,7 @@ void BKE_ipo_free(Ipo *ipo) } if (G.debug & G_DEBUG) - printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name+2); + printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name + 2); } /* *************************************************** */ @@ -115,35 +115,35 @@ typedef struct AdrBit2Path { /* Mapping Tables to use bits <-> RNA paths */ /* Object layers */ -static AdrBit2Path ob_layer_bits[]= { - {(1<<0), "layers", 0}, - {(1<<1), "layers", 1}, - {(1<<2), "layers", 2}, - {(1<<3), "layers", 3}, - {(1<<4), "layers", 4}, - {(1<<5), "layers", 5}, - {(1<<6), "layers", 6}, - {(1<<7), "layers", 7}, - {(1<<8), "layers", 8}, - {(1<<9), "layers", 9}, - {(1<<10), "layers", 10}, - {(1<<11), "layers", 11}, - {(1<<12), "layers", 12}, - {(1<<13), "layers", 13}, - {(1<<14), "layers", 14}, - {(1<<15), "layers", 15}, - {(1<<16), "layers", 16}, - {(1<<17), "layers", 17}, - {(1<<18), "layers", 18}, - {(1<<19), "layers", 19} +static AdrBit2Path ob_layer_bits[] = { + {(1 << 0), "layers", 0}, + {(1 << 1), "layers", 1}, + {(1 << 2), "layers", 2}, + {(1 << 3), "layers", 3}, + {(1 << 4), "layers", 4}, + {(1 << 5), "layers", 5}, + {(1 << 6), "layers", 6}, + {(1 << 7), "layers", 7}, + {(1 << 8), "layers", 8}, + {(1 << 9), "layers", 9}, + {(1 << 10), "layers", 10}, + {(1 << 11), "layers", 11}, + {(1 << 12), "layers", 12}, + {(1 << 13), "layers", 13}, + {(1 << 14), "layers", 14}, + {(1 << 15), "layers", 15}, + {(1 << 16), "layers", 16}, + {(1 << 17), "layers", 17}, + {(1 << 18), "layers", 18}, + {(1 << 19), "layers", 19} }; /* Material mode */ -static AdrBit2Path ma_mode_bits[]= { +static AdrBit2Path ma_mode_bits[] = { // {MA_TRACEBLE, "traceable", 0}, -// {MA_SHADOW, "shadow", 0}, +// {MA_SHADOW, "shadow", 0}, // {MA_SHLESS, "shadeless", 0}, -// ... +// ... {MA_RAYTRANSP, "transparency", 0}, {MA_RAYMIRROR, "raytrace_mirror.enabled", 0}, // {MA_HALO, "type", MA_TYPE_HALO} @@ -154,99 +154,99 @@ static AdrBit2Path ma_mode_bits[]= { /* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */ #define RET_ABP(items) \ { \ - *tot= sizeof(items)/sizeof(AdrBit2Path); \ + *tot = sizeof(items) / sizeof(AdrBit2Path); \ return items; \ } /* This function checks if a Blocktype+Adrcode combo, returning a mapping table */ -static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *tot) +static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *tot) { /* Object layers */ if ((blocktype == ID_OB) && (adrcode == OB_LAY)) RET_ABP(ob_layer_bits) - else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) - RET_ABP(ma_mode_bits) - // XXX TODO: add other types... + else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) + RET_ABP(ma_mode_bits) + // XXX TODO: add other types... - /* Normal curve */ - return NULL; + /* Normal curve */ + return NULL; } /* *************************************************** */ /* ADRCODE to RNA-Path Conversion Code - Standard */ /* Object types */ -static const char *ob_adrcodes_to_paths (int adrcode, int *array_index) +static const char *ob_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case OB_LOC_X: - *array_index= 0; return "location"; + *array_index = 0; return "location"; case OB_LOC_Y: - *array_index= 1; return "location"; + *array_index = 1; return "location"; case OB_LOC_Z: - *array_index= 2; return "location"; + *array_index = 2; return "location"; case OB_DLOC_X: - *array_index= 0; return "delta_location"; + *array_index = 0; return "delta_location"; case OB_DLOC_Y: - *array_index= 1; return "delta_location"; + *array_index = 1; return "delta_location"; case OB_DLOC_Z: - *array_index= 2; return "delta_location"; + *array_index = 2; return "delta_location"; case OB_ROT_X: - *array_index= 0; return "rotation_euler"; + *array_index = 0; return "rotation_euler"; case OB_ROT_Y: - *array_index= 1; return "rotation_euler"; + *array_index = 1; return "rotation_euler"; case OB_ROT_Z: - *array_index= 2; return "rotation_euler"; + *array_index = 2; return "rotation_euler"; case OB_DROT_X: - *array_index= 0; return "delta_rotation_euler"; + *array_index = 0; return "delta_rotation_euler"; case OB_DROT_Y: - *array_index= 1; return "delta_rotation_euler"; + *array_index = 1; return "delta_rotation_euler"; case OB_DROT_Z: - *array_index= 2; return "delta_rotation_euler"; + *array_index = 2; return "delta_rotation_euler"; case OB_SIZE_X: - *array_index= 0; return "scale"; + *array_index = 0; return "scale"; case OB_SIZE_Y: - *array_index= 1; return "scale"; + *array_index = 1; return "scale"; case OB_SIZE_Z: - *array_index= 2; return "scale"; + *array_index = 2; return "scale"; case OB_DSIZE_X: - *array_index= 0; return "delta_scale"; + *array_index = 0; return "delta_scale"; case OB_DSIZE_Y: - *array_index= 1; return "delta_scale"; + *array_index = 1; return "delta_scale"; case OB_DSIZE_Z: - *array_index= 2; return "delta_scale"; + *array_index = 2; return "delta_scale"; case OB_COL_R: - *array_index= 0; return "color"; + *array_index = 0; return "color"; case OB_COL_G: - *array_index= 1; return "color"; + *array_index = 1; return "color"; case OB_COL_B: - *array_index= 2; return "color"; + *array_index = 2; return "color"; case OB_COL_A: - *array_index= 3; return "color"; + *array_index = 3; return "color"; #if 0 case OB_PD_FSTR: - if (ob->pd) poin= &(ob->pd->f_strength); + if (ob->pd) poin = &(ob->pd->f_strength); break; case OB_PD_FFALL: - if (ob->pd) poin= &(ob->pd->f_power); + if (ob->pd) poin = &(ob->pd->f_power); break; case OB_PD_SDAMP: - if (ob->pd) poin= &(ob->pd->pdef_damp); + if (ob->pd) poin = &(ob->pd->pdef_damp); break; case OB_PD_RDAMP: - if (ob->pd) poin= &(ob->pd->pdef_rdamp); + if (ob->pd) poin = &(ob->pd->pdef_rdamp); break; case OB_PD_PERM: - if (ob->pd) poin= &(ob->pd->pdef_perm); + if (ob->pd) poin = &(ob->pd->pdef_perm); break; case OB_PD_FMAXD: - if (ob->pd) poin= &(ob->pd->maxdist); + if (ob->pd) poin = &(ob->pd->maxdist); break; #endif } @@ -257,42 +257,42 @@ static const char *ob_adrcodes_to_paths (int adrcode, int *array_index) /* PoseChannel types * NOTE: pchan name comes from 'actname' added earlier... */ -static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index) +static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case AC_QUAT_W: - *array_index= 0; return "rotation_quaternion"; + *array_index = 0; return "rotation_quaternion"; case AC_QUAT_X: - *array_index= 1; return "rotation_quaternion"; + *array_index = 1; return "rotation_quaternion"; case AC_QUAT_Y: - *array_index= 2; return "rotation_quaternion"; + *array_index = 2; return "rotation_quaternion"; case AC_QUAT_Z: - *array_index= 3; return "rotation_quaternion"; + *array_index = 3; return "rotation_quaternion"; case AC_EUL_X: - *array_index= 0; return "rotation_euler"; + *array_index = 0; return "rotation_euler"; case AC_EUL_Y: - *array_index= 1; return "rotation_euler"; + *array_index = 1; return "rotation_euler"; case AC_EUL_Z: - *array_index= 2; return "rotation_euler"; + *array_index = 2; return "rotation_euler"; case AC_LOC_X: - *array_index= 0; return "location"; + *array_index = 0; return "location"; case AC_LOC_Y: - *array_index= 1; return "location"; + *array_index = 1; return "location"; case AC_LOC_Z: - *array_index= 2; return "location"; + *array_index = 2; return "location"; case AC_SIZE_X: - *array_index= 0; return "scale"; + *array_index = 0; return "scale"; case AC_SIZE_Y: - *array_index= 1; return "scale"; + *array_index = 1; return "scale"; case AC_SIZE_Z: - *array_index= 2; return "scale"; + *array_index = 2; return "scale"; } /* for debugging only */ @@ -301,16 +301,16 @@ static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index) } /* Constraint types */ -static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) +static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case CO_ENFORCE: return "influence"; - case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid + case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid return "data.head_tail"; } @@ -321,7 +321,7 @@ static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) * NOTE: as we don't have access to the keyblock where the data comes from (for now), * we'll just use numerical indices for now... */ -static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) +static char *shapekey_adrcodes_to_paths(int adrcode, int *UNUSED(array_index)) { static char buf[128]; @@ -338,64 +338,64 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) } /* MTex (Texture Slot) types */ -static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) +static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index)) { - const char *base=NULL, *prop=NULL; + const char *base = NULL, *prop = NULL; static char buf[128]; /* base part of path */ - if (adrcode & MA_MAP1) base= "textures[0]"; - else if (adrcode & MA_MAP2) base= "textures[1]"; - else if (adrcode & MA_MAP3) base= "textures[2]"; - else if (adrcode & MA_MAP4) base= "textures[3]"; - else if (adrcode & MA_MAP5) base= "textures[4]"; - else if (adrcode & MA_MAP6) base= "textures[5]"; - else if (adrcode & MA_MAP7) base= "textures[6]"; - else if (adrcode & MA_MAP8) base= "textures[7]"; - else if (adrcode & MA_MAP9) base= "textures[8]"; - else if (adrcode & MA_MAP10) base= "textures[9]"; - else if (adrcode & MA_MAP11) base= "textures[10]"; - else if (adrcode & MA_MAP12) base= "textures[11]"; - else if (adrcode & MA_MAP13) base= "textures[12]"; - else if (adrcode & MA_MAP14) base= "textures[13]"; - else if (adrcode & MA_MAP15) base= "textures[14]"; - else if (adrcode & MA_MAP16) base= "textures[15]"; - else if (adrcode & MA_MAP17) base= "textures[16]"; - else if (adrcode & MA_MAP18) base= "textures[17]"; + if (adrcode & MA_MAP1) base = "textures[0]"; + else if (adrcode & MA_MAP2) base = "textures[1]"; + else if (adrcode & MA_MAP3) base = "textures[2]"; + else if (adrcode & MA_MAP4) base = "textures[3]"; + else if (adrcode & MA_MAP5) base = "textures[4]"; + else if (adrcode & MA_MAP6) base = "textures[5]"; + else if (adrcode & MA_MAP7) base = "textures[6]"; + else if (adrcode & MA_MAP8) base = "textures[7]"; + else if (adrcode & MA_MAP9) base = "textures[8]"; + else if (adrcode & MA_MAP10) base = "textures[9]"; + else if (adrcode & MA_MAP11) base = "textures[10]"; + else if (adrcode & MA_MAP12) base = "textures[11]"; + else if (adrcode & MA_MAP13) base = "textures[12]"; + else if (adrcode & MA_MAP14) base = "textures[13]"; + else if (adrcode & MA_MAP15) base = "textures[14]"; + else if (adrcode & MA_MAP16) base = "textures[15]"; + else if (adrcode & MA_MAP17) base = "textures[16]"; + else if (adrcode & MA_MAP18) base = "textures[17]"; /* property identifier for path */ - adrcode= (adrcode & (MA_MAP1-1)); + adrcode = (adrcode & (MA_MAP1 - 1)); switch (adrcode) { #if 0 // XXX these are not wrapped in RNA yet! case MAP_OFS_X: - poin= &(mtex->ofs[0]); break; + poin = &(mtex->ofs[0]); break; case MAP_OFS_Y: - poin= &(mtex->ofs[1]); break; + poin = &(mtex->ofs[1]); break; case MAP_OFS_Z: - poin= &(mtex->ofs[2]); break; + poin = &(mtex->ofs[2]); break; case MAP_SIZE_X: - poin= &(mtex->size[0]); break; + poin = &(mtex->size[0]); break; case MAP_SIZE_Y: - poin= &(mtex->size[1]); break; + poin = &(mtex->size[1]); break; case MAP_SIZE_Z: - poin= &(mtex->size[2]); break; + poin = &(mtex->size[2]); break; case MAP_R: - poin= &(mtex->r); break; + poin = &(mtex->r); break; case MAP_G: - poin= &(mtex->g); break; + poin = &(mtex->g); break; case MAP_B: - poin= &(mtex->b); break; + poin = &(mtex->b); break; case MAP_DVAR: - poin= &(mtex->def_var); break; + poin = &(mtex->def_var); break; case MAP_COLF: - poin= &(mtex->colfac); break; + poin = &(mtex->colfac); break; case MAP_NORF: - poin= &(mtex->norfac); break; + poin = &(mtex->norfac); break; case MAP_VARF: - poin= &(mtex->varfac); break; + poin = &(mtex->varfac); break; #endif case MAP_DISP: - prop= "warp_factor"; break; + prop = "warp_factor"; break; } /* only build and return path if there's a property */ @@ -408,10 +408,10 @@ static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index) } /* Texture types */ -static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) +static const char *texture_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -420,7 +420,7 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) case TE_TURB: return "turbulence"; - case TE_NDEPTH: // XXX texture RNA undefined + case TE_NDEPTH: // XXX texture RNA undefined //poin= &(tex->noisedepth); *type= IPO_SHORT; break; break; case TE_NTYPE: // XXX texture RNA undefined @@ -432,15 +432,15 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) case TE_N_BAS2: return "noise_basis"; // XXX this is not yet defined in RNA... - /* voronoi */ + /* voronoi */ case TE_VNW1: - *array_index= 0; return "feature_weights"; + *array_index = 0; return "feature_weights"; case TE_VNW2: - *array_index= 1; return "feature_weights"; + *array_index = 1; return "feature_weights"; case TE_VNW3: - *array_index= 2; return "feature_weights"; + *array_index = 2; return "feature_weights"; case TE_VNW4: - *array_index= 3; return "feature_weights"; + *array_index = 3; return "feature_weights"; case TE_VNMEXP: return "minkovsky_exponent"; case TE_VN_DISTM: @@ -448,17 +448,17 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) case TE_VN_COLT: return "color_type"; - /* distorted noise / voronoi */ + /* distorted noise / voronoi */ case TE_ISCA: return "noise_intensity"; - /* distorted noise */ + /* distorted noise */ case TE_DISTA: return "distortion_amount"; - /* musgrave */ + /* musgrave */ case TE_MG_TYP: // XXX texture RNA undefined - // poin= &(tex->stype); *type= IPO_SHORT; break; + // poin= &(tex->stype); *type= IPO_SHORT; break; break; case TE_MGH: return "highest_dimension"; @@ -472,11 +472,11 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) return "gain"; case TE_COL_R: - *array_index= 0; return "rgb_factor"; + *array_index = 0; return "rgb_factor"; case TE_COL_G: - *array_index= 1; return "rgb_factor"; + *array_index = 1; return "rgb_factor"; case TE_COL_B: - *array_index= 2; return "rgb_factor"; + *array_index = 2; return "rgb_factor"; case TE_BRIGHT: return "brightness"; @@ -488,33 +488,33 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) } /* Material Types */ -static const char *material_adrcodes_to_paths (int adrcode, int *array_index) +static const char *material_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case MA_COL_R: - *array_index= 0; return "diffuse_color"; + *array_index = 0; return "diffuse_color"; case MA_COL_G: - *array_index= 1; return "diffuse_color"; + *array_index = 1; return "diffuse_color"; case MA_COL_B: - *array_index= 2; return "diffuse_color"; + *array_index = 2; return "diffuse_color"; case MA_SPEC_R: - *array_index= 0; return "specular_color"; + *array_index = 0; return "specular_color"; case MA_SPEC_G: - *array_index= 1; return "specular_color"; + *array_index = 1; return "specular_color"; case MA_SPEC_B: - *array_index= 2; return "specular_color"; + *array_index = 2; return "specular_color"; case MA_MIR_R: - *array_index= 0; return "mirror_color"; + *array_index = 0; return "mirror_color"; case MA_MIR_G: - *array_index= 1; return "mirror_color"; + *array_index = 1; return "mirror_color"; case MA_MIR_B: - *array_index= 2; return "mirror_color"; + *array_index = 2; return "mirror_color"; case MA_ALPHA: return "alpha"; @@ -572,10 +572,10 @@ static const char *material_adrcodes_to_paths (int adrcode, int *array_index) } /* Camera Types */ -static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) +static const char *camera_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -596,9 +596,9 @@ static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) #if 0 // XXX these are not defined in RNA case CAM_YF_APERT: - poin= &(ca->YF_aperture); break; + poin = &(ca->YF_aperture); break; case CAM_YF_FDIST: - poin= &(ca->YF_dofdist); break; + poin = &(ca->YF_dofdist); break; #endif // XXX these are not defined in RNA case CAM_SHIFT_X: @@ -612,10 +612,10 @@ static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) } /* Lamp Types */ -static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) +static const char *lamp_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -623,11 +623,11 @@ static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) return "energy"; case LA_COL_R: - *array_index= 0; return "color"; + *array_index = 0; return "color"; case LA_COL_G: - *array_index= 1; return "color"; + *array_index = 1; return "color"; case LA_COL_B: - *array_index= 2; return "color"; + *array_index = 2; return "color"; case LA_DIST: return "distance"; @@ -654,10 +654,10 @@ static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) } /* Sound Types */ -static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) +static const char *sound_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -665,7 +665,7 @@ static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) return "volume"; case SND_PITCH: return "pitch"; - /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */ + /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */ #if 0 case SND_PANNING: return "panning"; @@ -679,25 +679,25 @@ static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) } /* World Types */ -static const char *world_adrcodes_to_paths (int adrcode, int *array_index) +static const char *world_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case WO_HOR_R: - *array_index= 0; return "horizon_color"; + *array_index = 0; return "horizon_color"; case WO_HOR_G: - *array_index= 1; return "horizon_color"; + *array_index = 1; return "horizon_color"; case WO_HOR_B: - *array_index= 2; return "horizon_color"; + *array_index = 2; return "horizon_color"; case WO_ZEN_R: - *array_index= 0; return "zenith_color"; + *array_index = 0; return "zenith_color"; case WO_ZEN_G: - *array_index= 1; return "zenith_color"; + *array_index = 1; return "zenith_color"; case WO_ZEN_B: - *array_index= 2; return "zenith_color"; + *array_index = 2; return "zenith_color"; case WO_EXPOS: return "exposure"; @@ -724,16 +724,16 @@ static const char *world_adrcodes_to_paths (int adrcode, int *array_index) default: /* for now, we assume that the others were MTex channels */ return mtex_adrcodes_to_paths(adrcode, array_index); - } + } return NULL; } /* Particle Types */ -static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) +static const char *particle_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -752,11 +752,11 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) case PART_LENGTH: return "settings.length"; case PART_GRAV_X: - *array_index= 0; return "settings.acceleration"; + *array_index = 0; return "settings.acceleration"; case PART_GRAV_Y: - *array_index= 1; return "settings.acceleration"; + *array_index = 1; return "settings.acceleration"; case PART_GRAV_Z: - *array_index= 2; return "settings.acceleration"; + *array_index = 2; return "settings.acceleration"; case PART_KINK_AMP: return "settings.kink_amplitude"; case PART_KINK_FREQ: @@ -773,22 +773,22 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) * as the similar object forces */ #if 0 case PART_PD_FSTR: - if (part->pd) poin= &(part->pd->f_strength); + if (part->pd) poin = &(part->pd->f_strength); break; case PART_PD_FFALL: - if (part->pd) poin= &(part->pd->f_power); + if (part->pd) poin = &(part->pd->f_power); break; case PART_PD_FMAXD: - if (part->pd) poin= &(part->pd->maxdist); + if (part->pd) poin = &(part->pd->maxdist); break; case PART_PD2_FSTR: - if (part->pd2) poin= &(part->pd2->f_strength); + if (part->pd2) poin = &(part->pd2->f_strength); break; case PART_PD2_FFALL: - if (part->pd2) poin= &(part->pd2->f_power); + if (part->pd2) poin = &(part->pd2->f_power); break; case PART_PD2_FMAXD: - if (part->pd2) poin= &(part->pd2->maxdist); + if (part->pd2) poin = &(part->pd2->maxdist); break; #endif @@ -807,84 +807,84 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) * - array_index - index in property's array (if applicable) to use * - return - the allocated path... */ -static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index) +static char *get_rna_access(int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index) { - DynStr *path= BLI_dynstr_new(); - const char *propname=NULL; - char *rpath=NULL; + DynStr *path = BLI_dynstr_new(); + const char *propname = NULL; + char *rpath = NULL; char buf[512]; - int dummy_index= 0; + int dummy_index = 0; /* hack: if constname is set, we can only be dealing with an Constraint curve */ if (constname) - blocktype= ID_CO; + blocktype = ID_CO; /* get property name based on blocktype */ switch (blocktype) { case ID_OB: /* object */ - propname= ob_adrcodes_to_paths(adrcode, &dummy_index); + propname = ob_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_PO: /* pose channel */ - propname= pchan_adrcodes_to_paths(adrcode, &dummy_index); + propname = pchan_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_KE: /* shapekeys */ - propname= shapekey_adrcodes_to_paths(adrcode, &dummy_index); + propname = shapekey_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_CO: /* constraint */ - propname= constraint_adrcodes_to_paths(adrcode, &dummy_index); + propname = constraint_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_TE: /* texture */ - propname= texture_adrcodes_to_paths(adrcode, &dummy_index); + propname = texture_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_MA: /* material */ - propname= material_adrcodes_to_paths(adrcode, &dummy_index); + propname = material_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_CA: /* camera */ - propname= camera_adrcodes_to_paths(adrcode, &dummy_index); + propname = camera_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_LA: /* lamp */ - propname= lamp_adrcodes_to_paths(adrcode, &dummy_index); + propname = lamp_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_SO: /* sound */ - propname= sound_adrcodes_to_paths(adrcode, &dummy_index); + propname = sound_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_WO: /* world */ - propname= world_adrcodes_to_paths(adrcode, &dummy_index); + propname = world_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_PA: /* particle */ - propname= particle_adrcodes_to_paths(adrcode, &dummy_index); + propname = particle_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_CU: /* curve */ /* this used to be a 'dummy' curve which got evaluated on the fly... * now we've got real var for this! */ - propname= "eval_time"; + propname = "eval_time"; break; /* XXX problematic blocktypes */ case ID_SEQ: /* sequencer strip */ //SEQ_FAC1: switch (adrcode) { - case SEQ_FAC1: - propname= "effect_fader"; - break; - case SEQ_FAC_SPEED: - propname= "speed_fader"; - break; - case SEQ_FAC_OPACITY: - propname= "blend_opacity"; - break; + case SEQ_FAC1: + propname = "effect_fader"; + break; + case SEQ_FAC_SPEED: + propname = "speed_fader"; + break; + case SEQ_FAC_OPACITY: + propname = "blend_opacity"; + break; } // poin= &(seq->facf0); // XXX this doesn't seem to be included anywhere in sequencer RNA... break; @@ -906,7 +906,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co if ((propname == NULL) && (blocktype > 0)) { /* nothing was found, so exit */ if (array_index) - *array_index= 0; + *array_index = 0; BLI_dynstr_free(path); @@ -914,7 +914,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else { if (array_index) - *array_index= dummy_index; + *array_index = dummy_index; } /* 'buf' _must_ be initialized in this block */ @@ -925,11 +925,11 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); } else if (actname && actname[0]) { - if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) { + if ((blocktype == ID_OB) && strcmp(actname, "Object") == 0) { /* Actionified "Object" IPO's... no extra path stuff needed */ - buf[0]= '\0'; /* empty string */ + buf[0] = '\0'; /* empty string */ } - else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) { + else if ((blocktype == ID_KE) && strcmp(actname, "Shape") == 0) { /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */ strcpy(buf, "data.shape_keys"); } @@ -944,10 +944,10 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else if (seq) { /* Sequence names in Scene */ - BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name+2); + BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name + 2); } else { - buf[0]= '\0'; /* empty string */ + buf[0] = '\0'; /* empty string */ } BLI_dynstr_append(path, buf); @@ -966,7 +966,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } /* convert to normal MEM_malloc'd string */ - rpath= BLI_dynstr_get_cstring(path); + rpath = BLI_dynstr_get_cstring(path); BLI_dynstr_free(path); /* return path... */ @@ -977,7 +977,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* Conversion Utilities */ /* Convert adrcodes to driver target transform channel types */ -static short adrcode_to_dtar_transchan (short adrcode) +static short adrcode_to_dtar_transchan(short adrcode) { switch (adrcode) { case OB_LOC_X: @@ -1007,12 +1007,12 @@ static short adrcode_to_dtar_transchan (short adrcode) } /* Convert IpoDriver to ChannelDriver - will free the old data (i.e. the old driver) */ -static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) +static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver) { ChannelDriver *cdriver; /* allocate memory for new driver */ - cdriver= MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); + cdriver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); /* if 'pydriver', just copy data across */ if (idriver->type == IPO_DRIVER_TYPE_PYTHON) { @@ -1027,54 +1027,54 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) DriverTarget *dtar = NULL; /* this should be ok for all types here... */ - cdriver->type= DRIVER_TYPE_AVERAGE; + cdriver->type = DRIVER_TYPE_AVERAGE; /* what to store depends on the 'blocktype' - object or posechannel */ if (idriver->blocktype == ID_AR) { /* PoseChannel */ if (idriver->adrcode == OB_ROT_DIFF) { /* Rotational Difference requires a special type of variable */ - dvar= driver_add_new_variable(cdriver); + dvar = driver_add_new_variable(cdriver); driver_change_variable_type(dvar, DVAR_TYPE_ROT_DIFF); - /* first bone target */ - dtar= &dvar->targets[0]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; + /* first bone target */ + dtar = &dvar->targets[0]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); - /* second bone target (name was stored in same var as the first one) */ - dtar= &dvar->targets[1]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; + /* second bone target (name was stored in same var as the first one) */ + dtar = &dvar->targets[1]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; if (idriver->name[0]) // xxx... for safety - BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); + BLI_strncpy(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); } else { /* only a single variable, of type 'transform channel' */ - dvar= driver_add_new_variable(cdriver); + dvar = driver_add_new_variable(cdriver); driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); /* only requires a single target */ - dtar= &dvar->targets[0]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; + dtar = &dvar->targets[0]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); - dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); + dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode); dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */ } } else { /* Object */ - /* only a single variable, of type 'transform channel' */ - dvar= driver_add_new_variable(cdriver); + /* only a single variable, of type 'transform channel' */ + dvar = driver_add_new_variable(cdriver); driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); - /* only requires single target */ - dtar= &dvar->targets[0]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; - dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); + /* only requires single target */ + dtar = &dvar->targets[0]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; + dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode); } } @@ -1085,7 +1085,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) /* Add F-Curve to the correct list * - grpname is needed to be used as group name where relevant, and is usually derived from actname */ -static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo) +static void fcurve_add_to_list(ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo) { /* If we're adding to an action, we will have groups to write to... */ if (groups && grpname) { @@ -1093,22 +1093,22 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * and extract the resultant lists... */ bAction tmp_act; - bActionGroup *agrp= NULL; + bActionGroup *agrp = NULL; /* init the temp action */ memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors - tmp_act.groups.first= groups->first; - tmp_act.groups.last= groups->last; - tmp_act.curves.first= list->first; - tmp_act.curves.last= list->last; + tmp_act.groups.first = groups->first; + tmp_act.groups.last = groups->last; + tmp_act.curves.first = list->first; + tmp_act.curves.last = list->last; /* ... xxx, the other vars don't need to be filled in */ /* get the group to use */ - agrp= BKE_action_group_find_name(&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 */ - agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup"); agrp->flag = AGRP_SELECTED; if (muteipo) agrp->flag |= AGRP_MUTED; @@ -1127,10 +1127,10 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c fcu->flag |= FCURVE_MUTED; /* set the output lists based on the ones in the temp action */ - groups->first= tmp_act.groups.first; - groups->last= tmp_act.groups.last; - list->first= tmp_act.curves.first; - list->last= tmp_act.curves.last; + groups->first = tmp_act.groups.first; + groups->last = tmp_act.groups.last; + list->first = tmp_act.curves.first; + list->last = tmp_act.curves.last; } else { /* simply add the F-Curve to the end of the given list */ @@ -1144,18 +1144,18 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to * seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence * seq, int muteipo) +static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence *seq, int muteipo) { AdrBit2Path *abp; FCurve *fcu; int totbits; /* allocate memory for a new F-Curve */ - fcu= MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = MEM_callocN(sizeof(FCurve), "FCurve"); /* convert driver */ if (icu->driver) - fcu->driver= idriver_to_cdriver(icu->driver); + fcu->driver = idriver_to_cdriver(icu->driver); /* copy flags */ if (icu->flag & IPO_VISIBLE) fcu->flag |= FCURVE_VISIBLE; @@ -1170,9 +1170,9 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * case IPO_DIR: /* linear extrapolation */ { /* just copy, as the new defines match the old ones... */ - fcu->extend= icu->extrap; + fcu->extend = icu->extrap; } - break; + break; case IPO_CYCL: /* cyclic extrapolation */ case IPO_CYCLX: /* cyclic extrapolation + offset */ @@ -1180,22 +1180,22 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* Add a new FModifier (Cyclic) instead of setting extend value * as that's the new equivalent of that option. */ - FModifier *fcm= add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); - FMod_Cycles *data= (FMod_Cycles *)fcm->data; + FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); + FMod_Cycles *data = (FMod_Cycles *)fcm->data; /* if 'offset' one is in use, set appropriate settings */ if (icu->extrap == IPO_CYCLX) - data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC_OFFSET; + data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC_OFFSET; else - data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC; + data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC; } - break; + break; } /* -------- */ /* get adrcode <-> bitflags mapping to handle nasty bitflag curves? */ - abp= adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits); + abp = adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits); if (abp && totbits) { FCurve *fcurve; int b; @@ -1203,49 +1203,49 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * if (G.debug & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d\n", totbits); /* add the 'only int values' flag */ - fcu->flag |= (FCURVE_INT_VALUES|FCURVE_DISCRETE_VALUES); + fcu->flag |= (FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES); /* for each bit we have to remap + check for: * 1) we need to make copy the existing F-Curve data (fcu -> fcurve), - * except for the last one which will use the original + * except for the last one which will use the original * 2) copy the relevant path info across * 3) filter the keyframes for the flag of interest */ - for (b=0; b < totbits; b++, abp++) { - unsigned int i=0; + for (b = 0; b < totbits; b++, abp++) { + unsigned int i = 0; /* make a copy of existing base-data if not the last curve */ - if (b < (totbits-1)) - fcurve= copy_fcurve(fcu); + if (b < (totbits - 1)) + fcurve = copy_fcurve(fcu); else - fcurve= fcu; + fcurve = fcu; /* set path */ - fcurve->rna_path= BLI_strdup(abp->path); - fcurve->array_index= abp->array_index; + fcurve->rna_path = BLI_strdup(abp->path); + fcurve->array_index = abp->array_index; /* convert keyframes * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet) */ - fcurve->totvert= icu->totvert; + fcurve->totvert = icu->totvert; if (icu->bezt) { BezTriple *dst, *src; /* allocate new array for keyframes/beztriples */ - fcurve->bezt= MEM_callocN(sizeof(BezTriple)*fcurve->totvert, "BezTriples"); + fcurve->bezt = MEM_callocN(sizeof(BezTriple) * fcurve->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcurve->bezt, src=icu->bezt, i=0; i < fcurve->totvert; i++, dst++, src++) { + for (dst = fcurve->bezt, src = icu->bezt, i = 0; i < fcurve->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ - *dst= *src; + *dst = *src; /* interpolation can only be constant... */ - dst->ipo= BEZT_IPO_CONST; + dst->ipo = BEZT_IPO_CONST; /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ - dst->hide= BEZT_KEYTYPE_KEYFRAME; + dst->hide = BEZT_KEYTYPE_KEYFRAME; /* auto-handles - per curve to per handle */ if (icu->flag & IPO_AUTO_HORIZ) { @@ -1255,9 +1255,9 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct values, by checking if the flag of interest is set */ if ( ((int)(dst->vec[1][1])) & (abp->bit) ) - dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 1.0f; + dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 1.0f; else - dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 0.0f; + dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 0.0f; } } else if (icu->bp) { @@ -1271,12 +1271,12 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * } } else { - unsigned int i=0; + unsigned int i = 0; /* get rna-path * - we will need to set the 'disabled' flag if no path is able to be made (for now) */ - fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index); + fcu->rna_path = get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index); if (fcu->rna_path == NULL) fcu->flag |= FCURVE_DISABLED; @@ -1284,25 +1284,25 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet) */ - fcu->totvert= icu->totvert; + fcu->totvert = icu->totvert; if (icu->bezt) { BezTriple *dst, *src; /* allocate new array for keyframes/beztriples */ - fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples"); + fcu->bezt = MEM_callocN(sizeof(BezTriple) * fcu->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcu->bezt, src=icu->bezt, i=0; i < fcu->totvert; i++, dst++, src++) { + for (dst = fcu->bezt, src = icu->bezt, i = 0; i < fcu->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ - *dst= *src; + *dst = *src; /* now copy interpolation from curve (if not already set) */ if (icu->ipo != IPO_MIXED) - dst->ipo= icu->ipo; + dst->ipo = icu->ipo; /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ - dst->hide= BEZT_KEYTYPE_KEYFRAME; + dst->hide = BEZT_KEYTYPE_KEYFRAME; /* auto-handles - per curve to per handle */ if (icu->flag & IPO_AUTO_HORIZ) { @@ -1315,9 +1315,9 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * - we need radians for RNA to do the right thing */ if ( ((icu->blocktype == ID_OB) && ELEM3(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) || - ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) ) + ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) ) { - const float fac= (float)M_PI / 18.0f; //10.0f * M_PI/180.0f; + const float fac = (float)M_PI / 18.0f; //10.0f * M_PI/180.0f; dst->vec[0][1] *= fac; dst->vec[1][1] *= fac; @@ -1329,7 +1329,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * - we now need as 'frames' */ if ( (id) && (icu->blocktype == GS(id->name)) && - (fcu->rna_path && strcmp(fcu->rna_path, "eval_time")==0) ) + (fcu->rna_path && strcmp(fcu->rna_path, "eval_time") == 0) ) { Curve *cu = (Curve *)id; @@ -1340,15 +1340,15 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct times for rotation drivers * - need to go from degrees to radians... - * - there's only really 1 target to worry about + * - there's only really 1 target to worry about * - were also degrees/10 */ if (fcu->driver && fcu->driver->variables.first) { - DriverVar *dvar= fcu->driver->variables.first; - DriverTarget *dtar= &dvar->targets[0]; + DriverVar *dvar = fcu->driver->variables.first; + DriverTarget *dtar = &dvar->targets[0]; if (ELEM3(dtar->transChan, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ)) { - const float fac= (float)M_PI / 18.0f; + const float fac = (float)M_PI / 18.0f; dst->vec[0][0] *= fac; dst->vec[1][0] *= fac; @@ -1358,8 +1358,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct values for sequencer curves, that were not locked to frame */ if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { - double mul= (seq->enddisp-seq->startdisp)/100.0f; - double offset= seq->startdisp; + double mul = (seq->enddisp - seq->startdisp) / 100.0f; + double offset = seq->startdisp; dst->vec[0][0] *= mul; dst->vec[0][0] += offset; @@ -1389,7 +1389,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1407,13 +1407,13 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], */ if (actname) { if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Object") == 0)) - actname= NULL; + actname = NULL; else if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Shape") == 0)) - actname= NULL; + actname = NULL; } /* loop over IPO-Curves, freeing as we progress */ - for (icu= ipo->curve.first; icu; icu= icu->next) { + for (icu = ipo->curve.first; icu; icu = icu->next) { /* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves), * we figure out the best place to put the channel, then tell the curve-converter to just dump there */ @@ -1424,7 +1424,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], } else { MEM_freeN(icu->driver); - icu->driver= NULL; + icu->driver = NULL; } } else @@ -1436,8 +1436,8 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], if (ID_REAL_USERS(ipo) <= 0) { IpoCurve *icn; - for (icu= ipo->curve.first; icu; icu= icn) { - icn= icu->next; + for (icu = ipo->curve.first; icu; icu = icn) { + icn = icu->next; /* free driver */ if (icu->driver) @@ -1458,7 +1458,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], * to Objects, where ob->ipo and ob->action need to be combined). * NOTE: we need to be careful here, as same data-structs are used for new system too! */ -static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) +static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) { bActionChannel *achan, *achann; bConstraintChannel *conchan, *conchann; @@ -1473,27 +1473,27 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase BLI_freelistN(&act->groups); /* loop through Action-Channels, converting data, freeing as we go */ - for (achan= act->chanbase.first; achan; achan= achann) { + for (achan = act->chanbase.first; achan; achan = achann) { /* get pointer to next Action Channel */ - achann= achan->next; + achann = achan->next; /* convert Action Channel's IPO data */ if (achan->ipo) { ipo_to_animato(id, achan->ipo, achan->name, NULL, NULL, groups, curves, drivers); achan->ipo->id.us--; - achan->ipo= NULL; + achan->ipo = NULL; } /* convert constraint channel IPO-data */ - for (conchan= achan->constraintChannels.first; conchan; conchan= conchann) { + for (conchan = achan->constraintChannels.first; conchan; conchan = conchann) { /* get pointer to next Constraint Channel */ - conchann= conchan->next; + conchann = conchan->next; /* convert Constraint Channel's IPO data */ if (conchan->ipo) { ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, NULL, groups, curves, drivers); conchan->ipo->id.us--; - conchan->ipo= NULL; + conchan->ipo = NULL; } /* free Constraint Channel */ @@ -1512,9 +1512,9 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) +static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; ListBase drivers = {NULL, NULL}; @@ -1528,8 +1528,8 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (G.debug & G_DEBUG) { printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s curves:%d\n", - id->name+2, ipo->id.name+2, (actname)?actname:"", (constname)?constname:"", (seq)?(seq->name+2):"", - BLI_countlist(&ipo->curve)); + id->name + 2, ipo->id.name + 2, (actname) ? actname : "", (constname) ? constname : "", (seq) ? (seq->name + 2) : "", + BLI_countlist(&ipo->curve)); } /* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers), @@ -1545,9 +1545,9 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (adt->action == NULL) { char nameBuf[MAX_ID_NAME]; - BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name+2); + BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2); - adt->action= add_empty_action(nameBuf); + adt->action = add_empty_action(nameBuf); if (G.debug & G_DEBUG) printf("\t\tadded new action - '%s'\n", nameBuf); } @@ -1566,9 +1566,9 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], /* Convert Action-block to new system * NOTE: we need to be careful here, as same data-structs are used for new system too! */ -static void action_to_animdata (ID *id, bAction *act) +static void action_to_animdata(ID *id, bAction *act) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* only continue if there are Action Channels (indicating unconverted data) */ if (ELEM(NULL, adt, act->chanbase.first)) @@ -1578,7 +1578,7 @@ static void action_to_animdata (ID *id, bAction *act) if (adt->action == NULL) { /* set this Action as AnimData's Action */ if (G.debug & G_DEBUG) printf("act_to_adt - set adt action to act\n"); - adt->action= act; + adt->action = act; } /* convert Action data */ @@ -1592,16 +1592,16 @@ static void action_to_animdata (ID *id, bAction *act) // - NLA curve/stride modifiers... /* Convert NLA-Strip to new system */ -static void nlastrips_to_animdata (ID *id, ListBase *strips) +static void nlastrips_to_animdata(ID *id, ListBase *strips) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); NlaTrack *nlt = NULL; NlaStrip *strip; bActionStrip *as, *asn; /* for each one of the original strips, convert to a new strip and free the old... */ - for (as= strips->first; as; as= asn) { - asn= as->next; + for (as = strips->first; as; as = asn) { + asn = as->next; /* this old strip is only worth something if it had an action... */ if (as->act) { @@ -1614,36 +1614,36 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) * - no need to muck around with the user-counts, since this is just * passing over the ref to the new owner, not creating an additional ref */ - strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); - strip->act= as->act; + strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); + strip->act = as->act; - /* endpoints */ - strip->start= as->start; - strip->end= as->end; - strip->actstart= as->actstart; - strip->actend= as->actend; - - /* action reuse */ - strip->repeat= as->repeat; - strip->scale= as->scale; - if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH; - - /* blending */ - strip->blendin= as->blendin; - strip->blendout= as->blendout; - strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE; - if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS; - - /* assorted setting flags */ - if (as->flag & ACTSTRIP_SELECT) strip->flag |= NLASTRIP_FLAG_SELECT; - if (as->flag & ACTSTRIP_ACTIVE) strip->flag |= NLASTRIP_FLAG_ACTIVE; - - if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED; - if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE; - - /* by default, we now always extrapolate, while in the past this was optional */ - if ((as->flag & ACTSTRIP_HOLDLASTFRAME)==0) - strip->extendmode= NLASTRIP_EXTEND_NOTHING; + /* endpoints */ + strip->start = as->start; + strip->end = as->end; + strip->actstart = as->actstart; + strip->actend = as->actend; + + /* action reuse */ + strip->repeat = as->repeat; + strip->scale = as->scale; + if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH; + + /* blending */ + strip->blendin = as->blendin; + strip->blendout = as->blendout; + strip->blendmode = (as->mode == ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE; + if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS; + + /* assorted setting flags */ + if (as->flag & ACTSTRIP_SELECT) strip->flag |= NLASTRIP_FLAG_SELECT; + if (as->flag & ACTSTRIP_ACTIVE) strip->flag |= NLASTRIP_FLAG_ACTIVE; + + if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED; + if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE; + + /* by default, we now always extrapolate, while in the past this was optional */ + if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0) + strip->extendmode = NLASTRIP_EXTEND_NOTHING; } /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */ @@ -1651,7 +1651,7 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt= add_nlatrack(adt, NULL); + nlt = add_nlatrack(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } } @@ -1701,13 +1701,13 @@ void do_versions_ipos_to_animato(Main *main) /* ----------- Animation Attached to Data -------------- */ /* objects */ - for (id= main->object.first; id; id= id->next) { - Object *ob= (Object *)id; + for (id = main->object.first; id; id = id->next) { + Object *ob = (Object *)id; bPoseChannel *pchan; bConstraint *con; bConstraintChannel *conchan, *conchann; - if (G.debug & G_DEBUG) printf("\tconverting ob %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting ob %s\n", id->name + 2); /* check if object has any animation data */ if (ob->nlastrips.first) { @@ -1719,7 +1719,7 @@ void do_versions_ipos_to_animato(Main *main) ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; - ob->ipo= NULL; + ob->ipo = NULL; } /* Action is skipped since it'll be used by some strip in the NLA anyway, @@ -1727,7 +1727,7 @@ void do_versions_ipos_to_animato(Main *main) */ if (ob->action) { ob->action->id.us--; - ob->action= NULL; + ob->action = NULL; } /* finally NLA */ @@ -1735,7 +1735,7 @@ void do_versions_ipos_to_animato(Main *main) } else if ((ob->ipo) || (ob->action)) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Action first - so that Action name get conserved */ if (ob->action) { @@ -1744,7 +1744,7 @@ void do_versions_ipos_to_animato(Main *main) /* only decrease usercount if this Action isn't now being used by AnimData */ if (ob->action != adt->action) { ob->action->id.us--; - ob->action= NULL; + ob->action = NULL; } } @@ -1752,7 +1752,7 @@ void do_versions_ipos_to_animato(Main *main) if (ob->ipo) { ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; - ob->ipo= NULL; + ob->ipo = NULL; } } @@ -1761,8 +1761,8 @@ void do_versions_ipos_to_animato(Main *main) /* Verify if there's AnimData block */ BKE_id_add_animdata(id); - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { /* if constraint has own IPO, convert add these to Object * (NOTE: they're most likely to be drivers too) */ @@ -1772,14 +1772,14 @@ void do_versions_ipos_to_animato(Main *main) */ ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL); con->ipo->id.us--; - con->ipo= NULL; + con->ipo = NULL; } } } } /* check constraints for local IPO's */ - for (con= ob->constraints.first; con; con= con->next) { + for (con = ob->constraints.first; con; con = con->next) { /* if constraint has own IPO, convert add these to Object * (NOTE: they're most likely to be drivers too) */ @@ -1792,7 +1792,7 @@ void do_versions_ipos_to_animato(Main *main) */ ipo_to_animdata(id, con->ipo, NULL, con->name, NULL); con->ipo->id.us--; - con->ipo= NULL; + con->ipo = NULL; } /* check for Action Constraint */ @@ -1804,15 +1804,15 @@ void do_versions_ipos_to_animato(Main *main) /* Verify if there's AnimData block */ BKE_id_add_animdata(id); - for (conchan= ob->constraintChannels.first; conchan; conchan= conchann) { + for (conchan = ob->constraintChannels.first; conchan; conchan = conchann) { /* get pointer to next Constraint Channel */ - conchann= conchan->next; + conchann = conchan->next; /* convert Constraint Channel's IPO data */ if (conchan->ipo) { ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL); conchan->ipo->id.us--; - conchan->ipo= NULL; + conchan->ipo = NULL; } /* free Constraint Channel */ @@ -1822,17 +1822,17 @@ void do_versions_ipos_to_animato(Main *main) /* object's action will always be object-rooted */ { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); if (adt && adt->action) adt->action->idroot = ID_OB; } } /* shapekeys */ - for (id= main->key.first; id; id= id->next) { - Key *key= (Key *)id; + for (id = main->key.first; id; id = id->next) { + Key *key = (Key *)id; - if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name + 2); /* we're only interested in the IPO * NOTE: for later, it might be good to port these over to Object instead, as many of these @@ -1840,7 +1840,7 @@ void do_versions_ipos_to_animato(Main *main) */ if (key->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Shapekey data... */ ipo_to_animdata(id, key->ipo, NULL, NULL, NULL); @@ -1849,20 +1849,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = key->ipo->blocktype; key->ipo->id.us--; - key->ipo= NULL; + key->ipo = NULL; } } /* materials */ - for (id= main->mat.first; id; id= id->next) { - Material *ma= (Material *)id; + for (id = main->mat.first; id; id = id->next) { + Material *ma = (Material *)id; - if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name + 2); /* we're only interested in the IPO */ if (ma->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Material data... */ ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL); @@ -1871,20 +1871,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = ma->ipo->blocktype; ma->ipo->id.us--; - ma->ipo= NULL; + ma->ipo = NULL; } } /* worlds */ - for (id= main->world.first; id; id= id->next) { - World *wo= (World *)id; + for (id = main->world.first; id; id = id->next) { + World *wo = (World *)id; - if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name + 2); /* we're only interested in the IPO */ if (wo->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert World data... */ ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL); @@ -1893,26 +1893,26 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = wo->ipo->blocktype; wo->ipo->id.us--; - wo->ipo= NULL; + wo->ipo = NULL; } } /* sequence strips */ - for (id= main->scene.first; id; id= id->next) { + for (id = main->scene.first; id; id = id->next) { Scene *scene = (Scene *)id; - Editing * ed = scene->ed; + Editing *ed = scene->ed; if (ed && ed->seqbasep) { - Sequence * seq; + Sequence *seq; - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); - SEQ_BEGIN (ed, seq) + SEQ_BEGIN(ed, seq) { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; if (G.debug & G_DEBUG) - printf("\tconverting sequence strip %s\n", seq->name+2); + printf("\tconverting sequence strip %s\n", seq->name + 2); if (ELEM(NULL, seq->ipo, icu)) { seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; @@ -1941,7 +1941,7 @@ void do_versions_ipos_to_animato(Main *main) ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq); if (adt->action) - adt->action->idroot = ID_SCE; /* scene-rooted */ + adt->action->idroot = ID_SCE; /* scene-rooted */ seq->ipo->id.us--; seq->ipo = NULL; @@ -1952,15 +1952,15 @@ void do_versions_ipos_to_animato(Main *main) /* textures */ - for (id= main->tex.first; id; id= id->next) { - Tex *te= (Tex *)id; + for (id = main->tex.first; id; id = id->next) { + Tex *te = (Tex *)id; - if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name + 2); /* we're only interested in the IPO */ if (te->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Texture data... */ ipo_to_animdata(id, te->ipo, NULL, NULL, NULL); @@ -1969,20 +1969,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = te->ipo->blocktype; te->ipo->id.us--; - te->ipo= NULL; + te->ipo = NULL; } } /* cameras */ - for (id= main->camera.first; id; id= id->next) { - Camera *ca= (Camera *)id; + for (id = main->camera.first; id; id = id->next) { + Camera *ca = (Camera *)id; - if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name + 2); /* we're only interested in the IPO */ if (ca->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Camera data... */ ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL); @@ -1991,20 +1991,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = ca->ipo->blocktype; ca->ipo->id.us--; - ca->ipo= NULL; + ca->ipo = NULL; } } /* lamps */ - for (id= main->lamp.first; id; id= id->next) { - Lamp *la= (Lamp *)id; + for (id = main->lamp.first; id; id = id->next) { + Lamp *la = (Lamp *)id; - if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2); /* we're only interested in the IPO */ if (la->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Lamp data... */ ipo_to_animdata(id, la->ipo, NULL, NULL, NULL); @@ -2013,20 +2013,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = la->ipo->blocktype; la->ipo->id.us--; - la->ipo= NULL; + la->ipo = NULL; } } /* curves */ - for (id= main->curve.first; id; id= id->next) { - Curve *cu= (Curve *)id; + for (id = main->curve.first; id; id = id->next) { + Curve *cu = (Curve *)id; - if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name + 2); /* we're only interested in the IPO */ if (cu->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Curve data... */ ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL); @@ -2035,7 +2035,7 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = cu->ipo->blocktype; cu->ipo->id.us--; - cu->ipo= NULL; + cu->ipo = NULL; } } @@ -2051,10 +2051,10 @@ void do_versions_ipos_to_animato(Main *main) */ /* actions */ - for (id= main->action.first; id; id= id->next) { - bAction *act= (bAction *)id; + for (id = main->action.first; id; id = id->next) { + bAction *act = (bAction *)id; - if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name + 2); /* if old action, it will be object-only... */ if (act->chanbase.first) @@ -2065,23 +2065,23 @@ void do_versions_ipos_to_animato(Main *main) } /* ipo's */ - for (id= main->ipo.first; id; id= id->next) { - Ipo *ipo= (Ipo *)id; + for (id = main->ipo.first; id; id = id->next) { + Ipo *ipo = (Ipo *)id; - if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name + 2); /* most likely this IPO has already been processed, so check if any curves left to convert */ if (ipo->curve.first) { bAction *new_act; /* add a new action for this, and convert all data into that action */ - new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name... + new_act = add_empty_action("ConvIPO_Action"); // XXX need a better name... ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers); new_act->idroot = ipo->blocktype; } /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */ - ipo->id.us= 0; + ipo->id.us = 0; ipo->id.flag &= ~LIB_FAKEUSER; } diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index e7206af3a0f..20e3edc7044 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -55,30 +55,30 @@ void *BKE_lamp_add(const char *name) { Lamp *la; - la= BKE_libblock_alloc(&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; - la->dist= 25.0f; - la->spotsize= 45.0f; - la->spotblend= 0.15f; - la->att2= 1.0f; - la->mode= LA_SHAD_BUF; - la->bufsize= 512; - la->clipsta= 0.5f; - la->clipend= 40.0f; - la->shadspotsize= 45.0f; - la->samp= 3; - la->bias= 1.0f; - la->soft= 3.0f; - la->compressthresh= 0.05f; - la->ray_samp= la->ray_sampy= la->ray_sampz= 1; - la->area_size=la->area_sizey=la->area_sizez= 1.0f; - la->buffers= 1; - la->buftype= LA_SHADBUF_HALFWAY; + la->r = la->g = la->b = la->k = 1.0f; + la->haint = la->energy = 1.0f; + la->dist = 25.0f; + la->spotsize = 45.0f; + la->spotblend = 0.15f; + la->att2 = 1.0f; + la->mode = LA_SHAD_BUF; + la->bufsize = 512; + la->clipsta = 0.5f; + la->clipend = 40.0f; + la->shadspotsize = 45.0f; + la->samp = 3; + la->bias = 1.0f; + la->soft = 3.0f; + la->compressthresh = 0.05f; + la->ray_samp = la->ray_sampy = la->ray_sampz = 1; + la->area_size = la->area_sizey = la->area_sizez = 1.0f; + la->buffers = 1; + la->buftype = LA_SHADBUF_HALFWAY; la->ray_samp_method = LA_SAMP_HALTON; la->adapt_thresh = 0.001f; - la->preview=NULL; + la->preview = NULL; la->falloff_type = LA_FALLOFF_INVSQUARE; la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); la->sun_effect_type = 0; @@ -92,11 +92,11 @@ void *BKE_lamp_add(const char *name) la->atm_extinction_factor = 1.0f; la->atm_distance_factor = 1.0f; la->sun_intensity = 1.0f; - la->skyblendtype= MA_RAMP_ADD; - la->skyblendfac= 1.0f; - la->sky_colorspace= BLI_XYZ_CIE; - la->sky_exposure= 1.0f; - la->shadow_frustum_size= 10.0f; + la->skyblendtype = MA_RAMP_ADD; + la->skyblendfac = 1.0f; + la->sky_colorspace = BLI_XYZ_CIE; + la->sky_exposure = 1.0f; + la->shadow_frustum_size = 10.0f; curvemapping_initialize(la->curfalloff); return la; @@ -107,11 +107,11 @@ Lamp *BKE_lamp_copy(Lamp *la) Lamp *lan; int a; - lan= BKE_libblock_copy(&la->id); + lan = BKE_libblock_copy(&la->id); - for (a=0; amtex[a]) { - lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex"); + lan->mtex[a] = MEM_mallocN(sizeof(MTex), "copylamptex"); memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex)); id_us_plus((ID *)lan->mtex[a]->tex); } @@ -120,7 +120,7 @@ Lamp *BKE_lamp_copy(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); if (la->nodetree) - lan->nodetree= ntreeCopyTree(la->nodetree); + lan->nodetree = ntreeCopyTree(la->nodetree); if (la->preview) lan->preview = BKE_previewimg_copy(la->preview); @@ -133,12 +133,12 @@ Lamp *localize_lamp(Lamp *la) Lamp *lan; int a; - lan= BKE_libblock_copy(&la->id); + lan = BKE_libblock_copy(&la->id); BLI_remlink(&G.main->lamp, lan); - for (a=0; amtex[a]) { - lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp"); + lan->mtex[a] = MEM_mallocN(sizeof(MTex), "localize_lamp"); memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex)); /* free lamp decrements */ id_us_plus((ID *)lan->mtex[a]->tex); @@ -148,60 +148,60 @@ Lamp *localize_lamp(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); if (la->nodetree) - lan->nodetree= ntreeLocalize(la->nodetree); + lan->nodetree = ntreeLocalize(la->nodetree); - lan->preview= NULL; + lan->preview = NULL; return lan; } void BKE_lamp_make_local(Lamp *la) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (la->id.lib==NULL) return; - if (la->id.us==1) { + if (la->id.lib == NULL) return; + if (la->id.us == 1) { id_clear_lib_data(bmain, &la->id); return; } - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==la) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->data == la) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } - ob= ob->id.next; + ob = ob->id.next; } if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &la->id); } else if (is_local && is_lib) { - Lamp *la_new= BKE_lamp_copy(la); - la_new->id.us= 0; + Lamp *la_new = BKE_lamp_copy(la); + la_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, la->id.lib, &la_new->id); - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==la) { + if (ob->data == la) { - if (ob->id.lib==NULL) { - ob->data= la_new; + if (ob->id.lib == NULL) { + ob->data = la_new; la_new->id.us++; la->id.us--; } } - ob= ob->id.next; + ob = ob->id.next; } } } @@ -211,8 +211,8 @@ void BKE_lamp_free(Lamp *la) MTex *mtex; int a; - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = la->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 12496e78037..4076031fa18 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -69,17 +69,17 @@ void calc_lat_fudu(int flag, int res, float *fu, float *du) { - if (res==1) { - *fu= 0.0; - *du= 0.0; + if (res == 1) { + *fu = 0.0; + *du = 0.0; } else if (flag & LT_GRID) { - *fu= -0.5f*(res-1); - *du= 1.0f; + *fu = -0.5f * (res - 1); + *du = 1.0f; } else { - *fu= -1.0f; - *du= 2.0f/(res-1); + *fu = -1.0f; + *du = 2.0f / (res - 1); } } @@ -87,53 +87,53 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) { BPoint *bp; int i, u, v, w; - float fu, fv, fw, uc, vc, wc, du=0.0, dv=0.0, dw=0.0; + float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0; float *co, (*vertexCos)[3] = NULL; /* vertex weight groups are just freed all for now */ if (lt->dvert) { - free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); - lt->dvert= NULL; + free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + lt->dvert = NULL; } - while (uNew*vNew*wNew > 32000) { - if ( uNew>=vNew && uNew>=wNew) uNew--; - else if ( vNew>=uNew && vNew>=wNew) vNew--; + while (uNew * vNew * wNew > 32000) { + if (uNew >= vNew && uNew >= wNew) uNew--; + else if (vNew >= uNew && vNew >= wNew) vNew--; else wNew--; } - vertexCos = MEM_mallocN(sizeof(*vertexCos)*uNew*vNew*wNew, "tmp_vcos"); + vertexCos = MEM_mallocN(sizeof(*vertexCos) * uNew * vNew * wNew, "tmp_vcos"); calc_lat_fudu(lt->flag, uNew, &fu, &du); calc_lat_fudu(lt->flag, vNew, &fv, &dv); calc_lat_fudu(lt->flag, wNew, &fw, &dw); - /* If old size is different then resolution changed in interface, - * try to do clever reinit of points. Pretty simply idea, we just - * deform new verts by old lattice, but scaling them to match old - * size first. - */ + /* If old size is different then resolution changed in interface, + * try to do clever reinit of points. Pretty simply idea, we just + * deform new verts by old lattice, but scaling them to match old + * size first. + */ if (ltOb) { - if (uNew!=1 && lt->pntsu!=1) { + if (uNew != 1 && lt->pntsu != 1) { fu = lt->fu; - du = (lt->pntsu-1)*lt->du/(uNew-1); + du = (lt->pntsu - 1) * lt->du / (uNew - 1); } - if (vNew!=1 && lt->pntsv!=1) { + if (vNew != 1 && lt->pntsv != 1) { fv = lt->fv; - dv = (lt->pntsv-1)*lt->dv/(vNew-1); + dv = (lt->pntsv - 1) * lt->dv / (vNew - 1); } - if (wNew!=1 && lt->pntsw!=1) { + if (wNew != 1 && lt->pntsw != 1) { fw = lt->fw; - dw = (lt->pntsw-1)*lt->dw/(wNew-1); + dw = (lt->pntsw - 1) * lt->dw / (wNew - 1); } } co = vertexCos[0]; - for (w=0, wc=fw; wtypeu, typev = lt->typev, typew = lt->typew; - /* works best if we force to linear type (endpoints match) */ + /* works best if we force to linear type (endpoints match) */ lt->typeu = lt->typev = lt->typew = KEY_LINEAR; - /* prevent using deformed locations */ + /* prevent using deformed locations */ freedisplist(<Ob->disp); copy_m4_m4(mat, ltOb->obmat); unit_m4(ltOb->obmat); - lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL, 1.0f); + lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew * vNew * wNew, NULL, 1.0f); copy_m4_m4(ltOb->obmat, mat); lt->typeu = typeu; @@ -173,11 +173,11 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) lt->pntsw = wNew; MEM_freeN(lt->def); - lt->def= MEM_callocN(lt->pntsu*lt->pntsv*lt->pntsw*sizeof(BPoint), "lattice bp"); + lt->def = MEM_callocN(lt->pntsu * lt->pntsv * lt->pntsw * sizeof(BPoint), "lattice bp"); - bp= lt->def; + bp = lt->def; - for (i=0; ipntsu*lt->pntsv*lt->pntsw; i++, bp++) { + for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) { copy_v3_v3(bp->vec, vertexCos[i]); } @@ -188,14 +188,14 @@ Lattice *BKE_lattice_add(const char *name) { Lattice *lt; - lt= BKE_libblock_alloc(&G.main->latt, ID_LT, name); + lt = BKE_libblock_alloc(&G.main->latt, ID_LT, name); - lt->flag= LT_GRID; + lt->flag = LT_GRID; - lt->typeu= lt->typev= lt->typew= KEY_BSPLINE; + lt->typeu = lt->typev = lt->typew = KEY_BSPLINE; - lt->def= MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ - BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ + lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ + BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ return lt; } @@ -204,19 +204,19 @@ Lattice *BKE_lattice_copy(Lattice *lt) { Lattice *ltn; - ltn= BKE_libblock_copy(<->id); - ltn->def= MEM_dupallocN(lt->def); + ltn = BKE_libblock_copy(<->id); + ltn->def = MEM_dupallocN(lt->def); - ltn->key= BKE_key_copy(ltn->key); - if (ltn->key) ltn->key->from= (ID *)ltn; + ltn->key = BKE_key_copy(ltn->key); + if (ltn->key) ltn->key->from = (ID *)ltn; if (lt->dvert) { - int tot= lt->pntsu*lt->pntsv*lt->pntsw; - ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + int tot = lt->pntsu * lt->pntsv * lt->pntsw; + ltn->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(ltn->dvert, lt->dvert, tot); } - ltn->editlatt= NULL; + ltn->editlatt = NULL; return ltn; } @@ -224,12 +224,12 @@ Lattice *BKE_lattice_copy(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); + if (lt->dvert) free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); if (lt->editlatt) { - Lattice *editlt= lt->editlatt->latt; + Lattice *editlt = lt->editlatt->latt; if (editlt->def) MEM_freeN(editlt->def); - if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); + if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); MEM_freeN(editlt); MEM_freeN(lt->editlatt); @@ -238,49 +238,49 @@ void BKE_lattice_free(Lattice *lt) /* free animation data */ if (lt->adt) { BKE_free_animdata(<->id); - lt->adt= NULL; + lt->adt = NULL; } } void BKE_lattice_make_local(Lattice *lt) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (lt->id.lib==NULL) return; - if (lt->id.us==1) { + if (lt->id.lib == NULL) return; + if (lt->id.us == 1) { id_clear_lib_data(bmain, <->id); return; } - for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) { - if (ob->data==lt) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (ob = bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob = ob->id.next) { + if (ob->data == lt) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - if (is_local && is_lib==FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, <->id); } else if (is_local && is_lib) { - Lattice *lt_new= BKE_lattice_copy(lt); - lt_new->id.us= 0; + Lattice *lt_new = BKE_lattice_copy(lt); + lt_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, lt->id.lib, <_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { - if (ob->data==lt) { - if (ob->id.lib==NULL) { - ob->data= lt_new; + for (ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->data == lt) { + if (ob->id.lib == NULL) { + ob->data = lt_new; lt_new->id.us++; lt->id.us--; } @@ -291,22 +291,22 @@ void BKE_lattice_make_local(Lattice *lt) void init_latt_deform(Object *oblatt, Object *ob) { - /* we make an array with all differences */ - Lattice *lt= oblatt->data; + /* we make an array with all differences */ + Lattice *lt = oblatt->data; BPoint *bp; DispList *dl = find_displist(&oblatt->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; + float *co = dl ? dl->verts : NULL; float *fp, imat[4][4]; float fu, fv, fw; int u, v, w; - if (lt->editlatt) lt= lt->editlatt->latt; + if (lt->editlatt) lt = lt->editlatt->latt; bp = lt->def; - fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata"); + fp = lt->latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata"); - /* for example with a particle system: ob==0 */ - if (ob==NULL) { + /* for example with a particle system: ob==0 */ + if (ob == NULL) { /* in deformspace, calc matrix */ invert_m4_m4(lt->latmat, oblatt->obmat); @@ -322,9 +322,9 @@ void init_latt_deform(Object *oblatt, Object *ob) invert_m4_m4(imat, lt->latmat); } - for (w=0, fw=lt->fw; wpntsw; w++, fw+=lt->dw) { - for (v=0, fv=lt->fv; vpntsv; v++, fv+=lt->dv) { - for (u=0, fu=lt->fu; upntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) { + for (w = 0, fw = lt->fw; w < lt->pntsw; w++, fw += lt->dw) { + for (v = 0, fv = lt->fv; v < lt->pntsv; v++, fv += lt->dv) { + for (u = 0, fu = lt->fu; u < lt->pntsu; u++, bp++, co += 3, fp += 3, fu += lt->du) { if (dl) { fp[0] = co[0] - fu; fp[1] = co[1] - fv; @@ -344,23 +344,23 @@ void init_latt_deform(Object *oblatt, Object *ob) void calc_latt_deform(Object *ob, float co[3], float weight) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; float u, v, w, tu[4], tv[4], tw[4]; float vec[3]; int idx_w, idx_v, idx_u; int ui, vi, wi, uu, vv, ww; /* vgroup influence */ - int defgroup_nr= -1; - float co_prev[3], weight_blend= 0.0f; - MDeformVert *dvert= BKE_lattice_deform_verts_get(ob); + int defgroup_nr = -1; + float co_prev[3], weight_blend = 0.0f; + MDeformVert *dvert = BKE_lattice_deform_verts_get(ob); - if (lt->editlatt) lt= lt->editlatt->latt; - if (lt->latticedata==NULL) return; + if (lt->editlatt) lt = lt->editlatt->latt; + if (lt->latticedata == NULL) return; if (lt->vgroup[0] && dvert) { - defgroup_nr= defgroup_name_index(ob, lt->vgroup); + defgroup_nr = defgroup_name_index(ob, lt->vgroup); copy_v3_v3(co_prev, co); } @@ -369,68 +369,68 @@ void calc_latt_deform(Object *ob, float co[3], float weight) /* u v w coords */ - if (lt->pntsu>1) { - u= (vec[0]-lt->fu)/lt->du; - ui= (int)floor(u); + if (lt->pntsu > 1) { + u = (vec[0] - lt->fu) / lt->du; + ui = (int)floor(u); u -= ui; key_curve_position_weights(u, tu, lt->typeu); } else { - tu[0]= tu[2]= tu[3]= 0.0; tu[1]= 1.0; - ui= 0; + tu[0] = tu[2] = tu[3] = 0.0; tu[1] = 1.0; + ui = 0; } - if (lt->pntsv>1) { - v= (vec[1]-lt->fv)/lt->dv; - vi= (int)floor(v); + if (lt->pntsv > 1) { + v = (vec[1] - lt->fv) / lt->dv; + vi = (int)floor(v); v -= vi; key_curve_position_weights(v, tv, lt->typev); } else { - tv[0]= tv[2]= tv[3]= 0.0; tv[1]= 1.0; - vi= 0; + tv[0] = tv[2] = tv[3] = 0.0; tv[1] = 1.0; + vi = 0; } - if (lt->pntsw>1) { - w= (vec[2]-lt->fw)/lt->dw; - wi= (int)floor(w); + if (lt->pntsw > 1) { + w = (vec[2] - lt->fw) / lt->dw; + wi = (int)floor(w); w -= wi; key_curve_position_weights(w, tw, lt->typew); } else { - tw[0]= tw[2]= tw[3]= 0.0; tw[1]= 1.0; - wi= 0; + tw[0] = tw[2] = tw[3] = 0.0; tw[1] = 1.0; + wi = 0; } - for (ww= wi-1; ww<=wi+2; ww++) { - w= tw[ww-wi+1]; + for (ww = wi - 1; ww <= wi + 2; ww++) { + w = tw[ww - wi + 1]; if (w != 0.0f) { - if (ww>0) { - if (wwpntsw) idx_w= ww*lt->pntsu*lt->pntsv; - else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv; + if (ww > 0) { + if (ww < lt->pntsw) idx_w = ww * lt->pntsu * lt->pntsv; + else idx_w = (lt->pntsw - 1) * lt->pntsu * lt->pntsv; } - else idx_w= 0; + else idx_w = 0; - for (vv= vi-1; vv<=vi+2; vv++) { - v= w*tv[vv-vi+1]; + for (vv = vi - 1; vv <= vi + 2; vv++) { + v = w * tv[vv - vi + 1]; if (v != 0.0f) { - if (vv>0) { - if (vvpntsv) idx_v= idx_w + vv*lt->pntsu; - else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu; + if (vv > 0) { + if (vv < lt->pntsv) idx_v = idx_w + vv * lt->pntsu; + else idx_v = idx_w + (lt->pntsv - 1) * lt->pntsu; } - else idx_v= idx_w; + else idx_v = idx_w; - for (uu= ui-1; uu<=ui+2; uu++) { - u= weight*v*tu[uu-ui+1]; + for (uu = ui - 1; uu <= ui + 2; uu++) { + u = weight * v * tu[uu - ui + 1]; if (u != 0.0f) { - if (uu>0) { - if (uupntsu) idx_u= idx_v + uu; - else idx_u= idx_v + (lt->pntsu-1); + if (uu > 0) { + if (uu < lt->pntsu) idx_u = idx_v + uu; + else idx_u = idx_v + (lt->pntsu - 1); } - else idx_u= idx_v; + else idx_u = idx_v; madd_v3_v3fl(co, <->latticedata[idx_u * 3], u); @@ -450,18 +450,18 @@ void calc_latt_deform(Object *ob, float co[3], float weight) void end_latt_deform(Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; - if (lt->editlatt) lt= lt->editlatt->latt; + if (lt->editlatt) lt = lt->editlatt->latt; if (lt->latticedata) MEM_freeN(lt->latticedata); - lt->latticedata= NULL; + lt->latticedata = NULL; } - /* calculations is in local space of deformed object - * so we store in latmat transform from path coord inside object - */ +/* calculations is in local space of deformed object + * so we store in latmat transform from path coord inside object + */ typedef struct { float dmin[3], dmax[3]; float curvespace[4][4], objectspace[4][4], objectspace3[3][3]; @@ -474,7 +474,7 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd) mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat); invert_m4_m4(cd->curvespace, cd->objectspace); copy_m3_m4(cd->objectspace3, cd->objectspace); - cd->no_rot_axis= 0; + cd->no_rot_axis = 0; } /* this makes sure we can extend for non-cyclic. @@ -483,41 +483,41 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd) */ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir[3], float quat[4], float *radius) { - Curve *cu= ob->data; + Curve *cu = ob->data; BevList *bl; float ctime1; - int cycl=0; + int cycl = 0; /* test for cyclic */ - bl= cu->bev.first; + bl = cu->bev.first; if (!bl->nr) return 0; - if (bl && bl->poly> -1) cycl= 1; + if (bl && bl->poly > -1) cycl = 1; - if (cycl==0) { - ctime1= CLAMPIS(ctime, 0.0f, 1.0f); + if (cycl == 0) { + ctime1 = CLAMPIS(ctime, 0.0f, 1.0f); } - else ctime1= ctime; + else ctime1 = ctime; /* vec needs 4 items */ if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) { - if (cycl==0) { - Path *path= cu->path; + if (cycl == 0) { + Path *path = cu->path; float dvec[3]; if (ctime < 0.0f) { sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); - mul_v3_fl(dvec, ctime*(float)path->len); + mul_v3_fl(dvec, ctime * (float)path->len); add_v3_v3(vec, dvec); if (quat) copy_qt_qt(quat, path->data[0].quat); - if (radius) *radius= path->data[0].radius; + if (radius) *radius = path->data[0].radius; } else if (ctime > 1.0f) { - sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); - mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len); + sub_v3_v3v3(dvec, path->data[path->len - 1].vec, path->data[path->len - 2].vec); + mul_v3_fl(dvec, (ctime - 1.0f) * (float)path->len); add_v3_v3(vec, dvec); - if (quat) copy_qt_qt(quat, path->data[path->len-1].quat); - if (radius) *radius= path->data[path->len-1].radius; + if (quat) copy_qt_qt(quat, path->data[path->len - 1].quat); + if (radius) *radius = path->data[path->len - 1].radius; /* weight - not used but could be added */ } } @@ -534,43 +534,43 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir static int calc_curve_deform(Scene *scene, Object *par, float co[3], const short axis, CurveDeform *cd, float quat_r[4]) { - Curve *cu= par->data; + Curve *cu = par->data; float fac, loc[4], dir[3], new_quat[4], radius; short index; const int is_neg_axis = (axis > 2); /* to be sure, mostly after file load */ - if (cu->path==NULL) { + if (cu->path == NULL) { makeDispListCurveTypes(scene, par, 0); - if (cu->path==NULL) return 0; // happens on append... + if (cu->path == NULL) return 0; // happens on append... } /* options */ if (is_neg_axis) { index = axis - 3; if (cu->flag & CU_STRETCH) - fac= (-co[index]-cd->dmax[index])/(cd->dmax[index] - cd->dmin[index]); + fac = (-co[index] - cd->dmax[index]) / (cd->dmax[index] - cd->dmin[index]); else - fac= - (co[index]-cd->dmax[index])/(cu->path->totdist); + fac = -(co[index] - cd->dmax[index]) / (cu->path->totdist); } else { index = axis; if (cu->flag & CU_STRETCH) - fac= (co[index]-cd->dmin[index])/(cd->dmax[index] - cd->dmin[index]); + fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]); else - fac= + (co[index]-cd->dmin[index])/(cu->path->totdist); + fac = +(co[index] - cd->dmin[index]) / (cu->path->totdist); } - if ( where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */ + if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */ float quat[4], cent[3]; - if (cd->no_rot_axis) { /* set by caller */ + if (cd->no_rot_axis) { /* set by caller */ /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than * changing the axis before calculating the tilt but serves much the same purpose */ - float dir_flat[3]={0, 0, 0}, q[4]; + float dir_flat[3] = {0, 0, 0}, q[4]; copy_v3_v3(dir_flat, dir); - dir_flat[cd->no_rot_axis-1]= 0.0f; + dir_flat[cd->no_rot_axis - 1] = 0.0f; normalize_v3(dir); normalize_v3(dir_flat); @@ -598,9 +598,9 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3], /* zero the axis which is not used, * the big block of text above now applies to these 3 lines */ - quat_apply_track(quat, axis, (axis == 0 || axis == 2) ? 1:0); /* up flag is a dummy, set so no rotation is done */ + quat_apply_track(quat, axis, (axis == 0 || axis == 2) ? 1 : 0); /* up flag is a dummy, set so no rotation is done */ vec_apply_track(cent, axis); - cent[index]= 0.0f; + cent[index] = 0.0f; /* scale if enabled */ @@ -637,26 +637,26 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, cu = cuOb->data; flag = cu->flag; - cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist + cu->flag |= (CU_PATH | CU_FOLLOW); // needed for path & bevlist init_curve_deform(cuOb, target, &cd); /* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */ if (is_neg_axis == FALSE) { - cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f; - cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f; + cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = 0.0f; + cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 1.0f; } else { /* negative, these bounds give a good rest position */ - cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f; - cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f; + cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = -1.0f; + cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 0.0f; } /* check whether to use vertex groups (only possible if target is a Mesh) * we want either a Mesh with no derived data, or derived data with * deformverts */ - if (target && target->type==OB_MESH) { + if (target && target->type == OB_MESH) { /* if there's derived data without deformverts, don't use vgroups */ if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT)) use_vgroups = 0; @@ -668,8 +668,8 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, } if (vgroup && vgroup[0] && use_vgroups) { - Mesh *me= target->data; - int index= defgroup_name_index(target, vgroup); + Mesh *me = target->data; + int index = defgroup_name_index(target, vgroup); if (index != -1 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; @@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, dvert = me->dvert; for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight= defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, index); if (weight > 0.0f) { mul_m4_v3(cd.curvespace, vertexCos[a]); @@ -709,7 +709,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight= defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, index); if (weight > 0.0f) { /* already in 'cd.curvespace', prev for loop */ @@ -764,7 +764,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, } init_curve_deform(cuOb, target, &cd); - cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */ + cd.no_rot_axis = no_rot_axis; /* option to only rotate for XY, for example */ copy_v3_v3(cd.dmin, orco); copy_v3_v3(cd.dmax, orco); @@ -799,7 +799,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, * we want either a Mesh with no derived data, or derived data with * deformverts */ - if (target && target->type==OB_MESH) { + if (target && target->type == OB_MESH) { /* if there's derived data without deformverts, don't use vgroups */ if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT)) use_vgroups = 0; @@ -821,7 +821,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight= defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, index); if (weight > 0.0f) calc_latt_deform(laOb, vertexCos[a], weight * fac); @@ -838,12 +838,12 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, int object_deform_mball(Object *ob, ListBase *dispbase) { - if (ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + if (ob->parent && ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) { DispList *dl; - for (dl=dispbase->first; dl; dl=dl->next) { + for (dl = dispbase->first; dl; dl = dl->next) { lattice_deform_verts(ob->parent, ob, NULL, - (float(*)[3]) dl->verts, dl->nr, NULL, 1.0f); + (float(*)[3])dl->verts, dl->nr, NULL, 1.0f); } return 1; @@ -862,52 +862,52 @@ void outside_lattice(Lattice *lt) { BPoint *bp, *bp1, *bp2; int u, v, w; - float fac1, du=0.0, dv=0.0, dw=0.0; + float fac1, du = 0.0, dv = 0.0, dw = 0.0; if (lt->flag & LT_OUTSIDE) { - bp= lt->def; + bp = lt->def; - if (lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1); - if (lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1); - if (lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1); + if (lt->pntsu > 1) du = 1.0f / ((float)lt->pntsu - 1); + if (lt->pntsv > 1) dv = 1.0f / ((float)lt->pntsv - 1); + if (lt->pntsw > 1) dw = 1.0f / ((float)lt->pntsw - 1); - for (w=0; wpntsw; w++) { + for (w = 0; w < lt->pntsw; w++) { - for (v=0; vpntsv; v++) { + for (v = 0; v < lt->pntsv; v++) { - for (u=0; upntsu; u++, bp++) { - if (u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1); + for (u = 0; u < lt->pntsu; u++, bp++) { + if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) ; else { - bp->hide= 1; + bp->hide = 1; bp->f1 &= ~SELECT; /* u extrema */ - bp1= latt_bp(lt, 0, v, w); - bp2= latt_bp(lt, lt->pntsu-1, v, w); + bp1 = latt_bp(lt, 0, v, w); + bp2 = latt_bp(lt, lt->pntsu - 1, v, w); - fac1= du*u; - bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0]; - bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; - bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; + fac1 = du * u; + bp->vec[0] = (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0]; + bp->vec[1] = (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; + bp->vec[2] = (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; /* v extrema */ - bp1= latt_bp(lt, u, 0, w); - bp2= latt_bp(lt, u, lt->pntsv-1, w); + bp1 = latt_bp(lt, u, 0, w); + bp2 = latt_bp(lt, u, lt->pntsv - 1, w); - fac1= dv*v; - bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0]; - bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; - bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; + fac1 = dv * v; + bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0]; + bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; + bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; /* w extrema */ - bp1= latt_bp(lt, u, v, 0); - bp2= latt_bp(lt, u, v, lt->pntsw-1); + bp1 = latt_bp(lt, u, v, 0); + bp2 = latt_bp(lt, u, v, lt->pntsw - 1); - fac1= dw*w; - bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0]; - bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; - bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; + fac1 = dw * w; + bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0]; + bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; + bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; mul_v3_fl(bp->vec, 0.3333333f); @@ -919,12 +919,12 @@ void outside_lattice(Lattice *lt) } } else { - bp= lt->def; + bp = lt->def; - for (w=0; wpntsw; w++) - for (v=0; vpntsv; v++) - for (u=0; upntsu; u++, bp++) - bp->hide= 0; + for (w = 0; w < lt->pntsw; w++) + for (v = 0; v < lt->pntsv; v++) + for (u = 0; u < lt->pntsu; u++, bp++) + bp->hide = 0; } } @@ -934,12 +934,12 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3] int i, numVerts; float (*vertexCos)[3]; - if (lt->editlatt) lt= lt->editlatt->latt; - numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw; + if (lt->editlatt) lt = lt->editlatt->latt; + numVerts = *numVerts_r = lt->pntsu * lt->pntsv * lt->pntsw; - vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts, "lt_vcos"); + vertexCos = MEM_mallocN(sizeof(*vertexCos) * numVerts, "lt_vcos"); - for (i=0; idef[i].vec); } @@ -949,31 +949,31 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[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; + int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw; - for (i=0; idef[i].vec, vertexCos[i]); } } void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; ModifierData *md = modifiers_getVirtualModifierList(ob); float (*vertexCos)[3] = NULL; - int numVerts, editmode = (lt->editlatt!=NULL); + int numVerts, editmode = (lt->editlatt != NULL); freedisplist(&ob->disp); - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; - if (!(md->mode&eModifierMode_Realtime)) continue; - if (editmode && !(md->mode&eModifierMode_Editmode)) continue; + if (!(md->mode & eModifierMode_Realtime)) continue; + if (editmode && !(md->mode & eModifierMode_Editmode)) continue; if (mti->isDisabled && mti->isDisabled(md, 0)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform) continue; + if (mti->type != eModifierTypeType_OnlyDeform) continue; if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); @@ -987,16 +987,16 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) dl->type = DL_VERTS; dl->parts = 1; dl->nr = numVerts; - dl->verts = (float*) vertexCos; + dl->verts = (float *) vertexCos; BLI_addtail(&ob->disp, dl); } } -struct MDeformVert* BKE_lattice_deform_verts_get(struct Object *oblatt) +struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *oblatt) { - Lattice *lt = (Lattice*)oblatt->data; + Lattice *lt = (Lattice *)oblatt->data; BLI_assert(oblatt->type == OB_LATTICE); - if (lt->editlatt) lt= lt->editlatt->latt; + if (lt->editlatt) lt = lt->editlatt->latt; return lt->dvert; } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 13cfb40a0eb..7507442a4d5 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -82,8 +82,8 @@ void BKE_material_free(Material *ma) MTex *mtex; int a; - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = ma->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -95,7 +95,7 @@ void BKE_material_free(Material *ma) if (ma->preview) BKE_previewimg_free(&ma->preview); - BKE_icon_delete((struct ID*)ma); + BKE_icon_delete((struct ID *)ma); ma->id.icon_id = 0; /* is no lib link block, but material extension */ @@ -110,67 +110,67 @@ void BKE_material_free(Material *ma) void init_material(Material *ma) { - ma->r= ma->g= ma->b= ma->ref= 0.8; - ma->specr= ma->specg= ma->specb= 1.0; - ma->mirr= ma->mirg= ma->mirb= 1.0; - ma->spectra= 1.0; - ma->amb= 1.0; - ma->alpha= 1.0; - ma->spec= ma->hasize= 0.5; - ma->har= 50; - ma->starc= ma->ringc= 4; - ma->linec= 12; - ma->flarec= 1; - ma->flaresize= ma->subsize= 1.0; - ma->flareboost= 1; - ma->seed2= 6; - ma->friction= 0.5; - ma->refrac= 4.0; - ma->roughness= 0.5; - ma->param[0]= 0.5; - ma->param[1]= 0.1; - ma->param[2]= 0.5; - ma->param[3]= 0.1; - ma->rms= 0.1; - ma->darkness= 1.0; + ma->r = ma->g = ma->b = ma->ref = 0.8; + ma->specr = ma->specg = ma->specb = 1.0; + ma->mirr = ma->mirg = ma->mirb = 1.0; + ma->spectra = 1.0; + ma->amb = 1.0; + ma->alpha = 1.0; + ma->spec = ma->hasize = 0.5; + ma->har = 50; + ma->starc = ma->ringc = 4; + ma->linec = 12; + ma->flarec = 1; + ma->flaresize = ma->subsize = 1.0; + ma->flareboost = 1; + ma->seed2 = 6; + ma->friction = 0.5; + ma->refrac = 4.0; + ma->roughness = 0.5; + ma->param[0] = 0.5; + ma->param[1] = 0.1; + ma->param[2] = 0.5; + ma->param[3] = 0.1; + ma->rms = 0.1; + ma->darkness = 1.0; + + ma->strand_sta = ma->strand_end = 1.0f; + + ma->ang = 1.0; + ma->ray_depth = 2; + ma->ray_depth_tra = 2; + ma->fresnel_mir = 0.0; + ma->fresnel_tra = 0.0; + ma->fresnel_tra_i = 1.25; + ma->fresnel_mir_i = 1.25; + ma->tx_limit = 0.0; + ma->tx_falloff = 1.0; + ma->shad_alpha = 1.0f; - ma->strand_sta= ma->strand_end= 1.0f; - - ma->ang= 1.0; - ma->ray_depth= 2; - ma->ray_depth_tra= 2; - ma->fresnel_mir= 0.0; - ma->fresnel_tra= 0.0; - ma->fresnel_tra_i= 1.25; - ma->fresnel_mir_i= 1.25; - ma->tx_limit= 0.0; - ma->tx_falloff= 1.0; - ma->shad_alpha= 1.0f; - - ma->gloss_mir = ma->gloss_tra= 1.0; - ma->samp_gloss_mir = ma->samp_gloss_tra= 18; + ma->gloss_mir = ma->gloss_tra = 1.0; + ma->samp_gloss_mir = ma->samp_gloss_tra = 18; ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005; ma->dist_mir = 0.0; ma->fadeto_mir = MA_RAYMIR_FADETOSKY; - ma->rampfac_col= 1.0; - ma->rampfac_spec= 1.0; - ma->pr_lamp= 3; /* two lamps, is bits */ - ma->pr_type= MA_SPHERE; + ma->rampfac_col = 1.0; + ma->rampfac_spec = 1.0; + ma->pr_lamp = 3; /* two lamps, is bits */ + ma->pr_type = MA_SPHERE; - ma->sss_radius[0]= 1.0f; - ma->sss_radius[1]= 1.0f; - ma->sss_radius[2]= 1.0f; - ma->sss_col[0]= 1.0f; - ma->sss_col[1]= 1.0f; - ma->sss_col[2]= 1.0f; - 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; - ma->sss_front= 1.0f; - ma->sss_back= 1.0f; + ma->sss_radius[0] = 1.0f; + ma->sss_radius[1] = 1.0f; + ma->sss_radius[2] = 1.0f; + ma->sss_col[0] = 1.0f; + ma->sss_col[1] = 1.0f; + ma->sss_col[2] = 1.0f; + 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; + ma->sss_front = 1.0f; + ma->sss_back = 1.0f; ma->vol.density = 1.0f; ma->vol.emission = 0.0f; @@ -191,11 +191,11 @@ void init_material(Material *ma) ma->vol.ms_intensity = 1.f; ma->game.flag = GEMAT_BACKCULL; - ma->game.alpha_blend=0; - ma->game.face_orientation=0; + ma->game.alpha_blend = 0; + ma->game.face_orientation = 0; - ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP; - ma->shade_flag= MA_APPROX_OCCLUSION; + ma->mode = MA_TRACEBLE | MA_SHADBUF | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP; + ma->shade_flag = MA_APPROX_OCCLUSION; ma->preview = NULL; } @@ -203,7 +203,7 @@ Material *BKE_material_add(const char *name) { Material *ma; - ma= BKE_libblock_alloc(&G.main->mat, ID_MA, name); + ma = BKE_libblock_alloc(&G.main->mat, ID_MA, name); init_material(ma); @@ -216,28 +216,28 @@ Material *BKE_material_copy(Material *ma) Material *man; int a; - man= BKE_libblock_copy(&ma->id); + man = BKE_libblock_copy(&ma->id); id_lib_extern((ID *)man->group); - for (a=0; amtex[a]) { - man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial"); + man->mtex[a] = MEM_mallocN(sizeof(MTex), "copymaterial"); memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex)); id_us_plus((ID *)man->mtex[a]->tex); } } - if (ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); - if (ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); + if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col); + if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec); if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); if (ma->nodetree) { - man->nodetree= ntreeCopyTree(ma->nodetree); /* 0 == full new tree */ + man->nodetree = ntreeCopyTree(ma->nodetree); /* 0 == full new tree */ } - man->gpumaterial.first= man->gpumaterial.last= NULL; + man->gpumaterial.first = man->gpumaterial.last = NULL; return man; } @@ -248,26 +248,26 @@ Material *localize_material(Material *ma) Material *man; int a; - man= BKE_libblock_copy(&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 */ - for (a=0; amtex[a]) { - man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial"); + man->mtex[a] = MEM_mallocN(sizeof(MTex), "copymaterial"); memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex)); } } - if (ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); - if (ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); + if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col); + if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec); man->preview = NULL; if (ma->nodetree) - man->nodetree= ntreeLocalize(ma->nodetree); + man->nodetree = ntreeLocalize(ma->nodetree); - man->gpumaterial.first= man->gpumaterial.last= NULL; + man->gpumaterial.first = man->gpumaterial.last = NULL; return man; } @@ -275,29 +275,29 @@ Material *localize_material(Material *ma) static void extern_local_material(Material *ma) { int i; - for (i=0; i < MAX_MTEX; i++) { + for (i = 0; i < MAX_MTEX; i++) { if (ma->mtex[i]) id_lib_extern((ID *)ma->mtex[i]->tex); } } void BKE_material_make_local(Material *ma) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; Mesh *me; Curve *cu; MetaBall *mb; - int a, is_local= FALSE, is_lib= FALSE; + int a, is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (ma->id.lib==NULL) return; + if (ma->id.lib == NULL) return; /* One local user; set flag and return. */ - if (ma->id.us==1) { + if (ma->id.us == 1) { id_clear_lib_data(bmain, &ma->id); extern_local_material(ma); return; @@ -306,56 +306,56 @@ void BKE_material_make_local(Material *ma) /* Check which other IDs reference this one to determine if it's used by * lib or local */ /* test objects */ - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { if (ob->mat) { - for (a=0; atotcol; a++) { - if (ob->mat[a]==ma) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < ob->totcol; a++) { + if (ob->mat[a] == ma) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - ob= ob->id.next; + ob = ob->id.next; } /* test meshes */ - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { if (me->mat) { - for (a=0; atotcol; a++) { - if (me->mat[a]==ma) { - if (me->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < me->totcol; a++) { + if (me->mat[a] == ma) { + if (me->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - me= me->id.next; + me = me->id.next; } /* test curves */ - cu= bmain->curve.first; + cu = bmain->curve.first; while (cu) { if (cu->mat) { - for (a=0; atotcol; a++) { - if (cu->mat[a]==ma) { - if (cu->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < cu->totcol; a++) { + if (cu->mat[a] == ma) { + if (cu->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - cu= cu->id.next; + cu = cu->id.next; } /* test mballs */ - mb= bmain->mball.first; + mb = bmain->mball.first; while (mb) { if (mb->mat) { - for (a=0; atotcol; a++) { - if (mb->mat[a]==ma) { - if (mb->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < mb->totcol; a++) { + if (mb->mat[a] == ma) { + if (mb->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - mb= mb->id.next; + mb = mb->id.next; } /* Only local users. */ @@ -365,76 +365,76 @@ void BKE_material_make_local(Material *ma) } /* Both user and local, so copy. */ else if (is_local && is_lib) { - Material *ma_new= BKE_material_copy(ma); + Material *ma_new = BKE_material_copy(ma); - ma_new->id.us= 0; + ma_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, ma->id.lib, &ma_new->id); /* do objects */ - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { if (ob->mat) { - for (a=0; atotcol; a++) { - if (ob->mat[a]==ma) { - if (ob->id.lib==NULL) { - ob->mat[a]= ma_new; + for (a = 0; a < ob->totcol; a++) { + if (ob->mat[a] == ma) { + if (ob->id.lib == NULL) { + ob->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - ob= ob->id.next; + ob = ob->id.next; } /* do meshes */ - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { if (me->mat) { - for (a=0; atotcol; a++) { - if (me->mat[a]==ma) { - if (me->id.lib==NULL) { - me->mat[a]= ma_new; + for (a = 0; a < me->totcol; a++) { + if (me->mat[a] == ma) { + if (me->id.lib == NULL) { + me->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - me= me->id.next; + me = me->id.next; } /* do curves */ - cu= bmain->curve.first; + cu = bmain->curve.first; while (cu) { if (cu->mat) { - for (a=0; atotcol; a++) { - if (cu->mat[a]==ma) { - if (cu->id.lib==NULL) { - cu->mat[a]= ma_new; + for (a = 0; a < cu->totcol; a++) { + if (cu->mat[a] == ma) { + if (cu->id.lib == NULL) { + cu->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - cu= cu->id.next; + cu = cu->id.next; } /* do mballs */ - mb= bmain->mball.first; + mb = bmain->mball.first; while (mb) { if (mb->mat) { - for (a=0; atotcol; a++) { - if (mb->mat[a]==ma) { - if (mb->id.lib==NULL) { - mb->mat[a]= ma_new; + for (a = 0; a < mb->totcol; a++) { + if (mb->mat[a] == ma) { + if (mb->id.lib == NULL) { + mb->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - mb= mb->id.next; + mb = mb->id.next; } } } @@ -443,7 +443,7 @@ void BKE_material_make_local(Material *ma) void extern_local_matarar(struct Material **matar, short totcol) { short i; - for (i= 0; i < totcol; i++) { + for (i = 0; i < totcol; i++) { id_lib_extern((ID *)matar[i]); } } @@ -454,16 +454,16 @@ Material ***give_matarar(Object *ob) Curve *cu; MetaBall *mb; - if (ob->type==OB_MESH) { - me= ob->data; + if (ob->type == OB_MESH) { + me = ob->data; return &(me->mat); } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { - cu= ob->data; + cu = ob->data; return &(cu->mat); } - else if (ob->type==OB_MBALL) { - mb= ob->data; + else if (ob->type == OB_MBALL) { + mb = ob->data; return &(mb->mat); } return NULL; @@ -475,16 +475,16 @@ short *give_totcolp(Object *ob) Curve *cu; MetaBall *mb; - if (ob->type==OB_MESH) { - me= ob->data; + if (ob->type == OB_MESH) { + me = ob->data; return &(me->totcol); } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { - cu= ob->data; + cu = ob->data; return &(cu->totcol); } - else if (ob->type==OB_MBALL) { - mb= ob->data; + else if (ob->type == OB_MBALL) { + mb = ob->data; return &(mb->totcol); } return NULL; @@ -494,15 +494,15 @@ short *give_totcolp(Object *ob) Material ***give_matarar_id(ID *id) { switch (GS(id->name)) { - case ID_ME: - return &(((Mesh *)id)->mat); - break; - case ID_CU: - return &(((Curve *)id)->mat); - break; - case ID_MB: - return &(((MetaBall *)id)->mat); - break; + case ID_ME: + return &(((Mesh *)id)->mat); + break; + case ID_CU: + return &(((Curve *)id)->mat); + break; + case ID_MB: + return &(((MetaBall *)id)->mat); + break; } return NULL; } @@ -510,15 +510,15 @@ Material ***give_matarar_id(ID *id) short *give_totcolp_id(ID *id) { switch (GS(id->name)) { - case ID_ME: - return &(((Mesh *)id)->totcol); - break; - case ID_CU: - return &(((Curve *)id)->totcol); - break; - case ID_MB: - return &(((MetaBall *)id)->totcol); - break; + case ID_ME: + return &(((Mesh *)id)->totcol); + break; + case ID_CU: + return &(((Curve *)id)->totcol); + break; + case ID_MB: + return &(((MetaBall *)id)->totcol); + break; } return NULL; } @@ -526,29 +526,29 @@ short *give_totcolp_id(ID *id) static void data_delete_material_index_id(ID *id, short index) { switch (GS(id->name)) { - case ID_ME: - BKE_mesh_delete_material_index((Mesh *)id, index); - break; - case ID_CU: - BKE_curve_delete_material_index((Curve *)id, index); - break; - case ID_MB: - /* meta-elems don't have materials atm */ - break; + case ID_ME: + BKE_mesh_delete_material_index((Mesh *)id, index); + break; + case ID_CU: + BKE_curve_delete_material_index((Curve *)id, index); + break; + case ID_MB: + /* meta-elems don't have materials atm */ + break; } } void material_append_id(ID *id, Material *ma) { Material ***matar; - if ((matar= give_matarar_id(id))) { - short *totcol= give_totcolp_id(id); - Material **mat= MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar"); + if ((matar = give_matarar_id(id))) { + short *totcol = give_totcolp_id(id); + Material **mat = MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar"); if (*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol)); if (*matar) MEM_freeN(*matar); - *matar= mat; - (*matar)[(*totcol)++]= ma; + *matar = mat; + (*matar)[(*totcol)++] = ma; id_us_plus((ID *)ma); test_object_materials(id); @@ -557,33 +557,33 @@ void material_append_id(ID *id, Material *ma) Material *material_pop_id(ID *id, int index_i, int remove_material_slot) { - short index= (short)index_i; - Material *ret= NULL; + short index = (short)index_i; + Material *ret = NULL; Material ***matar; - if ((matar= give_matarar_id(id))) { - short *totcol= give_totcolp_id(id); + if ((matar = give_matarar_id(id))) { + short *totcol = give_totcolp_id(id); if (index >= 0 && index < (*totcol)) { - ret= (*matar)[index]; + ret = (*matar)[index]; id_us_min((ID *)ret); if (remove_material_slot) { if (*totcol <= 1) { - *totcol= 0; + *totcol = 0; MEM_freeN(*matar); - *matar= NULL; + *matar = NULL; } else { Material **mat; if (index + 1 != (*totcol)) - memmove((*matar)+index, (*matar)+(index+1), sizeof(void *) * ((*totcol) - (index + 1))); + memmove((*matar) + index, (*matar) + (index + 1), sizeof(void *) * ((*totcol) - (index + 1))); (*totcol)--; - mat= MEM_callocN(sizeof(void *) * (*totcol), "newmatar"); + mat = MEM_callocN(sizeof(void *) * (*totcol), "newmatar"); memcpy(mat, *matar, sizeof(void *) * (*totcol)); MEM_freeN(*matar); - *matar= mat; + *matar = mat; test_object_materials(id); } @@ -593,7 +593,7 @@ Material *material_pop_id(ID *id, int index_i, int remove_material_slot) /* don't remove material slot, only clear it*/ else - (*matar)[index]= NULL; + (*matar)[index] = NULL; } } @@ -605,33 +605,33 @@ Material *give_current_material(Object *ob, short act) Material ***matarar, *ma; short *totcolp; - if (ob==NULL) return NULL; + if (ob == NULL) return NULL; /* if object cannot have material, totcolp==NULL */ - totcolp= give_totcolp(ob); - if (totcolp==NULL || ob->totcol==0) return NULL; + totcolp = give_totcolp(ob); + if (totcolp == NULL || ob->totcol == 0) return NULL; - if (act<0) { + if (act < 0) { printf("no!\n"); } - if (act>ob->totcol) act= ob->totcol; - else if (act<=0) act= 1; + if (act > ob->totcol) act = ob->totcol; + else if (act <= 0) act = 1; - if (ob->matbits && ob->matbits[act-1]) { /* in object */ - ma= ob->mat[act-1]; + if (ob->matbits && ob->matbits[act - 1]) { /* in object */ + ma = ob->mat[act - 1]; } - else { /* in data */ + else { /* in data */ /* check for inconsistency */ if (*totcolp < ob->totcol) - ob->totcol= *totcolp; - if (act>ob->totcol) act= ob->totcol; + ob->totcol = *totcolp; + if (act > ob->totcol) act = ob->totcol; - matarar= give_matarar(ob); + matarar = give_matarar(ob); - if (matarar && *matarar) ma= (*matarar)[act-1]; - else ma= NULL; + if (matarar && *matarar) ma = (*matarar)[act - 1]; + else ma = NULL; } @@ -641,19 +641,19 @@ Material *give_current_material(Object *ob, short act) ID *material_from(Object *ob, short act) { - if (ob==NULL) return NULL; + if (ob == NULL) return NULL; - if (ob->totcol==0) return ob->data; - if (act==0) act= 1; + if (ob->totcol == 0) return ob->data; + if (act == 0) act = 1; - if (ob->matbits[act-1]) return (ID *)ob; + if (ob->matbits[act - 1]) return (ID *)ob; else return ob->data; } Material *give_node_material(Material *ma) { if (ma && ma->use_nodes && ma->nodetree) { - bNode *node= nodeGetActiveID(ma->nodetree, ID_MA); + bNode *node = nodeGetActiveID(ma->nodetree, ID_MA); if (node) return (Material *)node->id; @@ -670,7 +670,7 @@ Material *give_node_material(Material *ma) * well. I expect we'll sort it out soon... */ /* from blendef: */ -#define GS(a) (*((short *)(a))) +#define GS(a) (*((short *)(a))) /* from misc_util: flip the bytes from x */ /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */ @@ -680,29 +680,29 @@ void resize_object_material(Object *ob, const short totcol) Material **newmatar; char *newmatbits; - if (totcol==0) { + if (totcol == 0) { if (ob->totcol) { MEM_freeN(ob->mat); MEM_freeN(ob->matbits); - ob->mat= NULL; - ob->matbits= NULL; + ob->mat = NULL; + ob->matbits = NULL; } } - else if (ob->totcoltotcol < totcol) { + newmatar = MEM_callocN(sizeof(void *) * totcol, "newmatar"); + newmatbits = MEM_callocN(sizeof(char) * totcol, "newmatbits"); if (ob->totcol) { - memcpy(newmatar, ob->mat, sizeof(void *)*ob->totcol); - memcpy(newmatbits, ob->matbits, sizeof(char)*ob->totcol); + memcpy(newmatar, ob->mat, sizeof(void *) * ob->totcol); + memcpy(newmatbits, ob->matbits, sizeof(char) * ob->totcol); MEM_freeN(ob->mat); MEM_freeN(ob->matbits); } - ob->mat= newmatar; - ob->matbits= newmatbits; + ob->mat = newmatar; + ob->matbits = newmatbits; } - ob->totcol= totcol; - if (ob->totcol && ob->actcol==0) ob->actcol= 1; - if (ob->actcol>ob->totcol) ob->actcol= ob->totcol; + ob->totcol = totcol; + if (ob->totcol && ob->actcol == 0) ob->actcol = 1; + if (ob->actcol > ob->totcol) ob->actcol = ob->totcol; } void test_object_materials(ID *id) @@ -711,12 +711,12 @@ void test_object_materials(ID *id) Object *ob; short *totcol; - if (id==NULL || (totcol=give_totcolp_id(id))==NULL) { + if (id == NULL || (totcol = give_totcolp_id(id)) == NULL) { return; } - for (ob= G.main->object.first; ob; ob= ob->id.next) { - if (ob->data==id) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { + if (ob->data == id) { resize_object_material(ob, *totcol); } } @@ -727,8 +727,8 @@ void assign_material_id(ID *id, Material *ma, short act) Material *mao, **matar, ***matarar; short *totcolp; - if (act>MAXMAT) return; - if (act<1) act= 1; + if (act > MAXMAT) return; + if (act < 1) act = 1; /* prevent crashing when using accidentally */ BLI_assert(id->lib == NULL); @@ -736,27 +736,27 @@ void assign_material_id(ID *id, Material *ma, short act) /* test arraylens */ - totcolp= give_totcolp_id(id); - matarar= give_matarar_id(id); + totcolp = give_totcolp_id(id); + matarar = give_matarar_id(id); - if (totcolp==NULL || matarar==NULL) return; + if (totcolp == NULL || matarar == NULL) return; if (act > *totcolp) { - matar= MEM_callocN(sizeof(void *)*act, "matarray1"); + matar = MEM_callocN(sizeof(void *) * act, "matarray1"); if (*totcolp) { - memcpy(matar, *matarar, sizeof(void *)*(*totcolp)); + memcpy(matar, *matarar, sizeof(void *) * (*totcolp)); MEM_freeN(*matarar); } - *matarar= matar; - *totcolp= act; + *matarar = matar; + *totcolp = act; } /* in data */ - mao= (*matarar)[act-1]; + mao = (*matarar)[act - 1]; if (mao) mao->id.us--; - (*matarar)[act-1]= ma; + (*matarar)[act - 1] = ma; if (ma) id_us_plus((ID *)ma); @@ -770,8 +770,8 @@ void assign_material(Object *ob, Material *ma, short act) char *matbits; short *totcolp; - if (act>MAXMAT) return; - if (act<1) act= 1; + if (act > MAXMAT) return; + if (act < 1) act = 1; /* prevent crashing when using accidentally */ BLI_assert(ob->id.lib == NULL); @@ -779,54 +779,54 @@ void assign_material(Object *ob, Material *ma, short act) /* test arraylens */ - totcolp= give_totcolp(ob); - matarar= give_matarar(ob); + totcolp = give_totcolp(ob); + matarar = give_matarar(ob); - if (totcolp==NULL || matarar==NULL) return; + if (totcolp == NULL || matarar == NULL) return; if (act > *totcolp) { - matar= MEM_callocN(sizeof(void *)*act, "matarray1"); + matar = MEM_callocN(sizeof(void *) * act, "matarray1"); if (*totcolp) { - memcpy(matar, *matarar, sizeof(void *)*(*totcolp)); + memcpy(matar, *matarar, sizeof(void *) * (*totcolp)); MEM_freeN(*matarar); } - *matarar= matar; - *totcolp= act; + *matarar = matar; + *totcolp = act; } if (act > ob->totcol) { - matar= MEM_callocN(sizeof(void *)*act, "matarray2"); - matbits= MEM_callocN(sizeof(char)*act, "matbits1"); - if ( ob->totcol) { + matar = MEM_callocN(sizeof(void *) * act, "matarray2"); + matbits = MEM_callocN(sizeof(char) * act, "matbits1"); + if (ob->totcol) { memcpy(matar, ob->mat, sizeof(void *) * ob->totcol); - memcpy(matbits, ob->matbits, sizeof(char)*(*totcolp)); + memcpy(matbits, ob->matbits, sizeof(char) * (*totcolp)); MEM_freeN(ob->mat); MEM_freeN(ob->matbits); } - ob->mat= matar; - ob->matbits= matbits; - ob->totcol= act; + ob->mat = matar; + ob->matbits = matbits; + ob->totcol = act; /* copy object/mesh linking, or assign based on userpref */ if (ob->actcol) - ob->matbits[act-1]= ob->matbits[ob->actcol-1]; + ob->matbits[act - 1] = ob->matbits[ob->actcol - 1]; else - ob->matbits[act-1]= (U.flag & USER_MAT_ON_OB)? 1: 0; + ob->matbits[act - 1] = (U.flag & USER_MAT_ON_OB) ? 1 : 0; } /* do it */ - if (ob->matbits[act-1]) { /* in object */ - mao= ob->mat[act-1]; + if (ob->matbits[act - 1]) { /* in object */ + mao = ob->mat[act - 1]; if (mao) mao->id.us--; - ob->mat[act-1]= ma; + ob->mat[act - 1] = ma; } - else { /* in data */ - mao= (*matarar)[act-1]; + else { /* in data */ + mao = (*matarar)[act - 1]; if (mao) mao->id.us--; - (*matarar)[act-1]= ma; + (*matarar)[act - 1] = ma; } if (ma) @@ -837,19 +837,19 @@ void assign_material(Object *ob, Material *ma, short act) /* XXX - this calls many more update calls per object then are needed, could be optimized */ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol) { - int actcol_orig= ob->actcol; + int actcol_orig = ob->actcol; short i; while (object_remove_material_slot(ob)) {}; /* now we have the right number of slots */ - for (i=0; i ob->totcol) - actcol_orig= ob->totcol; + actcol_orig = ob->totcol; - ob->actcol= actcol_orig; + ob->actcol = actcol_orig; } @@ -858,45 +858,45 @@ short find_material_index(Object *ob, Material *ma) Material ***matarar; short a, *totcolp; - if (ma==NULL) return 0; + if (ma == NULL) return 0; - totcolp= give_totcolp(ob); - matarar= give_matarar(ob); + totcolp = give_totcolp(ob); + matarar = give_matarar(ob); - if (totcolp==NULL || matarar==NULL) return 0; + if (totcolp == NULL || matarar == NULL) return 0; - for (a=0; a<*totcolp; a++) - if ((*matarar)[a]==ma) - break; - if (a<*totcolp) - return a+1; + for (a = 0; a < *totcolp; a++) + if ((*matarar)[a] == ma) + break; + if (a < *totcolp) + return a + 1; return 0; } int object_add_material_slot(Object *ob) { - if (ob==NULL) return FALSE; - if (ob->totcol>=MAXMAT) return FALSE; + if (ob == NULL) return FALSE; + if (ob->totcol >= MAXMAT) return FALSE; - assign_material(ob, NULL, ob->totcol+1); - ob->actcol= ob->totcol; + assign_material(ob, NULL, ob->totcol + 1); + ob->actcol = ob->totcol; return TRUE; } static void do_init_render_material(Material *ma, int r_mode, float *amb) { MTex *mtex; - int a, needuv=0, needtang=0; + int a, needuv = 0, needtang = 0; - if (ma->flarec==0) ma->flarec= 1; + if (ma->flarec == 0) ma->flarec = 1; /* add all texcoflags from mtex, texco and mapto were cleared in advance */ - for (a=0; aseptex & (1<septex & (1 << a)) continue; - mtex= ma->mtex[a]; + mtex = ma->mtex[a]; if (mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) { ma->texco |= mtex->texco; @@ -904,41 +904,41 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* always get derivatives for these textures */ if (ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP)) ma->texco |= TEXCO_OSA; - else if (mtex->texflag & (MTEX_COMPAT_BUMP|MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA; + else if (mtex->texflag & (MTEX_COMPAT_BUMP | MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA; - if (ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1; - else if (ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1; - else if (ma->texco & (TEXCO_LAVECTOR|TEXCO_VIEW|TEXCO_STICKY)) needuv= 1; + if (ma->texco & (TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM | TEXCO_STRAND | TEXCO_STRESS)) needuv = 1; + else if (ma->texco & (TEXCO_GLOB | TEXCO_UV | TEXCO_OBJECT | TEXCO_SPEED)) needuv = 1; + else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW | TEXCO_STICKY)) needuv = 1; if ((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT)) - needtang= 1; + needtang = 1; } } if (needtang) ma->mode |= MA_NORMAP_TANG; else ma->mode &= ~MA_NORMAP_TANG; - if (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { - needuv= 1; - if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */ + if (ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { + needuv = 1; + if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */ } if (needuv) ma->texco |= NEED_UV; /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */ if (r_mode & R_RAYTRACE) { - if ((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { - ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM; + if ((ma->mode & (MA_RAYMIRROR | MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { + ma->texco |= NEED_UV | TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM; if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; } } if (amb) { - ma->ambr= ma->amb*amb[0]; - ma->ambg= ma->amb*amb[1]; - ma->ambb= ma->amb*amb[2]; + ma->ambr = ma->amb * amb[0]; + ma->ambg = ma->amb * amb[1]; + ma->ambb = ma->amb * amb[2]; } /* will become or-ed result of all node modes */ - ma->mode_l= ma->mode; + ma->mode_l = ma->mode; ma->mode_l &= ~MA_SHLESS; if (ma->strand_surfnor > 0.0f) @@ -953,17 +953,17 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode { bNode *node; - for (node=ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->id) { - if (GS(node->id->name)==ID_MA) { - Material *ma= (Material *)node->id; - if (ma!=basemat) { + if (GS(node->id->name) == ID_MA) { + Material *ma = (Material *)node->id; + if (ma != basemat) { do_init_render_material(ma, r_mode, amb); basemat->texco |= ma->texco; - basemat->mode_l |= ma->mode_l & ~(MA_TRANSP|MA_ZTRANSP|MA_RAYTRANSP); + basemat->mode_l |= ma->mode_l & ~(MA_TRANSP | MA_ZTRANSP | MA_RAYTRANSP); } } - else if (node->type==NODE_GROUP) + else if (node->type == NODE_GROUP) init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb); } } @@ -989,15 +989,15 @@ void init_render_materials(Main *bmain, int r_mode, float *amb) /* clear these flags before going over materials, to make sure they * are cleared only once, otherwise node materials contained in other * node materials can go wrong */ - for (ma= bmain->mat.first; ma; ma= ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->id.us) { - ma->texco= 0; - ma->mapto= 0; + ma->texco = 0; + ma->mapto = 0; } } /* two steps, first initialize, then or the flags for layers */ - for (ma= bmain->mat.first; ma; ma= ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { /* is_used flag comes back in convertblender.c */ ma->flag &= ~MA_IS_USED; if (ma->id.us) @@ -1019,7 +1019,7 @@ void end_render_material(Material *mat) void end_render_materials(Main *bmain) { Material *ma; - for (ma= bmain->mat.first; ma; ma= ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->id.us) end_render_material(ma); } @@ -1028,13 +1028,13 @@ static int material_in_nodetree(bNodeTree *ntree, Material *mat) { bNode *node; - for (node=ntree->nodes.first; node; node= node->next) { - if (node->id && GS(node->id->name)==ID_MA) { - if (node->id==(ID*)mat) + for (node = ntree->nodes.first; node; node = node->next) { + if (node->id && GS(node->id->name) == ID_MA) { + if (node->id == (ID *)mat) return 1; } - else if (node->type==NODE_GROUP) - if (material_in_nodetree((bNodeTree*)node->id, mat)) + else if (node->type == NODE_GROUP) + if (material_in_nodetree((bNodeTree *)node->id, mat)) return 1; } @@ -1043,7 +1043,7 @@ static int material_in_nodetree(bNodeTree *ntree, Material *mat) int material_in_material(Material *parmat, Material *mat) { - if (parmat==mat) + if (parmat == mat) return 1; else if (parmat->nodetree && parmat->use_nodes) return material_in_nodetree(parmat->nodetree, mat); @@ -1086,15 +1086,15 @@ void automatname(Material *ma) int nr, r, g, b; float ref; - if (ma==NULL) return; - if (ma->mode & MA_SHLESS) ref= 1.0; - else ref= ma->ref; - - r= (int)(4.99f*(ref*ma->r)); - g= (int)(4.99f*(ref*ma->g)); - b= (int)(4.99f*(ref*ma->b)); - nr= r + 5*g + 25*b; - if (nr>124) nr= 124; + if (ma == NULL) return; + if (ma->mode & MA_SHLESS) ref = 1.0; + else ref = ma->ref; + + r = (int)(4.99f * (ref * ma->r)); + g = (int)(4.99f * (ref * ma->g)); + b = (int)(4.99f * (ref * ma->b)); + nr = r + 5 * g + 25 * b; + if (nr > 124) nr = 124; new_id(&G.main->mat, (ID *)ma, colname_array[nr]); } @@ -1107,7 +1107,7 @@ int object_remove_material_slot(Object *ob) short *totcolp; short a, actcol; - if (ob==NULL || ob->totcol==0) { + if (ob == NULL || ob->totcol == 0) { return FALSE; } @@ -1124,54 +1124,54 @@ int object_remove_material_slot(Object *ob) * after that check indices in mesh/curve/mball!!! */ - totcolp= give_totcolp(ob); - matarar= give_matarar(ob); + totcolp = give_totcolp(ob); + matarar = give_matarar(ob); - if (*matarar==NULL) return FALSE; + if (*matarar == NULL) return FALSE; /* we delete the actcol */ - mao= (*matarar)[ob->actcol-1]; + mao = (*matarar)[ob->actcol - 1]; if (mao) mao->id.us--; - for (a=ob->actcol; atotcol; a++) - (*matarar)[a-1]= (*matarar)[a]; + for (a = ob->actcol; a < ob->totcol; a++) + (*matarar)[a - 1] = (*matarar)[a]; (*totcolp)--; - if (*totcolp==0) { + if (*totcolp == 0) { MEM_freeN(*matarar); - *matarar= NULL; + *matarar = NULL; } - actcol= ob->actcol; - obt= G.main->object.first; + actcol = ob->actcol; + obt = G.main->object.first; while (obt) { - if (obt->data==ob->data) { + if (obt->data == ob->data) { /* WATCH IT: do not use actcol from ob or from obt (can become zero) */ - mao= obt->mat[actcol-1]; + mao = obt->mat[actcol - 1]; if (mao) mao->id.us--; - for (a=actcol; atotcol; a++) { - obt->mat[a-1]= obt->mat[a]; - obt->matbits[a-1]= obt->matbits[a]; + for (a = actcol; a < obt->totcol; a++) { + obt->mat[a - 1] = obt->mat[a]; + obt->matbits[a - 1] = obt->matbits[a]; } obt->totcol--; - if (obt->actcol > obt->totcol) obt->actcol= obt->totcol; + if (obt->actcol > obt->totcol) obt->actcol = obt->totcol; - if (obt->totcol==0) { + if (obt->totcol == 0) { MEM_freeN(obt->mat); MEM_freeN(obt->matbits); - obt->mat= NULL; - obt->matbits= NULL; + obt->mat = NULL; + obt->matbits = NULL; } } - obt= obt->id.next; + obt = obt->id.next; } /* check indices from mesh */ if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) { - data_delete_material_index_id((ID *)ob->data, actcol-1); + data_delete_material_index_id((ID *)ob->data, actcol - 1); freedisplist(&ob->disp); } @@ -1182,253 +1182,253 @@ int object_remove_material_slot(Object *ob) /* r_col = current value, col = new value, fac==0 is no change */ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) { - float tmp, facm= 1.0f-fac; + float tmp, facm = 1.0f - fac; switch (type) { case MA_RAMP_BLEND: - r_col[0] = facm*(r_col[0]) + fac*col[0]; - r_col[1] = facm*(r_col[1]) + fac*col[1]; - r_col[2] = facm*(r_col[2]) + fac*col[2]; + r_col[0] = facm * (r_col[0]) + fac * col[0]; + r_col[1] = facm * (r_col[1]) + fac * col[1]; + r_col[2] = facm * (r_col[2]) + fac * col[2]; break; case MA_RAMP_ADD: - r_col[0] += fac*col[0]; - r_col[1] += fac*col[1]; - r_col[2] += fac*col[2]; + r_col[0] += fac * col[0]; + r_col[1] += fac * col[1]; + r_col[2] += fac * col[2]; break; case MA_RAMP_MULT: - r_col[0] *= (facm + fac*col[0]); - r_col[1] *= (facm + fac*col[1]); - r_col[2] *= (facm + fac*col[2]); + r_col[0] *= (facm + fac * col[0]); + r_col[1] *= (facm + fac * col[1]); + r_col[2] *= (facm + fac * col[2]); break; case MA_RAMP_SCREEN: - r_col[0] = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - r_col[0]); - r_col[1] = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - r_col[1]); - r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]); + r_col[0] = 1.0f - (facm + fac * (1.0f - col[0])) * (1.0f - r_col[0]); + r_col[1] = 1.0f - (facm + fac * (1.0f - col[1])) * (1.0f - r_col[1]); + r_col[2] = 1.0f - (facm + fac * (1.0f - col[2])) * (1.0f - r_col[2]); break; case MA_RAMP_OVERLAY: if (r_col[0] < 0.5f) - r_col[0] *= (facm + 2.0f*fac*col[0]); + r_col[0] *= (facm + 2.0f * fac * col[0]); else - r_col[0] = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - r_col[0]); + r_col[0] = 1.0f - (facm + 2.0f * fac * (1.0f - col[0])) * (1.0f - r_col[0]); if (r_col[1] < 0.5f) - r_col[1] *= (facm + 2.0f*fac*col[1]); + r_col[1] *= (facm + 2.0f * fac * col[1]); else - r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]); + r_col[1] = 1.0f - (facm + 2.0f * fac * (1.0f - col[1])) * (1.0f - r_col[1]); if (r_col[2] < 0.5f) - r_col[2] *= (facm + 2.0f*fac*col[2]); + r_col[2] *= (facm + 2.0f * fac * col[2]); else - r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]); + r_col[2] = 1.0f - (facm + 2.0f * fac * (1.0f - col[2])) * (1.0f - r_col[2]); break; case MA_RAMP_SUB: - r_col[0] -= fac*col[0]; - r_col[1] -= fac*col[1]; - r_col[2] -= fac*col[2]; + r_col[0] -= fac * col[0]; + r_col[1] -= fac * col[1]; + r_col[2] -= fac * col[2]; break; case MA_RAMP_DIV: - if (col[0]!=0.0f) - r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0]; - if (col[1]!=0.0f) - r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1]; - if (col[2]!=0.0f) - r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2]; + if (col[0] != 0.0f) + r_col[0] = facm * (r_col[0]) + fac * (r_col[0]) / col[0]; + if (col[1] != 0.0f) + r_col[1] = facm * (r_col[1]) + fac * (r_col[1]) / col[1]; + if (col[2] != 0.0f) + r_col[2] = facm * (r_col[2]) + fac * (r_col[2]) / col[2]; break; case MA_RAMP_DIFF: - r_col[0] = facm*(r_col[0]) + fac*fabsf(r_col[0]-col[0]); - r_col[1] = facm*(r_col[1]) + fac*fabsf(r_col[1]-col[1]); - r_col[2] = facm*(r_col[2]) + fac*fabsf(r_col[2]-col[2]); + r_col[0] = facm * (r_col[0]) + fac *fabsf(r_col[0] - col[0]); + r_col[1] = facm * (r_col[1]) + fac *fabsf(r_col[1] - col[1]); + r_col[2] = facm * (r_col[2]) + fac *fabsf(r_col[2] - col[2]); break; case MA_RAMP_DARK: - tmp=col[0]+((1-col[0])*facm); - if (tmp < r_col[0]) r_col[0]= tmp; - tmp=col[1]+((1-col[1])*facm); - if (tmp < r_col[1]) r_col[1]= tmp; - tmp=col[2]+((1-col[2])*facm); - if (tmp < r_col[2]) r_col[2]= tmp; + tmp = col[0] + ((1 - col[0]) * facm); + if (tmp < r_col[0]) r_col[0] = tmp; + tmp = col[1] + ((1 - col[1]) * facm); + if (tmp < r_col[1]) r_col[1] = tmp; + tmp = col[2] + ((1 - col[2]) * facm); + if (tmp < r_col[2]) r_col[2] = tmp; break; case MA_RAMP_LIGHT: - tmp= fac*col[0]; - if (tmp > r_col[0]) r_col[0]= tmp; - tmp= fac*col[1]; - if (tmp > r_col[1]) r_col[1]= tmp; - tmp= fac*col[2]; - if (tmp > r_col[2]) r_col[2]= tmp; - break; + tmp = fac * col[0]; + if (tmp > r_col[0]) r_col[0] = tmp; + tmp = fac * col[1]; + if (tmp > r_col[1]) r_col[1] = tmp; + tmp = fac * col[2]; + if (tmp > r_col[2]) r_col[2] = tmp; + break; case MA_RAMP_DODGE: if (r_col[0] != 0.0f) { - tmp = 1.0f - fac*col[0]; + tmp = 1.0f - fac * col[0]; if (tmp <= 0.0f) r_col[0] = 1.0f; - else if ((tmp = (r_col[0]) / tmp)> 1.0f) + else if ((tmp = (r_col[0]) / tmp) > 1.0f) r_col[0] = 1.0f; else r_col[0] = tmp; } if (r_col[1] != 0.0f) { - tmp = 1.0f - fac*col[1]; - if (tmp <= 0.0f ) + tmp = 1.0f - fac * col[1]; + if (tmp <= 0.0f) r_col[1] = 1.0f; - else if ((tmp = (r_col[1]) / tmp) > 1.0f ) + else if ((tmp = (r_col[1]) / tmp) > 1.0f) r_col[1] = 1.0f; else r_col[1] = tmp; } if (r_col[2] != 0.0f) { - tmp = 1.0f - fac*col[2]; + tmp = 1.0f - fac * col[2]; if (tmp <= 0.0f) r_col[2] = 1.0f; - else if ((tmp = (r_col[2]) / tmp) > 1.0f ) + else if ((tmp = (r_col[2]) / tmp) > 1.0f) r_col[2] = 1.0f; else r_col[2] = tmp; } break; case MA_RAMP_BURN: - tmp = facm + fac*col[0]; + tmp = facm + fac * col[0]; if (tmp <= 0.0f) r_col[0] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[0])) / tmp )) < 0.0f) - r_col[0] = 0.0f; + else if ((tmp = (1.0f - (1.0f - (r_col[0])) / tmp)) < 0.0f) + r_col[0] = 0.0f; else if (tmp > 1.0f) - r_col[0]=1.0f; + r_col[0] = 1.0f; else r_col[0] = tmp; - tmp = facm + fac*col[1]; + tmp = facm + fac * col[1]; if (tmp <= 0.0f) r_col[1] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f ) - r_col[1] = 0.0f; - else if (tmp >1.0f) - r_col[1]=1.0f; + else if ((tmp = (1.0f - (1.0f - (r_col[1])) / tmp)) < 0.0f) + r_col[1] = 0.0f; + else if (tmp > 1.0f) + r_col[1] = 1.0f; else r_col[1] = tmp; - tmp = facm + fac*col[2]; - if (tmp <= 0.0f) + tmp = facm + fac * col[2]; + if (tmp <= 0.0f) r_col[2] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f ) - r_col[2] = 0.0f; - else if (tmp >1.0f) - r_col[2]= 1.0f; + else if ((tmp = (1.0f - (1.0f - (r_col[2])) / tmp)) < 0.0f) + r_col[2] = 0.0f; + else if (tmp > 1.0f) + r_col[2] = 1.0f; else r_col[2] = tmp; break; case MA_RAMP_HUE: - { - float rH, rS, rV; - float colH, colS, colV; - float tmpr, tmpg, tmpb; - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - if (colS != 0) { - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb); - r_col[0] = facm*(r_col[0]) + fac*tmpr; - r_col[1] = facm*(r_col[1]) + fac*tmpg; - r_col[2] = facm*(r_col[2]) + fac*tmpb; - } + { + float rH, rS, rV; + float colH, colS, colV; + float tmpr, tmpg, tmpb; + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + if (colS != 0) { + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb); + r_col[0] = facm * (r_col[0]) + fac * tmpr; + r_col[1] = facm * (r_col[1]) + fac * tmpg; + r_col[2] = facm * (r_col[2]) + fac * tmpb; } - break; + } + break; case MA_RAMP_SAT: - { - float rH, rS, rV; - float colH, colS, colV; - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - if (rS != 0) { - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - hsv_to_rgb(rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2); - } + { + float rH, rS, rV; + float colH, colS, colV; + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + if (rS != 0) { + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + hsv_to_rgb(rH, (facm * rS + fac * colS), rV, r_col + 0, r_col + 1, r_col + 2); } - break; + } + break; case MA_RAMP_VAL: - { - float rH, rS, rV; - float colH, colS, colV; - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - hsv_to_rgb(rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2); - } - break; + { + float rH, rS, rV; + float colH, colS, colV; + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + hsv_to_rgb(rH, rS, (facm * rV + fac * colV), r_col + 0, r_col + 1, r_col + 2); + } + break; case MA_RAMP_COLOR: - { - float rH, rS, rV; - float colH, colS, colV; - float tmpr, tmpg, tmpb; - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - if (colS != 0) { - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb); - r_col[0] = facm*(r_col[0]) + fac*tmpr; - r_col[1] = facm*(r_col[1]) + fac*tmpg; - r_col[2] = facm*(r_col[2]) + fac*tmpb; - } + { + float rH, rS, rV; + float colH, colS, colV; + float tmpr, tmpg, tmpb; + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + if (colS != 0) { + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb); + r_col[0] = facm * (r_col[0]) + fac * tmpr; + r_col[1] = facm * (r_col[1]) + fac * tmpg; + r_col[2] = facm * (r_col[2]) + fac * tmpb; } - break; + } + break; case MA_RAMP_SOFT: - { - float scr, scg, scb; + { + float scr, scg, scb; - /* first calculate non-fac based Screen mix */ - scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]); - scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]); - scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]); + /* first calculate non-fac based Screen mix */ + scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]); + scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]); + scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]); - r_col[0] = facm*(r_col[0]) + fac*(((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr)); - r_col[1] = facm*(r_col[1]) + fac*(((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg)); - r_col[2] = facm*(r_col[2]) + fac*(((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb)); - } - break; + r_col[0] = facm * (r_col[0]) + fac * (((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr)); + r_col[1] = facm * (r_col[1]) + fac * (((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg)); + r_col[2] = facm * (r_col[2]) + fac * (((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb)); + } + break; case MA_RAMP_LINEAR: if (col[0] > 0.5f) - r_col[0] = r_col[0] + fac*(2.0f*(col[0]-0.5f)); + r_col[0] = r_col[0] + fac * (2.0f * (col[0] - 0.5f)); else - r_col[0] = r_col[0] + fac*(2.0f*(col[0]) - 1.0f); + r_col[0] = r_col[0] + fac * (2.0f * (col[0]) - 1.0f); if (col[1] > 0.5f) - r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f)); + r_col[1] = r_col[1] + fac * (2.0f * (col[1] - 0.5f)); else - r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f); + r_col[1] = r_col[1] + fac * (2.0f * (col[1]) - 1.0f); if (col[2] > 0.5f) - r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f)); + r_col[2] = r_col[2] + fac * (2.0f * (col[2] - 0.5f)); else - r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f); + r_col[2] = r_col[2] + fac * (2.0f * (col[2]) - 1.0f); break; } } /* copy/paste buffer, if we had a propper py api that would be better */ static Material matcopybuf; -static short matcopied= 0; +static short matcopied = 0; void clear_matcopybuf(void) { memset(&matcopybuf, 0, sizeof(Material)); - matcopied= 0; + matcopied = 0; } void free_matcopybuf(void) { int a; - for (a=0; anodetree); - matcopybuf.preview= NULL; - matcopybuf.gpumaterial.first= matcopybuf.gpumaterial.last= NULL; - matcopied= 1; + matcopybuf.nodetree = ntreeCopyTree(ma->nodetree); + matcopybuf.preview = NULL; + matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL; + matcopied = 1; } void paste_matcopybuf(Material *ma) @@ -1461,13 +1461,13 @@ void paste_matcopybuf(Material *ma) MTex *mtex; ID id; - if (matcopied==0) + if (matcopied == 0) return; /* free current mat */ if (ma->ramp_col) MEM_freeN(ma->ramp_col); if (ma->ramp_spec) MEM_freeN(ma->ramp_spec); - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = ma->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -1479,22 +1479,22 @@ void paste_matcopybuf(Material *ma) GPU_material_free(ma); - id= (ma->id); + id = (ma->id); memcpy(ma, &matcopybuf, sizeof(Material)); - (ma->id)= id; + (ma->id) = id; - if (matcopybuf.ramp_col) ma->ramp_col= MEM_dupallocN(matcopybuf.ramp_col); - if (matcopybuf.ramp_spec) ma->ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec); + if (matcopybuf.ramp_col) ma->ramp_col = MEM_dupallocN(matcopybuf.ramp_col); + if (matcopybuf.ramp_spec) ma->ramp_spec = MEM_dupallocN(matcopybuf.ramp_spec); - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = ma->mtex[a]; if (mtex) { - ma->mtex[a]= MEM_dupallocN(mtex); + ma->mtex[a] = MEM_dupallocN(mtex); if (mtex->tex) id_us_plus((ID *)mtex->tex); } } - ma->nodetree= ntreeCopyTree(matcopybuf.nodetree); + ma->nodetree = ntreeCopyTree(matcopybuf.nodetree); } @@ -1530,7 +1530,7 @@ static int encode_tfaceflag(MTFace *tf, int convertall) static void decode_tfaceflag(Material *ma, int flag, int convertall) { int alphablend; - GameSettings *game= &ma->game; + GameSettings *game = &ma->game; /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ flag -= 1; @@ -1539,7 +1539,7 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) (*game).flag = 0; /* General Material Options */ - if ((flag & TF_DYNAMIC)==0) (*game).flag |= GEMAT_NOPHYSICS; + if ((flag & TF_DYNAMIC) == 0) (*game).flag |= GEMAT_NOPHYSICS; /* Material Offline Rendering Properties */ if (convertall) { @@ -1547,8 +1547,8 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) } /* Special Face Properties */ - if ((flag & TF_TWOSIDE)==0) (*game).flag |= GEMAT_BACKCULL; - if (flag & TF_INVISIBLE)(*game).flag |= GEMAT_INVISIBLE; + if ((flag & TF_TWOSIDE) == 0) (*game).flag |= GEMAT_BACKCULL; + if (flag & TF_INVISIBLE) (*game).flag |= GEMAT_INVISIBLE; if (flag & TF_BMFONT) (*game).flag |= GEMAT_TEXT; /* Face Orientation */ @@ -1570,7 +1570,7 @@ static int check_tfaceneedmaterial(int flag) // also if only flags are visible and collision see if all objects using this mesh have this option in physics /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ - flag -=1; + flag -= 1; // deprecated flags flag &= ~TF_OBCOL; @@ -1597,11 +1597,11 @@ static int check_tfaceneedmaterial(int flag) // XXX to be optmized or replaced by an equivalent blender internal function static int integer_getdigits(int number) { - int i=0; + int i = 0; if (number == 0) return 1; while (number != 0) { - number = (int)(number/10); + number = (int)(number / 10); i++; } return i; @@ -1615,7 +1615,7 @@ static void calculate_tface_materialname(char *matname, char *newname, int flag) int digits = integer_getdigits(flag); /* clamp the old name, remove the MA prefix and add the .TF.flag suffix * e.g. matname = "MALoooooooooooooongName"; newname = "Loooooooooooooon.TF.2" */ - BLI_snprintf(newname, MAX_ID_NAME, "%.*s.TF.%0*d", MAX_ID_NAME-(digits+5), matname, digits, flag); + BLI_snprintf(newname, MAX_ID_NAME, "%.*s.TF.%0*d", MAX_ID_NAME - (digits + 5), matname, digits, flag); } /* returns -1 if no match */ @@ -1623,7 +1623,7 @@ static short mesh_getmaterialnumber(Mesh *me, Material *ma) { short a; - for (a=0; atotcol; a++) { + for (a = 0; a < me->totcol; a++) { if (me->mat[a] == ma) { return a; } @@ -1636,11 +1636,11 @@ static short mesh_getmaterialnumber(Mesh *me, Material *ma) static short mesh_addmaterial(Mesh *me, Material *ma) { material_append_id(&me->id, NULL); - me->mat[me->totcol-1]= ma; + me->mat[me->totcol - 1] = ma; id_us_plus(&ma->id); - return me->totcol-1; + return me->totcol - 1; } static void set_facetexture_flags(Material *ma, Image *image) @@ -1659,26 +1659,26 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) { Material *ma; char idname[MAX_ID_NAME]; - short mat_nr= -1; + short mat_nr = -1; /* new material, the name uses the flag*/ BLI_snprintf(idname, sizeof(idname), "MAMaterial.TF.%0*d", integer_getdigits(flag), flag); - if ((ma= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) { - mat_nr= mesh_getmaterialnumber(me, ma); + if ((ma = BLI_findstring(&main->mat, idname + 2, offsetof(ID, name) + 2))) { + mat_nr = mesh_getmaterialnumber(me, ma); /* assign the material to the mesh */ - if (mat_nr == -1) mat_nr= mesh_addmaterial(me, ma); + if (mat_nr == -1) mat_nr = mesh_addmaterial(me, ma); /* if needed set "Face Textures [Alpha]" Material options */ set_facetexture_flags(ma, tf->tpage); } /* create a new material */ else { - ma= BKE_material_add(idname+2); + ma = BKE_material_add(idname + 2); if (ma) { - printf("TexFace Convert: Material \"%s\" created.\n", idname+2); - mat_nr= mesh_addmaterial(me, ma); + printf("TexFace Convert: Material \"%s\" created.\n", idname + 2); + mat_nr = mesh_addmaterial(me, ma); /* if needed set "Face Textures [Alpha]" Material options */ set_facetexture_flags(ma, tf->tpage); @@ -1690,7 +1690,7 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) ma->game.flag = -flag; id_us_min((ID *)ma); } - else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname+2, me->id.name+2); + else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname + 2, me->id.name + 2); } /* set as converted, no need to go bad to this face */ @@ -1711,49 +1711,49 @@ static void convert_tfacematerial(Main *main, Material *ma) CustomDataLayer *cdl; char idname[MAX_ID_NAME]; - for (me=main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { /* check if this mesh uses this material */ - for (a=0;atotcol;a++) + for (a = 0; a < me->totcol; a++) if (me->mat[a] == ma) break; /* no material found */ if (a == me->totcol) continue; /* get the active tface layer */ - index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - cdl= (index == -1)? NULL: &me->fdata.layers[index]; + index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl = (index == -1) ? NULL : &me->fdata.layers[index]; if (!cdl) continue; /* loop over all the faces and stop at the ones that use the material*/ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (me->mat[mf->mat_nr] != ma) continue; /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; + tf = ((MTFace *)cdl->data) + a; flag = encode_tfaceflag(tf, 1); /* the name of the new material */ calculate_tface_materialname(ma->id.name, (char *)&idname, flag); - if ((mat_new= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) { + if ((mat_new = BLI_findstring(&main->mat, idname + 2, offsetof(ID, name) + 2))) { /* material already existent, see if the mesh has it */ mat_nr = mesh_getmaterialnumber(me, mat_new); /* material is not in the mesh, add it */ - if (mat_nr == -1) mat_nr= mesh_addmaterial(me, mat_new); + if (mat_nr == -1) mat_nr = mesh_addmaterial(me, mat_new); } /* create a new material */ else { - mat_new=BKE_material_copy(ma); + mat_new = BKE_material_copy(ma); if (mat_new) { /* rename the material*/ strcpy(mat_new->id.name, idname); id_us_min((ID *)mat_new); - mat_nr= mesh_addmaterial(me, mat_new); + mat_nr = mesh_addmaterial(me, mat_new); decode_tfaceflag(mat_new, flag, 1); } else { - printf("Error: Unable to create Material \"%s\" for Mesh \"%s.", idname+2, me->id.name+2); + printf("Error: Unable to create Material \"%s\" for Mesh \"%s.", idname + 2, me->id.name + 2); mat_nr = mf->mat_nr; continue; } @@ -1770,8 +1770,8 @@ static void convert_tfacematerial(Main *main, Material *ma) mf->mat_nr = mat_nr; } /* remove material from mesh */ - for (a=0;atotcol;) - if (me->mat[a] == ma) material_pop_id(&me->id, a, 1);else a++; + for (a = 0; a < me->totcol; ) + if (me->mat[a] == ma) material_pop_id(&me->id, a, 1); else a++; } } @@ -1805,20 +1805,20 @@ int do_version_tface(Main *main, int fileload) */ /* 1st part: marking mesh materials to update */ - for (me=main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { if (me->id.lib) continue; /* get the active tface layer */ - index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - cdl= (index == -1)? NULL: &me->fdata.layers[index]; + index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl = (index == -1) ? NULL : &me->fdata.layers[index]; if (!cdl) continue; - nomaterialslots = (me->totcol==0?1:0); + nomaterialslots = (me->totcol == 0 ? 1 : 0); /* loop over all the faces*/ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; + tf = ((MTFace *)cdl->data) + a; /* conversion should happen only once */ if (fileload) @@ -1834,7 +1834,7 @@ int do_version_tface(Main *main, int fileload) /* create/find a new material and assign to the face */ if (check_tfaceneedmaterial(flag)) { - mf->mat_nr= convert_tfacenomaterial(main, me, tf, flag); + mf->mat_nr = convert_tfacenomaterial(main, me, tf, flag); } /* else mark them as no-material to be reverted to 0 later */ else { @@ -1842,7 +1842,7 @@ int do_version_tface(Main *main, int fileload) } } else if (mf->mat_nr < me->totcol) { - ma= me->mat[mf->mat_nr]; + ma = me->mat[mf->mat_nr]; /* no material create one if necessary */ if (!ma) { @@ -1851,7 +1851,7 @@ int do_version_tface(Main *main, int fileload) /* create/find a new material and assign to the face */ if (check_tfaceneedmaterial(flag)) - mf->mat_nr= convert_tfacenomaterial(main, me, tf, flag); + mf->mat_nr = convert_tfacenomaterial(main, me, tf, flag); continue; } @@ -1869,11 +1869,11 @@ int do_version_tface(Main *main, int fileload) /* found a material */ else { - flag = encode_tfaceflag(tf, ((fileload)?0:1)); + flag = encode_tfaceflag(tf, ((fileload) ? 0 : 1)); /* first time changing this material */ if (ma->game.flag == 0) - ma->game.flag= -flag; + ma->game.flag = -flag; /* mark material as disputed */ else if (ma->game.flag != -flag) { @@ -1902,18 +1902,18 @@ int do_version_tface(Main *main, int fileload) /* if we didn't have material slot and now we do, we need to * make sure the materials are correct */ if (nomaterialslots) { - if (me->totcol>0) { - for (a=0, mf=me->mface; atotface; a++, mf++) { + if (me->totcol > 0) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (mf->mat_nr == -1) { /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; - mf->mat_nr= convert_tfacenomaterial(main, me, tf, encode_tfaceflag(tf, 1)); + tf = ((MTFace *)cdl->data) + a; + mf->mat_nr = convert_tfacenomaterial(main, me, tf, encode_tfaceflag(tf, 1)); } } } else { - for (a=0, mf=me->mface; atotface; a++, mf++) { - mf->mat_nr=0; + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { + mf->mat_nr = 0; } } } @@ -1924,14 +1924,14 @@ int do_version_tface(Main *main, int fileload) /* skip library files */ /* we shouldn't loop through the materials created in the loop. make the loop stop at its original length) */ - for (ma= main->mat.first, a=0; ma; ma= ma->id.next, a++) { + for (ma = main->mat.first, a = 0; ma; ma = ma->id.next, a++) { if (ma->id.lib) continue; /* disputed material */ if (ma->game.flag == MAT_BGE_DISPUTED) { ma->game.flag = 0; if (fileload) { - printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name+2); + printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name + 2); nowarning = 0; } else @@ -1947,24 +1947,24 @@ int do_version_tface(Main *main, int fileload) /* material is good make sure all faces using * this material are set to converted */ if (fileload) { - for (me=main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { /* check if this mesh uses this material */ - for (a=0;atotcol;a++) + for (a = 0; a < me->totcol; a++) if (me->mat[a] == ma) break; /* no material found */ if (a == me->totcol) continue; /* get the active tface layer */ - index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - cdl= (index == -1)? NULL: &me->fdata.layers[index]; + index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl = (index == -1) ? NULL : &me->fdata.layers[index]; if (!cdl) continue; /* loop over all the faces and stop at the ones that use the material*/ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (me->mat[mf->mat_nr] == ma) { /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; + tf = ((MTFace *)cdl->data) + a; tf->mode |= TF_CONVERTED; } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index be6459bac90..ba0efe5fbba 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -67,67 +67,67 @@ /* Data types */ -typedef struct point { /* a three-dimensional point */ - float x, y, z; /* its coordinates */ +typedef struct point { /* a three-dimensional point */ + float x, y, z; /* its coordinates */ } MB_POINT; -typedef struct vertex { /* surface vertex */ - MB_POINT position, normal; /* position and surface normal */ +typedef struct vertex { /* surface vertex */ + MB_POINT position, normal; /* position and surface normal */ } VERTEX; -typedef struct vertices { /* list of vertices in polygonization */ - int count, max; /* # vertices, max # allowed */ - VERTEX *ptr; /* dynamically allocated */ +typedef struct vertices { /* list of vertices in polygonization */ + int count, max; /* # vertices, max # allowed */ + VERTEX *ptr; /* dynamically allocated */ } VERTICES; -typedef struct corner { /* corner of a cube */ - int i, j, k; /* (i, j, k) is index within lattice */ - float x, y, z, value; /* location and function value */ +typedef struct corner { /* corner of a cube */ + int i, j, k; /* (i, j, k) is index within lattice */ + float x, y, z, value; /* location and function value */ struct corner *next; } CORNER; -typedef struct cube { /* partitioning cell (cube) */ - int i, j, k; /* lattice location of cube */ - CORNER *corners[8]; /* eight corners */ +typedef struct cube { /* partitioning cell (cube) */ + int i, j, k; /* lattice location of cube */ + CORNER *corners[8]; /* eight corners */ } CUBE; -typedef struct cubes { /* linked list of cubes acting as stack */ - CUBE cube; /* a single cube */ - struct cubes *next; /* remaining elements */ +typedef struct cubes { /* linked list of cubes acting as stack */ + CUBE cube; /* a single cube */ + struct cubes *next; /* remaining elements */ } CUBES; -typedef struct centerlist { /* list of cube locations */ - int i, j, k; /* cube location */ - struct centerlist *next; /* remaining elements */ +typedef struct centerlist { /* list of cube locations */ + int i, j, k; /* cube location */ + struct centerlist *next; /* remaining elements */ } CENTERLIST; -typedef struct edgelist { /* list of edges */ - int i1, j1, k1, i2, j2, k2; /* edge corner ids */ - int vid; /* vertex id */ - struct edgelist *next; /* remaining elements */ +typedef struct edgelist { /* list of edges */ + int i1, j1, k1, i2, j2, k2; /* edge corner ids */ + int vid; /* vertex id */ + struct edgelist *next; /* remaining elements */ } EDGELIST; -typedef struct intlist { /* list of integers */ - int i; /* an integer */ - struct intlist *next; /* remaining elements */ +typedef struct intlist { /* list of integers */ + int i; /* an integer */ + struct intlist *next; /* remaining elements */ } INTLIST; -typedef struct intlists { /* list of list of integers */ - INTLIST *list; /* a list of integers */ - struct intlists *next; /* remaining elements */ +typedef struct intlists { /* list of list of integers */ + INTLIST *list; /* a list of integers */ + struct intlists *next; /* remaining elements */ } INTLISTS; -typedef struct process { /* parameters, function, storage */ +typedef struct process { /* parameters, function, storage */ /* what happens here? floats, I think. */ /* float (*function)(void); */ /* implicit surface function */ float (*function)(float, float, float); - float size, delta; /* cube size, normal delta */ - int bounds; /* cube range within lattice */ - CUBES *cubes; /* active cubes */ - VERTICES vertices; /* surface vertices */ - CENTERLIST **centers; /* cube center hash table */ - CORNER **corners; /* corner value hash table */ - EDGELIST **edges; /* edge and vertex id hash table */ + float size, delta; /* cube size, normal delta */ + int bounds; /* cube range within lattice */ + CUBES *cubes; /* active cubes */ + VERTICES vertices; /* surface vertices */ + CENTERLIST **centers; /* cube center hash table */ + CORNER **corners; /* corner value hash table */ + EDGELIST **edges; /* edge and vertex id hash table */ } PROCESS; /* dividing scene using octal tree makes polygonisation faster */ @@ -137,20 +137,20 @@ typedef struct ml_pointer { } ml_pointer; typedef struct octal_node { - struct octal_node *nodes[8]; /* children of current node */ - struct octal_node *parent; /* parent of current node */ - struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ - float x_min, y_min, z_min; /* 1st border point */ - float x_max, y_max, z_max; /* 7th border point */ - float x, y, z; /* center of node */ - int pos, neg; /* number of positive and negative MetaElements in the node */ - int count; /* number of MetaElems, which belongs to the node */ + struct octal_node *nodes[8];/* children of current node */ + struct octal_node *parent; /* parent of current node */ + struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ + float x_min, y_min, z_min; /* 1st border point */ + float x_max, y_max, z_max; /* 7th border point */ + float x, y, z; /* center of node */ + int pos, neg; /* number of positive and negative MetaElements in the node */ + int count; /* number of MetaElems, which belongs to the node */ } octal_node; typedef struct octal_tree { - struct octal_node *first; /* first node */ - int pos, neg; /* number of positive and negative MetaElements in the scene */ - short depth; /* number of scene subdivision */ + struct octal_node *first; /* first node */ + int pos, neg; /* number of positive and negative MetaElements in the scene */ + short depth; /* number of scene subdivision */ } octal_tree; struct pgn_elements { @@ -161,14 +161,14 @@ struct pgn_elements { /* Forward declarations */ static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb); static int setcenter(CENTERLIST *table[], int i, int j, int k); -static CORNER *setcorner(PROCESS* p, int i, int j, int k); -static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, - float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f); +static CORNER *setcorner(PROCESS *p, int i, int j, int k); +static void converge(MB_POINT *p1, MB_POINT *p2, float v1, float v2, + float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f); /* Global variables */ -static float thresh= 0.6f; -static int totelem=0; +static float thresh = 0.6f; +static int totelem = 0; static MetaElem **mainb; static octal_tree *metaball_tree = NULL; /* Functions */ @@ -177,9 +177,9 @@ void BKE_metaball_unlink(MetaBall *mb) { int a; - for (a=0; atotcol; a++) { + for (a = 0; a < mb->totcol; a++) { if (mb->mat[a]) mb->mat[a]->id.us--; - mb->mat[a]= NULL; + mb->mat[a] = NULL; } } @@ -203,14 +203,14 @@ MetaBall *BKE_metaball_add(const char *name) { MetaBall *mb; - mb= BKE_libblock_alloc(&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; + mb->size[0] = mb->size[1] = mb->size[2] = 1.0; + mb->texflag = MB_AUTOSPACE; - mb->wiresize= 0.4f; - mb->rendersize= 0.2f; - mb->thresh= 0.6f; + mb->wiresize = 0.4f; + mb->rendersize = 0.2f; + mb->thresh = 0.6f; return mb; } @@ -220,18 +220,18 @@ MetaBall *BKE_metaball_copy(MetaBall *mb) MetaBall *mbn; int a; - mbn= BKE_libblock_copy(&mb->id); + mbn = BKE_libblock_copy(&mb->id); BLI_duplicatelist(&mbn->elems, &mb->elems); - mbn->mat= MEM_dupallocN(mb->mat); - for (a=0; atotcol; a++) { + mbn->mat = MEM_dupallocN(mb->mat); + for (a = 0; a < mbn->totcol; a++) { id_us_plus((ID *)mbn->mat[a]); } - mbn->bb= MEM_dupallocN(mb->bb); + mbn->bb = MEM_dupallocN(mb->bb); - mbn->editelems= NULL; - mbn->lastelem= NULL; + mbn->editelems = NULL; + mbn->lastelem = NULL; return mbn; } @@ -245,27 +245,27 @@ static void extern_local_mball(MetaBall *mb) void BKE_metaball_make_local(MetaBall *mb) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (mb->id.lib==NULL) return; - if (mb->id.us==1) { + if (mb->id.lib == NULL) return; + if (mb->id.us == 1) { id_clear_lib_data(bmain, &mb->id); extern_local_mball(mb); return; } - for (ob= G.main->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + for (ob = G.main->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { if (ob->data == mb) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -274,16 +274,16 @@ void BKE_metaball_make_local(MetaBall *mb) extern_local_mball(mb); } else if (is_local && is_lib) { - MetaBall *mb_new= BKE_metaball_copy(mb); - mb_new->id.us= 0; + MetaBall *mb_new = BKE_metaball_copy(mb); + mb_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, mb->id.lib, &mb_new->id); - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { if (ob->data == mb) { - if (ob->id.lib==NULL) { - ob->data= mb_new; + if (ob->id.lib == NULL) { + ob->data = mb_new; mb_new->id.us++; mb->id.us--; } @@ -296,44 +296,44 @@ void BKE_metaball_make_local(MetaBall *mb) * don't do context manipulation here (rna uses) */ MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) { - MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem"); + MetaElem *ml = MEM_callocN(sizeof(MetaElem), "metaelem"); unit_qt(ml->quat); - ml->rad= 2.0; - ml->s= 2.0; - ml->flag= MB_SCALE_RAD; + ml->rad = 2.0; + ml->s = 2.0; + ml->flag = MB_SCALE_RAD; switch (type) { - case MB_BALL: - ml->type = MB_BALL; - ml->expx= ml->expy= ml->expz= 1.0; + case MB_BALL: + ml->type = MB_BALL; + ml->expx = ml->expy = ml->expz = 1.0; - break; - case MB_TUBE: - ml->type = MB_TUBE; - ml->expx= ml->expy= ml->expz= 1.0; + break; + case MB_TUBE: + ml->type = MB_TUBE; + ml->expx = ml->expy = ml->expz = 1.0; - break; - case MB_PLANE: - ml->type = MB_PLANE; - ml->expx= ml->expy= ml->expz= 1.0; + break; + case MB_PLANE: + ml->type = MB_PLANE; + ml->expx = ml->expy = ml->expz = 1.0; - break; - case MB_ELIPSOID: - ml->type = MB_ELIPSOID; - ml->expx= 1.2f; - ml->expy= 0.8f; - ml->expz= 1.0; - - break; - case MB_CUBE: - ml->type = MB_CUBE; - ml->expx= ml->expy= ml->expz= 1.0; + break; + case MB_ELIPSOID: + ml->type = MB_ELIPSOID; + ml->expx = 1.2f; + ml->expy = 0.8f; + ml->expz = 1.0; - break; - default: - break; + break; + case MB_CUBE: + ml->type = MB_CUBE; + ml->expx = ml->expy = ml->expz = 1.0; + + break; + default: + break; } BLI_addtail(&mb->elems, ml); @@ -351,27 +351,27 @@ void BKE_metaball_texspace_calc(Object *ob) DispList *dl; BoundBox *bb; float *data, min[3], max[3] /*, loc[3], size[3] */; - int tot, doit=0; + int tot, doit = 0; - if (ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox"); - bb= ob->bb; + if (ob->bb == NULL) ob->bb = MEM_callocN(sizeof(BoundBox), "mb boundbox"); + bb = ob->bb; /* Weird one, this. */ -/* INIT_MINMAX(min, max); */ - (min)[0]= (min)[1]= (min)[2]= 1.0e30f; - (max)[0]= (max)[1]= (max)[2]= -1.0e30f; +/* INIT_MINMAX(min, max); */ + (min)[0] = (min)[1] = (min)[2] = 1.0e30f; + (max)[0] = (max)[1] = (max)[2] = -1.0e30f; - dl= ob->disp.first; + dl = ob->disp.first; while (dl) { - tot= dl->nr; - if (tot) doit= 1; - data= dl->verts; + tot = dl->nr; + if (tot) doit = 1; + data = dl->verts; while (tot--) { /* Also weird... but longer. From utildefines. */ DO_MINMAX(data, min, max); - data+= 3; + data += 3; } - dl= dl->next; + dl = dl->next; } if (!doit) { @@ -379,13 +379,13 @@ void BKE_metaball_texspace_calc(Object *ob) max[0] = max[1] = max[2] = 1.0f; } #if 0 - loc[0]= (min[0]+max[0])/2.0f; - loc[1]= (min[1]+max[1])/2.0f; - loc[2]= (min[2]+max[2])/2.0f; - - size[0]= (max[0]-min[0])/2.0f; - size[1]= (max[1]-min[1])/2.0f; - size[2]= (max[2]-min[2])/2.0f; + loc[0] = (min[0] + max[0]) / 2.0f; + loc[1] = (min[1] + max[1]) / 2.0f; + loc[2] = (min[2] + max[2]) / 2.0f; + + size[0] = (max[0] - min[0]) / 2.0f; + size[1] = (max[1] - min[1]) / 2.0f; + size[2] = (max[2] - min[2]) / 2.0f; #endif BKE_boundbox_init_from_minmax(bb, min, max); } @@ -399,27 +399,27 @@ float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) int a; /* restore size and loc */ - bb= ob->bb; - loc[0]= (bb->vec[0][0]+bb->vec[4][0])/2.0f; - size[0]= bb->vec[4][0]-loc[0]; - loc[1]= (bb->vec[0][1]+bb->vec[2][1])/2.0f; - size[1]= bb->vec[2][1]-loc[1]; - loc[2]= (bb->vec[0][2]+bb->vec[1][2])/2.0f; - size[2]= bb->vec[1][2]-loc[2]; + bb = ob->bb; + loc[0] = (bb->vec[0][0] + bb->vec[4][0]) / 2.0f; + size[0] = bb->vec[4][0] - loc[0]; + loc[1] = (bb->vec[0][1] + bb->vec[2][1]) / 2.0f; + size[1] = bb->vec[2][1] - loc[1]; + loc[2] = (bb->vec[0][2] + bb->vec[1][2]) / 2.0f; + size[2] = bb->vec[1][2] - loc[2]; - dl= dispbase->first; - orcodata= MEM_mallocN(sizeof(float)*3*dl->nr, "MballOrco"); + dl = dispbase->first; + orcodata = MEM_mallocN(sizeof(float) * 3 * dl->nr, "MballOrco"); - data= dl->verts; - orco= orcodata; - a= dl->nr; + data = dl->verts; + orco = orcodata; + a = dl->nr; while (a--) { - orco[0]= (data[0]-loc[0])/size[0]; - orco[1]= (data[1]-loc[1])/size[1]; - orco[2]= (data[2]-loc[2])/size[2]; + orco[0] = (data[0] - loc[0]) / size[0]; + orco[1] = (data[1] - loc[1]) / size[1]; + orco[2] = (data[2] - loc[2]) / size[2]; - data+= 3; - orco+= 3; + data += 3; + orco += 3; } return orcodata; @@ -447,8 +447,8 @@ int BKE_metaball_is_basis(Object *ob) int len; /* just a quick test */ - len= strlen(ob->id.name); - if ( isdigit(ob->id.name[len-1]) ) return 0; + len = strlen(ob->id.name); + if (isdigit(ob->id.name[len - 1]) ) return 0; return 1; } @@ -458,8 +458,8 @@ int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) int basis1nr, basis2nr; char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; - BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.'); - BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.'); + BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.'); + BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.'); if (!strcmp(basis1name, basis2name)) return BKE_metaball_is_basis(ob1); else return 0; @@ -473,34 +473,34 @@ int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) * because this metaball influence polygonisation of metaballs. */ void BKE_metaball_properties_copy(Scene *scene, Object *active_object) { - Scene *sce_iter= scene; + Scene *sce_iter = scene; Base *base; Object *ob; - MetaBall *active_mball = (MetaBall*)active_object->data; + MetaBall *active_mball = (MetaBall *)active_object->data; int basisnr, obnr; char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; - BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.'); + BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.'); /* 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)) + if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL)) return; while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) { - if (ob->type==OB_MBALL) { + if (ob->type == OB_MBALL) { if (ob != active_object) { - BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); + BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* Object ob has to be in same "group" ... it means, that it has to have * same base of its name */ - if (strcmp(obname, basisname)==0) { - MetaBall *mb= ob->data; + if (strcmp(obname, basisname) == 0) { + MetaBall *mb = ob->data; /* Copy properties from selected/edited metaball */ - mb->wiresize= active_mball->wiresize; - mb->rendersize= active_mball->rendersize; - mb->thresh= active_mball->thresh; - mb->flag= active_mball->flag; + mb->wiresize = active_mball->wiresize; + mb->rendersize = active_mball->rendersize; + mb->thresh = active_mball->thresh; + mb->flag = active_mball->flag; } } } @@ -518,50 +518,50 @@ void BKE_metaball_properties_copy(Scene *scene, Object *active_object) */ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) { - Scene *sce_iter= scene; + Scene *sce_iter = scene; Base *base; - Object *ob, *bob= basis; - MetaElem *ml=NULL; + Object *ob, *bob = basis; + MetaElem *ml = NULL; int basisnr, obnr; char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; - BLI_split_name_num(basisname, &basisnr, basis->id.name+2, '.'); - totelem= 0; + BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.'); + totelem = 0; /* 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)) + if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL)) return NULL; while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) { - if (ob->type==OB_MBALL) { - if (ob==bob) { - MetaBall *mb= ob->data; + if (ob->type == OB_MBALL) { + if (ob == bob) { + MetaBall *mb = ob->data; /* if bob object is in edit mode, then dynamic list of all MetaElems * is stored in editelems */ - if (mb->editelems) ml= mb->editelems->first; + if (mb->editelems) ml = mb->editelems->first; /* if bob object is in object mode */ - else ml= mb->elems.first; + else ml = mb->elems.first; } else { - BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); + BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* object ob has to be in same "group" ... it means, that it has to have * same base of its name */ - if (strcmp(obname, basisname)==0) { - MetaBall *mb= ob->data; + if (strcmp(obname, basisname) == 0) { + MetaBall *mb = ob->data; /* if object is in edit mode, then dynamic list of all MetaElems * is stored in editelems */ - if (mb->editelems) ml= mb->editelems->first; + if (mb->editelems) ml = mb->editelems->first; /* if bob object is in object mode */ - else ml= mb->elems.first; + else ml = mb->elems.first; if (obnr < basisnr) { if (!(ob->flag & OB_FROMDUPLI)) { - basis= ob; - basisnr= obnr; + basis = ob; + basisnr = obnr; } } } @@ -569,7 +569,7 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) while (ml) { if (!(ml->flag & MB_HIDE)) totelem++; - ml= ml->next; + ml = ml->next; } } } @@ -591,33 +591,33 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) * Permission is granted to reproduce, use and distribute this code for * any and all purposes, provided that this notice appears in all copies. */ -#define RES 12 /* # converge iterations */ +#define RES 12 /* # converge iterations */ -#define L 0 /* left direction: -x, -i */ -#define R 1 /* right direction: +x, +i */ -#define B 2 /* bottom direction: -y, -j */ -#define T 3 /* top direction: +y, +j */ -#define N 4 /* near direction: -z, -k */ -#define F 5 /* far direction: +z, +k */ -#define LBN 0 /* left bottom near corner */ -#define LBF 1 /* left bottom far corner */ -#define LTN 2 /* left top near corner */ -#define LTF 3 /* left top far corner */ -#define RBN 4 /* right bottom near corner */ -#define RBF 5 /* right bottom far corner */ -#define RTN 6 /* right top near corner */ -#define RTF 7 /* right top far corner */ +#define L 0 /* left direction: -x, -i */ +#define R 1 /* right direction: +x, +i */ +#define B 2 /* bottom direction: -y, -j */ +#define T 3 /* top direction: +y, +j */ +#define N 4 /* near direction: -z, -k */ +#define F 5 /* far direction: +z, +k */ +#define LBN 0 /* left bottom near corner */ +#define LBF 1 /* left bottom far corner */ +#define LTN 2 /* left top near corner */ +#define LTF 3 /* left top far corner */ +#define RBN 4 /* right bottom near corner */ +#define RBF 5 /* right bottom far corner */ +#define RTN 6 /* right top near corner */ +#define RTF 7 /* right top far corner */ /* the LBN corner of cube (i, j, k), corresponds with location * (i-0.5)*size, (j-0.5)*size, (k-0.5)*size) */ -#define HASHBIT (5) -#define HASHSIZE (size_t)(1<<(3*HASHBIT)) /*! < hash table size (32768) */ +#define HASHBIT (5) +#define HASHSIZE (size_t)(1 << (3 * HASHBIT)) /*! < hash table size (32768) */ -#define HASH(i, j, k) ((((( (i) & 31)<<5) | ( (j) & 31))<<5 ) | ( (k) & 31) ) +#define HASH(i, j, k) ((((( (i) & 31) << 5) | ( (j) & 31)) << 5) | ( (k) & 31) ) -#define MB_BIT(i, bit) (((i)>>(bit))&1) -#define FLIP(i, bit) ((i)^1<<(bit)) /* flip the given bit of i */ +#define MB_BIT(i, bit) (((i) >> (bit)) & 1) +#define FLIP(i, bit) ((i) ^ 1 << (bit)) /* flip the given bit of i */ /* **************** POLYGONIZATION ************************ */ @@ -634,78 +634,78 @@ static float densfunc(MetaElem *ball, float x, float y, float z) float dist2 = 0.0, dx, dy, dz; float vec[3]; - vec[0]= x; - vec[1]= y; - vec[2]= z; + vec[0] = x; + vec[1] = y; + vec[2] = z; mul_m4_v3((float (*)[4])ball->imat, vec); - dx= vec[0]; - dy= vec[1]; - dz= vec[2]; - - if (ball->type==MB_BALL) { + dx = vec[0]; + dy = vec[1]; + dz = vec[2]; + + if (ball->type == MB_BALL) { } - else if (ball->type==MB_TUBEX) { - if ( dx > ball->len) dx-= ball->len; - else if (dx< -ball->len) dx+= ball->len; - else dx= 0.0; + else if (ball->type == MB_TUBEX) { + if (dx > ball->len) dx -= ball->len; + else if (dx < -ball->len) dx += ball->len; + else dx = 0.0; } - else if (ball->type==MB_TUBEY) { - if ( dy > ball->len) dy-= ball->len; - else if (dy< -ball->len) dy+= ball->len; - else dy= 0.0; + else if (ball->type == MB_TUBEY) { + if (dy > ball->len) dy -= ball->len; + else if (dy < -ball->len) dy += ball->len; + else dy = 0.0; } - else if (ball->type==MB_TUBEZ) { - if ( dz > ball->len) dz-= ball->len; - else if (dz< -ball->len) dz+= ball->len; - else dz= 0.0; + else if (ball->type == MB_TUBEZ) { + if (dz > ball->len) dz -= ball->len; + else if (dz < -ball->len) dz += ball->len; + else dz = 0.0; } - else if (ball->type==MB_TUBE) { - if ( dx > ball->expx) dx-= ball->expx; - else if (dx< -ball->expx) dx+= ball->expx; - else dx= 0.0; + else if (ball->type == MB_TUBE) { + if (dx > ball->expx) dx -= ball->expx; + else if (dx < -ball->expx) dx += ball->expx; + else dx = 0.0; } - else if (ball->type==MB_PLANE) { - if ( dx > ball->expx) dx-= ball->expx; - else if (dx< -ball->expx) dx+= ball->expx; - else dx= 0.0; - if ( dy > ball->expy) dy-= ball->expy; - else if (dy< -ball->expy) dy+= ball->expy; - else dy= 0.0; + else if (ball->type == MB_PLANE) { + if (dx > ball->expx) dx -= ball->expx; + else if (dx < -ball->expx) dx += ball->expx; + else dx = 0.0; + if (dy > ball->expy) dy -= ball->expy; + else if (dy < -ball->expy) dy += ball->expy; + else dy = 0.0; } - else if (ball->type==MB_ELIPSOID) { - dx *= 1/ball->expx; - dy *= 1/ball->expy; - dz *= 1/ball->expz; + else if (ball->type == MB_ELIPSOID) { + dx *= 1 / ball->expx; + dy *= 1 / ball->expy; + dz *= 1 / ball->expz; } - else if (ball->type==MB_CUBE) { - if ( dx > ball->expx) dx-= ball->expx; - else if (dx< -ball->expx) dx+= ball->expx; - else dx= 0.0; - if ( dy > ball->expy) dy-= ball->expy; - else if (dy< -ball->expy) dy+= ball->expy; - else dy= 0.0; - if ( dz > ball->expz) dz-= ball->expz; - else if (dz< -ball->expz) dz+= ball->expz; - else dz= 0.0; + else if (ball->type == MB_CUBE) { + if (dx > ball->expx) dx -= ball->expx; + else if (dx < -ball->expx) dx += ball->expx; + else dx = 0.0; + if (dy > ball->expy) dy -= ball->expy; + else if (dy < -ball->expy) dy += ball->expy; + else dy = 0.0; + if (dz > ball->expz) dz -= ball->expz; + else if (dz < -ball->expz) dz += ball->expz; + else dz = 0.0; } - dist2= (dx*dx + dy*dy + dz*dz); + dist2 = (dx * dx + dy * dy + dz * dz); if (ball->flag & MB_NEGATIVE) { - dist2= 1.0f-(dist2/ball->rad2); + dist2 = 1.0f - (dist2 / ball->rad2); if (dist2 < 0.0f) return 0.5f; - return 0.5f-ball->s*dist2*dist2*dist2; + return 0.5f - ball->s * dist2 * dist2 * dist2; } else { - dist2= 1.0f-(dist2/ball->rad2); + dist2 = 1.0f - (dist2 / ball->rad2); if (dist2 < 0.0f) return -0.5f; - return ball->s*dist2*dist2*dist2 -0.5f; + return ball->s * dist2 * dist2 * dist2 - 0.5f; } } -static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth) +static octal_node *find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth) { if (!depth) return node; @@ -778,24 +778,24 @@ static float metaball(float x, float y, float z) { struct octal_node *node; struct ml_pointer *ml_p; - float dens=0; + float dens = 0; int a; if (totelem > 1) { - node= find_metaball_octal_node(metaball_tree->first, x, y, z, metaball_tree->depth); + node = find_metaball_octal_node(metaball_tree->first, x, y, z, metaball_tree->depth); if (node) { - ml_p= node->elems.first; + ml_p = node->elems.first; while (ml_p) { - dens+=densfunc(ml_p->ml, x, y, z); - ml_p= ml_p->next; + dens += densfunc(ml_p->ml, x, y, z); + ml_p = ml_p->next; } - dens+= -0.5f*(metaball_tree->pos - node->pos); - dens+= 0.5f*(metaball_tree->neg - node->neg); + dens += -0.5f * (metaball_tree->pos - node->pos); + dens += 0.5f * (metaball_tree->neg - node->neg); } else { - for (a=0; a10000 || size==0) { + if (size > 10000 || size == 0) { printf("incorrect use of new_pgn_element\n"); } - else if (size== -1) { - cur= lb.first; + else if (size == -1) { + cur = lb.first; while (cur) { MEM_freeN(cur->data); - cur= cur->next; + cur = cur->next; } BLI_freelistN(&lb); return NULL; } - size= 4*( (size+3)/4 ); + size = 4 * ( (size + 3) / 4); if (cur) { - if (size+offs < blocksize) { - adr= (void *) (cur->data+offs); - offs+= size; + if (size + offs < blocksize) { + adr = (void *) (cur->data + offs); + offs += size; return adr; } } - cur= MEM_callocN(sizeof(struct pgn_elements), "newpgn"); - cur->data= MEM_callocN(blocksize, "newpgn"); + cur = MEM_callocN(sizeof(struct pgn_elements), "newpgn"); + cur->data = MEM_callocN(blocksize, "newpgn"); BLI_addtail(&lb, cur); - offs= size; + offs = size; return cur->data; } @@ -902,31 +902,35 @@ static void freepolygonize(PROCESS *p) /**** Cubical Polygonization (optional) ****/ -#define LB 0 /* left bottom edge */ -#define LT 1 /* left top edge */ -#define LN 2 /* left near edge */ -#define LF 3 /* left far edge */ -#define RB 4 /* right bottom edge */ -#define RT 5 /* right top edge */ -#define RN 6 /* right near edge */ -#define RF 7 /* right far edge */ -#define BN 8 /* bottom near edge */ -#define BF 9 /* bottom far edge */ -#define TN 10 /* top near edge */ -#define TF 11 /* top far edge */ +#define LB 0 /* left bottom edge */ +#define LT 1 /* left top edge */ +#define LN 2 /* left near edge */ +#define LF 3 /* left far edge */ +#define RB 4 /* right bottom edge */ +#define RT 5 /* right top edge */ +#define RN 6 /* right near edge */ +#define RF 7 /* right far edge */ +#define BN 8 /* bottom near edge */ +#define BF 9 /* bottom far edge */ +#define TN 10 /* top near edge */ +#define TF 11 /* top far edge */ static INTLISTS *cubetable[256]; /* edge: LB, LT, LN, LF, RB, RT, RN, RF, BN, BF, TN, TF */ -static int corner1[12] = { - LBN, LTN, LBN, LBF, RBN, RTN, RBN, RBF, LBN, LBF, LTN, LTF}; -static int corner2[12] = { - LBF, LTF, LTN, LTF, RBF, RTF, RTN, RTF, RBN, RBF, RTN, RTF}; -static int leftface[12] = { - B, L, L, F, R, T, N, R, N, B, T, F}; +static int corner1[12] = { + LBN, LTN, LBN, LBF, RBN, RTN, RBN, RBF, LBN, LBF, LTN, LTF +}; +static int corner2[12] = { + LBF, LTF, LTN, LTF, RBF, RTF, RTN, RTF, RBN, RBF, RTN, RTF +}; +static int leftface[12] = { + B, L, L, F, R, T, N, R, N, B, T, F +}; /* face on left when going corner1 to corner2 */ -static int rightface[12] = { - L, T, N, L, B, R, R, F, B, F, N, T}; +static int rightface[12] = { + L, T, N, L, B, R, R, F, B, F, N, T +}; /* face on right when going corner1 to corner2 */ @@ -938,7 +942,7 @@ static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) CORNER *c1, *c2; int i, index = 0, count, indexar[8]; - for (i = 0; i < 8; i++) if (cube->corners[i]->value > 0.0f) index += (1<corners[i]->value > 0.0f) index += (1 << i); for (polys = cubetable[index]; polys; polys = polys->next) { INTLIST *edges; @@ -952,44 +956,44 @@ static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) indexar[count] = vertid(c1, c2, p, mb); count++; } - if (count>2) { + if (count > 2) { switch (count) { - case 3: - accum_mballfaces(indexar[2], indexar[1], indexar[0], 0); - break; - case 4: - if (indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); - break; - case 5: - if (indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + case 3: + accum_mballfaces(indexar[2], indexar[1], indexar[0], 0); + break; + case 4: + if (indexar[0] == 0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + break; + case 5: + if (indexar[0] == 0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + + accum_mballfaces(indexar[4], indexar[3], indexar[0], 0); + break; + case 6: + if (indexar[0] == 0) { + accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); + } + else { + accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); + } + break; + case 7: + if (indexar[0] == 0) { + accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); + } + else { + accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); + } + + accum_mballfaces(indexar[6], indexar[5], indexar[0], 0); - accum_mballfaces(indexar[4], indexar[3], indexar[0], 0); - break; - case 6: - if (indexar[0]==0) { - accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); - } - else { - accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); - accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); - } - break; - case 7: - if (indexar[0]==0) { - accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); - } - else { - accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); - accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); - } - - accum_mballfaces(indexar[6], indexar[5], indexar[0], 0); - - break; + break; } } } @@ -1000,17 +1004,17 @@ static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) * if surface crosses face, compute other four corners of adjacent cube * and add new cube to cube stack */ -static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p) +static void testface(int i, int j, int k, CUBE *old, int bit, int c1, int c2, int c3, int c4, PROCESS *p) { CUBE newc; CUBES *oldcubes = p->cubes; CORNER *corn1, *corn2, *corn3, *corn4; int n, pos; - corn1= old->corners[c1]; - corn2= old->corners[c2]; - corn3= old->corners[c3]; - corn4= old->corners[c4]; + corn1 = old->corners[c1]; + corn2 = old->corners[c2]; + corn3 = old->corners[c3]; + corn4 = old->corners[c4]; pos = corn1->value > 0.0f ? 1 : 0; @@ -1036,22 +1040,22 @@ static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, in newc.corners[FLIP(c3, bit)] = corn3; newc.corners[FLIP(c4, bit)] = corn4; - if (newc.corners[0]==NULL) newc.corners[0] = setcorner(p, i, j, k); - if (newc.corners[1]==NULL) newc.corners[1] = setcorner(p, i, j, k+1); - if (newc.corners[2]==NULL) newc.corners[2] = setcorner(p, i, j+1, k); - if (newc.corners[3]==NULL) newc.corners[3] = setcorner(p, i, j+1, k+1); - if (newc.corners[4]==NULL) newc.corners[4] = setcorner(p, i+1, j, k); - if (newc.corners[5]==NULL) newc.corners[5] = setcorner(p, i+1, j, k+1); - if (newc.corners[6]==NULL) newc.corners[6] = setcorner(p, i+1, j+1, k); - if (newc.corners[7]==NULL) newc.corners[7] = setcorner(p, i+1, j+1, k+1); + if (newc.corners[0] == NULL) newc.corners[0] = setcorner(p, i, j, k); + if (newc.corners[1] == NULL) newc.corners[1] = setcorner(p, i, j, k + 1); + if (newc.corners[2] == NULL) newc.corners[2] = setcorner(p, i, j + 1, k); + if (newc.corners[3] == NULL) newc.corners[3] = setcorner(p, i, j + 1, k + 1); + if (newc.corners[4] == NULL) newc.corners[4] = setcorner(p, i + 1, j, k); + if (newc.corners[5] == NULL) newc.corners[5] = setcorner(p, i + 1, j, k + 1); + if (newc.corners[6] == NULL) newc.corners[6] = setcorner(p, i + 1, j + 1, k); + if (newc.corners[7] == NULL) newc.corners[7] = setcorner(p, i + 1, j + 1, k + 1); - p->cubes->cube= newc; + p->cubes->cube = newc; } /* setcorner: return corner with the given lattice location * set (and cache) its function value */ -static CORNER *setcorner (PROCESS* p, int i, int j, int k) +static CORNER *setcorner(PROCESS *p, int i, int j, int k) { /* for speed, do corner value caching here */ CORNER *c; @@ -1070,11 +1074,11 @@ static CORNER *setcorner (PROCESS* p, int i, int j, int k) c = (CORNER *) new_pgn_element(sizeof(CORNER)); c->i = i; - c->x = ((float)i-0.5f)*p->size; + c->x = ((float)i - 0.5f) * p->size; c->j = j; - c->y = ((float)j-0.5f)*p->size; + c->y = ((float)j - 0.5f) * p->size; c->k = k; - c->z = ((float)k-0.5f)*p->size; + c->z = ((float)k - 0.5f) * p->size; c->value = p->function(c->x, c->y, c->z); c->next = p->corners[index]; @@ -1086,33 +1090,33 @@ static CORNER *setcorner (PROCESS* p, int i, int j, int k) /* nextcwedge: return next clockwise edge from given edge around given face */ -static int nextcwedge (int edge, int face) +static int nextcwedge(int edge, int face) { switch (edge) { - case LB: - return (face == L)? LF : BN; - case LT: - return (face == L)? LN : TF; - case LN: - return (face == L)? LB : TN; - case LF: - return (face == L)? LT : BF; - case RB: - return (face == R)? RN : BF; - case RT: - return (face == R)? RF : TN; - case RN: - return (face == R)? RT : BN; - case RF: - return (face == R)? RB : TF; - case BN: - return (face == B)? RB : LN; - case BF: - return (face == B)? LB : RF; - case TN: - return (face == T)? LT : RN; - case TF: - return (face == T)? RT : LF; + case LB: + return (face == L) ? LF : BN; + case LT: + return (face == L) ? LN : TF; + case LN: + return (face == L) ? LB : TN; + case LF: + return (face == L) ? LT : BF; + case RB: + return (face == R) ? RN : BF; + case RT: + return (face == R) ? RF : TN; + case RN: + return (face == R) ? RT : BN; + case RF: + return (face == R) ? RB : TF; + case BN: + return (face == B) ? RB : LN; + case BF: + return (face == B) ? LB : RF; + case TN: + return (face == T) ? LT : RN; + case TF: + return (face == T) ? RT : LF; } return 0; } @@ -1120,22 +1124,22 @@ static int nextcwedge (int edge, int face) /* otherface: return face adjoining edge that is not the given face */ -static int otherface (int edge, int face) +static int otherface(int edge, int face) { int other = leftface[edge]; - return face == other? rightface[edge] : other; + return face == other ? rightface[edge] : other; } /* makecubetable: create the 256 entry table for cubical polygonization */ -static void makecubetable (void) +static void makecubetable(void) { - static int isdone= 0; + static int isdone = 0; int i, e, c, done[12], pos[8]; if (isdone) return; - isdone= 1; + isdone = 1; for (i = 0; i < 256; i++) { for (e = 0; e < 12; e++) done[e] = 0; @@ -1147,7 +1151,7 @@ static void makecubetable (void) int start = e, edge = e; /* get face that is to right of edge from pos to neg corner: */ - int face = pos[corner1[e]]? rightface[e] : leftface[e]; + int face = pos[corner1[e]] ? rightface[e] : leftface[e]; while (1) { edge = nextcwedge(edge, face); @@ -1177,21 +1181,21 @@ void BKE_metaball_cubeTable_free(void) INTLIST *ints, *nints; for (i = 0; i < 256; i++) { - lists= cubetable[i]; + lists = cubetable[i]; while (lists) { - nlists= lists->next; + nlists = lists->next; - ints= lists->list; + ints = lists->list; while (ints) { - nints= ints->next; + nints = ints->next; MEM_freeN(ints); - ints= nints; + ints = nints; } MEM_freeN(lists); - lists= nlists; + lists = nlists; } - cubetable[i]= NULL; + cubetable[i] = NULL; } } @@ -1205,8 +1209,8 @@ static int setcenter(CENTERLIST *table[], int i, int j, int k) int index; CENTERLIST *newc, *l, *q; - index= HASH(i, j, k); - q= table[index]; + index = HASH(i, j, k); + q = table[index]; for (l = q; l != NULL; l = l->next) { if (l->i == i && l->j == j && l->k == k) return 1; @@ -1225,25 +1229,25 @@ static int setcenter(CENTERLIST *table[], int i, int j, int k) /* setedge: set vertex id for edge */ -static void setedge (EDGELIST *table[], - int i1, int j1, - int k1, int i2, - int j2, int k2, - int vid) +static void setedge(EDGELIST *table[], + int i1, int j1, + int k1, int i2, + int j2, int k2, + int vid) { unsigned int index; EDGELIST *newe; - if (i1>i2 || (i1==i2 && (j1>j2 || (j1==j2 && k1>k2)))) { - int t=i1; - i1=i2; - i2=t; - t=j1; - j1=j2; - j2=t; - t=k1; - k1=k2; - k2=t; + if (i1 > i2 || (i1 == i2 && (j1 > j2 || (j1 == j2 && k1 > k2)))) { + int t = i1; + i1 = i2; + i2 = t; + t = j1; + j1 = j2; + j2 = t; + t = k1; + k1 = k2; + k2 = t; } index = HASH(i1, j1, k1) + HASH(i2, j2, k2); newe = (EDGELIST *) new_pgn_element(sizeof(EDGELIST)); @@ -1261,27 +1265,27 @@ static void setedge (EDGELIST *table[], /* getedge: return vertex id for edge; return -1 if not set */ -static int getedge (EDGELIST *table[], - int i1, int j1, int k1, - int i2, int j2, int k2) +static int getedge(EDGELIST *table[], + int i1, int j1, int k1, + int i2, int j2, int k2) { EDGELIST *q; - if (i1>i2 || (i1==i2 && (j1>j2 || (j1==j2 && k1>k2)))) { - int t=i1; - i1=i2; - i2=t; - t=j1; - j1=j2; - j2=t; - t=k1; - k1=k2; - k2=t; + if (i1 > i2 || (i1 == i2 && (j1 > j2 || (j1 == j2 && k1 > k2)))) { + int t = i1; + i1 = i2; + i2 = t; + t = j1; + j1 = j2; + j2 = t; + t = k1; + k1 = k2; + k2 = t; } - q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)]; + q = table[HASH(i1, j1, k1) + HASH(i2, j2, k2)]; for (; q != NULL; q = q->next) { if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && - q->i2 == i2 && q->j2 == j2 && q->k2 == k2) + q->i2 == i2 && q->j2 == j2 && q->k2 == k2) { return q->vid; } @@ -1302,12 +1306,12 @@ static int getedge (EDGELIST *table[], /* addtovertices: add v to sequence of vertices */ -static void addtovertices (VERTICES *vertices, VERTEX v) +static void addtovertices(VERTICES *vertices, VERTEX v) { if (vertices->count == vertices->max) { int i; VERTEX *newv; - vertices->max = vertices->count == 0 ? 10 : 2*vertices->count; + vertices->max = vertices->count == 0 ? 10 : 2 * vertices->count; newv = (VERTEX *) MEM_callocN(vertices->max * sizeof(VERTEX), "addtovertices"); for (i = 0; i < vertices->count; i++) newv[i] = vertices->ptr[i]; @@ -1320,15 +1324,15 @@ static void addtovertices (VERTICES *vertices, VERTEX v) /* vnormal: compute unit length surface normal at point */ -static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) +static void vnormal(MB_POINT *point, PROCESS *p, MB_POINT *v) { - float delta= 0.2f*p->delta; + float delta = 0.2f * p->delta; float f = p->function(point->x, point->y, point->z); - v->x = p->function(point->x+delta, point->y, point->z)-f; - v->y = p->function(point->x, point->y+delta, point->z)-f; - v->z = p->function(point->x, point->y, point->z+delta)-f; - f = sqrtf(v->x*v->x + v->y*v->y + v->z*v->z); + v->x = p->function(point->x + delta, point->y, point->z) - f; + v->y = p->function(point->x, point->y + delta, point->z) - f; + v->z = p->function(point->x, point->y, point->z + delta) - f; + f = sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); if (f != 0.0f) { v->x /= f; @@ -1343,21 +1347,21 @@ static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) f = p->function(point->x, point->y, point->z); - temp.x = p->function(point->x+delta, point->y, point->z)-f; - temp.y = p->function(point->x, point->y+delta, point->z)-f; - temp.z = p->function(point->x, point->y, point->z+delta)-f; - f = sqrtf(temp.x*temp.x + temp.y*temp.y + temp.z*temp.z); + temp.x = p->function(point->x + delta, point->y, point->z) - f; + temp.y = p->function(point->x, point->y + delta, point->z) - f; + temp.z = p->function(point->x, point->y, point->z + delta) - f; + f = sqrtf(temp.x * temp.x + temp.y * temp.y + temp.z * temp.z); if (f != 0.0f) { temp.x /= f; temp.y /= f; temp.z /= f; - v->x+= temp.x; - v->y+= temp.y; - v->z+= temp.z; + v->x += temp.x; + v->y += temp.y; + v->z += temp.z; - f = sqrtf(v->x*v->x + v->y*v->y + v->z*v->z); + f = sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); if (f != 0.0f) { v->x /= f; @@ -1370,13 +1374,13 @@ static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) } -static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) +static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) { VERTEX v; MB_POINT a, b; int vid = getedge(p->edges, c1->i, c1->j, c1->k, c2->i, c2->j, c2->k); - if (vid != -1) return vid; /* previously computed */ + if (vid != -1) return vid; /* previously computed */ a.x = c1->x; a.y = c1->y; a.z = c1->z; @@ -1387,8 +1391,8 @@ static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) converge(&a, &b, c1->value, c2->value, p->function, &v.position, mb, 1); /* position */ vnormal(&v.position, p, &v.normal); - addtovertices(&p->vertices, v); /* save vertex */ - vid = p->vertices.count-1; + addtovertices(&p->vertices, v); /* save vertex */ + vid = p->vertices.count - 1; setedge(p->edges, c1->i, c1->j, c1->k, c2->i, c2->j, c2->k, vid); return vid; @@ -1399,8 +1403,8 @@ static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) /* converge: from two points of differing sign, converge to zero crossing */ /* watch it: p1 and p2 are used to calculate */ -static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, - float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f) +static void converge(MB_POINT *p1, MB_POINT *p2, float v1, float v2, + float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f) { int i = 0; MB_POINT pos, neg; @@ -1408,14 +1412,14 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, float dx = 0.0f, dy = 0.0f, dz = 0.0f; if (v1 < 0) { - pos= *p2; - neg= *p1; + pos = *p2; + neg = *p1; positive = v2; negative = v1; } else { - pos= *p1; - neg= *p2; + pos = *p1; + neg = *p2; positive = v1; negative = v2; } @@ -1426,25 +1430,25 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, /* Approximation by linear interpolation is faster then binary subdivision, * but it results sometimes (mb->thresh < 0.2) into the strange results */ - if ((mb->thresh > 0.2f) && (f==1)) { - if ((dy == 0.0f) && (dz == 0.0f)) { - p->x = neg.x - negative*dx/(positive-negative); - p->y = neg.y; - p->z = neg.z; - return; - } - if ((dx == 0.0f) && (dz == 0.0f)) { - p->x = neg.x; - p->y = neg.y - negative*dy/(positive-negative); - p->z = neg.z; - return; - } - if ((dx == 0.0f) && (dy == 0.0f)) { - p->x = neg.x; - p->y = neg.y; - p->z = neg.z - negative*dz/(positive-negative); - return; - } + if ((mb->thresh > 0.2f) && (f == 1)) { + if ((dy == 0.0f) && (dz == 0.0f)) { + p->x = neg.x - negative * dx / (positive - negative); + p->y = neg.y; + p->z = neg.z; + return; + } + if ((dx == 0.0f) && (dz == 0.0f)) { + p->x = neg.x; + p->y = neg.y - negative * dy / (positive - negative); + p->z = neg.z; + return; + } + if ((dx == 0.0f) && (dy == 0.0f)) { + p->x = neg.x; + p->y = neg.y; + p->z = neg.z - negative * dz / (positive - negative); + return; + } } if ((dy == 0.0f) && (dz == 0.0f)) { @@ -1452,8 +1456,8 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->z = neg.z; while (1) { if (i++ == RES) return; - p->x = 0.5f*(pos.x + neg.x); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; + p->x = 0.5f * (pos.x + neg.x); + if ((function(p->x, p->y, p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; } } @@ -1462,26 +1466,26 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->z = neg.z; while (1) { if (i++ == RES) return; - p->y = 0.5f*(pos.y + neg.y); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; + p->y = 0.5f * (pos.y + neg.y); + if ((function(p->x, p->y, p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; } - } + } if ((dx == 0.0f) && (dy == 0.0f)) { p->x = neg.x; p->y = neg.y; while (1) { if (i++ == RES) return; - p->z = 0.5f*(pos.z + neg.z); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; + p->z = 0.5f * (pos.z + neg.z); + if ((function(p->x, p->y, p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; } } /* This is necessary to find start point */ while (1) { - p->x = 0.5f*(pos.x + neg.x); - p->y = 0.5f*(pos.y + neg.y); - p->z = 0.5f*(pos.z + neg.z); + p->x = 0.5f * (pos.x + neg.x); + p->y = 0.5f * (pos.y + neg.y); + p->z = 0.5f * (pos.z + neg.z); if (i++ == RES) return; @@ -1507,23 +1511,23 @@ static void add_cube(PROCESS *mbproc, int i, int j, int k, int count) /* hmmm, not only one, but eight cube will be added on the stack * ... */ - for (a=i-1; acenters, a, b, c)==0 ) { + if (setcenter(mbproc->centers, a, b, c) == 0) { /* push cube on stack: */ - ncube= (CUBES *) new_pgn_element(sizeof(CUBES)); - ncube->next= mbproc->cubes; - mbproc->cubes= ncube; + ncube = (CUBES *) new_pgn_element(sizeof(CUBES)); + ncube->next = mbproc->cubes; + mbproc->cubes = ncube; - ncube->cube.i= a; - ncube->cube.j= b; - ncube->cube.k= c; + ncube->cube.i = a; + ncube->cube.j = b; + ncube->cube.k = c; /* set corners of initial cube: */ for (n = 0; n < 8; n++) - ncube->cube.corners[n] = setcorner(mbproc, a+MB_BIT(n, 2), b+MB_BIT(n, 1), c+MB_BIT(n, 0)); + ncube->cube.corners[n] = setcorner(mbproc, a + MB_BIT(n, 2), b + MB_BIT(n, 1), c + MB_BIT(n, 0)); } } } @@ -1534,64 +1538,64 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) MB_POINT IN, in, OUT, out; /*point;*/ MetaElem *ml; int i, j, k, c_i, c_j, c_k; - int index[3]={1, 0, -1}; - float f =0.0f; + int index[3] = {1, 0, -1}; + float f = 0.0f; float in_v /*, out_v*/; MB_POINT workp; float tmp_v, workp_v, max_len, len, dx, dy, dz, nx, ny, nz, MAXN; ml = mainb[a]; - f = 1-(mb->thresh/ml->s); + f = 1 - (mb->thresh / ml->s); /* Skip, when Stiffness of MetaElement is too small ... MetaElement can't be * visible alone ... but still can influence others MetaElements :-) */ if (f > 0.0f) { - OUT.x = IN.x = in.x= 0.0; - OUT.y = IN.y = in.y= 0.0; - OUT.z = IN.z = in.z= 0.0; + OUT.x = IN.x = in.x = 0.0; + OUT.y = IN.y = in.y = 0.0; + OUT.z = IN.z = in.z = 0.0; calc_mballco(ml, (float *)&in); in_v = mbproc->function(in.x, in.y, in.z); - for (i=0;i<3;i++) { + for (i = 0; i < 3; i++) { switch (ml->type) { case MB_BALL: - OUT.x = out.x= IN.x + index[i]*ml->rad; + OUT.x = out.x = IN.x + index[i] * ml->rad; break; case MB_TUBE: case MB_PLANE: case MB_ELIPSOID: case MB_CUBE: - OUT.x = out.x= IN.x + index[i]*(ml->expx + ml->rad); + OUT.x = out.x = IN.x + index[i] * (ml->expx + ml->rad); break; } - for (j=0;j<3;j++) { + for (j = 0; j < 3; j++) { switch (ml->type) { case MB_BALL: - OUT.y = out.y= IN.y + index[j]*ml->rad; + OUT.y = out.y = IN.y + index[j] * ml->rad; break; case MB_TUBE: case MB_PLANE: case MB_ELIPSOID: case MB_CUBE: - OUT.y = out.y= IN.y + index[j]*(ml->expy + ml->rad); + OUT.y = out.y = IN.y + index[j] * (ml->expy + ml->rad); break; } - for (k=0;k<3;k++) { + for (k = 0; k < 3; k++) { out.x = OUT.x; out.y = OUT.y; switch (ml->type) { case MB_BALL: case MB_TUBE: case MB_PLANE: - out.z= IN.z + index[k]*ml->rad; + out.z = IN.z + index[k] * ml->rad; break; case MB_ELIPSOID: case MB_CUBE: - out.z= IN.z + index[k]*(ml->expz + ml->rad); + out.z = IN.z + index[k] * (ml->expz + ml->rad); break; } @@ -1604,32 +1608,32 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) workp.y = in.y; workp.z = in.z; workp_v = in_v; - max_len = sqrtf((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z)); + max_len = sqrtf((out.x - in.x) * (out.x - in.x) + (out.y - in.y) * (out.y - in.y) + (out.z - in.z) * (out.z - in.z)); - nx = abs((out.x - in.x)/mbproc->size); - ny = abs((out.y - in.y)/mbproc->size); - nz = abs((out.z - in.z)/mbproc->size); + nx = abs((out.x - in.x) / mbproc->size); + ny = abs((out.y - in.y) / mbproc->size); + nz = abs((out.z - in.z) / mbproc->size); MAXN = MAX3(nx, ny, nz); - if (MAXN!=0.0f) { - dx = (out.x - in.x)/MAXN; - dy = (out.y - in.y)/MAXN; - dz = (out.z - in.z)/MAXN; + if (MAXN != 0.0f) { + dx = (out.x - in.x) / MAXN; + dy = (out.y - in.y) / MAXN; + dz = (out.z - in.z) / MAXN; len = 0.0; - while (len<=max_len) { + while (len <= max_len) { workp.x += dx; workp.y += dy; workp.z += dz; /* compute value of implicite function */ tmp_v = mbproc->function(workp.x, workp.y, workp.z); /* add cube to the stack, when value of implicite function crosses zero value */ - if ((tmp_v<0.0f && workp_v>=0.0f)||(tmp_v>0.0f && workp_v<=0.0f)) { + if ((tmp_v < 0.0f && workp_v >= 0.0f) || (tmp_v > 0.0f && workp_v <= 0.0f)) { /* indexes of CUBE, which includes "first point" */ - c_i= (int)floor(workp.x/mbproc->size); - c_j= (int)floor(workp.y/mbproc->size); - c_k= (int)floor(workp.z/mbproc->size); + c_i = (int)floor(workp.x / mbproc->size); + c_j = (int)floor(workp.y / mbproc->size); + c_k = (int)floor(workp.z / mbproc->size); /* add CUBE (with indexes c_i, c_j, c_k) to the stack, * this cube includes found point of Implicit Surface */ @@ -1638,7 +1642,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) else add_cube(mbproc, c_i, c_j, c_k, 1); } - len = sqrtf((workp.x-in.x)*(workp.x-in.x) + (workp.y-in.y)*(workp.y-in.y) + (workp.z-in.z)*(workp.z-in.z)); + len = sqrtf((workp.x - in.x) * (workp.x - in.x) + (workp.y - in.y) * (workp.y - in.y) + (workp.z - in.z) * (workp.z - in.z)); workp_v = tmp_v; } @@ -1660,10 +1664,10 @@ static void polygonize(PROCESS *mbproc, MetaBall *mb) /* allocate hash tables and build cube polygon table: */ mbproc->centers = MEM_callocN(HASHSIZE * sizeof(CENTERLIST *), "mbproc->centers"); mbproc->corners = MEM_callocN(HASHSIZE * sizeof(CORNER *), "mbproc->corners"); - mbproc->edges = MEM_callocN(2*HASHSIZE * sizeof(EDGELIST *), "mbproc->edges"); + mbproc->edges = MEM_callocN(2 * HASHSIZE * sizeof(EDGELIST *), "mbproc->edges"); makecubetable(); - for (a=0; acubes = mbproc->cubes->next; /* test six face directions, maybe add to stack: */ - testface(c.i-1, c.j, c.k, &c, 2, LBN, LBF, LTN, LTF, mbproc); - testface(c.i+1, c.j, c.k, &c, 2, RBN, RBF, RTN, RTF, mbproc); - testface(c.i, c.j-1, c.k, &c, 1, LBN, LBF, RBN, RBF, mbproc); - testface(c.i, c.j+1, c.k, &c, 1, LTN, LTF, RTN, RTF, mbproc); - testface(c.i, c.j, c.k-1, &c, 0, LBN, LTN, RBN, RTN, mbproc); - testface(c.i, c.j, c.k+1, &c, 0, LBF, LTF, RBF, RTF, mbproc); + testface(c.i - 1, c.j, c.k, &c, 2, LBN, LBF, LTN, LTF, mbproc); + testface(c.i + 1, c.j, c.k, &c, 2, RBN, RBF, RTN, RTF, mbproc); + testface(c.i, c.j - 1, c.k, &c, 1, LBN, LBF, RBN, RBF, mbproc); + testface(c.i, c.j + 1, c.k, &c, 1, LTN, LTF, RTN, RTF, mbproc); + testface(c.i, c.j, c.k - 1, &c, 0, LBN, LTN, RBN, RTN, mbproc); + testface(c.i, c.j, c.k + 1, &c, 0, LBF, LTF, RBF, RTF, mbproc); } } -static float init_meta(Scene *scene, Object *ob) /* return totsize */ +static float init_meta(Scene *scene, Object *ob) /* return totsize */ { - Scene *sce_iter= scene; + Scene *sce_iter = scene; Base *base; Object *bob; MetaBall *mb; MetaElem *ml; float size, totsize, obinv[4][4], obmat[4][4], vec[3]; //float max=0.0; - int a, obnr, zero_size=0; + int a, obnr, zero_size = 0; char obname[MAX_ID_NAME]; - copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */ + copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */ invert_m4_m4(obinv, ob->obmat); - a= 0; + a = 0; - BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); + BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* make main array */ 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; - ml= NULL; + if (bob->type == OB_MBALL) { + zero_size = 0; + ml = NULL; - if (bob==ob && (base->flag & OB_FROMDUPLI)==0) { - mb= ob->data; + if (bob == ob && (base->flag & OB_FROMDUPLI) == 0) { + mb = ob->data; - if (mb->editelems) ml= mb->editelems->first; - else ml= mb->elems.first; + if (mb->editelems) ml = mb->editelems->first; + else ml = mb->elems.first; } else { char name[MAX_ID_NAME]; int nr; - BLI_split_name_num(name, &nr, bob->id.name+2, '.'); - if ( strcmp(obname, name)==0 ) { - mb= bob->data; + BLI_split_name_num(name, &nr, bob->id.name + 2, '.'); + if (strcmp(obname, name) == 0) { + mb = bob->data; - if (mb->editelems) ml= mb->editelems->first; - else ml= mb->elems.first; + if (mb->editelems) ml = mb->editelems->first; + else ml = mb->elems.first; } } /* when metaball object has zero scale, then MetaElem to this MetaBall * will not be put to mainb array */ - if (bob->size[0]==0.0f || bob->size[1]==0.0f || bob->size[2]==0.0f) { - zero_size= 1; + if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) { + zero_size = 1; } else if (bob->parent) { - struct Object *pob=bob->parent; + struct Object *pob = bob->parent; while (pob) { - if (pob->size[0]==0.0f || pob->size[1]==0.0f || pob->size[2]==0.0f) { - zero_size= 1; + if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) { + zero_size = 1; break; } - pob= pob->parent; + pob = pob->parent; } } if (zero_size) { - unsigned int ml_count=0; + unsigned int ml_count = 0; while (ml) { ml_count++; - ml= ml->next; + ml = ml->next; } totelem -= ml_count; } else { - while (ml) { - if (!(ml->flag & MB_HIDE)) { - int i; - float temp1[4][4], temp2[4][4], temp3[4][4]; - float (*mat)[4] = NULL, (*imat)[4] = NULL; - float max_x, max_y, max_z, min_x, min_y, min_z; + while (ml) { + if (!(ml->flag & MB_HIDE)) { + int i; + float temp1[4][4], temp2[4][4], temp3[4][4]; + float (*mat)[4] = NULL, (*imat)[4] = NULL; + float max_x, max_y, max_z, min_x, min_y, min_z; - max_x = max_y = max_z = -3.4e38; - min_x = min_y = min_z = 3.4e38; + max_x = max_y = max_z = -3.4e38; + min_x = min_y = min_z = 3.4e38; - /* too big stiffness seems only ugly due to linear interpolation - * no need to have possibility for too big stiffness */ - if (ml->s > 10.0f) ml->s = 10.0f; + /* too big stiffness seems only ugly due to linear interpolation + * no need to have possibility for too big stiffness */ + if (ml->s > 10.0f) ml->s = 10.0f; + + /* Rotation of MetaElem is stored in quat */ + quat_to_mat4(temp3, ml->quat); + + /* Translation of MetaElem */ + unit_m4(temp2); + temp2[3][0] = ml->x; + temp2[3][1] = ml->y; + temp2[3][2] = ml->z; + + mult_m4_m4m4(temp1, temp2, temp3); + + /* make a copy because of duplicates */ + mainb[a] = new_pgn_element(sizeof(MetaElem)); + *(mainb[a]) = *ml; + mainb[a]->bb = new_pgn_element(sizeof(BoundBox)); + + mat = new_pgn_element(4 * 4 * sizeof(float)); + imat = new_pgn_element(4 * 4 * sizeof(float)); + + /* mat is the matrix to transform from mball into the basis-mball */ + invert_m4_m4(obinv, obmat); + mult_m4_m4m4(temp2, obinv, bob->obmat); + /* MetaBall transformation */ + mult_m4_m4m4(mat, temp2, temp1); + + invert_m4_m4(imat, mat); + + mainb[a]->rad2 = ml->rad * ml->rad; + + mainb[a]->mat = (float *) mat; + mainb[a]->imat = (float *) imat; + + /* untransformed Bounding Box of MetaElem */ + /* 0 */ + mainb[a]->bb->vec[0][0] = -ml->expx; + mainb[a]->bb->vec[0][1] = -ml->expy; + mainb[a]->bb->vec[0][2] = -ml->expz; + /* 1 */ + mainb[a]->bb->vec[1][0] = ml->expx; + mainb[a]->bb->vec[1][1] = -ml->expy; + mainb[a]->bb->vec[1][2] = -ml->expz; + /* 2 */ + mainb[a]->bb->vec[2][0] = ml->expx; + mainb[a]->bb->vec[2][1] = ml->expy; + mainb[a]->bb->vec[2][2] = -ml->expz; + /* 3 */ + mainb[a]->bb->vec[3][0] = -ml->expx; + mainb[a]->bb->vec[3][1] = ml->expy; + mainb[a]->bb->vec[3][2] = -ml->expz; + /* 4 */ + mainb[a]->bb->vec[4][0] = -ml->expx; + mainb[a]->bb->vec[4][1] = -ml->expy; + mainb[a]->bb->vec[4][2] = ml->expz; + /* 5 */ + mainb[a]->bb->vec[5][0] = ml->expx; + mainb[a]->bb->vec[5][1] = -ml->expy; + mainb[a]->bb->vec[5][2] = ml->expz; + /* 6 */ + mainb[a]->bb->vec[6][0] = ml->expx; + mainb[a]->bb->vec[6][1] = ml->expy; + mainb[a]->bb->vec[6][2] = ml->expz; + /* 7 */ + mainb[a]->bb->vec[7][0] = -ml->expx; + mainb[a]->bb->vec[7][1] = ml->expy; + mainb[a]->bb->vec[7][2] = ml->expz; + + /* transformation of Metalem bb */ + for (i = 0; i < 8; i++) + mul_m4_v3((float (*)[4])mat, mainb[a]->bb->vec[i]); + + /* find max and min of transformed bb */ + for (i = 0; i < 8; i++) { + /* find maximums */ + if (mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0]; + if (mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1]; + if (mainb[a]->bb->vec[i][2] > max_z) max_z = mainb[a]->bb->vec[i][2]; + /* find minimums */ + if (mainb[a]->bb->vec[i][0] < min_x) min_x = mainb[a]->bb->vec[i][0]; + if (mainb[a]->bb->vec[i][1] < min_y) min_y = mainb[a]->bb->vec[i][1]; + if (mainb[a]->bb->vec[i][2] < min_z) min_z = mainb[a]->bb->vec[i][2]; + } - /* Rotation of MetaElem is stored in quat */ - quat_to_mat4(temp3, ml->quat); + /* create "new" bb, only point 0 and 6, which are + * necessary for octal tree filling */ + mainb[a]->bb->vec[0][0] = min_x - ml->rad; + mainb[a]->bb->vec[0][1] = min_y - ml->rad; + mainb[a]->bb->vec[0][2] = min_z - ml->rad; - /* Translation of MetaElem */ - unit_m4(temp2); - temp2[3][0]= ml->x; - temp2[3][1]= ml->y; - temp2[3][2]= ml->z; + mainb[a]->bb->vec[6][0] = max_x + ml->rad; + mainb[a]->bb->vec[6][1] = max_y + ml->rad; + mainb[a]->bb->vec[6][2] = max_z + ml->rad; - mult_m4_m4m4(temp1, temp2, temp3); - - /* make a copy because of duplicates */ - mainb[a]= new_pgn_element(sizeof(MetaElem)); - *(mainb[a])= *ml; - mainb[a]->bb = new_pgn_element(sizeof(BoundBox)); - - mat= new_pgn_element(4*4*sizeof(float)); - imat= new_pgn_element(4*4*sizeof(float)); - - /* mat is the matrix to transform from mball into the basis-mball */ - invert_m4_m4(obinv, obmat); - mult_m4_m4m4(temp2, obinv, bob->obmat); - /* MetaBall transformation */ - mult_m4_m4m4(mat, temp2, temp1); - - invert_m4_m4(imat, mat); - - mainb[a]->rad2= ml->rad*ml->rad; - - mainb[a]->mat= (float*) mat; - mainb[a]->imat= (float*) imat; - - /* untransformed Bounding Box of MetaElem */ - /* 0 */ - mainb[a]->bb->vec[0][0]= -ml->expx; - mainb[a]->bb->vec[0][1]= -ml->expy; - mainb[a]->bb->vec[0][2]= -ml->expz; - /* 1 */ - mainb[a]->bb->vec[1][0]= ml->expx; - mainb[a]->bb->vec[1][1]= -ml->expy; - mainb[a]->bb->vec[1][2]= -ml->expz; - /* 2 */ - mainb[a]->bb->vec[2][0]= ml->expx; - mainb[a]->bb->vec[2][1]= ml->expy; - mainb[a]->bb->vec[2][2]= -ml->expz; - /* 3 */ - mainb[a]->bb->vec[3][0]= -ml->expx; - mainb[a]->bb->vec[3][1]= ml->expy; - mainb[a]->bb->vec[3][2]= -ml->expz; - /* 4 */ - mainb[a]->bb->vec[4][0]= -ml->expx; - mainb[a]->bb->vec[4][1]= -ml->expy; - mainb[a]->bb->vec[4][2]= ml->expz; - /* 5 */ - mainb[a]->bb->vec[5][0]= ml->expx; - mainb[a]->bb->vec[5][1]= -ml->expy; - mainb[a]->bb->vec[5][2]= ml->expz; - /* 6 */ - mainb[a]->bb->vec[6][0]= ml->expx; - mainb[a]->bb->vec[6][1]= ml->expy; - mainb[a]->bb->vec[6][2]= ml->expz; - /* 7 */ - mainb[a]->bb->vec[7][0]= -ml->expx; - mainb[a]->bb->vec[7][1]= ml->expy; - mainb[a]->bb->vec[7][2]= ml->expz; - - /* transformation of Metalem bb */ - for (i=0; i<8; i++) - mul_m4_v3((float (*)[4])mat, mainb[a]->bb->vec[i]); - - /* find max and min of transformed bb */ - for (i=0; i<8; i++) { - /* find maximums */ - if (mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0]; - if (mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1]; - if (mainb[a]->bb->vec[i][2] > max_z) max_z = mainb[a]->bb->vec[i][2]; - /* find minimums */ - if (mainb[a]->bb->vec[i][0] < min_x) min_x = mainb[a]->bb->vec[i][0]; - if (mainb[a]->bb->vec[i][1] < min_y) min_y = mainb[a]->bb->vec[i][1]; - if (mainb[a]->bb->vec[i][2] < min_z) min_z = mainb[a]->bb->vec[i][2]; + a++; } - - /* create "new" bb, only point 0 and 6, which are - * necessary for octal tree filling */ - mainb[a]->bb->vec[0][0] = min_x - ml->rad; - mainb[a]->bb->vec[0][1] = min_y - ml->rad; - mainb[a]->bb->vec[0][2] = min_z - ml->rad; - - mainb[a]->bb->vec[6][0] = max_x + ml->rad; - mainb[a]->bb->vec[6][1] = max_y + ml->rad; - mainb[a]->bb->vec[6][2] = max_z + ml->rad; - - a++; + ml = ml->next; } - ml= ml->next; - } } } } /* totsize (= 'manhattan' radius) */ - totsize= 0.0; - for (a=0; ax + mainb[a]->rad + mainb[a]->expx; - vec[1]= mainb[a]->y + mainb[a]->rad + mainb[a]->expy; - vec[2]= mainb[a]->z + mainb[a]->rad + mainb[a]->expz; + vec[0] = mainb[a]->x + mainb[a]->rad + mainb[a]->expx; + vec[1] = mainb[a]->y + mainb[a]->rad + mainb[a]->expy; + vec[2] = mainb[a]->z + mainb[a]->rad + mainb[a]->expz; calc_mballco(mainb[a], vec); - size= fabsf(vec[0]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[1]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[2]); - if ( size > totsize ) totsize= size; + size = fabsf(vec[0]); + if (size > totsize) totsize = size; + size = fabsf(vec[1]); + if (size > totsize) totsize = size; + size = fabsf(vec[2]); + if (size > totsize) totsize = size; - vec[0]= mainb[a]->x - mainb[a]->rad; - vec[1]= mainb[a]->y - mainb[a]->rad; - vec[2]= mainb[a]->z - mainb[a]->rad; + vec[0] = mainb[a]->x - mainb[a]->rad; + vec[1] = mainb[a]->y - mainb[a]->rad; + vec[2] = mainb[a]->z - mainb[a]->rad; calc_mballco(mainb[a], vec); - size= fabsf(vec[0]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[1]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[2]); - if ( size > totsize ) totsize= size; + size = fabsf(vec[0]); + if (size > totsize) totsize = size; + size = fabsf(vec[1]); + if (size > totsize) totsize = size; + size = fabsf(vec[2]); + if (size > totsize) totsize = size; } - for (a=0; aml= ml; + ml_p = MEM_mallocN(sizeof(ml_pointer), "ml_pointer"); + ml_p->ml = ml; BLI_addtail(&(node->nodes[i]->elems), ml_p); node->count++; @@ -1955,16 +1959,16 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float int a, i; /* create new nodes */ - for (a=0;a<8;a++) { - node->nodes[a]= MEM_mallocN(sizeof(octal_node), "octal_node"); - for (i=0;i<8;i++) - node->nodes[a]->nodes[i]= NULL; - node->nodes[a]->parent= node; - node->nodes[a]->elems.first= NULL; - node->nodes[a]->elems.last= NULL; - node->nodes[a]->count= 0; - node->nodes[a]->neg= 0; - node->nodes[a]->pos= 0; + for (a = 0; a < 8; a++) { + node->nodes[a] = MEM_mallocN(sizeof(octal_node), "octal_node"); + for (i = 0; i < 8; i++) + node->nodes[a]->nodes[i] = NULL; + node->nodes[a]->parent = node; + node->nodes[a]->elems.first = NULL; + node->nodes[a]->elems.last = NULL; + node->nodes[a]->count = 0; + node->nodes[a]->neg = 0; + node->nodes[a]->pos = 0; } size_x /= 2; @@ -1980,64 +1984,64 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float node->nodes[0]->x_min = node->x_min; node->nodes[0]->y_min = node->y_min; node->nodes[0]->z_min = node->z_min; - node->nodes[0]->x = node->nodes[0]->x_min + size_x/2; - node->nodes[0]->y = node->nodes[0]->y_min + size_y/2; - node->nodes[0]->z = node->nodes[0]->z_min + size_z/2; + node->nodes[0]->x = node->nodes[0]->x_min + size_x / 2; + node->nodes[0]->y = node->nodes[0]->y_min + size_y / 2; + node->nodes[0]->z = node->nodes[0]->z_min + size_z / 2; node->nodes[1]->x_min = x; node->nodes[1]->y_min = node->y_min; node->nodes[1]->z_min = node->z_min; - node->nodes[1]->x = node->nodes[1]->x_min + size_x/2; - node->nodes[1]->y = node->nodes[1]->y_min + size_y/2; - node->nodes[1]->z = node->nodes[1]->z_min + size_z/2; + node->nodes[1]->x = node->nodes[1]->x_min + size_x / 2; + node->nodes[1]->y = node->nodes[1]->y_min + size_y / 2; + node->nodes[1]->z = node->nodes[1]->z_min + size_z / 2; node->nodes[2]->x_min = x; node->nodes[2]->y_min = y; node->nodes[2]->z_min = node->z_min; - node->nodes[2]->x = node->nodes[2]->x_min + size_x/2; - node->nodes[2]->y = node->nodes[2]->y_min + size_y/2; - node->nodes[2]->z = node->nodes[2]->z_min + size_z/2; + node->nodes[2]->x = node->nodes[2]->x_min + size_x / 2; + node->nodes[2]->y = node->nodes[2]->y_min + size_y / 2; + node->nodes[2]->z = node->nodes[2]->z_min + size_z / 2; node->nodes[3]->x_min = node->x_min; node->nodes[3]->y_min = y; node->nodes[3]->z_min = node->z_min; - node->nodes[3]->x = node->nodes[3]->x_min + size_x/2; - node->nodes[3]->y = node->nodes[3]->y_min + size_y/2; - node->nodes[3]->z = node->nodes[3]->z_min + size_z/2; + node->nodes[3]->x = node->nodes[3]->x_min + size_x / 2; + node->nodes[3]->y = node->nodes[3]->y_min + size_y / 2; + node->nodes[3]->z = node->nodes[3]->z_min + size_z / 2; node->nodes[4]->x_min = node->x_min; node->nodes[4]->y_min = node->y_min; node->nodes[4]->z_min = z; - node->nodes[4]->x = node->nodes[4]->x_min + size_x/2; - node->nodes[4]->y = node->nodes[4]->y_min + size_y/2; - node->nodes[4]->z = node->nodes[4]->z_min + size_z/2; + node->nodes[4]->x = node->nodes[4]->x_min + size_x / 2; + node->nodes[4]->y = node->nodes[4]->y_min + size_y / 2; + node->nodes[4]->z = node->nodes[4]->z_min + size_z / 2; node->nodes[5]->x_min = x; node->nodes[5]->y_min = node->y_min; node->nodes[5]->z_min = z; - node->nodes[5]->x = node->nodes[5]->x_min + size_x/2; - node->nodes[5]->y = node->nodes[5]->y_min + size_y/2; - node->nodes[5]->z = node->nodes[5]->z_min + size_z/2; + node->nodes[5]->x = node->nodes[5]->x_min + size_x / 2; + node->nodes[5]->y = node->nodes[5]->y_min + size_y / 2; + node->nodes[5]->z = node->nodes[5]->z_min + size_z / 2; node->nodes[6]->x_min = x; node->nodes[6]->y_min = y; node->nodes[6]->z_min = z; - node->nodes[6]->x = node->nodes[6]->x_min + size_x/2; - node->nodes[6]->y = node->nodes[6]->y_min + size_y/2; - node->nodes[6]->z = node->nodes[6]->z_min + size_z/2; + node->nodes[6]->x = node->nodes[6]->x_min + size_x / 2; + node->nodes[6]->y = node->nodes[6]->y_min + size_y / 2; + node->nodes[6]->z = node->nodes[6]->z_min + size_z / 2; node->nodes[7]->x_min = node->x_min; node->nodes[7]->y_min = y; node->nodes[7]->z_min = z; - node->nodes[7]->x = node->nodes[7]->x_min + size_x/2; - node->nodes[7]->y = node->nodes[7]->y_min + size_y/2; - node->nodes[7]->z = node->nodes[7]->z_min + size_z/2; + node->nodes[7]->x = node->nodes[7]->x_min + size_x / 2; + node->nodes[7]->y = node->nodes[7]->y_min + size_y / 2; + node->nodes[7]->z = node->nodes[7]->z_min + size_z / 2; - ml_p= node->elems.first; + ml_p = node->elems.first; /* setting up references of MetaElems for new nodes */ while (ml_p) { - ml= ml_p->ml; + ml = ml_p->ml; if (ml->bb->vec[0][2] < z) { if (ml->bb->vec[0][1] < y) { /* vec[0][0] lies in first octant */ @@ -2187,7 +2191,7 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float fill_metaball_octal_node(node, ml, 6); } } - ml_p= ml_p->next; + ml_p = ml_p->next; } /* free references of MetaElems for curent node (it is not needed anymore) */ @@ -2195,8 +2199,8 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float depth--; - if (depth>0) { - for (a=0;a<8;a++) { + if (depth > 0) { + for (a = 0; a < 8; a++) { if (node->nodes[a]->count > 0) /* if node is not empty, then it is subdivided */ subdivide_metaball_octal_node(node->nodes[a], size_x, size_y, size_z, depth); } @@ -2207,8 +2211,8 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float static void free_metaball_octal_node(octal_node *node) { int a; - for (a=0;a<8;a++) { - if (node->nodes[a]!=NULL) free_metaball_octal_node(node->nodes[a]); + for (a = 0; a < 8; a++) { + if (node->nodes[a] != NULL) free_metaball_octal_node(node->nodes[a]); } BLI_freelistN(&node->elems); MEM_freeN(node); @@ -2222,36 +2226,36 @@ static void init_metaball_octal_tree(int depth) float size[3]; int a; - metaball_tree= MEM_mallocN(sizeof(octal_tree), "metaball_octal_tree"); - metaball_tree->first= node= MEM_mallocN(sizeof(octal_node), "metaball_octal_node"); + metaball_tree = MEM_mallocN(sizeof(octal_tree), "metaball_octal_tree"); + metaball_tree->first = node = MEM_mallocN(sizeof(octal_node), "metaball_octal_node"); /* maximal depth of octree */ - metaball_tree->depth= depth; + metaball_tree->depth = depth; - metaball_tree->neg= node->neg=0; - metaball_tree->pos= node->pos=0; + metaball_tree->neg = node->neg = 0; + metaball_tree->pos = node->pos = 0; - node->elems.first= NULL; - node->elems.last= NULL; - node->count=0; + node->elems.first = NULL; + node->elems.last = NULL; + node->count = 0; - for (a=0;a<8;a++) - node->nodes[a]=NULL; + for (a = 0; a < 8; a++) + node->nodes[a] = NULL; - node->x_min= node->y_min= node->z_min= FLT_MAX; - node->x_max= node->y_max= node->z_max= -FLT_MAX; + node->x_min = node->y_min = node->z_min = FLT_MAX; + node->x_max = node->y_max = node->z_max = -FLT_MAX; /* size of octal tree scene */ - for (a=0;abb->vec[0][0] < node->x_min) node->x_min= mainb[a]->bb->vec[0][0]; - if (mainb[a]->bb->vec[0][1] < node->y_min) node->y_min= mainb[a]->bb->vec[0][1]; - if (mainb[a]->bb->vec[0][2] < node->z_min) node->z_min= mainb[a]->bb->vec[0][2]; - - if (mainb[a]->bb->vec[6][0] > node->x_max) node->x_max= mainb[a]->bb->vec[6][0]; - if (mainb[a]->bb->vec[6][1] > node->y_max) node->y_max= mainb[a]->bb->vec[6][1]; - if (mainb[a]->bb->vec[6][2] > node->z_max) node->z_max= mainb[a]->bb->vec[6][2]; + for (a = 0; a < totelem; a++) { + if (mainb[a]->bb->vec[0][0] < node->x_min) node->x_min = mainb[a]->bb->vec[0][0]; + if (mainb[a]->bb->vec[0][1] < node->y_min) node->y_min = mainb[a]->bb->vec[0][1]; + if (mainb[a]->bb->vec[0][2] < node->z_min) node->z_min = mainb[a]->bb->vec[0][2]; - ml_p= MEM_mallocN(sizeof(ml_pointer), "ml_pointer"); - ml_p->ml= mainb[a]; + if (mainb[a]->bb->vec[6][0] > node->x_max) node->x_max = mainb[a]->bb->vec[6][0]; + if (mainb[a]->bb->vec[6][1] > node->y_max) node->y_max = mainb[a]->bb->vec[6][1]; + if (mainb[a]->bb->vec[6][2] > node->z_max) node->z_max = mainb[a]->bb->vec[6][2]; + + ml_p = MEM_mallocN(sizeof(ml_pointer), "ml_pointer"); + ml_p->ml = mainb[a]; BLI_addtail(&node->elems, ml_p); if (mainb[a]->flag & MB_NEGATIVE) { @@ -2265,9 +2269,9 @@ static void init_metaball_octal_tree(int depth) } /* size of first node */ - size[0]= node->x_max - node->x_min; - size[1]= node->y_max - node->y_min; - size[2]= node->z_max - node->z_min; + size[0] = node->x_max - node->x_min; + size[1] = node->y_max - node->y_min; + size[2] = node->z_max - node->z_min; /* first node is subdivided recursively */ subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth); @@ -2281,41 +2285,41 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) int a, nr_cubes; float *ve, *no, totsize, width; - mb= ob->data; + mb = ob->data; - if (totelem==0) return; - if (!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return; - if (G.moving && mb->flag==MB_UPDATE_FAST) return; + if (totelem == 0) return; + if (!(G.rendering) && (mb->flag == MB_UPDATE_NEVER)) return; + if (G.moving && mb->flag == MB_UPDATE_FAST) return; - curindex= totindex= 0; - indices= NULL; - thresh= mb->thresh; + curindex = totindex = 0; + indices = NULL; + thresh = mb->thresh; /* total number of MetaElems (totelem) is precomputed in find_basis_mball() function */ - mainb= MEM_mallocN(sizeof(void *)*totelem, "mainb"); + mainb = MEM_mallocN(sizeof(void *) * totelem, "mainb"); /* initialize all mainb (MetaElems) */ - totsize= init_meta(scene, ob); + totsize = init_meta(scene, ob); if (metaball_tree) { free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); - metaball_tree= NULL; + metaball_tree = NULL; } /* if scene includes more then one MetaElem, then octal tree optimalisation is used */ if ((totelem > 1) && (totelem <= 64)) init_metaball_octal_tree(1); if ((totelem > 64) && (totelem <= 128)) init_metaball_octal_tree(2); - if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3); + if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3); if ((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4); if (totelem > 1024) init_metaball_octal_tree(5); /* don't polygonize metaballs with too high resolution (base mball to small) * note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */ if (metaball_tree) { - if ( ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) || - ob->size[1] <= 0.00001f * (metaball_tree->first->y_max - metaball_tree->first->y_min) || - ob->size[2] <= 0.00001f * (metaball_tree->first->z_max - metaball_tree->first->z_min)) + if (ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) || + ob->size[1] <= 0.00001f * (metaball_tree->first->y_max - metaball_tree->first->y_min) || + ob->size[2] <= 0.00001f * (metaball_tree->first->z_max - metaball_tree->first->z_min)) { new_pgn_element(-1); /* free values created by init_meta */ @@ -2324,27 +2328,27 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) /* free tree */ free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); - metaball_tree= NULL; + metaball_tree = NULL; return; } } /* width is size per polygonize cube */ - if (G.rendering) width= mb->rendersize; + if (G.rendering) width = mb->rendersize; else { - width= mb->wiresize; - if (G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2; + width = mb->wiresize; + if (G.moving && mb->flag == MB_UPDATE_HALFRES) width *= 2; } /* nr_cubes is just for safety, minimum is totsize */ - nr_cubes= (int)(0.5f+totsize/width); + nr_cubes = (int)(0.5f + totsize / width); /* init process */ mbproc.function = metaball; mbproc.size = width; mbproc.bounds = nr_cubes; - mbproc.cubes= NULL; - mbproc.delta = width/(float)(RES*RES); + mbproc.cubes = NULL; + mbproc.delta = width / (float)(RES * RES); polygonize(&mbproc, mb); @@ -2354,31 +2358,31 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) if (totelem > 1) { free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); - metaball_tree= NULL; + metaball_tree = NULL; } if (curindex) { - dl= MEM_callocN(sizeof(DispList), "mbaldisp"); + dl = MEM_callocN(sizeof(DispList), "mbaldisp"); BLI_addtail(dispbase, dl); - dl->type= DL_INDEX4; - dl->nr= mbproc.vertices.count; - dl->parts= curindex; + dl->type = DL_INDEX4; + dl->nr = mbproc.vertices.count; + dl->parts = curindex; - dl->index= indices; - indices= NULL; - - a= mbproc.vertices.count; - dl->verts= ve= MEM_mallocN(sizeof(float)*3*a, "mballverts"); - dl->nors= no= MEM_mallocN(sizeof(float)*3*a, "mballnors"); + dl->index = indices; + indices = NULL; - for (a=0; averts = ve = MEM_mallocN(sizeof(float) * 3 * a, "mballverts"); + dl->nors = no = MEM_mallocN(sizeof(float) * 3 * a, "mballnors"); - no[0]= mbproc.vertices.ptr[a].normal.x; - no[1]= mbproc.vertices.ptr[a].normal.y; - no[2]= mbproc.vertices.ptr[a].normal.z; + for (a = 0; a < mbproc.vertices.count; a++, no += 3, ve += 3) { + ve[0] = mbproc.vertices.ptr[a].position.x; + ve[1] = mbproc.vertices.ptr[a].position.y; + ve[2] = mbproc.vertices.ptr[a].position.z; + + no[0] = mbproc.vertices.ptr[a].normal.x; + no[1] = mbproc.vertices.ptr[a].normal.y; + no[2] = mbproc.vertices.ptr[a].normal.z; } } @@ -2402,7 +2406,7 @@ int BKE_metaball_minmax(MetaBall *mb, float min[3], float max[3]) int BKE_metaball_center_median(MetaBall *mb, float cent[3]) { MetaElem *ml; - int total= 0; + int total = 0; zero_v3(cent); @@ -2411,7 +2415,7 @@ int BKE_metaball_center_median(MetaBall *mb, float cent[3]) } if (total) - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); return (total != 0); } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index ffc33e3b86a..ecf6fd8e5de 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -97,28 +97,28 @@ static const char *cmpcode_to_str(int code) case MESHCMP_DVERT_WEIGHTMISMATCH: return "Vertex Weight Mismatch"; case MESHCMP_DVERT_GROUPMISMATCH: - return "Vertex Group Mismatch"; + return "Vertex Group Mismatch"; case MESHCMP_DVERT_TOTGROUPMISMATCH: - return "Vertex Doesn't Belong To Same Number Of Groups"; + return "Vertex Doesn't Belong To Same Number Of Groups"; case MESHCMP_LOOPCOLMISMATCH: - return "Vertex Color Mismatch"; + return "Vertex Color Mismatch"; case MESHCMP_LOOPUVMISMATCH: - return "UV Mismatch"; + return "UV Mismatch"; case MESHCMP_LOOPMISMATCH: - return "Loop Mismatch"; + return "Loop Mismatch"; case MESHCMP_POLYVERTMISMATCH: - return "Loop Vert Mismatch In Poly Test"; + return "Loop Vert Mismatch In Poly Test"; case MESHCMP_POLYMISMATCH: - return "Loop Vert Mismatch"; + return "Loop Vert Mismatch"; case MESHCMP_EDGEUNKNOWN: - return "Edge Mismatch"; + return "Edge Mismatch"; case MESHCMP_VERTCOMISMATCH: - return "Vertex Coordinate Mismatch"; + return "Vertex Coordinate Mismatch"; case MESHCMP_CDLAYERS_MISMATCH: - return "CustomData Layer Count Mismatch"; + return "CustomData Layer Count Mismatch"; default: - return "Mesh Comparison Code Unknown"; - } + return "Mesh Comparison Code Unknown"; + } } /* thresh is threshold for comparing vertices, uvs, vertex colors, @@ -126,7 +126,7 @@ static const char *cmpcode_to_str(int code) static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, float thresh) { CustomDataLayer *l1, *l2; - int i, i1=0, i2=0, tot, j; + int i, i1 = 0, i2 = 0, tot, j; for (i = 0; i < c1->totlayer; i++) { if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, @@ -150,7 +150,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 l1 = c1->layers; l2 = c2->layers; tot = i1; i1 = 0; i2 = 0; - for (i=0; i < tot; i++) { + for (i = 0; i < tot; i++) { while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY, CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) { @@ -168,7 +168,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MVert *v2 = l2->data; int vtot = m1->totvert; - for (j=0; jco, v2->co) > thresh) return MESHCMP_VERTCOMISMATCH; /*I don't care about normals, let's just do coodinates*/ @@ -182,11 +182,11 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 EdgeHash *eh = BLI_edgehash_new(); int etot = m1->totedge; - for (j=0; jv1, e1->v2, e1); } - for (j=0; jv1, e2->v2)) return MESHCMP_EDGEUNKNOWN; } @@ -198,7 +198,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MPoly *p2 = l2->data; int ptot = m1->totpoly; - for (j=0; jmloop + p1->loopstart; lp2 = m2->mloop + p2->loopstart; - for (k=0; ktotloop; k++, lp1++, lp2++) { + for (k = 0; k < p1->totloop; k++, lp1++, lp2++) { if (lp1->v != lp2->v) return MESHCMP_POLYVERTMISMATCH; } @@ -219,7 +219,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MLoop *lp2 = l2->data; int ltot = m1->totloop; - for (j=0; jv != lp2->v) return MESHCMP_LOOPMISMATCH; } @@ -229,7 +229,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MLoopUV *lp2 = l2->data; int ltot = m1->totloop; - for (j=0; juv, lp2->uv) > thresh) return MESHCMP_LOOPUVMISMATCH; } @@ -240,7 +240,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MLoopCol *lp2 = l2->data; int ltot = m1->totloop; - for (j=0; jr - lp2->r) > thresh || ABS(lp1->g - lp2->g) > thresh || ABS(lp1->b - lp2->b) > thresh || @@ -256,14 +256,14 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MDeformVert *dv2 = l2->data; int dvtot = m1->totvert; - for (j=0; jdw, *dw2=dv2->dw; + MDeformWeight *dw1 = dv1->dw, *dw2 = dv2->dw; if (dv1->totweight != dv2->totweight) return MESHCMP_DVERT_TOTGROUPMISMATCH; - for (k=0; ktotweight; k++, dw1++, dw2++) { + for (k = 0; k < dv1->totweight; k++, dw1++, dw2++) { if (dw1->def_nr != dw2->def_nr) return MESHCMP_DVERT_GROUPMISMATCH; if (ABS(dw1->weight - dw2->weight) > thresh) @@ -293,7 +293,7 @@ const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh) if (me1->totpoly != me2->totpoly) return "Number of faces don't match"; - if (me1->totloop !=me2->totloop) + if (me1->totloop != me2->totloop) return "Number of loops don't match"; if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh))) @@ -327,7 +327,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) const int totcol_tessface = CustomData_number_of_layers(&me->fdata, CD_MCOL); if (tottex_tessface != tottex_original || - totcol_tessface != totcol_original ) + totcol_tessface != totcol_original) { BKE_mesh_tessface_clear(me); @@ -340,8 +340,8 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) * and check if there was any data to begin with, for now just print the warning with * some info to help troubleshoot whats going on - campbell */ printf("%s: warning! Tessellation uvs or vcol data got out of sync, " - "had to reset!\n CD_MTFACE: %d != CD_MTEXPOLY: %d || CD_MCOL: %d != CD_MLOOPCOL: %d\n", - __func__, tottex_tessface, tottex_original, totcol_tessface, totcol_original); + "had to reset!\n CD_MTFACE: %d != CD_MTEXPOLY: %d || CD_MCOL: %d != CD_MLOOPCOL: %d\n", + __func__, tottex_tessface, tottex_original, totcol_tessface, totcol_original); } } } @@ -396,19 +396,19 @@ void BKE_mesh_unlink(Mesh *me) { int a; - if (me==NULL) return; + if (me == NULL) return; - for (a=0; atotcol; a++) { + for (a = 0; a < me->totcol; a++) { if (me->mat[a]) me->mat[a]->id.us--; - me->mat[a]= NULL; + me->mat[a] = NULL; } if (me->key) { me->key->id.us--; } - me->key= NULL; + me->key = NULL; - if (me->texcomesh) me->texcomesh= NULL; + if (me->texcomesh) me->texcomesh = NULL; } /* do not free mesh itself */ @@ -425,7 +425,7 @@ void BKE_mesh_free(Mesh *me, int unlink) if (me->adt) { BKE_free_animdata(&me->id); - me->adt= NULL; + me->adt = NULL; } if (me->mat) MEM_freeN(me->mat); @@ -443,12 +443,12 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) if (!src || !dst) return; - memcpy (dst, src, copycount * sizeof(MDeformVert)); + memcpy(dst, src, copycount * sizeof(MDeformVert)); - for (i=0; imesh, 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= BKE_boundbox_alloc_unit(); - me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; + me->size[0] = me->size[1] = me->size[2] = 1.0; + me->smoothresh = 30; + me->texflag = ME_AUTOSPACE; + me->flag = ME_TWOSIDED; + me->bb = BKE_boundbox_alloc_unit(); + me->drawflag = ME_DRAWEDGES | ME_DRAWFACES | ME_DRAWCREASES; return me; } @@ -508,10 +508,10 @@ Mesh *BKE_mesh_copy(Mesh *me) int a, i; const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */ - men= BKE_libblock_copy(&me->id); + men = BKE_libblock_copy(&me->id); - men->mat= MEM_dupallocN(me->mat); - for (a=0; atotcol; a++) { + men->mat = MEM_dupallocN(me->mat); + for (a = 0; a < men->totcol; a++) { id_us_plus((ID *)men->mat[a]); } id_us_plus((ID *)men->texcomesh); @@ -530,33 +530,33 @@ Mesh *BKE_mesh_copy(Mesh *me) mesh_update_customdata_pointers(men, do_tessface); /* ensure indirect linked data becomes lib-extern */ - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; + tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) + for (a = 0; a < me->totface; a++, tface++) if (tface->tpage) - id_lib_extern((ID*)tface->tpage); + id_lib_extern((ID *)tface->tpage); } } - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - txface= (MTexPoly*)me->pdata.layers[i].data; + txface = (MTexPoly *)me->pdata.layers[i].data; - for (a=0; atotpoly; a++, txface++) + for (a = 0; a < me->totpoly; a++, txface++) if (txface->tpage) - id_lib_extern((ID*)txface->tpage); + id_lib_extern((ID *)txface->tpage); } } - men->mselect= NULL; - men->edit_btmesh= NULL; + men->mselect = NULL; + men->edit_btmesh = NULL; - men->bb= MEM_dupallocN(men->bb); + men->bb = MEM_dupallocN(men->bb); - men->key= BKE_key_copy(me->key); - if (men->key) men->key->from= (ID *)men; + men->key = BKE_key_copy(me->key); + if (men->key) men->key->from = (ID *)men; return men; } @@ -579,11 +579,11 @@ static void expand_local_mesh(Mesh *me) if (me->mtface || me->mtpoly) { int a, i; - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - MTexPoly *txface= (MTexPoly*)me->fdata.layers[i].data; + MTexPoly *txface = (MTexPoly *)me->fdata.layers[i].data; - for (a=0; atotpoly; a++, txface++) { + for (a = 0; a < me->totpoly; a++, txface++) { /* special case: ima always local immediately */ if (txface->tpage) { id_lib_extern((ID *)txface->tpage); @@ -592,11 +592,11 @@ static void expand_local_mesh(Mesh *me) } } - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - MTFace *tface= (MTFace*)me->fdata.layers[i].data; + MTFace *tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) { + for (a = 0; a < me->totface; a++, tface++) { /* special case: ima always local immediately */ if (tface->tpage) { id_lib_extern((ID *)tface->tpage); @@ -613,26 +613,26 @@ static void expand_local_mesh(Mesh *me) void BKE_mesh_make_local(Mesh *me) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (me->id.lib==NULL) return; - if (me->id.us==1) { + if (me->id.lib == NULL) return; + if (me->id.us == 1) { id_clear_lib_data(bmain, &me->id); expand_local_mesh(me); return; } - for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { if (me == ob->data) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -641,16 +641,16 @@ void BKE_mesh_make_local(Mesh *me) expand_local_mesh(me); } else if (is_local && is_lib) { - Mesh *me_new= BKE_mesh_copy(me); - me_new->id.us= 0; + Mesh *me_new = BKE_mesh_copy(me); + me_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, me->id.lib, &me_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (me == ob->data) { - if (ob->id.lib==NULL) { + if (ob->id.lib == NULL) { set_mesh(ob, me_new); } } @@ -664,11 +664,11 @@ void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3]) float min[3], max[3]; float mloc[3], msize[3]; - if (me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= me->bb; + if (me->bb == NULL) me->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = me->bb; - if (!r_loc) r_loc= mloc; - if (!r_size) r_size= msize; + if (!r_loc) r_loc = mloc; + if (!r_size) r_size = msize; INIT_MINMAX(min, max); if (!BKE_mesh_minmax(me, min, max)) { @@ -678,9 +678,9 @@ void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3]) mid_v3_v3v3(r_loc, min, max); - r_size[0]= (max[0]-min[0])/2.0f; - r_size[1]= (max[1]-min[1])/2.0f; - r_size[2]= (max[2]-min[2])/2.0f; + r_size[0] = (max[0] - min[0]) / 2.0f; + r_size[1] = (max[1] - min[1]) / 2.0f; + r_size[2] = (max[2] - min[2]) / 2.0f; BKE_boundbox_init_from_minmax(bb, min, max); } @@ -693,10 +693,10 @@ void BKE_mesh_texspace_calc(Mesh *me) BKE_mesh_boundbox_calc(me, loc, size); if (me->texflag & ME_AUTOSPACE) { - for (a=0; a<3; a++) { - if (size[a]==0.0f) size[a]= 1.0f; - else if (size[a]>0.0f && size[a]<0.00001f) size[a]= 0.00001f; - else if (size[a]<0.0f && size[a]> -0.00001f) size[a]= -0.00001f; + for (a = 0; a < 3; a++) { + if (size[a] == 0.0f) size[a] = 1.0f; + else if (size[a] > 0.0f && size[a] < 0.00001f) size[a] = 0.00001f; + else if (size[a] < 0.0f && size[a] > -0.00001f) size[a] = -0.00001f; } copy_v3_v3(me->loc, loc); @@ -707,7 +707,7 @@ void BKE_mesh_texspace_calc(Mesh *me) BoundBox *BKE_mesh_boundbox_get(Object *ob) { - Mesh *me= ob->data; + Mesh *me = ob->data; if (ob->bb) return ob->bb; @@ -724,8 +724,8 @@ void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_siz BKE_mesh_texspace_calc(me); } - if (r_loc) copy_v3_v3(r_loc, me->loc); - if (r_rot) copy_v3_v3(r_rot, me->rot); + if (r_loc) copy_v3_v3(r_loc, me->loc); + if (r_rot) copy_v3_v3(r_rot, me->rot); if (r_size) copy_v3_v3(r_size, me->size); } @@ -733,20 +733,20 @@ float *BKE_mesh_orco_verts_get(Object *ob) { Mesh *me = ob->data; MVert *mvert = NULL; - Mesh *tme = me->texcomesh?me->texcomesh:me; + Mesh *tme = me->texcomesh ? me->texcomesh : me; int a, totvert; float (*vcos)[3] = NULL; /* Get appropriate vertex coordinates */ - vcos = MEM_callocN(sizeof(*vcos)*me->totvert, "orco mesh"); + vcos = MEM_callocN(sizeof(*vcos) * me->totvert, "orco mesh"); mvert = tme->mvert; totvert = MIN2(tme->totvert, me->totvert); - for (a=0; aco); } - return (float*)vcos; + return (float *)vcos; } void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert) @@ -757,17 +757,17 @@ void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, NULL, size); if (invert) { - for (a=0; av3 || nr==4) && mface->v3==mface->v4) { - mface->v4= 0; + if ((mface->v3 || nr == 4) && mface->v3 == mface->v4) { + mface->v4 = 0; nr--; } - if ((mface->v2 || mface->v4) && mface->v2==mface->v3) { - mface->v3= mface->v4; - mface->v4= 0; + if ((mface->v2 || mface->v4) && mface->v2 == mface->v3) { + mface->v3 = mface->v4; + mface->v4 = 0; nr--; } - if (mface->v1==mface->v2) { - mface->v2= mface->v3; - mface->v3= mface->v4; - mface->v4= 0; + if (mface->v1 == mface->v2) { + mface->v2 = mface->v3; + mface->v3 = mface->v4; + mface->v4 = 0; nr--; } /* check corrupt cases, bowtie geometry, cant handle these because edge data wont exist so just return 0 */ - if (nr==3) { + if (nr == 3) { if ( - /* real edges */ - mface->v1==mface->v2 || - mface->v2==mface->v3 || - mface->v3==mface->v1 - ) { + /* real edges */ + mface->v1 == mface->v2 || + mface->v2 == mface->v3 || + mface->v3 == mface->v1) + { return 0; } } - else if (nr==4) { + else if (nr == 4) { if ( - /* real edges */ - mface->v1==mface->v2 || - mface->v2==mface->v3 || - mface->v3==mface->v4 || - mface->v4==mface->v1 || - /* across the face */ - mface->v1==mface->v3 || - mface->v2==mface->v4 - ) { + /* real edges */ + mface->v1 == mface->v2 || + mface->v2 == mface->v3 || + mface->v3 == mface->v4 || + mface->v4 == mface->v1 || + /* across the face */ + mface->v1 == mface->v3 || + mface->v2 == mface->v4 + ) { return 0; } } /* prevent a zero at wrong index location */ - if (nr==3) { - if (mface->v3==0) { + if (nr == 3) { + if (mface->v3 == 0) { static int corner_indices[4] = {1, 2, 0, 3}; SWAP(unsigned int, mface->v1, mface->v2); @@ -831,8 +831,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) CustomData_swap(fdata, mfindex, corner_indices); } } - else if (nr==4) { - if (mface->v3==0 || mface->v4==0) { + else if (nr == 4) { + if (mface->v3 == 0 || mface->v4 == 0) { static int corner_indices[4] = {2, 3, 0, 1}; SWAP(unsigned int, mface->v1, mface->v3); @@ -849,24 +849,24 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) Mesh *BKE_mesh_from_object(Object *ob) { - if (ob==NULL) return NULL; - if (ob->type==OB_MESH) return ob->data; + if (ob == NULL) return NULL; + if (ob->type == OB_MESH) return ob->data; else return NULL; } void set_mesh(Object *ob, Mesh *me) { - Mesh *old=NULL; + Mesh *old = NULL; multires_force_update(ob); - if (ob==NULL) return; + if (ob == NULL) return; - if (ob->type==OB_MESH) { - old= ob->data; + if (ob->type == OB_MESH) { + old = ob->data; if (old) old->id.us--; - ob->data= me; + ob->data = me; id_us_plus((ID *)me); } @@ -887,24 +887,24 @@ static void to_edgesort(struct edgesort *ed, unsigned int v1, unsigned int v2, short is_loose, short is_draw) { - if (v1v1= v1; ed->v2= v2; + if (v1 < v2) { + ed->v1 = v1; ed->v2 = v2; } else { - ed->v1= v2; ed->v2= v1; + ed->v1 = v2; ed->v2 = v1; } - ed->is_loose= is_loose; - ed->is_draw= is_draw; + ed->is_loose = is_loose; + ed->is_draw = is_draw; } static int vergedgesort(const void *v1, const void *v2) { - const struct edgesort *x1=v1, *x2=v2; + const struct edgesort *x1 = v1, *x2 = v2; - if ( x1->v1 > x2->v1) return 1; - else if ( x1->v1 < x2->v1) return -1; - else if ( x1->v2 > x2->v2) return 1; - else if ( x1->v2 < x2->v2) return -1; + if (x1->v1 > x2->v1) return 1; + else if (x1->v1 < x2->v1) return -1; + else if (x1->v2 > x2->v2) return 1; + else if (x1->v2 < x2->v2) return -1; return 0; } @@ -912,8 +912,8 @@ static int vergedgesort(const void *v1, const void *v2) /* Create edges based on known verts and faces */ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *allloop, - MPoly *allpoly, int UNUSED(totvert), int totface, int UNUSED(totloop), int totpoly, - int old, MEdge **alledge, int *_totedge) + MPoly *allpoly, int UNUSED(totvert), int totface, int UNUSED(totloop), int totpoly, + int old, MEdge **alledge, int *_totedge) { MPoly *mpoly; MLoop *mloop; @@ -921,26 +921,26 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll MEdge *medge; EdgeHash *hash = BLI_edgehash_new(); struct edgesort *edsort, *ed; - int a, b, totedge=0, final=0; + int a, b, totedge = 0, final = 0; /* we put all edges in array, sort them, and detect doubles that way */ - for (a= totface, mface= allface; a>0; a--, mface++) { - if (mface->v4) totedge+=4; - else if (mface->v3) totedge+=3; - else totedge+=1; + for (a = totface, mface = allface; a > 0; a--, mface++) { + if (mface->v4) totedge += 4; + else if (mface->v3) totedge += 3; + else totedge += 1; } - if (totedge==0) { + if (totedge == 0) { /* flag that mesh has edges */ - (*alledge)= MEM_callocN(0, "make mesh edges"); + (*alledge) = MEM_callocN(0, "make mesh edges"); (*_totedge) = 0; return; } - ed= edsort= MEM_mallocN(totedge*sizeof(struct edgesort), "edgesort"); + ed = edsort = MEM_mallocN(totedge * sizeof(struct edgesort), "edgesort"); - for (a= totface, mface= allface; a>0; a--, mface++) { + for (a = totface, mface = allface; a > 0; a--, mface++) { to_edgesort(ed++, mface->v1, mface->v2, !mface->v3, mface->edcode & ME_V1V2); if (mface->v4) { to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); @@ -956,54 +956,54 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll qsort(edsort, totedge, sizeof(struct edgesort), vergedgesort); /* count final amount */ - for (a=totedge, ed=edsort; a>1; a--, ed++) { + for (a = totedge, ed = edsort; a > 1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ - if (ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) final++; + if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) final++; } final++; - (*alledge)= medge= MEM_callocN(sizeof (MEdge) * final, "BKE_mesh_make_edges mdge"); - (*_totedge)= final; + (*alledge) = medge = MEM_callocN(sizeof (MEdge) * final, "BKE_mesh_make_edges mdge"); + (*_totedge) = final; - for (a=totedge, ed=edsort; a>1; a--, ed++) { + for (a = totedge, ed = edsort; a > 1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ - if (ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) { - medge->v1= ed->v1; - medge->v2= ed->v2; - if (old==0 || ed->is_draw) medge->flag= ME_EDGEDRAW|ME_EDGERENDER; - if (ed->is_loose) medge->flag|= ME_LOOSEEDGE; + if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) { + medge->v1 = ed->v1; + medge->v2 = ed->v2; + if (old == 0 || ed->is_draw) medge->flag = ME_EDGEDRAW | ME_EDGERENDER; + if (ed->is_loose) medge->flag |= ME_LOOSEEDGE; /* order is swapped so extruding this edge as a surface wont flip face normals * with cyclic curves */ - if (ed->v1+1 != ed->v2) { + if (ed->v1 + 1 != ed->v2) { SWAP(unsigned int, medge->v1, medge->v2); } medge++; } else { /* equal edge, we merge the drawflag */ - (ed+1)->is_draw |= ed->is_draw; + (ed + 1)->is_draw |= ed->is_draw; } } /* last edge */ - medge->v1= ed->v1; - medge->v2= ed->v2; - medge->flag= ME_EDGEDRAW; - if (ed->is_loose) medge->flag|= ME_LOOSEEDGE; + medge->v1 = ed->v1; + medge->v2 = ed->v2; + medge->flag = ME_EDGEDRAW; + if (ed->is_loose) medge->flag |= ME_LOOSEEDGE; medge->flag |= ME_EDGERENDER; MEM_freeN(edsort); /*set edge members of mloops*/ - medge= *alledge; - for (a=0; a<*_totedge; a++, medge++) { + medge = *alledge; + for (a = 0; a < *_totedge; a++, medge++) { BLI_edgehash_insert(hash, medge->v1, medge->v2, SET_INT_IN_POINTER(a)); } mpoly = allpoly; - for (a=0; aloopstart; - for (b=0; btotloop; b++) { + for (b = 0; b < mpoly->totloop; b++) { int v1, v2; v1 = mloop[b].v; @@ -1018,19 +1018,19 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll void BKE_mesh_make_edges(Mesh *me, int old) { MEdge *medge; - int totedge=0; + int totedge = 0; make_edges_mdata(me->mvert, me->mface, me->mloop, me->mpoly, me->totvert, me->totface, me->totloop, me->totpoly, old, &medge, &totedge); - if (totedge==0) { + if (totedge == 0) { /* flag that mesh has edges */ me->medge = medge; me->totedge = 0; return; } - medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); - me->medge= medge; - me->totedge= totedge; + medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); + me->medge = medge; + me->totedge = totedge; BKE_mesh_strip_loose_faces(me); } @@ -1175,50 +1175,50 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me) float *nors, *verts; int a, *index; - dl= lb->first; - if (dl==NULL) return; + dl = lb->first; + if (dl == NULL) return; - if (dl->type==DL_INDEX4) { - mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, dl->nr); - allloop= mloop= CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, dl->parts * 4); - mpoly= CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, dl->parts); - me->mvert= mvert; - me->mloop= mloop; - me->mpoly= mpoly; - me->totvert= dl->nr; - me->totpoly= dl->parts; + if (dl->type == DL_INDEX4) { + mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, dl->nr); + allloop = mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, dl->parts * 4); + mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, dl->parts); + me->mvert = mvert; + me->mloop = mloop; + me->mpoly = mpoly; + me->totvert = dl->nr; + me->totpoly = dl->parts; - a= dl->nr; - nors= dl->nors; - verts= dl->verts; + a = dl->nr; + nors = dl->nors; + verts = dl->verts; while (a--) { copy_v3_v3(mvert->co, verts); normal_float_to_short_v3(mvert->no, nors); mvert++; - nors+= 3; - verts+= 3; + nors += 3; + verts += 3; } - a= dl->parts; - index= dl->index; + a = dl->parts; + index = dl->index; while (a--) { - int count= index[2] != index[3] ? 4 : 3; + int count = index[2] != index[3] ? 4 : 3; - mloop[0].v= index[0]; - mloop[1].v= index[1]; - mloop[2].v= index[2]; + mloop[0].v = index[0]; + mloop[1].v = index[1]; + mloop[2].v = index[2]; if (count == 4) - mloop[3].v= index[3]; + mloop[3].v = index[3]; - mpoly->totloop= count; - mpoly->loopstart= (int)(mloop - allloop); - mpoly->flag= ME_SMOOTH; + mpoly->totloop = count; + mpoly->loopstart = (int)(mloop - allloop); + mpoly->flag = ME_SMOOTH; mpoly++; - mloop+= count; - me->totloop+= count; - index+= 4; + mloop += count; + me->totloop += count; + index += 4; } mesh_update_customdata_pointers(me, TRUE); @@ -1260,46 +1260,46 @@ int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MLoop *mloop; MEdge *medge; float *data; - int a, b, ofs, vertcount, startvert, totvert=0, totedge=0, totloop=0, totvlak=0; + int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0; int p1, p2, p3, p4, *index; - int conv_polys= 0; + int conv_polys = 0; - cu= ob->data; + cu = ob->data; - conv_polys|= cu->flag & CU_3D; /* 2d polys are filled with DL_INDEX3 displists */ - conv_polys|= ob->type == OB_SURF; /* surf polys are never filled */ + conv_polys |= cu->flag & CU_3D; /* 2d polys are filled with DL_INDEX3 displists */ + conv_polys |= ob->type == OB_SURF; /* surf polys are never filled */ /* count */ - dl= dispbase->first; + dl = dispbase->first; while (dl) { - if (dl->type==DL_SEGM) { - totvert+= dl->parts*dl->nr; - totedge+= dl->parts*(dl->nr-1); + if (dl->type == DL_SEGM) { + totvert += dl->parts * dl->nr; + totedge += dl->parts * (dl->nr - 1); } - else if (dl->type==DL_POLY) { + else if (dl->type == DL_POLY) { if (conv_polys) { - totvert+= dl->parts*dl->nr; - totedge+= dl->parts*dl->nr; + totvert += dl->parts * dl->nr; + totedge += dl->parts * dl->nr; } } - else if (dl->type==DL_SURF) { + else if (dl->type == DL_SURF) { int tot; - totvert+= dl->parts*dl->nr; - tot = (dl->parts-1+((dl->flag & DL_CYCL_V)==2))*(dl->nr-1+(dl->flag & DL_CYCL_U)); + totvert += dl->parts * dl->nr; + tot = (dl->parts - 1 + ((dl->flag & DL_CYCL_V) == 2)) * (dl->nr - 1 + (dl->flag & DL_CYCL_U)); totvlak += tot; totloop += tot * 4; } - else if (dl->type==DL_INDEX3) { + else if (dl->type == DL_INDEX3) { int tot; - totvert+= dl->nr; + totvert += dl->nr; tot = dl->parts; - totvlak+= tot; + totvlak += tot; totloop += tot * 3; } - dl= dl->next; + dl = dl->next; } - if (totvert==0) { + if (totvert == 0) { /* error("can't convert"); */ /* Make Sure you check ob->data is a curve */ return -1; @@ -1311,28 +1311,28 @@ int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, *allpoly = mpoly = MEM_callocN(sizeof(MPoly) * totvlak, "nurbs_init mloop"); /* verts and faces */ - vertcount= 0; + vertcount = 0; - dl= dispbase->first; + dl = dispbase->first; while (dl) { - int smooth= dl->rt & CU_SMOOTH ? 1 : 0; + int smooth = dl->rt & CU_SMOOTH ? 1 : 0; - if (dl->type==DL_SEGM) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; + if (dl->type == DL_SEGM) { + startvert = vertcount; + a = dl->parts * dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - for (a=0; aparts; a++) { - ofs= a*dl->nr; - for (b=1; bnr; b++) { - medge->v1= startvert+ofs+b-1; - medge->v2= startvert+ofs+b; + for (a = 0; a < dl->parts; a++) { + ofs = a * dl->nr; + for (b = 1; b < dl->nr; b++) { + medge->v1 = startvert + ofs + b - 1; + medge->v2 = startvert + ofs + b; medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; medge++; @@ -1340,122 +1340,122 @@ int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, } } - else if (dl->type==DL_POLY) { + else if (dl->type == DL_POLY) { if (conv_polys) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; + startvert = vertcount; + a = dl->parts * dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - for (a=0; aparts; a++) { - ofs= a*dl->nr; - for (b=0; bnr; b++) { - medge->v1= startvert+ofs+b; - if (b==dl->nr-1) medge->v2= startvert+ofs; - else medge->v2= startvert+ofs+b+1; + for (a = 0; a < dl->parts; a++) { + ofs = a * dl->nr; + for (b = 0; b < dl->nr; b++) { + medge->v1 = startvert + ofs + b; + if (b == dl->nr - 1) medge->v2 = startvert + ofs; + else medge->v2 = startvert + ofs + b + 1; medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; medge++; } } } } - else if (dl->type==DL_INDEX3) { - startvert= vertcount; - a= dl->nr; - data= dl->verts; + else if (dl->type == DL_INDEX3) { + startvert = vertcount; + a = dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - a= dl->parts; - index= dl->index; + a = dl->parts; + index = dl->index; while (a--) { - mloop[0].v = startvert+index[0]; - mloop[1].v = startvert+index[2]; - mloop[2].v = startvert+index[1]; + mloop[0].v = startvert + index[0]; + mloop[1].v = startvert + index[2]; + mloop[2].v = startvert + index[1]; mpoly->loopstart = (int)(mloop - (*allloop)); mpoly->totloop = 3; mpoly->mat_nr = dl->col; if (smooth) mpoly->flag |= ME_SMOOTH; mpoly++; - mloop+= 3; - index+= 3; + mloop += 3; + index += 3; } } - else if (dl->type==DL_SURF) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; + else if (dl->type == DL_SURF) { + startvert = vertcount; + a = dl->parts * dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - for (a=0; aparts; a++) { + for (a = 0; a < dl->parts; a++) { - if ( (dl->flag & DL_CYCL_V)==0 && a==dl->parts-1) break; + if ( (dl->flag & DL_CYCL_V) == 0 && a == dl->parts - 1) break; - if (dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */ - p1= startvert+ dl->nr*a; /* p4 -> p3 -> */ - p2= p1+ dl->nr-1; /* -----> next row */ - p3= p1+ dl->nr; - p4= p2+ dl->nr; - b= 0; + if (dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */ + p1 = startvert + dl->nr * a; /* p4 -> p3 -> */ + p2 = p1 + dl->nr - 1; /* -----> next row */ + p3 = p1 + dl->nr; + p4 = p2 + dl->nr; + b = 0; } else { - p2= startvert+ dl->nr*a; - p1= p2+1; - p4= p2+ dl->nr; - p3= p1+ dl->nr; - b= 1; + p2 = startvert + dl->nr * a; + p1 = p2 + 1; + p4 = p2 + dl->nr; + p3 = p1 + dl->nr; + b = 1; } - if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) { - p3-= dl->parts*dl->nr; - p4-= dl->parts*dl->nr; + if ( (dl->flag & DL_CYCL_V) && a == dl->parts - 1) { + p3 -= dl->parts * dl->nr; + p4 -= dl->parts * dl->nr; } - for (; bnr; b++) { - mloop[0].v= p1; - mloop[1].v= p3; - mloop[2].v= p4; - mloop[3].v= p2; + for (; b < dl->nr; b++) { + mloop[0].v = p1; + mloop[1].v = p3; + mloop[2].v = p4; + mloop[3].v = p2; mpoly->loopstart = (int)(mloop - (*allloop)); mpoly->totloop = 4; mpoly->mat_nr = dl->col; if (smooth) mpoly->flag |= ME_SMOOTH; mpoly++; - mloop+= 4; + mloop += 4; - p4= p3; + p4 = p3; p3++; - p2= p1; + p2 = p1; p1++; } } } - dl= dl->next; + dl = dl->next; } - *_totpoly= totvlak; - *_totloop= totloop; - *_totedge= totedge; - *_totvert= totvert; + *_totpoly = totvlak; + *_totloop = totloop; + *_totedge = totedge; + *_totvert = totvert; /* not uded for bmesh */ #if 0 @@ -1469,18 +1469,18 @@ int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, /* this may fail replacing ob->data, be sure to check ob->type */ void BKE_mesh_from_nurbs(Object *ob) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob1; - DerivedMesh *dm= ob->derivedFinal; + DerivedMesh *dm = ob->derivedFinal; Mesh *me; Curve *cu; - MVert *allvert= NULL; - MEdge *alledge= NULL; + MVert *allvert = NULL; + MEdge *alledge = NULL; MLoop *allloop = NULL; MPoly *allpoly = NULL; int totvert, totedge, totloop, totpoly; - cu= ob->data; + cu = ob->data; if (dm == NULL) { if (BKE_mesh_nurbs_to_mdata(ob, &allvert, &totvert, @@ -1492,50 +1492,50 @@ void BKE_mesh_from_nurbs(Object *ob) } /* make mesh */ - me= BKE_mesh_add("Mesh"); - me->totvert= totvert; - me->totedge= totedge; + me = BKE_mesh_add("Mesh"); + me->totvert = totvert; + me->totedge = totedge; me->totloop = totloop; me->totpoly = totpoly; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert); - me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge); - me->mloop= CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop); - me->mpoly= CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly); + me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert); + me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge); + me->mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop); + me->mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly); BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); BKE_mesh_calc_edges(me, TRUE); } else { - me= BKE_mesh_add("Mesh"); + me = BKE_mesh_add("Mesh"); DM_to_mesh(dm, me, ob); } - me->totcol= cu->totcol; - me->mat= cu->mat; + me->totcol = cu->totcol; + me->mat = cu->mat; BKE_mesh_texspace_calc(me); - cu->mat= NULL; - cu->totcol= 0; + cu->mat = NULL; + cu->totcol = 0; if (ob->data) { BKE_libblock_free(&bmain->curve, ob->data); } - ob->data= me; - ob->type= OB_MESH; + ob->data = me; + ob->type = OB_MESH; /* other users */ - ob1= bmain->object.first; + ob1 = bmain->object.first; while (ob1) { - if (ob1->data==cu) { - ob1->type= OB_MESH; + if (ob1->data == cu) { + ob1->type = OB_MESH; - ob1->data= ob->data; + ob1->data = ob->data; id_us_plus((ID *)ob->data); } - ob1= ob1->id.next; + ob1 = ob1->id.next; } } @@ -1551,14 +1551,14 @@ typedef struct VertLink { static void prependPolyLineVert(ListBase *lb, unsigned int index) { - VertLink *vl= MEM_callocN(sizeof(VertLink), "VertLink"); + VertLink *vl = MEM_callocN(sizeof(VertLink), "VertLink"); vl->index = index; BLI_addhead(lb, vl); } static void appendPolyLineVert(ListBase *lb, unsigned int index) { - VertLink *vl= MEM_callocN(sizeof(VertLink), "VertLink"); + VertLink *vl = MEM_callocN(sizeof(VertLink), "VertLink"); vl->index = index; BLI_addtail(lb, vl); } @@ -1566,11 +1566,11 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) void BKE_mesh_from_curve(Scene *scene, Object *ob) { /* make new mesh data from the original copy */ - DerivedMesh *dm= mesh_get_derived_final(scene, ob, CD_MASK_MESH); + DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); - MVert *mverts= dm->getVertArray(dm); - MEdge *med, *medge= dm->getEdgeArray(dm); - MFace *mf, *mface= dm->getTessFaceArray(dm); + MVert *mverts = dm->getVertArray(dm); + MEdge *med, *medge = dm->getEdgeArray(dm); + MFace *mf, *mface = dm->getTessFaceArray(dm); int totedge = dm->getNumEdges(dm); int totface = dm->getNumTessFaces(dm); @@ -1585,7 +1585,7 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) ListBase edges = {NULL, NULL}; /* create edges from all faces (so as to find edges not in any faces) */ - mf= mface; + mf = mface; for (i = 0; i < totface; i++, mf++) { if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2)) BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL); @@ -1604,22 +1604,22 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) } } - med= medge; - for (i=0; iv1, med->v2)) { - EdgeLink *edl= MEM_callocN(sizeof(EdgeLink), "EdgeLink"); + EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink"); BLI_edgehash_insert(eh_edge, med->v1, med->v2, NULL); - edl->edge= med; + edl->edge = med; - BLI_addtail(&edges, edl); totedges++; + BLI_addtail(&edges, edl); totedges++; } } BLI_edgehash_free(eh_edge, NULL); BLI_edgehash_free(eh, NULL); if (edges.first) { - Curve *cu = BKE_curve_add(ob->id.name+2, OB_CURVE); + Curve *cu = BKE_curve_add(ob->id.name + 2, OB_CURVE); cu->flag |= CU_3D; while (edges.first) { @@ -1627,55 +1627,55 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) ListBase polyline = {NULL, NULL}; /* store a list of VertLink's */ int closed = FALSE; - int totpoly= 0; - MEdge *med_current= ((EdgeLink *)edges.last)->edge; - unsigned int startVert= med_current->v1; - unsigned int endVert= med_current->v2; - int ok= TRUE; + int totpoly = 0; + MEdge *med_current = ((EdgeLink *)edges.last)->edge; + unsigned int startVert = med_current->v1; + unsigned int endVert = med_current->v2; + int ok = TRUE; - appendPolyLineVert(&polyline, startVert); totpoly++; - appendPolyLineVert(&polyline, endVert); totpoly++; - BLI_freelinkN(&edges, edges.last); totedges--; + appendPolyLineVert(&polyline, startVert); totpoly++; + appendPolyLineVert(&polyline, endVert); totpoly++; + BLI_freelinkN(&edges, edges.last); totedges--; while (ok) { /* while connected edges are found... */ ok = FALSE; - i= totedges; + i = totedges; while (i) { EdgeLink *edl; - i-=1; - edl= BLI_findlink(&edges, i); - med= edl->edge; + i -= 1; + edl = BLI_findlink(&edges, i); + med = edl->edge; - if (med->v1==endVert) { + if (med->v1 == endVert) { endVert = med->v2; - appendPolyLineVert(&polyline, med->v2); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + appendPolyLineVert(&polyline, med->v2); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } - else if (med->v2==endVert) { + else if (med->v2 == endVert) { endVert = med->v1; - appendPolyLineVert(&polyline, endVert); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + appendPolyLineVert(&polyline, endVert); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } - else if (med->v1==startVert) { + else if (med->v1 == startVert) { startVert = med->v2; - prependPolyLineVert(&polyline, startVert); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + prependPolyLineVert(&polyline, startVert); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } - else if (med->v2==startVert) { + else if (med->v2 == startVert) { startVert = med->v1; - prependPolyLineVert(&polyline, startVert); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + prependPolyLineVert(&polyline, startVert); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } } } /* Now we have a polyline, make into a curve */ - if (startVert==endVert) { + if (startVert == endVert) { BLI_freelinkN(&polyline, polyline.last); totpoly--; closed = TRUE; @@ -1690,19 +1690,19 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "MeshNurb"); - nu->pntsu= totpoly; - nu->pntsv= 1; - nu->orderu= 4; - nu->flagu= CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC:0); /* endpoint */ - nu->resolu= 12; + nu->pntsu = totpoly; + nu->pntsv = 1; + nu->orderu = 4; + nu->flagu = CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC : 0); /* endpoint */ + nu->resolu = 12; - nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*totpoly, "bpoints"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * totpoly, "bpoints"); /* add points */ - vl= polyline.first; - for (i=0, bp=nu->bp; i < totpoly; i++, bp++, vl=(VertLink *)vl->next) { + vl = polyline.first; + for (i = 0, bp = nu->bp; i < totpoly; i++, bp++, vl = (VertLink *)vl->next) { copy_v3_v3(bp->vec, mverts[vl->index].co); - bp->f1= SELECT; + bp->f1 = SELECT; bp->radius = bp->weight = 1.0; } BLI_freelistN(&polyline); @@ -1714,11 +1714,11 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) } ((Mesh *)ob->data)->id.us--; - ob->data= cu; - ob->type= OB_CURVE; + ob->data = cu; + ob->type = OB_CURVE; /* curve objects can't contain DM in usual cases, we could free memory */ - needsFree= 1; + needsFree = 1; } dm->needsFree = needsFree; @@ -1730,7 +1730,7 @@ void BKE_mesh_from_curve(Scene *scene, Object *ob) /* curve object could have got bounding box only in special cases */ if (ob->bb) { MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; } } } @@ -1739,15 +1739,15 @@ void BKE_mesh_delete_material_index(Mesh *me, short index) { int i; - for (i=0; itotpoly; i++) { - MPoly *mp = &((MPoly*) me->mpoly)[i]; - if (mp->mat_nr && mp->mat_nr>=index) + for (i = 0; i < me->totpoly; i++) { + MPoly *mp = &((MPoly *) me->mpoly)[i]; + if (mp->mat_nr && mp->mat_nr >= index) mp->mat_nr--; } - for (i=0; itotface; i++) { - MFace *mf = &((MFace*) me->mface)[i]; - if (mf->mat_nr && mf->mat_nr>=index) + for (i = 0; i < me->totface; i++) { + MFace *mf = &((MFace *) me->mface)[i]; + if (mf->mat_nr && mf->mat_nr >= index) mf->mat_nr--; } } @@ -1757,8 +1757,8 @@ void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth) Mesh *me = meshOb->data; int i; - for (i=0; itotpoly; i++) { - MPoly *mp = &((MPoly*) me->mpoly)[i]; + for (i = 0; i < me->totpoly; i++) { + MPoly *mp = &((MPoly *) me->mpoly)[i]; if (enableSmooth) { mp->flag |= ME_SMOOTH; @@ -1768,8 +1768,8 @@ void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth) } } - for (i=0; itotface; i++) { - MFace *mf = &((MFace*) me->mface)[i]; + for (i = 0; i < me->totface; i++) { + MFace *mf = &((MFace *) me->mface)[i]; if (enableSmooth) { mf->flag |= ME_SMOOTH; @@ -1781,8 +1781,8 @@ void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth) } void BKE_mesh_calc_normals_mapping(MVert *mverts, int numVerts, - MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], - MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]) + MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], + MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]) { BKE_mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, numLoops, numPolys, polyNors_r, mfaces, numFaces, @@ -1790,10 +1790,10 @@ void BKE_mesh_calc_normals_mapping(MVert *mverts, int numVerts, } void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, - MLoop *mloop, MPoly *mpolys, - int numLoops, int numPolys, float (*polyNors_r)[3], - MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], - const short only_face_normals) + MLoop *mloop, MPoly *mpolys, + int numLoops, int numPolys, float (*polyNors_r)[3], + MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], + const short only_face_normals) { float (*pnors)[3] = polyNors_r, (*fnors)[3] = faceNors_r; int i; @@ -1822,18 +1822,18 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, else { /* only calc poly normals */ mp = mpolys; - for (i=0; iloopstart, mverts, pnors[i]); + for (i = 0; i < numPolys; i++, mp++) { + mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]); } } - if ( origIndexFace && - /* fnors==faceNors_r */ /* NO NEED TO ALLOC YET */ - fnors != NULL && - numFaces) + if (origIndexFace && + /* fnors==faceNors_r */ /* NO NEED TO ALLOC YET */ + fnors != NULL && + numFaces) { mf = mfaces; - for (i=0; iloopstart, mverts, pnors[i]); + for (i = 0; i < numPolys; i++, mp++) { + mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]); ml = mloop + mp->loopstart; BLI_array_empty(vertcos); @@ -1881,7 +1881,7 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo BLI_array_grow_items(vertcos, mp->totloop); BLI_array_grow_items(vertnos, mp->totloop); - for (j=0; j < mp->totloop; j++) { + for (j = 0; j < mp->totloop; j++) { int vindex = ml[j].v; vertcos[j] = mverts[vindex].co; vertnos[j] = tnorms[vindex]; @@ -1898,9 +1898,9 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo BLI_array_free(edgevecbuf); /* following Mesh convention; we use vertex coordinate itself for normal in this case */ - for (i=0; ico); @@ -1915,15 +1915,15 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3]) { - float (*tnorms)[3]= MEM_callocN(numVerts*sizeof(*tnorms), "tnorms"); - float (*fnors)[3]= (faceNors_r)? faceNors_r: MEM_callocN(sizeof(*fnors)*numFaces, "meshnormals"); + float (*tnorms)[3] = MEM_callocN(numVerts * sizeof(*tnorms), "tnorms"); + float (*fnors)[3] = (faceNors_r) ? faceNors_r : MEM_callocN(sizeof(*fnors) * numFaces, "meshnormals"); int i; - for (i=0; iv4)? tnorms[mf->v4]: NULL; - float *c4 = (mf->v4)? mverts[mf->v4].co: NULL; + for (i = 0; i < numFaces; i++) { + MFace *mf = &mfaces[i]; + float *f_no = fnors[i]; + float *n4 = (mf->v4) ? tnorms[mf->v4] : NULL; + float *c4 = (mf->v4) ? mverts[mf->v4].co : NULL; if (mf->v4) normal_quad_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); @@ -1931,13 +1931,13 @@ void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); accumulate_vertex_normals(tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4, - f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); + f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); } /* following Mesh convention; we use vertex coordinate itself for normal in this case */ - for (i=0; ico); @@ -1964,7 +1964,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, mf = me->mface + findex; - for (i=0; i < numTex; i++) { + for (i = 0; i < numTex; i++) { texface = CustomData_get_n(&me->fdata, CD_MTFACE, findex, i); texpoly = CustomData_get_n(&me->pdata, CD_MTEXPOLY, findex, i); @@ -1980,7 +1980,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, } } - for (i=0; i < numCol; i++) { + for (i = 0; i < numCol; i++) { mloopcol = CustomData_get_n(&me->ldata, CD_MLOOPCOL, loopstart, i); mcol = CustomData_get_n(&me->fdata, CD_MCOL, findex, i); @@ -2001,7 +2001,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, if (CustomData_external_test(&me->fdata, CD_MDISPS)) { CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, - me->totloop, me->fdata.external->filename); + me->totloop, me->fdata.external->filename); } corners = multires_mdisp_corners(fd); @@ -2015,16 +2015,16 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, else { side = sqrt(fd->totdisp / corners); - for (i=0; itotdisp = side*side; + for (i = 0; i < tot; i++, disps += side * side, ld++) { + ld->totdisp = side * side; ld->level = (int)(logf(side - 1.0f) / (float)M_LN2) + 1; if (ld->disps) MEM_freeN(ld->disps); - ld->disps = MEM_callocN(sizeof(float)*3*side*side, "converted loop mdisps"); + ld->disps = MEM_callocN(sizeof(float) * 3 * side * side, "converted loop mdisps"); if (fd->disps) { - memcpy(ld->disps, disps, sizeof(float)*3*side*side); + memcpy(ld->disps, disps, sizeof(float) * 3 * side * side); } } } @@ -2048,7 +2048,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) memset(&mesh->pdata, 0, sizeof(mesh->pdata)); mesh->totpoly = mesh->totface; - mesh->mpoly = MEM_callocN(sizeof(MPoly)*mesh->totpoly, "mpoly converted"); + mesh->mpoly = MEM_callocN(sizeof(MPoly) * mesh->totpoly, "mpoly converted"); CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_ASSIGN, mesh->mpoly, mesh->totpoly); numTex = CustomData_number_of_layers(&mesh->fdata, CD_MTFACE); @@ -2056,16 +2056,16 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) totloop = 0; mf = mesh->mface; - for (i=0; itotface; i++, mf++) { + for (i = 0; i < mesh->totface; i++, mf++) { totloop += mf->v4 ? 4 : 3; } mesh->totloop = totloop; - mesh->mloop = MEM_callocN(sizeof(MLoop)*mesh->totloop, "mloop converted"); + mesh->mloop = MEM_callocN(sizeof(MLoop) * mesh->totloop, "mloop converted"); CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_ASSIGN, mesh->mloop, totloop); CustomData_to_bmeshpoly(&mesh->fdata, &mesh->pdata, &mesh->ldata, - mesh->totloop, mesh->totpoly); + mesh->totloop, mesh->totpoly); /* ensure external data is transferred */ CustomData_external_read(&mesh->fdata, &mesh->id, CD_MASK_MDISPS, mesh->totface); @@ -2085,7 +2085,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) ml = mesh->mloop; mf = mesh->mface; mp = mesh->mpoly; - for (i=0; itotface; i++, mf++, mp++) { + for (i = 0; i < mesh->totface; i++, mf++, mp++) { mp->loopstart = j; mp->totloop = mf->v4 ? 4 : 3; @@ -2093,7 +2093,8 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) mp->mat_nr = mf->mat_nr; mp->flag = mf->flag; -# define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++;} +# define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++; \ +} ML(v1, v2); ML(v2, v3); @@ -2105,7 +2106,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) ML(v3, v1); } -# undef ML +# undef ML bm_corners_to_loops(mesh, i, mp->loopstart, numTex, numCol); } @@ -2118,13 +2119,13 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) BLI_edgehash_free(eh, NULL); } -float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3] +float (*mesh_getVertexCos(Mesh * me, int *numVerts_r))[3] { int i, numVerts = me->totvert; - float (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos1"); + float (*cos)[3] = MEM_mallocN(sizeof(*cos) * numVerts, "vertexcos1"); if (numVerts_r) *numVerts_r = numVerts; - for (i=0; imvert[i].co); return cos; @@ -2141,86 +2142,86 @@ UvVertMap *BKE_mesh_uv_vert_map_make(struct MPoly *mpoly, struct MLoop *mloop, s UvMapVert *buf; MPoly *mp; unsigned int a; - int i, totuv, nverts; + int i, totuv, nverts; totuv = 0; /* generate UvMapVert array */ - mp= mpoly; - for (a=0; aflag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) totuv += mp->totloop; - if (totuv==0) + if (totuv == 0) return NULL; - vmap= (UvVertMap*)MEM_callocN(sizeof(*vmap), "UvVertMap"); + vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap"); if (!vmap) return NULL; - vmap->vert= (UvMapVert**)MEM_callocN(sizeof(*vmap->vert)*totvert, "UvMapVert*"); - buf= vmap->buf= (UvMapVert*)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvMapVert"); + vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*"); + buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { BKE_mesh_uv_vert_map_free(vmap); return NULL; } - mp= mpoly; - for (a=0; aflag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) { - nverts= mp->totloop; + nverts = mp->totloop; - for (i=0; itfindex= i; - buf->f= a; + for (i = 0; i < nverts; i++) { + buf->tfindex = i; + buf->f = a; buf->separate = 0; - buf->next= vmap->vert[mloop[mp->loopstart + i].v]; - vmap->vert[mloop[mp->loopstart + i].v]= buf; + buf->next = vmap->vert[mloop[mp->loopstart + i].v]; + vmap->vert[mloop[mp->loopstart + i].v] = buf; buf++; } } } /* sort individual uvs for each vert */ - for (a=0; avert[a]; + for (a = 0; a < totvert; a++) { + UvMapVert *newvlist = NULL, *vlist = vmap->vert[a]; UvMapVert *iterv, *v, *lastv, *next; float *uv, *uv2, uvdiff[2]; while (vlist) { - v= vlist; - vlist= vlist->next; - v->next= newvlist; - newvlist= v; + v = vlist; + vlist = vlist->next; + v->next = newvlist; + newvlist = v; - uv= mloopuv[mpoly[v->f].loopstart + v->tfindex].uv; - lastv= NULL; - iterv= vlist; + uv = mloopuv[mpoly[v->f].loopstart + v->tfindex].uv; + lastv = NULL; + iterv = vlist; while (iterv) { - next= iterv->next; + next = iterv->next; - uv2= mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv; + uv2 = mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv; sub_v2_v2v2(uvdiff, uv2, uv); - if (fabsf(uv[0]-uv2[0]) < limit[0] && fabsf(uv[1]-uv2[1]) < limit[1]) { - if (lastv) lastv->next= next; - else vlist= next; - iterv->next= newvlist; - newvlist= iterv; + if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1]) { + if (lastv) lastv->next = next; + else vlist = next; + iterv->next = newvlist; + newvlist = iterv; } else - lastv=iterv; + lastv = iterv; - iterv= next; + iterv = next; } newvlist->separate = 1; } - vmap->vert[a]= newvlist; + vmap->vert[a] = newvlist; } return vmap; @@ -2300,7 +2301,7 @@ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, c for (i = 0; i < totedge; ++i) { for (j = 0; j < 2; ++j, ++node) { node->index = i; - BLI_addtail(&(*map)[((unsigned int*)(&medge[i].v1))[j]], node); + BLI_addtail(&(*map)[((unsigned int *)(&medge[i].v1))[j]], node); } } } @@ -2324,22 +2325,22 @@ void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, MLoopUV *mloopuv; int i, j; - for (i=0; i < numTex; i++) { + for (i = 0; i < numTex; i++) { texface = CustomData_get_n(fdata, CD_MTFACE, findex, i); texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i); ME_MTEXFACE_CPY(texface, texpoly); - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, lindex[j], i); copy_v2_v2(texface->uv[j], mloopuv->uv); } } - for (i=0; i < numCol; i++) { + for (i = 0; i < numCol; i++) { mcol = CustomData_get_n(fdata, CD_MCOL, findex, i); - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, lindex[j], i); MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); } @@ -2348,7 +2349,7 @@ void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, if (hasPCol) { mcol = CustomData_get(fdata, findex, CD_PREVIEW_MCOL); - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { mloopcol = CustomData_get(ldata, lindex[j], CD_PREVIEW_MLOOPCOL); MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); } @@ -2358,7 +2359,7 @@ void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, OrigSpaceFace *of = CustomData_get(fdata, findex, CD_ORIGSPACE); OrigSpaceLoop *lof; - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { lof = CustomData_get(ldata, lindex[j], CD_ORIGSPACE_MLOOP); copy_v2_v2(of->uv[j], lof->uv); } @@ -2370,12 +2371,12 @@ void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, * returns number of tessellation faces. */ int BKE_mesh_recalc_tessellation(CustomData *fdata, - CustomData *ldata, CustomData *pdata, - MVert *mvert, int totface, int UNUSED(totloop), - int totpoly, - /* when tessellating to recalculate normals after - * we can skip copying here */ - const int do_face_nor_cpy) + CustomData *ldata, CustomData *pdata, + MVert *mvert, int totface, int UNUSED(totloop), + int totpoly, + /* when tessellating to recalculate normals after + * we can skip copying here */ + const int do_face_nor_cpy) { /* use this to avoid locking pthread for _every_ polygon * and calling the fill function */ @@ -2383,8 +2384,8 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, #define USE_TESSFACE_SPEEDUP #define USE_TESSFACE_QUADS // NEEDS FURTHER TESTING -#define TESSFACE_SCANFILL (1<<0) -#define TESSFACE_IS_QUAD (1<<1) +#define TESSFACE_SCANFILL (1 << 0) +#define TESSFACE_IS_QUAD (1 << 1) MPoly *mp, *mpoly; MLoop *ml, *mloop; @@ -2428,7 +2429,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, BLI_array_grow_one(mface_to_poly_map); \ BLI_array_grow_one(mface); \ mface_to_poly_map[mface_index] = poly_index; \ - mf= &mface[mface_index]; \ + mf = &mface[mface_index]; \ /* set loop indices, transformed to vert indices later */ \ mf->v1 = mp->loopstart + i1; \ mf->v2 = mp->loopstart + i2; \ @@ -2447,7 +2448,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, BLI_array_grow_one(mface_to_poly_map); \ BLI_array_grow_one(mface); \ mface_to_poly_map[mface_index] = poly_index; \ - mf= &mface[mface_index]; \ + mf = &mface[mface_index]; \ /* set loop indices, transformed to vert indices later */ \ mf->v1 = mp->loopstart + 0; /* EXCEPTION */ \ mf->v2 = mp->loopstart + 1; /* EXCEPTION */ \ @@ -2487,7 +2488,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, BLI_scanfill_begin(&sf_ctx); firstv = NULL; lastv = NULL; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { v = BLI_scanfill_vert_add(&sf_ctx, mvert[ml->v].co); v->keyindex = mp->loopstart + j; @@ -2511,7 +2512,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, for (f = sf_ctx.fillfacebase.first; f; f = f->next, mf++) { mface_to_poly_map[mface_index] = poly_index; - mf= &mface[mface_index]; + mf = &mface[mface_index]; /* set loop indices, transformed to vert indices later */ mf->v1 = f->v1->keyindex; @@ -2579,7 +2580,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, } mf = mface; - for (mface_index=0; mface_index < totface; mface_index++, mf++) { + for (mface_index = 0; mface_index < totface; mface_index++, mf++) { #ifdef USE_TESSFACE_QUADS const int mf_len = mf->edcode & TESSFACE_IS_QUAD ? 4 : 3; @@ -2651,7 +2652,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata, * returns number of tessellation faces. */ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly) + struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly) { MLoop *mloop; @@ -2673,7 +2674,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mp = mpoly; k = 0; - for (i = 0; itotloop, 3, 4)) { BLI_array_grow_one(mface); mf = &mface[k]; @@ -2696,7 +2697,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, CustomData_free(fdata, totface); memset(fdata, 0, sizeof(CustomData)); - totface= k; + totface = k; CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface); @@ -2704,7 +2705,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mp = mpoly; k = 0; - for (i = 0; itotloop, 3, 4)) { mf = &mface[k]; @@ -2748,7 +2749,7 @@ int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, test_index_face(mf, fdata, k, 4); } - mf->edcode= 0; + mf->edcode = 0; k++; } @@ -2833,7 +2834,7 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart, } void BKE_mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, - const float (*vertex_coords)[3], float no[3]) + const float (*vertex_coords)[3], float no[3]) { if (mpoly->totloop > 4) { mesh_calc_ngon_normal_coords(mpoly, loopstart, vertex_coords, no); @@ -2863,7 +2864,7 @@ void BKE_mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, static void mesh_calc_ngon_center(MPoly *mpoly, MLoop *loopstart, MVert *mvert, float cent[3]) { - const float w= 1.0f / (float)mpoly->totloop; + const float w = 1.0f / (float)mpoly->totloop; int i; zero_v3(cent); @@ -2874,7 +2875,7 @@ static void mesh_calc_ngon_center(MPoly *mpoly, MLoop *loopstart, } void BKE_mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, - MVert *mvarray, float cent[3]) + MVert *mvarray, float cent[3]) { if (mpoly->totloop == 3) { cent_tri_v3(cent, @@ -2898,7 +2899,7 @@ void BKE_mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, /* note, passing polynormal is only a speedup so we can skip calculating it */ float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, - MVert *mvarray, float polynormal[3]) + MVert *mvarray, float polynormal[3]) { if (mpoly->totloop == 3) { return area_tri_v3(mvarray[loopstart[0].v].co, @@ -2917,7 +2918,7 @@ float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, int i; MLoop *l_iter = loopstart; float area, polynorm_local[3], (*vertexcos)[3]; - float *no= polynormal ? polynormal : polynorm_local; + float *no = polynormal ? polynormal : polynorm_local; BLI_array_fixedstack_declare(vertexcos, BM_NGON_STACK_SIZE, mpoly->totloop, __func__); /* pack vertex cos into an array for area_poly_v3 */ @@ -2942,7 +2943,7 @@ float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, /* Find the index of the loop in 'poly' which references vertex, * returns -1 if not found */ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, - unsigned vert) + unsigned vert) { int j; for (j = 0; j < poly->totloop; j++, loopstart++) { @@ -2957,11 +2958,11 @@ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, * vertex. Returns the index of the loop matching vertex, or -1 if the * vertex is not in 'poly' */ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, - const MLoop *mloop, unsigned vert) + const MLoop *mloop, unsigned vert) { int corner = poly_find_loop_from_vert(poly, - &mloop[poly->loopstart], - vert); + &mloop[poly->loopstart], + vert); if (corner != -1) { const MLoop *ml = &mloop[poly->loopstart + corner]; @@ -2978,9 +2979,9 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, /* update the hide flag for edges and faces from the corresponding * flag in verts */ void BKE_mesh_flush_hidden_from_verts(const MVert *mvert, - const MLoop *mloop, - MEdge *medge, int totedge, - MPoly *mpoly, int totpoly) + const MLoop *mloop, + MEdge *medge, int totedge, + MPoly *mpoly, int totpoly) { int i, j; @@ -3019,15 +3020,15 @@ int BKE_mesh_minmax(Mesh *me, float r_min[3], float r_max[3]) int BKE_mesh_center_median(Mesh *me, float cent[3]) { - int i= me->totvert; + int i = me->totvert; MVert *mvert; zero_v3(cent); - for (mvert= me->mvert; i--; mvert++) { + for (mvert = me->mvert; i--; mvert++) { add_v3_v3(cent, mvert->co); } /* otherwise we get NAN for 0 verts */ if (me->totvert) { - mul_v3_fl(cent, 1.0f/(float)me->totvert); + mul_v3_fl(cent, 1.0f / (float)me->totvert); } return (me->totvert != 0); @@ -3047,17 +3048,17 @@ int BKE_mesh_center_bounds(Mesh *me, float cent[3]) void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys) { - int i= me->totvert; + int i = me->totvert; MVert *mvert; - for (mvert= me->mvert; i--; mvert++) { + for (mvert = me->mvert; i--; mvert++) { add_v3_v3(mvert->co, offset); } if (do_keys && me->key) { KeyBlock *kb; - for (kb=me->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; - for (i= kb->totelem; i--; fp+=3) { + for (kb = me->key->block.first; kb; kb = kb->next) { + float *fp = kb->data; + for (i = kb->totelem; i--; fp += 3) { add_v3_v3(fp, offset); } } @@ -3072,9 +3073,9 @@ void BKE_mesh_ensure_navmesh(Mesh *me) int numFaces = me->totpoly; int *recastData; CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_CALLOC, NULL, numFaces, "recastData"); - recastData = (int*)CustomData_get_layer(&me->pdata, CD_RECAST); - for (i=0; ipdata, CD_RECAST); + for (i = 0; i < numFaces; i++) { + recastData[i] = i + 1; } CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_REFERENCE, recastData, numFaces, "recastData"); } @@ -3083,10 +3084,10 @@ void BKE_mesh_ensure_navmesh(Mesh *me) void BKE_mesh_tessface_calc(Mesh *mesh) { mesh->totface = BKE_mesh_recalc_tessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata, - mesh->mvert, - mesh->totface, mesh->totloop, mesh->totpoly, - /* calc normals right after, don't copy from polys here */ - FALSE); + mesh->mvert, + mesh->totface, mesh->totloop, mesh->totpoly, + /* calc normals right after, don't copy from polys here */ + FALSE); mesh_update_customdata_pointers(mesh, TRUE); } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 849dbd83366..31741718a09 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -71,7 +71,7 @@ #include "BKE_main.h" #include "BKE_utildefines.h" #include "BKE_movieclip.h" -#include "BKE_image.h" /* openanim */ +#include "BKE_image.h" /* openanim */ #include "BKE_tracking.h" #include "IMB_imbuf_types.h" @@ -205,7 +205,7 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, else get_sequence_fname(clip, framenr, name); - loadflag = IB_rect|IB_multilayer; + loadflag = IB_rect | IB_multilayer; /* read ibuf */ ibuf = IMB_loadiffname(name, loadflag); @@ -250,7 +250,7 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in dur = IMB_anim_get_duration(clip->anim, tc); fra = framenr - 1; - if (fra<0) + if (fra < 0) fra = 0; if (fra > (dur - 1)) @@ -283,7 +283,7 @@ static void movieclip_calc_length(MovieClip *clip) clip->len = framenr + 1; } else { - for (;;) { + for (;; ) { get_sequence_fname(clip, framenr, name); if (!BLI_exists(name)) { @@ -338,7 +338,7 @@ typedef struct MovieClipImBufCacheKey { static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags) { - MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)userkey; + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey; *framenr = key->framenr; *proxy = key->proxy; @@ -347,7 +347,7 @@ static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *ren static unsigned int moviecache_hashhash(const void *keyv) { - MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)keyv; + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)keyv; int rval = key->framenr; return rval; @@ -355,8 +355,8 @@ static unsigned int moviecache_hashhash(const void *keyv) static int moviecache_hashcmp(const void *av, const void *bv) { - const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey*)av; - const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey*)bv; + const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey *)av; + const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey *)bv; if (a->framenr < b->framenr) return -1; @@ -406,7 +406,7 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache"); clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash, - moviecache_hashcmp, moviecache_keydata); + moviecache_hashcmp, moviecache_keydata); } key.framenr = user->framenr; @@ -529,8 +529,8 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in break; case MCLIP_PROXY_RENDER_SIZE_75: - *width = ((float)*width)*4.0f/3.0f; - *height = ((float)*height)*4.0f/3.0f; + *width = ((float)*width) * 4.0f / 3.0f; + *height = ((float)*height) * 4.0f / 3.0f; break; } } @@ -669,8 +669,8 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u if (postprocess_flag) { int disable_red = postprocess_flag & MOVIECLIP_DISABLE_RED, disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN, - disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE, - grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE; + disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE, + grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE; if (!postproc_ibuf) postproc_ibuf = IMB_dupImBuf(ibuf); @@ -801,8 +801,8 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int /* check for stabilization parameters */ if (tscale != cache->stabilized.scale || - tangle != cache->stabilized.angle || - !equals_v2v2(tloc, cache->stabilized.loc)) + tangle != cache->stabilized.angle || + !equals_v2v2(tloc, cache->stabilized.loc)) { return NULL; } @@ -1049,17 +1049,17 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip BKE_movieclip_get_size(clip, user, &width, &height); undist_marker.pos[0] *= width; - undist_marker.pos[1] *= height*aspy; + undist_marker.pos[1] *= height * aspy; BKE_tracking_invert_intrinsics(&clip->tracking, undist_marker.pos, undist_marker.pos); undist_marker.pos[0] /= width; - undist_marker.pos[1] /= height*aspy; + undist_marker.pos[1] /= height * aspy; } /* 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 */, - 1 /* anchor */, scopes->track_pos, NULL); + 1 /* anchor */, scopes->track_pos, NULL); if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); @@ -1073,11 +1073,11 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip IMB_freeImBuf(ibuf); } - if ((track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_LOCKED) == 0) { scopes->marker = marker; scopes->track = track; - scopes->slide_scale[0] = track->pat_max[0]-track->pat_min[0]; - scopes->slide_scale[1] = track->pat_max[1]-track->pat_min[1]; + scopes->slide_scale[0] = track->pat_max[0] - track->pat_min[0]; + scopes->slide_scale[1] = track->pat_max[1] - track->pat_min[1]; } } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1057b027d1b..bf279040760 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -115,26 +115,26 @@ #include "GPU_material.h" /* Local function protos */ -static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); +static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); -float originmat[3][3]; /* after BKE_object_where_is_calc(), 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 BKE_object_workob_clear(Object *workob) { memset(workob, 0, sizeof(Object)); - workob->size[0]= workob->size[1]= workob->size[2]= 1.0f; - workob->dscale[0]= workob->dscale[1]= workob->dscale[2]= 1.0f; - workob->rotmode= ROT_MODE_EUL; + workob->size[0] = workob->size[1] = workob->size[2] = 1.0f; + workob->dscale[0] = workob->dscale[1] = workob->dscale[2] = 1.0f; + workob->rotmode = ROT_MODE_EUL; } void BKE_object_update_base_layer(struct Scene *scene, Object *ob) { - Base *base= scene->base.first; + Base *base = scene->base.first; while (base) { - if (base->object == ob) base->lay= ob->lay; - base= base->next; + if (base->object == ob) base->lay = ob->lay; + base = base->next; } } @@ -153,7 +153,7 @@ void BKE_object_free_softbody(Object *ob) { if (ob->soft) { sbFree(ob->soft); - ob->soft= NULL; + ob->soft = NULL; } } @@ -161,7 +161,7 @@ void BKE_object_free_bulletsoftbody(Object *ob) { if (ob->bsoft) { bsbFree(ob->bsoft); - ob->bsoft= NULL; + ob->bsoft = NULL; } } @@ -189,9 +189,9 @@ int BKE_object_support_modifier_type_check(Object *ob, int modifier_type) mti = modifierType_getInfo(modifier_type); if (!((mti->flags & eModifierTypeFlag_AcceptsCVs) || - (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) + (ob->type == OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) { - return FALSE; + return FALSE; } return TRUE; @@ -208,7 +208,7 @@ void BKE_object_link_modifiers(struct Object *ob, struct Object *from) return; } - for (md=from->modifiers.first; md; md=md->next) { + for (md = from->modifiers.first; md; md = md->next) { ModifierData *nmd = NULL; if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue; @@ -234,12 +234,12 @@ void BKE_object_free_display(Object *ob) if (ob->derivedDeform) { ob->derivedDeform->needsFree = 1; ob->derivedDeform->release(ob->derivedDeform); - ob->derivedDeform= NULL; + ob->derivedDeform = NULL; } if (ob->derivedFinal) { ob->derivedFinal->needsFree = 1; ob->derivedFinal->release(ob->derivedFinal); - ob->derivedFinal= NULL; + ob->derivedFinal = NULL; } freedisplist(&ob->disp); @@ -260,12 +260,12 @@ void free_sculptsession(Object *ob) { if (ob && ob->sculpt) { SculptSession *ss = ob->sculpt; - DerivedMesh *dm= ob->derivedFinal; + DerivedMesh *dm = ob->derivedFinal; if (ss->pbvh) BLI_pbvh_free(ss->pbvh); if (dm && dm->getPBVH) - dm->getPBVH(NULL, dm); /* signal to clear */ + dm->getPBVH(NULL, dm); /* signal to clear */ if (ss->texcache) MEM_freeN(ss->texcache); @@ -296,25 +296,25 @@ void BKE_object_free(Object *ob) /* disconnect specific data */ if (ob->data) { - ID *id= ob->data; + ID *id = ob->data; id->us--; - if (id->us==0) { - if (ob->type==OB_MESH) BKE_mesh_unlink(ob->data); - else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data); - else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data); + if (id->us == 0) { + if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data); + else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data); + else if (ob->type == OB_MBALL) BKE_metaball_unlink(ob->data); } - ob->data= NULL; + ob->data = NULL; } - for (a=0; atotcol; a++) { + for (a = 0; a < ob->totcol; a++) { if (ob->mat[a]) ob->mat[a]->id.us--; } if (ob->mat) MEM_freeN(ob->mat); if (ob->matbits) MEM_freeN(ob->matbits); - ob->mat= NULL; - ob->matbits= NULL; + ob->mat = NULL; + ob->matbits = NULL; if (ob->bb) MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; if (ob->adt) BKE_free_animdata((ID *)ob); if (ob->poselib) ob->poselib->id.us--; if (ob->gpd) ((ID *)ob->gpd)->us--; @@ -348,15 +348,15 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec { Object *unlinkOb = userData; - if (*obpoin==unlinkOb) { + if (*obpoin == unlinkOb) { *obpoin = NULL; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA? + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA? } } void BKE_object_unlink(Object *ob) { - Main *bmain= G.main; + Main *bmain = G.main; Object *obt; Material *mat; World *wrld; @@ -378,55 +378,55 @@ void BKE_object_unlink(Object *ob) /* check all objects: parents en bevels and fields, also from libraries */ // FIXME: need to check all animation blocks (drivers) - obt= bmain->object.first; + obt = bmain->object.first; while (obt) { - if (obt->proxy==ob) - obt->proxy= NULL; - if (obt->proxy_from==ob) { - obt->proxy_from= NULL; + if (obt->proxy == ob) + obt->proxy = NULL; + if (obt->proxy_from == ob) { + obt->proxy_from = NULL; obt->recalc |= OB_RECALC_OB; } - if (obt->proxy_group==ob) - obt->proxy_group= NULL; + if (obt->proxy_group == ob) + obt->proxy_group = NULL; - if (obt->parent==ob) { - obt->parent= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (obt->parent == ob) { + obt->parent = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); if (ELEM(obt->type, OB_CURVE, OB_FONT)) { - cu= obt->data; + cu = obt->data; - if (cu->bevobj==ob) { - cu->bevobj= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (cu->bevobj == ob) { + cu->bevobj = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } - if (cu->taperobj==ob) { - cu->taperobj= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (cu->taperobj == ob) { + cu->taperobj = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } - if (cu->textoncurve==ob) { - cu->textoncurve= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (cu->textoncurve == ob) { + cu->textoncurve = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } } - else if (obt->type==OB_ARMATURE && obt->pose) { + else if (obt->type == OB_ARMATURE && obt->pose) { bPoseChannel *pchan; - for (pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = obt->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { ct->tar = NULL; - ct->subtarget[0]= '\0'; + ct->subtarget[0] = '\0'; obt->recalc |= OB_RECALC_DATA; } } @@ -435,29 +435,29 @@ void BKE_object_unlink(Object *ob) cti->flush_constraint_targets(con, &targets, 0); } } - if (pchan->custom==ob) - pchan->custom= NULL; + if (pchan->custom == ob) + pchan->custom = NULL; } } else if (ELEM(OB_MBALL, ob->type, obt->type)) { - if (BKE_metaball_is_basis_for (obt, ob)) - obt->recalc|= OB_RECALC_DATA; + if (BKE_metaball_is_basis_for(obt, ob)) + obt->recalc |= OB_RECALC_DATA; } sca_remove_ob_poin(obt, ob); - for (con = obt->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = obt->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { ct->tar = NULL; - ct->subtarget[0]= '\0'; + ct->subtarget[0] = '\0'; obt->recalc |= OB_RECALC_DATA; } } @@ -473,73 +473,73 @@ void BKE_object_unlink(Object *ob) obt->recalc |= OB_RECALC_DATA; /* cloth */ - for (md=obt->modifiers.first; md; md=md->next) + for (md = obt->modifiers.first; md; md = md->next) if (md->type == eModifierType_Cloth) obt->recalc |= OB_RECALC_DATA; } /* strips */ #if 0 // XXX old animation system - for (strip= obt->nlastrips.first; strip; strip= strip->next) { - if (strip->object==ob) - strip->object= NULL; + for (strip = obt->nlastrips.first; strip; strip = strip->next) { + if (strip->object == ob) + strip->object = NULL; if (strip->modifiers.first) { bActionModifier *amod; - for (amod= strip->modifiers.first; amod; amod= amod->next) - if (amod->ob==ob) - amod->ob= NULL; + for (amod = strip->modifiers.first; amod; amod = amod->next) + if (amod->ob == ob) + amod->ob = NULL; } } #endif // XXX old animation system /* particle systems */ if (obt->particlesystem.first) { - ParticleSystem *tpsys= obt->particlesystem.first; - for (; tpsys; tpsys=tpsys->next) { + ParticleSystem *tpsys = obt->particlesystem.first; + for (; tpsys; tpsys = tpsys->next) { BoidState *state = NULL; BoidRule *rule = NULL; ParticleTarget *pt = tpsys->targets.first; - for (; pt; pt=pt->next) { - if (pt->ob==ob) { + for (; pt; pt = pt->next) { + if (pt->ob == ob) { pt->ob = NULL; obt->recalc |= OB_RECALC_DATA; break; } } - if (tpsys->target_ob==ob) { - tpsys->target_ob= NULL; + if (tpsys->target_ob == ob) { + tpsys->target_ob = NULL; obt->recalc |= OB_RECALC_DATA; } - if (tpsys->part->dup_ob==ob) - tpsys->part->dup_ob= NULL; + if (tpsys->part->dup_ob == ob) + tpsys->part->dup_ob = NULL; - if (tpsys->part->phystype==PART_PHYS_BOIDS) { + if (tpsys->part->phystype == PART_PHYS_BOIDS) { ParticleData *pa; BoidParticle *bpa; int p; - for (p=0, pa=tpsys->particles; ptotpart; p++, pa++) { + for (p = 0, pa = tpsys->particles; p < tpsys->totpart; p++, pa++) { bpa = pa->boid; if (bpa->ground == ob) bpa->ground = NULL; } } if (tpsys->part->boids) { - for (state = tpsys->part->boids->states.first; state; state=state->next) { - for (rule = state->rules.first; rule; rule=rule->next) { - if (rule->type==eBoidRuleType_Avoid) { - BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid*)rule; - if (gabr->ob==ob) - gabr->ob= NULL; + for (state = tpsys->part->boids->states.first; state; state = state->next) { + for (rule = state->rules.first; rule; rule = rule->next) { + if (rule->type == eBoidRuleType_Avoid) { + BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule; + if (gabr->ob == ob) + gabr->ob = NULL; } - else if (rule->type==eBoidRuleType_FollowLeader) { - BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*)rule; - if (flbr->ob==ob) - flbr->ob= NULL; + else if (rule->type == eBoidRuleType_FollowLeader) { + BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule; + if (flbr->ob == ob) + flbr->ob = NULL; } } } @@ -549,64 +549,64 @@ void BKE_object_unlink(Object *ob) obt->recalc |= OB_RECALC_DATA; } - obt= obt->id.next; + obt = obt->id.next; } /* materials */ - mat= bmain->mat.first; + mat = bmain->mat.first; while (mat) { - for (a=0; amtex[a] && ob==mat->mtex[a]->object) { + for (a = 0; a < MAX_MTEX; a++) { + if (mat->mtex[a] && ob == mat->mtex[a]->object) { /* actually, test for lib here... to do */ - mat->mtex[a]->object= NULL; + mat->mtex[a]->object = NULL; } } - mat= mat->id.next; + mat = mat->id.next; } /* textures */ - for (tex= bmain->tex.first; tex; tex= tex->id.next) { - if (tex->env && (ob==tex->env->object)) tex->env->object= NULL; - if (tex->pd && (ob==tex->pd->object)) tex->pd->object= NULL; - if (tex->vd && (ob==tex->vd->object)) tex->vd->object= NULL; + for (tex = bmain->tex.first; tex; tex = tex->id.next) { + if (tex->env && (ob == tex->env->object)) tex->env->object = NULL; + if (tex->pd && (ob == tex->pd->object)) tex->pd->object = NULL; + if (tex->vd && (ob == tex->vd->object)) tex->vd->object = NULL; } /* worlds */ - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - if (wrld->id.lib==NULL) { - for (a=0; amtex[a] && ob==wrld->mtex[a]->object) - wrld->mtex[a]->object= NULL; + if (wrld->id.lib == NULL) { + for (a = 0; a < MAX_MTEX; a++) { + if (wrld->mtex[a] && ob == wrld->mtex[a]->object) + wrld->mtex[a]->object = NULL; } } - wrld= wrld->id.next; + wrld = wrld->id.next; } /* scenes */ - sce= bmain->scene.first; + sce = bmain->scene.first; while (sce) { - if (sce->id.lib==NULL) { - if (sce->camera==ob) sce->camera= NULL; - if (sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL; - if (sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL; + if (sce->id.lib == NULL) { + if (sce->camera == ob) sce->camera = NULL; + if (sce->toolsettings->skgen_template == ob) sce->toolsettings->skgen_template = NULL; + if (sce->toolsettings->particle.object == ob) sce->toolsettings->particle.object = NULL; #ifdef DURIAN_CAMERA_SWITCH { TimeMarker *m; - for (m= sce->markers.first; m; m= m->next) { - if (m->camera==ob) - m->camera= NULL; + for (m = sce->markers.first; m; m = m->next) { + if (m->camera == ob) + m->camera = NULL; } } #endif if (sce->ed) { Sequence *seq; - SEQ_BEGIN (sce->ed, seq) + SEQ_BEGIN(sce->ed, seq) { if (seq->scene_camera == ob) { seq->scene_camera = NULL; @@ -616,19 +616,19 @@ void BKE_object_unlink(Object *ob) } } - sce= sce->id.next; + sce = sce->id.next; } /* screens */ - sc= bmain->screen.first; + sc = bmain->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *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; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; /* found doesn't need to be set here */ if (v3d->ob_centre == ob) { @@ -640,74 +640,74 @@ void BKE_object_unlink(Object *ob) v3d->localvd->ob_centre_bone[0] = '\0'; } - found= 0; - if (v3d->camera==ob) { - v3d->camera= NULL; - found= 1; + found = 0; + if (v3d->camera == ob) { + v3d->camera = NULL; + found = 1; } - if (v3d->localvd && v3d->localvd->camera==ob ) { - v3d->localvd->camera= NULL; + if (v3d->localvd && v3d->localvd->camera == ob) { + v3d->localvd->camera = NULL; found += 2; } if (found) { if (sa->spacetype == SPACE_VIEW3D) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - rv3d= (RegionView3D *)ar->regiondata; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + rv3d = (RegionView3D *)ar->regiondata; if (found == 1 || found == 3) { if (rv3d->persp == RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; + rv3d->persp = RV3D_PERSP; } if (found == 2 || found == 3) { if (rv3d->localvd && rv3d->localvd->persp == RV3D_CAMOB) - rv3d->localvd->persp= RV3D_PERSP; + rv3d->localvd->persp = RV3D_PERSP; } } } } } } - else if (sl->spacetype==SPACE_OUTLINER) { - SpaceOops *so= (SpaceOops *)sl; + else if (sl->spacetype == SPACE_OUTLINER) { + SpaceOops *so = (SpaceOops *)sl; if (so->treestore) { - TreeStoreElem *tselem= so->treestore->data; + TreeStoreElem *tselem = so->treestore->data; int a; - for (a=0; atreestore->usedelem; a++, tselem++) { - if (tselem->id==(ID *)ob) tselem->id= NULL; + for (a = 0; a < so->treestore->usedelem; a++, tselem++) { + if (tselem->id == (ID *)ob) tselem->id = NULL; } } } - else if (sl->spacetype==SPACE_BUTS) { - SpaceButs *sbuts= (SpaceButs *)sl; + else if (sl->spacetype == SPACE_BUTS) { + SpaceButs *sbuts = (SpaceButs *)sl; - if (sbuts->pinid==(ID *)ob) { - sbuts->flag&= ~SB_PIN_CONTEXT; - sbuts->pinid= NULL; + if (sbuts->pinid == (ID *)ob) { + sbuts->flag &= ~SB_PIN_CONTEXT; + sbuts->pinid = NULL; } } } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } /* groups */ - group= bmain->group.first; + group = bmain->group.first; while (group) { rem_from_group(group, ob, NULL, NULL); - group= group->id.next; + group = group->id.next; } /* cameras */ - camera= bmain->camera.first; + camera = bmain->camera.first; while (camera) { - if (camera->dof_ob==ob) { + if (camera->dof_ob == ob) { camera->dof_ob = NULL; } - camera= camera->id.next; + camera = camera->id.next; } } @@ -715,12 +715,12 @@ int BKE_object_exists_check(Object *obtest) { Object *ob; - if (obtest==NULL) return 0; + if (obtest == NULL) return 0; - ob= G.main->object.first; + ob = G.main->object.first; while (ob) { - if (ob==obtest) return 1; - ob= ob->id.next; + if (ob == obtest) return 1; + ob = ob->id.next; } return 0; } @@ -730,40 +730,40 @@ int BKE_object_exists_check(Object *obtest) void *BKE_object_obdata_add_from_type(int type) { switch (type) { - 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; + 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; } } static const char *get_obdata_defname(int type) { switch (type) { - case OB_MESH: return "Mesh"; - case OB_CURVE: return "Curve"; - case OB_SURF: return "Surf"; - case OB_FONT: return "Text"; - case OB_MBALL: return "Mball"; - case OB_CAMERA: return "Camera"; - case OB_LAMP: return "Lamp"; - case OB_LATTICE: return "Lattice"; - case OB_ARMATURE: return "Armature"; - case OB_SPEAKER: return "Speaker"; - case OB_EMPTY: return "Empty"; - default: - printf("get_obdata_defname: Internal error, bad type: %d\n", type); - return "Empty"; + case OB_MESH: return "Mesh"; + case OB_CURVE: return "Curve"; + case OB_SURF: return "Surf"; + case OB_FONT: return "Text"; + case OB_MBALL: return "Mball"; + case OB_CAMERA: return "Camera"; + case OB_LAMP: return "Lamp"; + case OB_LATTICE: return "Lattice"; + case OB_ARMATURE: return "Armature"; + case OB_SPEAKER: return "Speaker"; + case OB_EMPTY: return "Empty"; + default: + printf("get_obdata_defname: Internal error, bad type: %d\n", type); + return "Empty"; } } @@ -772,24 +772,24 @@ Object *BKE_object_add_only_object(int type, const char *name) { Object *ob; - if(!name) + if (!name) name = get_obdata_defname(type); - ob= BKE_libblock_alloc(&G.main->object, ID_OB, name); + ob = BKE_libblock_alloc(&G.main->object, ID_OB, name); /* default object vars */ - ob->type= type; + ob->type = type; - ob->col[0]= ob->col[1]= ob->col[2]= 1.0; - ob->col[3]= 1.0; + ob->col[0] = ob->col[1] = ob->col[2] = 1.0; + ob->col[3] = 1.0; - ob->size[0]= ob->size[1]= ob->size[2]= 1.0; - ob->dscale[0]= ob->dscale[1]= ob->dscale[2]= 1.0; + ob->size[0] = ob->size[1] = ob->size[2] = 1.0; + ob->dscale[0] = ob->dscale[1] = ob->dscale[2] = 1.0; /* objects should default to having Euler XYZ rotations, * but rotations default to quaternions */ - ob->rotmode= ROT_MODE_EUL; + ob->rotmode = ROT_MODE_EUL; unit_axis_angle(ob->rotAxis, &ob->rotAngle); unit_axis_angle(ob->drotAxis, &ob->drotAngle); @@ -803,35 +803,35 @@ Object *BKE_object_add_only_object(int type, const char *name) unit_m4(ob->constinv); unit_m4(ob->parentinv); unit_m4(ob->obmat); - ob->dt= OB_TEXTURE; - ob->empty_drawtype= OB_PLAINAXES; - ob->empty_drawsize= 1.0; + ob->dt = OB_TEXTURE; + ob->empty_drawtype = OB_PLAINAXES; + ob->empty_drawsize = 1.0; - if (type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) { - ob->trackflag= OB_NEGZ; - ob->upflag= OB_POSY; + if (type == OB_CAMERA || type == OB_LAMP || type == OB_SPEAKER) { + ob->trackflag = OB_NEGZ; + ob->upflag = OB_POSY; } else { - ob->trackflag= OB_POSY; - ob->upflag= OB_POSZ; + ob->trackflag = OB_POSY; + ob->upflag = OB_POSZ; } - ob->dupon= 1; ob->dupoff= 0; - ob->dupsta= 1; ob->dupend= 100; + ob->dupon = 1; ob->dupoff = 0; + ob->dupsta = 1; ob->dupend = 100; ob->dupfacesca = 1.0; /* Game engine defaults*/ - ob->mass= ob->inertia= 1.0f; - ob->formfactor= 0.4f; - ob->damping= 0.04f; - ob->rdamping= 0.1f; + ob->mass = ob->inertia = 1.0f; + ob->formfactor = 0.4f; + ob->damping = 0.04f; + ob->rdamping = 0.1f; ob->anisotropicFriction[0] = 1.0f; ob->anisotropicFriction[1] = 1.0f; ob->anisotropicFriction[2] = 1.0f; - ob->gameflag= OB_PROP|OB_COLLISION; + ob->gameflag = OB_PROP | OB_COLLISION; ob->margin = 0.0; - ob->init_state=1; - ob->state=1; + ob->init_state = 1; + ob->state = 1; /* ob->pad3 == Contact Processing Threshold */ ob->m_contactProcessingThreshold = 1.0f; ob->obstacleRad = 1.0f; @@ -858,14 +858,14 @@ Object *BKE_object_add(struct Scene *scene, int type) BLI_strncpy(name, get_obdata_defname(type), sizeof(name)); ob = BKE_object_add_only_object(type, name); - ob->data= BKE_object_obdata_add_from_type(type); + ob->data = BKE_object_obdata_add_from_type(type); - ob->lay= scene->lay; + ob->lay = scene->lay; - base= BKE_scene_base_add(scene, ob); + 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; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; return ob; } @@ -874,19 +874,19 @@ SoftBody *copy_softbody(SoftBody *sb) { SoftBody *sbn; - if (sb==NULL) return(NULL); + if (sb == NULL) return(NULL); - sbn= MEM_dupallocN(sb); - sbn->totspring= sbn->totpoint= 0; - sbn->bpoint= NULL; - sbn->bspring= NULL; + sbn = MEM_dupallocN(sb); + sbn->totspring = sbn->totpoint = 0; + sbn->bpoint = NULL; + sbn->bspring = NULL; - sbn->keys= NULL; - sbn->totkey= sbn->totpointkey= 0; + sbn->keys = NULL; + sbn->totkey = sbn->totpointkey = 0; - sbn->scratch= NULL; + sbn->scratch = NULL; - sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); + sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); if (sb->effector_weights) sbn->effector_weights = MEM_dupallocN(sb->effector_weights); @@ -911,12 +911,12 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) ParticleData *pa; int p; - psysn= MEM_dupallocN(psys); - psysn->particles= MEM_dupallocN(psys->particles); - psysn->child= MEM_dupallocN(psys->child); + psysn = MEM_dupallocN(psys); + psysn->particles = MEM_dupallocN(psys->particles); + psysn->child = MEM_dupallocN(psys->child); if (psys->part->type == PART_HAIR) { - for (p=0, pa=psysn->particles; ptotpart; p++, pa++) + for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++) pa->hair = MEM_dupallocN(pa->hair); } @@ -930,7 +930,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) if (boid) boid = MEM_dupallocN(boid); - for (p=0, pa=psysn->particles; ptotpart; p++, pa++) { + for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++) { if (boid) pa->boid = boid++; if (key) { @@ -942,29 +942,29 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) if (psys->clmd) { psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); - modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)psysn->clmd); + modifier_copyData((ModifierData *)psys->clmd, (ModifierData *)psysn->clmd); psys->hair_in_dm = psys->hair_out_dm = NULL; } BLI_duplicatelist(&psysn->targets, &psys->targets); - psysn->pathcache= NULL; - psysn->childcache= NULL; - psysn->edit= NULL; - psysn->frand= NULL; - psysn->pdd= NULL; - psysn->effectors= NULL; + psysn->pathcache = NULL; + psysn->childcache = NULL; + psysn->edit = NULL; + psysn->frand = NULL; + psysn->pdd = NULL; + psysn->effectors = NULL; psysn->pathcachebufs.first = psysn->pathcachebufs.last = NULL; psysn->childcachebufs.first = psysn->childcachebufs.last = NULL; psysn->renderdata = NULL; - psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); + psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); /* XXX - from reading existing code this seems correct but intended usage of * pointcache should /w cloth should be added in 'ParticleSystem' - campbell */ if (psysn->clmd) { - psysn->clmd->point_cache= psysn->pointcache; + psysn->clmd->point_cache = psysn->pointcache; } id_us_plus((ID *)psysn->part); @@ -982,34 +982,34 @@ void BKE_object_copy_particlesystems(Object *obn, Object *ob) return; } - obn->particlesystem.first= obn->particlesystem.last= NULL; - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - npsys= copy_particlesystem(psys); + obn->particlesystem.first = obn->particlesystem.last = NULL; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + npsys = copy_particlesystem(psys); BLI_addtail(&obn->particlesystem, npsys); /* need to update particle modifiers too */ - for (md=obn->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_ParticleSystem) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*)md; - if (psmd->psys==psys) - psmd->psys= npsys; + for (md = obn->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_ParticleSystem) { + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; + if (psmd->psys == psys) + psmd->psys = npsys; } - else if (md->type==eModifierType_DynamicPaint) { - DynamicPaintModifierData *pmd= (DynamicPaintModifierData*)md; + else if (md->type == eModifierType_DynamicPaint) { + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; if (pmd->brush) { - if (pmd->brush->psys==psys) { - pmd->brush->psys= npsys; + if (pmd->brush->psys == psys) { + pmd->brush->psys = npsys; } } } - else if (md->type==eModifierType_Smoke) { - SmokeModifierData *smd = (SmokeModifierData*) md; + else if (md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *) md; - if (smd->type==MOD_SMOKE_TYPE_FLOW) { + if (smd->type == MOD_SMOKE_TYPE_FLOW) { if (smd->flow) { if (smd->flow->psys == psys) - smd->flow->psys= npsys; + smd->flow->psys = npsys; } } } @@ -1020,7 +1020,7 @@ void BKE_object_copy_particlesystems(Object *obn, Object *ob) void BKE_object_copy_softbody(Object *obn, Object *ob) { if (ob->soft) - obn->soft= copy_softbody(ob->soft); + obn->soft = copy_softbody(ob->soft); } static void copy_object_pose(Object *obn, Object *ob) @@ -1028,23 +1028,23 @@ static void copy_object_pose(Object *obn, Object *ob) bPoseChannel *chan; /* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */ - obn->pose= NULL; - BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */ + obn->pose = NULL; + BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */ - for (chan = obn->pose->chanbase.first; chan; chan=chan->next) { + for (chan = obn->pose->chanbase.first; chan; chan = chan->next) { bConstraint *con; - chan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); + chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); - for (con= chan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = chan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) ct->tar = obn; } @@ -1058,11 +1058,11 @@ static void copy_object_pose(Object *obn, Object *ob) static int object_pose_context(Object *ob) { - if ( (ob) && - (ob->type == OB_ARMATURE) && - (ob->pose) && - (ob->mode & OB_MODE_POSE) - ) { + if ( (ob) && + (ob->type == OB_ARMATURE) && + (ob->pose) && + (ob->mode & OB_MODE_POSE)) + { return 1; } else { @@ -1072,13 +1072,13 @@ static int object_pose_context(Object *ob) Object *BKE_object_pose_armature_get(Object *ob) { - if (ob==NULL) + if (ob == NULL) return NULL; if (object_pose_context(ob)) return ob; - ob= modifiers_isDeformedByArmature(ob); + ob = modifiers_isDeformedByArmature(ob); if (object_pose_context(ob)) return ob; @@ -1092,8 +1092,8 @@ static void copy_object_transform(Object *ob_tar, Object *ob_src) copy_v3_v3(ob_tar->rot, ob_src->rot); copy_v3_v3(ob_tar->quat, ob_src->quat); copy_v3_v3(ob_tar->rotAxis, ob_src->rotAxis); - ob_tar->rotAngle= ob_src->rotAngle; - ob_tar->rotmode= ob_src->rotmode; + ob_tar->rotAngle = ob_src->rotAngle; + ob_tar->rotmode = ob_src->rotmode; copy_v3_v3(ob_tar->size, ob_src->size); } @@ -1103,20 +1103,20 @@ Object *BKE_object_copy(Object *ob) ModifierData *md; int a; - obn= BKE_libblock_copy(&ob->id); + obn = BKE_libblock_copy(&ob->id); if (ob->totcol) { - obn->mat= MEM_dupallocN(ob->mat); - obn->matbits= MEM_dupallocN(ob->matbits); - obn->totcol= ob->totcol; + obn->mat = MEM_dupallocN(ob->mat); + obn->matbits = MEM_dupallocN(ob->matbits); + obn->totcol = ob->totcol; } - if (ob->bb) obn->bb= MEM_dupallocN(ob->bb); + if (ob->bb) obn->bb = MEM_dupallocN(ob->bb); obn->flag &= ~OB_FROMGROUP; - obn->modifiers.first = obn->modifiers.last= NULL; + obn->modifiers.first = obn->modifiers.last = NULL; - for (md=ob->modifiers.first; md; md=md->next) { + for (md = ob->modifiers.first; md; md = md->next) { ModifierData *nmd = modifier_new(md->type); BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); modifier_copyData(md, nmd); @@ -1133,7 +1133,7 @@ Object *BKE_object_copy(Object *ob) if (ob->pose) { copy_object_pose(obn, ob); /* backwards compat... non-armatures can get poses in older files? */ - if (ob->type==OB_ARMATURE) + if (ob->type == OB_ARMATURE) BKE_pose_rebuild(obn, obn->data); } defgroup_copy_list(&obn->defbase, &ob->defbase); @@ -1147,18 +1147,18 @@ Object *BKE_object_copy(Object *ob) id_us_plus((ID *)obn->gpd); id_lib_extern((ID *)obn->dup_group); - for (a=0; atotcol; a++) id_us_plus((ID *)obn->mat[a]); + for (a = 0; a < obn->totcol; a++) id_us_plus((ID *)obn->mat[a]); - obn->disp.first= obn->disp.last= NULL; + obn->disp.first = obn->disp.last = NULL; if (ob->pd) { - obn->pd= MEM_dupallocN(ob->pd); + obn->pd = MEM_dupallocN(ob->pd); if (obn->pd->tex) id_us_plus(&(obn->pd->tex->id)); if (obn->pd->rng) obn->pd->rng = MEM_dupallocN(ob->pd->rng); } - obn->soft= copy_softbody(ob->soft); + obn->soft = copy_softbody(ob->soft); obn->bsoft = copy_bulletsoftbody(ob->bsoft); BKE_object_copy_particlesystems(obn, ob); @@ -1169,7 +1169,7 @@ Object *BKE_object_copy(Object *ob) obn->gpulamp.first = obn->gpulamp.last = NULL; obn->pc_ids.first = obn->pc_ids.last = NULL; - obn->mpath= NULL; + obn->mpath = NULL; return obn; } @@ -1185,35 +1185,35 @@ static void extern_local_object(Object *ob) extern_local_matarar(ob->mat, ob->totcol); - for (psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys = ob->particlesystem.first; psys; psys = psys->next) id_lib_extern((ID *)psys->part); } void BKE_object_make_local(Object *ob) { - Main *bmain= G.main; + Main *bmain = G.main; Scene *sce; Base *base; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (ob->id.lib==NULL) return; + if (ob->id.lib == NULL) return; - ob->proxy= ob->proxy_from= NULL; + ob->proxy = ob->proxy_from = NULL; - if (ob->id.us==1) { + if (ob->id.us == 1) { id_clear_lib_data(bmain, &ob->id); extern_local_object(ob); } else { - for (sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) { + for (sce = bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce = sce->id.next) { if (BKE_scene_base_find(sce, ob)) { - if (sce->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (sce->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -1222,27 +1222,27 @@ void BKE_object_make_local(Object *ob) extern_local_object(ob); } else if (is_local && is_lib) { - Object *ob_new= BKE_object_copy(ob); + Object *ob_new = BKE_object_copy(ob); - ob_new->id.us= 0; + ob_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, ob->id.lib, &ob_new->id); - sce= bmain->scene.first; + sce = bmain->scene.first; while (sce) { - if (sce->id.lib==NULL) { - base= sce->base.first; + if (sce->id.lib == NULL) { + base = sce->base.first; while (base) { - if (base->object==ob) { - base->object= ob_new; + if (base->object == ob) { + base->object = ob_new; ob_new->id.us++; ob->id.us--; } - base= base->next; + base = base->next; } } - sce= sce->id.next; + sce = sce->id.next; } } } @@ -1263,9 +1263,9 @@ int BKE_object_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; + if (ob->proxy && (ob->data == NULL || ((ID *)ob->data)->lib == NULL)) return 0; if (ob->id.lib) return 1; - if (ob->data==NULL) return 0; + if (ob->data == NULL) return 0; if (((ID *)ob->data)->lib) return 1; return 0; @@ -1276,11 +1276,11 @@ int BKE_object_obdata_is_libdata(Object *ob) /* when you make proxy, ensure the exposed layers are extern */ static void armature_set_id_extern(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; - unsigned int lay= arm->layer_protected; + unsigned int lay = arm->layer_protected; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (!(pchan->bone->layer & lay)) id_lib_extern((ID *)pchan->custom); } @@ -1294,27 +1294,27 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target) /* add new animdata block */ if (!ob->adt) - ob->adt= BKE_id_add_animdata(&ob->id); + ob->adt = BKE_id_add_animdata(&ob->id); /* make a copy of all the drivers (for now), then correct any links that need fixing */ free_fcurves(&ob->adt->drivers); copy_fcurves(&ob->adt->drivers, &target->adt->drivers); - for (fcu= ob->adt->drivers.first; fcu; fcu= fcu->next) { - ChannelDriver *driver= fcu->driver; + for (fcu = ob->adt->drivers.first; fcu; fcu = fcu->next) { + ChannelDriver *driver = fcu->driver; DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* all drivers */ DRIVER_TARGETS_LOOPER(dvar) { if (dtar->id) { if ((Object *)dtar->id == target) - dtar->id= (ID *)ob; + dtar->id = (ID *)ob; else { /* only on local objects because this causes indirect links a -> b -> c, blend to point directly to a.blend * when a.blend has a proxy thats linked into c.blend */ - if (ob->id.lib==NULL) + if (ob->id.lib == NULL) id_lib_extern((ID *)dtar->id); } } @@ -1332,16 +1332,16 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target) void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) { /* paranoia checks */ - if (ob->id.lib || target->id.lib==NULL) { + if (ob->id.lib || target->id.lib == NULL) { printf("cannot make proxy\n"); return; } - ob->proxy= target; - ob->proxy_group= gob; + ob->proxy = target; + ob->proxy_group = gob; id_lib_extern(&target->id); - ob->recalc= target->recalc= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc = target->recalc = OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* copy transform * - gob means this proxy comes from a group, just apply the matrix @@ -1350,7 +1350,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) * - no gob means this is being made from a linked object, * this is closer to making a copy of the object - in-place. */ if (gob) { - ob->rotmode= target->rotmode; + ob->rotmode = target->rotmode; mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat); if (gob->dup_group) { /* should always be true */ float tvec[3]; @@ -1362,7 +1362,7 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) } else { copy_object_transform(ob, target); - ob->parent= target->parent; /* libdata */ + ob->parent = target->parent; /* libdata */ copy_m4_m4(ob->parentinv, target->parentinv); } @@ -1373,25 +1373,25 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) // FIXME: this is considered by many as a bug /* set object type and link to data */ - ob->type= target->type; - ob->data= target->data; - id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */ + ob->type = target->type; + ob->data = target->data; + id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */ /* copy material and index information */ - ob->actcol= ob->totcol= 0; + ob->actcol = ob->totcol = 0; if (ob->mat) MEM_freeN(ob->mat); if (ob->matbits) MEM_freeN(ob->matbits); ob->mat = NULL; - ob->matbits= NULL; + ob->matbits = NULL; if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { int i; - ob->actcol= target->actcol; - ob->totcol= target->totcol; + ob->actcol = target->actcol; + ob->totcol = target->totcol; ob->mat = MEM_dupallocN(target->mat); ob->matbits = MEM_dupallocN(target->matbits); - for (i=0; itotcol; i++) { + for (i = 0; i < target->totcol; i++) { /* don't need to run test_object_materials since we know this object is new and not used elsewhere */ id_us_plus((ID *)ob->mat[i]); } @@ -1399,9 +1399,9 @@ 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 */ - BKE_pose_rest(ob->pose); /* clear all transforms in channels */ - BKE_pose_rebuild(ob, ob->data); /* set all internal links */ + copy_object_pose(ob, target); /* data copy, object pointers in constraints */ + 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); } @@ -1414,14 +1414,14 @@ void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) if (ob->id.properties) { IDP_FreeProperty(ob->id.properties); MEM_freeN(ob->id.properties); - ob->id.properties= NULL; + ob->id.properties = NULL; } if (target->id.properties) { - ob->id.properties= IDP_CopyProperty(target->id.properties); + ob->id.properties = IDP_CopyProperty(target->id.properties); } /* copy drawtype info */ - ob->dt= target->dt; + ob->dt = target->dt; } @@ -1471,7 +1471,7 @@ void BKE_object_rot_to_mat3(Object *ob, float mat[][3]) void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { switch (ob->rotmode) { - case ROT_MODE_QUAT: + case ROT_MODE_QUAT: { float dquat[4]; mat3_to_quat(ob->quat, mat); @@ -1480,12 +1480,12 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) mul_qt_qtqt(ob->quat, dquat, ob->quat); } break; - case ROT_MODE_AXISANGLE: - mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); - sub_v3_v3(ob->rotAxis, ob->drotAxis); - ob->rotAngle -= ob->drotAngle; - break; - default: /* euler */ + case ROT_MODE_AXISANGLE: + mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); + sub_v3_v3(ob->rotAxis, ob->drotAxis); + ob->rotAngle -= ob->drotAngle; + break; + default: /* euler */ { float quat[4]; float dquat[4]; @@ -1499,19 +1499,19 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) quat_to_mat3(tmat, quat); /* end drot correction */ - if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat); - else mat3_to_eulO(ob->rot, ob->rotmode, tmat); + if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat); + else mat3_to_eulO(ob->rot, ob->rotmode, tmat); } } } void BKE_object_tfm_protected_backup(const Object *ob, - ObjectTfmProtectedChannels *obtfm) + ObjectTfmProtectedChannels *obtfm) { -#define TFMCPY( _v) (obtfm->_v = ob->_v) -#define TFMCPY3D( _v) copy_v3_v3(obtfm->_v, ob->_v) -#define TFMCPY4D( _v) copy_v4_v4(obtfm->_v, ob->_v) +#define TFMCPY(_v) (obtfm->_v = ob->_v) +#define TFMCPY3D(_v) copy_v3_v3(obtfm->_v, ob->_v) +#define TFMCPY4D(_v) copy_v4_v4(obtfm->_v, ob->_v) TFMCPY3D(loc); TFMCPY3D(dloc); @@ -1533,40 +1533,40 @@ void BKE_object_tfm_protected_backup(const Object *ob, } void BKE_object_tfm_protected_restore(Object *ob, - const ObjectTfmProtectedChannels *obtfm, - const short protectflag) + const ObjectTfmProtectedChannels *obtfm, + const short protectflag) { unsigned int i; - for (i= 0; i < 3; i++) { - if (protectflag & (OB_LOCK_LOCX<loc[i]= obtfm->loc[i]; - ob->dloc[i]= obtfm->dloc[i]; + for (i = 0; i < 3; i++) { + if (protectflag & (OB_LOCK_LOCX << i)) { + ob->loc[i] = obtfm->loc[i]; + ob->dloc[i] = obtfm->dloc[i]; } - if (protectflag & (OB_LOCK_SCALEX<size[i]= obtfm->size[i]; - ob->dscale[i]= obtfm->dscale[i]; + if (protectflag & (OB_LOCK_SCALEX << i)) { + ob->size[i] = obtfm->size[i]; + ob->dscale[i] = obtfm->dscale[i]; } - if (protectflag & (OB_LOCK_ROTX<rot[i]= obtfm->rot[i]; - ob->drot[i]= obtfm->drot[i]; + if (protectflag & (OB_LOCK_ROTX << i)) { + ob->rot[i] = obtfm->rot[i]; + ob->drot[i] = obtfm->drot[i]; - ob->quat[i + 1]= obtfm->quat[i + 1]; - ob->dquat[i + 1]= obtfm->dquat[i + 1]; + ob->quat[i + 1] = obtfm->quat[i + 1]; + ob->dquat[i + 1] = obtfm->dquat[i + 1]; - ob->rotAxis[i]= obtfm->rotAxis[i]; - ob->drotAxis[i]= obtfm->drotAxis[i]; + ob->rotAxis[i] = obtfm->rotAxis[i]; + ob->drotAxis[i] = obtfm->drotAxis[i]; } } if ((protectflag & OB_LOCK_ROT4D) && (protectflag & OB_LOCK_ROTW)) { - ob->quat[0]= obtfm->quat[0]; - ob->dquat[0]= obtfm->dquat[0]; + ob->quat[0] = obtfm->quat[0]; + ob->dquat[0] = obtfm->dquat[0]; - ob->rotAngle= obtfm->rotAngle; - ob->drotAngle= obtfm->drotAngle; + ob->rotAngle = obtfm->rotAngle; + ob->drotAngle = obtfm->drotAngle; } } @@ -1600,7 +1600,7 @@ void BKE_object_apply_mat4(Object *ob, float mat[][4], const short use_compat, c /* BKE_object_mat3_to_rot handles delta rotations */ } -void BKE_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]; @@ -1626,7 +1626,7 @@ void BKE_object_to_mat4(Object *ob, float mat[][4]) } /* extern */ -int enable_cu_speed= 1; +int enable_cu_speed = 1; static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) { @@ -1636,14 +1636,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) unit_m4(mat); - cu= par->data; - if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */ + cu = par->data; + if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ makeDispListCurveTypes(scene, par, 0); - if (cu->path==NULL) return; + if (cu->path == NULL) return; /* catch exceptions: feature for nla stride editing */ if (ob->ipoflag & OB_DISABLE_PATH) { - ctime= 0.0f; + ctime = 0.0f; } /* catch exceptions: curve paths used as a duplicator */ else if (enable_cu_speed) { @@ -1654,14 +1654,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) * factor, which then gets clamped to lie within 0.0 - 1.0 range */ if (IS_EQF(cu->pathlen, 0.0f) == 0) - ctime= cu->ctime / cu->pathlen; + ctime = cu->ctime / cu->pathlen; else - ctime= cu->ctime; + ctime = cu->ctime; CLAMP(ctime, 0.0f, 1.0f); } else { - ctime= scene->r.cfra; + ctime = scene->r.cfra; if (IS_EQF(cu->pathlen, 0.0f) == 0) ctime /= cu->pathlen; @@ -1670,7 +1670,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* time calculus is correct, now apply distance offset */ if (cu->flag & CU_OFFS_PATHDIST) { - ctime += timeoffs/cu->path->totdist; + ctime += timeoffs / cu->path->totdist; /* restore */ SWAP(float, sf_orig, ob->sf); @@ -1678,7 +1678,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* vec: 4 items! */ - if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL)) { + if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat : NULL, &radius, NULL)) { if (cu->flag & CU_FOLLOW) { #if 0 @@ -1687,11 +1687,11 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* the tilt */ normalize_v3(dir); - q[0]= (float)cos(0.5*vec[3]); - x1= (float)sin(0.5*vec[3]); - q[1]= -x1*dir[0]; - q[2]= -x1*dir[1]; - q[3]= -x1*dir[2]; + q[0] = (float)cos(0.5 * vec[3]); + x1 = (float)sin(0.5 * vec[3]); + q[1] = -x1 * dir[0]; + q[2] = -x1 * dir[1]; + q[3] = -x1 * dir[2]; mul_qt_qtqt(quat, q, quat); #else quat_apply_track(quat, ob->trackflag, ob->upflag); @@ -1717,15 +1717,15 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) bPoseChannel *pchan; float vec[3]; - if (par->type!=OB_ARMATURE) { + if (par->type != OB_ARMATURE) { unit_m4(mat); return; } /* Make sure the bone is still valid */ - pchan= BKE_pose_channel_find_name(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); + printf("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name + 2, ob->parsubstr); unit_m4(mat); return; } @@ -1744,15 +1744,15 @@ static void give_parvert(Object *par, int nr, float vec[3]) BMEditMesh *em; int a, count; - vec[0]=vec[1]=vec[2]= 0.0f; + vec[0] = vec[1] = vec[2] = 0.0f; - if (par->type==OB_MESH) { - Mesh *me= par->data; + if (par->type == OB_MESH) { + Mesh *me = par->data; DerivedMesh *dm; em = me->edit_btmesh; -#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/ +#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/ if (em) { BMVert *eve; BMIter iter; @@ -1760,7 +1760,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); - if (keyindex && *keyindex==nr) { + if (keyindex && *keyindex == nr) { copy_v3_v3(vec, eve->co); break; } @@ -1768,17 +1768,17 @@ static void give_parvert(Object *par, int nr, float vec[3]) } #endif - dm = (em)? em->derivedFinal: par->derivedFinal; + dm = (em) ? em->derivedFinal : par->derivedFinal; if (dm) { - MVert *mvert= dm->getVertArray(dm); + MVert *mvert = dm->getVertArray(dm); int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); int i, vindex, numVerts = dm->getNumVerts(dm); /* get the average of all verts with (original index == nr) */ - count= 0; + count = 0; for (i = 0; i < numVerts; i++) { - vindex= (index)? index[i]: i; + vindex = (index) ? index[i] : i; if (vindex == nr) { add_v3_v3(vec, mvert[i].co); @@ -1786,7 +1786,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } - if (count==0) { + if (count == 0) { /* keep as 0, 0, 0 */ } else if (count > 0) { @@ -1804,21 +1804,21 @@ static void give_parvert(Object *par, int nr, float vec[3]) Curve *cu; BPoint *bp; BezTriple *bezt; - int found= 0; + int found = 0; ListBase *nurbs; - cu= par->data; - nurbs= BKE_curve_nurbs_get(cu); - nu= nurbs->first; + cu = par->data; + nurbs = BKE_curve_nurbs_get(cu); + nu = nurbs->first; - count= 0; + count = 0; while (nu && !found) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (count==nr) { - found= 1; + if (count == nr) { + found = 1; copy_v3_v3(vec, bezt->vec[1]); break; } @@ -1827,43 +1827,43 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if (count==nr) { - found= 1; - memcpy(vec, bp->vec, sizeof(float)*3); + if (count == nr) { + found = 1; + memcpy(vec, bp->vec, sizeof(float) * 3); break; } count++; bp++; } } - nu= nu->next; + nu = nu->next; } } - else if (par->type==OB_LATTICE) { - Lattice *latt= par->data; + else if (par->type == OB_LATTICE) { + Lattice *latt = par->data; BPoint *bp; DispList *dl = find_displist(&par->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; + float *co = dl ? dl->verts : NULL; - if (latt->editlatt) latt= latt->editlatt->latt; + if (latt->editlatt) latt = latt->editlatt->latt; - a= latt->pntsu*latt->pntsv*latt->pntsw; - count= 0; - bp= latt->def; + a = latt->pntsu * latt->pntsv * latt->pntsw; + count = 0; + bp = latt->def; while (a--) { - if (count==nr) { + if (count == nr) { if (co) - memcpy(vec, co, 3*sizeof(float)); + memcpy(vec, co, 3 * sizeof(float)); else - memcpy(vec, bp->vec, 3*sizeof(float)); + memcpy(vec, bp->vec, 3 * sizeof(float)); break; } count++; - if (co) co+= 3; + if (co) co += 3; else bp++; } } @@ -1886,7 +1886,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) quat_to_mat3(cmat, q); copy_m4_m3(mat, cmat); - if (ob->type==OB_CURVE) { + if (ob->type == OB_CURVE) { copy_v3_v3(mat[3], v1); } else { @@ -1904,14 +1904,14 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ int a; // include framerate - fac1= (1.0f / (1.0f + fabsf(ob->sf)) ); + fac1 = (1.0f / (1.0f + fabsf(ob->sf)) ); if (fac1 >= 1.0f) return 0; - fac2= 1.0f-fac1; + fac2 = 1.0f - fac1; - fp1= obmat[0]; - fp2= slowmat[0]; - for (a=0; a<16; a++, fp1++, fp2++) { - fp1[0]= fac1*fp1[0] + fac2*fp2[0]; + fp1 = obmat[0]; + fp2 = slowmat[0]; + for (a = 0; a < 16; a++, fp1++, fp2++) { + fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; } return 1; @@ -1920,32 +1920,32 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) { float slowmat[4][4] = MAT4_UNITY; - float stime=ctime; + float stime = ctime; /* new version: correct parent+vertexparent and track+parent */ /* this one only calculates direct attached parent and track */ /* is faster, but should keep track of timeoffs */ - if (ob==NULL) return; + if (ob == NULL) return; /* execute drivers only, as animation has already been done */ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS); if (ob->parent) { - Object *par= ob->parent; + Object *par = ob->parent; /* hurms, code below conflicts with depgraph... (ton) */ /* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */ if (stime != par->ctime) { // only for ipo systems? - Object tmp= *par; + Object tmp = *par; - if (par->proxy_from); // was a copied matrix, no where_is! bad... + if (par->proxy_from) ; // was a copied matrix, no where_is! bad... else BKE_object_where_is_calc_time(scene, par, ctime); solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); - *par= tmp; + *par = tmp; } else solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); @@ -1966,17 +1966,17 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; - cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); /* constraints need ctime, not stime. Some call BKE_object_where_is_calc_time and bsystem_time */ - solve_constraints (&ob->constraints, cob, ctime); + solve_constraints(&ob->constraints, cob, ctime); constraints_clear_evalob(cob); } /* set negative scale flag in object */ - if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; - else ob->transflag &= ~OB_NEG_SCALE; + if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; + else ob->transflag &= ~OB_NEG_SCALE; } /* get object transformation matrix without recalculating dependencies and @@ -1988,7 +1988,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) float slowmat[4][4] = MAT4_UNITY; if (ob->parent) { - Object *par= ob->parent; + Object *par = ob->parent; solve_parenting(scene, ob, par, obmat, slowmat, 1); @@ -2000,7 +2000,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) } } -static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul) +static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul) { float totmat[4][4]; float tmat[4][4]; @@ -2013,53 +2013,53 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); switch (ob->partype & PARTYPE) { - case PAROBJECT: - ok= 0; - if (par->type==OB_CURVE) { - if (((Curve *)par->data)->flag & CU_PATH ) { - ob_parcurve(scene, ob, par, tmat); - ok= 1; + case PAROBJECT: + ok = 0; + if (par->type == OB_CURVE) { + if (((Curve *)par->data)->flag & CU_PATH) { + ob_parcurve(scene, ob, par, tmat); + ok = 1; + } } - } - if (ok) mul_serie_m4(totmat, par->obmat, tmat, - NULL, NULL, NULL, NULL, NULL, NULL); - else copy_m4_m4(totmat, par->obmat); + if (ok) mul_serie_m4(totmat, par->obmat, tmat, + NULL, NULL, NULL, NULL, NULL, NULL); + else copy_m4_m4(totmat, par->obmat); - break; - case PARBONE: - ob_parbone(ob, par, tmat); - mul_serie_m4(totmat, par->obmat, tmat, - NULL, NULL, NULL, NULL, NULL, NULL); - break; + break; + case PARBONE: + ob_parbone(ob, par, tmat); + mul_serie_m4(totmat, par->obmat, tmat, + NULL, NULL, NULL, NULL, NULL, NULL); + break; - case PARVERT1: - unit_m4(totmat); - if (simul) { - copy_v3_v3(totmat[3], par->obmat[3]); - } - else { - give_parvert(par, ob->par1, vec); - mul_v3_m4v3(totmat[3], par->obmat, vec); - } - break; - case PARVERT3: - ob_parvert3(ob, par, tmat); + case PARVERT1: + unit_m4(totmat); + if (simul) { + copy_v3_v3(totmat[3], par->obmat[3]); + } + else { + give_parvert(par, ob->par1, vec); + mul_v3_m4v3(totmat[3], par->obmat, vec); + } + break; + case PARVERT3: + ob_parvert3(ob, par, tmat); - mul_serie_m4(totmat, par->obmat, tmat, - NULL, NULL, NULL, NULL, NULL, NULL); - break; + mul_serie_m4(totmat, par->obmat, tmat, + NULL, NULL, NULL, NULL, NULL, NULL); + break; - case PARSKEL: - copy_m4_m4(totmat, par->obmat); - break; + case PARSKEL: + copy_m4_m4(totmat, par->obmat); + break; } // total mul_serie_m4(tmat, totmat, ob->parentinv, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL); mul_serie_m4(obmat, tmat, locmat, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL); if (simul) { @@ -2069,7 +2069,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ copy_m3_m4(originmat, tmat); // origin, voor help line - if ((ob->partype & PARTYPE)==PARSKEL ) { + if ((ob->partype & PARTYPE) == PARSKEL) { copy_v3_v3(ob->orig, par->obmat[3]); } else { @@ -2098,17 +2098,17 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) /* NO TIMEOFFS */ if (ob->parent) { - par= ob->parent; + par = ob->parent; solve_parenting(scene, ob, par, ob->obmat, slowmat, 1); if (ob->partype & PARSLOW) { - fac1= (float)(1.0/(1.0+ fabs(ob->sf))); - fac2= 1.0f-fac1; - fp1= ob->obmat[0]; - fp2= slowmat[0]; - for (a=0; a<16; a++, fp1++, fp2++) { - fp1[0]= fac1*fp1[0] + fac2*fp2[0]; + fac1 = (float)(1.0 / (1.0 + fabs(ob->sf))); + fac2 = 1.0f - fac1; + fp1 = ob->obmat[0]; + fp2 = slowmat[0]; + for (a = 0; a < 16; a++, fp1++, fp2++) { + fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; } } } @@ -2120,7 +2120,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) if (ob->constraints.first) { bConstraintOb *cob; - cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); solve_constraints(&ob->constraints, cob, (float)scene->r.cfra); constraints_clear_evalob(cob); } @@ -2134,15 +2134,15 @@ void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob) unit_m4(workob->obmat); unit_m4(workob->parentinv); unit_m4(workob->constinv); - workob->parent= ob->parent; + workob->parent = ob->parent; - workob->trackflag= ob->trackflag; - workob->upflag= ob->upflag; + workob->trackflag = ob->trackflag; + workob->upflag = ob->upflag; - workob->partype= ob->partype; - workob->par1= ob->par1; - workob->par2= ob->par2; - workob->par3= ob->par3; + workob->partype = ob->partype; + workob->par1 = ob->par1; + workob->par2 = ob->par2; + workob->par3 = ob->par3; workob->constraints.first = ob->constraints.first; workob->constraints.last = ob->constraints.last; @@ -2157,7 +2157,7 @@ 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"); + bb = MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); BKE_boundbox_init_from_minmax(bb, min, max); return bb; @@ -2165,28 +2165,28 @@ BoundBox *BKE_boundbox_alloc_unit(void) 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]; + 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]; - bb->vec[0][1]=bb->vec[1][1]=bb->vec[4][1]=bb->vec[5][1]= min[1]; - bb->vec[2][1]=bb->vec[3][1]=bb->vec[6][1]=bb->vec[7][1]= max[1]; + bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = min[1]; + bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = max[1]; - bb->vec[0][2]=bb->vec[3][2]=bb->vec[4][2]=bb->vec[7][2]= min[2]; - bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= max[2]; + bb->vec[0][2] = bb->vec[3][2] = bb->vec[4][2] = bb->vec[7][2] = min[2]; + bb->vec[1][2] = bb->vec[2][2] = bb->vec[5][2] = bb->vec[6][2] = max[2]; } BoundBox *BKE_object_boundbox_get(Object *ob) { - BoundBox *bb= NULL; + BoundBox *bb = NULL; - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - bb= ob->bb ? ob->bb : ((Curve *)ob->data )->bb; + bb = ob->bb ? ob->bb : ((Curve *)ob->data)->bb; } - else if (ob->type==OB_MBALL) { - bb= ob->bb; + else if (ob->type == OB_MBALL) { + bb = ob->bb; } return bb; } @@ -2194,7 +2194,7 @@ BoundBox *BKE_object_boundbox_get(Object *ob) /* used to temporally disable/enable boundbox */ void BKE_object_boundbox_flag(Object *ob, int flag, int set) { - BoundBox *bb= BKE_object_boundbox_get(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { if (set) bb->flag |= flag; else bb->flag &= ~flag; @@ -2205,7 +2205,7 @@ void BKE_object_dimensions_get(Object *ob, float vec[3]) { BoundBox *bb = NULL; - bb= BKE_object_boundbox_get(ob); + bb = BKE_object_boundbox_get(ob); if (bb) { float scale[3]; @@ -2224,7 +2224,7 @@ void BKE_object_dimensions_set(Object *ob, const float *value) { BoundBox *bb = NULL; - bb= BKE_object_boundbox_get(ob); + bb = BKE_object_boundbox_get(ob); if (bb) { float scale[3], len[3]; @@ -2245,66 +2245,66 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) BoundBox bb; float vec[3]; int a; - short change= FALSE; + short change = FALSE; switch (ob->type) { - case OB_CURVE: - case OB_FONT: - case OB_SURF: + case OB_CURVE: + case OB_FONT: + case OB_SURF: { - Curve *cu= ob->data; + Curve *cu = ob->data; - if (cu->bb==NULL) BKE_curve_texspace_calc(cu); - bb= *(cu->bb); + if (cu->bb == NULL) BKE_curve_texspace_calc(cu); + bb = *(cu->bb); - for (a=0; a<8; a++) { + for (a = 0; a < 8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); DO_MINMAX(bb.vec[a], min_r, max_r); } - change= TRUE; + change = TRUE; } break; - case OB_LATTICE: + case OB_LATTICE: { - Lattice *lt= ob->data; - BPoint *bp= lt->def; + Lattice *lt = ob->data; + BPoint *bp = lt->def; int u, v, w; - for (w=0; wpntsw; w++) { - for (v=0; vpntsv; v++) { - for (u=0; upntsu; u++, bp++) { + for (w = 0; w < lt->pntsw; w++) { + for (v = 0; v < lt->pntsv; v++) { + for (u = 0; u < lt->pntsu; u++, bp++) { mul_v3_m4v3(vec, ob->obmat, bp->vec); DO_MINMAX(vec, min_r, max_r); } } } - change= TRUE; + change = TRUE; } break; - case OB_ARMATURE: - if (ob->pose) { - 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_r, max_r); - mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); - DO_MINMAX(vec, min_r, max_r); + case OB_ARMATURE: + if (ob->pose) { + 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_r, max_r); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); + DO_MINMAX(vec, min_r, max_r); + } + change = TRUE; } - change= TRUE; - } - break; - case OB_MESH: + break; + case OB_MESH: { - Mesh *me= BKE_mesh_from_object(ob); + Mesh *me = BKE_mesh_from_object(ob); if (me) { bb = *BKE_mesh_boundbox_get(ob); - for (a=0; a<8; a++) { + for (a = 0; a < 8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); DO_MINMAX(bb.vec[a], min_r, max_r); } - change= TRUE; + change = TRUE; } } break; @@ -2325,32 +2325,32 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[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) { + int ok = 0; + if ((ob->transflag & OB_DUPLI) == 0) { return ok; } else { ListBase *lb; DupliObject *dob; - lb= object_duplilist(scene, ob); - for (dob= lb->first; dob; dob= dob->next) { + lb = object_duplilist(scene, ob); + for (dob = lb->first; dob; dob = dob->next) { if (dob->no_draw == 0) { - BoundBox *bb= BKE_object_boundbox_get(dob->ob); + BoundBox *bb = BKE_object_boundbox_get(dob->ob); if (bb) { int i; - for (i=0; i<8; i++) { + for (i = 0; i < 8; i++) { float vec[3]; mul_v3_m4v3(vec, dob->mat, bb->vec[i]); DO_MINMAX(vec, r_min, r_max); } - ok= 1; + ok = 1; } } } - free_object_duplilist(lb); /* does restore */ + free_object_duplilist(lb); /* does restore */ } return ok; @@ -2363,12 +2363,12 @@ void BKE_object_foreach_display_point( float co[3]; if (ob->derivedFinal) { - DerivedMesh *dm= ob->derivedFinal; - MVert *mv= dm->getVertArray(dm); - int totvert= dm->getNumVerts(dm); + DerivedMesh *dm = ob->derivedFinal; + MVert *mv = dm->getVertArray(dm); + int totvert = dm->getNumVerts(dm); int i; - for (i= 0; i < totvert; i++, mv++) { + for (i = 0; i < totvert; i++, mv++) { mul_v3_m4v3(co, obmat, mv->co); func_cb(co, user_data); } @@ -2376,12 +2376,12 @@ void BKE_object_foreach_display_point( else if (ob->disp.first) { DispList *dl; - for (dl=ob->disp.first; dl; dl=dl->next) { - float *v3= dl->verts; - int totvert= dl->nr; + for (dl = ob->disp.first; dl; dl = dl->next) { + float *v3 = dl->verts; + int totvert = dl->nr; int i; - for (i= 0; i < totvert; i++, v3+=3) { + for (i = 0; i < totvert; i++, v3 += 3) { mul_v3_m4v3(co, obmat, v3); func_cb(co, user_data); } @@ -2396,24 +2396,24 @@ void BKE_scene_foreach_display_point( Base *base; Object *ob; - for (base= FIRSTBASE; base; base = base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) { - ob= base->object; + ob = base->object; - if ((ob->transflag & OB_DUPLI)==0) { + if ((ob->transflag & OB_DUPLI) == 0) { BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data); } else { ListBase *lb; DupliObject *dob; - lb= object_duplilist(scene, ob); - for (dob= lb->first; dob; dob= dob->next) { + lb = object_duplilist(scene, ob); + for (dob = lb->first; dob; dob = dob->next) { if (dob->no_draw == 0) { BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data); } } - free_object_duplilist(lb); /* does restore */ + free_object_duplilist(lb); /* does restore */ } } } @@ -2422,20 +2422,20 @@ void BKE_scene_foreach_display_point( /* copied from DNA_object_types.h */ typedef struct ObTfmBack { float loc[3], dloc[3], orig[3]; - float size[3], dscale[3]; /* scale and delta scale */ - float rot[3], drot[3]; /* euler rotation */ - float quat[4], dquat[4]; /* quaternion rotation */ - float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ - float rotAngle, drotAngle; /* axis angle rotation - angle part */ - float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ + float size[3], dscale[3]; /* scale and delta scale */ + float rot[3], drot[3]; /* euler rotation */ + float quat[4], dquat[4]; /* quaternion rotation */ + float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ + float rotAngle, drotAngle; /* axis angle rotation - angle part */ + float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ - float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ + float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ } ObTfmBack; void *BKE_object_tfm_backup(Object *ob) { - ObTfmBack *obtfm= MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack"); + ObTfmBack *obtfm = MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack"); copy_v3_v3(obtfm->loc, ob->loc); copy_v3_v3(obtfm->dloc, ob->dloc); copy_v3_v3(obtfm->orig, ob->orig); @@ -2447,8 +2447,8 @@ void *BKE_object_tfm_backup(Object *ob) copy_qt_qt(obtfm->dquat, ob->dquat); copy_v3_v3(obtfm->rotAxis, ob->rotAxis); copy_v3_v3(obtfm->drotAxis, ob->drotAxis); - obtfm->rotAngle= ob->rotAngle; - obtfm->drotAngle= ob->drotAngle; + obtfm->rotAngle = ob->rotAngle; + obtfm->drotAngle = ob->drotAngle; copy_m4_m4(obtfm->obmat, ob->obmat); copy_m4_m4(obtfm->parentinv, ob->parentinv); copy_m4_m4(obtfm->constinv, ob->constinv); @@ -2459,7 +2459,7 @@ void *BKE_object_tfm_backup(Object *ob) void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) { - ObTfmBack *obtfm= (ObTfmBack *)obtfm_pt; + ObTfmBack *obtfm = (ObTfmBack *)obtfm_pt; copy_v3_v3(ob->loc, obtfm->loc); copy_v3_v3(ob->dloc, obtfm->dloc); copy_v3_v3(ob->orig, obtfm->orig); @@ -2471,8 +2471,8 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) copy_qt_qt(ob->dquat, obtfm->dquat); copy_v3_v3(ob->rotAxis, obtfm->rotAxis); copy_v3_v3(ob->drotAxis, obtfm->drotAxis); - ob->rotAngle= obtfm->rotAngle; - ob->drotAngle= obtfm->drotAngle; + ob->rotAngle = obtfm->rotAngle; + ob->drotAngle = obtfm->drotAngle; copy_m4_m4(ob->obmat, obtfm->obmat); copy_m4_m4(ob->parentinv, obtfm->parentinv); copy_m4_m4(ob->constinv, obtfm->constinv); @@ -2502,12 +2502,12 @@ void BKE_object_handle_update(Scene *scene, Object *ob) BKE_pose_channels_hash_make(ob->pose); if (ob->recalc & OB_RECALC_DATA) { - if (ob->type==OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { /* this happens for reading old files and to match library armatures * 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)) + if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) BKE_pose_rebuild(ob, ob->data); } } @@ -2518,13 +2518,13 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (ob->recalc & OB_RECALC_ALL) { if (G.debug & G_DEBUG) - printf("recalcob %s\n", ob->id.name+2); + printf("recalcob %s\n", ob->id.name + 2); /* handle proxy copy for target */ if (ob->id.lib && ob->proxy_from) { // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); - if (ob->proxy_from->proxy_group) {/* transform proxy into group space */ - Object *obg= ob->proxy_from->proxy_group; + if (ob->proxy_from->proxy_group) { /* transform proxy into group space */ + Object *obg = ob->proxy_from->proxy_group; invert_m4_m4(obg->imat, obg->obmat); mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat); if (obg->dup_group) { /* should always be true */ @@ -2539,14 +2539,14 @@ void BKE_object_handle_update(Scene *scene, Object *ob) } if (ob->recalc & OB_RECALC_DATA) { - ID *data_id= (ID *)ob->data; - AnimData *adt= BKE_animdata_from_id(data_id); - float ctime= (float)scene->r.cfra; // XXX this is bad... + ID *data_id = (ID *)ob->data; + AnimData *adt = BKE_animdata_from_id(data_id); + float ctime = (float)scene->r.cfra; // XXX this is bad... ListBase pidlist; PTCacheID *pid; if (G.debug & G_DEBUG) - printf("recalcdata %s\n", ob->id.name+2); + printf("recalcdata %s\n", ob->id.name + 2); if (adt) { /* evaluate drivers */ @@ -2556,9 +2556,9 @@ void BKE_object_handle_update(Scene *scene, Object *ob) /* includes all keys and modifiers */ switch (ob->type) { - case OB_MESH: + case OB_MESH: { -#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' +#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' BMEditMesh *em = (ob == scene->obedit) ? BMEdit_FromObject(ob) : NULL; BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); if (em) { @@ -2568,9 +2568,9 @@ void BKE_object_handle_update(Scene *scene, Object *ob) makeDerivedMesh(scene, ob, NULL, scene->customdata_mask, 0); } -#else /* ensure CD_MASK_BAREMESH for now */ +#else /* ensure CD_MASK_BAREMESH for now */ BMEditMesh *em = (ob == scene->obedit) ? BMEdit_FromObject(ob) : NULL; - uint64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; + uint64_t data_mask = scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if (em) { makeDerivedMesh(scene, ob, em, data_mask, 0); /* was CD_MASK_BAREMESH */ } @@ -2582,29 +2582,29 @@ void BKE_object_handle_update(Scene *scene, Object *ob) } break; - 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); - BKE_pose_copy_result(ob->pose, ob->proxy_from->pose); - } - else { - BKE_pose_where_is(scene, ob); - } - break; + 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); + BKE_pose_copy_result(ob->pose, ob->proxy_from->pose); + } + else { + BKE_pose_where_is(scene, ob); + } + break; - case OB_MBALL: - makeDispListMBall(scene, ob); - break; + case OB_MBALL: + makeDispListMBall(scene, ob); + break; - case OB_CURVE: - case OB_SURF: - case OB_FONT: - makeDispListCurveTypes(scene, ob, 0); - break; + case OB_CURVE: + case OB_SURF: + case OB_FONT: + makeDispListCurveTypes(scene, ob, 0); + break; - case OB_LATTICE: - BKE_lattice_modifiers_calc(scene, ob); - break; + case OB_LATTICE: + BKE_lattice_modifiers_calc(scene, ob); + break; } @@ -2613,7 +2613,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) DerivedMesh *dm; ob->transflag &= ~OB_DUPLIPARTS; - psys= ob->particlesystem.first; + psys = ob->particlesystem.first; while (psys) { if (psys_check_enabled(ob, psys)) { /* check use of dupli objects here */ @@ -2625,26 +2625,26 @@ void BKE_object_handle_update(Scene *scene, Object *ob) } particle_system_update(scene, ob, psys); - psys= psys->next; + psys = psys->next; } else if (psys->flag & PSYS_DELETE) { - tpsys=psys->next; + tpsys = psys->next; BLI_remlink(&ob->particlesystem, psys); psys_free(ob, psys); - psys= tpsys; + psys = tpsys; } else - psys= psys->next; + psys = psys->next; } if (G.rendering && ob->transflag & OB_DUPLIPARTS) { /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ - dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL); dm->release(dm); - for (psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys = ob->particlesystem.first; psys; psys = psys->next) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } @@ -2652,18 +2652,18 @@ void BKE_object_handle_update(Scene *scene, Object *ob) /* check if quick cache is needed */ BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for (pid=pidlist.first; pid; pid=pid->next) { + for (pid = pidlist.first; pid; pid = pid->next) { if ((pid->cache->flag & PTCACHE_BAKED) || (pid->cache->flag & PTCACHE_QUICK_CACHE) == 0) { continue; } - if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) { + if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID) == 0) { scene->physics_settings.quick_cache_step = - scene->physics_settings.quick_cache_step ? - MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) : - pid->cache->step; + scene->physics_settings.quick_cache_step ? + MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) : + pid->cache->step; } } @@ -2671,9 +2671,9 @@ void BKE_object_handle_update(Scene *scene, Object *ob) } /* the no-group proxy case, we call update */ - if (ob->proxy && ob->proxy_group==NULL) { + if (ob->proxy && ob->proxy_group == NULL) { /* set pointer in library proxy target, for copying, but restore it */ - ob->proxy->proxy_from= ob; + ob->proxy->proxy_from = ob; // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name); BKE_object_handle_update(scene, ob->proxy); } @@ -2683,22 +2683,22 @@ void BKE_object_handle_update(Scene *scene, Object *ob) /* the case when this is a group proxy, object_update is called in group.c */ if (ob->proxy) { - ob->proxy->proxy_from= ob; + ob->proxy->proxy_from = ob; // printf("set proxy pointer for later group stuff %s\n", ob->id.name); } } void BKE_object_sculpt_modifiers_changed(Object *ob) { - SculptSession *ss= ob->sculpt; + SculptSession *ss = ob->sculpt; if (!ss->cache) { /* we free pbvh on changes, except during sculpt since it can't deal with * changing PVBH node organization, we hope topology does not change in * the meantime .. weak */ if (ss->pbvh) { - BLI_pbvh_free(ss->pbvh); - ss->pbvh= NULL; + BLI_pbvh_free(ss->pbvh); + ss->pbvh = NULL; } free_sculptsession_deformMats(ob->sculpt); @@ -2719,39 +2719,39 @@ void BKE_object_sculpt_modifiers_changed(Object *ob) int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot) { - if (ob->data==NULL) + if (ob->data == NULL) return 0; switch (GS(((ID *)ob->data)->name)) { - case ID_ME: - { - Mesh *me= ob->data; - 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 (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 (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: - return 0; + case ID_ME: + { + Mesh *me = ob->data; + 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 (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 (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: + return 0; } return 1; } @@ -2798,7 +2798,7 @@ int BKE_object_insert_ptcache(Object *ob) BLI_sortlist(&ob->pc_ids, pc_cmp); - for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) { + for (link = ob->pc_ids.first, i = 0; link; link = link->next, i++) { int index = GET_INT_FROM_POINTER(link->data); if (i < index) @@ -2815,18 +2815,18 @@ int BKE_object_insert_ptcache(Object *ob) #if 0 static int pc_findindex(ListBase *listbase, int index) { - LinkData *link= NULL; - int number= 0; + LinkData *link = NULL; + int number = 0; if (listbase == NULL) return -1; - link= listbase->first; + link = listbase->first; while (link) { if ((int)link->data == index) return number; number++; - link= link->next; + link = link->next; } return -1; @@ -2845,30 +2845,30 @@ void object_delete_ptcache(Object *ob, int index) /************************* Mesh ************************/ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int from_mix) { - Mesh *me= ob->data; - Key *key= me->key; + Mesh *me = ob->data; + Key *key = me->key; KeyBlock *kb; - int newkey= 0; + int newkey = 0; if (key == NULL) { - key= me->key= add_key((ID *)me); - key->type= KEY_RELATIVE; - newkey= 1; + key = me->key = add_key((ID *)me); + key->type = KEY_RELATIVE; + newkey = 1; } - if (newkey || from_mix==FALSE) { + if (newkey || from_mix == FALSE) { /* create from mesh */ kb = add_keyblock_ctime(key, name, FALSE); mesh_to_key(me, kb); } else { /* copy from current values */ - float *data= do_ob_key(scene, ob); + float *data = do_ob_key(scene, ob); /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->data= data; - kb->totelem= me->totvert; + kb->data = data; + kb->totelem = me->totvert; } return kb; @@ -2876,23 +2876,23 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int /************************* Lattice ************************/ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int from_mix) { - Lattice *lt= ob->data; - Key *key= lt->key; + Lattice *lt = ob->data; + Key *key = lt->key; KeyBlock *kb; - int newkey= 0; + int newkey = 0; - if (key==NULL) { - key= lt->key= add_key((ID *)lt); - key->type= KEY_RELATIVE; - newkey= 1; + if (key == NULL) { + key = lt->key = add_key((ID *)lt); + key->type = KEY_RELATIVE; + newkey = 1; } - if (newkey || from_mix==FALSE) { + if (newkey || from_mix == FALSE) { kb = add_keyblock_ctime(key, name, FALSE); if (!newkey) { - KeyBlock *basekb= (KeyBlock *)key->block.first; - kb->data= MEM_dupallocN(basekb->data); - kb->totelem= basekb->totelem; + KeyBlock *basekb = (KeyBlock *)key->block.first; + kb->data = MEM_dupallocN(basekb->data); + kb->totelem = basekb->totelem; } else { latt_to_key(lt, kb); @@ -2900,12 +2900,12 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int } else { /* copy from current values */ - float *data= do_ob_key(scene, ob); + float *data = do_ob_key(scene, ob); /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw; - kb->data= data; + kb->totelem = lt->pntsu * lt->pntsv * lt->pntsw; + kb->data = data; } return kb; @@ -2913,25 +2913,25 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int /************************* Curve ************************/ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int from_mix) { - Curve *cu= ob->data; - Key *key= cu->key; + Curve *cu = ob->data; + Key *key = cu->key; KeyBlock *kb; - ListBase *lb= BKE_curve_nurbs_get(cu); - int newkey= 0; + ListBase *lb = BKE_curve_nurbs_get(cu); + int newkey = 0; - if (key==NULL) { - key= cu->key= add_key((ID *)cu); + if (key == NULL) { + key = cu->key = add_key((ID *)cu); key->type = KEY_RELATIVE; - newkey= 1; + newkey = 1; } - if (newkey || from_mix==FALSE) { + if (newkey || from_mix == FALSE) { /* create from curve */ kb = add_keyblock_ctime(key, name, FALSE); if (!newkey) { - KeyBlock *basekb= (KeyBlock *)key->block.first; - kb->data= MEM_dupallocN(basekb->data); - kb->totelem= basekb->totelem; + KeyBlock *basekb = (KeyBlock *)key->block.first; + kb->data = MEM_dupallocN(basekb->data); + kb->totelem = basekb->totelem; } else { curve_to_key(cu, kb, lb); @@ -2939,12 +2939,12 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int } else { /* copy from current values */ - float *data= do_ob_key(scene, ob); + float *data = do_ob_key(scene, ob); /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->totelem= BKE_nurbList_verts_count(lb); - kb->data= data; + kb->totelem = BKE_nurbList_verts_count(lb); + kb->data = data; } return kb; @@ -2970,7 +2970,7 @@ KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name * cases false positives are hard to avoid (shape keys for example) */ int BKE_object_is_modified(Scene *scene, Object *ob) { - int flag= 0; + int flag = 0; if (ob_get_key(ob)) { flag |= eModifierMode_Render; @@ -2978,9 +2978,9 @@ int BKE_object_is_modified(Scene *scene, Object *ob) else { ModifierData *md; /* cloth */ - for (md=modifiers_getVirtualModifierList(ob); + for (md = modifiers_getVirtualModifierList(ob); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); - md=md->next) + md = md->next) { if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) flag |= eModifierMode_Render; @@ -2999,12 +2999,12 @@ int BKE_object_is_modified(Scene *scene, Object *ob) int BKE_object_is_deform_modified(Scene *scene, Object *ob) { ModifierData *md; - int flag= 0; + int flag = 0; /* cloth */ - for (md=modifiers_getVirtualModifierList(ob); - md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); - md=md->next) + for (md = modifiers_getVirtualModifierList(ob); + md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); + md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -3034,7 +3034,7 @@ void BKE_object_relink(Object *ob) relink_constraints(&ob->constraints); if (ob->pose) { bPoseChannel *chan; - for (chan = ob->pose->chanbase.first; chan; chan=chan->next) { + for (chan = ob->pose->chanbase.first; chan; chan = chan->next) { relink_constraints(&chan->constraints); } } @@ -3051,24 +3051,24 @@ void BKE_object_relink(Object *ob) 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; + MovieClip *clip = use_default ? scene->clip : NULL; + bConstraint *con = ob->constraints.first, *scon = NULL; while (con) { - if (con->type==CONSTRAINT_TYPE_CAMERASOLVER) { - if (scon==NULL || (scon->flag&CONSTRAINT_OFF)) - scon= con; + if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) { + if (scon == NULL || (scon->flag & CONSTRAINT_OFF)) + scon = con; } - con= con->next; + con = con->next; } if (scon) { - bCameraSolverConstraint *solver= scon->data; - if ((solver->flag&CAMERASOLVER_ACTIVECLIP)==0) - clip= solver->clip; + bCameraSolverConstraint *solver = scon->data; + if ((solver->flag & CAMERASOLVER_ACTIVECLIP) == 0) + clip = solver->clip; else - clip= scene->clip; + clip = scene->clip; } return clip; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2a8a4ebc34b..a254e892289 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -84,35 +84,35 @@ #include "RE_render_ext.h" static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx, - ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex); + ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex); static void do_child_modifiers(ParticleSimulationData *sim, - ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, - float *orco, float mat[4][4], ParticleKey *state, float t); + ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, + float *orco, float mat[4][4], ParticleKey *state, float t); /* few helpers for countall etc. */ int count_particles(ParticleSystem *psys) { - ParticleSettings *part=psys->part; + ParticleSettings *part = psys->part; PARTICLE_P; - int tot=0; + int tot = 0; LOOP_SHOWN_PARTICLES { - if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0); - else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0); + if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) ; + else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) ; else tot++; } return tot; } int count_particles_mod(ParticleSystem *psys, int totgr, int cur) { - ParticleSettings *part=psys->part; + ParticleSettings *part = psys->part; PARTICLE_P; - int tot=0; + int tot = 0; LOOP_SHOWN_PARTICLES { - if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0); - else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0); - else if (p%totgr==cur) tot++; + if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) ; + else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) ; + else if (p % totgr == cur) tot++; } return tot; } @@ -127,17 +127,17 @@ static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, ParticleCacheKey **cache; int i, totkey, totbufkey; - tot= MAX2(tot, 1); + tot = MAX2(tot, 1); totkey = 0; - cache = MEM_callocN(tot*sizeof(void*), "PathCacheArray"); + cache = MEM_callocN(tot * sizeof(void *), "PathCacheArray"); while (totkey < tot) { - totbufkey= MIN2(tot-totkey, PATH_CACHE_BUF_SIZE); - buf= MEM_callocN(sizeof(LinkData), "PathCacheLinkData"); - buf->data= MEM_callocN(sizeof(ParticleCacheKey)*totbufkey*steps, "ParticleCacheKey"); + totbufkey = MIN2(tot - totkey, PATH_CACHE_BUF_SIZE); + buf = MEM_callocN(sizeof(LinkData), "PathCacheLinkData"); + buf->data = MEM_callocN(sizeof(ParticleCacheKey) * totbufkey * steps, "ParticleCacheKey"); - for (i=0; idata) + i*steps; + for (i = 0; i < totbufkey; i++) + cache[totkey + i] = ((ParticleCacheKey *)buf->data) + i * steps; totkey += totbufkey; BLI_addtail(bufs, buf); @@ -153,7 +153,7 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf if (cache) MEM_freeN(cache); - for (buf= bufs->first; buf; buf=buf->next) + for (buf = bufs->first; buf; buf = buf->next) MEM_freeN(buf->data); BLI_freelistN(bufs); } @@ -165,9 +165,9 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf ParticleSystem *psys_get_current(Object *ob) { ParticleSystem *psys; - if (ob==NULL) return NULL; + if (ob == NULL) return NULL; - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { if (psys->flag & PSYS_CURRENT) return psys; } @@ -179,9 +179,9 @@ short psys_get_current_num(Object *ob) ParticleSystem *psys; short i; - if (ob==NULL) return 0; + if (ob == NULL) return 0; - for (psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) + for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) if (psys->flag & PSYS_CURRENT) return i; @@ -192,9 +192,9 @@ void psys_set_current_num(Object *ob, int index) ParticleSystem *psys; short i; - if (ob==NULL) return; + if (ob == NULL) return; - for (psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) { + for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) { if (i == index) psys->flag |= PSYS_CURRENT; else @@ -209,7 +209,7 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys) ParticleSystem *tpsys; for (base = scene->base.first; base; base = base->next) { - for (tpsys = base->object->particlesystem.first; psys; psys=psys->next) { + for (tpsys = base->object->particlesystem.first; psys; psys = psys->next) { if (tpsys == psys) return base->object; } @@ -221,16 +221,16 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys) Object *psys_get_lattice(ParticleSimulationData *sim) { - Object *lattice=NULL; + Object *lattice = NULL; - if (psys_in_edit_mode(sim->scene, sim->psys)==0) { + if (psys_in_edit_mode(sim->scene, sim->psys) == 0) { - ModifierData *md = (ModifierData*)psys_get_modifier(sim->ob, sim->psys); + ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys); - for (; md; md=md->next) { - if (md->type==eModifierType_Lattice) { + for (; md; md = md->next) { + if (md->type == eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData *)md; - lattice=lmd->object; + lattice = lmd->object; break; } } @@ -242,21 +242,21 @@ Object *psys_get_lattice(ParticleSimulationData *sim) } void psys_disable_all(Object *ob) { - ParticleSystem *psys=ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) psys->flag |= PSYS_DISABLED; } void psys_enable_all(Object *ob) { - ParticleSystem *psys=ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) psys->flag &= ~PSYS_DISABLED; } int psys_in_edit_mode(Scene *scene, ParticleSystem *psys) { - return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit) && !psys->renderdata); + return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys == psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit) && !psys->renderdata); } static void psys_create_frand(ParticleSystem *psys) { @@ -265,7 +265,7 @@ static void psys_create_frand(ParticleSystem *psys) BLI_srandom(psys->seed); - for (i=0; i<1024; i++, rand++) + for (i = 0; i < 1024; i++, rand++) *rand = BLI_frand(); } int psys_check_enabled(Object *ob, ParticleSystem *psys) @@ -275,7 +275,7 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys) if (psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part) return 0; - psmd= psys_get_modifier(ob, psys); + psmd = psys_get_modifier(ob, psys); if (psys->renderdata || G.rendering) { if (!(psmd->modifier.mode & eModifierMode_Render)) return 0; @@ -296,7 +296,7 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys) int psys_check_edited(ParticleSystem *psys) { - if (psys->part && psys->part->type==PART_HAIR) + if (psys->part && psys->part->type == PART_HAIR) return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited)); else return (psys->pointcache->edit && psys->pointcache->edit->edited); @@ -339,7 +339,7 @@ void psys_check_group_weights(ParticleSettings *part) } dw = part->dupliweights.first; - for (; dw; dw=dw->next) { + for (; dw; dw = dw->next) { if (dw->flag & PART_DUPLIW_CURRENT) { current = 1; break; @@ -385,8 +385,8 @@ void BKE_particlesettings_free(ParticleSettings *part) boid_free_settings(part->boids); fluid_free_settings(part->fluid); - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = part->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -411,7 +411,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics) psys->clmd->point_cache = psys->pointcache = NULL; psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL; - modifier_free((ModifierData*)psys->clmd); + modifier_free((ModifierData *)psys->clmd); psys->clmd = NULL; psys->pointcache = BKE_ptcache_add(&psys->ptcaches); @@ -441,8 +441,8 @@ void free_keyed_keys(ParticleSystem *psys) LOOP_PARTICLES { if (pa->keys) { - pa->keys= NULL; - pa->totkey= 0; + pa->keys = NULL; + pa->totkey = 0; } } } @@ -457,13 +457,13 @@ void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit) { if (edit) { psys_free_path_cache_buffers(edit->pathcache, &edit->pathcachebufs); - edit->pathcache= NULL; - edit->totcached= 0; + edit->pathcache = NULL; + edit->totcached = 0; } if (psys) { psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs); - psys->pathcache= NULL; - psys->totcached= 0; + psys->pathcache = NULL; + psys->totcached = 0; free_child_path_cache(psys); } @@ -472,8 +472,8 @@ void psys_free_children(ParticleSystem *psys) { if (psys->child) { MEM_freeN(psys->child); - psys->child= NULL; - psys->totchild=0; + psys->child = NULL; + psys->totchild = 0; } free_child_path_cache(psys); @@ -483,7 +483,7 @@ void psys_free_particles(ParticleSystem *psys) PARTICLE_P; if (psys->particles) { - if (psys->part->type==PART_HAIR) { + if (psys->part->type == PART_HAIR) { LOOP_PARTICLES { if (pa->hair) MEM_freeN(pa->hair); @@ -497,8 +497,8 @@ void psys_free_particles(ParticleSystem *psys) MEM_freeN(psys->particles->boid); MEM_freeN(psys->particles); - psys->particles= NULL; - psys->totpart= 0; + psys->particles = NULL; + psys->totpart = 0; } } void psys_free_pdd(ParticleSystem *psys) @@ -525,11 +525,11 @@ void psys_free_pdd(ParticleSystem *psys) } } /* free everything */ -void psys_free(Object *ob, ParticleSystem * psys) +void psys_free(Object *ob, ParticleSystem *psys) { if (psys) { int nr = 0; - ParticleSystem * tpsys; + ParticleSystem *tpsys; psys_free_path_cache(psys, NULL); @@ -547,7 +547,7 @@ void psys_free(Object *ob, ParticleSystem * psys) } // check if we are last non-visible particle system - for (tpsys=ob->particlesystem.first; tpsys; tpsys=tpsys->next) { + for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) { if (tpsys->part) { if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { nr++; @@ -561,7 +561,7 @@ void psys_free(Object *ob, ParticleSystem * psys) if (psys->part) { psys->part->id.us--; - psys->part=NULL; + psys->part = NULL; } BKE_ptcache_free_list(&psys->ptcaches); @@ -622,17 +622,17 @@ typedef struct ParticleRenderData { static float psys_render_viewport_falloff(double rate, float dist, float width) { - return pow(rate, dist/width); + return pow(rate, dist / width); } static float psys_render_projected_area(ParticleSystem *psys, const float center[3], float area, double vprate, float *viewport) { - ParticleRenderData *data= psys->renderdata; + ParticleRenderData *data = psys->renderdata; float co[4], view[3], ortho1[3], ortho2[3], w, dx, dy, radius; /* transform to view space */ copy_v3_v3(co, center); - co[3]= 1.0f; + co[3] = 1.0f; mul_m4_v4(data->viewmat, co); /* compute two vectors orthogonal to view vector */ @@ -640,87 +640,87 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center ortho_basis_v3v3_v3(ortho1, ortho2, view); /* compute on screen minification */ - w= co[2]*data->winmat[2][3] + data->winmat[3][3]; - dx= data->winx*ortho2[0]*data->winmat[0][0]; - dy= data->winy*ortho2[1]*data->winmat[1][1]; - w= sqrtf(dx*dx + dy*dy)/w; + w = co[2] * data->winmat[2][3] + data->winmat[3][3]; + dx = data->winx * ortho2[0] * data->winmat[0][0]; + dy = data->winy * ortho2[1] * data->winmat[1][1]; + w = sqrtf(dx * dx + dy * dy) / w; /* w squared because we are working with area */ - area= area*w*w; + area = area * w * w; /* viewport of the screen test */ /* project point on screen */ mul_m4_v4(data->winmat, co); if (co[3] != 0.0f) { - co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]); - co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]); + co[0] = 0.5f * data->winx * (1.0f + co[0] / co[3]); + co[1] = 0.5f * data->winy * (1.0f + co[1] / co[3]); } /* screen space radius */ - radius= sqrt(area/(float)M_PI); + radius = sqrt(area / (float)M_PI); /* make smaller using fallof once over screen edge */ - *viewport= 1.0f; + *viewport = 1.0f; - if (co[0]+radius < 0.0f) - *viewport *= psys_render_viewport_falloff(vprate, -(co[0]+radius), data->winx); - else if (co[0]-radius > data->winx) - *viewport *= psys_render_viewport_falloff(vprate, (co[0]-radius) - data->winx, data->winx); + if (co[0] + radius < 0.0f) + *viewport *= psys_render_viewport_falloff(vprate, -(co[0] + radius), data->winx); + else if (co[0] - radius > data->winx) + *viewport *= psys_render_viewport_falloff(vprate, (co[0] - radius) - data->winx, data->winx); - if (co[1]+radius < 0.0f) - *viewport *= psys_render_viewport_falloff(vprate, -(co[1]+radius), data->winy); - else if (co[1]-radius > data->winy) - *viewport *= psys_render_viewport_falloff(vprate, (co[1]-radius) - data->winy, data->winy); + if (co[1] + radius < 0.0f) + *viewport *= psys_render_viewport_falloff(vprate, -(co[1] + radius), data->winy); + else if (co[1] - radius > data->winy) + *viewport *= psys_render_viewport_falloff(vprate, (co[1] - radius) - data->winy, data->winy); return area; } void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float winmat[][4], int winx, int winy, int timeoffset) { - ParticleRenderData*data; - ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); + ParticleRenderData *data; + ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); if (!G.rendering) return; if (psys->renderdata) return; - data= MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData"); + data = MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData"); - data->child= psys->child; - data->totchild= psys->totchild; - data->pathcache= psys->pathcache; + data->child = psys->child; + data->totchild = psys->totchild; + data->pathcache = psys->pathcache; data->pathcachebufs.first = psys->pathcachebufs.first; data->pathcachebufs.last = psys->pathcachebufs.last; - data->totcached= psys->totcached; - data->childcache= psys->childcache; + data->totcached = psys->totcached; + data->childcache = psys->childcache; data->childcachebufs.first = psys->childcachebufs.first; data->childcachebufs.last = psys->childcachebufs.last; - data->totchildcache= psys->totchildcache; + data->totchildcache = psys->totchildcache; if (psmd->dm) - data->dm= CDDM_copy(psmd->dm); - data->totdmvert= psmd->totdmvert; - data->totdmedge= psmd->totdmedge; - data->totdmface= psmd->totdmface; + data->dm = CDDM_copy(psmd->dm); + data->totdmvert = psmd->totdmvert; + data->totdmedge = psmd->totdmedge; + data->totdmface = psmd->totdmface; - psys->child= NULL; - psys->pathcache= NULL; - psys->childcache= NULL; - psys->totchild= psys->totcached= psys->totchildcache= 0; + psys->child = NULL; + psys->pathcache = NULL; + psys->childcache = NULL; + psys->totchild = psys->totcached = psys->totchildcache = 0; psys->pathcachebufs.first = psys->pathcachebufs.last = NULL; psys->childcachebufs.first = psys->childcachebufs.last = NULL; copy_m4_m4(data->winmat, winmat); mult_m4_m4m4(data->viewmat, viewmat, ob->obmat); mult_m4_m4m4(data->mat, winmat, data->viewmat); - data->winx= winx; - data->winy= winy; + data->winx = winx; + data->winy = winy; - data->timeoffset= timeoffset; + data->timeoffset = timeoffset; - psys->renderdata= data; + psys->renderdata = data; /* Hair can and has to be recalculated if everything isn't displayed. */ if (psys->part->disp != 100 && psys->part->type == PART_HAIR) @@ -729,10 +729,10 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float void psys_render_restore(Object *ob, ParticleSystem *psys) { - ParticleRenderData*data; - ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); + ParticleRenderData *data; + ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - data= psys->renderdata; + data = psys->renderdata; if (!data) return; @@ -740,7 +740,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys) MEM_freeN(data->elems); if (psmd->dm) { - psmd->dm->needsFree= 1; + psmd->dm->needsFree = 1; psmd->dm->release(psmd->dm); } @@ -748,93 +748,93 @@ void psys_render_restore(Object *ob, ParticleSystem *psys) if (psys->child) { MEM_freeN(psys->child); - psys->child= 0; - psys->totchild= 0; + psys->child = 0; + psys->totchild = 0; } - psys->child= data->child; - psys->totchild= data->totchild; - psys->pathcache= data->pathcache; + psys->child = data->child; + psys->totchild = data->totchild; + psys->pathcache = data->pathcache; psys->pathcachebufs.first = data->pathcachebufs.first; psys->pathcachebufs.last = data->pathcachebufs.last; - psys->totcached= data->totcached; - psys->childcache= data->childcache; + psys->totcached = data->totcached; + psys->childcache = data->childcache; psys->childcachebufs.first = data->childcachebufs.first; psys->childcachebufs.last = data->childcachebufs.last; - psys->totchildcache= data->totchildcache; + psys->totchildcache = data->totchildcache; - psmd->dm= data->dm; - psmd->totdmvert= data->totdmvert; - psmd->totdmedge= data->totdmedge; - psmd->totdmface= data->totdmface; + psmd->dm = data->dm; + psmd->totdmvert = data->totdmvert; + psmd->totdmedge = data->totdmedge; + psmd->totdmface = data->totdmface; psmd->flag &= ~eParticleSystemFlag_psys_updated; if (psmd->dm) psys_calc_dmcache(ob, psmd->dm, psys); MEM_freeN(data); - psys->renderdata= NULL; + psys->renderdata = NULL; } /* BMESH_TODO, for orig face data, we need to use MPoly */ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) { - DerivedMesh *dm= ctx->dm; - Mesh *me= (Mesh*)(ctx->sim.ob->data); + DerivedMesh *dm = ctx->dm; + Mesh *me = (Mesh *)(ctx->sim.ob->data); MFace *mf, *mface; MVert *mvert; ParticleRenderData *data; ParticleRenderElem *elems, *elem; - ParticleSettings *part= ctx->sim.psys->part; + ParticleSettings *part = ctx->sim.psys->part; float *facearea, (*facecenter)[3], size[3], fac, powrate, scaleclamp; float co1[3], co2[3], co3[3], co4[3], lambda, arearatio, t, area, viewport; double vprate; int *origindex, *facetotvert; int a, b, totorigface, totface, newtot, skipped; - if (part->ren_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND)) + if (part->ren_as != PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND)) return tot; if (!ctx->sim.psys->renderdata) return tot; - data= ctx->sim.psys->renderdata; + data = ctx->sim.psys->renderdata; if (data->timeoffset) return 0; if (!(part->simplify_flag & PART_SIMPLIFY_ENABLE)) return tot; - mvert= dm->getVertArray(dm); - mface= dm->getTessFaceArray(dm); - origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); - totface= dm->getNumTessFaces(dm); - totorigface= me->totpoly; + mvert = dm->getVertArray(dm); + mface = dm->getTessFaceArray(dm); + origindex = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); + totface = dm->getNumTessFaces(dm); + totorigface = me->totpoly; if (totface == 0 || totorigface == 0) return tot; - facearea= MEM_callocN(sizeof(float)*totorigface, "SimplifyFaceArea"); - facecenter= MEM_callocN(sizeof(float[3])*totorigface, "SimplifyFaceCenter"); - facetotvert= MEM_callocN(sizeof(int)*totorigface, "SimplifyFaceArea"); - elems= MEM_callocN(sizeof(ParticleRenderElem)*totorigface, "SimplifyFaceElem"); + facearea = MEM_callocN(sizeof(float) * totorigface, "SimplifyFaceArea"); + facecenter = MEM_callocN(sizeof(float[3]) * totorigface, "SimplifyFaceCenter"); + facetotvert = MEM_callocN(sizeof(int) * totorigface, "SimplifyFaceArea"); + elems = MEM_callocN(sizeof(ParticleRenderElem) * totorigface, "SimplifyFaceElem"); if (data->elems) MEM_freeN(data->elems); - data->dosimplify= 1; - data->elems= elems; - data->origindex= origindex; + data->dosimplify = 1; + data->elems = elems; + data->origindex = origindex; /* compute number of children per original face */ - for (a=0; aindex[a]]: ctx->index[a]; + for (a = 0; a < tot; a++) { + b = (origindex) ? origindex[ctx->index[a]] : ctx->index[a]; if (b != -1) elems[b].totchild++; } /* compute areas and centers of original faces */ - for (mf=mface, a=0; av1].co); @@ -858,67 +858,67 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) } } - for (a=0; a 0) - mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]); + mul_v3_fl(facecenter[a], 1.0f / facetotvert[a]); /* for conversion from BU area / pixel area to reference screen size */ BKE_mesh_texspace_get(me, 0, 0, size); - fac= ((size[0] + size[1] + size[2])/3.0f)/part->simplify_refsize; - fac= fac*fac; + fac = ((size[0] + size[1] + size[2]) / 3.0f) / part->simplify_refsize; + fac = fac * fac; - powrate= log(0.5f)/log(part->simplify_rate*0.5f); + powrate = log(0.5f) / log(part->simplify_rate * 0.5f); if (part->simplify_flag & PART_SIMPLIFY_VIEWPORT) - vprate= pow(1.0f - part->simplify_viewport, 5.0); + vprate = pow(1.0f - part->simplify_viewport, 5.0); else - vprate= 1.0; + vprate = 1.0; /* set simplification parameters per original face */ - for (a=0, elem=elems; asim.psys, facecenter[a], facearea[a], vprate, &viewport); - arearatio= fac*area/facearea[a]; + arearatio = fac * area / facearea[a]; if ((arearatio < 1.0f || viewport < 1.0f) && elem->totchild) { /* lambda is percentage of elements to keep */ - lambda= (arearatio < 1.0f)? powf(arearatio, powrate): 1.0f; + lambda = (arearatio < 1.0f) ? powf(arearatio, powrate) : 1.0f; lambda *= viewport; - lambda= MAX2(lambda, 1.0f/elem->totchild); + lambda = MAX2(lambda, 1.0f / elem->totchild); /* compute transition region */ - t= part->simplify_transition; - elem->t= (lambda-t < 0.0f)? lambda: (lambda+t > 1.0f)? 1.0f-lambda: t; - elem->reduce= 1; + t = part->simplify_transition; + elem->t = (lambda - t < 0.0f) ? lambda : (lambda + t > 1.0f) ? 1.0f - lambda : t; + elem->reduce = 1; /* scale at end and beginning of the transition region */ - elem->scalemax= (lambda+t < 1.0f)? 1.0f/lambda: 1.0f/(1.0f - elem->t*elem->t/t); - elem->scalemin= (lambda+t < 1.0f)? 0.0f: elem->scalemax*(1.0f-elem->t/t); + elem->scalemax = (lambda + t < 1.0f) ? 1.0f / lambda : 1.0f / (1.0f - elem->t * elem->t / t); + elem->scalemin = (lambda + t < 1.0f) ? 0.0f : elem->scalemax * (1.0f - elem->t / t); - elem->scalemin= sqrt(elem->scalemin); - elem->scalemax= sqrt(elem->scalemax); + elem->scalemin = sqrt(elem->scalemin); + elem->scalemax = sqrt(elem->scalemax); /* clamp scaling */ - scaleclamp= MIN2(elem->totchild, 10.0f); - elem->scalemin= MIN2(scaleclamp, elem->scalemin); - elem->scalemax= MIN2(scaleclamp, elem->scalemax); + scaleclamp = MIN2(elem->totchild, 10.0f); + elem->scalemin = MIN2(scaleclamp, elem->scalemin); + elem->scalemax = MIN2(scaleclamp, elem->scalemax); /* extend lambda to include transition */ - lambda= lambda + elem->t; + lambda = lambda + elem->t; if (lambda > 1.0f) - lambda= 1.0f; + lambda = 1.0f; } else { - lambda= arearatio; + lambda = arearatio; - elem->scalemax= 1.0f; //sqrt(lambda); - elem->scalemin= 1.0f; //sqrt(lambda); - elem->reduce= 0; + elem->scalemax = 1.0f; //sqrt(lambda); + elem->scalemin = 1.0f; //sqrt(lambda); + elem->reduce = 0; } - elem->lambda= lambda; - elem->scalemin= sqrt(elem->scalemin); - elem->scalemax= sqrt(elem->scalemax); - elem->curchild= 0; + elem->lambda = lambda; + elem->scalemin = sqrt(elem->scalemin); + elem->scalemax = sqrt(elem->scalemax); + elem->curchild = 0; } MEM_freeN(facearea); @@ -926,16 +926,16 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) MEM_freeN(facetotvert); /* move indices and set random number skipping */ - ctx->skip= MEM_callocN(sizeof(int)*tot, "SimplificationSkip"); + ctx->skip = MEM_callocN(sizeof(int) * tot, "SimplificationSkip"); - skipped= 0; - for (a=0, newtot=0; aindex[a]]: ctx->index[a]; + skipped = 0; + for (a = 0, newtot = 0; a < tot; a++) { + b = (origindex) ? origindex[ctx->index[a]] : ctx->index[a]; if (b != -1) { - if (elems[b].curchild++ < ceil(elems[b].lambda*elems[b].totchild)) { - ctx->index[newtot]= ctx->index[a]; - ctx->skip[newtot]= skipped; - skipped= 0; + if (elems[b].curchild++ < ceil(elems[b].lambda * elems[b].totchild)) { + ctx->index[newtot] = ctx->index[a]; + ctx->skip[newtot] = skipped; + skipped = 0; newtot++; } else skipped++; @@ -943,8 +943,8 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) else skipped++; } - for (a=0, elem=elems; acurchild= 0; + for (a = 0, elem = elems; a < totorigface; a++, elem++) + elem->curchild = 0; return newtot; } @@ -959,44 +959,44 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float if (!(psys->renderdata && (psys->part->simplify_flag & PART_SIMPLIFY_ENABLE))) return 0; - data= psys->renderdata; + data = psys->renderdata; if (!data->dosimplify) return 0; - b= (data->origindex)? data->origindex[cpa->num]: cpa->num; + b = (data->origindex) ? data->origindex[cpa->num] : cpa->num; if (b == -1) return 0; - elem= &data->elems[b]; + elem = &data->elems[b]; - lambda= elem->lambda; - t= elem->t; - scalemin= elem->scalemin; - scalemax= elem->scalemax; + lambda = elem->lambda; + t = elem->t; + scalemin = elem->scalemin; + scalemax = elem->scalemax; if (!elem->reduce) { - scale= scalemin; - alpha= 1.0f; + scale = scalemin; + alpha = 1.0f; } else { - x= (elem->curchild+0.5f)/elem->totchild; - if (x < lambda-t) { - scale= scalemax; - alpha= 1.0f; + x = (elem->curchild + 0.5f) / elem->totchild; + if (x < lambda - t) { + scale = scalemax; + alpha = 1.0f; } - else if (x >= lambda+t) { - scale= scalemin; - alpha= 0.0f; + else if (x >= lambda + t) { + scale = scalemin; + alpha = 0.0f; } else { - w= (lambda+t - x)/(2.0f*t); - scale= scalemin + (scalemax - scalemin)*w; - alpha= w; + w = (lambda + t - x) / (2.0f * t); + scale = scalemin + (scalemax - scalemin) * w; + alpha = w; } } - params[0]= scale; - params[1]= alpha; + params[0] = scale; + params[1] = alpha; elem->curchild++; @@ -1010,9 +1010,9 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4, { float value; - value= w[0]*v1 + w[1]*v2 + w[2]*v3; + value = w[0] * v1 + w[1] * v2 + w[2] * v3; if (four) - value += w[3]*v4; + value += w[3] * v4; CLAMP(value, 0.f, 1.f); @@ -1023,7 +1023,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic { float t[4]; - if (type<0) { + if (type < 0) { interp_cubic_v3(result->co, result->vel, keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt); } else { @@ -1034,13 +1034,13 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic if (velocity) { float temp[3]; - if (dt>0.999f) { - key_curve_position_weights(dt-0.001f, t, type); + if (dt > 0.999f) { + key_curve_position_weights(dt - 0.001f, t, type); interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); sub_v3_v3v3(result->vel, result->co, temp); } else { - key_curve_position_weights(dt+0.001f, t, type); + key_curve_position_weights(dt + 0.001f, t, type); interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); sub_v3_v3v3(result->vel, temp, result->co); } @@ -1110,7 +1110,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float PTCacheMem *pm; int ret = 0; - for (pm=cache->mem_cache.first; pm; pm=pm->next) { + for (pm = cache->mem_cache.first; pm; pm = pm->next) { if (BKE_ptcache_mem_index_find(pm, index) >= 0) { *start = pm->frame; ret++; @@ -1118,7 +1118,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float } } - for (pm=cache->mem_cache.last; pm; pm=pm->prev) { + for (pm = cache->mem_cache.last; pm; pm = pm->prev) { if (BKE_ptcache_mem_index_find(pm, index) >= 0) { *end = pm->frame; ret++; @@ -1134,7 +1134,7 @@ float psys_get_dietime_from_cache(PointCache *cache, int index) PTCacheMem *pm; int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */ - for (pm=cache->mem_cache.last; pm; pm=pm->prev) { + for (pm = cache->mem_cache.last; pm; pm = pm->prev) { if (BKE_ptcache_mem_index_find(pm, index) >= 0) return (float)pm->frame; } @@ -1163,7 +1163,7 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic pind->dietime = (key + pa->totkey - 1)->time; } else if (pind->cache) { - float start=0.0f, end=0.0f; + float start = 0.0f, end = 0.0f; get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL); pind->birthtime = pa ? pa->time : pind->cache->startframe; pind->dietime = pa ? pa->dietime : pind->cache->endframe; @@ -1222,7 +1222,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData if (result->time < 0.0f) real_t = -result->time; else - real_t = *(pind->ekey[0]->time) + t * (*(pind->ekey[0][point->totkey-1].time) - *(pind->ekey[0]->time)); + real_t = *(pind->ekey[0]->time) + t * (*(pind->ekey[0][point->totkey - 1].time) - *(pind->ekey[0]->time)); while (*(pind->ekey[1]->time) < real_t) pind->ekey[1]++; @@ -1231,7 +1231,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData } else if (pind->keyed) { /* we have only one key, so let's use that */ - if (pind->kkey[1]==NULL) { + if (pind->kkey[1] == NULL) { copy_particle_key(result, pind->kkey[0], 1); return; } @@ -1239,24 +1239,24 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData if (result->time < 0.0f) real_t = -result->time; else - real_t = pind->kkey[0]->time + t * (pind->kkey[0][pa->totkey-1].time - pind->kkey[0]->time); + real_t = pind->kkey[0]->time + t * (pind->kkey[0][pa->totkey - 1].time - pind->kkey[0]->time); - if (psys->part->phystype==PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) { + if (psys->part->phystype == PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) { ParticleTarget *pt = psys->targets.first; - pt=pt->next; + pt = pt->next; while (pt && pa->time + pt->time < real_t) - pt= pt->next; + pt = pt->next; if (pt) { - pt=pt->prev; + pt = pt->prev; if (pa->time + pt->time + pt->duration > real_t) real_t = pa->time + pt->time; } else - real_t = pa->time + ((ParticleTarget*)psys->targets.last)->time; + real_t = pa->time + ((ParticleTarget *)psys->targets.last)->time; } CLAMP(real_t, pa->time, pa->dietime); @@ -1276,7 +1276,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData if (result->time < 0.0f) real_t = -result->time; else - real_t = pind->hkey[0]->time + t * (pind->hkey[0][pa->totkey-1].time - pind->hkey[0]->time); + real_t = pind->hkey[0]->time + t * (pind->hkey[0][pa->totkey - 1].time - pind->hkey[0]->time); while (pind->hkey[1]->time < real_t) { pind->hkey[1]++; @@ -1301,7 +1301,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey)); } else if (pind->cache) { - get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys+1, keys+2); + get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys + 1, keys + 2); } else { hair_to_particle(keys + 1, pind->hkey[0]); @@ -1362,37 +1362,37 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation)*/ psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ? -1 /* signal for cubic interpolation */ - : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL), - keys, keytime, result, 1); + : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL), + keys, keytime, result, 1); /* the velocity needs to be converted back from cubic interpolation */ if (pind->keyed || pind->cache || point_vel) - mul_v3_fl(result->vel, 1.f/invdt); + mul_v3_fl(result->vel, 1.f / invdt); } static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCacheKey *result) { - int i=0; + int i = 0; ParticleCacheKey *cur = first; /* scale the requested time to fit the entire path even if the path is cut early */ - t *= (first+first->steps)->time; + t *= (first + first->steps)->time; - while (isteps && cur->time < t) + while (i < first->steps && cur->time < t) cur++; if (cur->time == t) *result = *cur; else { - float dt = (t-(cur-1)->time)/(cur->time-(cur-1)->time); - interp_v3_v3v3(result->co, (cur-1)->co, cur->co, dt); - interp_v3_v3v3(result->vel, (cur-1)->vel, cur->vel, dt); - interp_qt_qtqt(result->rot, (cur-1)->rot, cur->rot, dt); + float dt = (t - (cur - 1)->time) / (cur->time - (cur - 1)->time); + interp_v3_v3v3(result->co, (cur - 1)->co, cur->co, dt); + interp_v3_v3v3(result->vel, (cur - 1)->vel, cur->vel, dt); + interp_qt_qtqt(result->rot, (cur - 1)->rot, cur->rot, dt); result->time = t; } /* first is actual base rotation, others are incremental from first */ - if (cur==first || cur-1==first) + if (cur == first || cur - 1 == first) copy_qt_qt(result->rot, first->rot); else mul_qt_qtqt(result->rot, first->rot, result->rot); @@ -1405,23 +1405,23 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*orcodata)[3], float *w, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { - float *v1=0, *v2=0, *v3=0, *v4=0; + float *v1 = 0, *v2 = 0, *v3 = 0, *v4 = 0; float e1[3], e2[3], s1, s2, t1, t2; float *uv1, *uv2, *uv3, *uv4; float n1[3], n2[3], n3[3], n4[3]; float tuv[4][2]; float *o1, *o2, *o3, *o4; - v1= mvert[mface->v1].co; - v2= mvert[mface->v2].co; - v3= mvert[mface->v3].co; + v1 = mvert[mface->v1].co; + v2 = mvert[mface->v2].co; + v3 = mvert[mface->v3].co; normal_short_to_float_v3(n1, mvert[mface->v1].no); normal_short_to_float_v3(n2, mvert[mface->v2].no); normal_short_to_float_v3(n3, mvert[mface->v3].no); if (mface->v4) { - v4= mvert[mface->v4].co; + v4 = mvert[mface->v4].co; normal_short_to_float_v3(n4, mvert[mface->v4].no); interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w); @@ -1447,58 +1447,58 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or /* calculate tangent vectors */ if (utan && vtan) { if (tface) { - uv1= tface->uv[0]; - uv2= tface->uv[1]; - uv3= tface->uv[2]; - uv4= tface->uv[3]; + uv1 = tface->uv[0]; + uv2 = tface->uv[1]; + uv3 = tface->uv[2]; + uv4 = tface->uv[3]; } else { - uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3]; - map_to_sphere(uv1, uv1+1, v1[0], v1[1], v1[2]); - map_to_sphere(uv2, uv2+1, v2[0], v2[1], v2[2]); - map_to_sphere(uv3, uv3+1, v3[0], v3[1], v3[2]); + uv1 = tuv[0]; uv2 = tuv[1]; uv3 = tuv[2]; uv4 = tuv[3]; + map_to_sphere(uv1, uv1 + 1, v1[0], v1[1], v1[2]); + map_to_sphere(uv2, uv2 + 1, v2[0], v2[1], v2[2]); + map_to_sphere(uv3, uv3 + 1, v3[0], v3[1], v3[2]); if (v4) - map_to_sphere(uv4, uv4+1, v4[0], v4[1], v4[2]); + map_to_sphere(uv4, uv4 + 1, v4[0], v4[1], v4[2]); } if (v4) { - s1= uv3[0] - uv1[0]; - s2= uv4[0] - uv1[0]; + s1 = uv3[0] - uv1[0]; + s2 = uv4[0] - uv1[0]; - t1= uv3[1] - uv1[1]; - t2= uv4[1] - uv1[1]; + t1 = uv3[1] - uv1[1]; + t2 = uv4[1] - uv1[1]; sub_v3_v3v3(e1, v3, v1); sub_v3_v3v3(e2, v4, v1); } else { - s1= uv2[0] - uv1[0]; - s2= uv3[0] - uv1[0]; + s1 = uv2[0] - uv1[0]; + s2 = uv3[0] - uv1[0]; - t1= uv2[1] - uv1[1]; - t2= uv3[1] - uv1[1]; + t1 = uv2[1] - uv1[1]; + t2 = uv3[1] - uv1[1]; sub_v3_v3v3(e1, v2, v1); sub_v3_v3v3(e2, v3, v1); } - vtan[0] = (s1*e2[0] - s2*e1[0]); - vtan[1] = (s1*e2[1] - s2*e1[1]); - vtan[2] = (s1*e2[2] - s2*e1[2]); + vtan[0] = (s1 * e2[0] - s2 * e1[0]); + vtan[1] = (s1 * e2[1] - s2 * e1[1]); + vtan[2] = (s1 * e2[2] - s2 * e1[2]); - utan[0] = (t1*e2[0] - t2*e1[0]); - utan[1] = (t1*e2[1] - t2*e1[1]); - utan[2] = (t1*e2[2] - t2*e1[2]); + utan[0] = (t1 * e2[0] - t2 * e1[0]); + utan[1] = (t1 * e2[1] - t2 * e1[1]); + utan[2] = (t1 * e2[2] - t2 * e1[2]); } if (orco) { if (orcodata) { - o1= orcodata[mface->v1]; - o2= orcodata[mface->v2]; - o3= orcodata[mface->v3]; + o1 = orcodata[mface->v1]; + o2 = orcodata[mface->v2]; + o3 = orcodata[mface->v3]; if (mface->v4) { - o4= orcodata[mface->v4]; + o4 = orcodata[mface->v4]; interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w); @@ -1521,24 +1521,24 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } void psys_interpolate_uvs(const MTFace *tface, int quad, const float w[4], float uvco[2]) { - float v10= tface->uv[0][0]; - float v11= tface->uv[0][1]; - float v20= tface->uv[1][0]; - float v21= tface->uv[1][1]; - float v30= tface->uv[2][0]; - float v31= tface->uv[2][1]; + float v10 = tface->uv[0][0]; + float v11 = tface->uv[0][1]; + float v20 = tface->uv[1][0]; + float v21 = tface->uv[1][1]; + float v30 = tface->uv[2][0]; + float v31 = tface->uv[2][1]; float v40, v41; if (quad) { - v40= tface->uv[3][0]; - v41= tface->uv[3][1]; + v40 = tface->uv[3][0]; + v41 = tface->uv[3][1]; - uvco[0]= w[0]*v10 + w[1]*v20 + w[2]*v30 + w[3]*v40; - uvco[1]= w[0]*v11 + w[1]*v21 + w[2]*v31 + w[3]*v41; + uvco[0] = w[0] * v10 + w[1] * v20 + w[2] * v30 + w[3] * v40; + uvco[1] = w[0] * v11 + w[1] * v21 + w[2] * v31 + w[3] * v41; } else { - uvco[0]= w[0]*v10 + w[1]*v20 + w[2]*v30; - uvco[1]= w[0]*v11 + w[1]*v21 + w[2]*v31; + uvco[0] = w[0] * v10 + w[1] * v20 + w[2] * v30; + uvco[1] = w[0] * v11 + w[1] * v21 + w[2] * v31; } } @@ -1546,30 +1546,30 @@ void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *m { char *cp, *cp1, *cp2, *cp3, *cp4; - cp= (char *)mc; - cp1= (char *)&mcol[0]; - cp2= (char *)&mcol[1]; - cp3= (char *)&mcol[2]; + cp = (char *)mc; + cp1 = (char *)&mcol[0]; + cp2 = (char *)&mcol[1]; + cp3 = (char *)&mcol[2]; if (quad) { - cp4= (char *)&mcol[3]; + cp4 = (char *)&mcol[3]; - cp[0]= (int)(w[0]*cp1[0] + w[1]*cp2[0] + w[2]*cp3[0] + w[3]*cp4[0]); - cp[1]= (int)(w[0]*cp1[1] + w[1]*cp2[1] + w[2]*cp3[1] + w[3]*cp4[1]); - cp[2]= (int)(w[0]*cp1[2] + w[1]*cp2[2] + w[2]*cp3[2] + w[3]*cp4[2]); - cp[3]= (int)(w[0]*cp1[3] + w[1]*cp2[3] + w[2]*cp3[3] + w[3]*cp4[3]); + cp[0] = (int)(w[0] * cp1[0] + w[1] * cp2[0] + w[2] * cp3[0] + w[3] * cp4[0]); + cp[1] = (int)(w[0] * cp1[1] + w[1] * cp2[1] + w[2] * cp3[1] + w[3] * cp4[1]); + cp[2] = (int)(w[0] * cp1[2] + w[1] * cp2[2] + w[2] * cp3[2] + w[3] * cp4[2]); + cp[3] = (int)(w[0] * cp1[3] + w[1] * cp2[3] + w[2] * cp3[3] + w[3] * cp4[3]); } else { - cp[0]= (int)(w[0]*cp1[0] + w[1]*cp2[0] + w[2]*cp3[0]); - cp[1]= (int)(w[0]*cp1[1] + w[1]*cp2[1] + w[2]*cp3[1]); - cp[2]= (int)(w[0]*cp1[2] + w[1]*cp2[2] + w[2]*cp3[2]); - cp[3]= (int)(w[0]*cp1[3] + w[1]*cp2[3] + w[2]*cp3[3]); + cp[0] = (int)(w[0] * cp1[0] + w[1] * cp2[0] + w[2] * cp3[0]); + cp[1] = (int)(w[0] * cp1[1] + w[1] * cp2[1] + w[2] * cp3[1]); + cp[2] = (int)(w[0] * cp1[2] + w[1] * cp2[2] + w[2] * cp3[2]); + cp[3] = (int)(w[0] * cp1[3] + w[1] * cp2[3] + w[2] * cp3[3]); } } static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int index, const float fw[4], const float *values) { - if (values==0 || index==-1) + if (values == 0 || index == -1) return 0.0; switch (from) { @@ -1578,7 +1578,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int case PART_FROM_FACE: case PART_FROM_VOLUME: { - MFace *mf=dm->getTessFaceData(dm, index, CD_MFACE); + MFace *mf = dm->getTessFaceData(dm, index, CD_MFACE); return interpolate_particle_value(values[mf->v1], values[mf->v2], values[mf->v3], values[mf->v4], fw, mf->v4); } @@ -1589,8 +1589,8 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int /* conversion of pa->fw to origspace layer coordinates */ static void psys_w_to_origspace(const float w[4], float uv[2]) { - uv[0]= w[1] + w[2]; - uv[1]= w[2] + w[3]; + uv[0] = w[1] + w[2]; + uv[1] = w[2] + w[3]; } /* conversion of pa->fw to weights in face from origspace */ @@ -1598,20 +1598,20 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4 { float v[4][3], co[3]; - v[0][0]= osface->uv[0][0]; v[0][1]= osface->uv[0][1]; v[0][2]= 0.0f; - v[1][0]= osface->uv[1][0]; v[1][1]= osface->uv[1][1]; v[1][2]= 0.0f; - v[2][0]= osface->uv[2][0]; v[2][1]= osface->uv[2][1]; v[2][2]= 0.0f; + v[0][0] = osface->uv[0][0]; v[0][1] = osface->uv[0][1]; v[0][2] = 0.0f; + v[1][0] = osface->uv[1][0]; v[1][1] = osface->uv[1][1]; v[1][2] = 0.0f; + v[2][0] = osface->uv[2][0]; v[2][1] = osface->uv[2][1]; v[2][2] = 0.0f; psys_w_to_origspace(w, co); - co[2]= 0.0f; + co[2] = 0.0f; if (quad) { - v[3][0]= osface->uv[3][0]; v[3][1]= osface->uv[3][1]; v[3][2]= 0.0f; + v[3][0] = osface->uv[3][0]; v[3][1] = osface->uv[3][1]; v[3][2] = 0.0f; interp_weights_poly_v3(neww, v, 4, co); } else { interp_weights_poly_v3(neww, v, 3, co); - neww[3]= 0.0f; + neww[3] = 0.0f; } } @@ -1619,7 +1619,7 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4 * and can be optimized but only for many lookups. returns the face index. */ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const float fw[4], struct LinkNode *node) { - Mesh *me= (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; MPoly *mpoly; OrigSpaceFace *osface; int *origindex; @@ -1632,9 +1632,9 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f totface = dm->getNumTessFaces(dm); - if (osface==NULL || origindex==NULL) { + if (osface == NULL || origindex == NULL) { /* Assume we don't need osface data */ - if (index = me->totpoly) - return DMCACHE_NOTFOUND; /* index not in the original mesh */ + return DMCACHE_NOTFOUND; /* index not in the original mesh */ psys_w_to_origspace(fw, uv); if (node) { /* we have a linked list of faces that we use, faster! */ - for (;node; node=node->next) { - findex= GET_INT_FROM_POINTER(node->link); - faceuv= osface[findex].uv; + for (; node; node = node->next) { + findex = GET_INT_FROM_POINTER(node->link); + faceuv = osface[findex].uv; quad = (mpoly[findex].totloop == 4); /* check that this intersects - Its possible this misses :/ - @@ -1665,9 +1665,9 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f } } else { /* if we have no node, try every face */ - for (findex=0; findex= dm->getNumTessFaces(dm)) + if (i == DMCACHE_NOTFOUND || i >= dm->getNumTessFaces(dm)) return 0; *mapindex = i; /* modify the original weights to become * weights for the derived mesh face */ - osface= dm->getTessFaceDataArray(dm, CD_ORIGSPACE); - mface= dm->getTessFaceData(dm, i, CD_MFACE); + osface = dm->getTessFaceDataArray(dm, CD_ORIGSPACE); + mface = dm->getTessFaceData(dm, i, CD_MFACE); if (osface == NULL) - mapfw[0]= mapfw[1]= mapfw[2]= mapfw[3]= 0.0f; + mapfw[0] = mapfw[1] = mapfw[2] = mapfw[3] = 0.0f; else psys_origspace_to_w(&osface[i], mface->v4, fw, mapfw); } @@ -1753,17 +1753,17 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache int mapindex; if (!psys_map_index_on_dm(dm, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) { - if (vec) { vec[0]=vec[1]=vec[2]=0.0; } - if (nor) { nor[0]=nor[1]=0.0; nor[2]=1.0; } - if (orco) { orco[0]=orco[1]=orco[2]=0.0; } - if (ornor) { ornor[0]=ornor[1]=0.0; ornor[2]=1.0; } - if (utan) { utan[0]=utan[1]=utan[2]=0.0; } - if (vtan) { vtan[0]=vtan[1]=vtan[2]=0.0; } + if (vec) { vec[0] = vec[1] = vec[2] = 0.0; } + if (nor) { nor[0] = nor[1] = 0.0; nor[2] = 1.0; } + if (orco) { orco[0] = orco[1] = orco[2] = 0.0; } + if (ornor) { ornor[0] = ornor[1] = 0.0; ornor[2] = 1.0; } + if (utan) { utan[0] = utan[1] = utan[2] = 0.0; } + if (vtan) { vtan[0] = vtan[1] = vtan[2] = 0.0; } return; } - orcodata= dm->getVertDataArray(dm, CD_ORCO); + orcodata = dm->getVertDataArray(dm, CD_ORCO); if (from == PART_FROM_VERT) { dm->getVertCo(dm, mapindex, vec); @@ -1782,8 +1782,8 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache } if (utan && vtan) { - utan[0]= utan[1]= utan[2]= 0.0f; - vtan[0]= vtan[1]= vtan[2]= 0.0f; + utan[0] = utan[1] = utan[2] = 0.0f; + vtan[0] = vtan[1] = vtan[2] = 0.0f; } } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ @@ -1791,14 +1791,14 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache MTFace *mtface; MVert *mvert; - mface=dm->getTessFaceData(dm, mapindex, CD_MFACE); - mvert=dm->getVertDataArray(dm, CD_MVERT); - mtface=CustomData_get_layer(&dm->faceData, CD_MTFACE); + mface = dm->getTessFaceData(dm, mapindex, CD_MFACE); + mvert = dm->getVertDataArray(dm, CD_MVERT); + mtface = CustomData_get_layer(&dm->faceData, CD_MTFACE); if (mtface) mtface += mapindex; - if (from==PART_FROM_VOLUME) { + if (from == PART_FROM_VOLUME) { psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco, ornor); if (nor) copy_v3_v3(nor, tmpnor); @@ -1828,10 +1828,10 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) ModifierData *md; ParticleSystemModifierData *psmd; - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_ParticleSystem) { - psmd= (ParticleSystemModifierData*) md; - if (psmd->psys==psys) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_ParticleSystem) { + psmd = (ParticleSystemModifierData *) md; + if (psmd->psys == psys) { return psmd; } } @@ -1845,7 +1845,7 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { /* TODO */ - float zerovec[3]={0.0f, 0.0f, 0.0f}; + float zerovec[3] = {0.0f, 0.0f, 0.0f}; if (vec) { copy_v3_v3(vec, zerovec); } @@ -1871,7 +1871,7 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float * void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { if (psmd) { - if (psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) { + if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) { if (vec) copy_v3_v3(vec, fuv); @@ -1892,34 +1892,34 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat, short type, short axis, float obmat[][4], int smooth_start) { - float kink[3]={1.f, 0.f, 0.f}, par_vec[3], q1[4]={1.f, 0.f, 0.f, 0.f}; - float t, dt=1.f, result[3]; + float kink[3] = {1.f, 0.f, 0.f}, par_vec[3], q1[4] = {1.f, 0.f, 0.f, 0.f}; + float t, dt = 1.f, result[3]; if (par == NULL || type == PART_KINK_NO) return; CLAMP(time, 0.f, 1.f); - if (shape!=0.0f && type!=PART_KINK_BRAID) { - if (shape<0.0f) - time= (float)pow(time, 1.f+shape); + if (shape != 0.0f && type != PART_KINK_BRAID) { + if (shape < 0.0f) + time = (float)pow(time, 1.f + shape); else - time= (float)pow(time, 1.f/(1.f-shape)); + time = (float)pow(time, 1.f / (1.f - shape)); } - t = time * freq *(float)M_PI; + t = time * freq * (float)M_PI; if (smooth_start) { dt = fabs(t); /* smooth the beginning of kink */ CLAMP(dt, 0.f, (float)M_PI); - dt = sin(dt/2.f); + dt = sin(dt / 2.f); } if (type != PART_KINK_RADIAL) { float temp[3]; - kink[axis]=1.f; + kink[axis] = 1.f; if (obmat) mul_mat3_m4_v3(obmat, kink); @@ -1937,124 +1937,124 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float sub_v3_v3v3(par_vec, par->co, state->co); switch (type) { - case PART_KINK_CURL: - { - negate_v3(par_vec); + case PART_KINK_CURL: + { + negate_v3(par_vec); - if (flat > 0.f) { - float proj[3]; - project_v3_v3v3(proj, par_vec, par->vel); - madd_v3_v3fl(par_vec, proj, -flat); + if (flat > 0.f) { + float proj[3]; + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(par_vec, proj, -flat); - project_v3_v3v3(proj, par_vec, kink); - madd_v3_v3fl(par_vec, proj, -flat); - } + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(par_vec, proj, -flat); + } - axis_angle_to_quat(q1, kink, (float)M_PI/2.f); + axis_angle_to_quat(q1, kink, (float)M_PI / 2.f); - mul_qt_v3(q1, par_vec); - - madd_v3_v3fl(par_vec, kink, amplitude); - - /* rotate kink vector around strand tangent */ - if (t!=0.f) { - axis_angle_to_quat(q1, par->vel, t); mul_qt_v3(q1, par_vec); + + madd_v3_v3fl(par_vec, kink, amplitude); + + /* rotate kink vector around strand tangent */ + if (t != 0.f) { + axis_angle_to_quat(q1, par->vel, t); + mul_qt_v3(q1, par_vec); + } + + add_v3_v3v3(result, par->co, par_vec); + break; } + case PART_KINK_RADIAL: + { + if (flat > 0.f) { + float proj[3]; + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } - add_v3_v3v3(result, par->co, par_vec); - break; - } - case PART_KINK_RADIAL: - { - if (flat > 0.f) { - float proj[3]; - /* flatten along strand */ - project_v3_v3v3(proj, par_vec, par->vel); - madd_v3_v3fl(result, proj, flat); + madd_v3_v3fl(result, par_vec, -amplitude * (float)sin(t)); + break; } + case PART_KINK_WAVE: + { + madd_v3_v3fl(result, kink, amplitude * (float)sin(t)); - madd_v3_v3fl(result, par_vec, -amplitude*(float)sin(t)); - break; - } - case PART_KINK_WAVE: - { - madd_v3_v3fl(result, kink, amplitude*(float)sin(t)); + if (flat > 0.f) { + float proj[3]; + /* flatten along wave */ + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(result, proj, flat); - if (flat > 0.f) { - float proj[3]; - /* flatten along wave */ - project_v3_v3v3(proj, par_vec, kink); - madd_v3_v3fl(result, proj, flat); - - /* flatten along strand */ - project_v3_v3v3(proj, par_vec, par->vel); - madd_v3_v3fl(result, proj, flat); - } - break; - } - case PART_KINK_BRAID: - { - float y_vec[3]={0.f, 1.f, 0.f}; - float z_vec[3]={0.f, 0.f, 1.f}; - float vec_one[3], state_co[3]; - float inp_y, inp_z, length; - - if (par_rot) { - mul_qt_v3(par_rot, y_vec); - mul_qt_v3(par_rot, z_vec); + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } + break; } + case PART_KINK_BRAID: + { + float y_vec[3] = {0.f, 1.f, 0.f}; + float z_vec[3] = {0.f, 0.f, 1.f}; + float vec_one[3], state_co[3]; + float inp_y, inp_z, length; - negate_v3(par_vec); - normalize_v3_v3(vec_one, par_vec); + if (par_rot) { + mul_qt_v3(par_rot, y_vec); + mul_qt_v3(par_rot, z_vec); + } - inp_y=dot_v3v3(y_vec, vec_one); - inp_z=dot_v3v3(z_vec, vec_one); + negate_v3(par_vec); + normalize_v3_v3(vec_one, par_vec); - if (inp_y > 0.5f) { - copy_v3_v3(state_co, y_vec); + inp_y = dot_v3v3(y_vec, vec_one); + inp_z = dot_v3v3(z_vec, vec_one); - mul_v3_fl(y_vec, amplitude*(float)cos(t)); - mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t)); + if (inp_y > 0.5f) { + copy_v3_v3(state_co, y_vec); + + mul_v3_fl(y_vec, amplitude * (float)cos(t)); + mul_v3_fl(z_vec, amplitude / 2.f * (float)sin(2.f * t)); + } + else if (inp_z > 0.0f) { + mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI / 3.f)); + madd_v3_v3fl(state_co, y_vec, -0.5f); + + mul_v3_fl(y_vec, -amplitude * (float)cos(t + (float)M_PI / 3.f)); + mul_v3_fl(z_vec, amplitude / 2.f * (float)cos(2.f * t + (float)M_PI / 6.f)); + } + else { + mul_v3_v3fl(state_co, z_vec, -(float)sin((float)M_PI / 3.f)); + madd_v3_v3fl(state_co, y_vec, -0.5f); + + mul_v3_fl(y_vec, amplitude * (float)-sin(t + (float)M_PI / 6.f)); + mul_v3_fl(z_vec, amplitude / 2.f * (float)-sin(2.f * t + (float)M_PI / 3.f)); + } + + mul_v3_fl(state_co, amplitude); + add_v3_v3(state_co, par->co); + sub_v3_v3v3(par_vec, state->co, state_co); + + length = normalize_v3(par_vec); + mul_v3_fl(par_vec, MIN2(length, amplitude / 2.f)); + + add_v3_v3v3(state_co, par->co, y_vec); + add_v3_v3(state_co, z_vec); + add_v3_v3(state_co, par_vec); + + shape = 2.f * (float)M_PI * (1.f + shape); + + if (t < shape) { + shape = t / shape; + shape = (float)sqrt((double)shape); + interp_v3_v3v3(result, result, state_co, shape); + } + else { + copy_v3_v3(result, state_co); + } + break; } - else if (inp_z > 0.0f) { - mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI/3.f)); - madd_v3_v3fl(state_co, y_vec, -0.5f); - - mul_v3_fl(y_vec, -amplitude * (float)cos(t + (float)M_PI/3.f)); - mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + (float)M_PI/6.f)); - } - else { - mul_v3_v3fl(state_co, z_vec, -(float)sin((float)M_PI/3.f)); - madd_v3_v3fl(state_co, y_vec, -0.5f); - - mul_v3_fl(y_vec, amplitude * (float)-sin(t + (float)M_PI/6.f)); - mul_v3_fl(z_vec, amplitude/2.f * (float)-sin(2.f*t + (float)M_PI/3.f)); - } - - mul_v3_fl(state_co, amplitude); - add_v3_v3(state_co, par->co); - sub_v3_v3v3(par_vec, state->co, state_co); - - length = normalize_v3(par_vec); - mul_v3_fl(par_vec, MIN2(length, amplitude/2.f)); - - add_v3_v3v3(state_co, par->co, y_vec); - add_v3_v3(state_co, z_vec); - add_v3_v3(state_co, par_vec); - - shape = 2.f*(float)M_PI * (1.f+shape); - - if (tco, state->co, par->co, clump); } @@ -2108,12 +2108,12 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) pd_point_from_particle(sim, pa, &state, &point); - for (eff = effectors->first; eff; eff=eff->next) { + for (eff = effectors->first; eff; eff = eff->next) { if (eff->pd->forcefield != PFIELD_GUIDE) continue; if (!eff->guide_data) - eff->guide_data = MEM_callocN(sizeof(GuideEffectorData)*psys->totpart, "GuideEffectorData"); + eff->guide_data = MEM_callocN(sizeof(GuideEffectorData) * psys->totpart, "GuideEffectorData"); data = eff->guide_data + p; @@ -2139,78 +2139,78 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) float guidetime, radius, weight, angle, totstrength = 0.0f; float vec_to_point[3]; - if (effectors) for (eff = effectors->first; eff; eff=eff->next) { - pd = eff->pd; + if (effectors) for (eff = effectors->first; eff; eff = eff->next) { + pd = eff->pd; - if (pd->forcefield != PFIELD_GUIDE) - continue; + if (pd->forcefield != PFIELD_GUIDE) + continue; - data = eff->guide_data + index; + data = eff->guide_data + index; - if (data->strength <= 0.0f) - continue; + if (data->strength <= 0.0f) + continue; - guidetime = time / (1.0f - pd->free_end); + guidetime = time / (1.0f - pd->free_end); - if (guidetime>1.0f) - continue; + if (guidetime > 1.0f) + continue; - cu = (Curve*)eff->ob->data; + cu = (Curve *)eff->ob->data; - if (pd->flag & PFIELD_GUIDE_PATH_ADD) { - if (where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight)==0) - return 0; - } - else { - if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight)==0) - return 0; - } - - mul_m4_v3(eff->ob->obmat, guidevec); - mul_mat3_m4_v3(eff->ob->obmat, guidedir); - - normalize_v3(guidedir); - - copy_v3_v3(vec_to_point, data->vec_to_point); - - if (guidetime != 0.0f) { - /* curve direction */ - cross_v3_v3v3(temp, eff->guide_dir, guidedir); - angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir)); - angle = saacos(angle); - axis_angle_to_quat(rot2, temp, angle); - mul_qt_v3(rot2, vec_to_point); - - /* curve tilt */ - axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]); - mul_qt_v3(rot2, vec_to_point); - } - - /* curve taper */ - if (cu->taperobj) - mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0f), 100)); - - else { /* curve size*/ - if (cu->flag & CU_PATH_RADIUS) { - mul_v3_fl(vec_to_point, radius); + if (pd->flag & PFIELD_GUIDE_PATH_ADD) { + if (where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0) + return 0; } + else { + if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0) + return 0; + } + + mul_m4_v3(eff->ob->obmat, guidevec); + mul_mat3_m4_v3(eff->ob->obmat, guidedir); + + normalize_v3(guidedir); + + copy_v3_v3(vec_to_point, data->vec_to_point); + + if (guidetime != 0.0f) { + /* curve direction */ + cross_v3_v3v3(temp, eff->guide_dir, guidedir); + angle = dot_v3v3(eff->guide_dir, guidedir) / (len_v3(eff->guide_dir)); + angle = saacos(angle); + axis_angle_to_quat(rot2, temp, angle); + mul_qt_v3(rot2, vec_to_point); + + /* curve tilt */ + axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]); + mul_qt_v3(rot2, vec_to_point); + } + + /* curve taper */ + if (cu->taperobj) + mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100)); + + else { /* curve size*/ + if (cu->flag & CU_PATH_RADIUS) { + mul_v3_fl(vec_to_point, radius); + } + } + par.co[0] = par.co[1] = par.co[2] = 0.0f; + copy_v3_v3(key.co, vec_to_point); + do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); + do_clump(&key, &par, guidetime, pd->clump_fac, pd->clump_pow, 1.0f); + copy_v3_v3(vec_to_point, key.co); + + add_v3_v3(vec_to_point, guidevec); + + //sub_v3_v3v3(pa_loc, pa_loc, pa_zero); + madd_v3_v3fl(effect, vec_to_point, data->strength); + madd_v3_v3fl(veffect, guidedir, data->strength); + totstrength += data->strength; + + if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT) + totstrength *= weight; } - par.co[0] = par.co[1] = par.co[2] = 0.0f; - copy_v3_v3(key.co, vec_to_point); - do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); - do_clump(&key, &par, guidetime, pd->clump_fac, pd->clump_pow, 1.0f); - copy_v3_v3(vec_to_point, key.co); - - add_v3_v3(vec_to_point, guidevec); - - //sub_v3_v3v3(pa_loc, pa_loc, pa_zero); - madd_v3_v3fl(effect, vec_to_point, data->strength); - madd_v3_v3fl(veffect, guidedir, data->strength); - totstrength += data->strength; - - if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT) - totstrength *= weight; - } if (totstrength != 0.0f) { if (totstrength > 1.0f) @@ -2232,13 +2232,13 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size float rco[3]; if (thres != 0.0f) - if ((float)fabs((float)(-1.5f+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; + if ((float)fabs((float)(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * thres) return; copy_v3_v3(rco, loc); mul_v3_fl(rco, t); - rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2); - rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2); - rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2); + rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2); + rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2); + rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2); madd_v3_v3fl(state->co, mat[0], fac * rough[0]); madd_v3_v3fl(state->co, mat[1], fac * rough[1]); @@ -2249,10 +2249,10 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float float rough[2]; float roughfac; - roughfac=fac*(float)pow((double)t, shape); + roughfac = fac * (float)pow((double)t, shape); copy_v2_v2(rough, loc); - rough[0]=-1.0f+2.0f*rough[0]; - rough[1]=-1.0f+2.0f*rough[1]; + rough[0] = -1.0f + 2.0f * rough[0]; + rough[1] = -1.0f + 2.0f * rough[1]; mul_v2_fl(rough, roughfac); madd_v3_v3fl(state->co, mat[0], rough[0]); @@ -2268,23 +2268,23 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK if (sim->psys->flag & PSYS_HAIR_DYNAMICS) return; - copy_v3_v3(eff_key.co, (ca-1)->co); - copy_v3_v3(eff_key.vel, (ca-1)->vel); - copy_qt_qt(eff_key.rot, (ca-1)->rot); + copy_v3_v3(eff_key.co, (ca - 1)->co); + copy_v3_v3(eff_key.vel, (ca - 1)->vel); + copy_qt_qt(eff_key.rot, (ca - 1)->rot); - pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint); + pd_point_from_particle(sim, sim->psys->particles + i, &eff_key, &epoint); pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); - mul_v3_fl(force, effector*powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); + mul_v3_fl(force, effector * powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); add_v3_v3(force, vec); normalize_v3(force); if (k < steps) - sub_v3_v3v3(vec, (ca+1)->co, ca->co); + sub_v3_v3v3(vec, (ca + 1)->co, ca->co); - madd_v3_v3v3fl(ca->co, (ca-1)->co, force, *length); + madd_v3_v3v3fl(ca->co, (ca - 1)->co, force, *length); if (k < steps) *length = len_v3(vec); @@ -2296,10 +2296,10 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st add_v3_v3v3(state->co, (state - 1)->co, dvec); keys->steps = k; /* something over the maximum step value */ - return k=100000; + return k = 100000; } else { - *cur_length+=length; + *cur_length += length; return k; } } @@ -2308,7 +2308,7 @@ static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, P copy_v3_v3(child->co, cpa->fuv); mul_v3_fl(child->co, radius); - child->co[0]*=flat; + child->co[0] *= flat; copy_v3_v3(child->vel, par->vel); @@ -2323,7 +2323,7 @@ static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, P } float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) { - float *vg=0; + float *vg = 0; if (vgroup < 0) { /* hair dynamics pinning vgroup */ @@ -2332,15 +2332,15 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) else if (psys->vgroup[vgroup]) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert) { - int totvert=dm->getNumVerts(dm), i; - vg=MEM_callocN(sizeof(float)*totvert, "vg_cache"); - if (psys->vg_neg&(1<vgroup[vgroup] - 1); + int totvert = dm->getNumVerts(dm), i; + vg = MEM_callocN(sizeof(float) * totvert, "vg_cache"); + if (psys->vg_neg & (1 << vgroup)) { + for (i = 0; i < totvert; i++) + vg[i] = 1.0f - defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } else { - for (i=0; ivgroup[vgroup] - 1); + for (i = 0; i < totvert; i++) + vg[i] = defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } } } @@ -2348,29 +2348,29 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) } void psys_find_parents(ParticleSimulationData *sim) { - ParticleSettings *part=sim->psys->part; + ParticleSettings *part = sim->psys->part; KDTree *tree; ChildParticle *cpa; - int p, totparent, totchild=sim->psys->totchild; + int p, totparent, totchild = sim->psys->totchild; float co[3], orco[3]; - int from=PART_FROM_FACE; - totparent=(int)(totchild*part->parents*0.3f); + int from = PART_FROM_FACE; + totparent = (int)(totchild * part->parents * 0.3f); if (G.rendering && part->child_nbr && part->ren_child_nbr) - totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; - tree=BLI_kdtree_new(totparent); + tree = BLI_kdtree_new(totparent); - for (p=0, cpa=sim->psys->child; ppsys->child; p < totparent; p++, cpa++) { psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0); BLI_kdtree_insert(tree, p, orco, NULL); } BLI_kdtree_balance(tree); - for (; ppsmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0); - cpa->parent=BLI_kdtree_find_nearest(tree, orco, NULL, NULL); + cpa->parent = BLI_kdtree_find_nearest(tree, orco, NULL, NULL); } BLI_kdtree_free(tree); @@ -2399,7 +2399,7 @@ static void get_strand_normal(Material *ma, const float surfnor[3], float surfdi if (ma->strand_surfnor > 0.0f) { if (ma->strand_surfnor > surfdist) { - blend= (ma->strand_surfnor - surfdist)/ma->strand_surfnor; + blend = (ma->strand_surfnor - surfdist) / ma->strand_surfnor; interp_v3_v3v3(vnor, vnor, surfnor, blend); normalize_v3(vnor); } @@ -2410,64 +2410,64 @@ static void get_strand_normal(Material *ma, const float surfnor[3], float surfdi static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float cfra, int editupdate) { - ParticleThreadContext *ctx= threads[0].ctx; + ParticleThreadContext *ctx = threads[0].ctx; /* Object *ob= ctx->sim.ob; */ - ParticleSystem *psys= ctx->sim.psys; + ParticleSystem *psys = ctx->sim.psys; ParticleSettings *part = psys->part; /* ParticleEditSettings *pset = &scene->toolsettings->particle; */ - int totparent=0, between=0; + int totparent = 0, between = 0; int steps = (int)pow(2.0, (double)part->draw_step); int totchild = psys->totchild; - int i, seed, totthread= threads[0].tot; + int i, seed, totthread = threads[0].tot; /*---start figuring out what is actually wanted---*/ if (psys_in_edit_mode(scene, psys)) { ParticleEditSettings *pset = &scene->toolsettings->particle; - if (psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) - totchild=0; + if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) + totchild = 0; steps = (int)pow(2.0, (double)pset->draw_step); } - if (totchild && part->childtype==PART_CHILD_FACES) { - totparent=(int)(totchild*part->parents*0.3f); + if (totchild && part->childtype == PART_CHILD_FACES) { + totparent = (int)(totchild * part->parents * 0.3f); if (G.rendering && part->child_nbr && part->ren_child_nbr) - totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; /* part->parents could still be 0 so we can't test with totparent */ - between=1; + between = 1; } if (psys->renderdata) - steps=(int)pow(2.0, (double)part->ren_step); + steps = (int)pow(2.0, (double)part->ren_step); else { - totchild=(int)((float)totchild*(float)part->disp/100.0f); - totparent=MIN2(totparent, totchild); + totchild = (int)((float)totchild * (float)part->disp / 100.0f); + totparent = MIN2(totparent, totchild); } - if (totchild==0) return 0; + if (totchild == 0) return 0; /* init random number generator */ - seed= 31415926 + ctx->sim.psys->seed; + seed = 31415926 + ctx->sim.psys->seed; if (ctx->editupdate || totchild < 10000) - totthread= 1; + totthread = 1; - for (i=0; ibetween= between; - ctx->steps= steps; - ctx->totchild= totchild; - ctx->totparent= totparent; - ctx->parent_pass= 0; - ctx->cfra= cfra; - ctx->editupdate= editupdate; + ctx->between = between; + ctx->steps = steps; + ctx->totchild = totchild; + ctx->totparent = totparent; + ctx->parent_pass = 0; + ctx->cfra = cfra; + ctx->editupdate = editupdate; psys->lattice = psys_get_lattice(&ctx->sim); @@ -2483,7 +2483,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c /* set correct ipo timing */ #if 0 // XXX old animation system - if (part->flag&PART_ABS_TIME && part->ipo) { + if (part->flag & PART_ABS_TIME && part->ipo) { calc_ipo(part->ipo, cfra); execute_ipo((ID *)part, part->ipo); } @@ -2495,15 +2495,15 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c /* note: this function must be thread safe, except for branching! */ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ParticleCacheKey *child_keys, int i) { - ParticleThreadContext *ctx= thread->ctx; - Object *ob= ctx->sim.ob; + ParticleThreadContext *ctx = thread->ctx; + Object *ob = ctx->sim.ob; ParticleSystem *psys = ctx->sim.psys; ParticleSettings *part = psys->part; - ParticleCacheKey **cache= psys->childcache; - ParticleCacheKey **pcache= psys_in_edit_mode(ctx->sim.scene, psys) ? psys->edit->pathcache : psys->pathcache; + ParticleCacheKey **cache = psys->childcache; + ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.scene, psys) ? psys->edit->pathcache : psys->pathcache; ParticleCacheKey *child, *par = NULL, *key[4]; ParticleTexture ptex; - float *cpa_fuv=0, *par_rot=0, rot[4]; + float *cpa_fuv = 0, *par_rot = 0, rot[4]; float orco[3], ornor[3], hairmat[4][4], t, dvec[3], off1[4][3], off2[4][3]; float length, max_length = 1.0f, cur_length = 0.0f; float eff_length, eff_vec[3], weight[4]; @@ -2516,7 +2516,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (ctx->between) { ParticleData *pa = psys->particles + cpa->pa[0]; int w, needupdate; - float foffset, wsum=0.f; + float foffset, wsum = 0.f; float co[3]; float p_min = part->parting_min; float p_max = part->parting_max; @@ -2524,11 +2524,11 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle float p_fac = part->parents > 0.f ? 0.f : part->parting_fac; if (ctx->editupdate) { - needupdate= 0; - w= 0; - while (w<4 && cpa->pa[w]>=0) { + needupdate = 0; + w = 0; + while (w < 4 && cpa->pa[w] >= 0) { if (psys->edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) { - needupdate= 1; + needupdate = 1; break; } w++; @@ -2537,11 +2537,11 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (!needupdate) return; else - memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys) * (ctx->steps + 1)); } /* get parent paths */ - for (w=0; w<4; w++) { + for (w = 0; w < 4; w++) { if (cpa->pa[w] >= 0) { key[w] = pcache[cpa->pa[w]]; weight[w] = cpa->w[w]; @@ -2554,20 +2554,20 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle /* modify weights to create parting */ if (p_fac > 0.f) { - for (w=0; w<4; w++) { + for (w = 0; w < 4; w++) { if (w && weight[w] > 0.f) { float d; if (part->flag & PART_CHILD_LONG_HAIR) { /* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */ float d1 = len_v3v3(key[0]->co, key[w]->co); - float d2 = len_v3v3((key[0]+key[0]->steps-1)->co, (key[w]+key[w]->steps-1)->co); + float d2 = len_v3v3((key[0] + key[0]->steps - 1)->co, (key[w] + key[w]->steps - 1)->co); - d = d1 > 0.f ? d2/d1 - 1.f : 10000.f; + d = d1 > 0.f ? d2 / d1 - 1.f : 10000.f; } else { float v1[3], v2[3]; - sub_v3_v3v3(v1, (key[0]+key[0]->steps-1)->co, key[0]->co); - sub_v3_v3v3(v2, (key[w]+key[w]->steps-1)->co, key[w]->co); + sub_v3_v3v3(v1, (key[0] + key[0]->steps - 1)->co, key[0]->co); + sub_v3_v3v3(v2, (key[w] + key[w]->steps - 1)->co, key[w]->co); normalize_v3(v1); normalize_v3(v2); @@ -2575,7 +2575,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } if (p_max > p_min) - d = (d - p_min)/(p_max - p_min); + d = (d - p_min) / (p_max - p_min); else d = (d - p_min) <= 0.f ? 0.f : 1.f; @@ -2586,7 +2586,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } wsum += weight[w]; } - for (w=0; w<4; w++) + for (w = 0; w < 4; w++) weight[w] /= wsum; interp_v4_v4v4(weight, cpa->w, weight, p_fac); @@ -2603,7 +2603,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle mul_m4_v3(ob->obmat, co); - for (w=0; w<4; w++) + for (w = 0; w < 4; w++) sub_v3_v3v3(off1[w], co, key[w]->co); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); @@ -2615,7 +2615,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) return; - memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys) * (ctx->steps + 1)); } /* get the parent path */ @@ -2642,66 +2642,66 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } /* create the child path */ - for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { + for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) { if (ctx->between) { - int w=0; + int w = 0; zero_v3(child->co); zero_v3(child->vel); unit_qt(child->rot); - for (w=0; w<4; w++) { + for (w = 0; w < 4; w++) { copy_v3_v3(off2[w], off1[w]); if (part->flag & PART_CHILD_LONG_HAIR) { /* Use parent rotation (in addition to emission location) to determine child offset. */ if (k) - mul_qt_v3((key[w]+k)->rot, off2[w]); + mul_qt_v3((key[w] + k)->rot, off2[w]); /* Fade the effect of rotation for even lengths in the end */ - project_v3_v3v3(dvec, off2[w], (key[w]+k)->vel); - madd_v3_v3fl(off2[w], dvec, -(float)k/(float)ctx->steps); + project_v3_v3v3(dvec, off2[w], (key[w] + k)->vel); + madd_v3_v3fl(off2[w], dvec, -(float)k / (float)ctx->steps); } - add_v3_v3(off2[w], (key[w]+k)->co); + add_v3_v3(off2[w], (key[w] + k)->co); } /* child position is the weighted sum of parent positions */ interp_v3_v3v3v3v3(child->co, off2[0], off2[1], off2[2], off2[3], weight); - interp_v3_v3v3v3v3(child->vel, (key[0]+k)->vel, (key[1]+k)->vel, (key[2]+k)->vel, (key[3]+k)->vel, weight); + interp_v3_v3v3v3v3(child->vel, (key[0] + k)->vel, (key[1] + k)->vel, (key[2] + k)->vel, (key[3] + k)->vel, weight); - copy_qt_qt(child->rot, (key[0]+k)->rot); + copy_qt_qt(child->rot, (key[0] + k)->rot); } else { if (k) { - mul_qt_qtqt(rot, (key[0]+k)->rot, key[0]->rot); + mul_qt_qtqt(rot, (key[0] + k)->rot, key[0]->rot); par_rot = rot; } else { par_rot = key[0]->rot; } /* offset the child from the parent position */ - offset_child(cpa, (ParticleKey*)(key[0]+k), par_rot, (ParticleKey*)child, part->childflat, part->childrad); + offset_child(cpa, (ParticleKey *)(key[0] + k), par_rot, (ParticleKey *)child, part->childflat, part->childrad); } - child->time = (float)k/(float)ctx->steps; + child->time = (float)k / (float)ctx->steps; } /* apply effectors */ if (part->flag & PART_CHILD_EFFECT) { - for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { + for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) { if (k) { do_path_effectors(&ctx->sim, cpa->pa[0], child, k, ctx->steps, child_keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } else { - sub_v3_v3v3(eff_vec, (child+1)->co, child->co); + sub_v3_v3v3(eff_vec, (child + 1)->co, child->co); eff_length = len_v3(eff_vec); } } } - for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { - t = (float)k/(float)ctx->steps; + for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) { + t = (float)k / (float)ctx->steps; if (ctx->totparent) /* this is now threadsafe, virtual parents are calculated before rest of children */ @@ -2711,7 +2711,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (par) { if (k) { - mul_qt_qtqt(rot, (par+k)->rot, par->rot); + mul_qt_qtqt(rot, (par + k)->rot, par->rot); par_rot = rot; } else { @@ -2724,21 +2724,21 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)child, t); /* we have to correct velocity because of kink & clump */ - if (k>1) { - sub_v3_v3v3((child-1)->vel, child->co, (child-2)->co); - mul_v3_fl((child-1)->vel, 0.5); + if (k > 1) { + sub_v3_v3v3((child - 1)->vel, child->co, (child - 2)->co); + mul_v3_fl((child - 1)->vel, 0.5); if (ctx->ma && (part->draw_col == PART_DRAW_COL_MAT)) - get_strand_normal(ctx->ma, ornor, cur_length, (child-1)->vel); + get_strand_normal(ctx->ma, ornor, cur_length, (child - 1)->vel); } if (k == ctx->steps) - sub_v3_v3v3(child->vel, child->co, (child-1)->co); + sub_v3_v3v3(child->vel, child->co, (child - 1)->co); /* check if path needs to be cut before actual end of data points */ if (k) { - sub_v3_v3v3(dvec, child->co, (child-1)->co); - length = 1.0f/(float)ctx->steps; + sub_v3_v3v3(dvec, child->co, (child - 1)->co); + length = 1.0f / (float)ctx->steps; k = check_path_length(k, child_keys, child, max_length, &cur_length, length, dvec); } else { @@ -2760,20 +2760,20 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle static void *exec_child_path_cache(void *data) { - ParticleThread *thread= (ParticleThread*)data; - ParticleThreadContext *ctx= thread->ctx; - ParticleSystem *psys= ctx->sim.psys; - ParticleCacheKey **cache= psys->childcache; + ParticleThread *thread = (ParticleThread *)data; + ParticleThreadContext *ctx = thread->ctx; + ParticleSystem *psys = ctx->sim.psys; + ParticleCacheKey **cache = psys->childcache; ChildParticle *cpa; - int i, totchild= ctx->totchild, first= 0; + int i, totchild = ctx->totchild, first = 0; if (thread->tot > 1) { - first= ctx->parent_pass? 0 : ctx->totparent; - totchild= ctx->parent_pass? ctx->totparent : ctx->totchild; + first = ctx->parent_pass ? 0 : ctx->totparent; + totchild = ctx->parent_pass ? ctx->totparent : ctx->totchild; } - cpa= psys->child + first + thread->num; - for (i=first+thread->num; itot, cpa+=thread->tot) + cpa = psys->child + first + thread->num; + for (i = first + thread->num; i < totchild; i += thread->tot, cpa += thread->tot) psys_thread_create_path(thread, cpa, cache[i], i); return 0; @@ -2789,16 +2789,16 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd if (sim->psys->flag & PSYS_GLOBAL_HAIR) return; - pthreads= psys_threads_create(sim); + pthreads = psys_threads_create(sim); if (!psys_threads_init_path(pthreads, sim->scene, cfra, editupdate)) { psys_threads_free(pthreads); return; } - ctx= pthreads[0].ctx; - totchild= ctx->totchild; - totparent= ctx->totparent; + ctx = pthreads[0].ctx; + totchild = ctx->totchild; + totparent = ctx->totparent; if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { ; /* just overwrite the existing cache */ @@ -2806,11 +2806,11 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd else { /* clear out old and create new empty path cache */ free_child_path_cache(sim->psys); - sim->psys->childcache= psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps+1); + sim->psys->childcache = psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps + 1); sim->psys->totchildcache = totchild; } - totthread= pthreads[0].tot; + totthread = pthreads[0].tot; if (totthread > 1) { @@ -2818,20 +2818,20 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd if (totparent) { BLI_init_threads(&threads, exec_child_path_cache, totthread); - for (i=0; iparent_pass = 1; BLI_insert_thread(&threads, &pthreads[i]); } BLI_end_threads(&threads); - for (i=0; iparent_pass = 0; } BLI_init_threads(&threads, exec_child_path_cache, totthread); - for (i=0; ico, key1->co); - normalize_v3(prev_tangent); - unit_qt(key1->rot); - break; - default: - sub_v3_v3v3(tangent, key0->co, key1->co); - normalize_v3(tangent); + case 0: + /* start from second key */ + break; + case 1: + /* calculate initial tangent for incremental rotations */ + sub_v3_v3v3(prev_tangent, key0->co, key1->co); + normalize_v3(prev_tangent); + unit_qt(key1->rot); + break; + default: + sub_v3_v3v3(tangent, key0->co, key1->co); + normalize_v3(tangent); - cosangle= dot_v3v3(tangent, prev_tangent); + cosangle = dot_v3v3(tangent, prev_tangent); - /* note we do the comparison on cosangle instead of - * angle, since floating point accuracy makes it give - * different results across platforms */ - if (cosangle > 0.999999f) { - copy_v4_v4(key1->rot, key2->rot); - } - else { - angle= saacos(cosangle); - cross_v3_v3v3(normal, prev_tangent, tangent); - axis_angle_to_quat(q, normal, angle); - mul_qt_qtqt(key1->rot, q, key2->rot); - } + /* note we do the comparison on cosangle instead of + * angle, since floating point accuracy makes it give + * different results across platforms */ + if (cosangle > 0.999999f) { + copy_v4_v4(key1->rot, key2->rot); + } + else { + angle = saacos(cosangle); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat(q, normal, angle); + mul_qt_qtqt(key1->rot, q, key2->rot); + } - copy_v3_v3(prev_tangent, tangent); + copy_v3_v3(prev_tangent, tangent); } } @@ -2892,7 +2892,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) ParticleSettings *part = psys->part; ParticleCacheKey *ca, **cache; - DerivedMesh *hair_dm = (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; + DerivedMesh *hair_dm = (psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; ParticleKey result; @@ -2911,16 +2911,16 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) int steps = (int)pow(2.0, (double)(psys->renderdata ? part->ren_step : part->draw_step)); int totpart = psys->totpart; float length, vec[3]; - float *vg_effector= NULL; - float *vg_length= NULL, pa_length=1.0f; + float *vg_effector = NULL; + float *vg_length = NULL, pa_length = 1.0f; int keyed, baked; /* we don't have anything valid to create paths from so let's quit here */ - if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0) + if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0) return; if (psys_in_edit_mode(sim->scene, psys)) - if (psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) + if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) return; keyed = psys->flag & PSYS_KEYED; @@ -2928,15 +2928,15 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* clear out old and create new empty path cache */ psys_free_path_cache(psys, psys->edit); - cache= psys->pathcache= psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps+1); + cache = psys->pathcache = psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps + 1); psys->lattice = psys_get_lattice(sim); - ma= give_current_material(sim->ob, psys->part->omat); + ma = give_current_material(sim->ob, psys->part->omat); if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT)) copy_v3_v3(col, &ma->r); - if ((psys->flag & PSYS_GLOBAL_HAIR)==0) { - if ((psys->part->flag & PART_CHILD_EFFECT)==0) + if ((psys->flag & PSYS_GLOBAL_HAIR) == 0) { + if ((psys->part->flag & PART_CHILD_EFFECT) == 0) vg_effector = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_EFFECTOR); if (!psys->totchild) @@ -2963,7 +2963,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); pind.dm = hair_dm; - memset(cache[p], 0, sizeof(*cache[p])*(steps+1)); + memset(cache[p], 0, sizeof(*cache[p]) * (steps + 1)); cache[p]->steps = steps; @@ -2994,7 +2994,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) dietime = birthtime + pa_length * (dietime - birthtime); /*--interpolate actual path from data points--*/ - for (k=0, ca=cache[p]; k<=steps; k++, ca++) { + for (k = 0, ca = cache[p]; k <= steps; k++, ca++) { time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; @@ -3016,45 +3016,45 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if (!(psys->flag & PSYS_GLOBAL_HAIR)) { /* apply effectors */ if ((psys->part->flag & PART_CHILD_EFFECT) == 0) { - float effector= 1.0f; + float effector = 1.0f; if (vg_effector) - effector*= psys_particle_value_from_verts(psmd->dm, psys->part->from, pa, vg_effector); + effector *= psys_particle_value_from_verts(psmd->dm, psys->part->from, pa, vg_effector); - sub_v3_v3v3(vec, (cache[p]+1)->co, cache[p]->co); + sub_v3_v3v3(vec, (cache[p] + 1)->co, cache[p]->co); length = len_v3(vec); - for (k=1, ca=cache[p]+1; k<=steps; k++, ca++) + for (k = 1, ca = cache[p] + 1; k <= steps; k++, ca++) do_path_effectors(sim, p, ca, k, steps, cache[p]->co, effector, dfra, cfra, &length, vec); } /* apply guide curves to path data */ - if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) { - for (k=0, ca=cache[p]; k<=steps; k++, ca++) + if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) { + for (k = 0, ca = cache[p]; k <= steps; k++, ca++) /* ca is safe to cast, since only co and vel are used */ - do_guides(sim->psys->effectors, (ParticleKey*)ca, p, (float)k/(float)steps); + do_guides(sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)steps); } /* lattices have to be calculated separately to avoid mixups between effector calculations */ if (psys->lattice) { - for (k=0, ca=cache[p]; k<=steps; k++, ca++) + for (k = 0, ca = cache[p]; k <= steps; k++, ca++) calc_latt_deform(psys->lattice, ca->co, 1.0f); } } /* finally do rotation & velocity */ - for (k=1, ca=cache[p]+1; k<=steps; k++, ca++) { + for (k = 1, ca = cache[p] + 1; k <= steps; k++, ca++) { cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k); if (k == steps) copy_qt_qt(ca->rot, (ca - 1)->rot); /* set velocity */ - sub_v3_v3v3(ca->vel, ca->co, (ca-1)->co); + sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co); - if (k==1) - copy_v3_v3((ca-1)->vel, ca->vel); + if (k == 1) + copy_v3_v3((ca - 1)->vel, ca->vel); - ca->time = (float)k/(float)steps; + ca->time = (float)k / (float)steps; } /* First rotation is based on emitting face orientation. * This is way better than having flipping rotations resulting @@ -3070,7 +3070,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if (psys->lattice) { end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; } if (vg_effector) @@ -3081,7 +3081,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) } void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cfra) { - ParticleCacheKey *ca, **cache= edit->pathcache; + ParticleCacheKey *ca, **cache = edit->pathcache; ParticleEditSettings *pset = &scene->toolsettings->particle; PTCacheEditPoint *point = NULL; @@ -3099,7 +3099,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f}; int k, i; int steps = (int)pow(2.0, (double)pset->draw_step); - int totpart = edit->totpoint, recalc_set=0; + int totpart = edit->totpoint, recalc_set = 0; float sel_col[3]; float nosel_col[3]; @@ -3108,10 +3108,10 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf if (!cache || edit->totpoint != edit->totcached) { /* clear out old and create new empty path cache */ psys_free_path_cache(edit->psys, edit); - cache= edit->pathcache= psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps+1); + cache = edit->pathcache = psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps + 1); /* set flag for update (child particles check this too) */ - for (i=0, point=edit->points; ipoints; i < totpart; i++, point++) point->flag |= PEP_EDIT_RECALC; recalc_set = 1; } @@ -3119,7 +3119,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; */ /* UNUSED */ if (pset->brushtype == PE_BRUSH_WEIGHT) { - ;/* use weight painting colors now... */ + ; /* use weight painting colors now... */ } else { sel_col[0] = (float)edit->sel_col[0] / 255.0f; @@ -3131,7 +3131,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*---first main loop: create all actual particles' paths---*/ - for (i=0, point=edit->points; ipoints; i < totpart; i++, pa += pa ? 1 : 0, point++) { if (edit->totcached && !(point->flag & PEP_EDIT_RECALC)) continue; @@ -3148,14 +3148,14 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* should init_particle_interpolation set this ? */ - if (pset->brushtype==PE_BRUSH_WEIGHT) { + if (pset->brushtype == PE_BRUSH_WEIGHT) { pind.hkey[0] = NULL; /* pa != NULL since the weight brush is only available for hair */ pind.hkey[1] = pa->hair; } - memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); + memset(cache[i], 0, sizeof(*cache[i]) * (steps + 1)); cache[i]->steps = steps; @@ -3178,14 +3178,14 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*--interpolate actual path from data points--*/ - for (k=0, ca=cache[i]; k<=steps; k++, ca++) { + for (k = 0, ca = cache[i]; k <= steps; k++, ca++) { time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; do_particle_interpolation(psys, i, pa, t, &pind, &result); copy_v3_v3(ca->co, result.co); - /* non-hair points are already in global space */ + /* non-hair points are already in global space */ if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, ca->co); @@ -3198,7 +3198,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* set velocity */ sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co); - if (k==1) + if (k == 1) copy_v3_v3((ca - 1)->vel, ca->vel); } } @@ -3208,15 +3208,15 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /* selection coloring in edit mode */ - if (pset->brushtype==PE_BRUSH_WEIGHT) { + if (pset->brushtype == PE_BRUSH_WEIGHT) { float t2; - if (k==0) { + if (k == 0) { weight_to_rgb(ca->col, pind.hkey[1]->weight); } else { float w1[3], w2[3]; - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); weight_to_rgb(w1, pind.hkey[0]->weight); weight_to_rgb(w2, pind.hkey[1]->weight); @@ -3226,7 +3226,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* at the moment this is only used for weight painting. * will need to move out of this check if its used elsewhere. */ - t2 = birthtime + ((float)k/(float)steps) * (dietime - birthtime); + t2 = birthtime + ((float)k / (float)steps) * (dietime - birthtime); while (pind.hkey[1]->time < t2) pind.hkey[1]++; pind.hkey[0] = pind.hkey[1] - 1; @@ -3237,13 +3237,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf copy_v3_v3(ca->col, sel_col); } else { - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); } } else { if ((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) { - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); } else { @@ -3269,18 +3269,18 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf edit->totcached = totpart; if (psys) { - ParticleSimulationData sim= {0}; - sim.scene= scene; - sim.ob= ob; - sim.psys= psys; - sim.psmd= psys_get_modifier(ob, psys); + ParticleSimulationData sim = {0}; + sim.scene = scene; + sim.ob = ob; + sim.psys = psys; + sim.psmd = psys_get_modifier(ob, psys); psys_cache_child_paths(&sim, cfra, 1); } /* clear recalc flag if set here */ if (recalc_set) { - for (i=0, point=edit->points; ipoints; i < totpart; i++, point++) point->flag &= ~PEP_EDIT_RECALC; } } @@ -3293,9 +3293,9 @@ void copy_particle_key(ParticleKey *to, ParticleKey *from, int time) memcpy(to, from, sizeof(ParticleKey)); } else { - float to_time=to->time; + float to_time = to->time; memcpy(to, from, sizeof(ParticleKey)); - to->time=to_time; + to->time = to_time; } } void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, float *time) @@ -3303,7 +3303,7 @@ void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, flo if (loc) copy_v3_v3(loc, key->co); if (vel) copy_v3_v3(vel, key->vel); if (rot) copy_qt_qt(rot, key->rot); - if (time) *time=key->time; + if (time) *time = key->time; } /*-------changing particle keys from space to another-------*/ #if 0 @@ -3326,33 +3326,33 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat { float det, w1, w2, d1[2], d2[2]; - memset(mat, 0, sizeof(float)*4*4); - mat[3][3]= 1.0f; + memset(mat, 0, sizeof(float) * 4 * 4); + mat[3][3] = 1.0f; /* first axis is the normal */ normal_tri_v3(mat[2], v1, v2, v3); /* second axis along (1, 0) in uv space */ if (uv) { - d1[0]= uv[1][0] - uv[0][0]; - d1[1]= uv[1][1] - uv[0][1]; - d2[0]= uv[2][0] - uv[0][0]; - d2[1]= uv[2][1] - uv[0][1]; + d1[0] = uv[1][0] - uv[0][0]; + d1[1] = uv[1][1] - uv[0][1]; + d2[0] = uv[2][0] - uv[0][0]; + d2[1] = uv[2][1] - uv[0][1]; - det = d2[0]*d1[1] - d2[1]*d1[0]; + det = d2[0] * d1[1] - d2[1] * d1[0]; if (det != 0.0f) { - det= 1.0f/det; - w1= -d2[1]*det; - w2= d1[1]*det; + det = 1.0f / det; + w1 = -d2[1] * det; + w2 = d1[1] * det; - mat[1][0]= w1*(v2[0] - v1[0]) + w2*(v3[0] - v1[0]); - mat[1][1]= w1*(v2[1] - v1[1]) + w2*(v3[1] - v1[1]); - mat[1][2]= w1*(v2[2] - v1[2]) + w2*(v3[2] - v1[2]); + mat[1][0] = w1 * (v2[0] - v1[0]) + w2 * (v3[0] - v1[0]); + mat[1][1] = w1 * (v2[1] - v1[1]) + w2 * (v3[1] - v1[1]); + mat[1][2] = w1 * (v2[2] - v1[2]) + w2 * (v3[2] - v1[2]); normalize_v3(mat[1]); } else - mat[1][0]= mat[1][1]= mat[1][2]= 0.0f; + mat[1][0] = mat[1][1] = mat[1][2] = 0.0f; } else { sub_v3_v3v3(mat[1], v2, v1); @@ -3370,14 +3370,14 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m OrigSpaceFace *osface; float (*orcodata)[3]; - int i = pa->num_dmcache==DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache; + int i = pa->num_dmcache == DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache; - if (i==-1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; } + if (i == -1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; } - mface=dm->getTessFaceData(dm, i, CD_MFACE); - osface=dm->getTessFaceData(dm, i, CD_ORIGSPACE); + mface = dm->getTessFaceData(dm, i, CD_MFACE); + osface = dm->getTessFaceData(dm, i, CD_ORIGSPACE); - if (orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) { + if (orco && (orcodata = dm->getVertDataArray(dm, CD_ORCO))) { copy_v3_v3(v[0], orcodata[mface->v1]); copy_v3_v3(v[1], orcodata[mface->v2]); copy_v3_v3(v[2], orcodata[mface->v3]); @@ -3393,7 +3393,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m dm->getVertCo(dm, mface->v3, v[2]); } - triatomat(v[0], v[1], v[2], (osface)? osface->uv: NULL, mat); + triatomat(v[0], v[1], v[2], (osface) ? osface->uv : NULL, mat); } void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) @@ -3449,7 +3449,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n return NULL; psys = ob->particlesystem.first; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) psys->flag &= ~PSYS_CURRENT; psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); @@ -3458,23 +3458,23 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->part = psys_new_settings("ParticleSettings", NULL); - if (BLI_countlist(&ob->particlesystem)>1) + if (BLI_countlist(&ob->particlesystem) > 1) BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); else strcpy(psys->name, "ParticleSystem"); - md= modifier_new(eModifierType_ParticleSystem); + md = modifier_new(eModifierType_ParticleSystem); - if (name) BLI_strncpy(md->name, name, sizeof(md->name)); - else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + if (name) BLI_strncpy(md->name, name, sizeof(md->name)); + else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); modifier_unique_name(&ob->modifiers, md); - psmd= (ParticleSystemModifierData*) md; - psmd->psys=psys; + psmd = (ParticleSystemModifierData *) md; + psmd->psys = psys; BLI_addtail(&ob->modifiers, md); - psys->totpart=0; - psys->flag = PSYS_ENABLED|PSYS_CURRENT; + psys->totpart = 0; + psys->flag = PSYS_ENABLED | PSYS_CURRENT; psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1); DAG_scene_sort(G.main, scene); @@ -3507,7 +3507,7 @@ void object_remove_particle_system(Scene *scene, Object *ob) } /* clear modifier */ - psmd= psys_get_modifier(ob, psys); + psmd = psys_get_modifier(ob, psys); BLI_remlink(&ob->modifiers, psmd); modifier_free((ModifierData *)psmd); @@ -3525,64 +3525,64 @@ void object_remove_particle_system(Scene *scene, Object *ob) } static void default_particle_settings(ParticleSettings *part) { - part->type= PART_EMITTER; - part->distr= PART_DISTR_JIT; + part->type = PART_EMITTER; + part->distr = PART_DISTR_JIT; part->draw_as = PART_DRAW_REND; part->ren_as = PART_DRAW_HALO; - part->bb_uv_split=1; - part->bb_align=PART_BB_VIEW; - part->bb_split_offset=PART_BB_OFF_LINEAR; - part->flag=PART_EDISTR|PART_TRAND|PART_HIDE_ADVANCED_HAIR; + part->bb_uv_split = 1; + part->bb_align = PART_BB_VIEW; + part->bb_split_offset = PART_BB_OFF_LINEAR; + part->flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR; - part->sta= 1.0; - part->end= 200.0; - part->lifetime= 50.0; - part->jitfac= 1.0; - part->totpart= 1000; - part->grid_res= 10; - part->timetweak= 1.0; + part->sta = 1.0; + part->end = 200.0; + part->lifetime = 50.0; + part->jitfac = 1.0; + part->totpart = 1000; + part->grid_res = 10; + part->timetweak = 1.0; part->courant_target = 0.2; - part->integrator= PART_INT_MIDPOINT; - part->phystype= PART_PHYS_NEWTON; - part->hair_step= 5; - part->keys_step= 5; - part->draw_step= 2; - part->ren_step= 3; - part->adapt_angle= 5; - part->adapt_pix= 3; - part->kink_axis= 2; - part->kink_amp_clump= 1.f; - part->reactevent= PART_EVENT_DEATH; - part->disp=100; - part->from= PART_FROM_FACE; + part->integrator = PART_INT_MIDPOINT; + part->phystype = PART_PHYS_NEWTON; + part->hair_step = 5; + part->keys_step = 5; + part->draw_step = 2; + part->ren_step = 3; + part->adapt_angle = 5; + part->adapt_pix = 3; + part->kink_axis = 2; + part->kink_amp_clump = 1.f; + part->reactevent = PART_EVENT_DEATH; + part->disp = 100; + part->from = PART_FROM_FACE; - part->normfac= 1.0f; + part->normfac = 1.0f; - part->mass=1.0; - part->size=0.05; - part->childsize=1.0; + part->mass = 1.0; + part->size = 0.05; + part->childsize = 1.0; part->rotmode = PART_ROT_VEL; part->avemode = PART_AVE_VELOCITY; - part->child_nbr=10; - part->ren_child_nbr=100; - part->childrad=0.2f; - part->childflat=0.0f; - part->clumppow=0.0f; - part->kink_amp=0.2f; - part->kink_freq=2.0; + part->child_nbr = 10; + part->ren_child_nbr = 100; + part->childrad = 0.2f; + part->childflat = 0.0f; + part->clumppow = 0.0f; + part->kink_amp = 0.2f; + part->kink_freq = 2.0; - part->rough1_size=1.0; - part->rough2_size=1.0; - part->rough_end_shape=1.0; + part->rough1_size = 1.0; + part->rough2_size = 1.0; + part->rough_end_shape = 1.0; - part->clength=1.0f; - part->clength_thres=0.0f; + part->clength = 1.0f; + part->clength_thres = 0.0f; - part->draw= PART_DRAW_EMITTER; - part->draw_line[0]=0.5; + part->draw = PART_DRAW_EMITTER; + part->draw_line[0] = 0.5; part->path_start = 0.0f; part->path_end = 1.0f; @@ -3593,10 +3593,10 @@ static void default_particle_settings(ParticleSettings *part) part->color_vec_max = 1.f; part->draw_col = PART_DRAW_COL_MAT; - part->simplify_refsize= 1920; - part->simplify_rate= 1.0f; - part->simplify_transition= 0.1f; - part->simplify_viewport= 0.8; + part->simplify_refsize = 1920; + part->simplify_rate = 1.0f; + part->simplify_transition = 0.1f; + part->simplify_viewport = 0.8; if (!part->effector_weights) part->effector_weights = BKE_add_effector_weights(NULL); @@ -3607,10 +3607,10 @@ ParticleSettings *psys_new_settings(const char *name, Main *main) { ParticleSettings *part; - if (main==NULL) + if (main == NULL) main = G.main; - part= BKE_libblock_alloc(&main->particle, ID_PA, name); + part = BKE_libblock_alloc(&main->particle, ID_PA, name); default_particle_settings(part); @@ -3622,17 +3622,17 @@ ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part) ParticleSettings *partn; int a; - 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); - partn->fluid= MEM_dupallocN(part->fluid); + 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); + partn->fluid = MEM_dupallocN(part->fluid); partn->boids = boid_copy_settings(part->boids); - for (a=0; amtex[a]) { - partn->mtex[a]= MEM_mallocN(sizeof(MTex), "psys_copy_tex"); + partn->mtex[a] = MEM_mallocN(sizeof(MTex), "psys_copy_tex"); memcpy(partn->mtex[a], part->mtex[a], sizeof(MTex)); id_us_plus((ID *)partn->mtex[a]->tex); } @@ -3648,57 +3648,57 @@ static void expand_local_particlesettings(ParticleSettings *part) int i; id_lib_extern((ID *)part->dup_group); - for (i=0; imtex[i]) id_lib_extern((ID *)part->mtex[i]->tex); } } void BKE_particlesettings_make_local(ParticleSettings *part) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (part->id.lib==0) return; - if (part->id.us==1) { + if (part->id.lib == 0) return; + if (part->id.us == 1) { id_clear_lib_data(bmain, &part->id); expand_local_particlesettings(part); return; } /* test objects */ - for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) { - ParticleSystem *psys=ob->particlesystem.first; - for (; psys; psys=psys->next) { - if (psys->part==part) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (ob = bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob = ob->id.next) { + ParticleSystem *psys = ob->particlesystem.first; + for (; psys; psys = psys->next) { + if (psys->part == part) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - if (is_local && is_lib==FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &part->id); expand_local_particlesettings(part); } else if (is_local && is_lib) { - ParticleSettings *part_new= BKE_particlesettings_copy(part); - part_new->id.us= 0; + ParticleSettings *part_new = BKE_particlesettings_copy(part); + part_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, part->id.lib, &part_new->id); /* do objects */ - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ParticleSystem *psys; - for (psys= ob->particlesystem.first; psys; psys=psys->next) { - if (psys->part==part && ob->id.lib==0) { - psys->part= part_new; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part == part && ob->id.lib == 0) { + psys->part = part_new; part_new->id.us++; part->id.us--; } @@ -3717,42 +3717,42 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co MTFace *tf; int i; - tf= CustomData_get_layer_named(&dm->faceData, CD_MTFACE, name); + tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, name); if (tf == NULL) - tf= CustomData_get_layer(&dm->faceData, CD_MTFACE); + tf = CustomData_get_layer(&dm->faceData, CD_MTFACE); if (tf == NULL) return 0; if (pa) { - i= (pa->num_dmcache==DMCACHE_NOTFOUND)? pa->num: pa->num_dmcache; + i = (pa->num_dmcache == DMCACHE_NOTFOUND) ? pa->num : pa->num_dmcache; if (i >= dm->getNumTessFaces(dm)) i = -1; } else - i= face_index; + i = face_index; - if (i==-1) { - texco[0]= 0.0f; - texco[1]= 0.0f; - texco[2]= 0.0f; + if (i == -1) { + texco[0] = 0.0f; + texco[1] = 0.0f; + texco[2] = 0.0f; } else { - mf= dm->getTessFaceData(dm, i, CD_MFACE); + mf = dm->getTessFaceData(dm, i, CD_MFACE); psys_interpolate_uvs(&tf[i], mf->v4, fuv, texco); - texco[0]= texco[0]*2.0f - 1.0f; - texco[1]= texco[1]*2.0f - 1.0f; - texco[2]= 0.0f; + texco[0] = texco[0] * 2.0f - 1.0f; + texco[1] = texco[1] * 2.0f - 1.0f; + texco[2] = 0.0f; } return 1; } -#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend);} -#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if (event & type) { if (pvalue < 0.f) pvalue = 1.f+pvalue; CLAMP(pvalue, 0.0f, 1.0f); } +#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } +#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if (event & type) { if (pvalue < 0.f) pvalue = 1.f + pvalue; CLAMP(pvalue, 0.0f, 1.0f); } #define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) if (event & type) { CLAMP(pvalue, -1.0f, 1.0f); } static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, const float fw[4], float *orco, ParticleTexture *ptex, int event, float cfra) @@ -3762,50 +3762,50 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti float value, rgba[4], texvec[3]; ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = - ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = - ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; - ptex->length= 1.0f - part->randlength * PSYS_FRAND(child_index + 26); - ptex->length*= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; + ptex->length = 1.0f - part->randlength *PSYS_FRAND(child_index + 26); + ptex->length *= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; - for (m=0; mmapto) { - float def=mtex->def_var; - short blend=mtex->blendtype; + float def = mtex->def_var; + short blend = mtex->blendtype; short texco = mtex->texco; if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; switch (texco) { - case TEXCO_GLOB: - copy_v3_v3(texvec, par->state.co); - break; - case TEXCO_OBJECT: - copy_v3_v3(texvec, par->state.co); - if (mtex->object) - mul_m4_v3(mtex->object->imat, texvec); - break; - case TEXCO_UV: - if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec)) + case TEXCO_GLOB: + copy_v3_v3(texvec, par->state.co); break; + case TEXCO_OBJECT: + copy_v3_v3(texvec, par->state.co); + if (mtex->object) + mul_m4_v3(mtex->object->imat, texvec); + break; + case TEXCO_UV: + if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec)) + break; /* no break, failed to get uv's, so let's try orco's */ - case TEXCO_ORCO: - copy_v3_v3(texvec, orco); - break; - case TEXCO_PARTICLE: - /* texture coordinates in range [-1, 1] */ - texvec[0] = 2.f * (cfra - par->time)/(par->dietime-par->time) - 1.f; - texvec[1] = 0.f; - texvec[2] = 0.f; - break; + case TEXCO_ORCO: + copy_v3_v3(texvec, orco); + break; + case TEXCO_PARTICLE: + /* texture coordinates in range [-1, 1] */ + texvec[0] = 2.f * (cfra - par->time) / (par->dietime - par->time) - 1.f; + texvec[1] = 0.f; + texvec[2] = 0.f; + break; } - externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); + externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0); if ((event & mtex->mapto) & PAMAP_ROUGH) - ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def, ptex->rough1, value, mtex->roughfac, blend); + ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend(def, ptex->rough1, value, mtex->roughfac, blend); SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac); SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac); @@ -3827,62 +3827,62 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex MTex *mtex; int m; float value, rgba[4], co[3], texvec[3]; - int setvars=0; + int setvars = 0; /* initialize ptex */ ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = - ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink = - ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f; - ptex->time = (float)(pa - sim->psys->particles)/(float)sim->psys->totpart; + ptex->time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart; - for (m=0; mmapto) { - float def=mtex->def_var; - short blend=mtex->blendtype; + float def = mtex->def_var; + short blend = mtex->blendtype; short texco = mtex->texco; if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; switch (texco) { - case TEXCO_GLOB: - copy_v3_v3(texvec, pa->state.co); - break; - case TEXCO_OBJECT: - copy_v3_v3(texvec, pa->state.co); - if (mtex->object) - mul_m4_v3(mtex->object->imat, texvec); - break; - case TEXCO_UV: - if (get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec)) + case TEXCO_GLOB: + copy_v3_v3(texvec, pa->state.co); break; + case TEXCO_OBJECT: + copy_v3_v3(texvec, pa->state.co); + if (mtex->object) + mul_m4_v3(mtex->object->imat, texvec); + break; + case TEXCO_UV: + if (get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec)) + break; /* no break, failed to get uv's, so let's try orco's */ - case TEXCO_ORCO: - psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0); - break; - case TEXCO_PARTICLE: - /* texture coordinates in range [-1, 1] */ - texvec[0] = 2.f * (cfra - pa->time)/(pa->dietime-pa->time) - 1.f; - texvec[1] = 0.f; - texvec[2] = 0.f; - break; + case TEXCO_ORCO: + psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0); + break; + case TEXCO_PARTICLE: + /* texture coordinates in range [-1, 1] */ + texvec[0] = 2.f * (cfra - pa->time) / (pa->dietime - pa->time) - 1.f; + texvec[1] = 0.f; + texvec[2] = 0.f; + break; } - externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); + externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0); if ((event & mtex->mapto) & PAMAP_TIME) { /* the first time has to set the base value for time regardless of blend mode */ - if ((setvars&MAP_PA_TIME)==0) { - int flip= (mtex->timefac < 0.0f); - float timefac= fabsf(mtex->timefac); + if ((setvars & MAP_PA_TIME) == 0) { + int flip = (mtex->timefac < 0.0f); + float timefac = fabsf(mtex->timefac); ptex->time *= 1.0f - timefac; - ptex->time += timefac * ((flip)? 1.0f - value : value); + ptex->time += timefac * ((flip) ? 1.0f - value : value); setvars |= MAP_PA_TIME; } else - ptex->time= texture_value_blend(def, ptex->time, value, mtex->timefac, blend); + ptex->time = texture_value_blend(def, ptex->time, value, mtex->timefac, blend); } SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac) SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac) @@ -3917,11 +3917,11 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, ParticleSettings *part = psys->part; float time, life; - if (part->childtype==PART_CHILD_FACES) { - int w=0; - time=0.0; - while (w<4 && cpa->pa[w]>=0) { - time+=cpa->w[w]*(psys->particles+cpa->pa[w])->time; + if (part->childtype == PART_CHILD_FACES) { + int w = 0; + time = 0.0; + while (w < 4 && cpa->pa[w] >= 0) { + time += cpa->w[w] * (psys->particles + cpa->pa[w])->time; w++; } @@ -3937,24 +3937,24 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, if (birthtime) *birthtime = time; if (dietime) - *dietime = time+life; + *dietime = time + life; - return (cfra-time)/life; + return (cfra - time) / life; } float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED(cfra), float *UNUSED(pa_time)) { ParticleSettings *part = psys->part; float size; // time XXX - if (part->childtype==PART_CHILD_FACES) - size=part->size; + if (part->childtype == PART_CHILD_FACES) + size = part->size; else - size=psys->particles[cpa->parent].size; + size = psys->particles[cpa->parent].size; - size*=part->childsize; + size *= part->childsize; if (part->childrandsize != 0.0f) - size *= 1.0f - part->childrandsize * PSYS_FRAND(cpa - psys->child + 26); + size *= 1.0f - part->childrandsize *PSYS_FRAND(cpa - psys->child + 26); return size; } @@ -3963,26 +3963,26 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread ParticleSystem *psys = ctx->sim.psys; int i = cpa - psys->child; - get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS|PAMAP_CHILD, psys->cfra); + get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS | PAMAP_CHILD, psys->cfra); if (ptex->exist < PSYS_FRAND(i + 24)) return; if (ctx->vg_length) - ptex->length*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_length); + ptex->length *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_length); if (ctx->vg_clump) - ptex->clump*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump); + ptex->clump *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump); if (ctx->vg_kink) - ptex->kink*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink); + ptex->kink *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink); if (ctx->vg_rough1) - ptex->rough1*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1); + ptex->rough1 *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1); if (ctx->vg_rough2) - ptex->rough2*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2); + ptex->rough2 *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2); if (ctx->vg_roughe) - ptex->roughe*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe); + ptex->roughe *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe); if (ctx->vg_effector) - ptex->effector*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector); + ptex->effector *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector); } static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, float mat[4][4], ParticleKey *state, float t) { @@ -4004,17 +4004,17 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte if (part->flag & PART_CHILD_EFFECT) /* state is safe to cast, since only co and vel are used */ - guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t); + guided = do_guides(sim->psys->effectors, (ParticleKey *)state, cpa->parent, t); - if (guided==0) { + if (guided == 0) { float clump = do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); if (kink_freq != 0.f) { float kink_amp = part->kink_amp * (1.f - part->kink_amp_clump * clump); do_kink(state, par, par_rot, t, kink_freq, part->kink_shape, - kink_amp, part->kink_flat, part->kink, part->kink_axis, - sim->ob->obmat, sim->psys->part->childtype == PART_CHILD_FACES); + kink_amp, part->kink_flat, part->kink, part->kink_axis, + sim->ob->obmat, sim->psys->part->childtype == PART_CHILD_FACES); } } @@ -4037,7 +4037,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * ParticleData *pa; ChildParticle *cpa; ParticleTexture ptex; - ParticleKey *par=0, keys[4], tstate; + ParticleKey *par = 0, keys[4], tstate; ParticleThreadContext ctx; /* fake thread context for child modifiers */ ParticleInterpolationData pind; @@ -4054,12 +4054,12 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * float *cpa_fuv; int cpa_num; short cpa_from; /* initialize keys to zero */ - memset(keys, 0, 4*sizeof(ParticleKey)); + memset(keys, 0, 4 * sizeof(ParticleKey)); - t=state->time; + t = state->time; CLAMP(t, 0.0f, 1.0f); - if (ppathcache) { ParticleCacheKey result; @@ -4087,17 +4087,17 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * mul_mat3_m4_v3(sim->ob->obmat, state->vel); } else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) { - if ((pa->flag & PARS_REKEY)==0) { + if ((pa->flag & PARS_REKEY) == 0) { psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat); mul_m4_v3(hairmat, state->co); mul_mat3_m4_v3(hairmat, state->vel); - if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) { + if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) { do_guides(sim->psys->effectors, state, p, state->time); /* TODO: proper velocity handling */ } - if (psys->lattice && edit==0) + if (psys->lattice && edit == 0) calc_latt_deform(psys->lattice, state->co, 1.0f); } } @@ -4109,36 +4109,36 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* interpolate childcache directly if it exists */ if (psys->childcache) { ParticleCacheKey result; - interpolate_pathcache(psys->childcache[p-totpart], t, &result); + interpolate_pathcache(psys->childcache[p - totpart], t, &result); copy_v3_v3(state->co, result.co); copy_v3_v3(state->vel, result.vel); copy_qt_qt(state->rot, result.rot); } else { - cpa=psys->child+p-totpart; + cpa = psys->child + p - totpart; if (state->time < 0.0f) t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL); - if (totchild && part->childtype==PART_CHILD_FACES) { + if (totchild && part->childtype == PART_CHILD_FACES) { /* part->parents could still be 0 so we can't test with totparent */ - between=1; + between = 1; } if (between) { int w = 0; float foffset; /* get parent states */ - while (w<4 && cpa->pa[w]>=0) { + while (w < 4 && cpa->pa[w] >= 0) { keys[w].time = state->time; - psys_get_particle_on_path(sim, cpa->pa[w], keys+w, 1); + psys_get_particle_on_path(sim, cpa->pa[w], keys + w, 1); w++; } /* get the original coordinates (orco) for texture usage */ - cpa_num=cpa->num; + cpa_num = cpa->num; - foffset= cpa->foffset; + foffset = cpa->foffset; cpa_fuv = cpa->fuv; cpa_from = PART_FROM_FACE; @@ -4156,7 +4156,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * else unit_m4(hairmat); - pa=0; + pa = 0; } else { /* get the parent state */ @@ -4164,11 +4164,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * psys_get_particle_on_path(sim, cpa->parent, keys, 1); /* get the original coordinates (orco) for texture usage */ - pa=psys->particles+cpa->parent; + pa = psys->particles + cpa->parent; - cpa_from=part->from; - cpa_num=pa->num; - cpa_fuv=pa->fuv; + cpa_from = part->from; + cpa_num = pa->num; + cpa_fuv = pa->fuv; @@ -4184,8 +4184,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* correct child ipo timing */ #if 0 // XXX old animation system - if ((part->flag&PART_ABS_TIME)==0 && part->ipo) { - calc_ipo(part->ipo, 100.0f*t); + if ((part->flag & PART_ABS_TIME) == 0 && part->ipo) { + calc_ipo(part->ipo, 100.0f * t); execute_ipo((ID *)part, part->ipo); } #endif // XXX old animation system @@ -4199,13 +4199,13 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * get_child_modifier_parameters(part, &ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex); if (between) { - int w=0; + int w = 0; state->co[0] = state->co[1] = state->co[2] = 0.0f; state->vel[0] = state->vel[1] = state->vel[2] = 0.0f; /* child position is the weighted sum of parent positions */ - while (w<4 && cpa->pa[w]>=0) { + while (w < 4 && cpa->pa[w] >= 0) { state->co[0] += cpa->w[w] * keys[w].co[0]; state->co[1] += cpa->w[w] * keys[w].co[1]; state->co[2] += cpa->w[w] * keys[w].co[2]; @@ -4236,14 +4236,14 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * ParticleKey tstate; float length = len_v3(state->vel); - if (t>=0.001f) { - tstate.time=t-0.001f; + if (t >= 0.001f) { + tstate.time = t - 0.001f; psys_get_particle_on_path(sim, p, &tstate, 0); sub_v3_v3v3(state->vel, state->co, tstate.co); normalize_v3(state->vel); } else { - tstate.time=t+0.001f; + tstate.time = t + 0.001f; psys_get_particle_on_path(sim, p, &tstate, 0); sub_v3_v3v3(state->vel, tstate.co, state->co); normalize_v3(state->vel); @@ -4268,7 +4268,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta /* negative time means "use current time" */ cfra = state->time > 0 ? state->time : BKE_scene_frame_get(sim->scene); - if (p>=totpart) { + if (p >= totpart) { if (!psys->totchild) return 0; @@ -4288,7 +4288,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } } - state->time= (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); + state->time = (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); psys_get_particle_on_path(sim, p, state, 1); return 1; @@ -4315,7 +4315,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } if (sim->psys->flag & PSYS_KEYED) { - state->time= -cfra; + state->time = -cfra; psys_get_particle_on_path(sim, p, state, 1); return 1; } @@ -4325,7 +4325,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta ParticleKey *key1; float t = (cfra - pa->time) / pa->lifetime; - key1=&pa->state; + key1 = &pa->state; offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); CLAMP(t, 0.0f, 1.0f); @@ -4337,9 +4337,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta calc_latt_deform(sim->psys->lattice, state->co, 1.0f); } else { - if (pa->state.time==cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) + if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) copy_particle_key(state, &pa->state, 1); - else if (pa->prev_state.time==cfra) + else if (pa->prev_state.time == cfra) copy_particle_key(state, &pa->prev_state, 1); else { float dfra, frs_sec = sim->scene->r.frs_sec; @@ -4351,14 +4351,14 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta copy_particle_key(state, &pa->state, 1); - madd_v3_v3v3fl(state->co, state->co, state->vel, dfra/frs_sec); + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); } else { ParticleKey keys[4]; float keytime; - copy_particle_key(keys+1, &pa->prev_state, 1); - copy_particle_key(keys+2, &pa->state, 1); + copy_particle_key(keys + 1, &pa->prev_state, 1); + copy_particle_key(keys + 2, &pa->state, 1); dfra = keys[2].time - keys[1].time; @@ -4384,7 +4384,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta copy_particle_key(state, &pa->state, 1); - madd_v3_v3v3fl(state->co, state->co, state->vel, dfra/frs_sec); + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); } else { /* extrapolating over big ranges is not accurate so let's just give something close to reasonable back */ @@ -4411,9 +4411,9 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic if (cpa) { if (part->childtype == PART_CHILD_FACES) { - mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); + mtface = CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); if (mtface) { - mface= psmd->dm->getTessFaceData(psmd->dm, cpa->num, CD_MFACE); + mface = psmd->dm->getTessFaceData(psmd->dm, cpa->num, CD_MFACE); mtface += cpa->num; psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv); } @@ -4427,20 +4427,20 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic } if (part->from == PART_FROM_FACE) { - mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); - num= pa->num_dmcache; + mtface = CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); + num = pa->num_dmcache; if (num == DMCACHE_NOTFOUND) - num= pa->num; + num = pa->num; if (num >= psmd->dm->getNumTessFaces(psmd->dm)) { /* happens when simplify is enabled * gives invalid coords but would crash otherwise */ - num= DMCACHE_NOTFOUND; + num = DMCACHE_NOTFOUND; } if (mtface && num != DMCACHE_NOTFOUND) { - mface= psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE); + mface = psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE); mtface += num; psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv); } @@ -4457,8 +4457,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float loc[3], nor[3], vec[3], side[3], len; float xvec[3] = {-1.0, 0.0, 0.0}, nmat[3][3]; - sub_v3_v3v3(vec, (cache+cache->steps)->co, cache->co); - len= normalize_v3(vec); + sub_v3_v3v3(vec, (cache + cache->steps)->co, cache->co); + len = normalize_v3(vec); if (pa == NULL && psys->part->childflat != PART_CHILD_FACES) pa = psys->particles + cpa->pa[0]; @@ -4475,8 +4475,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa normalize_v3(nor); /* make sure that we get a proper side vector */ - if (fabs(dot_v3v3(nor, vec))>0.999999) { - if (fabs(dot_v3v3(nor, xvec))>0.999999) { + if (fabs(dot_v3v3(nor, vec)) > 0.999999) { + if (fabs(dot_v3v3(nor, xvec)) > 0.999999) { nor[0] = 0.0f; nor[1] = 1.0f; nor[2] = 0.0f; @@ -4495,8 +4495,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float q_phase[4]; float phasefac = psys->part->phasefac; if (psys->part->randphasefac != 0.0f) - phasefac += psys->part->randphasefac * PSYS_FRAND((pa-psys->particles) + 20); - axis_angle_to_quat(q_phase, vec, phasefac*(float)M_PI); + phasefac += psys->part->randphasefac * PSYS_FRAND((pa - psys->particles) + 20); + axis_angle_to_quat(q_phase, vec, phasefac * (float)M_PI); mul_qt_v3(q_phase, side); } @@ -4512,7 +4512,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa quat_to_mat4(mat, pa->state.rot); } - *scale= len; + *scale = len; } void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]) @@ -4525,7 +4525,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] /* can happen with bad pointcache or physics calculation * since this becomes geometry, nan's and inf's crash raytrace code. * better not allow this. */ - if ( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || + if (!finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) ) { zero_v3(bb->vec); @@ -4540,7 +4540,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] } if (bb->align < PART_BB_VIEW) - onevec[bb->align]=1.0f; + onevec[bb->align] = 1.0f; if (bb->lock && (bb->align == PART_BB_VIEW)) { normalize_v3_v3(xvec, bb->ob->obmat[0]); @@ -4601,11 +4601,11 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) { - ParticleSimulationData sim= {0}; - sim.scene= scene; - sim.ob= ob; - sim.psys= psys; - sim.psmd= psys_get_modifier(ob, psys); + ParticleSimulationData sim = {0}; + sim.scene = scene; + sim.ob = ob; + sim.psys = psys; + sim.psmd = psys_get_modifier(ob, psys); psys->lattice = psys_get_lattice(&sim); @@ -4615,12 +4615,12 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) int p, h; float hairmat[4][4], imat[4][4]; - for (p=0; ptotpart; p++, pa++) { + for (p = 0; p < psys->totpart; p++, pa++) { psys_mat_hair_to_global(sim.ob, sim.psmd->dm, psys->part->from, pa, hairmat); invert_m4_m4(imat, hairmat); hkey = pa->hair; - for (h=0; htotkey; h++, hkey++) { + for (h = 0; h < pa->totkey; h++, hkey++) { mul_m4_v3(hairmat, hkey->co); calc_latt_deform(psys->lattice, hkey->co, 1.0f); mul_m4_v3(imat, hkey->co); @@ -4628,7 +4628,7 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) } end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; /* protect the applied shape */ psys->flag |= PSYS_EDITED; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 37d7cc06fe7..968f49357e6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -118,20 +118,20 @@ Scene *BKE_scene_copy(Scene *sce, int type) if (type == SCE_COPY_EMPTY) { ListBase lb; - scen= BKE_scene_add(sce->id.name+2); + scen = BKE_scene_add(sce->id.name + 2); - lb= scen->r.layers; - scen->r= sce->r; - scen->r.layers= lb; - scen->unit= sce->unit; - scen->physics_settings= sce->physics_settings; - scen->gm= sce->gm; - scen->audio= sce->audio; + lb = scen->r.layers; + scen->r = sce->r; + scen->r.layers = lb; + scen->unit = sce->unit; + scen->physics_settings = sce->physics_settings; + scen->gm = sce->gm; + scen->audio = sce->audio; MEM_freeN(scen->toolsettings); } else { - scen= BKE_libblock_copy(&sce->id); + scen = BKE_libblock_copy(&sce->id); BLI_duplicatelist(&(scen->base), &(sce->base)); clear_id_newpoins(); @@ -140,11 +140,11 @@ Scene *BKE_scene_copy(Scene *sce, int type) id_us_plus((ID *)scen->set); id_us_plus((ID *)scen->gm.dome.warptext); - scen->ed= NULL; - scen->theDag= NULL; - scen->obedit= NULL; - scen->stats= NULL; - scen->fps_info= NULL; + scen->ed = NULL; + scen->theDag = NULL; + scen->obedit = NULL; + scen->stats = NULL; + scen->fps_info = NULL; BLI_duplicatelist(&(scen->markers), &(sce->markers)); BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces)); @@ -152,48 +152,48 @@ Scene *BKE_scene_copy(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if (sce->nodetree) { - scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */ + scen->nodetree = ntreeCopyTree(sce->nodetree); /* copies actions */ ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } - obase= sce->base.first; - base= scen->base.first; + obase = sce->base.first; + base = scen->base.first; while (base) { id_us_plus(&base->object->id); - if (obase==sce->basact) scen->basact= base; + if (obase == sce->basact) scen->basact = base; - obase= obase->next; - base= base->next; + obase = obase->next; + base = base->next; } } /* tool settings */ - scen->toolsettings= MEM_dupallocN(sce->toolsettings); + scen->toolsettings = MEM_dupallocN(sce->toolsettings); - ts= scen->toolsettings; + ts = scen->toolsettings; if (ts) { if (ts->vpaint) { - ts->vpaint= MEM_dupallocN(ts->vpaint); - ts->vpaint->paintcursor= NULL; - ts->vpaint->vpaint_prev= NULL; - ts->vpaint->wpaint_prev= NULL; + ts->vpaint = MEM_dupallocN(ts->vpaint); + ts->vpaint->paintcursor = NULL; + ts->vpaint->vpaint_prev = NULL; + ts->vpaint->wpaint_prev = NULL; copy_paint(&ts->vpaint->paint, &ts->vpaint->paint); } if (ts->wpaint) { - ts->wpaint= MEM_dupallocN(ts->wpaint); - ts->wpaint->paintcursor= NULL; - ts->wpaint->vpaint_prev= NULL; - ts->wpaint->wpaint_prev= NULL; + ts->wpaint = MEM_dupallocN(ts->wpaint); + ts->wpaint->paintcursor = NULL; + ts->wpaint->vpaint_prev = NULL; + ts->wpaint->wpaint_prev = NULL; copy_paint(&ts->wpaint->paint, &ts->wpaint->paint); } if (ts->sculpt) { - ts->sculpt= MEM_dupallocN(ts->sculpt); + ts->sculpt = MEM_dupallocN(ts->sculpt); copy_paint(&ts->sculpt->paint, &ts->sculpt->paint); } copy_paint(&ts->imapaint.paint, &ts->imapaint.paint); - ts->imapaint.paintcursor= NULL; - ts->particle.paintcursor= NULL; + ts->imapaint.paintcursor = NULL; + ts->particle.paintcursor = NULL; } /* make a private copy of the avicodecdata */ @@ -210,7 +210,7 @@ Scene *BKE_scene_copy(Scene *sce, int type) } if (sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */ - scen->r.ffcodecdata.properties= IDP_CopyProperty(sce->r.ffcodecdata.properties); + scen->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties); } /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations @@ -229,13 +229,13 @@ Scene *BKE_scene_copy(Scene *sce, int type) BKE_copy_animdata_id_action((ID *)scen); if (scen->world) { id_us_plus((ID *)scen->world); - scen->world= BKE_world_copy(scen->world); + scen->world = BKE_world_copy(scen->world); BKE_copy_animdata_id_action((ID *)scen->world); } if (sce->ed) { - scen->ed= MEM_callocN(sizeof(Editing), "addseq"); - scen->ed->seqbasep= &scen->ed->seqbase; + scen->ed = MEM_callocN(sizeof(Editing), "addseq"); + scen->ed->seqbasep = &scen->ed->seqbase; seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); } } @@ -248,10 +248,10 @@ void BKE_scene_free(Scene *sce) { Base *base; - base= sce->base.first; + base = sce->base.first; while (base) { base->object->id.us--; - base= base->next; + base = base->next; } /* do not free objects! */ @@ -262,7 +262,7 @@ void BKE_scene_free(Scene *sce) // its probably safe not to do this, some save and reload will free this. sce->gpd->id.us--; #endif - sce->gpd= NULL; + sce->gpd = NULL; } BLI_freelistN(&sce->base); @@ -334,74 +334,74 @@ void BKE_scene_free(Scene *sce) Scene *BKE_scene_add(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Scene *sce; ParticleEditSettings *pset; int a; - sce= BKE_libblock_alloc(&bmain->scene, ID_SCE, name); - sce->lay= sce->layact= 1; + 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; - sce->r.cfra= 1; - sce->r.sfra= 1; - sce->r.efra= 250; - sce->r.frame_step= 1; - sce->r.xsch= 1920; - sce->r.ysch= 1080; - sce->r.xasp= 1; - sce->r.yasp= 1; - sce->r.xparts= 8; - sce->r.yparts= 8; - sce->r.mblur_samples= 1; - sce->r.filtertype= R_FILTER_MITCH; - sce->r.size= 50; + sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE; + sce->r.cfra = 1; + sce->r.sfra = 1; + sce->r.efra = 250; + sce->r.frame_step = 1; + sce->r.xsch = 1920; + sce->r.ysch = 1080; + sce->r.xasp = 1; + sce->r.yasp = 1; + sce->r.xparts = 8; + sce->r.yparts = 8; + sce->r.mblur_samples = 1; + sce->r.filtertype = R_FILTER_MITCH; + sce->r.size = 50; - sce->r.im_format.planes= R_IMF_PLANES_RGB; - sce->r.im_format.imtype= R_IMF_IMTYPE_PNG; - sce->r.im_format.quality= 90; + sce->r.im_format.planes = R_IMF_PLANES_RGB; + sce->r.im_format.imtype = R_IMF_IMTYPE_PNG; + sce->r.im_format.quality = 90; - sce->r.displaymode= R_OUTPUT_AREA; - sce->r.framapto= 100; - sce->r.images= 100; - sce->r.framelen= 1.0; - sce->r.blurfac= 0.5; - sce->r.frs_sec= 24; - sce->r.frs_sec_base= 1; - sce->r.edgeint= 10; + sce->r.displaymode = R_OUTPUT_AREA; + sce->r.framapto = 100; + sce->r.images = 100; + sce->r.framelen = 1.0; + sce->r.blurfac = 0.5; + sce->r.frs_sec = 24; + sce->r.frs_sec_base = 1; + sce->r.edgeint = 10; sce->r.ocres = 128; sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; - sce->r.gauss= 1.0; + sce->r.gauss = 1.0; /* deprecated but keep for upwards compat */ - sce->r.postgamma= 1.0; - sce->r.posthue= 0.0; - sce->r.postsat= 1.0; - - 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; - sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT; - sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; - sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_FILENAME|R_STAMP_RENDERTIME; - sce->r.stamp_font_id= 12; - sce->r.fg_stamp[0]= sce->r.fg_stamp[1]= sce->r.fg_stamp[2]= 0.8f; - sce->r.fg_stamp[3]= 1.0f; - sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f; - sce->r.bg_stamp[3]= 0.25f; + sce->r.postgamma = 1.0; + sce->r.posthue = 0.0; + sce->r.postsat = 1.0; + + 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; + sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT; + sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION; + sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME; + sce->r.stamp_font_id = 12; + sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; + sce->r.fg_stamp[3] = 1.0f; + sce->r.bg_stamp[0] = sce->r.bg_stamp[1] = sce->r.bg_stamp[2] = 0.0f; + sce->r.bg_stamp[3] = 0.25f; sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES; - sce->r.seq_prev_type= OB_SOLID; - sce->r.seq_rend_type= OB_SOLID; - sce->r.seq_flag= R_SEQ_GL_PREV; + sce->r.seq_prev_type = OB_SOLID; + sce->r.seq_rend_type = OB_SOLID; + sce->r.seq_flag = R_SEQ_GL_PREV; - sce->r.threads= 1; + sce->r.threads = 1; - sce->r.simplify_subsurf= 6; - sce->r.simplify_particles= 1.0f; - sce->r.simplify_shadowsamples= 16; - sce->r.simplify_aosss= 1.0f; + sce->r.simplify_subsurf = 6; + sce->r.simplify_particles = 1.0f; + sce->r.simplify_shadowsamples = 16; + sce->r.simplify_aosss = 1.0f; sce->r.border.xmin = 0.0f; sce->r.border.ymin = 0.0f; @@ -409,7 +409,7 @@ Scene *BKE_scene_add(const char *name) sce->r.border.ymax = 1.0f; sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); - sce->toolsettings->cornertype=1; + sce->toolsettings->cornertype = 1; sce->toolsettings->degr = 90; sce->toolsettings->step = 9; sce->toolsettings->turn = 1; @@ -423,25 +423,25 @@ Scene *BKE_scene_add(const char *name) sce->toolsettings->uvcalc_mapdir = 1; sce->toolsettings->uvcalc_mapalign = 1; sce->toolsettings->unwrapper = 1; - sce->toolsettings->select_thresh= 0.01f; + sce->toolsettings->select_thresh = 0.01f; sce->toolsettings->jointrilimit = 0.8f; - sce->toolsettings->selectmode= SCE_SELECT_VERTEX; - sce->toolsettings->uv_selectmode= UV_SELECT_VERTEX; - sce->toolsettings->normalsize= 0.1; - sce->toolsettings->autokey_mode= U.autokey_mode; + sce->toolsettings->selectmode = SCE_SELECT_VERTEX; + sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX; + sce->toolsettings->normalsize = 0.1; + sce->toolsettings->autokey_mode = U.autokey_mode; sce->toolsettings->skgen_resolution = 100; - sce->toolsettings->skgen_threshold_internal = 0.01f; - sce->toolsettings->skgen_threshold_external = 0.01f; - sce->toolsettings->skgen_angle_limit = 45.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_threshold_internal = 0.01f; + sce->toolsettings->skgen_threshold_external = 0.01f; + sce->toolsettings->skgen_angle_limit = 45.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 = 1; - sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_HARMONIC|SKGEN_SUB_CORRELATION|SKGEN_STICK_TO_EMBEDDING; + sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL | SKGEN_FILTER_EXTERNAL | SKGEN_FILTER_SMART | SKGEN_HARMONIC | SKGEN_SUB_CORRELATION | SKGEN_STICK_TO_EMBEDDING; sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; @@ -455,22 +455,22 @@ Scene *BKE_scene_add(const char *name) sce->unit.scale_length = 1.0f; - pset= &sce->toolsettings->particle; - pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER|PE_AUTO_VELOCITY; - pset->emitterdist= 0.25f; - pset->totrekey= 5; - pset->totaddkey= 5; - pset->brushtype= PE_BRUSH_NONE; - pset->draw_step= 2; - pset->fade_frames= 2; - pset->selectmode= SCE_SELECT_PATH; - for (a=0; abrush[a].strength= 0.5; - pset->brush[a].size= 50; - pset->brush[a].step= 10; - pset->brush[a].count= 10; + pset = &sce->toolsettings->particle; + pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER | PE_AUTO_VELOCITY; + pset->emitterdist = 0.25f; + pset->totrekey = 5; + pset->totaddkey = 5; + pset->brushtype = PE_BRUSH_NONE; + pset->draw_step = 2; + pset->fade_frames = 2; + pset->selectmode = SCE_SELECT_PATH; + for (a = 0; a < PE_TOT_BRUSH; a++) { + pset->brush[a].strength = 0.5; + pset->brush[a].size = 50; + pset->brush[a].step = 10; + pset->brush[a].count = 10; } - pset->brush[PE_BRUSH_CUT].strength= 100; + pset->brush[PE_BRUSH_CUT].strength = 100; sce->r.ffcodecdata.audio_mixrate = 44100; sce->r.ffcodecdata.audio_volume = 1.0f; @@ -487,7 +487,7 @@ Scene *BKE_scene_add(const char *name) BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); - sce->r.osa= 8; + 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 */ BKE_scene_add_render_layer(sce, NULL); @@ -503,13 +503,13 @@ Scene *BKE_scene_add(const char *name) sce->gm.dome.resbuf = 1.0f; sce->gm.dome.tilt = 0; - sce->gm.xplay= 640; - sce->gm.yplay= 480; - sce->gm.freqplay= 60; - sce->gm.depth= 32; + sce->gm.xplay = 640; + sce->gm.yplay = 480; + sce->gm.freqplay = 60; + sce->gm.depth = 32; - sce->gm.gravity= 9.8f; - sce->gm.physicsEngine= WOPHY_BULLET; + sce->gm.gravity = 9.8f; + sce->gm.physicsEngine = WOPHY_BULLET; sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling sce->gm.occlusionRes = 128; sce->gm.ticrate = 60; @@ -520,12 +520,12 @@ Scene *BKE_scene_add(const char *name) sce->gm.flag = GAME_DISPLAY_LISTS; sce->gm.matmode = GAME_MAT_MULTITEX; - sce->gm.obstacleSimulation= OBSTSIMULATION_NONE; + sce->gm.obstacleSimulation = OBSTSIMULATION_NONE; sce->gm.levelHeight = 2.f; sce->gm.recastData.cellsize = 0.3f; sce->gm.recastData.cellheight = 0.2f; - sce->gm.recastData.agentmaxslope = M_PI/2; + sce->gm.recastData.agentmaxslope = M_PI / 2; sce->gm.recastData.agentmaxclimb = 0.9f; sce->gm.recastData.agentheight = 2.0f; sce->gm.recastData.agentradius = 0.6f; @@ -548,10 +548,10 @@ Base *BKE_scene_base_find(Scene *scene, Object *ob) { Base *base; - base= scene->base.first; + base = scene->base.first; while (base) { if (base->object == ob) return base; - base= base->next; + base = base->next; } return NULL; } @@ -570,18 +570,18 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) /* can happen when switching modes in other scenes */ if (scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT)) - scene->obedit= NULL; + scene->obedit = NULL; /* deselect objects (for dataselect) */ - for (ob= bmain->object.first; ob; ob= ob->id.next) - ob->flag &= ~(SELECT|OB_FROMGROUP); + for (ob = bmain->object.first; ob; ob = ob->id.next) + ob->flag &= ~(SELECT | OB_FROMGROUP); /* group flags again */ - for (group= bmain->group.first; group; group= group->id.next) { - go= group->gobject.first; + for (group = bmain->group.first; group; group = group->id.next) { + go = group->gobject.first; while (go) { if (go->ob) go->ob->flag |= OB_FROMGROUP; - go= go->next; + go = go->next; } } @@ -589,25 +589,25 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) DAG_scene_sort(bmain, scene); /* ensure dags are built for sets */ - for (sce= scene->set; sce; sce= sce->set) - if (sce->theDag==NULL) + for (sce = scene->set; sce; sce = sce->set) + if (sce->theDag == NULL) DAG_scene_sort(bmain, sce); /* copy layers and flags from bases to objects */ - for (base= scene->base.first; base; base= base->next) { - ob= base->object; - ob->lay= base->lay; + for (base = scene->base.first; base; base = base->next) { + ob = base->object; + ob->lay = base->lay; /* group patch... */ base->flag &= ~(OB_FROMGROUP); - flag= ob->flag & (OB_FROMGROUP); + flag = ob->flag & (OB_FROMGROUP); base->flag |= flag; /* not too nice... for recovering objects with lost data */ //if (ob->pose==NULL) base->flag &= ~OB_POSEMODE; - ob->flag= base->flag; + ob->flag = base->flag; - ob->ctime= -1234567.0; /* force ipo to be calculated later */ + ob->ctime = -1234567.0; /* force ipo to be calculated later */ } /* no full animation update, this to enable render code to work (render code calls own animation updates) */ } @@ -632,9 +632,9 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce) bScreen *sc; /* check all sets */ - for (sce1= bmain->scene.first; sce1; sce1= sce1->id.next) + for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next) if (sce1->set == sce) - sce1->set= NULL; + sce1->set = NULL; /* check all sequences */ clear_scene_in_allseqs(bmain, sce); @@ -643,9 +643,9 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce) clear_scene_in_nodes(bmain, sce); /* al screens */ - for (sc= bmain->screen.first; sc; sc= sc->id.next) + for (sc = bmain->screen.first; sc; sc = sc->id.next) if (sc->scene == sce) - sc->scene= newsce; + sc->scene = newsce; BKE_libblock_free(&bmain->scene, sce); } @@ -655,15 +655,15 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce) */ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) { - static ListBase *duplilist= NULL; + static ListBase *duplilist = NULL; static DupliObject *dupob; - static int fase= F_START, in_next_object= 0; - int run_again=1; + static int fase = F_START, in_next_object = 0; + int run_again = 1; /* init */ - if (val==0) { - fase= F_START; - dupob= NULL; + if (val == 0) { + fase = F_START; + dupob = NULL; /* XXX particle systems with metas+dupligroups call this recursively */ /* see bug #18725 */ @@ -674,44 +674,44 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) } } else { - in_next_object= 1; + in_next_object = 1; /* run_again is set when a duplilist has been ended */ while (run_again) { - run_again= 0; + run_again = 0; /* the first base */ - if (fase==F_START) { - *base= (*scene)->base.first; + if (fase == F_START) { + *base = (*scene)->base.first; if (*base) { - *ob= (*base)->object; - fase= F_SCENE; + *ob = (*base)->object; + fase = F_SCENE; } else { /* exception: empty scene */ while ((*scene)->set) { - (*scene)= (*scene)->set; + (*scene) = (*scene)->set; if ((*scene)->base.first) { - *base= (*scene)->base.first; - *ob= (*base)->object; - fase= F_SCENE; + *base = (*scene)->base.first; + *ob = (*base)->object; + fase = F_SCENE; break; } } } } else { - if (*base && fase!=F_DUPLI) { - *base= (*base)->next; - if (*base) *ob= (*base)->object; + if (*base && fase != F_DUPLI) { + *base = (*base)->next; + if (*base) *ob = (*base)->object; else { - if (fase==F_SCENE) { + if (fase == F_SCENE) { /* (*scene) is finished, now do the set */ while ((*scene)->set) { - (*scene)= (*scene)->set; + (*scene) = (*scene)->set; if ((*scene)->base.first) { - *base= (*scene)->base.first; - *ob= (*base)->object; + *base = (*scene)->base.first; + *ob = (*base)->object; break; } } @@ -720,17 +720,17 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) } } - if (*base == NULL) fase= F_START; + if (*base == NULL) fase = F_START; else { - if (fase!=F_DUPLI) { + if (fase != F_DUPLI) { if ( (*base)->object->transflag & OB_DUPLI) { /* groups cannot be duplicated for mballs yet, * this enters eternal loop because of * makeDispListMBall getting called inside of group_duplilist */ if ((*base)->object->dup_group == NULL) { - duplilist= object_duplilist((*scene), (*base)->object); + duplilist = object_duplilist((*scene), (*base)->object); - dupob= duplilist->first; + dupob = duplilist->first; if (!dupob) free_object_duplilist(duplilist); @@ -743,22 +743,22 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) copy_m4_m4(dupob->ob->obmat, dupob->mat); (*base)->flag |= OB_FROMDUPLI; - *ob= dupob->ob; - fase= F_DUPLI; + *ob = dupob->ob; + fase = F_DUPLI; - dupob= dupob->next; + dupob = dupob->next; } - else if (fase==F_DUPLI) { - fase= F_SCENE; + else if (fase == F_DUPLI) { + fase = F_SCENE; (*base)->flag &= ~OB_FROMDUPLI; - for (dupob= duplilist->first; dupob; dupob= dupob->next) { + for (dupob = duplilist->first; dupob; dupob = dupob->next) { copy_m4_m4(dupob->ob->obmat, dupob->omat); } free_object_duplilist(duplilist); - duplilist= NULL; - run_again= 1; + duplilist = NULL; + run_again = 1; } } } @@ -766,12 +766,12 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) #if 0 if (ob && *ob) { - printf("Scene: '%s', '%s'\n", (*scene)->id.name+2, (*ob)->id.name+2); + printf("Scene: '%s', '%s'\n", (*scene)->id.name + 2, (*ob)->id.name + 2); } #endif /* reset recursion test */ - in_next_object= 0; + in_next_object = 0; return fase; } @@ -780,8 +780,8 @@ Object *BKE_scene_camera_find(Scene *sc) { Base *base; - for (base= sc->base.first; base; base= base->next) - if (base->object->type==OB_CAMERA) + for (base = sc->base.first; base; base = base->next) + if (base->object->type == OB_CAMERA) return base->object; return NULL; @@ -793,12 +793,12 @@ Object *BKE_scene_camera_switch_find(Scene *scene) TimeMarker *m; int cfra = scene->r.cfra; int frame = -(MAXFRAME + 1); - Object *camera= NULL; + Object *camera = NULL; - for (m= scene->markers.first; m; m= m->next) { - if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) { - camera= m->camera; - frame= m->frame; + for (m = scene->markers.first; m; m = m->next) { + if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0 && (m->frame <= cfra) && (m->frame > frame)) { + camera = m->camera; + frame = m->frame; if (frame == cfra) break; @@ -812,9 +812,9 @@ Object *BKE_scene_camera_switch_find(Scene *scene) int BKE_scene_camera_switch_update(Scene *scene) { #ifdef DURIAN_CAMERA_SWITCH - Object *camera= BKE_scene_camera_switch_find(scene); + Object *camera = BKE_scene_camera_switch_find(scene); if (camera) { - scene->camera= camera; + scene->camera = camera; return 1; } #else @@ -825,18 +825,18 @@ int BKE_scene_camera_switch_update(Scene *scene) char *BKE_scene_find_marker_name(Scene *scene, int frame) { - ListBase *markers= &scene->markers; + ListBase *markers = &scene->markers; TimeMarker *m1, *m2; /* search through markers for match */ - for (m1=markers->first, m2=markers->last; m1 && m2; m1=m1->next, m2=m2->prev) { - if (m1->frame==frame) + for (m1 = markers->first, m2 = markers->last; m1 && m2; m1 = m1->next, m2 = m2->prev) { + if (m1->frame == frame) return m1->name; if (m1 == m2) break; - if (m2->frame==frame) + if (m2->frame == frame) return m2->name; } @@ -848,13 +848,13 @@ char *BKE_scene_find_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; - for (marker= scene->markers.first; marker; marker= marker->next) { - if (marker->frame==frame) { + int best_frame = -MAXFRAME * 2; + for (marker = scene->markers.first; marker; marker = marker->next) { + if (marker->frame == frame) { return marker->name; } - if ( marker->frame > best_frame && marker->frame < frame) { + if (marker->frame > best_frame && marker->frame < frame) { best_marker = marker; best_frame = marker->frame; } @@ -866,12 +866,12 @@ char *BKE_scene_find_last_marker_name(Scene *scene, int frame) Base *BKE_scene_base_add(Scene *sce, Object *ob) { - Base *b= MEM_callocN(sizeof(*b), "BKE_scene_base_add"); + Base *b = MEM_callocN(sizeof(*b), "BKE_scene_base_add"); BLI_addhead(&sce->base, b); - b->object= ob; - b->flag= ob->flag; - b->lay= ob->lay; + b->object = ob; + b->flag = ob->flag; + b->lay = ob->lay; return b; } @@ -880,18 +880,18 @@ void BKE_scene_base_deselect_all(Scene *sce) { Base *b; - for (b= sce->base.first; b; b= b->next) { - b->flag&= ~SELECT; - b->object->flag= b->flag; + for (b = sce->base.first; b; b = b->next) { + b->flag &= ~SELECT; + b->object->flag = b->flag; } } void BKE_scene_base_select(Scene *sce, Base *selbase) { selbase->flag |= SELECT; - selbase->object->flag= selbase->flag; + selbase->object->flag = selbase->flag; - sce->basact= selbase; + sce->basact = selbase; } /* checks for cycle, returns 1 if it's all OK */ @@ -900,17 +900,17 @@ int BKE_scene_validate_setscene(Main *bmain, Scene *sce) Scene *scene; int a, totscene; - if (sce->set==NULL) return 1; + if (sce->set == NULL) return 1; - totscene= 0; - for (scene= bmain->scene.first; scene; scene= scene->id.next) + totscene = 0; + for (scene = bmain->scene.first; scene; scene = scene->id.next) totscene++; - for (a=0, scene=sce; scene->set; scene=scene->set, a++) { + for (a = 0, scene = sce; scene->set; scene = scene->set, a++) { /* more iterations than scenes means we have a cycle */ if (a > totscene) { /* the tested scene gets zero'ed, that's typically current scene */ - sce->set= NULL; + sce->set = NULL; return 0; } } @@ -937,7 +937,7 @@ float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame) } /* drivers support/hacks - * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render + * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render * - these are always run since the depsgraph can't handle non-object data * - these happen after objects are all done so that we can read in their final transform values, * though this means that objects can't refer to scene info for guidance... @@ -955,7 +955,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) // TODO: what about world textures? but then those have nodes too... if (scene->world) { ID *wid = (ID *)scene->world; - AnimData *adt= BKE_animdata_from_id(wid); + AnimData *adt = BKE_animdata_from_id(wid); if (adt && adt->drivers.first) BKE_animsys_evaluate_animdata(scene, wid, adt, ctime, ADT_RECALC_DRIVERS); @@ -964,7 +964,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) /* nodes */ if (scene->nodetree) { ID *nid = (ID *)scene->nodetree; - AnimData *adt= BKE_animdata_from_id(nid); + AnimData *adt = BKE_animdata_from_id(nid); if (adt && adt->drivers.first) BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, ADT_RECALC_DRIVERS); @@ -976,7 +976,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen Base *base; - scene->customdata_mask= scene_parent->customdata_mask; + scene->customdata_mask = scene_parent->customdata_mask; /* sets first, we allow per definition current scene to have * dependencies on sets, but not the other way around. */ @@ -984,8 +984,8 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen scene_update_tagged_recursive(bmain, scene->set, scene_parent); /* scene objects */ - for (base= scene->base.first; base; base= base->next) { - Object *ob= base->object; + for (base = scene->base.first; base; base = base->next) { + Object *ob = base->object; BKE_object_handle_update(scene_parent, ob); @@ -993,7 +993,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); /* always update layer, so that animating layers works */ - base->lay= ob->lay; + base->lay = ob->lay; } /* scene drivers... */ @@ -1012,7 +1012,7 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene) /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); - scene->physics_settings.quick_cache_step= 0; + scene->physics_settings.quick_cache_step = 0; /* update all objects: drivers, matrices, displists, etc. flags set * by depgraph or manual, no layer check here, gets correct flushed @@ -1023,7 +1023,7 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene) /* extra call here to recalc scene animation (for sequencer) */ { - AnimData *adt= BKE_animdata_from_id(&scene->id); + AnimData *adt = BKE_animdata_from_id(&scene->id); float ctime = BKE_scene_frame_get(scene); if (adt && (adt->recalc & ADT_RECALC_ANIM)) @@ -1057,8 +1057,8 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* clear animation overrides */ // XXX TODO... - for (sce_iter= sce; sce_iter; sce_iter= sce_iter->set) { - if (sce_iter->theDag==NULL) + for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) { + if (sce_iter->theDag == NULL) DAG_scene_sort(bmain, sce_iter); } @@ -1099,24 +1099,24 @@ SceneRenderLayer *BKE_scene_add_render_layer(Scene *sce, const char *name) SceneRenderLayer *srl; if (!name) - name= "RenderLayer"; + name = "RenderLayer"; - srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer"); + srl = MEM_callocN(sizeof(SceneRenderLayer), "new render layer"); BLI_strncpy(srl->name, name, sizeof(srl->name)); BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(srl->name)); BLI_addtail(&sce->r.layers, srl); /* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */ - srl->lay= (1<<20) -1; - srl->layflag= 0x7FFF; /* solid ztra halo edge strand */ - srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z; + srl->lay = (1 << 20) - 1; + srl->layflag = 0x7FFF; /* solid ztra halo edge strand */ + srl->passflag = SCE_PASS_COMBINED | SCE_PASS_Z; return srl; } int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl) { - const int act= BLI_findindex(&scene->r.layers, srl); + const int act = BLI_findindex(&scene->r.layers, srl); Scene *sce; if (act == -1) { @@ -1132,16 +1132,16 @@ int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *s BLI_remlink(&scene->r.layers, srl); MEM_freeN(srl); - scene->r.actlay= 0; + scene->r.actlay = 0; for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; for (node = sce->nodetree->nodes.first; node; node = node->next) { - if (node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) { - if (node->custom1==act) - node->custom1= 0; - else if (node->custom1>act) + if (node->type == CMP_NODE_R_LAYERS && (Scene *)node->id == scene) { + if (node->custom1 == act) + node->custom1 = 0; + else if (node->custom1 > act) node->custom1--; } } @@ -1164,7 +1164,7 @@ int get_render_subsurf_level(RenderData *r, int lvl) int get_render_child_particle_number(RenderData *r, int num) { if (r->mode & R_SIMPLIFY) - return (int)(r->simplify_particles*num); + return (int)(r->simplify_particles * num); else return num; } @@ -1180,7 +1180,7 @@ int get_render_shadow_samples(RenderData *r, int samples) float get_render_aosss_error(RenderData *r, float error) { if (r->mode & R_SIMPLIFY) - return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error; + return ((1.0f - r->simplify_aosss) * 10.0f + 1.0f) * error; else return error; } @@ -1192,14 +1192,14 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) /* common case, step to the next */ return base->next; } - else if (base==NULL && (*sce_iter)->base.first) { + else if (base == NULL && (*sce_iter)->base.first) { /* first time looping, return the scenes first base */ return (Base *)(*sce_iter)->base.first; } else { /* reached the end, get the next base in the set */ - while ((*sce_iter= (*sce_iter)->set)) { - base= (Base *)(*sce_iter)->base.first; + while ((*sce_iter = (*sce_iter)->set)) { + base = (Base *)(*sce_iter)->base.first; if (base) { return base; } @@ -1211,26 +1211,26 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) int BKE_scene_use_new_shading_nodes(Scene *scene) { - RenderEngineType *type= RE_engines_find(scene->r.engine); + RenderEngineType *type = RE_engines_find(scene->r.engine); return (type && type->flag & RE_USE_SHADING_NODES); } void BKE_scene_base_flag_to_objects(struct Scene *scene) { - Base *base= scene->base.first; + Base *base = scene->base.first; while (base) { - base->object->flag= base->flag; - base= base->next; + base->object->flag = base->flag; + base = base->next; } } void BKE_scene_base_flag_from_objects(struct Scene *scene) { - Base *base= scene->base.first; + Base *base = scene->base.first; while (base) { - base->flag= base->object->flag; - base= base->next; + 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 8e380c3674f..1f129b1c547 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -51,7 +51,7 @@ /* ************ Spacetype/regiontype handling ************** */ /* keep global; this has to be accessible outside of windowmanager */ -static ListBase spacetypes= {NULL, NULL}; +static ListBase spacetypes = {NULL, NULL}; /* not SpaceType itself */ static void spacetype_free(SpaceType *st) @@ -60,14 +60,14 @@ static void spacetype_free(SpaceType *st) PanelType *pt; HeaderType *ht; - for (art= st->regiontypes.first; art; art= art->next) { + for (art = st->regiontypes.first; art; art = art->next) { BLI_freelistN(&art->drawcalls); - for (pt= art->paneltypes.first; pt; pt= pt->next) + for (pt = art->paneltypes.first; pt; pt = pt->next) if (pt->ext.free) pt->ext.free(pt->ext.data); - for (ht= art->headertypes.first; ht; ht= ht->next) + for (ht = art->headertypes.first; ht; ht = ht->next) if (ht->ext.free) ht->ext.free(ht->ext.data); @@ -84,7 +84,7 @@ void BKE_spacetypes_free(void) { SpaceType *st; - for (st= spacetypes.first; st; st= st->next) { + for (st = spacetypes.first; st; st = st->next) { spacetype_free(st); } @@ -95,8 +95,8 @@ SpaceType *BKE_spacetype_from_id(int spaceid) { SpaceType *st; - for (st= spacetypes.first; st; st= st->next) { - if (st->spaceid==spaceid) + for (st = spacetypes.first; st; st = st->next) { + if (st->spaceid == spaceid) return st; } return NULL; @@ -106,8 +106,8 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) { ARegionType *art; - for (art= st->regiontypes.first; art; art= art->next) - if (art->regionid==regionid) + for (art = st->regiontypes.first; art; art = art->next) + if (art->regionid == regionid) return art; printf("Error, region type missing in - name:\"%s\", id:%d\n", st->name, st->spaceid); @@ -125,7 +125,7 @@ void BKE_spacetype_register(SpaceType *st) SpaceType *stype; /* sanity check */ - stype= BKE_spacetype_from_id(st->spaceid); + stype = BKE_spacetype_from_id(st->spaceid); if (stype) { printf("error: redefinition of spacetype %s\n", stype->name); spacetype_free(stype); @@ -142,11 +142,11 @@ void BKE_spacedata_freelist(ListBase *lb) SpaceLink *sl; ARegion *ar; - for (sl= lb->first; sl; sl= sl->next) { - SpaceType *st= BKE_spacetype_from_id(sl->spacetype); + for (sl = lb->first; sl; sl = sl->next) { + SpaceType *st = BKE_spacetype_from_id(sl->spacetype); /* free regions for pushed spaces */ - for (ar=sl->regionbase.first; ar; ar=ar->next) + for (ar = sl->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sl->regionbase); @@ -160,41 +160,41 @@ void BKE_spacedata_freelist(ListBase *lb) ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar) { - ARegion *newar= MEM_dupallocN(ar); + ARegion *newar = MEM_dupallocN(ar); Panel *pa, *newpa, *patab; - newar->prev= newar->next= NULL; - newar->handlers.first= newar->handlers.last= NULL; - newar->uiblocks.first= newar->uiblocks.last= NULL; - newar->swinid= 0; + newar->prev = newar->next = NULL; + newar->handlers.first = newar->handlers.last = NULL; + newar->uiblocks.first = newar->uiblocks.last = NULL; + newar->swinid = 0; /* use optional regiondata callback */ if (ar->regiondata) { - ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype); + ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); if (art && art->duplicate) - newar->regiondata= art->duplicate(ar->regiondata); + newar->regiondata = art->duplicate(ar->regiondata); else - newar->regiondata= MEM_dupallocN(ar->regiondata); + newar->regiondata = MEM_dupallocN(ar->regiondata); } if (ar->v2d.tab_offset) - newar->v2d.tab_offset= MEM_dupallocN(ar->v2d.tab_offset); + newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset); - newar->panels.first= newar->panels.last= NULL; + newar->panels.first = newar->panels.last = NULL; BLI_duplicatelist(&newar->panels, &ar->panels); /* copy panel pointers */ - for (newpa= newar->panels.first; newpa; newpa= newpa->next) { - patab= newar->panels.first; - pa= ar->panels.first; + for (newpa = newar->panels.first; newpa; newpa = newpa->next) { + patab = newar->panels.first; + pa = ar->panels.first; while (patab) { if (newpa->paneltab == pa) { newpa->paneltab = patab; break; } - patab= patab->next; - pa= pa->next; + patab = patab->next; + pa = pa->next; } } @@ -208,10 +208,10 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2) ARegion *ar; /* to be sure */ - lb1->first= lb1->last= NULL; + lb1->first = lb1->last = NULL; - for (ar= lb2->first; ar; ar= ar->next) { - ARegion *arnew= BKE_area_region_copy(st, ar); + for (ar = lb2->first; ar; ar = ar->next) { + ARegion *arnew = BKE_area_region_copy(st, ar); BLI_addtail(lb1, arnew); } } @@ -222,13 +222,13 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2) { SpaceLink *sl; - lb1->first= lb1->last= NULL; /* to be sure */ + lb1->first = lb1->last = NULL; /* to be sure */ - for (sl= lb2->first; sl; sl= sl->next) { - SpaceType *st= BKE_spacetype_from_id(sl->spacetype); + for (sl = lb2->first; sl; sl = sl->next) { + SpaceType *st = BKE_spacetype_from_id(sl->spacetype); if (st && st->duplicate) { - SpaceLink *slnew= st->duplicate(sl); + SpaceLink *slnew = st->duplicate(sl); BLI_addtail(lb1, slnew); @@ -244,14 +244,14 @@ void BKE_spacedata_draw_locks(int set) { SpaceType *st; - for (st= spacetypes.first; st; st= st->next) { + for (st = spacetypes.first; st; st = st->next) { ARegionType *art; - for (art= st->regiontypes.first; art; art= art->next) { + for (art = st->regiontypes.first; art; art = art->next) { if (set) - art->do_lock= art->lock; + art->do_lock = art->lock; else - art->do_lock= 0; + art->do_lock = 0; } } } @@ -261,7 +261,7 @@ void BKE_spacedata_draw_locks(int set) void BKE_area_region_free(SpaceType *st, ARegion *ar) { if (st) { - ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype); + ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); if (art && art->free) art->free(ar); @@ -274,7 +274,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) if (ar->v2d.tab_offset) { MEM_freeN(ar->v2d.tab_offset); - ar->v2d.tab_offset= NULL; + ar->v2d.tab_offset = NULL; } BLI_freelistN(&ar->panels); @@ -283,10 +283,10 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) /* not area itself */ void BKE_screen_area_free(ScrArea *sa) { - SpaceType *st= BKE_spacetype_from_id(sa->spacetype); + SpaceType *st = BKE_spacetype_from_id(sa->spacetype); ARegion *ar; - for (ar=sa->regionbase.first; ar; ar=ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sa->regionbase); @@ -302,13 +302,13 @@ void BKE_screen_free(bScreen *sc) ScrArea *sa, *san; ARegion *ar; - for (ar=sc->regionbase.first; ar; ar=ar->next) + for (ar = sc->regionbase.first; ar; ar = ar->next) BKE_area_region_free(NULL, ar); BLI_freelistN(&sc->regionbase); - for (sa= sc->areabase.first; sa; sa= san) { - san= sa->next; + for (sa = sc->areabase.first; sa; sa = san) { + san = sa->next; BKE_screen_area_free(sa); } @@ -321,12 +321,12 @@ void BKE_screen_free(bScreen *sc) unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene) { ScrArea *sa; - unsigned int layer= 0; + unsigned int layer = 0; if (screen) { /* get all used view3d layers */ - for (sa= screen->areabase.first; sa; sa= sa->next) - if (sa->spacetype==SPACE_VIEW3D) + for (sa = screen->areabase.first; sa; sa = sa->next) + if (sa->spacetype == SPACE_VIEW3D) layer |= ((View3D *)sa->spacedata.first)->lay; } @@ -344,7 +344,7 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) if (sa) { ARegion *ar; - for (ar=sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == type) return ar; } @@ -357,16 +357,16 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) * -1 for any type */ struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min) { - ScrArea *sa, *big= NULL; - int size, maxsize= 0; + ScrArea *sa, *big = NULL; + int size, maxsize = 0; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { if ((spacetype == -1) || sa->spacetype == spacetype) { if (min <= sa->winx && min <= sa->winy) { - size= sa->winx*sa->winy; + size = sa->winx * sa->winy; if (size > maxsize) { - maxsize= size; - big= sa; + maxsize = size; + big = sa; } } } @@ -379,26 +379,26 @@ void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene) { int bit; - if (v3d->scenelock && v3d->localvd==NULL) { - v3d->lay= scene->lay; - v3d->camera= scene->camera; + if (v3d->scenelock && v3d->localvd == NULL) { + v3d->lay = scene->lay; + v3d->camera = scene->camera; - if (v3d->camera==NULL) { + if (v3d->camera == NULL) { ARegion *ar; - for (ar=v3d->regionbase.first; ar; ar= ar->next) { + for (ar = v3d->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; - if (rv3d->persp==RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; + RegionView3D *rv3d = ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) + rv3d->persp = RV3D_PERSP; } } } if ((v3d->lay & v3d->layact) == 0) { - for (bit= 0; bit<32; bit++) { - if (v3d->lay & (1<layact= 1<lay & (1 << bit)) { + v3d->layact = 1 << bit; break; } } @@ -410,11 +410,11 @@ void BKE_screen_view3d_scene_sync(bScreen *sc) { /* are there cameras in the views that are not in the scene? */ ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + 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; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; BKE_screen_view3d_sync(v3d, sc->scene); } } @@ -428,14 +428,14 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene) SpaceLink *sl; /* from scene copy to the other views */ - for (sc=screen_lb->first; sc; sc=sc->id.next) { - if (sc->scene!=scene) + for (sc = screen_lb->first; sc; sc = sc->id.next) { + if (sc->scene != scene) continue; - for (sa=sc->areabase.first; sa; sa=sa->next) - for (sl=sa->spacedata.first; sl; sl=sl->next) - if (sl->spacetype==SPACE_VIEW3D) - BKE_screen_view3d_sync((View3D*)sl, scene); + for (sa = sc->areabase.first; sa; sa = sa->next) + for (sl = sa->spacedata.first; sl; sl = sl->next) + if (sl->spacetype == SPACE_VIEW3D) + BKE_screen_view3d_sync((View3D *)sl, scene); } } @@ -449,7 +449,7 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene) */ float BKE_screen_view3d_zoom_to_fac(float camzoom) { - return powf(((float)M_SQRT2 + camzoom/50.0f), 2.0f) / 4.0f; + return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f; } float BKE_screen_view3d_zoom_from_fac(float zoomfac) diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index da73491eaa3..84d2bf815bc 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -63,16 +63,16 @@ // evil quiet NaN definition static const int NAN_INT = 0x7FC00000; -#define NAN_FLT *((float*)(&NAN_INT)) +#define NAN_FLT *((float *)(&NAN_INT)) #ifdef WITH_AUDASPACE // evil global ;-) static int sound_cfra; #endif -struct bSound* sound_new_file(struct Main *bmain, const char *filename) +struct bSound *sound_new_file(struct Main *bmain, const char *filename) { - bSound* sound = NULL; + bSound *sound = NULL; char str[FILE_MAX]; char *path; @@ -86,10 +86,10 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) BLI_path_abs(str, path); len = strlen(filename); - while (len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + while (len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\') len--; - sound = BKE_libblock_alloc(&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; @@ -103,7 +103,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) return sound; } -void BKE_sound_free(struct bSound* sound) +void BKE_sound_free(struct bSound *sound) { if (sound->packedfile) { freePackedFile(sound->packedfile); @@ -131,10 +131,10 @@ void BKE_sound_free(struct bSound* sound) static int force_device = -1; #ifdef WITH_JACK -static void sound_sync_callback(void* data, int mode, float time) +static void sound_sync_callback(void *data, int mode, float time) { - struct Main* bmain = (struct Main*)data; - struct Scene* scene; + struct Main *bmain = (struct Main *)data; + struct Scene *scene; scene = bmain->scene.first; while (scene) { @@ -223,11 +223,11 @@ void sound_exit(void) // XXX unused currently #if 0 -struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) +struct bSound *sound_new_buffer(struct Main *bmain, struct bSound *source) { - bSound* sound = NULL; + bSound *sound = NULL; - char name[MAX_ID_NAME+5]; + char name[MAX_ID_NAME + 5]; strcpy(name, "buf_"); strcpy(name + 4, source->id.name); @@ -247,11 +247,11 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) return sound; } -struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end) +struct bSound *sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end) { - bSound* sound = NULL; + bSound *sound = NULL; - char name[MAX_ID_NAME+5]; + char name[MAX_ID_NAME + 5]; strcpy(name, "lim_"); strcpy(name + 4, source->id.name); @@ -274,7 +274,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa } #endif -void sound_delete(struct Main *bmain, struct bSound* sound) +void sound_delete(struct Main *bmain, struct bSound *sound) { if (sound) { BKE_sound_free(sound); @@ -283,7 +283,7 @@ void sound_delete(struct Main *bmain, struct bSound* sound) } } -void sound_cache(struct bSound* sound) +void sound_cache(struct bSound *sound) { sound->flags |= SOUND_FLAGS_CACHING; if (sound->cache) @@ -296,13 +296,13 @@ void sound_cache(struct bSound* sound) sound->playback_handle = sound->handle; } -void sound_cache_notifying(struct Main* main, struct bSound* sound) +void sound_cache_notifying(struct Main *main, struct bSound *sound) { sound_cache(sound); sound_update_sequencer(main, sound); } -void sound_delete_cache(struct bSound* sound) +void sound_delete_cache(struct bSound *sound) { sound->flags &= ~SOUND_FLAGS_CACHING; if (sound->cache) { @@ -312,7 +312,7 @@ void sound_delete_cache(struct bSound* sound) } } -void sound_load(struct Main *bmain, struct bSound* sound) +void sound_load(struct Main *bmain, struct bSound *sound) { if (sound) { if (sound->cache) { @@ -332,13 +332,13 @@ void sound_load(struct Main *bmain, struct bSound* sound) #if 0 switch (sound->type) { - case SOUND_TYPE_FILE: + case SOUND_TYPE_FILE: #endif { char fullpath[FILE_MAX]; /* load sound */ - PackedFile* pf = sound->packedfile; + PackedFile *pf = sound->packedfile; /* don't modify soundact->sound->name, only change a copy */ BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); @@ -346,7 +346,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) /* but we need a packed file then */ if (pf) - sound->handle = AUD_loadBuffer((unsigned char*) pf->data, pf->size); + sound->handle = AUD_loadBuffer((unsigned char *) pf->data, pf->size); /* or else load it from disk */ else sound->handle = AUD_load(fullpath); @@ -366,7 +366,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) } #endif if (sound->flags & SOUND_FLAGS_MONO) { - void* handle = AUD_monoSound(sound->handle); + void *handle = AUD_monoSound(sound->handle); AUD_unload(sound->handle); sound->handle = handle; } @@ -384,7 +384,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) } } -AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume) +AUD_Device *sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume) { return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS); } @@ -393,7 +393,7 @@ void sound_create_scene(struct Scene *scene) { scene->sound_scene = AUD_createSequencer(FPS, scene->audio.flag & AUDIO_MUTE); AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound, - scene->audio.doppler_factor, scene->audio.distance_model); + scene->audio.doppler_factor, scene->audio.distance_model); scene->sound_scene_handle = NULL; scene->sound_scrub_handle = NULL; scene->speaker_handles = NULL; @@ -426,26 +426,26 @@ void sound_update_fps(struct Scene *scene) void sound_update_scene_listener(struct Scene *scene) { AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound, - scene->audio.doppler_factor, scene->audio.distance_model); + scene->audio.doppler_factor, scene->audio.distance_model); } -void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) +void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip) { if (scene != sequence->scene) return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS); return NULL; } -void* sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence) +void *sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence) { return sound_scene_add_scene_sound(scene, sequence, sequence->startdisp, sequence->enddisp, sequence->startofs + sequence->anim_startofs); } -void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) +void *sound_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip) { - void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS); + void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS); AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0); AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0); AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0); @@ -453,29 +453,29 @@ void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int return handle; } -void* sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence) +void *sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence) { return sound_add_scene_sound(scene, sequence, sequence->startdisp, sequence->enddisp, sequence->startofs + sequence->anim_startofs); } -void sound_remove_scene_sound(struct Scene *scene, void* handle) +void sound_remove_scene_sound(struct Scene *scene, void *handle) { AUD_removeSequence(scene->sound_scene, handle); } -void sound_mute_scene_sound(void* handle, char mute) +void sound_mute_scene_sound(void *handle, char mute) { AUD_muteSequence(handle, mute); } -void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip) +void sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip) { AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS); } -void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence) +void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence) { if (sequence->scene_sound) { sound_move_scene_sound(scene, sequence->scene_sound, @@ -484,7 +484,7 @@ void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* seque } } -void sound_update_scene_sound(void* handle, struct bSound* sound) +void sound_update_scene_sound(void *handle, struct bSound *sound) { AUD_updateSequenceSound(handle, sound->playback_handle); } @@ -499,24 +499,24 @@ void sound_set_scene_volume(struct Scene *scene, float volume) AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume, (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0); } -void sound_set_scene_sound_volume(void* handle, float volume, char animated) +void sound_set_scene_sound_volume(void *handle, float volume, char animated) { AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, sound_cfra, &volume, animated); } -void sound_set_scene_sound_pitch(void* handle, float pitch, char animated) +void sound_set_scene_sound_pitch(void *handle, float pitch, char animated) { AUD_setSequenceAnimData(handle, AUD_AP_PITCH, sound_cfra, &pitch, animated); } -void sound_set_scene_sound_pan(void* handle, float pan, char animated) +void sound_set_scene_sound_pan(void *handle, float pan, char animated) { AUD_setSequenceAnimData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated); } -void sound_update_sequencer(struct Main* main, struct bSound* sound) +void sound_update_sequencer(struct Main *main, struct bSound *sound) { - struct Scene* scene; + struct Scene *scene; for (scene = main->scene.first; scene; scene = scene->id.next) { seq_update_sound(scene, sound); @@ -592,7 +592,7 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) } animation_playing = 0; - for (screen=bmain->screen.first; screen; screen=screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { if (screen->animtimer) { animation_playing = 1; } @@ -645,24 +645,24 @@ int sound_scene_playing(struct Scene *scene) return -1; } -void sound_free_waveform(struct bSound* sound) +void sound_free_waveform(struct bSound *sound) { if (sound->waveform) { - MEM_freeN(((SoundWaveform*)sound->waveform)->data); + MEM_freeN(((SoundWaveform *)sound->waveform)->data); MEM_freeN(sound->waveform); } sound->waveform = NULL; } -void sound_read_waveform(struct bSound* sound) +void sound_read_waveform(struct bSound *sound) { AUD_SoundInfo info; info = AUD_getInfo(sound->playback_handle); if (info.length > 0) { - SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); + SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples"); @@ -673,17 +673,17 @@ void sound_read_waveform(struct bSound* sound) } } -void sound_update_scene(struct Scene* scene) +void sound_update_scene(struct Scene *scene) { - Object* ob; - Base* base; - NlaTrack* track; - NlaStrip* strip; - Speaker* speaker; - Scene* sce_it; + Object *ob; + Base *base; + NlaTrack *track; + NlaStrip *strip; + Speaker *speaker; + Scene *sce_it; - void* new_set = AUD_createSet(); - void* handle; + void *new_set = AUD_createSet(); + void *handle; float quat[4]; for (SETLOOPER(scene, sce_it, base)) { @@ -693,7 +693,7 @@ void sound_update_scene(struct Scene* scene) for (track = ob->adt->nla_tracks.first; track; track = track->next) { for (strip = track->strips.first; strip; strip = strip->next) { if (strip->type == NLASTRIP_TYPE_SOUND) { - speaker = (Speaker*)ob->data; + speaker = (Speaker *)ob->data; if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { if (speaker->sound) @@ -713,10 +713,10 @@ void sound_update_scene(struct Scene* scene) if (strip->speaker_handle) { AUD_addSet(new_set, strip->speaker_handle); AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max, - speaker->volume_min, speaker->distance_max, - speaker->distance_reference, speaker->attenuation, - speaker->cone_angle_outer, speaker->cone_angle_inner, - speaker->cone_volume_outer); + speaker->volume_min, speaker->distance_max, + speaker->distance_reference, speaker->attenuation, + speaker->cone_angle_outer, speaker->cone_angle_inner, + speaker->cone_volume_outer); mat4_to_quat(quat, ob->obmat); AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1); @@ -747,9 +747,9 @@ void sound_update_scene(struct Scene* scene) scene->speaker_handles = new_set; } -void* sound_get_factory(void* sound) +void *sound_get_factory(void *sound) { - return ((struct bSound*) sound)->playback_handle; + return ((struct bSound *) sound)->playback_handle; } #else // WITH_AUDASPACE diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index e94a11b8f89..09440591826 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -47,7 +47,7 @@ void *BKE_speaker_add(const char *name) { Speaker *spk; - spk= BKE_libblock_alloc(&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; @@ -69,7 +69,7 @@ Speaker *BKE_speaker_copy(Speaker *spk) { Speaker *spkn; - spkn= BKE_libblock_copy(&spk->id); + spkn = BKE_libblock_copy(&spk->id); if (spkn->sound) spkn->sound->id.us++; @@ -78,51 +78,51 @@ Speaker *BKE_speaker_copy(Speaker *spk) void BKE_speaker_make_local(Speaker *spk) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (spk->id.lib==NULL) return; - if (spk->id.us==1) { + if (spk->id.lib == NULL) return; + if (spk->id.us == 1) { id_clear_lib_data(bmain, &spk->id); return; } - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==spk) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->data == spk) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } - ob= ob->id.next; + ob = ob->id.next; } if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &spk->id); } else if (is_local && is_lib) { - Speaker *spk_new= BKE_speaker_copy(spk); - spk_new->id.us= 0; + Speaker *spk_new = BKE_speaker_copy(spk); + spk_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id); - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==spk) { + if (ob->data == spk) { - if (ob->id.lib==NULL) { - ob->data= spk_new; + if (ob->id.lib == NULL) { + ob->data = spk_new; spk_new->id.us++; spk->id.us--; } } - ob= ob->id.next; + ob = ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index e3e4f663e27..e8010ceceff 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -135,8 +135,8 @@ static void txt_pop_last(Text *text); static void txt_undo_add_op(Text *text, int op); static void txt_undo_add_block(Text *text, int op, const char *buf); static void txt_delete_line(Text *text, TextLine *line); -static void txt_delete_sel (Text *text); -static void txt_make_dirty (Text *text); +static void txt_delete_sel(Text *text); +static void txt_make_dirty(Text *text); /***/ @@ -155,19 +155,19 @@ int txt_get_undostate(void) static void init_undo_text(Text *text) { - text->undo_pos= -1; - text->undo_len= TXT_INIT_UNDO; - text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); + text->undo_pos = -1; + text->undo_len = TXT_INIT_UNDO; + text->undo_buf = MEM_mallocN(text->undo_len, "undo buf"); } void BKE_text_free(Text *text) { TextLine *tmp; - for (tmp= text->lines.first; tmp; tmp= tmp->next) { + for (tmp = text->lines.first; tmp; tmp = tmp->next) { MEM_freeN(tmp->line); if (tmp->format) - MEM_freeN(tmp->format); + MEM_freeN(tmp->format); } BLI_freelistN(&text->lines); @@ -182,41 +182,41 @@ void BKE_text_free(Text *text) Text *BKE_text_add(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Text *ta; TextLine *tmp; - ta= BKE_libblock_alloc(&bmain->text, ID_TXT, name); - ta->id.us= 1; + ta = BKE_libblock_alloc(&bmain->text, ID_TXT, name); + ta->id.us = 1; - ta->name= NULL; + ta->name = NULL; init_undo_text(ta); - ta->nlines=1; - ta->flags= TXT_ISDIRTY | TXT_ISMEM; - if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0) + ta->nlines = 1; + ta->flags = TXT_ISDIRTY | TXT_ISMEM; + if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) ta->flags |= TXT_TABSTOSPACES; - ta->lines.first= ta->lines.last= NULL; - ta->markers.first= ta->markers.last= NULL; + ta->lines.first = ta->lines.last = NULL; + ta->markers.first = ta->markers.last = NULL; - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= (char*) MEM_mallocN(1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(1, "textline_string"); + tmp->format = NULL; - tmp->line[0]=0; - tmp->len= 0; + tmp->line[0] = 0; + tmp->len = 0; - tmp->next= NULL; - tmp->prev= NULL; + tmp->next = NULL; + tmp->prev = NULL; BLI_addhead(&ta->lines, tmp); - ta->curl= ta->lines.first; - ta->curc= 0; - ta->sell= ta->lines.first; - ta->selc= 0; + ta->curl = ta->lines.first; + ta->curc = 0; + ta->sell = ta->lines.first; + ta->selc = 0; return ta; } @@ -225,35 +225,35 @@ Text *BKE_text_add(const char *name) /* to a valid utf-8 sequences */ int txt_extended_ascii_as_utf8(char **str) { - int bad_char, added= 0, i= 0; + int bad_char, added = 0, i = 0; int length = strlen(*str); while ((*str)[i]) { - if ((bad_char= BLI_utf8_invalid_byte(*str+i, length-i)) == -1) + if ((bad_char = BLI_utf8_invalid_byte(*str + i, length - i)) == -1) break; added++; - i+= bad_char + 1; + i += bad_char + 1; } if (added != 0) { - char *newstr = MEM_mallocN(length+added+1, "text_line"); + char *newstr = MEM_mallocN(length + added + 1, "text_line"); int mi = 0; - i= 0; + i = 0; while ((*str)[i]) { - if ((bad_char= BLI_utf8_invalid_byte((*str)+i, length-i)) == -1) { - memcpy(newstr+mi, (*str)+i, length - i + 1); + if ((bad_char = BLI_utf8_invalid_byte((*str) + i, length - i)) == -1) { + memcpy(newstr + mi, (*str) + i, length - i + 1); break; } - memcpy(newstr+mi, (*str)+i, bad_char); + memcpy(newstr + mi, (*str) + i, bad_char); - BLI_str_utf8_from_unicode((*str)[i+bad_char], newstr+mi+bad_char); - i+= bad_char+1; - mi+= bad_char+2; + BLI_str_utf8_from_unicode((*str)[i + bad_char], newstr + mi + bad_char); + i += bad_char + 1; + mi += bad_char + 2; } - newstr[length+added] = '\0'; + newstr[length + added] = '\0'; MEM_freeN(*str); *str = newstr; } @@ -264,18 +264,18 @@ int txt_extended_ascii_as_utf8(char **str) // this function removes any control characters from // a textline and fixes invalid utf-8 sequences -static void cleanup_textline(TextLine * tl) +static void cleanup_textline(TextLine *tl) { int i; - for (i = 0; i < tl->len; i++ ) { + for (i = 0; i < tl->len; i++) { if (tl->line[i] < ' ' && tl->line[i] != '\t') { memmove(tl->line + i, tl->line + i + 1, tl->len - i); tl->len--; i--; } } - tl->len+= txt_extended_ascii_as_utf8(&tl->line); + tl->len += txt_extended_ascii_as_utf8(&tl->line); } int BKE_text_reload(Text *text) @@ -292,32 +292,32 @@ int BKE_text_reload(Text *text) BLI_strncpy(str, text->name, FILE_MAX); BLI_path_abs(str, G.main->name); - fp= BLI_fopen(str, "r"); - if (fp==NULL) return 0; + fp = BLI_fopen(str, "r"); + if (fp == NULL) return 0; /* free memory: */ - for (tmp= text->lines.first; tmp; tmp= tmp->next) { + for (tmp = text->lines.first; tmp; tmp = tmp->next) { MEM_freeN(tmp->line); if (tmp->format) MEM_freeN(tmp->format); } BLI_freelistN(&text->lines); - text->lines.first= text->lines.last= NULL; - text->curl= text->sell= NULL; + text->lines.first = text->lines.last = NULL; + text->curl = text->sell = NULL; /* clear undo buffer */ MEM_freeN(text->undo_buf); init_undo_text(text); fseek(fp, 0L, SEEK_END); - len= ftell(fp); + len = ftell(fp); fseek(fp, 0L, SEEK_SET); - text->undo_pos= -1; + text->undo_pos = -1; - buffer= MEM_mallocN(len, "text_buffer"); + buffer = MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because // of CR stripping len = fread(buffer, 1, len, fp); @@ -325,40 +325,40 @@ int BKE_text_reload(Text *text) fclose(fp); stat(str, &st); - text->mtime= st.st_mtime; + text->mtime = st.st_mtime; - text->nlines=0; - llen=0; - for (i=0; iline= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; - - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + text->nlines = 0; + llen = 0; + for (i = 0; i < len; i++) { + if (buffer[i] == '\n') { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; + + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); BLI_addtail(&text->lines, tmp); text->nlines++; - llen=0; + llen = 0; continue; } llen++; } - if (llen!=0 || text->nlines==0) { - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; + if (llen != 0 || text->nlines == 0) { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); @@ -366,8 +366,8 @@ int BKE_text_reload(Text *text) text->nlines++; } - text->curl= text->sell= text->lines.first; - text->curc= text->selc= 0; + text->curl = text->sell = text->lines.first; + text->curc = text->selc = 0; MEM_freeN(buffer); return 1; @@ -375,7 +375,7 @@ int BKE_text_reload(Text *text) Text *BKE_text_load(const char *file, const char *relpath) { - Main *bmain= G.main; + Main *bmain = G.main; FILE *fp; int i, llen, len; unsigned char *buffer; @@ -388,29 +388,29 @@ Text *BKE_text_load(const char *file, const char *relpath) if (relpath) /* can be NULL (bg mode) */ BLI_path_abs(str, relpath); - fp= BLI_fopen(str, "r"); - if (fp==NULL) return NULL; + fp = BLI_fopen(str, "r"); + if (fp == NULL) return NULL; - ta= BKE_libblock_alloc(&bmain->text, ID_TXT, BLI_path_basename(str)); - ta->id.us= 1; + ta = BKE_libblock_alloc(&bmain->text, ID_TXT, BLI_path_basename(str)); + ta->id.us = 1; - ta->lines.first= ta->lines.last= NULL; - ta->markers.first= ta->markers.last= NULL; - ta->curl= ta->sell= NULL; + ta->lines.first = ta->lines.last = NULL; + ta->markers.first = ta->markers.last = NULL; + ta->curl = ta->sell = NULL; - if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0) - ta->flags= TXT_TABSTOSPACES; + if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) + ta->flags = TXT_TABSTOSPACES; fseek(fp, 0L, SEEK_END); - len= ftell(fp); + len = ftell(fp); fseek(fp, 0L, SEEK_SET); - ta->name= MEM_mallocN(strlen(file)+1, "text_name"); + ta->name = MEM_mallocN(strlen(file) + 1, "text_name"); strcpy(ta->name, file); init_undo_text(ta); - buffer= MEM_mallocN(len, "text_buffer"); + buffer = MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because // of CR stripping len = fread(buffer, 1, len, fp); @@ -418,26 +418,26 @@ Text *BKE_text_load(const char *file, const char *relpath) fclose(fp); stat(str, &st); - ta->mtime= st.st_mtime; + ta->mtime = st.st_mtime; - ta->nlines=0; - llen=0; - for (i=0; iline= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; - - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + ta->nlines = 0; + llen = 0; + for (i = 0; i < len; i++) { + if (buffer[i] == '\n') { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; + + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); BLI_addtail(&ta->lines, tmp); ta->nlines++; - llen=0; + llen = 0; continue; } llen++; @@ -449,15 +449,15 @@ Text *BKE_text_load(const char *file, const char *relpath) * - file is empty. in this case new line is needed to start editing from. * - last characted in buffer is \n. in this case new line is needed to * deal with newline at end of file. (see [#28087]) (sergey) */ - if (llen!=0 || ta->nlines==0 || buffer[len-1]=='\n') { - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; + if (llen != 0 || ta->nlines == 0 || buffer[len - 1] == '\n') { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); @@ -465,8 +465,8 @@ Text *BKE_text_load(const char *file, const char *relpath) ta->nlines++; } - ta->curl= ta->sell= ta->lines.first; - ta->curc= ta->selc= 0; + ta->curl = ta->sell = ta->lines.first; + ta->curc = ta->selc = 0; MEM_freeN(buffer); @@ -478,43 +478,43 @@ Text *BKE_text_copy(Text *ta) Text *tan; TextLine *line, *tmp; - tan= BKE_libblock_copy(&ta->id); + tan = BKE_libblock_copy(&ta->id); /* file name can be NULL */ if (ta->name) { - tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name"); + tan->name = MEM_mallocN(strlen(ta->name) + 1, "text_name"); strcpy(tan->name, ta->name); } else { - tan->name= NULL; + tan->name = NULL; } tan->flags = ta->flags | TXT_ISDIRTY; - tan->lines.first= tan->lines.last= NULL; - tan->markers.first= tan->markers.last= NULL; - tan->curl= tan->sell= NULL; + tan->lines.first = tan->lines.last = NULL; + tan->markers.first = tan->markers.last = NULL; + tan->curl = tan->sell = NULL; - tan->nlines= ta->nlines; + tan->nlines = ta->nlines; - line= ta->lines.first; + line = ta->lines.first; /* Walk down, reconstructing */ while (line) { - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= MEM_mallocN(line->len+1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = MEM_mallocN(line->len + 1, "textline_string"); + tmp->format = NULL; strcpy(tmp->line, line->line); - tmp->len= line->len; + tmp->len = line->len; BLI_addtail(&tan->lines, tmp); - line= line->next; + line = line->next; } - tan->curl= tan->sell= tan->lines.first; - tan->curc= tan->selc= 0; + tan->curl = tan->sell = tan->lines.first; + tan->curc = tan->selc = 0; init_undo_text(tan); @@ -531,27 +531,27 @@ void BKE_text_unlink(Main *bmain, Text *text) bConstraint *con; short update; - for (ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* game controllers */ - for (cont=ob->controllers.first; cont; cont=cont->next) { - if (cont->type==CONT_PYTHON) { + for (cont = ob->controllers.first; cont; cont = cont->next) { + if (cont->type == CONT_PYTHON) { bPythonCont *pc; - pc= cont->data; - if (pc->text==text) pc->text= NULL; + pc = cont->data; + if (pc->text == text) pc->text = NULL; } } /* pyconstraints */ update = 0; - if (ob->type==OB_ARMATURE && ob->pose) { + if (ob->type == OB_ARMATURE && ob->pose) { bPoseChannel *pchan; - 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) { + 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 = con->data; - if (data->text==text) data->text = NULL; + if (data->text == text) data->text = NULL; update = 1; } @@ -559,10 +559,10 @@ void BKE_text_unlink(Main *bmain, Text *text) } } - for (con = ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_PYTHON) { + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_PYTHON) { bPythonConstraint *data = con->data; - if (data->text==text) data->text = NULL; + if (data->text == text) data->text = NULL; update = 1; } } @@ -575,22 +575,22 @@ void BKE_text_unlink(Main *bmain, Text *text) // XXX nodeDynamicUnlinkText(&text->id); /* text space */ - for (scr= bmain->screen.first; scr; scr= scr->id.next) { - for (area= scr->areabase.first; area; area= area->next) { - for (sl= area->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText*) sl; - - if (st->text==text) { - st->text= NULL; - st->top= 0; + for (scr = bmain->screen.first; scr; scr = scr->id.next) { + for (area = scr->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_TEXT) { + SpaceText *st = (SpaceText *) sl; + + if (st->text == text) { + st->text = NULL; + st->top = 0; } } } } } - text->id.us= 0; + text->id.us = 0; } void BKE_text_clear(Text *text) /* called directly from rna */ @@ -627,25 +627,25 @@ static void make_new_line(TextLine *line, char *newline) if (line->line) MEM_freeN(line->line); if (line->format) MEM_freeN(line->format); - line->line= newline; - line->len= strlen(newline); - line->format= NULL; + line->line = newline; + line->len = strlen(newline); + line->format = NULL; } static TextLine *txt_new_line(const char *str) { TextLine *tmp; - if (!str) str= ""; + if (!str) str = ""; - tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= MEM_mallocN(strlen(str)+1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = MEM_mallocN(strlen(str) + 1, "textline_string"); + tmp->format = NULL; strcpy(tmp->line, str); - tmp->len= strlen(str); - tmp->next= tmp->prev= NULL; + tmp->len = strlen(str); + tmp->next = tmp->prev = NULL; return tmp; } @@ -654,14 +654,14 @@ static TextLine *txt_new_linen(const char *str, int n) { TextLine *tmp; - tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= MEM_mallocN(n+1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = MEM_mallocN(n + 1, "textline_string"); + tmp->format = NULL; - BLI_strncpy(tmp->line, (str)? str: "", n+1); + BLI_strncpy(tmp->line, (str) ? str : "", n + 1); - tmp->len= strlen(tmp->line); - tmp->next= tmp->prev= NULL; + tmp->len = strlen(tmp->line); + tmp->next = tmp->prev = NULL; return tmp; } @@ -673,61 +673,61 @@ void txt_clean_text(Text *text) if (!text) return; if (!text->lines.first) { - if (text->lines.last) text->lines.first= text->lines.last; - else text->lines.first= text->lines.last= txt_new_line(NULL); + if (text->lines.last) text->lines.first = text->lines.last; + else text->lines.first = text->lines.last = txt_new_line(NULL); } - if (!text->lines.last) text->lines.last= text->lines.first; + if (!text->lines.last) text->lines.last = text->lines.first; - top= (TextLine **) &text->lines.first; - bot= (TextLine **) &text->lines.last; + top = (TextLine **) &text->lines.first; + bot = (TextLine **) &text->lines.last; - while ((*top)->prev) *top= (*top)->prev; - while ((*bot)->next) *bot= (*bot)->next; + while ((*top)->prev) *top = (*top)->prev; + while ((*bot)->next) *bot = (*bot)->next; if (!text->curl) { - if (text->sell) text->curl= text->sell; - else text->curl= text->lines.first; - text->curc= 0; + if (text->sell) text->curl = text->sell; + else text->curl = text->lines.first; + text->curc = 0; } if (!text->sell) { - text->sell= text->curl; - text->selc= 0; + text->sell = text->curl; + text->selc = 0; } } int txt_get_span(TextLine *from, TextLine *to) { - int ret=0; - TextLine *tmp= from; + int ret = 0; + TextLine *tmp = from; if (!to || !from) return 0; - if (from==to) return 0; + if (from == to) return 0; /* Look forwards */ while (tmp) { if (tmp == to) return ret; ret++; - tmp= tmp->next; + tmp = tmp->next; } /* Look backwards */ if (!tmp) { - tmp= from; - ret=0; + tmp = from; + ret = 0; while (tmp) { if (tmp == to) break; ret--; - tmp= tmp->prev; + tmp = tmp->prev; } - if (!tmp) ret=0; + if (!tmp) ret = 0; } return ret; } -static void txt_make_dirty (Text *text) +static void txt_make_dirty(Text *text) { text->flags |= TXT_ISDIRTY; #ifdef WITH_PYTHON @@ -739,30 +739,30 @@ static void txt_make_dirty (Text *text) /* Cursor utility functions */ /****************************/ -static void txt_curs_cur (Text *text, TextLine ***linep, int **charp) +static void txt_curs_cur(Text *text, TextLine ***linep, int **charp) { - *linep= &text->curl; *charp= &text->curc; + *linep = &text->curl; *charp = &text->curc; } -static void txt_curs_sel (Text *text, TextLine ***linep, int **charp) +static void txt_curs_sel(Text *text, TextLine ***linep, int **charp) { - *linep= &text->sell; *charp= &text->selc; + *linep = &text->sell; *charp = &text->selc; } -static void txt_curs_first (Text *text, TextLine **linep, int *charp) +static void txt_curs_first(Text *text, TextLine **linep, int *charp) { - if (text->curl==text->sell) { - *linep= text->curl; - if (text->curcselc) *charp= text->curc; - else *charp= text->selc; + if (text->curl == text->sell) { + *linep = text->curl; + if (text->curc < text->selc) *charp = text->curc; + else *charp = text->selc; } - else if (txt_get_span(text->lines.first, text->curl)lines.first, text->sell)) { - *linep= text->curl; - *charp= text->curc; + else if (txt_get_span(text->lines.first, text->curl) < txt_get_span(text->lines.first, text->sell)) { + *linep = text->curl; + *charp = text->curc; } else { - *linep= text->sell; - *charp= text->selc; + *linep = text->sell; + *charp = text->selc; } } @@ -772,7 +772,7 @@ static void txt_curs_first (Text *text, TextLine **linep, int *charp) int txt_utf8_offset_to_index(const char *str, int offset) { - int index= 0, pos= 0; + int index = 0, pos = 0; while (pos != offset) { pos += BLI_str_utf8_size(str + pos); index++; @@ -782,7 +782,7 @@ int txt_utf8_offset_to_index(const char *str, int offset) int txt_utf8_index_to_offset(const char *str, int index) { - int offset= 0, pos= 0; + int offset = 0, pos = 0; while (pos != index) { offset += BLI_str_utf8_size(str + offset); pos++; @@ -796,7 +796,7 @@ static int txt_utf8_len(const char *src) { int len; - for (len=0; *src; len++) { + for (len = 0; *src; len++) { src += BLI_str_utf8_size(src); } @@ -817,12 +817,12 @@ void txt_move_up(Text *text, short sel) if ((*linep)->prev) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); - *linep= (*linep)->prev; - if (index > txt_utf8_len((*linep)->line)) *charp= (*linep)->len; - else *charp= txt_utf8_index_to_offset((*linep)->line, index); + *linep = (*linep)->prev; + if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; + else *charp = txt_utf8_index_to_offset((*linep)->line, index); if (!undoing) - txt_undo_add_op(text, sel?UNDO_SUP:UNDO_CUP); + txt_undo_add_op(text, sel ? UNDO_SUP : UNDO_CUP); } else { txt_move_bol(text, sel); @@ -845,12 +845,12 @@ void txt_move_down(Text *text, short sel) if ((*linep)->next) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); - *linep= (*linep)->next; - if (index > txt_utf8_len((*linep)->line)) *charp= (*linep)->len; - else *charp= txt_utf8_index_to_offset((*linep)->line, index); + *linep = (*linep)->next; + if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; + else *charp = txt_utf8_index_to_offset((*linep)->line, index); if (!undoing) - txt_undo_add_op(text, sel?UNDO_SDOWN:UNDO_CDOWN); + txt_undo_add_op(text, sel ? UNDO_SDOWN : UNDO_CDOWN); } else { txt_move_eol(text, sel); @@ -862,49 +862,49 @@ void txt_move_down(Text *text, short sel) void txt_move_left(Text *text, short sel) { TextLine **linep; - int *charp, oundoing= undoing; - int tabsize= 0, i= 0; + int *charp, oundoing = undoing; + int tabsize = 0, i = 0; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - undoing= 1; + undoing = 1; - if (*charp== 0) { + if (*charp == 0) { if ((*linep)->prev) { txt_move_up(text, sel); - *charp= (*linep)->len; + *charp = (*linep)->len; } } else { // do nice left only if there are only spaces // TXT_TABSIZE hardcoded in DNA_text_types.h if (text->flags & TXT_TABSTOSPACES) { - tabsize= (*charp < TXT_TABSIZE) ? *charp : TXT_TABSIZE; + tabsize = (*charp < TXT_TABSIZE) ? *charp : TXT_TABSIZE; - for (i=0; i<(*charp); i++) + for (i = 0; i < (*charp); i++) if ((*linep)->line[i] != ' ') { - tabsize= 0; + tabsize = 0; break; } // if in the middle of the space-tab if (tabsize && (*charp) % TXT_TABSIZE != 0) - tabsize= ((*charp) % TXT_TABSIZE); + tabsize = ((*charp) % TXT_TABSIZE); } if (tabsize) - (*charp)-= tabsize; + (*charp) -= tabsize; else { - const char *prev= BLI_str_prev_char_utf8((*linep)->line + *charp); - *charp= prev - (*linep)->line; + const char *prev = BLI_str_prev_char_utf8((*linep)->line + *charp); + *charp = prev - (*linep)->line; } } - undoing= oundoing; - if (!undoing) txt_undo_add_op(text, sel?UNDO_SLEFT:UNDO_CLEFT); + undoing = oundoing; + if (!undoing) txt_undo_add_op(text, sel ? UNDO_SLEFT : UNDO_CLEFT); if (!sel) txt_pop_sel(text); } @@ -912,44 +912,44 @@ void txt_move_left(Text *text, short sel) void txt_move_right(Text *text, short sel) { TextLine **linep; - int *charp, oundoing= undoing, do_tab= 0, i; + int *charp, oundoing = undoing, do_tab = 0, i; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - undoing= 1; + undoing = 1; - if (*charp== (*linep)->len) { + if (*charp == (*linep)->len) { if ((*linep)->next) { txt_move_down(text, sel); - *charp= 0; + *charp = 0; } } else { // do nice right only if there are only spaces // spaces hardcoded in DNA_text_types.h - if (text->flags & TXT_TABSTOSPACES && (*linep)->line[*charp]== ' ') { - do_tab= 1; - for (i=0; i<*charp; i++) - if ((*linep)->line[i]!= ' ') { - do_tab= 0; + if (text->flags & TXT_TABSTOSPACES && (*linep)->line[*charp] == ' ') { + do_tab = 1; + for (i = 0; i < *charp; i++) + if ((*linep)->line[i] != ' ') { + do_tab = 0; break; } } if (do_tab) { - int tabsize= (*charp) % TXT_TABSIZE + 1; - for (i=*charp+1; (*linep)->line[i]==' ' && tabsizeline[i] == ' ' && tabsize < TXT_TABSIZE; i++) tabsize++; - (*charp)= i; + (*charp) = i; } - else (*charp)+= BLI_str_utf8_size((*linep)->line + *charp); + else (*charp) += BLI_str_utf8_size((*linep)->line + *charp); } - undoing= oundoing; - if (!undoing) txt_undo_add_op(text, sel?UNDO_SRIGHT:UNDO_CRIGHT); + undoing = oundoing; + if (!undoing) txt_undo_add_op(text, sel ? UNDO_SRIGHT : UNDO_CRIGHT); if (!sel) txt_pop_sel(text); } @@ -968,19 +968,19 @@ void txt_jump_left(Text *text, short sel) oldflags = text->flags; text->flags &= ~TXT_TABSTOSPACES; - oldl= *linep; - oldc= *charp; - oldu= undoing; - undoing= 1; /* Don't push individual moves to undo stack */ + oldl = *linep; + oldc = *charp; + oldu = undoing; + undoing = 1; /* Don't push individual moves to undo stack */ BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, - charp, STRCUR_DIR_PREV, + charp, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM); text->flags = oldflags; - undoing= oldu; - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + undoing = oldu; + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_jump_right(Text *text, short sel) @@ -997,19 +997,19 @@ void txt_jump_right(Text *text, short sel) oldflags = text->flags; text->flags &= ~TXT_TABSTOSPACES; - oldl= *linep; - oldc= *charp; - oldu= undoing; - undoing= 1; /* Don't push individual moves to undo stack */ + oldl = *linep; + oldc = *charp; + oldu = undoing; + undoing = 1; /* Don't push individual moves to undo stack */ BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, - charp, STRCUR_DIR_NEXT, + charp, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM); text->flags = oldflags; - undoing= oldu; - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + undoing = oldu; + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_bol(Text *text, short sel) @@ -1021,12 +1021,12 @@ void txt_move_bol(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *charp= 0; + *charp = 0; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_eol(Text *text, short sel) @@ -1038,12 +1038,12 @@ void txt_move_eol(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *charp= (*linep)->len; + *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_bof(Text *text, short sel) @@ -1055,13 +1055,13 @@ void txt_move_bof(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *linep= text->lines.first; - *charp= 0; + *linep = text->lines.first; + *charp = 0; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_eof(Text *text, short sel) @@ -1073,13 +1073,13 @@ void txt_move_eof(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *linep= text->lines.last; - *charp= (*linep)->len; + *linep = text->lines.last; + *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_toline(Text *text, unsigned int line, short sel) @@ -1098,71 +1098,71 @@ void txt_move_to(Text *text, unsigned int line, unsigned int ch, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - oldc= *charp; - oldl= *linep; + oldc = *charp; + oldl = *linep; - *linep= text->lines.first; - for (i=0; inext) *linep= (*linep)->next; + *linep = text->lines.first; + for (i = 0; i < line; i++) { + if ((*linep)->next) *linep = (*linep)->next; else break; } - if (ch>(unsigned int)((*linep)->len)) - ch= (unsigned int)((*linep)->len); - *charp= ch; + if (ch > (unsigned int)((*linep)->len)) + ch = (unsigned int)((*linep)->len); + *charp = ch; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } /****************************/ /* Text selection functions */ /****************************/ -static void txt_curs_swap (Text *text) +static void txt_curs_swap(Text *text) { TextLine *tmpl; int tmpc; - tmpl= text->curl; - text->curl= text->sell; - text->sell= tmpl; - - tmpc= text->curc; - text->curc= text->selc; - text->selc= tmpc; + tmpl = text->curl; + text->curl = text->sell; + text->sell = tmpl; + + tmpc = text->curc; + text->curc = text->selc; + text->selc = tmpc; if (!undoing) txt_undo_add_op(text, UNDO_SWAP); } -static void txt_pop_first (Text *text) +static void txt_pop_first(Text *text) { - if (txt_get_span(text->curl, text->sell)<0 || - (text->curl==text->sell && text->curc>text->selc)) { + if (txt_get_span(text->curl, text->sell) < 0 || + (text->curl == text->sell && text->curc > text->selc)) { txt_curs_swap(text); } if (!undoing) txt_undo_add_toop(text, UNDO_STO, - txt_get_span(text->lines.first, text->sell), - text->selc, - txt_get_span(text->lines.first, text->curl), - text->curc); + txt_get_span(text->lines.first, text->sell), + text->selc, + txt_get_span(text->lines.first, text->curl), + text->curc); txt_pop_sel(text); } -static void txt_pop_last (Text *text) +static void txt_pop_last(Text *text) { - if (txt_get_span(text->curl, text->sell)>0 || - (text->curl==text->sell && text->curcselc)) { + if (txt_get_span(text->curl, text->sell) > 0 || + (text->curl == text->sell && text->curc < text->selc)) { txt_curs_swap(text); } if (!undoing) txt_undo_add_toop(text, UNDO_STO, - txt_get_span(text->lines.first, text->sell), - text->selc, - txt_get_span(text->lines.first, text->curl), - text->curc); + txt_get_span(text->lines.first, text->sell), + text->selc, + txt_get_span(text->lines.first, text->curl), + text->curc); txt_pop_sel(text); } @@ -1172,8 +1172,8 @@ static void txt_pop_last (Text *text) void txt_pop_sel(Text *text) { - text->sell= text->curl; - text->selc= text->curc; + text->sell = text->curl; + text->selc = text->curc; } void txt_order_cursors(Text *text) @@ -1182,7 +1182,7 @@ void txt_order_cursors(Text *text) if (!text->curl) return; if (!text->sell) return; - /* Flip so text->curl is before text->sell */ + /* Flip so text->curl is before text->sell */ if ((txt_get_span(text->curl, text->sell) < 0) || (text->curl == text->sell && text->curc > text->selc)) { @@ -1192,10 +1192,10 @@ void txt_order_cursors(Text *text) int txt_has_sel(Text *text) { - return ((text->curl!=text->sell) || (text->curc!=text->selc)); + return ((text->curl != text->sell) || (text->curc != text->selc)); } -static void txt_delete_sel (Text *text) +static void txt_delete_sel(Text *text) { TextLine *tmpl; TextMarker *mrk; @@ -1211,62 +1211,62 @@ static void txt_delete_sel (Text *text) txt_order_cursors(text); if (!undoing) { - buf= txt_sel_to_buf(text); + buf = txt_sel_to_buf(text); txt_undo_add_block(text, UNDO_DBLOCK, buf); MEM_freeN(buf); } - buf= MEM_mallocN(text->curc+(text->sell->len - text->selc)+1, "textline_string"); + buf = MEM_mallocN(text->curc + (text->sell->len - text->selc) + 1, "textline_string"); if (text->curl != text->sell) { txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0, 0); - move= txt_get_span(text->curl, text->sell); + move = txt_get_span(text->curl, text->sell); } else { - mrk= txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0); if (mrk && (mrk->start > text->curc || mrk->end < text->selc)) txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0, 0); - move= 0; + move = 0; } - mrk= txt_find_marker_region(text, text->sell, text->selc-1, text->sell->len, 0, 0); + mrk = txt_find_marker_region(text, text->sell, text->selc - 1, text->sell->len, 0, 0); if (mrk) { - lineno= mrk->lineno; + lineno = mrk->lineno; do { mrk->lineno -= move; if (mrk->start > text->curc) mrk->start -= text->selc - text->curc; mrk->end -= text->selc - text->curc; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } strncpy(buf, text->curl->line, text->curc); - strcpy(buf+text->curc, text->sell->line + text->selc); - buf[text->curc+(text->sell->len - text->selc)]=0; + strcpy(buf + text->curc, text->sell->line + text->selc); + buf[text->curc + (text->sell->len - text->selc)] = 0; make_new_line(text->curl, buf); - tmpl= text->sell; + tmpl = text->sell; while (tmpl != text->curl) { - tmpl= tmpl->prev; + tmpl = tmpl->prev; if (!tmpl) break; txt_delete_line(text, tmpl->next); } - text->sell= text->curl; - text->selc= text->curc; + text->sell = text->curl; + text->selc = text->curc; } void txt_sel_all(Text *text) { if (!text) return; - text->curl= text->lines.first; - text->curc= 0; + text->curl = text->lines.first; + text->curc = 0; - text->sell= text->lines.last; - text->selc= text->sell->len; + text->sell = text->lines.last; + text->selc = text->sell->len; } void txt_sel_line(Text *text) @@ -1274,16 +1274,16 @@ void txt_sel_line(Text *text) if (!text) return; if (!text->curl) return; - text->curc= 0; - text->sell= text->curl; - text->selc= text->sell->len; + text->curc = 0; + text->sell = text->curl; + text->selc = text->sell->len; } /***************************/ /* Cut and paste functions */ /***************************/ -char *txt_to_buf (Text *text) +char *txt_to_buf(Text *text) { int length; TextLine *tmp, *linef, *linel; @@ -1295,53 +1295,53 @@ char *txt_to_buf (Text *text) if (!text->sell) return NULL; if (!text->lines.first) return NULL; - linef= text->lines.first; - charf= 0; + linef = text->lines.first; + charf = 0; - linel= text->lines.last; - charl= linel->len; + linel = text->lines.last; + charl = linel->len; if (linef == text->lines.last) { - length= charl-charf; + length = charl - charf; - buf= MEM_mallocN(length+2, "text buffer"); + buf = MEM_mallocN(length + 2, "text buffer"); - BLI_strncpy(buf, linef->line + charf, length+1); - buf[length]=0; + BLI_strncpy(buf, linef->line + charf, length + 1); + buf[length] = 0; } else { - length= linef->len - charf; - length+= charl; - length+= 2; /* For the 2 '\n' */ + length = linef->len - charf; + length += charl; + length += 2; /* For the 2 '\n' */ - tmp= linef->next; - while (tmp && tmp!= linel) { - length+= tmp->len+1; - tmp= tmp->next; + tmp = linef->next; + while (tmp && tmp != linel) { + length += tmp->len + 1; + tmp = tmp->next; } - buf= MEM_mallocN(length+1, "cut buffer"); + buf = MEM_mallocN(length + 1, "cut buffer"); - strncpy(buf, linef->line + charf, linef->len-charf); - length= linef->len - charf; + strncpy(buf, linef->line + charf, linef->len - charf); + length = linef->len - charf; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= linef->next; - while (tmp && tmp!=linel) { - strncpy(buf+length, tmp->line, tmp->len); - length+= tmp->len; + tmp = linef->next; + while (tmp && tmp != linel) { + strncpy(buf + length, tmp->line, tmp->len); + length += tmp->len; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= tmp->next; + tmp = tmp->next; } - strncpy(buf+length, linel->line, charl); - length+= charl; + strncpy(buf + length, linel->line, charl); + length += charl; /* python compiler wants an empty end line */ - buf[length++]='\n'; - buf[length]=0; + buf[length++] = '\n'; + buf[length] = 0; } return buf; @@ -1350,34 +1350,34 @@ char *txt_to_buf (Text *text) int txt_find_string(Text *text, const char *findstr, int wrap, int match_case) { TextLine *tl, *startl; - char *s= NULL; + char *s = NULL; if (!text || !text->curl || !text->sell) return 0; txt_order_cursors(text); - tl= startl= text->sell; + tl = startl = text->sell; - if (match_case) s= strstr(&tl->line[text->selc], findstr); - else s= BLI_strcasestr(&tl->line[text->selc], findstr); + if (match_case) s = strstr(&tl->line[text->selc], findstr); + else s = BLI_strcasestr(&tl->line[text->selc], findstr); while (!s) { - tl= tl->next; + tl = tl->next; if (!tl) { if (wrap) - tl= text->lines.first; + tl = text->lines.first; else break; } - if (match_case) s= strstr(tl->line, findstr); - else s= BLI_strcasestr(tl->line, findstr); - if (tl==startl) + if (match_case) s = strstr(tl->line, findstr); + else s = BLI_strcasestr(tl->line, findstr); + if (tl == startl) break; } if (s) { - int newl= txt_get_span(text->lines.first, tl); - int newc= (int)(s-tl->line); + int newl = txt_get_span(text->lines.first, tl); + int newc = (int)(s - tl->line); txt_move_to(text, newl, newc, 0); txt_move_to(text, newl, newc + strlen(findstr), 1); return 1; @@ -1386,10 +1386,10 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case) return 0; } -char *txt_sel_to_buf (Text *text) +char *txt_sel_to_buf(Text *text) { char *buf; - int length=0; + int length = 0; TextLine *tmp, *linef, *linel; int charf, charl; @@ -1397,71 +1397,71 @@ char *txt_sel_to_buf (Text *text) if (!text->curl) return NULL; if (!text->sell) return NULL; - if (text->curl==text->sell) { - linef= linel= text->curl; + if (text->curl == text->sell) { + linef = linel = text->curl; if (text->curc < text->selc) { - charf= text->curc; - charl= text->selc; + charf = text->curc; + charl = text->selc; } else { - charf= text->selc; - charl= text->curc; + charf = text->selc; + charl = text->curc; } } - else if (txt_get_span(text->curl, text->sell)<0) { - linef= text->sell; - linel= text->curl; + else if (txt_get_span(text->curl, text->sell) < 0) { + linef = text->sell; + linel = text->curl; - charf= text->selc; - charl= text->curc; + charf = text->selc; + charl = text->curc; } else { - linef= text->curl; - linel= text->sell; + linef = text->curl; + linel = text->sell; - charf= text->curc; - charl= text->selc; + charf = text->curc; + charl = text->selc; } if (linef == linel) { - length= charl-charf; + length = charl - charf; - buf= MEM_mallocN(length+1, "sel buffer"); + buf = MEM_mallocN(length + 1, "sel buffer"); - BLI_strncpy(buf, linef->line + charf, length+1); + BLI_strncpy(buf, linef->line + charf, length + 1); } else { - length+= linef->len - charf; - length+= charl; + length += linef->len - charf; + length += charl; length++; /* For the '\n' */ - tmp= linef->next; - while (tmp && tmp!= linel) { - length+= tmp->len+1; - tmp= tmp->next; + tmp = linef->next; + while (tmp && tmp != linel) { + length += tmp->len + 1; + tmp = tmp->next; } - buf= MEM_mallocN(length+1, "sel buffer"); + buf = MEM_mallocN(length + 1, "sel buffer"); - strncpy(buf, linef->line+ charf, linef->len-charf); - length= linef->len-charf; + strncpy(buf, linef->line + charf, linef->len - charf); + length = linef->len - charf; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= linef->next; - while (tmp && tmp!=linel) { - strncpy(buf+length, tmp->line, tmp->len); - length+= tmp->len; + tmp = linef->next; + while (tmp && tmp != linel) { + strncpy(buf + length, tmp->line, tmp->len); + length += tmp->len; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= tmp->next; + tmp = tmp->next; } - strncpy(buf+length, linel->line, charl); - length+= charl; + strncpy(buf + length, linel->line, charl); + length += charl; - buf[length]=0; + buf[length] = 0; } return buf; @@ -1471,16 +1471,16 @@ static void txt_shift_markers(Text *text, int lineno, int count) { TextMarker *marker; - for (marker=text->markers.first; marker; marker= marker->next) - if (marker->lineno>=lineno) { - marker->lineno+= count; + for (marker = text->markers.first; marker; marker = marker->next) + if (marker->lineno >= lineno) { + marker->lineno += count; } } void txt_insert_buf(Text *text, const char *in_buffer) { - int l=0, u, len, lineno= -1, count= 0; - size_t i=0, j; + int l = 0, u, len, lineno = -1, count = 0; + size_t i = 0, j; TextLine *add; char *buffer; @@ -1489,35 +1489,35 @@ void txt_insert_buf(Text *text, const char *in_buffer) txt_delete_sel(text); - len= strlen(in_buffer); - buffer= BLI_strdupn(in_buffer, len); - len+= txt_extended_ascii_as_utf8(&buffer); + len = strlen(in_buffer); + buffer = BLI_strdupn(in_buffer, len); + len += txt_extended_ascii_as_utf8(&buffer); if (!undoing) txt_undo_add_block(text, UNDO_IBLOCK, buffer); - u= undoing; - undoing= 1; + u = undoing; + undoing = 1; /* Read the first line (or as close as possible */ - while (buffer[i] && buffer[i]!='\n') + while (buffer[i] && buffer[i] != '\n') txt_add_raw_char(text, BLI_str_utf8_as_unicode_step(buffer, &i)); - if (buffer[i]=='\n') txt_split_curline(text); + if (buffer[i] == '\n') txt_split_curline(text); else { undoing = u; MEM_freeN(buffer); return; } i++; /* Read as many full lines as we can */ - lineno= txt_get_span(text->lines.first, text->curl); + lineno = txt_get_span(text->lines.first, text->curl); - while (ilines, text->curl, add); i++; count++; @@ -1525,10 +1525,10 @@ void txt_insert_buf(Text *text, const char *in_buffer) else { if (count) { txt_shift_markers(text, lineno, count); - count= 0; + count = 0; } - for (j= i-l; jundo_pos+x >= text->undo_len) { - if (text->undo_len*2 > TXT_MAX_UNDO) { + while (text->undo_pos + x >= text->undo_len) { + if (text->undo_len * 2 > TXT_MAX_UNDO) { /* XXX error("Undo limit reached, buffer cleared\n"); */ MEM_freeN(text->undo_buf); init_undo_text(text); return 0; } else { - void *tmp= text->undo_buf; - text->undo_buf= MEM_callocN(text->undo_len*2, "undo buf"); + void *tmp = text->undo_buf; + text->undo_buf = MEM_callocN(text->undo_len * 2, "undo buf"); memcpy(text->undo_buf, tmp, text->undo_len); - text->undo_len*=2; + text->undo_len *= 2; MEM_freeN(tmp); } } @@ -1570,218 +1570,218 @@ static int max_undo_test(Text *text, int x) static void dump_buffer(Text *text) { - int i= 0; + int i = 0; - while (i++undo_pos) printf("%d: %d %c\n", i, text->undo_buf[i], text->undo_buf[i]); + while (i++ < text->undo_pos) printf("%d: %d %c\n", i, text->undo_buf[i], text->undo_buf[i]); } void txt_print_undo(Text *text) { - int i= 0; + int i = 0; int op; const char *ops; int linep, charp; dump_buffer(text); - printf ("---< Undo Buffer >---\n"); + printf("---< Undo Buffer >---\n"); - printf ("UndoPosition is %d\n", text->undo_pos); + printf("UndoPosition is %d\n", text->undo_pos); - while (i<=text->undo_pos) { - op= text->undo_buf[i]; + while (i <= text->undo_pos) { + op = text->undo_buf[i]; - if (op==UNDO_CLEFT) { - ops= "Cursor left"; + if (op == UNDO_CLEFT) { + ops = "Cursor left"; } - else if (op==UNDO_CRIGHT) { - ops= "Cursor right"; + else if (op == UNDO_CRIGHT) { + ops = "Cursor right"; } - else if (op==UNDO_CUP) { - ops= "Cursor up"; + else if (op == UNDO_CUP) { + ops = "Cursor up"; } - else if (op==UNDO_CDOWN) { - ops= "Cursor down"; + else if (op == UNDO_CDOWN) { + ops = "Cursor down"; } - else if (op==UNDO_SLEFT) { - ops= "Selection left"; + else if (op == UNDO_SLEFT) { + ops = "Selection left"; } - else if (op==UNDO_SRIGHT) { - ops= "Selection right"; + else if (op == UNDO_SRIGHT) { + ops = "Selection right"; } - else if (op==UNDO_SUP) { - ops= "Selection up"; + else if (op == UNDO_SUP) { + ops = "Selection up"; } - else if (op==UNDO_SDOWN) { - ops= "Selection down"; + else if (op == UNDO_SDOWN) { + ops = "Selection down"; } - else if (op==UNDO_STO) { - ops= "Selection "; + else if (op == UNDO_STO) { + ops = "Selection "; } - else if (op==UNDO_CTO) { - ops= "Cursor "; + else if (op == UNDO_CTO) { + ops = "Cursor "; } - else if (op==UNDO_INSERT_1) { - ops= "Insert ascii "; + else if (op == UNDO_INSERT_1) { + ops = "Insert ascii "; } - else if (op==UNDO_INSERT_2) { - ops= "Insert 2 bytes "; + else if (op == UNDO_INSERT_2) { + ops = "Insert 2 bytes "; } - else if (op==UNDO_INSERT_3) { - ops= "Insert 3 bytes "; + else if (op == UNDO_INSERT_3) { + ops = "Insert 3 bytes "; } - else if (op==UNDO_INSERT_4) { - ops= "Insert unicode "; + else if (op == UNDO_INSERT_4) { + ops = "Insert unicode "; } - else if (op==UNDO_BS_1) { - ops= "Backspace for ascii "; + else if (op == UNDO_BS_1) { + ops = "Backspace for ascii "; } - else if (op==UNDO_BS_2) { - ops= "Backspace for 2 bytes "; + else if (op == UNDO_BS_2) { + ops = "Backspace for 2 bytes "; } - else if (op==UNDO_BS_3) { - ops= "Backspace for 3 bytes "; + else if (op == UNDO_BS_3) { + ops = "Backspace for 3 bytes "; } - else if (op==UNDO_BS_4) { - ops= "Backspace for unicode "; + else if (op == UNDO_BS_4) { + ops = "Backspace for unicode "; } - else if (op==UNDO_DEL_1) { - ops= "Delete ascii "; + else if (op == UNDO_DEL_1) { + ops = "Delete ascii "; } - else if (op==UNDO_DEL_2) { - ops= "Delete 2 bytes "; + else if (op == UNDO_DEL_2) { + ops = "Delete 2 bytes "; } - else if (op==UNDO_DEL_3) { - ops= "Delete 3 bytes "; + else if (op == UNDO_DEL_3) { + ops = "Delete 3 bytes "; } - else if (op==UNDO_DEL_4) { - ops= "Delete unicode "; + else if (op == UNDO_DEL_4) { + ops = "Delete unicode "; } - else if (op==UNDO_SWAP) { - ops= "Cursor swap"; + else if (op == UNDO_SWAP) { + ops = "Cursor swap"; } - else if (op==UNDO_DBLOCK) { - ops= "Delete text block"; + else if (op == UNDO_DBLOCK) { + ops = "Delete text block"; } - else if (op==UNDO_IBLOCK) { - ops= "Insert text block"; + else if (op == UNDO_IBLOCK) { + ops = "Insert text block"; } - else if (op==UNDO_INDENT) { - ops= "Indent "; + else if (op == UNDO_INDENT) { + ops = "Indent "; } - else if (op==UNDO_UNINDENT) { - ops= "Unindent "; + else if (op == UNDO_UNINDENT) { + ops = "Unindent "; } - else if (op==UNDO_COMMENT) { - ops= "Comment "; + else if (op == UNDO_COMMENT) { + ops = "Comment "; } - else if (op==UNDO_UNCOMMENT) { - ops= "Uncomment "; + else if (op == UNDO_UNCOMMENT) { + ops = "Uncomment "; } else { - ops= "Unknown"; + ops = "Unknown"; } - printf ("Op (%o) at %d = %s", op, i, ops); + printf("Op (%o) at %d = %s", op, i, ops); if (op >= UNDO_INSERT_1 && op <= UNDO_DEL_4) { i++; - printf (" - Char is "); + printf(" - Char is "); switch (op) { case UNDO_INSERT_1: case UNDO_BS_1: case UNDO_DEL_1: - printf ("%c", text->undo_buf[i]); + printf("%c", text->undo_buf[i]); i++; break; case UNDO_INSERT_2: case UNDO_BS_2: case UNDO_DEL_2: - printf ("%c%c", text->undo_buf[i], text->undo_buf[i+1]); - i+=2; + printf("%c%c", text->undo_buf[i], text->undo_buf[i + 1]); + i += 2; break; case UNDO_INSERT_3: case UNDO_BS_3: case UNDO_DEL_3: - printf ("%c%c%c", text->undo_buf[i], text->undo_buf[i+1], text->undo_buf[i+2]); - i+=3; + printf("%c%c%c", text->undo_buf[i], text->undo_buf[i + 1], text->undo_buf[i + 2]); + i += 3; break; case UNDO_INSERT_4: case UNDO_BS_4: case UNDO_DEL_4: { unsigned int uc; - char c[BLI_UTF8_MAX+1]; + char c[BLI_UTF8_MAX + 1]; size_t c_len; - uc= text->undo_buf[i]; i++; - uc= uc+(text->undo_buf[i]<<8); i++; - uc= uc+(text->undo_buf[i]<<16); i++; - uc= uc+(text->undo_buf[i]<<24); i++; - c_len= BLI_str_utf8_from_unicode(uc, c); - c[c_len]= '\0'; + uc = text->undo_buf[i]; i++; + uc = uc + (text->undo_buf[i] << 8); i++; + uc = uc + (text->undo_buf[i] << 16); i++; + uc = uc + (text->undo_buf[i] << 24); i++; + c_len = BLI_str_utf8_from_unicode(uc, c); + c[c_len] = '\0'; puts(c); } } } - else if (op==UNDO_STO || op==UNDO_CTO) { + else if (op == UNDO_STO || op == UNDO_CTO) { i++; - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("to <%d, %d> ", linep, charp); + printf("to <%d, %d> ", linep, charp); - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("from <%d, %d>", linep, charp); + printf("from <%d, %d>", linep, charp); } - else if (op==UNDO_DBLOCK || op==UNDO_IBLOCK) { + else if (op == UNDO_DBLOCK || op == UNDO_IBLOCK) { i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf (" (length %d) <", linep); + printf(" (length %d) <", linep); - while (linep>0) { + while (linep > 0) { putchar(text->undo_buf[i]); linep--; i++; } - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; - printf ("> (%d)", linep); + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; + printf("> (%d)", linep); } - else if (op==UNDO_INDENT || op==UNDO_UNINDENT) { + else if (op == UNDO_INDENT || op == UNDO_UNINDENT) { i++; - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("to <%d, %d> ", linep, charp); + printf("to <%d, %d> ", linep, charp); - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("from <%d, %d>", linep, charp); + printf("from <%d, %d>", linep, charp); } - printf (" %d\n", i); + printf(" %d\n", i); i++; } } @@ -1792,50 +1792,50 @@ static void txt_undo_add_op(Text *text, int op) return; text->undo_pos++; - text->undo_buf[text->undo_pos]= op; - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos] = op; + text->undo_buf[text->undo_pos + 1] = 0; } static void txt_undo_store_uint16(char *undo_buf, int *undo_pos, unsigned short value) { - undo_buf[*undo_pos]= (value)&0xff; + undo_buf[*undo_pos] = (value) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>8)&0xff; + undo_buf[*undo_pos] = (value >> 8) & 0xff; (*undo_pos)++; } static void txt_undo_store_uint32(char *undo_buf, int *undo_pos, unsigned int value) { - undo_buf[*undo_pos]= (value)&0xff; + undo_buf[*undo_pos] = (value) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>8)&0xff; + undo_buf[*undo_pos] = (value >> 8) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>16)&0xff; + undo_buf[*undo_pos] = (value >> 16) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>24)&0xff; + undo_buf[*undo_pos] = (value >> 24) & 0xff; (*undo_pos)++; } static void txt_undo_add_block(Text *text, int op, const char *buf) { - unsigned int length= strlen(buf); + unsigned int length = strlen(buf); - if (!max_undo_test(text, length+11)) + if (!max_undo_test(text, length + 11)) return; text->undo_pos++; - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; text->undo_pos++; txt_undo_store_uint32(text->undo_buf, &text->undo_pos, length); - strncpy(text->undo_buf+text->undo_pos, buf, length); - text->undo_pos+=length; + strncpy(text->undo_buf + text->undo_pos, buf, length); + text->undo_pos += length; txt_undo_store_uint32(text->undo_buf, &text->undo_pos, length); - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos + 1] = 0; } void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc) @@ -1843,10 +1843,10 @@ void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fr if (!max_undo_test(text, 15)) return; - if (froml==tol && fromc==toc) return; + if (froml == tol && fromc == toc) return; text->undo_pos++; - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; text->undo_pos++; @@ -1855,9 +1855,9 @@ void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fr txt_undo_store_uint16(text->undo_buf, &text->undo_pos, toc); txt_undo_store_uint32(text->undo_buf, &text->undo_pos, tol); - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos + 1] = 0; } static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) @@ -1871,48 +1871,48 @@ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) text->undo_pos++; if (utf8_size < 4) { - text->undo_buf[text->undo_pos]= op_start + utf8_size - 1; + text->undo_buf[text->undo_pos] = op_start + utf8_size - 1; text->undo_pos++; for (i = 0; i < utf8_size; i++) { - text->undo_buf[text->undo_pos]= utf8[i]; + text->undo_buf[text->undo_pos] = utf8[i]; text->undo_pos++; } - text->undo_buf[text->undo_pos]= op_start + utf8_size - 1; + text->undo_buf[text->undo_pos] = op_start + utf8_size - 1; } else { - text->undo_buf[text->undo_pos]= op_start + 3; + text->undo_buf[text->undo_pos] = op_start + 3; text->undo_pos++; txt_undo_store_uint32(text->undo_buf, &text->undo_pos, c); - text->undo_buf[text->undo_pos]= op_start + 3; + text->undo_buf[text->undo_pos] = op_start + 3; } - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos + 1] = 0; } static unsigned short txt_undo_read_uint16(const char *undo_buf, int *undo_pos) { unsigned short val; - val= undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; + val = undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; return val; } static unsigned int txt_undo_read_uint32(const char *undo_buf, int *undo_pos) { unsigned int val; - val= undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; + val = undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; return val; } static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, short bytes) { unsigned int unicode; - char utf8[BLI_UTF8_MAX+1]; + char utf8[BLI_UTF8_MAX + 1]; switch (bytes) { case 1: /* ascii */ @@ -1922,21 +1922,21 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s utf8[2] = '\0'; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)--; utf8[0] = undo_buf[*undo_pos]; (*undo_pos)--; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 3: /* 3-byte symbol */ utf8[3] = '\0'; utf8[2] = undo_buf[*undo_pos]; (*undo_pos)--; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)--; utf8[0] = undo_buf[*undo_pos]; (*undo_pos)--; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 4: /* 32-bit unicode symbol */ - unicode= txt_undo_read_uint32(undo_buf, undo_pos); + unicode = txt_undo_read_uint32(undo_buf, undo_pos); default: /* should never happen */ BLI_assert(0); - unicode= 0; + unicode = 0; } return unicode; @@ -1946,24 +1946,24 @@ static unsigned short txt_redo_read_uint16(const char *undo_buf, int *undo_pos) { unsigned short val; val = undo_buf[*undo_pos]; (*undo_pos)++; - val = val+(undo_buf[*undo_pos]<<8); (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 8); (*undo_pos)++; return val; } static unsigned int txt_redo_read_uint32(const char *undo_buf, int *undo_pos) { unsigned int val; - val= undo_buf[*undo_pos]; (*undo_pos)++; - val= val+(undo_buf[*undo_pos]<<8); (*undo_pos)++; - val= val+(undo_buf[*undo_pos]<<16); (*undo_pos)++; - val= val+(undo_buf[*undo_pos]<<24); (*undo_pos)++; + val = undo_buf[*undo_pos]; (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 8); (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 16); (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 24); (*undo_pos)++; return val; } static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, short bytes) { unsigned int unicode; - char utf8[BLI_UTF8_MAX+1]; + char utf8[BLI_UTF8_MAX + 1]; switch (bytes) { case 1: /* ascii */ @@ -1973,21 +1973,21 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s utf8[0] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[2] = '\0'; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 3: /* 3-byte symbol */ utf8[0] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[2] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[3] = '\0'; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 4: /* 32-bit unicode symbol */ - unicode= txt_undo_read_uint32(undo_buf, undo_pos); + unicode = txt_undo_read_uint32(undo_buf, undo_pos); default: /* should never happen */ BLI_assert(0); - unicode= 0; + unicode = 0; } return unicode; @@ -1995,20 +1995,20 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s void txt_do_undo(Text *text) { - int op= text->undo_buf[text->undo_pos]; + int op = text->undo_buf[text->undo_pos]; unsigned int linep, i; unsigned short charp; TextLine *holdl; int holdc, holdln; char *buf; - if (text->undo_pos<0) { + if (text->undo_pos < 0) { return; } text->undo_pos--; - undoing= 1; + undoing = 1; switch (op) { case UNDO_CLEFT: @@ -2053,17 +2053,17 @@ void txt_do_undo(Text *text) text->undo_pos--; text->undo_pos--; - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - charp= txt_undo_read_uint16(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); - if (op==UNDO_CTO) { + if (op == UNDO_CTO) { txt_move_toline(text, linep, 0); - text->curc= charp; + text->curc = charp; txt_pop_sel(text); } else { txt_move_toline(text, linep, 1); - text->selc= charp; + text->selc = charp; } text->undo_pos--; @@ -2071,7 +2071,7 @@ void txt_do_undo(Text *text) case UNDO_INSERT_1: case UNDO_INSERT_2: case UNDO_INSERT_3: case UNDO_INSERT_4: txt_backspace_char(text); - text->undo_pos-= op - UNDO_INSERT_1 + 1; + text->undo_pos -= op - UNDO_INSERT_1 + 1; text->undo_pos--; break; @@ -2093,29 +2093,29 @@ void txt_do_undo(Text *text) break; case UNDO_DBLOCK: - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - buf= MEM_mallocN(linep+1, "dblock buffer"); - for (i=0; i < linep; i++) { - buf[(linep-1)-i]= text->undo_buf[text->undo_pos]; + buf = MEM_mallocN(linep + 1, "dblock buffer"); + for (i = 0; i < linep; i++) { + buf[(linep - 1) - i] = text->undo_buf[text->undo_pos]; text->undo_pos--; } - buf[i]= 0; + buf[i] = 0; txt_curs_first(text, &holdl, &holdc); - holdln= txt_get_span(text->lines.first, holdl); + holdln = txt_get_span(text->lines.first, holdl); txt_insert_buf(text, buf); MEM_freeN(buf); - text->curl= text->lines.first; - while (holdln>0) { + text->curl = text->lines.first; + while (holdln > 0) { if (text->curl->next) - text->curl= text->curl->next; + text->curl = text->curl->next; holdln--; } - text->curc= holdc; + text->curc = holdc; text->undo_pos--; text->undo_pos--; @@ -2127,20 +2127,20 @@ void txt_do_undo(Text *text) break; case UNDO_IBLOCK: - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + 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++) { - buf[(linep-1)-i]= text->undo_buf[text->undo_pos]; + buf = MEM_mallocN(linep + 1, "iblock buffer"); + for (i = 0; i < linep; i++) { + buf[(linep - 1) - i] = text->undo_buf[text->undo_pos]; text->undo_pos--; } - buf[i]= 0; - linep= txt_utf8_len(buf); + buf[i] = 0; + linep = txt_utf8_len(buf); MEM_freeN(buf); - while (linep>0) { + while (linep > 0) { txt_backspace_char(text); linep--; } @@ -2157,7 +2157,7 @@ void txt_do_undo(Text *text) case UNDO_UNINDENT: case UNDO_COMMENT: case UNDO_UNCOMMENT: - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); //linep is now the end line of the selection charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); @@ -2166,11 +2166,11 @@ void txt_do_undo(Text *text) //set the selection for this now text->selc = charp; text->sell = text->lines.first; - for (i= 0; i < linep; i++) { + for (i = 0; i < linep; i++) { text->sell = text->sell->next; } - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); //first line to be selected charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); @@ -2182,10 +2182,10 @@ void txt_do_undo(Text *text) } - if (op==UNDO_INDENT) { + if (op == UNDO_INDENT) { txt_unindent(text); } - else if (op== UNDO_UNINDENT) { + else if (op == UNDO_UNINDENT) { txt_indent(text); } else if (op == UNDO_COMMENT) { @@ -2208,13 +2208,13 @@ void txt_do_undo(Text *text) break; default: //XXX error("Undo buffer error - resetting"); - text->undo_pos= -1; + text->undo_pos = -1; break; } /* next undo step may need evaluating */ - if (text->undo_pos>=0) { + if (text->undo_pos >= 0) { switch (text->undo_buf[text->undo_pos]) { case UNDO_STO: txt_do_undo(text); @@ -2226,7 +2226,7 @@ void txt_do_undo(Text *text) } } - undoing= 0; + undoing = 0; } void txt_do_redo(Text *text) @@ -2237,14 +2237,14 @@ void txt_do_redo(Text *text) char *buf; text->undo_pos++; - op= text->undo_buf[text->undo_pos]; + op = text->undo_buf[text->undo_pos]; if (!op) { text->undo_pos--; return; } - undoing= 1; + undoing = 1; switch (op) { case UNDO_CLEFT: @@ -2288,13 +2288,13 @@ void txt_do_redo(Text *text) case UNDO_BS_1: case UNDO_BS_2: case UNDO_BS_3: case UNDO_BS_4: text->undo_pos++; txt_backspace_char(text); - text->undo_pos+= op - UNDO_BS_1 + 1; + text->undo_pos += op - UNDO_BS_1 + 1; break; case UNDO_DEL_1: case UNDO_DEL_2: case UNDO_DEL_3: case UNDO_DEL_4: text->undo_pos++; txt_delete_char(text); - text->undo_pos+= op - UNDO_DEL_1 + 1; + text->undo_pos += op - UNDO_DEL_1 + 1; break; case UNDO_SWAP: @@ -2314,27 +2314,27 @@ void txt_do_redo(Text *text) text->undo_pos++; - charp= txt_redo_read_uint16(text->undo_buf, &text->undo_pos); - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - if (op==UNDO_CTO) { + if (op == UNDO_CTO) { txt_move_toline(text, linep, 0); - text->curc= charp; + text->curc = charp; txt_pop_sel(text); } else { txt_move_toline(text, linep, 1); - text->selc= charp; + text->selc = charp; } break; case UNDO_DBLOCK: text->undo_pos++; - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); txt_delete_sel(text); - text->undo_pos+=linep; + text->undo_pos += linep; text->undo_pos++; text->undo_pos++; @@ -2345,12 +2345,12 @@ void txt_do_redo(Text *text) case UNDO_IBLOCK: text->undo_pos++; - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - buf= MEM_mallocN(linep+1, "iblock buffer"); - memcpy (buf, &text->undo_buf[text->undo_pos], linep); - text->undo_pos+= linep; - buf[linep]= 0; + buf = MEM_mallocN(linep + 1, "iblock buffer"); + memcpy(buf, &text->undo_buf[text->undo_pos], linep); + text->undo_pos += linep; + buf[linep] = 0; txt_insert_buf(text, buf); MEM_freeN(buf); @@ -2369,19 +2369,19 @@ void txt_do_redo(Text *text) charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); //charp is the first char selected or 0 - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); //linep is now the first line of the selection //set the selcetion for this now text->curc = charp; text->curl = text->lines.first; - for (i= 0; i < linep; i++) { + for (i = 0; i < linep; i++) { text->curl = text->curl->next; } charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); //last postion to be selected - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); //Last line to be selected text->selc = charp; @@ -2390,10 +2390,10 @@ void txt_do_redo(Text *text) text->sell = text->sell->next; } - if (op==UNDO_INDENT) { + if (op == UNDO_INDENT) { txt_indent(text); } - else if (op== UNDO_UNINDENT) { + else if (op == UNDO_UNINDENT) { txt_unindent(text); } else if (op == UNDO_COMMENT) { @@ -2414,12 +2414,12 @@ void txt_do_redo(Text *text) break; default: //XXX error("Undo buffer error - resetting"); - text->undo_pos= -1; + text->undo_pos = -1; break; } - undoing= 0; + undoing = 0; } /**************************/ @@ -2431,7 +2431,7 @@ void txt_split_curline(Text *text) TextLine *ins; TextMarker *mrk; char *left, *right; - int lineno= -1; + int lineno = -1; if (!text) return; if (!text->curl) return; @@ -2440,10 +2440,10 @@ void txt_split_curline(Text *text) /* Move markers */ - lineno= txt_get_span(text->lines.first, text->curl); - mrk= text->markers.first; + lineno = txt_get_span(text->lines.first, text->curl); + mrk = text->markers.first; while (mrk) { - if (mrk->lineno==lineno && mrk->start>text->curc) { + if (mrk->lineno == lineno && mrk->start > text->curc) { mrk->lineno++; mrk->start -= text->curc; mrk->end -= text->curc; @@ -2451,35 +2451,35 @@ void txt_split_curline(Text *text) else if (mrk->lineno > lineno) { mrk->lineno++; } - mrk= mrk->next; + mrk = mrk->next; } /* Make the two half strings */ - left= MEM_mallocN(text->curc+1, "textline_string"); + left = MEM_mallocN(text->curc + 1, "textline_string"); if (text->curc) memcpy(left, text->curl->line, text->curc); - left[text->curc]=0; + left[text->curc] = 0; - right= MEM_mallocN(text->curl->len - text->curc+1, "textline_string"); - memcpy(right, text->curl->line+text->curc, text->curl->len-text->curc+1); + right = MEM_mallocN(text->curl->len - text->curc + 1, "textline_string"); + memcpy(right, text->curl->line + text->curc, text->curl->len - text->curc + 1); MEM_freeN(text->curl->line); if (text->curl->format) MEM_freeN(text->curl->format); /* Make the new TextLine */ - ins= MEM_mallocN(sizeof(TextLine), "textline"); - ins->line= left; - ins->format= NULL; - ins->len= text->curc; - - text->curl->line= right; - text->curl->format= NULL; - text->curl->len= text->curl->len - text->curc; + ins = MEM_mallocN(sizeof(TextLine), "textline"); + ins->line = left; + ins->format = NULL; + ins->len = text->curc; + + text->curl->line = right; + text->curl->format = NULL; + text->curl->len = text->curl->len - text->curc; BLI_insertlinkbefore(&text->lines, text->curl, ins); - text->curc=0; + text->curc = 0; txt_make_dirty(text); txt_clean_text(text); @@ -2488,26 +2488,26 @@ void txt_split_curline(Text *text) if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, '\n'); } -static void txt_delete_line (Text *text, TextLine *line) +static void txt_delete_line(Text *text, TextLine *line) { - TextMarker *mrk=NULL, *nxt; - int lineno= -1; + TextMarker *mrk = NULL, *nxt; + int lineno = -1; if (!text) return; if (!text->curl) return; - lineno= txt_get_span(text->lines.first, line); - mrk= text->markers.first; + lineno = txt_get_span(text->lines.first, line); + mrk = text->markers.first; while (mrk) { - nxt= mrk->next; - if (mrk->lineno==lineno) + nxt = mrk->next; + if (mrk->lineno == lineno) BLI_freelinkN(&text->markers, mrk); else if (mrk->lineno > lineno) mrk->lineno--; - mrk= nxt; + mrk = nxt; } - BLI_remlink (&text->lines, line); + BLI_remlink(&text->lines, line); if (line->line) MEM_freeN(line->line); if (line->format) MEM_freeN(line->format); @@ -2518,29 +2518,29 @@ static void txt_delete_line (Text *text, TextLine *line) txt_clean_text(text); } -static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb) +static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) { char *tmp; - TextMarker *mrk= NULL; - int lineno=-1; + TextMarker *mrk = NULL; + int lineno = -1; if (!text) return; if (!linea || !lineb) return; - mrk= txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); + mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); if (mrk) { - lineno= mrk->lineno; + lineno = mrk->lineno; do { mrk->lineno--; mrk->start += linea->len; mrk->end += linea->len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } - if (lineno==-1) lineno= txt_get_span(text->lines.first, lineb); + if (lineno == -1) lineno = txt_get_span(text->lines.first, lineb); - tmp= MEM_mallocN(linea->len+lineb->len+1, "textline_string"); + tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string"); strcpy(tmp, linea->line); strcat(tmp, lineb->line); @@ -2572,7 +2572,7 @@ void txt_duplicate_line(Text *text) void txt_delete_char(Text *text) { - unsigned int c='\n'; + unsigned int c = '\n'; if (!text) return; if (!text->curl) return; @@ -2582,7 +2582,7 @@ void txt_delete_char(Text *text) txt_make_dirty(text); return; } - else if (text->curc== text->curl->len) { /* Appending two lines */ + else if (text->curc == text->curl->len) { /* Appending two lines */ if (text->curl->next) { txt_combine_lines(text, text->curl, text->curl->next); txt_pop_sel(text); @@ -2593,12 +2593,12 @@ void txt_delete_char(Text *text) else { /* Just deleting a char */ size_t c_len = 0; TextMarker *mrk; - c= BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len); + c = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len); - mrk= txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); if (mrk) { - int lineno= mrk->lineno; - if (mrk->end==text->curc) { + int lineno = mrk->lineno; + if (mrk->end == text->curc) { if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) { txt_clear_markers(text, mrk->group, TMARK_TEMP); } @@ -2608,15 +2608,15 @@ void txt_delete_char(Text *text) return; } do { - if (mrk->start>text->curc) mrk->start-= c_len; - mrk->end-= c_len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + if (mrk->start > text->curc) mrk->start -= c_len; + mrk->end -= c_len; + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } - memmove(text->curl->line+text->curc, text->curl->line+text->curc+c_len, text->curl->len-text->curc-c_len+1); + memmove(text->curl->line + text->curc, text->curl->line + text->curc + c_len, text->curl->len - text->curc - c_len + 1); - text->curl->len-= c_len; + text->curl->len -= c_len; txt_pop_sel(text); } @@ -2635,7 +2635,7 @@ void txt_delete_word(Text *text) void txt_backspace_char(Text *text) { - unsigned int c='\n'; + unsigned int c = '\n'; if (!text) return; if (!text->curl) return; @@ -2645,11 +2645,11 @@ void txt_backspace_char(Text *text) txt_make_dirty(text); return; } - else if (text->curc==0) { /* Appending two lines */ + else if (text->curc == 0) { /* Appending two lines */ if (!text->curl->prev) return; - text->curl= text->curl->prev; - text->curc= text->curl->len; + text->curl = text->curl->prev; + text->curc = text->curl->len; txt_combine_lines(text, text->curl, text->curl->next); txt_pop_sel(text); @@ -2658,12 +2658,12 @@ void txt_backspace_char(Text *text) size_t c_len = 0; TextMarker *mrk; char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc); - c= BLI_str_utf8_as_unicode_and_size(prev, &c_len); + c = BLI_str_utf8_as_unicode_and_size(prev, &c_len); - mrk= txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); if (mrk) { - int lineno= mrk->lineno; - if (mrk->start==text->curc) { + int lineno = mrk->lineno; + if (mrk->start == text->curc) { if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) { txt_clear_markers(text, mrk->group, TMARK_TEMP); } @@ -2673,10 +2673,10 @@ void txt_backspace_char(Text *text) return; } do { - if (mrk->start>text->curc - c_len) mrk->start-= c_len; - mrk->end-= c_len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + if (mrk->start > text->curc - c_len) mrk->start -= c_len; + mrk->end -= c_len; + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } /* source and destination overlap, don't use memcpy() */ @@ -2684,8 +2684,8 @@ void txt_backspace_char(Text *text) text->curl->line + text->curc, text->curl->len - text->curc + 1); - text->curl->len-= c_len; - text->curc-= c_len; + text->curl->len -= c_len; + text->curc -= c_len; txt_pop_sel(text); } @@ -2707,7 +2707,7 @@ void txt_backspace_word(Text *text) * Remember to change this string according to max tab size */ static char tab_to_spaces[] = " "; -static void txt_convert_tab_to_spaces (Text *text) +static void txt_convert_tab_to_spaces(Text *text) { /* sb aims to pad adjust the tab-width needed so that the right number of spaces * is added so that the indention of the line is the right width (i.e. aligned @@ -2717,7 +2717,7 @@ static void txt_convert_tab_to_spaces (Text *text) txt_insert_buf(text, sb); } -static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) +static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs) { int lineno; char *tmp, ch[BLI_UTF8_MAX]; @@ -2727,7 +2727,7 @@ static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) if (!text) return 0; if (!text->curl) return 0; - if (add=='\n') { + if (add == '\n') { txt_split_curline(text); return 1; } @@ -2741,25 +2741,25 @@ static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) txt_delete_sel(text); add_len = BLI_str_utf8_from_unicode(add, ch); - mrk= txt_find_marker_region(text, text->curl, text->curc-1, text->curl->len, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc - 1, text->curl->len, 0, 0); if (mrk) { - lineno= mrk->lineno; + lineno = mrk->lineno; do { - if (mrk->start>text->curc) mrk->start+= add_len; - mrk->end+= add_len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + if (mrk->start > text->curc) mrk->start += add_len; + mrk->end += add_len; + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } - tmp= MEM_mallocN(text->curl->len+add_len+1, "textline_string"); + tmp = MEM_mallocN(text->curl->len + add_len + 1, "textline_string"); memcpy(tmp, text->curl->line, text->curc); - memcpy(tmp+text->curc, ch, add_len); - memcpy(tmp+text->curc+add_len, text->curl->line+text->curc, text->curl->len-text->curc+1); + memcpy(tmp + text->curc, ch, add_len); + memcpy(tmp + text->curc + add_len, text->curl->line + text->curc, text->curl->len - text->curc + 1); make_new_line(text->curl, tmp); - text->curc+= add_len; + text->curc += add_len; txt_pop_sel(text); @@ -2796,30 +2796,30 @@ int txt_replace_char(Text *text, unsigned int add) if (!text->curl) return 0; /* If text is selected or we're at the end of the line just use txt_add_char */ - if (text->curc==text->curl->len || txt_has_sel(text) || add=='\n') { - int i= txt_add_char(text, add); - TextMarker *mrk= txt_find_marker(text, text->curl, text->curc, 0, 0); + if (text->curc == text->curl->len || txt_has_sel(text) || add == '\n') { + int i = txt_add_char(text, add); + TextMarker *mrk = txt_find_marker(text, text->curl, text->curc, 0, 0); if (mrk) BLI_freelinkN(&text->markers, mrk); return i; } - del= BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &del_size); - add_size= BLI_str_utf8_from_unicode(add, ch); + del = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &del_size); + add_size = BLI_str_utf8_from_unicode(add, ch); if (add_size > del_size) { - char *tmp= MEM_mallocN(text->curl->len+add_size-del_size+1, "textline_string"); + char *tmp = MEM_mallocN(text->curl->len + add_size - del_size + 1, "textline_string"); memcpy(tmp, text->curl->line, text->curc); - memcpy(tmp+text->curc+add_size, text->curl->line+text->curc+del_size, text->curl->len-text->curc-del_size+1); + memcpy(tmp + text->curc + add_size, text->curl->line + text->curc + del_size, text->curl->len - text->curc - del_size + 1); MEM_freeN(text->curl->line); text->curl->line = tmp; } else if (add_size < del_size) { - char *tmp= text->curl->line; - memmove(tmp+text->curc+add_size, tmp+text->curc+del_size, text->curl->len-text->curc-del_size+1); + char *tmp = text->curl->line; + memmove(tmp + text->curc + add_size, tmp + text->curc + del_size, text->curl->len - text->curc - del_size + 1); } memcpy(text->curl->line + text->curc, ch, add_size); - text->curc+= add_size; + text->curc += add_size; txt_pop_sel(text); txt_make_dirty(text); @@ -2860,19 +2860,19 @@ void txt_indent(Text *text) num = 0; while (TRUE) { - tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string"); + tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string"); text->curc = 0; - if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */ - memcpy(tmp+text->curc, add, indentlen); + if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */ + memcpy(tmp + text->curc, add, indentlen); - len= text->curl->len - text->curc; - if (len>0) memcpy(tmp+text->curc+indentlen, text->curl->line+text->curc, len); - tmp[text->curl->len+indentlen]= 0; + len = text->curl->len - text->curc; + if (len > 0) memcpy(tmp + text->curc + indentlen, text->curl->line + text->curc, len); + tmp[text->curl->len + indentlen] = 0; make_new_line(text->curl, tmp); - text->curc+= indentlen; + text->curc += indentlen; txt_make_dirty(text); txt_clean_text(text); @@ -2887,7 +2887,7 @@ void txt_indent(Text *text) } } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -2920,11 +2920,11 @@ void txt_unindent(Text *text) int i = 0; if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) { - while (i< text->curl->len) { - text->curl->line[i]= text->curl->line[i+indent]; + while (i < text->curl->len) { + text->curl->line[i] = text->curl->line[i + indent]; i++; } - text->curl->len-= indent; + text->curl->len -= indent; } txt_make_dirty(text); @@ -2941,7 +2941,7 @@ void txt_unindent(Text *text) } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -2959,19 +2959,19 @@ void txt_comment(Text *text) if (!text) return; if (!text->curl) return; - if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one + if (!text->sell) return; // Need to change this need to check if only one line is selected to more then one num = 0; while (TRUE) { - tmp= MEM_mallocN(text->curl->len+2, "textline_string"); + tmp = MEM_mallocN(text->curl->len + 2, "textline_string"); text->curc = 0; if (text->curc) memcpy(tmp, text->curl->line, text->curc); - tmp[text->curc]= add; + tmp[text->curc] = add; - len= text->curl->len - text->curc; - if (len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len); - tmp[text->curl->len+1]=0; + len = text->curl->len - text->curc; + if (len > 0) memcpy(tmp + text->curc + 1, text->curl->line + text->curc, len); + tmp[text->curl->len + 1] = 0; make_new_line(text->curl, tmp); @@ -2990,7 +2990,7 @@ void txt_comment(Text *text) } } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -3013,8 +3013,8 @@ void txt_uncomment(Text *text) int i = 0; if (text->curl->line[i] == remove) { - while (i< text->curl->len) { - text->curl->line[i]= text->curl->line[i+1]; + while (i < text->curl->len) { + text->curl->line[i] = text->curl->line[i + 1]; i++; } text->curl->len--; @@ -3035,7 +3035,7 @@ void txt_uncomment(Text *text) } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -3054,7 +3054,7 @@ void txt_move_lines_up(struct Text *text) txt_order_cursors(text); - prev_line= text->curl->prev; + prev_line = text->curl->prev; if (!prev_line) return; @@ -3106,8 +3106,8 @@ int setcurr_tab_spaces(Text *text, int space) int test = 0; const char *word = ":"; const char *comm = "#"; - const char indent= (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; - static const char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; + const char indent = (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; + static const char *back_words[] = {"return", "break", "continue", "pass", "yield", NULL}; if (!text) return 0; if (!text->curl) return 0; @@ -3122,20 +3122,20 @@ int setcurr_tab_spaces(Text *text, int space) } if (strstr(text->curl->line, word)) { /* if we find a ':' on this line, then add a tab but not if it is: - * 1) in a comment - * 2) within an identifier + * 1) in a comment + * 2) within an identifier * 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414] */ int a, is_indent = 0; - for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { - char ch= text->curl->line[a]; - if (ch=='#') { + for (a = 0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { + char ch = text->curl->line[a]; + if (ch == '#') { break; } - else if (ch==':') { + else if (ch == ':') { is_indent = 1; } - else if (ch!=' ' && ch!='\t') { + else if (ch != ' ' && ch != '\t') { is_indent = 0; } } @@ -3144,7 +3144,7 @@ int setcurr_tab_spaces(Text *text, int space) } } - for (test=0; back_words[test]; test++) { + for (test = 0; back_words[test]; test++) { /* if there are these key words then remove a tab because we are done with the block */ if (strstr(text->curl->line, back_words[test]) && i > 0) { if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) { @@ -3164,21 +3164,21 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsign { TextMarker *tmp, *marker; - marker= MEM_mallocN(sizeof(TextMarker), "text_marker"); + marker = MEM_mallocN(sizeof(TextMarker), "text_marker"); - marker->lineno= txt_get_span(text->lines.first, line); - marker->start= MIN2(start, end); - marker->end= MAX2(start, end); - marker->group= group; - marker->flags= flags; + marker->lineno = txt_get_span(text->lines.first, line); + marker->start = MIN2(start, end); + marker->end = MAX2(start, end); + marker->group = group; + marker->flags = flags; - marker->color[0]= color[0]; - marker->color[1]= color[1]; - marker->color[2]= color[2]; - marker->color[3]= color[3]; + marker->color[0] = color[0]; + marker->color[1] = color[1]; + marker->color[2] = color[2]; + marker->color[3] = color[3]; - for (tmp=text->markers.last; tmp; tmp=tmp->prev) - if (tmp->lineno < marker->lineno || (tmp->lineno==marker->lineno && tmp->start < marker->start)) + for (tmp = text->markers.last; tmp; tmp = tmp->prev) + if (tmp->lineno < marker->lineno || (tmp->lineno == marker->lineno && tmp->start < marker->start)) break; if (tmp) BLI_insertlinkafter(&text->markers, tmp, marker); @@ -3191,18 +3191,18 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsign TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) { TextMarker *marker, *next; - int lineno= txt_get_span(text->lines.first, line); + int lineno = txt_get_span(text->lines.first, line); - for (marker=text->markers.first; marker; marker=next) { - next= marker->next; + for (marker = text->markers.first; marker; marker = next) { + next = marker->next; - if (group && marker->group != group) continue; + if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; + else if (marker->lineno < lineno) continue; else if (marker->lineno > lineno) break; - if ((marker->start==marker->end && start<=marker->start && marker->start<=end) || - (marker->startend>start)) + if ((marker->start == marker->end && start <= marker->start && marker->start <= end) || + (marker->start < end && marker->end > start)) { return marker; } @@ -3216,21 +3216,21 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) { TextMarker *marker, *next; - int lineno= txt_get_span(text->lines.first, line); - short cleared= 0; + int lineno = txt_get_span(text->lines.first, line); + short cleared = 0; - for (marker=text->markers.first; marker; marker=next) { - next= marker->next; + for (marker = text->markers.first; marker; marker = next) { + next = marker->next; if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; else if (marker->lineno < lineno) continue; else if (marker->lineno > lineno) break; - if ((marker->start==marker->end && start<=marker->start && marker->start<=end) || - (marker->startend>start)) { + if ((marker->start == marker->end && start <= marker->start && marker->start <= end) || + (marker->start < end && marker->end > start)) { BLI_freelinkN(&text->markers, marker); - cleared= 1; + cleared = 1; } } return cleared; @@ -3242,15 +3242,15 @@ short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, in short txt_clear_markers(Text *text, int group, int flags) { TextMarker *marker, *next; - short cleared= 0; + short cleared = 0; - for (marker=text->markers.first; marker; marker=next) { - next= marker->next; + for (marker = text->markers.first; marker; marker = next) { + next = marker->next; - if ((!group || marker->group==group) && - (marker->flags & flags) == flags) { + if ((!group || marker->group == group) && + (marker->flags & flags) == flags) { BLI_freelinkN(&text->markers, marker); - cleared= 1; + cleared = 1; } } return cleared; @@ -3261,9 +3261,9 @@ short txt_clear_markers(Text *text, int group, int flags) TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags) { TextMarker *marker; - int lineno= txt_get_span(text->lines.first, line); + int lineno = txt_get_span(text->lines.first, line); - for (marker=text->markers.first; marker; marker=marker->next) { + for (marker = text->markers.first; marker; marker = marker->next) { if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; else if (marker->lineno < lineno) continue; @@ -3279,10 +3279,10 @@ TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int * marker will be returned */ TextMarker *txt_prev_marker(Text *text, TextMarker *marker) { - TextMarker *tmp= marker; + TextMarker *tmp = marker; while (tmp) { - if (tmp->prev) tmp= tmp->prev; - else tmp= text->markers.last; + if (tmp->prev) tmp = tmp->prev; + else tmp = text->markers.last; if (tmp->group == marker->group) return tmp; } @@ -3293,10 +3293,10 @@ TextMarker *txt_prev_marker(Text *text, TextMarker *marker) * marker will be returned */ TextMarker *txt_next_marker(Text *text, TextMarker *marker) { - TextMarker *tmp= marker; + TextMarker *tmp = marker; while (tmp) { - if (tmp->next) tmp= tmp->next; - else tmp= text->markers.first; + if (tmp->next) tmp = tmp->next; + else tmp = text->markers.first; if (tmp->group == marker->group) return tmp; } @@ -3314,11 +3314,11 @@ int text_check_bracket(const char ch) char opens[] = "([{"; char close[] = ")]}"; - for (a=0; a<(sizeof(opens)-1); a++) { - if (ch==opens[a]) - return a+1; - else if (ch==close[a]) - return -(a+1); + for (a = 0; a < (sizeof(opens) - 1); a++) { + if (ch == opens[a]) + return a + 1; + else if (ch == close[a]) + return -(a + 1); } return 0; } @@ -3329,8 +3329,8 @@ int text_check_delim(const char ch) int a; char delims[] = "():\"\' ~!%^&*-+=[]{};/<>|.#\t,@"; - for (a=0; a<(sizeof(delims)-1); a++) { - if (ch==delims[a]) + for (a = 0; a < (sizeof(delims) - 1); a++) { + if (ch == delims[a]) return 1; } return 0; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9b3689df941..98f5f45f525 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -80,7 +80,7 @@ int test_dlerr(const char *name, const char *symbol) { char *err; - err= BLI_dynlib_get_error_as_string(NULL); + err = BLI_dynlib_get_error_as_string(NULL); if (err) { printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err); return 1; @@ -96,14 +96,14 @@ void open_plugin_tex(PluginTex *pit) int (*version)(void); /* init all the happy variables */ - pit->doit= NULL; - pit->pname= NULL; - pit->stnames= NULL; - pit->varstr= NULL; - pit->result= NULL; - pit->cfra= NULL; - pit->version= 0; - pit->instance_init= NULL; + pit->doit = NULL; + pit->pname = NULL; + pit->stnames = NULL; + pit->varstr = NULL; + pit->result = NULL; + pit->cfra = NULL; + pit->version = 0; + pit->instance_init = NULL; /* clear the error list */ BLI_dynlib_get_error_as_string(NULL); @@ -113,42 +113,42 @@ void open_plugin_tex(PluginTex *pit) /* pit->handle= 0; */ /* open the needed object */ - pit->handle= BLI_dynlib_open(pit->name); + pit->handle = BLI_dynlib_open(pit->name); if (test_dlerr(pit->name, pit->name)) return; if (pit->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void)) BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); + version = (int (*)(void))BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); if (test_dlerr(pit->name, "plugin_tex_getversion")) return; if (version != NULL) { - pit->version= version(); - if ( pit->version >= 2 && pit->version <=6) { + pit->version = version(); + if (pit->version >= 2 && pit->version <= 6) { int (*info_func)(PluginInfo *); - PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); + PluginInfo *info = (PluginInfo *) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); + info_func = (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); if (!test_dlerr(pit->name, "plugin_getinfo")) { info->instance_init = NULL; info_func(info); - pit->doit= (int(*)(void)) info->tex_doit; - pit->callback= (void(*)(unsigned short)) info->callback; - pit->stypes= info->stypes; - pit->vars= info->nvars; - pit->pname= info->name; - pit->stnames= info->snames; - pit->varstr= info->varstr; - pit->result= info->result; - pit->cfra= info->cfra; + pit->doit = (int (*)(void))info->tex_doit; + pit->callback = (void (*)(unsigned short))info->callback; + pit->stypes = info->stypes; + pit->vars = info->nvars; + pit->pname = info->name; + pit->stnames = info->snames; + pit->varstr = info->varstr; + pit->result = info->result; + pit->cfra = info->cfra; pit->instance_init = info->instance_init; if (info->init) info->init(); } MEM_freeN(info); } else { - printf ("Plugin returned unrecognized version number\n"); + printf("Plugin returned unrecognized version number\n"); return; } } @@ -158,8 +158,8 @@ void open_plugin_tex(PluginTex *pit) /* ------------------------------------------------------------------------- */ /* very badlevel define to bypass linking with BIF_interface.h */ -#define INT 96 -#define FLO 128 +#define INT 96 +#define FLO 128 PluginTex *add_plugin_tex(char *str) { @@ -167,24 +167,24 @@ PluginTex *add_plugin_tex(char *str) VarStruct *varstr; int a; - pit= MEM_callocN(sizeof(PluginTex), "plugintex"); + pit = MEM_callocN(sizeof(PluginTex), "plugintex"); BLI_strncpy(pit->name, str, sizeof(pit->name)); open_plugin_tex(pit); - if (pit->doit==NULL) { - if (pit->handle==NULL) {;} //XXX error("no plugin: %s", str); - else {;} //XXX error("in plugin: %s", str); + if (pit->doit == NULL) { + if (pit->handle == NULL) {; } //XXX error("no plugin: %s", str); + else {; } //XXX error("in plugin: %s", str); MEM_freeN(pit); return NULL; } - varstr= pit->varstr; - for (a=0; avars; a++, varstr++) { - if ( (varstr->type & FLO)==FLO) - pit->data[a]= varstr->def; - else if ( (varstr->type & INT)==INT) - *((int *)(pit->data+a))= (int) varstr->def; + varstr = pit->varstr; + for (a = 0; a < pit->vars; a++, varstr++) { + if ( (varstr->type & FLO) == FLO) + pit->data[a] = varstr->def; + else if ( (varstr->type & INT) == INT) + *((int *)(pit->data + a)) = (int) varstr->def; } if (pit->instance_init) @@ -197,7 +197,7 @@ PluginTex *add_plugin_tex(char *str) void free_plugin_tex(PluginTex *pit) { - if (pit==NULL) return; + if (pit == NULL) return; /* no BLI_dynlib_close: same plugin can be opened multiple times, 1 handle */ MEM_freeN(pit); @@ -207,7 +207,7 @@ void free_plugin_tex(PluginTex *pit) TexMapping *add_tex_mapping(void) { - TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "TexMapping"); + TexMapping *texmap = MEM_callocN(sizeof(TexMapping), "TexMapping"); default_tex_mapping(texmap); @@ -218,14 +218,14 @@ void default_tex_mapping(TexMapping *texmap) { memset(texmap, 0, sizeof(TexMapping)); - texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f; - texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f; + texmap->size[0] = texmap->size[1] = texmap->size[2] = 1.0f; + texmap->max[0] = texmap->max[1] = texmap->max[2] = 1.0f; unit_m4(texmap->mat); - texmap->projx= PROJ_X; - texmap->projy= PROJ_Y; - texmap->projz= PROJ_Z; - texmap->mapping= MTEX_FLAT; + texmap->projx = PROJ_X; + texmap->projy = PROJ_Y; + texmap->projz = PROJ_Z; + texmap->mapping = MTEX_FLAT; } void init_tex_mapping(TexMapping *texmap) @@ -233,7 +233,7 @@ void init_tex_mapping(TexMapping *texmap) float smat[3][3], rmat[3][3], mat[3][3], proj[3][3]; if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z && - is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { + is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { unit_m4(texmap->mat); texmap->flag |= TEXMAP_UNIT_MATRIX; @@ -243,11 +243,11 @@ void init_tex_mapping(TexMapping *texmap) zero_m3(proj); if (texmap->projx != PROJ_N) - proj[texmap->projx-1][0]= 1.0f; + proj[texmap->projx - 1][0] = 1.0f; if (texmap->projy != PROJ_N) - proj[texmap->projy-1][1]= 1.0f; + proj[texmap->projy - 1][1] = 1.0f; if (texmap->projz != PROJ_N) - proj[texmap->projz-1][2]= 1.0f; + proj[texmap->projz - 1][2] = 1.0f; /* scale */ size_to_mat3(smat, texmap->size); @@ -270,7 +270,7 @@ void init_tex_mapping(TexMapping *texmap) ColorMapping *add_color_mapping(void) { - ColorMapping *colormap= MEM_callocN(sizeof(ColorMapping), "ColorMapping"); + ColorMapping *colormap = MEM_callocN(sizeof(ColorMapping), "ColorMapping"); default_color_mapping(colormap); @@ -283,15 +283,15 @@ void default_color_mapping(ColorMapping *colormap) init_colorband(&colormap->coba, 1); - colormap->bright= 1.0; - colormap->contrast= 1.0; - colormap->saturation= 1.0; + colormap->bright = 1.0; + colormap->contrast = 1.0; + colormap->saturation = 1.0; - colormap->blend_color[0]= 0.8f; - colormap->blend_color[1]= 0.8f; - colormap->blend_color[2]= 0.8f; - colormap->blend_type= MA_RAMP_BLEND; - colormap->blend_factor= 0.0f; + colormap->blend_color[0] = 0.8f; + colormap->blend_color[1] = 0.8f; + colormap->blend_color[2] = 0.8f; + colormap->blend_type = MA_RAMP_BLEND; + colormap->blend_factor = 0.0f; } /* ****************** COLORBAND ******************* */ @@ -300,41 +300,41 @@ void init_colorband(ColorBand *coba, int rangetype) { int a; - coba->data[0].pos= 0.0; - coba->data[1].pos= 1.0; + coba->data[0].pos = 0.0; + coba->data[1].pos = 1.0; - if (rangetype==0) { - coba->data[0].r= 0.0; - coba->data[0].g= 0.0; - coba->data[0].b= 0.0; - coba->data[0].a= 0.0; - - coba->data[1].r= 1.0; - coba->data[1].g= 1.0; - coba->data[1].b= 1.0; - coba->data[1].a= 1.0; + if (rangetype == 0) { + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 0.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; } else { - coba->data[0].r= 0.0; - coba->data[0].g= 0.0; - coba->data[0].b= 0.0; - coba->data[0].a= 1.0; - - coba->data[1].r= 1.0; - coba->data[1].g= 1.0; - coba->data[1].b= 1.0; - coba->data[1].a= 1.0; + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 1.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; + } + + for (a = 2; a < MAXCOLORBAND; a++) { + coba->data[a].r = 0.5; + coba->data[a].g = 0.5; + coba->data[a].b = 0.5; + coba->data[a].a = 1.0; + coba->data[a].pos = 0.5; } - for (a=2; adata[a].r= 0.5; - coba->data[a].g= 0.5; - coba->data[a].b= 0.5; - coba->data[a].a= 1.0; - coba->data[a].pos= 0.5; - } - - coba->tot= 2; + coba->tot = 2; } @@ -342,7 +342,7 @@ ColorBand *add_colorband(int rangetype) { ColorBand *coba; - coba= MEM_callocN(sizeof(ColorBand), "colorband"); + coba = MEM_callocN(sizeof(ColorBand), "colorband"); init_colorband(coba, rangetype); return coba; @@ -356,85 +356,85 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) float fac, mfac, t[4]; int a; - if (coba==NULL || coba->tot==0) return 0; + if (coba == NULL || coba->tot == 0) return 0; - cbd1= coba->data; - if (coba->tot==1) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + cbd1 = coba->data; + if (coba->tot == 1) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { - if (in <= cbd1->pos && coba->ipotype<2) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + if (in <= cbd1->pos && coba->ipotype < 2) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { CBData left, right; /* we're looking for first pos > in */ - for (a=0; atot; a++, cbd1++) if (cbd1->pos > in) break; + for (a = 0; a < coba->tot; a++, cbd1++) if (cbd1->pos > in) break; - if (a==coba->tot) { - cbd2= cbd1-1; - right= *cbd2; - right.pos= 1.0f; - cbd1= &right; + if (a == coba->tot) { + cbd2 = cbd1 - 1; + right = *cbd2; + right.pos = 1.0f; + cbd1 = &right; } - else if (a==0) { - left= *cbd1; - left.pos= 0.0f; - cbd2= &left; + else if (a == 0) { + left = *cbd1; + left.pos = 0.0f; + cbd2 = &left; } - else cbd2= cbd1-1; + else cbd2 = cbd1 - 1; - if (in >= cbd1->pos && coba->ipotype<2) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + if (in >= cbd1->pos && coba->ipotype < 2) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { - if (cbd2->pos!=cbd1->pos) - fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos); + if (cbd2->pos != cbd1->pos) + fac = (in - cbd1->pos) / (cbd2->pos - cbd1->pos); else { /* was setting to 0.0 in 2.56 & previous, but this * is incorrect for the last element, see [#26732] */ - fac= (a != coba->tot) ? 0.0f : 1.0f; + fac = (a != coba->tot) ? 0.0f : 1.0f; } - if (coba->ipotype==4) { + if (coba->ipotype == 4) { /* constant */ - out[0]= cbd2->r; - out[1]= cbd2->g; - out[2]= cbd2->b; - out[3]= cbd2->a; + out[0] = cbd2->r; + out[1] = cbd2->g; + out[2] = cbd2->b; + out[3] = cbd2->a; return 1; } - if (coba->ipotype>=2) { + if (coba->ipotype >= 2) { /* ipo from right to left: 3 2 1 0 */ - if (a>=coba->tot-1) cbd0= cbd1; - else cbd0= cbd1+1; - if (a<2) cbd3= cbd2; - else cbd3= cbd2-1; + if (a >= coba->tot - 1) cbd0 = cbd1; + else cbd0 = cbd1 + 1; + if (a < 2) cbd3 = cbd2; + else cbd3 = cbd2 - 1; CLAMP(fac, 0.0f, 1.0f); - if (coba->ipotype==3) + if (coba->ipotype == 3) key_curve_position_weights(fac, t, KEY_CARDINAL); else key_curve_position_weights(fac, t, KEY_BSPLINE); - out[0]= t[3]*cbd3->r +t[2]*cbd2->r +t[1]*cbd1->r +t[0]*cbd0->r; - out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g; - out[2]= t[3]*cbd3->b +t[2]*cbd2->b +t[1]*cbd1->b +t[0]*cbd0->b; - out[3]= t[3]*cbd3->a +t[2]*cbd2->a +t[1]*cbd1->a +t[0]*cbd0->a; + out[0] = t[3] * cbd3->r + t[2] * cbd2->r + t[1] * cbd1->r + t[0] * cbd0->r; + out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g; + out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b; + out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a; CLAMP(out[0], 0.0f, 1.0f); CLAMP(out[1], 0.0f, 1.0f); CLAMP(out[2], 0.0f, 1.0f); @@ -442,40 +442,40 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) } else { - if (coba->ipotype==1) { /* EASE */ - mfac= fac*fac; - fac= 3.0f*mfac-2.0f*mfac*fac; + if (coba->ipotype == 1) { /* EASE */ + mfac = fac * fac; + fac = 3.0f * mfac - 2.0f * mfac * fac; } - mfac= 1.0f-fac; + mfac = 1.0f - fac; - out[0]= mfac*cbd1->r + fac*cbd2->r; - out[1]= mfac*cbd1->g + fac*cbd2->g; - out[2]= mfac*cbd1->b + fac*cbd2->b; - out[3]= mfac*cbd1->a + fac*cbd2->a; + out[0] = mfac * cbd1->r + fac * cbd2->r; + out[1] = mfac * cbd1->g + fac * cbd2->g; + out[2] = mfac * cbd1->b + fac * cbd2->b; + out[3] = mfac * cbd1->a + fac * cbd2->a; } } } } - return 1; /* OK */ + return 1; /* OK */ } void colorband_table_RGBA(ColorBand *coba, float **array, int *size) { int a; - *size = CM_TABLE+1; - *array = MEM_callocN(sizeof(float)*(*size)*4, "ColorBand"); + *size = CM_TABLE + 1; + *array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand"); - for (a=0; a<*size; a++) - do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]); + for (a = 0; a < *size; a++) + do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]); } int vergcband(const void *a1, const void *a2) { - const CBData *x1=a1, *x2=a2; + const CBData *x1 = a1, *x2 = a2; - if ( x1->pos > x2->pos ) return 1; - else if ( x1->pos < x2->pos) return -1; + if (x1->pos > x2->pos) return 1; + else if (x1->pos < x2->pos) return -1; return 0; } @@ -483,17 +483,17 @@ void colorband_update_sort(ColorBand *coba) { int a; - if (coba->tot<2) + if (coba->tot < 2) return; - for (a=0; atot; a++) - coba->data[a].cur= a; + for (a = 0; a < coba->tot; a++) + coba->data[a].cur = a; qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - for (a=0; atot; a++) { - if (coba->data[a].cur==coba->cur) { - coba->cur= a; + for (a = 0; a < coba->tot; a++) { + if (coba->data[a].cur == coba->cur) { + coba->cur = a; break; } } @@ -501,7 +501,7 @@ void colorband_update_sort(ColorBand *coba) CBData *colorband_element_add(struct ColorBand *coba, float position) { - if (coba->tot==MAXCOLORBAND) { + if (coba->tot == MAXCOLORBAND) { return NULL; } else if (coba->tot > 0) { @@ -520,7 +520,7 @@ CBData *colorband_element_add(struct ColorBand *coba, float position) } coba->tot++; - coba->cur = coba->tot-1; + coba->cur = coba->tot - 1; colorband_update_sort(coba); @@ -559,7 +559,7 @@ void BKE_texture_free(Tex *tex) BKE_free_animdata((struct ID *)tex); BKE_previewimg_free(&tex->preview); - BKE_icon_delete((struct ID*)tex); + BKE_icon_delete((struct ID *)tex); tex->id.icon_id = 0; if (tex->nodetree) { @@ -576,31 +576,31 @@ void default_tex(Tex *tex) VarStruct *varstr; int a; - tex->type= TEX_CLOUDS; - tex->stype= 0; - tex->flag= TEX_CHECKER_ODD; - tex->imaflag= TEX_INTERPOL|TEX_MIPMAP|TEX_USEALPHA; - tex->extend= TEX_REPEAT; - tex->cropxmin= tex->cropymin= 0.0; - tex->cropxmax= tex->cropymax= 1.0; + tex->type = TEX_CLOUDS; + tex->stype = 0; + tex->flag = TEX_CHECKER_ODD; + tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA; + tex->extend = TEX_REPEAT; + tex->cropxmin = tex->cropymin = 0.0; + tex->cropxmax = tex->cropymax = 1.0; tex->texfilter = TXF_EWA; tex->afmax = 8; - tex->xrepeat= tex->yrepeat= 1; - tex->fie_ima= 2; - tex->sfra= 1; - tex->frames= 0; - tex->offset= 0; - tex->noisesize= 0.25; - tex->noisedepth= 2; - tex->turbul= 5.0; - tex->nabla= 0.025; // also in do_versions - tex->bright= 1.0; - tex->contrast= 1.0; - tex->saturation= 1.0; - tex->filtersize= 1.0; - tex->rfac= 1.0; - tex->gfac= 1.0; - tex->bfac= 1.0; + tex->xrepeat = tex->yrepeat = 1; + tex->fie_ima = 2; + tex->sfra = 1; + tex->frames = 0; + tex->offset = 0; + tex->noisesize = 0.25; + tex->noisedepth = 2; + tex->turbul = 5.0; + tex->nabla = 0.025; // also in do_versions + tex->bright = 1.0; + tex->contrast = 1.0; + tex->saturation = 1.0; + tex->filtersize = 1.0; + tex->rfac = 1.0; + tex->gfac = 1.0; + tex->bfac = 1.0; /* newnoise: init. */ tex->noisebasis = 0; tex->noisebasis2 = 0; @@ -621,11 +621,11 @@ void default_tex(Tex *tex) tex->vn_coltype = 0; if (tex->env) { - tex->env->stype=ENV_ANIM; - tex->env->clipsta=0.1; - tex->env->clipend=100; - tex->env->cuberes=600; - tex->env->depth=0; + tex->env->stype = ENV_ANIM; + tex->env->clipsta = 0.1; + tex->env->clipend = 100; + tex->env->cuberes = 600; + tex->env->depth = 0; } if (tex->pd) { @@ -635,8 +635,8 @@ void default_tex(Tex *tex) if (tex->vd) { tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0; - tex->vd->interp_type=TEX_VD_LINEAR; - tex->vd->file_format=TEX_VD_SMOKE; + tex->vd->interp_type = TEX_VD_LINEAR; + tex->vd->file_format = TEX_VD_SMOKE; } if (tex->ot) { @@ -645,18 +645,18 @@ void default_tex(Tex *tex) } pit = tex->plugin; if (pit) { - varstr= pit->varstr; + varstr = pit->varstr; if (varstr) { - for (a=0; avars; a++, varstr++) { + for (a = 0; a < pit->vars; a++, varstr++) { pit->data[a] = varstr->def; } } } - tex->iuser.fie_ima= 2; - tex->iuser.ok= 1; - tex->iuser.frames= 100; - tex->iuser.sfra= 1; + tex->iuser.fie_ima = 2; + tex->iuser.ok = 1; + tex->iuser.frames = 100; + tex->iuser.sfra = 1; tex->preview = NULL; } @@ -690,10 +690,10 @@ void tex_set_type(Tex *tex, int type) Tex *add_texture(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Tex *tex; - tex= BKE_libblock_alloc(&bmain->tex, ID_TE, name); + tex = BKE_libblock_alloc(&bmain->tex, ID_TE, name); default_tex(tex); @@ -704,65 +704,65 @@ Tex *add_texture(const char *name) void default_mtex(MTex *mtex) { - mtex->texco= TEXCO_ORCO; - mtex->mapto= MAP_COL; - mtex->object= NULL; - mtex->projx= PROJ_X; - mtex->projy= PROJ_Y; - mtex->projz= PROJ_Z; - mtex->mapping= MTEX_FLAT; - mtex->ofs[0]= 0.0; - mtex->ofs[1]= 0.0; - mtex->ofs[2]= 0.0; - mtex->size[0]= 1.0; - mtex->size[1]= 1.0; - mtex->size[2]= 1.0; - mtex->tex= NULL; - mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; - mtex->colormodel= 0; - mtex->r= 1.0; - mtex->g= 0.0; - mtex->b= 1.0; - mtex->k= 1.0; - mtex->def_var= 1.0; - mtex->blendtype= MTEX_BLEND; - mtex->colfac= 1.0; - mtex->norfac= 1.0; - mtex->varfac= 1.0; - mtex->dispfac=0.2; - mtex->colspecfac= 1.0f; - mtex->mirrfac= 1.0f; - mtex->alphafac= 1.0f; - mtex->difffac= 1.0f; - mtex->specfac= 1.0f; - mtex->emitfac= 1.0f; - mtex->hardfac= 1.0f; - mtex->raymirrfac= 1.0f; - mtex->translfac= 1.0f; - mtex->ambfac= 1.0f; - mtex->colemitfac= 1.0f; - mtex->colreflfac= 1.0f; - mtex->coltransfac= 1.0f; - mtex->densfac= 1.0f; - mtex->scatterfac= 1.0f; - mtex->reflfac= 1.0f; - mtex->shadowfac= 1.0f; - mtex->zenupfac= 1.0f; - mtex->zendownfac= 1.0f; - mtex->blendfac= 1.0f; - mtex->timefac= 1.0f; - mtex->lengthfac= 1.0f; - mtex->clumpfac= 1.0f; - mtex->kinkfac= 1.0f; - mtex->roughfac= 1.0f; - mtex->padensfac= 1.0f; - mtex->lifefac= 1.0f; - mtex->sizefac= 1.0f; - mtex->ivelfac= 1.0f; - mtex->dampfac= 1.0f; - mtex->gravityfac= 1.0f; - mtex->fieldfac= 1.0f; - mtex->normapspace= MTEX_NSPACE_TANGENT; + mtex->texco = TEXCO_ORCO; + mtex->mapto = MAP_COL; + mtex->object = NULL; + mtex->projx = PROJ_X; + mtex->projy = PROJ_Y; + mtex->projz = PROJ_Z; + mtex->mapping = MTEX_FLAT; + mtex->ofs[0] = 0.0; + mtex->ofs[1] = 0.0; + mtex->ofs[2] = 0.0; + mtex->size[0] = 1.0; + mtex->size[1] = 1.0; + mtex->size[2] = 1.0; + mtex->tex = NULL; + mtex->texflag = MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; + mtex->colormodel = 0; + mtex->r = 1.0; + mtex->g = 0.0; + mtex->b = 1.0; + mtex->k = 1.0; + mtex->def_var = 1.0; + mtex->blendtype = MTEX_BLEND; + mtex->colfac = 1.0; + mtex->norfac = 1.0; + mtex->varfac = 1.0; + mtex->dispfac = 0.2; + mtex->colspecfac = 1.0f; + mtex->mirrfac = 1.0f; + mtex->alphafac = 1.0f; + mtex->difffac = 1.0f; + mtex->specfac = 1.0f; + mtex->emitfac = 1.0f; + mtex->hardfac = 1.0f; + mtex->raymirrfac = 1.0f; + mtex->translfac = 1.0f; + mtex->ambfac = 1.0f; + mtex->colemitfac = 1.0f; + mtex->colreflfac = 1.0f; + mtex->coltransfac = 1.0f; + mtex->densfac = 1.0f; + mtex->scatterfac = 1.0f; + mtex->reflfac = 1.0f; + mtex->shadowfac = 1.0f; + mtex->zenupfac = 1.0f; + mtex->zendownfac = 1.0f; + mtex->blendfac = 1.0f; + mtex->timefac = 1.0f; + mtex->lengthfac = 1.0f; + mtex->clumpfac = 1.0f; + mtex->kinkfac = 1.0f; + mtex->roughfac = 1.0f; + mtex->padensfac = 1.0f; + mtex->lifefac = 1.0f; + mtex->sizefac = 1.0f; + mtex->ivelfac = 1.0f; + mtex->dampfac = 1.0f; + mtex->gravityfac = 1.0f; + mtex->fieldfac = 1.0f; + mtex->normapspace = MTEX_NSPACE_TANGENT; } @@ -772,7 +772,7 @@ MTex *add_mtex(void) { MTex *mtex; - mtex= MEM_callocN(sizeof(MTex), "add_mtex"); + mtex = MEM_callocN(sizeof(MTex), "add_mtex"); default_mtex(mtex); @@ -787,16 +787,16 @@ MTex *add_mtex_id(ID *id, int slot) give_active_mtex(id, &mtex_ar, &act); - if (mtex_ar==NULL) { + if (mtex_ar == NULL) { return NULL; } - if (slot==-1) { + if (slot == -1) { /* find first free */ int i; - for (i= 0; i < MAX_MTEX; i++) { + for (i = 0; i < MAX_MTEX; i++) { if (!mtex_ar[i]) { - slot= i; + slot = i; break; } } @@ -814,10 +814,10 @@ MTex *add_mtex_id(ID *id, int slot) if (mtex_ar[slot]) { id_us_min((ID *)mtex_ar[slot]->tex); MEM_freeN(mtex_ar[slot]); - mtex_ar[slot]= NULL; + mtex_ar[slot] = NULL; } - mtex_ar[slot]= add_mtex(); + mtex_ar[slot] = add_mtex(); return mtex_ar[slot]; } @@ -828,27 +828,27 @@ Tex *BKE_texture_copy(Tex *tex) { Tex *texn; - texn= BKE_libblock_copy(&tex->id); - if (texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); - else texn->ima= NULL; + texn = BKE_libblock_copy(&tex->id); + if (texn->type == TEX_IMAGE) id_us_plus((ID *)texn->ima); + else texn->ima = NULL; if (texn->plugin) { - texn->plugin= MEM_dupallocN(texn->plugin); + texn->plugin = MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); - if (texn->env) texn->env= BKE_copy_envmap(texn->env); - if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); - if (texn->vd) texn->vd= MEM_dupallocN(texn->vd); - if (texn->ot) texn->ot= BKE_copy_oceantex(texn->ot); + if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); + if (texn->env) texn->env = BKE_copy_envmap(texn->env); + if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd); + if (texn->vd) texn->vd = MEM_dupallocN(texn->vd); + if (texn->ot) texn->ot = BKE_copy_oceantex(texn->ot); if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); if (tex->nodetree) { if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata, 1); } - texn->nodetree= ntreeCopyTree(tex->nodetree); + texn->nodetree = ntreeCopyTree(tex->nodetree); } return texn; @@ -859,35 +859,35 @@ Tex *localize_texture(Tex *tex) { Tex *texn; - texn= BKE_libblock_copy(&tex->id); + texn = BKE_libblock_copy(&tex->id); BLI_remlink(&G.main->tex, texn); /* image texture: BKE_texture_free also doesn't decrease */ if (texn->plugin) { - texn->plugin= MEM_dupallocN(texn->plugin); + texn->plugin = MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); + if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); if (texn->env) { - texn->env= BKE_copy_envmap(texn->env); + texn->env = BKE_copy_envmap(texn->env); id_us_min(&texn->env->ima->id); } - if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); + if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd); if (texn->vd) { - texn->vd= MEM_dupallocN(texn->vd); + texn->vd = MEM_dupallocN(texn->vd); if (texn->vd->dataset) - texn->vd->dataset= MEM_dupallocN(texn->vd->dataset); + texn->vd->dataset = MEM_dupallocN(texn->vd->dataset); } if (texn->ot) { - texn->ot= BKE_copy_oceantex(tex->ot); + texn->ot = BKE_copy_oceantex(tex->ot); } texn->preview = NULL; if (tex->nodetree) { - texn->nodetree= ntreeLocalize(tex->nodetree); + texn->nodetree = ntreeLocalize(tex->nodetree); } return texn; @@ -903,74 +903,74 @@ static void extern_local_texture(Tex *tex) void BKE_texture_make_local(Tex *tex) { - Main *bmain= G.main; + Main *bmain = G.main; Material *ma; World *wrld; Lamp *la; Brush *br; ParticleSettings *pa; - int a, is_local= FALSE, is_lib= FALSE; + int a, is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (tex->id.lib==NULL) return; + if (tex->id.lib == NULL) return; - if (tex->id.us==1) { + if (tex->id.us == 1) { id_clear_lib_data(bmain, &tex->id); extern_local_texture(tex); return; } - ma= bmain->mat.first; + ma = bmain->mat.first; while (ma) { - for (a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if (ma->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex == tex) { + if (ma->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - ma= ma->id.next; + ma = ma->id.next; } - la= bmain->lamp.first; + la = bmain->lamp.first; while (la) { - for (a=0; amtex[a] && la->mtex[a]->tex==tex) { - if (la->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (la->mtex[a] && la->mtex[a]->tex == tex) { + if (la->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - la= la->id.next; + la = la->id.next; } - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - for (a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if (wrld->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (wrld->mtex[a] && wrld->mtex[a]->tex == tex) { + if (wrld->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - wrld= wrld->id.next; + wrld = wrld->id.next; } - br= bmain->brush.first; + br = bmain->brush.first; while (br) { - if (br->mtex.tex==tex) { - if (br->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (br->mtex.tex == tex) { + if (br->id.lib) is_lib = TRUE; + else is_local = TRUE; } - br= br->id.next; + br = br->id.next; } - pa= bmain->particle.first; + pa = bmain->particle.first; while (pa) { - for (a=0; amtex[a] && pa->mtex[a]->tex==tex) { - if (pa->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (pa->mtex[a] && pa->mtex[a]->tex == tex) { + if (pa->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - pa= pa->id.next; + pa = pa->id.next; } if (is_local && is_lib == FALSE) { @@ -978,75 +978,75 @@ void BKE_texture_make_local(Tex *tex) extern_local_texture(tex); } else if (is_local && is_lib) { - Tex *tex_new= BKE_texture_copy(tex); + Tex *tex_new = BKE_texture_copy(tex); - tex_new->id.us= 0; + tex_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, tex->id.lib, &tex_new->id); - ma= bmain->mat.first; + ma = bmain->mat.first; while (ma) { - for (a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if (ma->id.lib==NULL) { - ma->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex == tex) { + if (ma->id.lib == NULL) { + ma->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - ma= ma->id.next; + ma = ma->id.next; } - la= bmain->lamp.first; + la = bmain->lamp.first; while (la) { - for (a=0; amtex[a] && la->mtex[a]->tex==tex) { - if (la->id.lib==NULL) { - la->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (la->mtex[a] && la->mtex[a]->tex == tex) { + if (la->id.lib == NULL) { + la->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - la= la->id.next; + la = la->id.next; } - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - for (a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if (wrld->id.lib==NULL) { - wrld->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (wrld->mtex[a] && wrld->mtex[a]->tex == tex) { + if (wrld->id.lib == NULL) { + wrld->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - wrld= wrld->id.next; + wrld = wrld->id.next; } - br= bmain->brush.first; + br = bmain->brush.first; while (br) { - if (br->mtex.tex==tex) { - if (br->id.lib==NULL) { - br->mtex.tex= tex_new; + if (br->mtex.tex == tex) { + if (br->id.lib == NULL) { + br->mtex.tex = tex_new; tex_new->id.us++; tex->id.us--; } } - br= br->id.next; + br = br->id.next; } - pa= bmain->particle.first; + pa = bmain->particle.first; while (pa) { - for (a=0; amtex[a] && pa->mtex[a]->tex==tex) { - if (pa->id.lib==NULL) { - pa->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (pa->mtex[a] && pa->mtex[a]->tex == tex) { + if (pa->id.lib == NULL) { + pa->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - pa= pa->id.next; + pa = pa->id.next; } } } @@ -1055,10 +1055,10 @@ void BKE_texture_make_local(Tex *tex) #if 0 /* UNUSED */ void autotexname(Tex *tex) { - Main *bmain= G.main; - char texstr[20][15]= {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", - "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", - "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; + Main *bmain = G.main; + char texstr[20][15] = {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", + "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", + "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; @@ -1067,8 +1067,8 @@ void autotexname(Tex *tex) new_id(&bmain->tex, (ID *)tex, "Noddy"); } else - if (tex->type==TEX_IMAGE) { - ima= tex->ima; + if (tex->type == TEX_IMAGE) { + ima = tex->ima; if (ima) { BLI_strncpy(di, ima->name, sizeof(di)); BLI_splitdirstring(di, fi); @@ -1078,7 +1078,7 @@ void autotexname(Tex *tex) } else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } - else if (tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); + else if (tex->type == TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } } @@ -1089,21 +1089,21 @@ void autotexname(Tex *tex) Tex *give_current_object_texture(Object *ob) { Material *ma, *node_ma; - Tex *tex= NULL; + Tex *tex = NULL; - if (ob==NULL) return NULL; - if (ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL; + if (ob == NULL) return NULL; + if (ob->totcol == 0 && !(ob->type == OB_LAMP)) return NULL; - if (ob->type==OB_LAMP) { - tex= give_current_lamp_texture(ob->data); + if (ob->type == OB_LAMP) { + tex = give_current_lamp_texture(ob->data); } else { - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); - if ((node_ma=give_node_material(ma))) - ma= node_ma; + if ((node_ma = give_node_material(ma))) + ma = node_ma; - tex= give_current_material_texture(ma); + tex = give_current_material_texture(ma); } return tex; @@ -1111,12 +1111,12 @@ Tex *give_current_object_texture(Object *ob) Tex *give_current_lamp_texture(Lamp *la) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (la) { - mtex= la->mtex[(int)(la->texact)]; - if (mtex) tex= mtex->tex; + mtex = la->mtex[(int)(la->texact)]; + if (mtex) tex = mtex->tex; } return tex; @@ -1124,23 +1124,23 @@ Tex *give_current_lamp_texture(Lamp *la) void set_current_lamp_texture(Lamp *la, Tex *newtex) { - int act= la->texact; + int act = la->texact; if (la->mtex[act] && la->mtex[act]->tex) id_us_min(&la->mtex[act]->tex->id); if (newtex) { if (!la->mtex[act]) { - la->mtex[act]= add_mtex(); - la->mtex[act]->texco= TEXCO_GLOB; + la->mtex[act] = add_mtex(); + la->mtex[act]->texco = TEXCO_GLOB; } - la->mtex[act]->tex= newtex; + la->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (la->mtex[act]) { MEM_freeN(la->mtex[act]); - la->mtex[act]= NULL; + la->mtex[act] = NULL; } } @@ -1154,25 +1154,25 @@ bNode *give_current_material_texture_node(Material *ma) Tex *give_current_material_texture(Material *ma) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; bNode *node; if (ma && ma->use_nodes && ma->nodetree) { /* first check texture, then material, this works together * with a hack that clears the active ID flag for textures on * making a material node active */ - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) { - tex= (Tex *)node->id; - ma= NULL; + tex = (Tex *)node->id; + ma = NULL; } } if (ma) { - mtex= ma->mtex[(int)(ma->texact)]; - if (mtex) tex= mtex->tex; + mtex = ma->mtex[(int)(ma->texact)]; + if (mtex) tex = mtex->tex; } return tex; @@ -1181,26 +1181,26 @@ Tex *give_current_material_texture(Material *ma) int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) { switch (GS(id->name)) { - case ID_MA: - *mtex_ar= ((Material *)id)->mtex; - if (act) *act= (((Material *)id)->texact); - break; - case ID_WO: - *mtex_ar= ((World *)id)->mtex; - if (act) *act= (((World *)id)->texact); - break; - case ID_LA: - *mtex_ar= ((Lamp *)id)->mtex; - if (act) *act= (((Lamp *)id)->texact); - break; - case ID_PA: - *mtex_ar= ((ParticleSettings *)id)->mtex; - if (act) *act= (((ParticleSettings *)id)->texact); - break; - default: - *mtex_ar = NULL; - if (act) *act= 0; - return FALSE; + case ID_MA: + *mtex_ar = ((Material *)id)->mtex; + if (act) *act = (((Material *)id)->texact); + break; + case ID_WO: + *mtex_ar = ((World *)id)->mtex; + if (act) *act = (((World *)id)->texact); + break; + case ID_LA: + *mtex_ar = ((Lamp *)id)->mtex; + if (act) *act = (((Lamp *)id)->texact); + break; + case ID_PA: + *mtex_ar = ((ParticleSettings *)id)->mtex; + if (act) *act = (((ParticleSettings *)id)->texact); + break; + default: + *mtex_ar = NULL; + if (act) *act = 0; + return FALSE; } return TRUE; @@ -1208,57 +1208,57 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) void set_active_mtex(ID *id, short act) { - if (act<0) act= 0; - else if (act>=MAX_MTEX) act= MAX_MTEX-1; + if (act < 0) act = 0; + else if (act >= MAX_MTEX) act = MAX_MTEX - 1; switch (GS(id->name)) { - case ID_MA: - ((Material *)id)->texact= act; - break; - case ID_WO: - ((World *)id)->texact= act; - break; - case ID_LA: - ((Lamp *)id)->texact= act; - break; - case ID_PA: - ((ParticleSettings *)id)->texact= act; - break; + case ID_MA: + ((Material *)id)->texact = act; + break; + case ID_WO: + ((World *)id)->texact = act; + break; + case ID_LA: + ((Lamp *)id)->texact = act; + break; + case ID_PA: + ((ParticleSettings *)id)->texact = act; + break; } } void set_current_material_texture(Material *ma, Tex *newtex) { - Tex *tex= NULL; + Tex *tex = NULL; bNode *node; if (ma && ma->use_nodes && ma->nodetree) { - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) { - tex= (Tex *)node->id; + tex = (Tex *)node->id; id_us_min(&tex->id); - node->id= &newtex->id; + node->id = &newtex->id; id_us_plus(&newtex->id); - ma= NULL; + ma = NULL; } } if (ma) { - int act= (int)ma->texact; + int act = (int)ma->texact; - tex= (ma->mtex[act])? ma->mtex[act]->tex: NULL; + tex = (ma->mtex[act]) ? ma->mtex[act]->tex : NULL; id_us_min(&tex->id); if (newtex) { if (!ma->mtex[act]) - ma->mtex[act]= add_mtex(); + ma->mtex[act] = add_mtex(); - ma->mtex[act]->tex= newtex; + ma->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (ma->mtex[act]) { MEM_freeN(ma->mtex[act]); - ma->mtex[act]= NULL; + ma->mtex[act] = NULL; } } } @@ -1268,7 +1268,7 @@ int has_current_material_texture(Material *ma) bNode *node; if (ma && ma->use_nodes && ma->nodetree) { - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) return 1; @@ -1279,36 +1279,36 @@ int has_current_material_texture(Material *ma) Tex *give_current_world_texture(World *world) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (!world) return NULL; - mtex= world->mtex[(int)(world->texact)]; - if (mtex) tex= mtex->tex; + mtex = world->mtex[(int)(world->texact)]; + if (mtex) tex = mtex->tex; return tex; } void set_current_world_texture(World *wo, Tex *newtex) { - int act= wo->texact; + int act = wo->texact; if (wo->mtex[act] && wo->mtex[act]->tex) id_us_min(&wo->mtex[act]->tex->id); if (newtex) { if (!wo->mtex[act]) { - wo->mtex[act]= add_mtex(); - wo->mtex[act]->texco= TEXCO_VIEW; + wo->mtex[act] = add_mtex(); + wo->mtex[act]->texco = TEXCO_VIEW; } - wo->mtex[act]->tex= newtex; + wo->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (wo->mtex[act]) { MEM_freeN(wo->mtex[act]); - wo->mtex[act]= NULL; + wo->mtex[act] = NULL; } } @@ -1323,44 +1323,44 @@ void set_current_brush_texture(Brush *br, Tex *newtex) id_us_min(&br->mtex.tex->id); if (newtex) { - br->mtex.tex= newtex; + br->mtex.tex = newtex; id_us_plus(&newtex->id); } } Tex *give_current_particle_texture(ParticleSettings *part) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (!part) return NULL; - mtex= part->mtex[(int)(part->texact)]; - if (mtex) tex= mtex->tex; + mtex = part->mtex[(int)(part->texact)]; + if (mtex) tex = mtex->tex; return tex; } void set_current_particle_texture(ParticleSettings *part, Tex *newtex) { - int act= part->texact; + int act = part->texact; if (part->mtex[act] && part->mtex[act]->tex) id_us_min(&part->mtex[act]->tex->id); if (newtex) { if (!part->mtex[act]) { - part->mtex[act]= add_mtex(); - part->mtex[act]->texco= TEXCO_ORCO; - part->mtex[act]->blendtype= MTEX_MUL; + part->mtex[act] = add_mtex(); + part->mtex[act]->texco = TEXCO_ORCO; + part->mtex[act]->blendtype = MTEX_MUL; } - part->mtex[act]->tex= newtex; + part->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (part->mtex[act]) { MEM_freeN(part->mtex[act]); - part->mtex[act]= NULL; + part->mtex[act] = NULL; } } @@ -1370,12 +1370,12 @@ EnvMap *BKE_add_envmap(void) { EnvMap *env; - env= MEM_callocN(sizeof(EnvMap), "envmap"); - env->type= ENV_CUBE; - env->stype= ENV_ANIM; - env->clipsta= 0.1; - env->clipend= 100.0; - env->cuberes= 600; + env = MEM_callocN(sizeof(EnvMap), "envmap"); + env->type = ENV_CUBE; + env->stype = ENV_ANIM; + env->clipsta = 0.1; + env->clipend = 100.0; + env->cuberes = 600; env->viewscale = 0.5; return env; @@ -1388,9 +1388,9 @@ EnvMap *BKE_copy_envmap(EnvMap *env) EnvMap *envn; int a; - envn= MEM_dupallocN(env); - envn->ok= 0; - for (a=0; a<6; a++) envn->cube[a]= NULL; + envn = MEM_dupallocN(env); + envn->ok = 0; + for (a = 0; a < 6; a++) envn->cube[a] = NULL; if (envn->ima) id_us_plus((ID *)envn->ima); return envn; @@ -1402,12 +1402,12 @@ void BKE_free_envmapdata(EnvMap *env) { unsigned int part; - for (part=0; part<6; part++) { + for (part = 0; part < 6; part++) { if (env->cube[part]) IMB_freeImBuf(env->cube[part]); - env->cube[part]= NULL; + env->cube[part] = NULL; } - env->ok= 0; + env->ok = 0; } /* ------------------------------------------------------------------------- */ @@ -1426,7 +1426,7 @@ PointDensity *BKE_add_pointdensity(void) { PointDensity *pd; - pd= MEM_callocN(sizeof(PointDensity), "pointdensity"); + pd = MEM_callocN(sizeof(PointDensity), "pointdensity"); pd->flag = 0; pd->radius = 0.3f; pd->falloff_type = TEX_PD_FALLOFF_STD; @@ -1443,7 +1443,7 @@ PointDensity *BKE_add_pointdensity(void) pd->totpoints = 0; pd->object = NULL; pd->psys = 0; - pd->psys_cache_space= TEX_PD_WORLDSPACE; + pd->psys_cache_space = TEX_PD_WORLDSPACE; pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); pd->falloff_curve->preset = CURVE_PRESET_LINE; @@ -1458,10 +1458,10 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd) { PointDensity *pdn; - pdn= MEM_dupallocN(pd); + pdn = MEM_dupallocN(pd); pdn->point_tree = NULL; pdn->point_data = NULL; - if (pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); + if (pdn->coba) pdn->coba = MEM_dupallocN(pdn->coba); pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */ return pdn; } @@ -1511,11 +1511,11 @@ struct VoxelData *BKE_add_voxeldata(void) { VoxelData *vd; - vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata"); + vd = MEM_callocN(sizeof(struct VoxelData), "voxeldata"); vd->dataset = NULL; vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; - vd->interp_type= TEX_VD_LINEAR; - vd->file_format= TEX_VD_SMOKE; + vd->interp_type = TEX_VD_LINEAR; + vd->file_format = TEX_VD_SMOKE; vd->int_multiplier = 1.0; vd->extend = TEX_CLIP; vd->object = NULL; @@ -1523,13 +1523,13 @@ struct VoxelData *BKE_add_voxeldata(void) vd->ok = 0; return vd; - } +} struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) { VoxelData *vdn; - vdn= MEM_dupallocN(vd); + vdn = MEM_dupallocN(vd); vdn->dataset = NULL; return vdn; @@ -1541,7 +1541,7 @@ struct OceanTex *BKE_add_oceantex(void) { OceanTex *ot; - ot= MEM_callocN(sizeof(struct OceanTex), "ocean texture"); + ot = MEM_callocN(sizeof(struct OceanTex), "ocean texture"); ot->output = TEX_OCN_DISPLACEMENT; ot->object = NULL; @@ -1550,7 +1550,7 @@ struct OceanTex *BKE_add_oceantex(void) struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot) { - OceanTex *otn= MEM_dupallocN(ot); + OceanTex *otn = MEM_dupallocN(ot); return otn; } @@ -1568,8 +1568,9 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) // assume all plugins depend on time return 1; } - else if ( texture->ima && - ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { + else if (texture->ima && + ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) + { return 1; } else if (texture->adt) { diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index f50a655236f..303098ea0bd 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -56,8 +56,8 @@ void BKE_world_free(World *wrld) MTex *mtex; int a; - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = wrld->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -71,40 +71,40 @@ void BKE_world_free(World *wrld) MEM_freeN(wrld->nodetree); } - BKE_icon_delete((struct ID*)wrld); + BKE_icon_delete((struct ID *)wrld); wrld->id.icon_id = 0; } World *add_world(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; World *wrld; - wrld= BKE_libblock_alloc(&bmain->world, ID_WO, name); + wrld = BKE_libblock_alloc(&bmain->world, ID_WO, name); - wrld->horr= 0.05f; - wrld->horg= 0.05f; - wrld->horb= 0.05f; - wrld->zenr= 0.01f; - wrld->zeng= 0.01f; - wrld->zenb= 0.01f; - wrld->skytype= 0; - wrld->stardist= 15.0f; - wrld->starsize= 2.0f; - - wrld->exp= 0.0f; - wrld->exposure=wrld->range= 1.0f; + wrld->horr = 0.05f; + wrld->horg = 0.05f; + wrld->horb = 0.05f; + wrld->zenr = 0.01f; + wrld->zeng = 0.01f; + wrld->zenb = 0.01f; + wrld->skytype = 0; + wrld->stardist = 15.0f; + wrld->starsize = 2.0f; - wrld->aodist= 10.0f; - wrld->aosamp= 5; - wrld->aoenergy= 1.0f; - wrld->ao_env_energy= 1.0f; - wrld->ao_indirect_energy= 1.0f; - wrld->ao_indirect_bounces= 1; - wrld->aobias= 0.05f; + wrld->exp = 0.0f; + wrld->exposure = wrld->range = 1.0f; + + wrld->aodist = 10.0f; + wrld->aosamp = 5; + wrld->aoenergy = 1.0f; + wrld->ao_env_energy = 1.0f; + wrld->ao_indirect_energy = 1.0f; + wrld->ao_indirect_bounces = 1; + wrld->aobias = 0.05f; wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; - wrld->ao_approx_error= 0.25f; + wrld->ao_approx_error = 0.25f; wrld->preview = NULL; wrld->miststa = 5.0f; @@ -118,18 +118,18 @@ World *BKE_world_copy(World *wrld) World *wrldn; int a; - wrldn= BKE_libblock_copy(&wrld->id); + wrldn = BKE_libblock_copy(&wrld->id); - for (a=0; amtex[a]) { - wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "BKE_world_copy"); + 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); } } if (wrld->nodetree) - wrldn->nodetree= ntreeCopyTree(wrld->nodetree); + wrldn->nodetree = ntreeCopyTree(wrld->nodetree); if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview); @@ -142,12 +142,12 @@ World *localize_world(World *wrld) World *wrldn; int a; - wrldn= BKE_libblock_copy(&wrld->id); + wrldn = BKE_libblock_copy(&wrld->id); BLI_remlink(&G.main->world, wrldn); - for (a=0; amtex[a]) { - wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world"); + wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), "localize_world"); memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex)); /* free world decrements */ id_us_plus((ID *)wrldn->mtex[a]->tex); @@ -155,51 +155,51 @@ World *localize_world(World *wrld) } if (wrld->nodetree) - wrldn->nodetree= ntreeLocalize(wrld->nodetree); + wrldn->nodetree = ntreeLocalize(wrld->nodetree); - wrldn->preview= NULL; + wrldn->preview = NULL; return wrldn; } void BKE_world_make_local(World *wrld) { - Main *bmain= G.main; + Main *bmain = G.main; Scene *sce; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (wrld->id.lib==NULL) return; - if (wrld->id.us==1) { + if (wrld->id.lib == NULL) return; + if (wrld->id.us == 1) { id_clear_lib_data(bmain, &wrld->id); return; } - for (sce= bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce= sce->id.next) { + for (sce = bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce = sce->id.next) { if (sce->world == wrld) { - if (sce->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (sce->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - if (is_local && is_lib==FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &wrld->id); } else if (is_local && is_lib) { - World *wrld_new= BKE_world_copy(wrld); - wrld_new->id.us= 0; + World *wrld_new = BKE_world_copy(wrld); + wrld_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrld_new->id); - for (sce= bmain->scene.first; sce; sce= sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->world == wrld) { - if (sce->id.lib==NULL) { - sce->world= wrld_new; + if (sce->id.lib == NULL) { + sce->world = wrld_new; wrld_new->id.us++; wrld->id.us--; } From 4f1cdb3e42c5a1103dde3794a87d7e4765702c72 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 6 May 2012 15:19:36 +0000 Subject: [PATCH 106/143] Code cleanup: patch by Thomas to fix PassType values to be consecutive. --- intern/cycles/kernel/kernel_types.h | 38 ++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 25ff7f73888..8c4334d61f3 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -173,25 +173,25 @@ typedef enum PassType { PASS_NONE = 0, PASS_COMBINED = 1, PASS_DEPTH = 2, - PASS_NORMAL = 8, - PASS_UV = 16, - PASS_OBJECT_ID = 32, - PASS_MATERIAL_ID = 64, - PASS_DIFFUSE_COLOR = 128, - PASS_GLOSSY_COLOR = 256, - PASS_TRANSMISSION_COLOR = 512, - PASS_DIFFUSE_INDIRECT = 1024, - PASS_GLOSSY_INDIRECT = 2048, - PASS_TRANSMISSION_INDIRECT = 4096, - PASS_DIFFUSE_DIRECT = 8192, - PASS_GLOSSY_DIRECT = 16384, - PASS_TRANSMISSION_DIRECT = 32768, - PASS_EMISSION = 65536, - PASS_BACKGROUND = 131072, - PASS_AO = 262144, - PASS_SHADOW = 524288, - PASS_MOTION = 1048576, - PASS_MOTION_WEIGHT = 2097152 + PASS_NORMAL = 4, + PASS_UV = 8, + PASS_OBJECT_ID = 16, + PASS_MATERIAL_ID = 32, + PASS_DIFFUSE_COLOR = 64, + PASS_GLOSSY_COLOR = 128, + PASS_TRANSMISSION_COLOR = 256, + PASS_DIFFUSE_INDIRECT = 512, + PASS_GLOSSY_INDIRECT = 1024, + PASS_TRANSMISSION_INDIRECT = 2048, + PASS_DIFFUSE_DIRECT = 4096, + PASS_GLOSSY_DIRECT = 8192, + PASS_TRANSMISSION_DIRECT = 16384, + PASS_EMISSION = 32768, + PASS_BACKGROUND = 65536, + PASS_AO = 131072, + PASS_SHADOW = 262144, + PASS_MOTION = 524288, + PASS_MOTION_WEIGHT = 1048576 } PassType; #define PASS_ALL (~0) From a058ac9c50fefe9d8ee0519a694d2ca371f358bd Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 6 May 2012 15:40:49 +0000 Subject: [PATCH 107/143] Fix for [#31333] 2.63 Bone copy rotation becomes mad after entering/leaving armature edit mode There is no real good solution to this problem, hopefully this threshold value will be a good compromize this time... :( --- source/blender/blenkernel/intern/armature.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 59ac1604e29..58264fb4175 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1463,8 +1463,12 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) * * was 0.000001, causes bug [#30438] (which is same as [#27675, imho). * Reseting it to org value seems to cause no more [#23954]... + * + * was 0.0000000000001, caused bug [#], smaller values give unstable + * roll when toggling editmode again... + * No good value here, trying 0.000000001 as best compromize. :/ */ - if (dot_v3v3(axis, axis) > 1.0e-13f) { + if (dot_v3v3(axis, axis) > 1.0e-9f) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); From 4504c66124203134fb70e9008082ef966db4a544 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 15:45:48 +0000 Subject: [PATCH 108/143] disable warping for tablet events (X11 only), added TODO's for OSX and win32. --- intern/ghost/intern/GHOST_SystemCocoa.mm | 14 +++++++++++++- intern/ghost/intern/GHOST_SystemWin32.cpp | 7 ++++++- intern/ghost/intern/GHOST_SystemX11.cpp | 12 ++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 50d8cfd074b..898171b344e 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1488,7 +1488,19 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) } case NSMouseMoved: - switch (window->getCursorGrabMode()) { + GHOST_TGrabCursorMode grab_mode = window->getCursorGrabMode(); + + /* TODO: CHECK IF THIS IS A TABLET EVENT */ + bool is_tablet = false; + + if (is_tablet && + (grab_mode != GHOST_kGrabDisable) && + (grab_mode != GHOST_kGrabNormal)) + { + grab_mode = GHOST_kGrabDisable; + } + + switch (grab_mode) { case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move { GHOST_TInt32 x_warp, y_warp, x_accum, y_accum, x, y; diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 2d8cf13ac4f..b00ff690cfa 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -649,7 +649,12 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, system->getCursorPosition(x_screen, y_screen); - if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal) + /* TODO: CHECK IF THIS IS A TABLET EVENT */ + bool is_tablet = false; + + if (is_tablet == false && + window->getCursorGrabMode() != GHOST_kGrabDisable && + window->getCursorGrabMode() != GHOST_kGrabNormal) { GHOST_TInt32 x_new= x_screen; GHOST_TInt32 y_new= y_screen; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 857d9e79e57..6a2e6f59717 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -471,8 +471,16 @@ GHOST_SystemX11::processEvent(XEvent *xe) case MotionNotify: { XMotionEvent &xme = xe->xmotion; - - if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal) + +#ifdef WITH_X11_XINPUT + bool is_tablet = window->GetXTablet().CommonData.Active != GHOST_kTabletModeNone; +#else + bool is_tablet = false; +#endif + + if(is_tablet == false && + window->getCursorGrabMode() != GHOST_kGrabDisable && + window->getCursorGrabMode() != GHOST_kGrabNormal) { GHOST_TInt32 x_new= xme.x_root; GHOST_TInt32 y_new= xme.y_root; From d5b96163f7f5ad341d5e252f88c4126b562317b3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 15:59:57 +0000 Subject: [PATCH 109/143] code cleanup: add getCursorGrabModeIsWarp(), makes the intent more clear where we check for mouse warping. --- intern/ghost/intern/GHOST_SystemCocoa.mm | 9 +++------ intern/ghost/intern/GHOST_SystemWin32.cpp | 5 +---- intern/ghost/intern/GHOST_SystemX11.cpp | 5 +---- intern/ghost/intern/GHOST_Window.h | 7 +++++++ 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 898171b344e..77d9e39a752 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1280,7 +1280,7 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest() GHOST_Window* window = (GHOST_Window*)m_windowManager->getActiveWindow(); //Discard quit event if we are in cursor grab sequence - if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal)) + if (window && window->getCursorGrabModeIsWarp()) return GHOST_kExitCancel; //Check open windows if some changes are not saved @@ -1329,7 +1329,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) } //Discard event if we are in cursor grab sequence, it'll lead to "stuck cursor" situation if the alert panel is raised - if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal)) + if (window && window->getCursorGrabModeIsWarp()) return GHOST_kExitCancel; //Check open windows if some changes are not saved @@ -1493,10 +1493,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) /* TODO: CHECK IF THIS IS A TABLET EVENT */ bool is_tablet = false; - if (is_tablet && - (grab_mode != GHOST_kGrabDisable) && - (grab_mode != GHOST_kGrabNormal)) - { + if (is_tablet && window->getCursorGrabModeIsWarp()) { grab_mode = GHOST_kGrabDisable; } diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index b00ff690cfa..9f2728a581f 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -652,10 +652,7 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, /* TODO: CHECK IF THIS IS A TABLET EVENT */ bool is_tablet = false; - if (is_tablet == false && - window->getCursorGrabMode() != GHOST_kGrabDisable && - window->getCursorGrabMode() != GHOST_kGrabNormal) - { + if (is_tablet == false && window->getCursorGrabModeIsWarp()) { GHOST_TInt32 x_new= x_screen; GHOST_TInt32 y_new= y_screen; GHOST_TInt32 x_accum, y_accum; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 6a2e6f59717..cabec06301a 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -478,10 +478,7 @@ GHOST_SystemX11::processEvent(XEvent *xe) bool is_tablet = false; #endif - if(is_tablet == false && - window->getCursorGrabMode() != GHOST_kGrabDisable && - window->getCursorGrabMode() != GHOST_kGrabNormal) - { + if (is_tablet == false && window->getCursorGrabModeIsWarp()) { GHOST_TInt32 x_new= xme.x_root; GHOST_TInt32 y_new= xme.y_root; GHOST_TInt32 x_accum, y_accum; diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index 323e0fa3418..23f1b044b60 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -161,6 +161,7 @@ public: */ inline virtual bool getCursorVisibility() const; inline virtual GHOST_TGrabCursorMode getCursorGrabMode() const; + inline virtual bool getCursorGrabModeIsWarp() const; inline virtual void getCursorGrabInitPos(GHOST_TInt32 &x, GHOST_TInt32 &y) const; inline virtual void getCursorGrabAccum(GHOST_TInt32 &x, GHOST_TInt32 &y) const; inline virtual void setCursorGrabAccum(GHOST_TInt32 x, GHOST_TInt32 y); @@ -362,6 +363,12 @@ inline GHOST_TGrabCursorMode GHOST_Window::getCursorGrabMode() const return m_cursorGrab; } +inline bool GHOST_Window::getCursorGrabModeIsWarp() const +{ + return (m_cursorGrab == GHOST_kGrabWrap) || + (m_cursorGrab == GHOST_kGrabHide); +} + inline void GHOST_Window::getCursorGrabInitPos(GHOST_TInt32 &x, GHOST_TInt32 &y) const { x = m_cursorGrabInitPos[0]; From 9e3523b556b1b7dc0863f64b7e53a513ab5bc507 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 16:28:52 +0000 Subject: [PATCH 110/143] code cleanup: documentation commit --- source/blender/makesdna/DNA_object_types.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 05a96ef2f35..1e428bb96e0 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -153,6 +153,9 @@ typedef struct Object { float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ float imat[4][4]; /* inverse matrix of 'obmat' for any other use than rendering! */ + /* note: this isn't assured to be valid as with 'obmat', + * before using this value you should do... + * invert_m4_m4(ob->imat, ob->obmat); */ /* Previously 'imat' was used at render time, but as other places use it too * the interactive ui of 2.5 creates problems. So now only 'imat_ren' should From 1118b3fe3f6a9597403e8eb61f33e7a877098145 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 6 May 2012 17:14:56 +0000 Subject: [PATCH 111/143] Mesh elements sorting refactor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now only one operator. Same options for vertices, edges and faces (so adds edges sorting, and some options to vertices sorting). Face sorting should behave as previously. However, XSortVerts won’t pack anymore selected vertices at the begining of the vert array (as it used to), if you want such behavior you’ll have to first run SortElements with Selected action. Also added bug ref I forgot in r46354 (armature.c). --- release/scripts/startup/bl_ui/space_view3d.py | 7 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 864 +++++++++++------- source/blender/editors/mesh/mesh_intern.h | 4 +- source/blender/editors/mesh/mesh_ops.c | 4 +- 5 files changed, 532 insertions(+), 349 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 629a2ec323d..7e53cfed282 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1675,6 +1675,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu): layout.operator("mesh.blend_from_shape") layout.operator("mesh.shape_propagate_to_all") layout.operator("mesh.select_vertex_path") + layout.operator("mesh.sort_elements") class VIEW3D_MT_edit_mesh_select_mode(Menu): @@ -1750,8 +1751,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu): layout.operator("mesh.vertices_smooth") layout.operator("mesh.remove_doubles") - layout.operator("mesh.vertices_sort") - layout.operator("mesh.vertices_randomize") + layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {"VERT"} layout.operator("mesh.select_vertex_path") @@ -1796,6 +1796,7 @@ class VIEW3D_MT_edit_mesh_edges(Menu): layout.operator("mesh.bevel") layout.operator("mesh.edge_split") layout.operator("mesh.bridge_edge_loops") + layout.operator("mesh.sort_elements", text="Sort Edges").elements = {"EDGE"} layout.separator() @@ -1828,7 +1829,7 @@ class VIEW3D_MT_edit_mesh_faces(Menu): layout.operator("mesh.bevel") layout.operator("mesh.solidify") layout.operator("mesh.wireframe") - layout.operator("mesh.sort_faces") + layout.operator("mesh.sort_elements", text="Sort Faces").elements = {"FACE"} layout.separator() diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 58264fb4175..1f4259c6d86 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1464,7 +1464,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) * was 0.000001, causes bug [#30438] (which is same as [#27675, imho). * Reseting it to org value seems to cause no more [#23954]... * - * was 0.0000000000001, caused bug [#], smaller values give unstable + * was 0.0000000000001, caused bug [#31333], smaller values give unstable * roll when toggling editmode again... * No good value here, trying 0.000000001 as best compromize. :/ */ diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 9c7ef756147..af3d7f16927 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -66,6 +66,8 @@ #include "RE_render_ext.h" +#include "UI_interface.h" + #include "mesh_intern.h" /* allow accumulated normals to form a new direction but don't @@ -3659,393 +3661,577 @@ void MESH_OT_select_mirror(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection"); } -/* qsort routines. not sure how to make these - * work, since we aren't using linked lists for - * geometry anymore. might need a sort of "swap" - * function for bmesh elements. */ +/****************************************************************************** + * qsort routines. + * Now unified, for vertices/edges/faces. */ -/* TODO All this section could probably use a refresh... - * face code works in object mode, does everything in one op, while vert uses several... - */ +enum { + SRT_VIEW_ZAXIS = 1, /* Use view Z (deep) axis. */ + SRT_VIEW_XAXIS, /* Use view X (left to right) axis. */ + SRT_CURSOR_DISTANCE, /* Use distance from element to 3D cursor. */ + SRT_MATERIAL, /* Face only: use mat number. */ + SRT_SELECTED, /* Move selected elements in first, without modifying + * relative order of selected and unselected elements. */ + SRT_RANDOMIZE, /* Randomize selected elements. */ + SRT_REVERSE, /* Reverse current order of selected elements. */ +}; -typedef struct xvertsort { - int x; /* X screen-coordinate */ - int org_idx; /* Original index of this vertex _in the mempool_ */ -} xvertsort; +typedef struct bmelemsort { + float srt; /* Sort factor */ + int org_idx; /* Original index of this element _in its mempool_ */ +} bmelemsort; - -static int vergxco(const void *v1, const void *v2) +static int bmelemsort_comp(const void *v1, const void *v2) { - const xvertsort *x1 = v1, *x2 = v2; + const bmelemsort *x1 = v1, *x2 = v2; - /* We move unchanged vertices (org_idx < 0) at the begining of the sorted list. */ - if (x1->org_idx >= 0 && x2->org_idx >= 0) - return (x1->x > x2->x) - (x1->x < x2->x); - return (x2->org_idx < 0) - (x1->org_idx < 0); + return (x1->srt > x2->srt) - (x1->srt < x2->srt); } -static void xsortvert_flag__doSetX(void *userData, BMVert *UNUSED(eve), int x, int UNUSED(y), int index) -{ - xvertsort *sortblock = userData; - - sortblock[index].x = x; -} - -/* all verts with (flag & 'flag') are sorted */ -static void xsortvert_flag(bContext *C, int flag) +/* Reorders vertices/edges/faces using a given methods. Loops are not supported. */ +static void sort_bmelem_flag(bContext *C, const int types, const int flag, const int action, + const int reverse, const unsigned int seed) { + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_edit_object(C); ViewContext vc; BMEditMesh *em; BMVert *ve; + BMEdge *ed; + BMFace *fa; BMIter iter; - xvertsort *sortblock; - int *unchangedblock, *vmap; - int totvert, sorted = 0, unchanged = 0, i; + + /* In all five elements below, 0 = vertices, 1 = edges, 2 = faces. */ + /* Just to mark protected elements. */ + char *pblock[3] = {NULL, NULL, NULL}, *pb; + bmelemsort *sblock[3] = {NULL, NULL, NULL}, *sb; + int *map[3] = {NULL, NULL, NULL}, *mp; + int totelem[3] = {0, 0, 0}, tot; + int affected[3] = {0, 0, 0}, aff; + int i, j; + + if (!(types && flag && action)) + return; em_setup_viewcontext(C, &vc); em = vc.em; - totvert = em->bm->totvert; + if (types & BM_VERT) + totelem[0] = em->bm->totvert; + if (types & BM_EDGE) + totelem[1] = em->bm->totedge; + if (types & BM_FACE) + totelem[2] = em->bm->totface; - sortblock = MEM_callocN(sizeof(xvertsort) * totvert, "xsort sorted"); - /* Stores unchanged verts, will be reused as final old2new vert mapping... */ - unchangedblock = MEM_callocN(sizeof(int) * totvert, "xsort unchanged"); - BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(ve, flag)) { - sortblock[i].org_idx = i; - sorted++; + if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) { + RegionView3D *rv3d = ED_view3d_context_rv3d(C); + float mat[4][4]; + float fact = reverse ? -1.0 : 1.0; + int coidx = (action == SRT_VIEW_ZAXIS) ? 2 : 0; + + mult_m4_m4m4(mat, rv3d->viewmat, ob->obmat); /* Apply the view matrix to the object matrix. */ + + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + float co[3]; + mul_v3_m4v3(co, mat, ve->co); + + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } } - else { - unchangedblock[unchanged++] = i; - sortblock[i].org_idx = -1; + + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + float co[3]; + mid_v3_v3v3(co, ed->v1->co, ed->v2->co); + mul_m4_v3(mat, co); + + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + float co[3]; + BM_face_calc_center_mean(fa, co); + mul_m4_v3(mat, co); + + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } } } -/* printf("%d verts: %d to be sorted, %d unchanged…\n", totvert, sorted, unchanged);*/ - if (sorted == 0) { - MEM_freeN(sortblock); - MEM_freeN(unchangedblock); + + else if (action == SRT_CURSOR_DISTANCE) { + View3D *v3d = CTX_wm_view3d(C); + float cur[3]; + float mat[4][4]; + float fact = reverse ? -1.0 : 1.0; + + if (v3d && v3d->localvd) + copy_v3_v3(cur, v3d->cursor); + else + copy_v3_v3(cur, scene->cursor); + invert_m4_m4(mat, ob->obmat); + mul_m4_v3(mat, cur); + + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = len_squared_v3v3(cur, ve->co) * fact; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + float co[3]; + mid_v3_v3v3(co, ed->v1->co, ed->v2->co); + + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = len_squared_v3v3(cur, co) * fact; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + float co[3]; + BM_face_calc_center_mean(fa, co); + + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = len_squared_v3v3(cur, co) * fact; + } + else { + pb[i] = TRUE; + } + } + } + } + + /* Faces only! */ + else if (action == SRT_MATERIAL && totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + /* Reverse materials' order, not order of faces inside each mat! */ + /* Note: cannot use totcol, as mat_nr may sometimes be greater... */ + float srt = reverse ? (float)(MAXMAT - fa->mat_nr) : (float)fa->mat_nr; + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + /* Multiplying with totface and adding i ensures us we keep current order for all faces of same mat. */ + sb[affected[2]++].srt = srt * ((float)totelem[2]) + ((float)i); +/* printf("e: %d; srt: %f; final: %f\n", i, srt, srt * ((float)totface) + ((float)i));*/ + } + else { + pb[i] = TRUE; + } + } + } + + else if (action == SRT_SELECTED) { + int *tbuf[3] = {NULL, NULL, NULL}, *tb; + + if (totelem[0]) { + tb = tbuf[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert tbuf"); + mp = map[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert map"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + mp[affected[0]++] = i; + } + else { + *tb = i; + tb++; + } + } + } + + if (totelem[1]) { + tb = tbuf[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge tbuf"); + mp = map[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge map"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + mp[affected[1]++] = i; + } + else { + *tb = i; + tb++; + } + } + } + + if (totelem[2]) { + tb = tbuf[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face tbuf"); + mp = map[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face map"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + mp[affected[2]++] = i; + } + else { + *tb = i; + tb++; + } + } + } + + for (j = 3; j--;) { + int tot = totelem[j]; + int aff = affected[j]; + tb = tbuf[j]; + mp = map[j]; + if (!(tb && mp)) + continue; + if (ELEM(aff, 0, tot)) { + MEM_freeN(tb); + MEM_freeN(mp); + map[j] = NULL; + continue; + } + if (reverse) { + memcpy(tb + (tot - aff), mp, aff * sizeof(int)); + } + else { + memcpy(mp + aff, tb, (tot - aff) * sizeof(int)); + tb = mp; + mp = map[j] = tbuf[j]; + tbuf[j] = tb; + } + + /* Reverse mapping, we want an org2new one! */ + for (i = tot, tb = tbuf[j] + tot - 1; i--; tb--) { + mp[*tb] = i; + } + MEM_freeN(tbuf[j]); + } + } + + else if (action == SRT_RANDOMIZE) { + if (totelem[0]) { + /* Re-init random generator for each element type, to get consistant random when + * enabling/disabling an element type. */ + BLI_srandom(seed); + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[1]) { + BLI_srandom(seed); + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + BLI_srandom(seed); + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + } + + else if (action == SRT_REVERSE) { + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + } + +/* printf("%d vertices: %d to be affected…\n", totelem[0], affected[0]);*/ +/* printf("%d edges: %d to be affected…\n", totelem[1], affected[1]);*/ +/* printf("%d faces: %d to be affected…\n", totelem[2], affected[2]);*/ + if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) { + for (j = 3; j--;) { + if (pblock[j]) + MEM_freeN(pblock[j]); + if (sblock[j]) + MEM_freeN(sblock[j]); + if (map[j]) + MEM_freeN(map[j]); + } return; } - ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - mesh_foreachScreenVert(&vc, xsortvert_flag__doSetX, sortblock, V3D_CLIP_TEST_OFF); + /* Sort affected elements, and populate mapping arrays, if needed. */ + for (j = 3; j--;) { + pb = pblock[j]; + sb = sblock[j]; + if (pb && sb && !map[j]) { + char *p_blk; + bmelemsort *s_blk; + tot = totelem[j]; + aff = affected[j]; - qsort(sortblock, totvert, sizeof(xvertsort), vergxco); + qsort(sb, aff, sizeof(bmelemsort), bmelemsort_comp); - /* Convert sortblock into an array mapping old idx to new. */ - vmap = unchangedblock; - unchangedblock = NULL; - if (unchanged) { - unchangedblock = MEM_mallocN(sizeof(int) * unchanged, "xsort unchanged"); - memcpy(unchangedblock, vmap, unchanged * sizeof(int)); - } - for (i = totvert; i--; ) { - if (i < unchanged) - vmap[unchangedblock[i]] = i; - else - vmap[sortblock[i].org_idx] = i; - } - - MEM_freeN(sortblock); - if (unchangedblock) - MEM_freeN(unchangedblock); - - BM_mesh_remap(em->bm, vmap, NULL, NULL); - - MEM_freeN(vmap); -} - -static int edbm_vertices_sort_exec(bContext *C, wmOperator *UNUSED(op)) -{ - xsortvert_flag(C, BM_ELEM_SELECT); - return OPERATOR_FINISHED; -} - -void MESH_OT_vertices_sort(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Vertex Sort"; - ot->description = "Sort vertex order"; - ot->idname = "MESH_OT_vertices_sort"; - - /* api callbacks */ - ot->exec = edbm_vertices_sort_exec; - - ot->poll = EM_view3d_poll; /* uses view relative X axis to sort verts */ - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -/* ********************** SORT FACES ******************* */ - -static void permutate(void *list, int num, int size, int *index) -{ - void *buf; - int len; - int i; - - len = num * size; - - buf = MEM_mallocN(len, "permutate"); - memcpy(buf, list, len); - - for (i = 0; i < num; i++) { - memcpy((char *)list + (i * size), (char *)buf + (index[i] * size), size); - } - MEM_freeN(buf); -} - -/* sort faces on view axis */ -static float *face_sort_floats; -static int float_sort(const void *v1, const void *v2) -{ - float x1, x2; - - x1 = face_sort_floats[((int *) v1)[0]]; - x2 = face_sort_floats[((int *) v2)[0]]; - - if (x1 > x2) return 1; - else if (x1 < x2) return -1; - return 0; -} - -static int edbm_sort_faces_exec(bContext *C, wmOperator *op) -{ - RegionView3D *rv3d = ED_view3d_context_rv3d(C); - View3D *v3d = CTX_wm_view3d(C); - Object *ob = CTX_data_edit_object(C); - Scene *scene = CTX_data_scene(C); - Mesh *me; - CustomDataLayer *layer; - int i, j, *index; - int event; - float reverse = 1; - // XXX int ctrl = 0; - - if (!v3d) return OPERATOR_CANCELLED; - - /* This operator work in Object Mode, not in edit mode. - * After talk with Campbell we agree that there is no point to port this to EditMesh right now. - * so for now, we just exit_editmode and enter_editmode at the end of this function. - */ - ED_object_exit_editmode(C, EM_FREEDATA); - - me = ob->data; - if (me->totpoly == 0) { - ED_object_enter_editmode(C, 0); - return OPERATOR_FINISHED; - } - - event = RNA_enum_get(op->ptr, "type"); - - // XXX - //if (ctrl) - // reverse = -1; - - /* create index list */ - index = (int *)MEM_mallocN(sizeof(int) * me->totpoly, "sort faces"); - for (i = 0; i < me->totpoly; i++) { - index[i] = i; - } - - face_sort_floats = (float *) MEM_mallocN(sizeof(float) * me->totpoly, "sort faces float"); - - /* sort index list instead of faces itself - * and apply this permutation to all face layers - */ - if (event == 5) { - /* Random */ - for (i = 0; i < me->totpoly; i++) { - face_sort_floats[i] = BLI_frand(); + mp = map[j] = MEM_mallocN(sizeof(int) * tot, "sort_bmelem map"); + p_blk = pb + tot - 1; + s_blk = sb + aff - 1; + for (i = tot; i--; p_blk--) { + if (*p_blk) { /* Protected! */ + mp[i] = i; + } + else { + mp[s_blk->org_idx] = i; + s_blk--; + } + } } - qsort(index, me->totpoly, sizeof(int), float_sort); + if (pb) + MEM_freeN(pb); + if (sb) + MEM_freeN(sb); + } + + BM_mesh_remap(em->bm, map[0], map[1], map[2]); +/* DAG_id_tag_update(ob->data, 0);*/ + + for (j = 3; j--;) { + if (map[j]) + MEM_freeN(map[j]); + } +} + +static int edbm_sort_elements_exec(bContext *C, wmOperator *op) +{ + int action = RNA_enum_get(op->ptr, "type"); + PropertyRNA *prop_elem_types = RNA_struct_find_property(op->ptr, "elements"); + int elem_types = 0; + int reverse = RNA_boolean_get(op->ptr, "reverse"); + unsigned int seed = RNA_int_get(op->ptr, "seed"); + + /* If no elem_types set, use current selection mode to set it! */ + if (RNA_property_is_set(op->ptr, prop_elem_types)) { + elem_types = RNA_property_enum_get(op->ptr, prop_elem_types); } else { - MPoly *mp; - MLoop *ml; - MVert *mv; - float vec[3]; - float mat[4][4]; - float cur[3]; - - if (event == 1) - mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */ - else if (event == 2) { /* sort from cursor */ - if (v3d && v3d->localvd) { - copy_v3_v3(cur, v3d->cursor); - } - else { - copy_v3_v3(cur, scene->cursor); - } - invert_m4_m4(mat, OBACT->obmat); - mul_m4_v3(mat, cur); - } - - mp = me->mpoly; - - for (i = 0; i < me->totpoly; i++, mp++) { - if (event == 3) { - face_sort_floats[i] = ((float)mp->mat_nr) * reverse; - } - else if (event == 4) { - /* selected first */ - if (mp->flag & ME_FACE_SEL) - face_sort_floats[i] = 0.0; - else - face_sort_floats[i] = reverse; - } - else { - /* find the face's center */ - ml = me->mloop + mp->loopstart; - zero_v3(vec); - for (j = 0; j < mp->totloop; j++, ml++) { - mv = me->mvert + ml->v; - add_v3_v3(vec, mv->co); - } - mul_v3_fl(vec, 1.0f / (float)mp->totloop); - - if (event == 1) { /* sort on view axis */ - mul_m4_v3(mat, vec); - face_sort_floats[i] = vec[2] * reverse; - } - else if (event == 2) { /* distance from cursor */ - face_sort_floats[i] = len_v3v3(cur, vec) * reverse; /* back to front */ - } - } - } - qsort(index, me->totpoly, sizeof(int), float_sort); - } - - MEM_freeN(face_sort_floats); - for (i = 0; i < me->pdata.totlayer; i++) { - layer = &me->pdata.layers[i]; - permutate(layer->data, me->totpoly, CustomData_sizeof(layer->type), index); + BMEditMesh *em = BMEdit_FromObject(CTX_data_edit_object(C)); + if (em->selectmode & SCE_SELECT_VERTEX) + elem_types |= BM_VERT; + if (em->selectmode & SCE_SELECT_EDGE) + elem_types |= BM_EDGE; + if (em->selectmode & SCE_SELECT_FACE) + elem_types |= BM_FACE; + RNA_enum_set(op->ptr, "elements", elem_types); } - MEM_freeN(index); - DAG_id_tag_update(ob->data, 0); - - /* Return to editmode. */ - ED_object_enter_editmode(C, 0); - + sort_bmelem_flag(C, elem_types, BM_ELEM_SELECT, action, reverse, seed); return OPERATOR_FINISHED; } -void MESH_OT_sort_faces(wmOperatorType *ot) +static int edbm_sort_elements_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +{ + const char *prop_id = RNA_property_identifier(prop); + int action = RNA_enum_get(ptr, "type"); + + /* Only show seed for randomize action! */ + if (strcmp(prop_id, "seed") == 0) { + if (action == SRT_RANDOMIZE) + return TRUE; + else + return FALSE; + } + + /* Hide seed for reverse and randomize actions! */ + if (strcmp(prop_id, "reverse") == 0) { + if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) + return FALSE; + else + return TRUE; + } + + return TRUE; +} + +static void edbm_sort_elements_ui(bContext *C, wmOperator *op) +{ + uiLayout *layout = op->layout; + wmWindowManager *wm = CTX_wm_manager(C); + PointerRNA ptr; + + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + + /* Main auto-draw call. */ + uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0'); +} + +void MESH_OT_sort_elements(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - { 1, "VIEW_AXIS", 0, "View Axis", "" }, - { 2, "CURSOR_DISTANCE", 0, "Cursor Distance", "" }, - { 3, "MATERIAL", 0, "Material", "" }, - { 4, "SELECTED", 0, "Selected", "" }, - { 5, "RANDOMIZE", 0, "Randomize", "" }, - { 0, NULL, 0, NULL, NULL }}; + {SRT_VIEW_ZAXIS, "VIEW_ZAXIS", 0, "View Z Axis", + "Sort selected elements from farest to nearest one in current view"}, + {SRT_VIEW_XAXIS, "VIEW_XAXIS", 0, "View X Axis", + "Sort selected elements from left to right one in current view"}, + {SRT_CURSOR_DISTANCE, "CURSOR_DISTANCE", 0, "Cursor Distance", + "Sort selected elements from nearest to farest from 3D cursor"}, + {SRT_MATERIAL, "MATERIAL", 0, "Material", + "Sort selected elements from smallest to greatest material index (faces only!)"}, + {SRT_SELECTED, "SELECTED", 0, "Selected", + "Move all selected elements in first places, preserving their relative order " + "(WARNING: this will affect unselected elements' indices as well!)"}, + {SRT_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Randomize order of selected elements"}, + {SRT_REVERSE, "REVERSE", 0, "Reverse", "Reverse current order of selected elements"}, + {0, NULL, 0, NULL, NULL}, + }; + + static EnumPropertyItem elem_items[] = { + {BM_VERT, "VERT", 0, "Vertices", ""}, + {BM_EDGE, "EDGE", 0, "Edges", ""}, + {BM_FACE, "FACE", 0, "Faces", ""}, + {0, NULL, 0, NULL, NULL}, + }; /* identifiers */ - ot->name = "Sort Faces"; // XXX (Ctrl to reverse)%t| - ot->description = "The faces of the active Mesh Object are sorted, based on the current view"; - ot->idname = "MESH_OT_sort_faces"; + ot->name = "Sort Mesh Elements"; + ot->description = "The order of selected vertices/edges/faces is modified, based on a given method"; + ot->idname = "MESH_OT_sort_elements"; /* api callbacks */ ot->invoke = WM_menu_invoke; - ot->exec = edbm_sort_faces_exec; + ot->exec = edbm_sort_elements_exec; ot->poll = ED_operator_editmesh; + ot->ui = edbm_sort_elements_ui; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Type of re-ordering operation to apply"); + RNA_def_enum_flag(ot->srna, "elements", elem_items, 0, "Elements", + "Which elements to affect (vertices, edges and/or faces)"); + RNA_def_boolean(ot->srna, "reverse", FALSE, "Reverse", "Reverse the sorting effect"); + RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for random-based operations", 0, 255); } -/* ******************************* Randomize verts ************************* */ -static void hashvert_flag(BMEditMesh *em, int flag, unsigned int seed) -{ - BMVert *ve; - BMIter iter; - char *block /* Just to mark protected vertices */, *t_blk; - int *randblock, *vmap, *t_idx, *r_idx; - int totvert, randomized = 0, /*protected = 0, */ i; - - totvert = em->bm->totvert; - - block = MEM_callocN(sizeof(char) * totvert, "randvert block"); - randblock = MEM_callocN(sizeof(int) * totvert, "randvert randblock"); - BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(ve, flag)) { - block[i] = FALSE; - randblock[randomized++] = i; - } - else { - block[i] = TRUE; - } - } -/* protected = totvert - randomized;*/ -/* printf("%d verts: %d to be randomized, %d protected…\n", totvert, randomized, protected);*/ - if (randomized == 0) { - MEM_freeN(block); - MEM_freeN(randblock); - return; - } - - - /* Randomize non-protected vertices indices, and create an array mapping old idx to new - * from both blocks, keeping protected vertices at the same indices. */ - vmap = randblock; - randblock = MEM_mallocN(sizeof(int) * randomized, "randvert randblock"); - memcpy(randblock, vmap, randomized * sizeof(int)); - BLI_array_randomize((void *)randblock, sizeof(int), randomized, seed); - t_blk = block + totvert - 1; - t_idx = vmap + totvert - 1; - r_idx = randblock + randomized - 1; - for (i = totvert; i--; t_blk--, t_idx--) { - if (*t_blk) /* Protected! */ - *t_idx = i; - else - *t_idx = *r_idx--; - } - - MEM_freeN(randblock); - MEM_freeN(block); - - BM_mesh_remap(em->bm, vmap, NULL, NULL); - - MEM_freeN(vmap); -} - -static int edbm_vertices_randomize_exec(bContext *C, wmOperator *op) -{ - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BMEdit_FromObject(obedit); - unsigned int seed = RNA_int_get(op->ptr, "seed"); - - hashvert_flag(em, BM_ELEM_SELECT, seed); - - return OPERATOR_FINISHED; -} - -void MESH_OT_vertices_randomize(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Vertex Randomize"; - ot->description = "Randomize vertex order"; - ot->idname = "MESH_OT_vertices_randomize"; - - /* api callbacks */ - ot->exec = edbm_vertices_randomize_exec; - - ot->poll = ED_operator_editmesh; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* Properties */ - ot->prop = RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for the random generator", 0, 255); -} - -/******end of qsort stuff ****/ - +/****** end of qsort stuff ****/ static int edbm_noise_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 31c130d20c9..cf17fce2971 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -147,8 +147,6 @@ extern struct EnumPropertyItem *corner_type_items; void MESH_OT_merge(struct wmOperatorType *ot); void MESH_OT_subdivide(struct wmOperatorType *ot); void MESH_OT_remove_doubles(struct wmOperatorType *ot); -void MESH_OT_vertices_randomize(struct wmOperatorType *ot); -void MESH_OT_vertices_sort(struct wmOperatorType *ot); void MESH_OT_spin(struct wmOperatorType *ot); void MESH_OT_screw(struct wmOperatorType *ot); @@ -183,7 +181,7 @@ void MESH_OT_rip(struct wmOperatorType *ot); void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot); void MESH_OT_blend_from_shape(struct wmOperatorType *ot); -void MESH_OT_sort_faces(struct wmOperatorType *ot); +void MESH_OT_sort_elements(struct wmOperatorType *ot); /* ******************* mesh_data.c */ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 9789fd03222..98dce10779f 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -87,8 +87,6 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_primitive_ico_sphere_add); WM_operatortype_append(MESH_OT_duplicate); WM_operatortype_append(MESH_OT_remove_doubles); - WM_operatortype_append(MESH_OT_vertices_sort); - WM_operatortype_append(MESH_OT_vertices_randomize); WM_operatortype_append(MESH_OT_spin); WM_operatortype_append(MESH_OT_screw); @@ -118,7 +116,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_dissolve_limited); WM_operatortype_append(MESH_OT_faces_shade_smooth); WM_operatortype_append(MESH_OT_faces_shade_flat); - WM_operatortype_append(MESH_OT_sort_faces); + WM_operatortype_append(MESH_OT_sort_elements); WM_operatortype_append(MESH_OT_delete); WM_operatortype_append(MESH_OT_edge_collapse); From ffed654ff2a1349b735026aafde6f8937a4a3f15 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 17:22:54 +0000 Subject: [PATCH 112/143] style cleanup: blenkernel --- source/blender/blenkernel/intern/anim.c | 718 +++---- source/blender/blenkernel/intern/blender.c | 244 +-- source/blender/blenkernel/intern/bvhutils.c | 115 +- .../blender/blenkernel/intern/cdderivedmesh.c | 498 ++--- source/blender/blenkernel/intern/colortools.c | 726 ++++---- source/blender/blenkernel/intern/constraint.c | 1648 ++++++++--------- source/blender/blenkernel/intern/context.c | 236 +-- source/blender/blenkernel/intern/depsgraph.c | 898 +++++---- source/blender/blenkernel/intern/displist.c | 828 ++++----- source/blender/blenkernel/intern/fcurve.c | 802 ++++---- source/blender/blenkernel/intern/fmodifier.c | 450 ++--- source/blender/blenkernel/intern/idprop.c | 134 +- source/blender/blenkernel/intern/image_gen.c | 214 +-- source/blender/blenkernel/intern/library.c | 505 ++--- source/blender/blenkernel/intern/modifier.c | 116 +- source/blender/blenkernel/intern/multires.c | 486 ++--- source/blender/blenkernel/intern/packedFile.c | 70 +- source/blender/blenkernel/intern/property.c | 178 +- source/blender/blenkernel/intern/texture.c | 14 +- 19 files changed, 4438 insertions(+), 4442 deletions(-) diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index f3b106efe33..ed6eceb036b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -88,23 +88,23 @@ void animviz_settings_init(bAnimVizSettings *avs) return; /* ghosting settings */ - avs->ghost_bc= avs->ghost_ac= 10; + avs->ghost_bc = avs->ghost_ac = 10; - avs->ghost_sf= 1; // xxx - take from scene instead? - avs->ghost_ef= 250; // xxx - take from scene instead? + avs->ghost_sf = 1; // xxx - take from scene instead? + avs->ghost_ef = 250; // xxx - take from scene instead? - avs->ghost_step= 1; + avs->ghost_step = 1; /* path settings */ - avs->path_bc= avs->path_ac= 10; + avs->path_bc = avs->path_ac = 10; - avs->path_sf= 1; // xxx - take from scene instead? - avs->path_ef= 250; // xxx - take from scene instead? + avs->path_sf = 1; // xxx - take from scene instead? + avs->path_ef = 250; // xxx - take from scene instead? - avs->path_viewflag= (MOTIONPATH_VIEW_KFRAS|MOTIONPATH_VIEW_KFNOS); + avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS); - avs->path_step= 1; + avs->path_step = 1; } /* ------------------- */ @@ -121,8 +121,8 @@ void animviz_free_motionpath_cache(bMotionPath *mpath) MEM_freeN(mpath->points); /* reset the relevant parameters */ - mpath->points= NULL; - mpath->length= 0; + mpath->points = NULL; + mpath->length = 0; } /* Free the given motion path instance and its data @@ -162,22 +162,22 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec /* get destination data */ if (pchan) { /* paths for posechannel - assume that posechannel belongs to the object */ - avs= &ob->pose->avs; - dst= &pchan->mpath; + avs = &ob->pose->avs; + dst = &pchan->mpath; } else { /* paths for object */ - avs= &ob->avs; - dst= &ob->mpath; + avs = &ob->avs; + dst = &ob->mpath; } /* avoid 0 size allocs */ if (avs->path_sf >= avs->path_ef) { BKE_reportf(reports, RPT_ERROR, - "Motion Path frame extents invalid for %s (%d to %d).%s\n", - (pchan)? pchan->name : ob->id.name, - avs->path_sf, avs->path_ef, - (avs->path_sf == avs->path_ef)? " Cannot have single-frame paths." : ""); + "Motion Path frame extents invalid for %s (%d to %d).%s\n", + (pchan) ? pchan->name : ob->id.name, + avs->path_sf, avs->path_ef, + (avs->path_sf == avs->path_ef) ? " Cannot have single-frame paths." : ""); return NULL; } @@ -187,7 +187,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec if (*dst != NULL) { int expected_length = avs->path_ef - avs->path_sf; - mpath= *dst; + mpath = *dst; /* path is "valid" if length is valid, but must also be of the same length as is being requested */ if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) { @@ -204,15 +204,15 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec } else { /* create a new motionpath, and assign it */ - mpath= MEM_callocN(sizeof(bMotionPath), "bMotionPath"); - *dst= mpath; + mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath"); + *dst = mpath; } /* set settings from the viz settings */ - mpath->start_frame= avs->path_sf; - mpath->end_frame= avs->path_ef; + mpath->start_frame = avs->path_sf; + mpath->end_frame = avs->path_ef; - mpath->length= mpath->end_frame - mpath->start_frame; + mpath->length = mpath->end_frame - mpath->start_frame; if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS) mpath->flag |= MOTIONPATH_FLAG_BHEAD; @@ -220,7 +220,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec mpath->flag &= ~MOTIONPATH_FLAG_BHEAD; /* allocate a cache */ - mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts"); + mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts"); /* tag viz settings as currently having some path(s) which use it */ avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS; @@ -235,16 +235,16 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec typedef struct MPathTarget { struct MPathTarget *next, *prev; - bMotionPath *mpath; /* motion path in question */ + bMotionPath *mpath; /* motion path in question */ - Object *ob; /* source object */ - bPoseChannel *pchan; /* source posechannel (if applicable) */ + Object *ob; /* source object */ + bPoseChannel *pchan; /* source posechannel (if applicable) */ } MPathTarget; /* ........ */ /* get list of motion paths to be baked for the given object - * - assumes the given list is ready to be used + * - assumes the given list is ready to be used */ // TODO: it would be nice in future to be able to update objects dependent on these bones too? void animviz_get_object_motionpaths(Object *ob, ListBase *targets) @@ -254,27 +254,27 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* object itself first */ if ((ob->avs.recalc & ANIMVIZ_RECALC_PATHS) && (ob->mpath)) { /* new target for object */ - mpt= MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob"); + mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob"); BLI_addtail(targets, mpt); - mpt->mpath= ob->mpath; - mpt->ob= ob; + mpt->mpath = ob->mpath; + mpt->ob = ob; } /* bones */ if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) { /* new target for bone */ - mpt= MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"); + mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"); BLI_addtail(targets, mpt); - mpt->mpath= pchan->mpath; - mpt->ob= ob; - mpt->pchan= pchan; + mpt->mpath = pchan->mpath; + mpt->ob = ob; + mpt->pchan = pchan; } } } @@ -296,12 +296,12 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) MPathTarget *mpt; /* make sure our temp-tag isn't already in use */ - for (base= scene->base.first; base; base= base->next) + for (base = scene->base.first; base; base = base->next) base->object->flag &= ~BA_TEMP_TAG; /* for each target, dump its object to the start of the list if it wasn't moved already */ - for (mpt= targets->first; mpt; mpt= mpt->next) { - for (base=scene->base.first; base; base=baseNext) { + for (mpt = targets->first; mpt; mpt = mpt->next) { + for (base = scene->base.first; base; base = baseNext) { baseNext = base->next; if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) { @@ -322,7 +322,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) static void motionpaths_calc_update_scene(Scene *scene) { #if 1 // 'production' optimisations always on - Base *base, *last=NULL; + Base *base, *last = NULL; /* only stuff that moves or needs display still */ DAG_scene_update_flags(G.main, scene, scene->lay, TRUE); @@ -331,7 +331,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * - all those afterwards are assumed to not be relevant for our calculations */ // optimize further by moving out... - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->object->flag & BA_TEMP_TAG) last = base; } @@ -339,7 +339,7 @@ static void motionpaths_calc_update_scene(Scene *scene) /* perform updates for tagged objects */ // XXX: this will break if rigs depend on scene or other data that // is animated but not attached to/updatable from objects - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { /* update this object */ BKE_object_handle_update(scene, base->object); @@ -348,11 +348,11 @@ static void motionpaths_calc_update_scene(Scene *scene) break; } #else // original, 'always correct' version - /* do all updates - * - if this is too slow, resort to using a more efficient way - * that doesn't force complete update, but for now, this is the - * most accurate way! - */ + /* do all updates + * - if this is too slow, resort to using a more efficient way + * that doesn't force complete update, but for now, this is the + * most accurate way! + */ BKE_scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving #endif } @@ -365,8 +365,8 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) MPathTarget *mpt; /* for each target, check if it can be baked on the current frame */ - for (mpt= targets->first; mpt; mpt= mpt->next) { - bMotionPath *mpath= mpt->mpath; + for (mpt = targets->first; mpt; mpt = mpt->next) { + bMotionPath *mpath = mpt->mpath; bMotionPathVert *mpv; /* current frame must be within the range the cache works for @@ -376,7 +376,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) continue; /* get the relevant cache vert to write to */ - mpv= mpath->points + (CFRA - mpath->start_frame); + mpv = mpath->points + (CFRA - mpath->start_frame); /* pose-channel or object path baking? */ if (mpt->pchan) { @@ -421,10 +421,10 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) // TODO: this method could be improved... // 1) max range for standard baking // 2) minimum range for recalc baking (i.e. between keyframes, but how?) - for (mpt= targets->first; mpt; mpt= mpt->next) { + for (mpt = targets->first; mpt; mpt = mpt->next) { /* try to increase area to do (only as much as needed) */ - sfra= MIN2(sfra, mpt->mpath->start_frame); - efra= MAX2(efra, mpt->mpath->end_frame); + sfra = MIN2(sfra, mpt->mpath->start_frame); + efra = MAX2(efra, mpt->mpath->end_frame); } if (efra <= sfra) return; @@ -433,7 +433,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) motionpaths_calc_optimise_depsgraph(scene, targets); /* calculate path over requested range */ - for (CFRA=sfra; CFRA<=efra; CFRA++) { + for (CFRA = sfra; CFRA <= efra; CFRA++) { /* update relevant data for new frame */ motionpaths_calc_update_scene(scene); @@ -442,18 +442,18 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) } /* reset original environment */ - CFRA= cfra; + CFRA = cfra; motionpaths_calc_update_scene(scene); /* clear recalc flags from targets */ - for (mpt= targets->first; mpt; mpt= mpt->next) { + for (mpt = targets->first; mpt; mpt = mpt->next) { bAnimVizSettings *avs; /* get pointer to animviz settings for each target */ if (mpt->pchan) - avs= &mpt->ob->pose->avs; + avs = &mpt->ob->pose->avs; else - avs= &mpt->ob->avs; + avs = &mpt->ob->avs; /* clear the flag requesting recalculation of targets */ avs->recalc &= ~ANIMVIZ_RECALC_PATHS; @@ -474,7 +474,7 @@ void free_path(Path *path) } /* calculate a curve-deform path for a curve - * - only called from displist.c -> do_makeDispListCurveTypes + * - only called from displist.c -> do_makeDispListCurveTypes */ void calc_curvepath(Object *ob) { @@ -485,92 +485,92 @@ void calc_curvepath(Object *ob) Nurb *nu; Path *path; float *fp, *dist, *maxdist, xyz[3]; - float fac, d=0, fac1, fac2; - int a, tot, cycl=0; + float fac, d = 0, fac1, fac2; + int a, tot, cycl = 0; ListBase *nurbs; /* in a path vertices are with equal differences: path->len = number of verts */ /* NOW WITH BEVELCURVE!!! */ - if (ob==NULL || ob->type != OB_CURVE) return; - cu= ob->data; + if (ob == NULL || ob->type != OB_CURVE) return; + cu = ob->data; - nurbs= BKE_curve_nurbs_get(cu); - nu= nurbs->first; + nurbs = BKE_curve_nurbs_get(cu); + nu = nurbs->first; if (cu->path) free_path(cu->path); - cu->path= NULL; + cu->path = NULL; - bl= cu->bev.first; - if (bl==NULL || !bl->nr) return; + bl = cu->bev.first; + if (bl == NULL || !bl->nr) return; - cu->path=path= MEM_callocN(sizeof(Path), "calc_curvepath"); + cu->path = path = MEM_callocN(sizeof(Path), "calc_curvepath"); /* if POLY: last vertice != first vertice */ - cycl= (bl->poly!= -1); + cycl = (bl->poly != -1); - if (cycl) tot= bl->nr; - else tot= bl->nr-1; + if (cycl) tot = bl->nr; + else tot = bl->nr - 1; - path->len= tot+1; + path->len = tot + 1; /* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */ - if (path->lenresolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu); + if (path->len < nu->resolu * SEGMENTSU(nu)) path->len = nu->resolu * SEGMENTSU(nu); - dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist"); + dist = (float *)MEM_mallocN((tot + 1) * 4, "calcpathdist"); - /* all lengths in *dist */ - bevp= bevpfirst= (BevPoint *)(bl+1); - fp= dist; - *fp= 0; - for (a=0; avec, bevp->vec); else - sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec); + sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec); - *fp= *(fp-1)+len_v3(xyz); + *fp = *(fp - 1) + len_v3(xyz); bevp++; } - path->totdist= *fp; + path->totdist = *fp; - /* the path verts in path->data */ - /* now also with TILT value */ - pp= path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint)*path->len, "pathdata"); + /* the path verts in path->data */ + /* now also with TILT value */ + pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata"); + + bevp = bevpfirst; + bevpn = bevp + 1; + bevplast = bevpfirst + (bl->nr - 1); + fp = dist + 1; + maxdist = dist + tot; + fac = 1.0f / ((float)path->len - 1.0f); + fac = fac * path->totdist; - bevp= bevpfirst; - bevpn= bevp+1; - bevplast= bevpfirst + (bl->nr-1); - fp= dist+1; - maxdist= dist+tot; - fac= 1.0f/((float)path->len-1.0f); - fac = fac * path->totdist; - - for (a=0; alen; a++) { + for (a = 0; a < path->len; a++) { - d= ((float)a)*fac; + d = ((float)a) * fac; /* we're looking for location (distance) 'd' in the array */ - while ((d>= *fp) && fp= *fp) && fp < maxdist) { fp++; - if (bevpbevplast) { - if (cycl) bevpn= bevpfirst; - else bevpn= bevplast; + if (bevp < bevplast) bevp++; + bevpn = bevp + 1; + if (bevpn > bevplast) { + if (cycl) bevpn = bevpfirst; + else bevpn = bevplast; } } - fac1= *(fp)- *(fp-1); - fac2= *(fp)-d; - fac1= fac2/fac1; - fac2= 1.0f-fac1; + fac1 = *(fp) - *(fp - 1); + fac2 = *(fp) - d; + fac1 = fac2 / fac1; + fac2 = 1.0f - fac1; interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); - pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa; - pp->radius= fac1*bevp->radius + fac2*bevpn->radius; - pp->weight= fac1*bevp->weight + fac2*bevpn->weight; + pp->vec[3] = fac1 * bevp->alfa + fac2 * bevpn->alfa; + pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius; + pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight; interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); normalize_qt(pp->quat); @@ -586,13 +586,13 @@ int interval_test(int min, int max, int p1, int cycl) { if (cycl) { if (p1 < min) - p1= ((p1 -min) % (max-min+1)) + max+1; + p1 = ((p1 - min) % (max - min + 1)) + max + 1; else if (p1 > max) - p1= ((p1 -min) % (max-min+1)) + min; + p1 = ((p1 - min) % (max - min + 1)) + min; } else { - if (p1 < min) p1= min; - else if (p1 > max) p1= max; + if (p1 < min) p1 = min; + else if (p1 > max) p1 = max; } return p1; } @@ -614,84 +614,84 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua PathPoint *pp, *p0, *p1, *p2, *p3; float fac; float data[4]; - int cycl=0, s0, s1, s2, s3; + int cycl = 0, s0, s1, s2, s3; - if (ob==NULL || ob->type != OB_CURVE) return 0; - cu= ob->data; - if (cu->path==NULL || cu->path->data==NULL) { + if (ob == NULL || ob->type != OB_CURVE) return 0; + cu = ob->data; + if (cu->path == NULL || cu->path->data == NULL) { printf("no path!\n"); return 0; } - path= cu->path; - pp= path->data; + path = cu->path; + pp = path->data; /* test for cyclic */ - bl= cu->bev.first; + bl = cu->bev.first; if (!bl) return 0; if (!bl->nr) return 0; - if (bl->poly> -1) cycl= 1; + if (bl->poly > -1) cycl = 1; - ctime *= (path->len-1); + ctime *= (path->len - 1); - s1= (int)floor(ctime); - fac= (float)(s1+1)-ctime; + s1 = (int)floor(ctime); + fac = (float)(s1 + 1) - ctime; /* path->len is corected for cyclic */ - s0= interval_test(0, path->len-1-cycl, s1-1, cycl); - s1= interval_test(0, path->len-1-cycl, s1, cycl); - s2= interval_test(0, path->len-1-cycl, s1+1, cycl); - s3= interval_test(0, path->len-1-cycl, s1+2, cycl); + s0 = interval_test(0, path->len - 1 - cycl, s1 - 1, cycl); + s1 = interval_test(0, path->len - 1 - cycl, s1, cycl); + s2 = interval_test(0, path->len - 1 - cycl, s1 + 1, cycl); + s3 = interval_test(0, path->len - 1 - cycl, s1 + 2, cycl); - p0= pp + s0; - p1= pp + s1; - p2= pp + s2; - p3= pp + s3; + p0 = pp + s0; + p1 = pp + s1; + p2 = pp + s2; + p3 = pp + s3; /* note, commented out for follow constraint */ //if (cu->flag & CU_FOLLOW) { - key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE); + key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE); - interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data); + interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data); - /* make compatible with vectoquat */ - negate_v3(dir); + /* make compatible with vectoquat */ + negate_v3(dir); //} - nu= cu->nurb.first; + nu = cu->nurb.first; /* make sure that first and last frame are included in the vectors here */ - if (nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR); - else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR); - else if (s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL); - else key_curve_position_weights(1.0f-fac, data, KEY_BSPLINE); + if (nu->type == CU_POLY) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); + else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); + else if (s0 == s1 || p2 == p3) key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL); + else key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE); - vec[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ; /* X */ - vec[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ; /* Y */ - vec[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ; /* Z */ - vec[3]= data[0]*p0->vec[3] + data[1]*p1->vec[3] + data[2]*p2->vec[3] + data[3]*p3->vec[3] ; /* Tilt, should not be needed since we have quat still used */ + vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + data[3] * p3->vec[0]; /* X */ + vec[1] = data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + data[3] * p3->vec[1]; /* Y */ + vec[2] = data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + data[3] * p3->vec[2]; /* Z */ + vec[3] = data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + data[3] * p3->vec[3]; /* Tilt, should not be needed since we have quat still used */ if (quat) { float totfac, q1[4], q2[4]; - totfac= data[0]+data[3]; - if (totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); - else copy_qt_qt(q1, p1->quat); + totfac = data[0] + data[3]; + if (totfac > FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); + else copy_qt_qt(q1, p1->quat); - totfac= data[1]+data[2]; - if (totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); - else copy_qt_qt(q2, p3->quat); + totfac = data[1] + data[2]; + if (totfac > FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); + else copy_qt_qt(q2, p3->quat); - totfac = data[0]+data[1]+data[2]+data[3]; - if (totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac); - else copy_qt_qt(quat, q2); + totfac = data[0] + data[1] + data[2] + data[3]; + if (totfac > FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac); + else copy_qt_qt(quat, q2); } if (radius) - *radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius; + *radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius + data[3] * p3->radius; if (weight) - *weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight; + *weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight + data[3] * p3->weight; return 1; } @@ -701,17 +701,17 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int type, int animated) { - DupliObject *dob= MEM_callocN(sizeof(DupliObject), "dupliobject"); + DupliObject *dob = MEM_callocN(sizeof(DupliObject), "dupliobject"); BLI_addtail(lb, dob); - dob->ob= ob; + dob->ob = ob; copy_m4_m4(dob->mat, mat); copy_m4_m4(dob->omat, ob->obmat); - dob->origlay= ob->lay; - dob->index= index; - dob->type= type; - dob->animated= (type == OB_DUPLIGROUP) && animated; - ob->lay= lay; + dob->origlay = ob->lay; + dob->index = index; + dob->type = type; + dob->animated = (type == OB_DUPLIGROUP) && animated; + ob->lay = lay; return dob; } @@ -723,20 +723,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i GroupObject *go; float mat[4][4], tmat[4][4]; - if (ob->dup_group==NULL) return; - group= ob->dup_group; + if (ob->dup_group == NULL) return; + group = ob->dup_group; /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; /* handles animated groups, and */ /* we need to check update for objects that are not in scene... */ group_handle_recalc_and_update(scene, ob, group); - animated= animated || group_is_animated(ob, group); + animated = animated || group_is_animated(ob, group); - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { /* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */ - if (go->ob!=ob) { + if (go->ob != ob) { /* group dupli offset, should apply after everything else */ if (!is_zero_v3(group->dupli_ofs)) { @@ -748,22 +748,22 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i mult_m4_m4m4(mat, ob->obmat, go->ob->obmat); } - dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); + dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); /* check the group instance and object layers match, also that the object visible flags are ok. */ - if ( (dob->origlay & group->layer)==0 || - (G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || - (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER) - ) { - dob->no_draw= 1; + if ( (dob->origlay & group->layer) == 0 || + (G.rendering == 0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || + (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER) + ) { + dob->no_draw = 1; } else { - dob->no_draw= 0; + dob->no_draw = 0; } if (go->ob->transflag & OB_DUPLI) { copy_m4_m4(dob->ob->obmat, dob->mat); - object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level+1, animated); + object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level + 1, animated); copy_m4_m4(dob->ob->obmat, dob->omat); } } @@ -772,7 +772,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated) { - extern int enable_cu_speed; /* object.c */ + extern int enable_cu_speed; /* object.c */ Object copyob; int cfrao = scene->r.cfra; int dupend = ob->dupend; @@ -783,7 +783,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, /* if we don't have any data/settings which will lead to object movement, * don't waste time trying, as it will all look the same... */ - if (ob->parent==NULL && ob->constraints.first==NULL && ob->adt==NULL) + if (ob->parent == NULL && ob->constraints.first == NULL && ob->adt == NULL) return; /* make a copy of the object's original data (before any dupli-data overwrites it) @@ -794,18 +794,18 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, copyob = *ob; /* duplicate over the required range */ - if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; + if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed = 0; - for (scene->r.cfra= ob->dupsta; scene->r.cfra<=dupend; scene->r.cfra++) { - short ok= 1; + for (scene->r.cfra = ob->dupsta; scene->r.cfra <= dupend; scene->r.cfra++) { + short ok = 1; /* - dupoff = how often a frames within the range shouldn't be made into duplis * - dupon = the length of each "skipping" block in frames */ if (ob->dupoff) { - ok= scene->r.cfra - ob->dupsta; - ok= ok % (ob->dupon+ob->dupoff); - ok= (ok < ob->dupon); + ok = scene->r.cfra - ob->dupsta; + ok = ok % (ob->dupon + ob->dupoff); + ok = (ok < ob->dupon); } if (ok) { @@ -818,17 +818,17 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, 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 */ 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); + dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); copy_m4_m4(dob->omat, copyob.obmat); } } - enable_cu_speed= 1; + enable_cu_speed = 1; /* reset frame to original frame, then re-evaluate animation as above * as 2.5 animation data may have far-reaching consequences */ - scene->r.cfra= cfrao; + 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 */ BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); @@ -857,7 +857,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]) { DupliObject *dob; - vertexDupliData *vdd= userData; + vertexDupliData *vdd = userData; float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4]; int origlay; @@ -870,10 +870,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], if (vdd->par->transflag & OB_DUPLIROT) { if (no_f) { - vec[0]= -no_f[0]; vec[1]= -no_f[1]; vec[2]= -no_f[2]; + vec[0] = -no_f[0]; vec[1] = -no_f[1]; vec[2] = -no_f[2]; } else if (no_s) { - vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2]; + vec[0] = -no_s[0]; vec[1] = -no_s[1]; vec[2] = -no_s[2]; } vec_to_quat(q2, vec, vdd->ob->trackflag, vdd->ob->upflag); @@ -885,7 +885,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], origlay = vdd->ob->lay; - dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); + dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); /* restore the original layer so that each dupli will have proper dob->origlay */ vdd->ob->lay = origlay; @@ -897,7 +897,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], float tmpmat[4][4]; copy_m4_m4(tmpmat, vdd->ob->obmat); copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */ - object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated); + object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level + 1, vdd->animated); copy_m4_m4(vdd->ob->obmat, tmpmat); } } @@ -905,13 +905,13 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int level, int animated) { Object *ob, *ob_iter; - Mesh *me= par->data; + Mesh *me = par->data; Base *base = NULL; DerivedMesh *dm; vertexDupliData vdd; Scene *sce = NULL; Group *group = NULL; - GroupObject * go = NULL; + GroupObject *go = NULL; BMEditMesh *em; float vec[3], no[3], pmat[4][4]; int totvert, a, oblay; @@ -920,54 +920,54 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl copy_m4_m4(pmat, par->obmat); /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; em = me->edit_btmesh; if (em) { - dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); + dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); } else - dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); + dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); if (G.rendering) { - vdd.orco= (float(*)[3])BKE_mesh_orco_verts_get(par); + vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par); BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0); } else - vdd.orco= NULL; + vdd.orco = NULL; totvert = dm->getNumVerts(dm); /* having to loop on scene OR group objects is NOT FUN */ if (GS(id->name) == ID_SCE) { sce = (Scene *)id; - lay= sce->lay; - base= sce->base.first; + lay = sce->lay; + base = sce->base.first; } else { group = (Group *)id; - lay= group->layer; + lay = group->layer; go = group->gobject.first; } /* Start looping on Scene OR Group objects */ while (base || go) { if (sce) { - ob_iter= base->object; + ob_iter = base->object; oblay = base->lay; } else { - ob_iter= go->ob; + ob_iter = go->ob; oblay = ob_iter->lay; } - if (lay & oblay && scene->obedit!=ob_iter) { - ob=ob_iter->parent; + if (lay & oblay && scene->obedit != ob_iter) { + ob = ob_iter->parent; while (ob) { - if (ob==par) { + if (ob == par) { ob = ob_iter; - /* End Scene/Group object loop, below is generic */ + /* End Scene/Group object loop, below is generic */ /* par_space_mat - only used for groups so we can modify the space dupli's are in @@ -978,23 +978,23 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl else copy_m4_m4(vdd.obmat, ob->obmat); - vdd.id= id; - vdd.level= level; - vdd.animated= animated; - vdd.lb= lb; - vdd.ob= ob; - vdd.scene= scene; - vdd.par= par; + vdd.id = id; + vdd.level = level; + vdd.animated = animated; + vdd.lb = lb; + vdd.ob = ob; + vdd.scene = scene; + vdd.par = par; copy_m4_m4(vdd.pmat, pmat); /* mballs have a different dupli handling */ - if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ + if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ if (me->edit_btmesh) { - dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd); + dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd); } else { - for (a=0; agetVertCo(dm, a, vec); dm->getVertNo(dm, a, no); @@ -1012,11 +1012,11 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl break; } - ob= ob->parent; + ob = ob->parent; } } - if (sce) base= base->next; /* scene loop */ - else go= go->next; /* group loop */ + if (sce) base = base->next; /* scene loop */ + else go = go->next; /* group loop */ } if (vdd.orco) @@ -1030,7 +1030,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa Base *base = NULL; DupliObject *dob; DerivedMesh *dm; - Mesh *me= par->data; + Mesh *me = par->data; MLoopUV *mloopuv; MPoly *mpoly, *mp; MLoop *mloop; @@ -1044,63 +1044,63 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */ /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; copy_m4_m4(pmat, par->obmat); em = me->edit_btmesh; if (em) { - dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); + dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); } else { dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); } - totface= dm->getNumPolys(dm); - mpoly= dm->getPolyArray(dm); - mloop= dm->getLoopArray(dm); - mvert= dm->getVertArray(dm); + totface = dm->getNumPolys(dm); + mpoly = dm->getPolyArray(dm); + mloop = dm->getLoopArray(dm); + mvert = dm->getVertArray(dm); if (G.rendering) { - orco= (float(*)[3])BKE_mesh_orco_verts_get(par); + orco = (float(*)[3])BKE_mesh_orco_verts_get(par); BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0); - mloopuv= me->mloopuv; + mloopuv = me->mloopuv; } else { - orco= NULL; - mloopuv= NULL; + orco = NULL; + mloopuv = NULL; } /* having to loop on scene OR group objects is NOT FUN */ if (GS(id->name) == ID_SCE) { sce = (Scene *)id; - lay= sce->lay; - base= sce->base.first; + lay = sce->lay; + base = sce->base.first; } else { group = (Group *)id; - lay= group->layer; + lay = group->layer; go = group->gobject.first; } /* Start looping on Scene OR Group objects */ while (base || go) { if (sce) { - ob_iter= base->object; + ob_iter = base->object; oblay = base->lay; } else { - ob_iter= go->ob; + ob_iter = go->ob; oblay = ob_iter->lay; } - if (lay & oblay && scene->obedit!=ob_iter) { - ob=ob_iter->parent; + if (lay & oblay && scene->obedit != ob_iter) { + ob = ob_iter->parent; while (ob) { - if (ob==par) { + if (ob == par) { ob = ob_iter; - /* End Scene/Group object loop, below is generic */ + /* End Scene/Group object loop, below is generic */ /* par_space_mat - only used for groups so we can modify the space dupli's are in * when par_space_mat is NULL ob->obmat can be used instead of ob__obmat @@ -1113,9 +1113,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_m3_m4(imat, ob->parentinv); /* mballs have a different dupli handling */ - if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ + if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ - for (a=0, mp= mpoly; aloopstart; + MLoop *loopstart = mloop + mp->loopstart; if (mp->totloop < 3) { /* highly unlikely but to be safe */ continue; } else { - v1= mvert[(mv1= loopstart[0].v)].co; - v2= mvert[(mv2= loopstart[1].v)].co; - v3= mvert[(mv3= loopstart[2].v)].co; + v1 = mvert[(mv1 = loopstart[0].v)].co; + v2 = mvert[(mv2 = loopstart[1].v)].co; + v3 = mvert[(mv3 = loopstart[2].v)].co; #if 0 if (mp->totloop > 3) { - v4= mvert[(mv4= loopstart[3].v)].co; + v4 = mvert[(mv4 = loopstart[3].v)].co; } #endif } @@ -1160,8 +1160,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* scale */ if (par->transflag & OB_DUPLIFACES_SCALE) { - float size= BKE_mesh_calc_poly_area(mp, loopstart, mvert, NULL); - size= sqrtf(size) * par->dupfacesca; + float size = BKE_mesh_calc_poly_area(mp, loopstart, mvert, NULL); + size = sqrtf(size) * par->dupfacesca; mul_m3_fl(mat, size); } @@ -1171,9 +1171,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_m4_m4(tmat, obmat); mul_m4_m4m3(obmat, tmat, mat); - dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated); + dob = new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated); if (G.rendering) { - w= 1.0f / (float)mp->totloop; + w = 1.0f / (float)mp->totloop; if (orco) { int j; @@ -1194,18 +1194,18 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa float tmpmat[4][4]; copy_m4_m4(tmpmat, ob->obmat); copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */ - object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated); + object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level + 1, animated); copy_m4_m4(ob->obmat, tmpmat); } } break; } - ob= ob->parent; + ob = ob->parent; } } - if (sce) base= base->next; /* scene loop */ - else go= go->next; /* group loop */ + if (sce) base = base->next; /* scene loop */ + else go = go->next; /* group loop */ } if (orco) @@ -1217,30 +1217,30 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) { GroupObject *go; - Object *ob=NULL, **oblist=NULL, obcopy, *obcopylist=NULL; + Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL; DupliObject *dob; ParticleDupliWeight *dw; ParticleSettings *part; ParticleData *pa; - ChildParticle *cpa=NULL; + ChildParticle *cpa = NULL; ParticleKey state; ParticleCacheKey *cache; float ctime, pa_time, scale = 1.0f; - float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0; + float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size = 0.0; float (*obmat)[4], (*oldobmat)[4]; int a, b, counter, hair = 0; - int totpart, totchild, totgroup=0 /*, pa_num */; + int totpart, totchild, totgroup = 0 /*, pa_num */; int no_draw_flag = PARS_UNEXIST; - if (psys==NULL) return; + if (psys == NULL) return; /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; - part=psys->part; + part = psys->part; - if (part==NULL) + if (part == NULL) return; if (!psys_check_enabled(par, psys)) @@ -1256,12 +1256,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p BLI_srandom(31415926 + psys->seed); - if ((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - ParticleSimulationData sim= {NULL}; - sim.scene= scene; - sim.ob= par; - sim.psys= psys; - sim.psmd= psys_get_modifier(par, psys); + if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + ParticleSimulationData sim = {NULL}; + sim.scene = scene; + sim.ob = par; + sim.psys = psys; + sim.psmd = psys_get_modifier(par, psys); /* make sure emitter imat is in global coordinates instead of render view coordinates */ invert_m4_m4(par->imat, par->obmat); @@ -1274,7 +1274,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->dup_group == NULL || part->dup_group->gobject.first == NULL) return; - for (go=part->dup_group->gobject.first; go; go=go->next) + for (go = part->dup_group->gobject.first; go; go = go->next) if (go->ob == par) return; } @@ -1282,7 +1282,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* if we have a hair particle system, use the path cache */ if (part->type == PART_HAIR) { if (psys->flag & PSYS_HAIR_DONE) - hair= (totchild == 0 || psys->childcache) && psys->pathcache; + hair = (totchild == 0 || psys->childcache) && psys->pathcache; if (!hair) return; @@ -1296,29 +1296,29 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p psys->lattice = psys_get_lattice(&sim); /* gather list of objects or single object */ - if (part->ren_as==PART_DRAW_GR) { + if (part->ren_as == PART_DRAW_GR) { group_handle_recalc_and_update(scene, par, part->dup_group); if (part->draw & PART_DRAW_COUNT_GR) { - for (dw=part->dupliweights.first; dw; dw=dw->next) + for (dw = part->dupliweights.first; dw; dw = dw->next) totgroup += dw->count; } else { - for (go=part->dup_group->gobject.first; go; go=go->next) + for (go = part->dup_group->gobject.first; go; go = go->next) totgroup++; } /* we also copy the actual objects to restore afterwards, since * 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"); + oblist = MEM_callocN(totgroup * sizeof(Object *), "dupgroup object list"); + obcopylist = MEM_callocN(totgroup * sizeof(Object), "dupgroup copy list"); if (part->draw & PART_DRAW_COUNT_GR && totgroup) { dw = part->dupliweights.first; - for (a=0; anext) { - for (b=0; bcount; b++, a++) { + for (a = 0; a < totgroup; dw = dw->next) { + for (b = 0; b < dw->count; b++, a++) { oblist[a] = dw->ob; obcopylist[a] = *dw->ob; } @@ -1326,7 +1326,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } else { go = part->dup_group->gobject.first; - for (a=0; anext) { + for (a = 0; a < totgroup; a++, go = go->next) { oblist[a] = go->ob; obcopylist[a] = *go->ob; } @@ -1337,13 +1337,13 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p obcopy = *ob; } - if (totchild==0 || part->draw & PART_DRAW_PARENT) + if (totchild == 0 || part->draw & PART_DRAW_PARENT) a = 0; else a = totpart; - for (pa=psys->particles, counter=0; aparticles, counter = 0; a < totpart + totchild; a++, pa++, counter++) { + if (a < totpart) { /* handle parent particle */ if (pa->flag & no_draw_flag) continue; @@ -1364,29 +1364,29 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* some hair paths might be non-existent so they can't be used for duplication */ if (hair && ((a < totpart && psys->pathcache[a]->steps < 0) || - (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + (a >= totpart && psys->childcache[a - totpart]->steps < 0))) { continue; } - if (part->ren_as==PART_DRAW_GR) { + if (part->ren_as == PART_DRAW_GR) { /* prevent divide by zero below [#28336] */ if (totgroup == 0) continue; /* for groups, pick the object based on settings */ - if (part->draw&PART_DRAW_RAND_GR) - b= BLI_rand() % totgroup; + if (part->draw & PART_DRAW_RAND_GR) + b = BLI_rand() % totgroup; else - b= a % totgroup; + b = a % totgroup; ob = oblist[b]; obmat = oblist[b]->obmat; oldobmat = obcopylist[b].obmat; } else { - obmat= ob->obmat; - oldobmat= obcopy.obmat; + obmat = ob->obmat; + oldobmat = obcopy.obmat; } if (hair) { @@ -1396,12 +1396,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale); } else { - cache = psys->childcache[a-totpart]; + cache = psys->childcache[a - totpart]; psys_get_dupli_path_transform(&sim, NULL, cpa, cache, pamat, &scale); } copy_v3_v3(pamat[3], cache->co); - pamat[3][3]= 1.0f; + pamat[3][3] = 1.0f; } else { @@ -1415,17 +1415,17 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p normalize_qt_qt(tquat, state.rot); quat_to_mat4(pamat, tquat); copy_v3_v3(pamat[3], state.co); - pamat[3][3]= 1.0f; + pamat[3][3] = 1.0f; } } - if (part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { - for (go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) { + if (part->ren_as == PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { + for (go = part->dup_group->gobject.first, b = 0; go; go = go->next, b++) { copy_m4_m4(tmat, oblist[b]->obmat); /* apply particle scale */ - mul_mat3_m4_fl(tmat, size*scale); - mul_v3_fl(tmat[3], size*scale); + mul_mat3_m4_fl(tmat, size * scale); + mul_v3_fl(tmat[3], size * scale); /* group dupli offset, should apply after everything else */ if (!is_zero_v3(part->dup_group->dupli_ofs)) sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs); @@ -1437,7 +1437,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p else copy_m4_m4(mat, tmat); - dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); + dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, obcopylist[b].obmat); if (G.rendering) psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco); @@ -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 */ - BKE_object_where_is_calc_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; @@ -1457,7 +1457,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p xvec[1] = xvec[2] = 0; vec_to_quat(q, xvec, ob->trackflag, ob->upflag); quat_to_mat4(obmat, q); - obmat[3][3]= 1.0f; + obmat[3][3] = 1.0f; } /* Normal particles and cached hair live in global space so we need to @@ -1469,7 +1469,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p copy_m4_m4(mat, pamat); mult_m4_m4m4(tmat, mat, obmat); - mul_mat3_m4_fl(tmat, size*scale); + mul_mat3_m4_fl(tmat, size * scale); if (par_space_mat) mult_m4_m4m4(mat, par_space_mat, tmat); @@ -1479,7 +1479,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->draw & PART_DRAW_GLOBAL_OB) add_v3_v3v3(mat[3], mat[3], vec); - dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated); + dob = new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, oldobmat); if (G.rendering) psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco); @@ -1487,12 +1487,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } /* restore objects since they were changed in BKE_object_where_is_calc_time */ - if (part->ren_as==PART_DRAW_GR) { - for (a=0; aren_as == PART_DRAW_GR) { + for (a = 0; a < totgroup; a++) + *(oblist[a]) = obcopylist[a]; } else - *ob= obcopy; + *ob = obcopy; } /* clean up */ @@ -1512,19 +1512,19 @@ static Object *find_family_object(Object **obar, char *family, char ch) Object *ob; int flen; - if ( obar[(int)ch] ) return obar[(int)ch]; + if (obar[(int)ch]) return obar[(int)ch]; - flen= strlen(family); + flen = strlen(family); - ob= G.main->object.first; + ob = G.main->object.first; while (ob) { if (ob->id.name[flen + 2] == ch) { - if ( strncmp(ob->id.name+2, family, flen)==0 ) break; + if (strncmp(ob->id.name + 2, family, flen) == 0) break; } - ob= ob->id.next; + ob = ob->id.next; } - obar[(int)ch]= ob; + obar[(int)ch] = ob; return ob; } @@ -1532,37 +1532,37 @@ static Object *find_family_object(Object **obar, char *family, char ch) static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated) { - Object *ob, *obar[256]= {NULL}; + Object *ob, *obar[256] = {NULL}; Curve *cu; struct chartrans *ct, *chartransdata; float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof; int slen, a; /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; copy_m4_m4(pmat, par->obmat); /* in par the family name is stored, use this to find the other objects */ - chartransdata= BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI); - if (chartransdata==NULL) return; + chartransdata = BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI); + if (chartransdata == NULL) return; - cu= par->data; - slen= strlen(cu->str); - fsize= cu->fsize; - xof= cu->xof; - yof= cu->yof; + cu = par->data; + slen = strlen(cu->str); + fsize = cu->fsize; + xof = cu->xof; + yof = cu->yof; - ct= chartransdata; + ct = chartransdata; - for (a=0; afamily, cu->str[a]); + ob = find_family_object(obar, cu->family, cu->str[a]); if (ob) { - vec[0]= fsize*(ct->xof - xof); - vec[1]= fsize*(ct->yof - yof); - vec[2]= 0.0; + vec[0] = fsize * (ct->xof - xof); + vec[1] = fsize * (ct->yof - yof); + vec[2] = 0.0; mul_m4_v3(pmat, vec); @@ -1580,7 +1580,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated) { - if ((ob->transflag & OB_DUPLI)==0) + if ((ob->transflag & OB_DUPLI) == 0) return; /* Should the dupli's be generated for this object? - Respect restrict flags */ @@ -1597,35 +1597,35 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas if (ob->transflag & OB_DUPLIPARTS) { ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) - new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level+1, animated); + for (; psys; psys = psys->next) + new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level + 1, animated); } else if (ob->transflag & OB_DUPLIVERTS) { - if (ob->type==OB_MESH) { - vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated); + if (ob->type == OB_MESH) { + vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level + 1, animated); } - else if (ob->type==OB_FONT) { - if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */ - font_duplilist(duplilist, scene, ob, level+1, animated); + else if (ob->type == OB_FONT) { + if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */ + font_duplilist(duplilist, scene, ob, level + 1, animated); } } } else if (ob->transflag & OB_DUPLIFACES) { - if (ob->type==OB_MESH) - face_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated); + if (ob->type == OB_MESH) + face_duplilist(duplilist, id, scene, ob, par_space_mat, level + 1, animated); } else if (ob->transflag & OB_DUPLIFRAMES) { - if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */ - frames_duplilist(duplilist, scene, ob, level+1, animated); + if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */ + frames_duplilist(duplilist, scene, ob, level + 1, animated); } } else if (ob->transflag & OB_DUPLIGROUP) { DupliObject *dob; - group_duplilist(duplilist, scene, ob, level+1, animated); /* now recursive */ + group_duplilist(duplilist, scene, ob, level + 1, animated); /* now recursive */ - if (level==0) { - for (dob= duplilist->first; dob; dob= dob->next) + if (level == 0) { + for (dob = duplilist->first; dob; dob = dob->next) if (dob->type == OB_DUPLIGROUP) copy_m4_m4(dob->ob->obmat, dob->mat); } @@ -1636,8 +1636,8 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas * note; group dupli's already set transform matrix. see note in group_duplilist() */ ListBase *object_duplilist(Scene *sce, Object *ob) { - ListBase *duplilist= MEM_mallocN(sizeof(ListBase), "duplilist"); - duplilist->first= duplilist->last= NULL; + ListBase *duplilist = MEM_mallocN(sizeof(ListBase), "duplilist"); + duplilist->first = duplilist->last = NULL; object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0); return duplilist; } @@ -1649,8 +1649,8 @@ void free_object_duplilist(ListBase *lb) /* loop in reverse order, if object is instanced multiple times * the original layer may not really be original otherwise, proper * solution is more complicated */ - for (dob= lb->last; dob; dob= dob->prev) { - dob->ob->lay= dob->origlay; + for (dob = lb->last; dob; dob = dob->prev) { + dob->ob->lay = dob->origlay; copy_m4_m4(dob->ob->obmat, dob->omat); } @@ -1662,16 +1662,16 @@ int count_duplilist(Object *ob) { if (ob->transflag & OB_DUPLI) { if (ob->transflag & OB_DUPLIVERTS) { - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { if (ob->transflag & OB_DUPLIVERTS) { ParticleSystem *psys = ob->particlesystem.first; - int pdup=0; + int pdup = 0; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) pdup += psys->totpart; - if (pdup==0) { - Mesh *me= ob->data; + if (pdup == 0) { + Mesh *me = ob->data; return me->totvert; } else @@ -1680,9 +1680,9 @@ int count_duplilist(Object *ob) } } else if (ob->transflag & OB_DUPLIFRAMES) { - int tot= ob->dupend - ob->dupsta; - tot/= (ob->dupon+ob->dupoff); - return tot*ob->dupon; + int tot = ob->dupend - ob->dupsta; + tot /= (ob->dupon + ob->dupoff); + return tot * ob->dupon; } } return 1; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 58ada7b0784..d8ae95e08e2 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -95,7 +95,7 @@ Global G; UserDef U; /* ListBase = {NULL, NULL}; */ -char versionstr[48]= ""; +char versionstr[48] = ""; /* ********** free ********** */ @@ -104,9 +104,9 @@ void free_blender(void) { /* samples are in a global list..., also sets G.main->sound->sample NULL */ free_main(G.main); - G.main= NULL; + G.main = NULL; - BKE_spacetypes_free(); /* after free main, it uses space callbacks */ + BKE_spacetypes_free(); /* after free main, it uses space callbacks */ IMB_exit(); @@ -122,18 +122,18 @@ void initglobals(void) { memset(&G, 0, sizeof(Global)); - U.savetime= 1; + U.savetime = 1; - G.main= MEM_callocN(sizeof(Main), "initglobals"); + G.main = MEM_callocN(sizeof(Main), "initglobals"); strcpy(G.ima, "//"); if (BLENDER_SUBVERSION) - BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); + BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); else - BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100); + BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION / 100, BLENDER_VERSION % 100); -#ifdef _WIN32 // FULLSCREEN +#ifdef _WIN32 // FULLSCREEN G.windowstate = G_WINDOWSTATE_USERDEF; #endif @@ -154,11 +154,11 @@ static void clear_global(void) { // extern short winqueue_break; /* screen.c */ - free_main(G.main); /* free all lib data */ + free_main(G.main); /* free all lib data */ // free_vertexpaint(); - G.main= NULL; + G.main = NULL; } static int clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src) @@ -175,7 +175,7 @@ static void clean_paths(Main *main) 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) { + for (scene = main->scene.first; scene; scene = scene->id.next) { BLI_clean(scene->r.pic); } } @@ -188,17 +188,17 @@ static void clean_paths(Main *main) static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath) { - bScreen *curscreen= NULL; - Scene *curscene= NULL; + bScreen *curscreen = NULL; + Scene *curscene = NULL; int recover; char mode; /* 'u' = undo save, 'n' = no UI load */ - if (bfd->main->screen.first==NULL) mode= 'u'; - else if (G.fileflags & G_FILE_NO_UI) mode= 'n'; - else mode= 0; + if (bfd->main->screen.first == NULL) mode = 'u'; + else if (G.fileflags & G_FILE_NO_UI) mode = 'n'; + else mode = 0; - recover= (G.fileflags & G_FILE_RECOVER); + recover = (G.fileflags & G_FILE_RECOVER); /* Free all render results, without this stale data gets displayed after loading files */ if (mode != 'u') { @@ -222,12 +222,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath SWAP(ListBase, G.main->script, bfd->main->script); /* we re-use current screen */ - curscreen= CTX_wm_screen(C); + curscreen = CTX_wm_screen(C); /* but use new Scene pointer */ - curscene= bfd->curscene; - if (curscene==NULL) curscene= bfd->main->scene.first; + curscene = bfd->curscene; + if (curscene == NULL) curscene = bfd->main->scene.first; /* and we enforce curscene to be in current screen */ - if (curscreen) curscreen->scene= curscene; /* can run in bgmode */ + if (curscreen) curscreen->scene = curscene; /* can run in bgmode */ /* clear_global will free G.main, here we can still restore pointers */ lib_link_screen_restore(bfd->main, curscreen, curscene); @@ -240,7 +240,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - G.main= bfd->main; + G.main = bfd->main; CTX_data_main_set(C, G.main); @@ -251,7 +251,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* only here free userdef themes... */ BKE_userdef_free(); - U= *bfd->user; + U = *bfd->user; MEM_freeN(bfd->user); } @@ -261,9 +261,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath CTX_data_scene_set(C, curscene); } else { - G.winpos= bfd->winpos; - G.displaymode= bfd->displaymode; - G.fileflags= bfd->fileflags; + G.winpos = bfd->winpos; + G.displaymode = bfd->displaymode; + G.fileflags = bfd->fileflags; CTX_wm_manager_set(C, bfd->main->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscreen->scene); @@ -273,20 +273,20 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath } /* this can happen when active scene was lib-linked, and doesn't exist anymore */ - if (CTX_data_scene(C)==NULL) { + if (CTX_data_scene(C) == NULL) { CTX_data_scene_set(C, bfd->main->scene.first); - CTX_wm_screen(C)->scene= CTX_data_scene(C); - curscene= CTX_data_scene(C); + CTX_wm_screen(C)->scene = CTX_data_scene(C); + curscene = CTX_data_scene(C); } /* special cases, override loaded flags: */ if (G.f != bfd->globalf) { const int flags_keep = (G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); - bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep); + bfd->globalf = (bfd->globalf & ~flags_keep) | (G.f & flags_keep); } - G.f= bfd->globalf; + G.f = bfd->globalf; if (!G.background) { //setscreen(G.curscreen); @@ -300,12 +300,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath if (recover && bfd->filename[0] && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ - filepath= bfd->filename; + filepath = bfd->filename; } #if 0 else if (!G.relbase_valid) { /* otherwise, use an empty string as filename, rather than */ - filepath=""; + filepath = ""; } #endif @@ -324,8 +324,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath static int handle_subversion_warning(Main *main, ReportList *reports) { if (main->minversionfile > BLENDER_VERSION || - (main->minversionfile == BLENDER_VERSION && - main->minsubversionfile > BLENDER_SUBVERSION)) { + (main->minversionfile == BLENDER_VERSION && + main->minsubversionfile > BLENDER_SUBVERSION)) { BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile); } @@ -348,8 +348,8 @@ void BKE_userdef_free(void) wmKeyMapItem *kmi; wmKeyMapDiffItem *kmdi; - for (km=U.user_keymaps.first; km; km=km->next) { - for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) { + for (km = U.user_keymaps.first; km; km = km->next) { + for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) { if (kmdi->add_item) { keymap_item_free(kmdi->add_item); MEM_freeN(kmdi->add_item); @@ -360,7 +360,7 @@ void BKE_userdef_free(void) } } - for (kmi=km->items.first; kmi; kmi=kmi->next) + for (kmi = km->items.first; kmi; kmi = kmi->next) keymap_item_free(kmi); BLI_freelistN(&km->diff_items); @@ -377,41 +377,41 @@ void BKE_userdef_free(void) int BKE_read_file(bContext *C, const char *filepath, ReportList *reports) { BlendFileData *bfd; - int retval= BKE_READ_FILE_OK; + int retval = BKE_READ_FILE_OK; - if (strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */ + if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) /* don't print user-pref loading */ printf("read blend: %s\n", filepath); - bfd= BLO_read_from_file(filepath, reports); + bfd = BLO_read_from_file(filepath, reports); if (bfd) { - if (bfd->user) retval= BKE_READ_FILE_OK_USERPREFS; + if (bfd->user) retval = BKE_READ_FILE_OK_USERPREFS; - if (0==handle_subversion_warning(bfd->main, reports)) { + if (0 == handle_subversion_warning(bfd->main, reports)) { free_main(bfd->main); MEM_freeN(bfd); - bfd= NULL; - retval= BKE_READ_FILE_FAIL; + bfd = NULL; + retval = BKE_READ_FILE_FAIL; } else - setup_app_data(C, bfd, filepath); // frees BFD + setup_app_data(C, bfd, filepath); // frees BFD } else BKE_reports_prependf(reports, "Loading %s failed: ", filepath); - return (bfd?retval:BKE_READ_FILE_FAIL); + return (bfd ? retval : BKE_READ_FILE_FAIL); } -int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, ReportList *reports) +int BKE_read_file_from_memory(bContext *C, char *filebuf, int filelength, ReportList *reports) { BlendFileData *bfd; - bfd= BLO_read_from_memory(filebuf, filelength, reports); + bfd = BLO_read_from_memory(filebuf, filelength, reports); if (bfd) setup_app_data(C, bfd, ""); else BKE_reports_prepend(reports, "Loading failed: "); - return (bfd?1:0); + return (bfd ? 1 : 0); } /* memfile is the undo buffer */ @@ -419,13 +419,13 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report { BlendFileData *bfd; - bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports); + bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports); if (bfd) setup_app_data(C, bfd, ""); else BKE_reports_prepend(reports, "Loading failed: "); - return (bfd?1:0); + return (bfd ? 1 : 0); } @@ -435,7 +435,7 @@ static void (*blender_test_break_cb)(void) = NULL; void set_blender_test_break_cb(void (*func)(void) ) { - blender_test_break_cb= func; + blender_test_break_cb = func; } @@ -446,15 +446,15 @@ int blender_test_break(void) blender_test_break_cb(); } - return (G.afbreek==1); + return (G.afbreek == 1); } /* ***************** GLOBAL UNDO *************** */ -#define UNDO_DISK 0 +#define UNDO_DISK 0 -#define MAXUNDONAME 64 +#define MAXUNDONAME 64 typedef struct UndoElem { struct UndoElem *next, *prev; char str[FILE_MAX]; @@ -463,31 +463,31 @@ typedef struct UndoElem { uintptr_t undosize; } UndoElem; -static ListBase undobase={NULL, NULL}; -static UndoElem *curundo= NULL; +static ListBase undobase = {NULL, NULL}; +static UndoElem *curundo = NULL; static int read_undosave(bContext *C, UndoElem *uel) { char mainstr[sizeof(G.main->name)]; - int success=0, fileflags; + int success = 0, fileflags; /* This is needed so undoing/redoing doesn't crash with threaded previews going */ WM_jobs_stop_all(CTX_wm_manager(C)); - BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ + BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ - fileflags= G.fileflags; + fileflags = G.fileflags; G.fileflags |= G_FILE_NO_UI; if (UNDO_DISK) - success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); + success = (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); else - success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); + success = BKE_read_file_from_memfile(C, &uel->memfile, NULL); /* restore */ BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */ - G.fileflags= fileflags; + G.fileflags = fileflags; if (success) { /* important not to update time here, else non keyed tranforms are lost */ @@ -504,33 +504,33 @@ void BKE_write_undo(bContext *C, const char *name) int nr /*, success */ /* UNUSED */; UndoElem *uel; - if ( (U.uiflag & USER_GLOBALUNDO)==0) return; - if ( U.undosteps==0) return; + if ( (U.uiflag & USER_GLOBALUNDO) == 0) return; + if (U.undosteps == 0) return; /* remove all undos after (also when curundo==NULL) */ while (undobase.last != curundo) { - uel= undobase.last; + uel = undobase.last; BLI_remlink(&undobase, uel); BLO_free_memfile(&uel->memfile); MEM_freeN(uel); } /* make new */ - curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file"); + curundo = uel = MEM_callocN(sizeof(UndoElem), "undo file"); BLI_strncpy(uel->name, name, sizeof(uel->name)); BLI_addtail(&undobase, uel); /* and limit amount to the maximum */ - nr= 0; - uel= undobase.last; + nr = 0; + uel = undobase.last; while (uel) { nr++; - if (nr==U.undosteps) break; - uel= uel->prev; + if (nr == U.undosteps) break; + uel = uel->prev; } if (uel) { - while (undobase.first!=uel) { - UndoElem *first= undobase.first; + while (undobase.first != uel) { + UndoElem *first = undobase.first; BLI_remlink(&undobase, first); /* the merge is because of compression */ BLO_merge_memfile(&first->memfile, &first->next->memfile); @@ -541,14 +541,14 @@ void BKE_write_undo(bContext *C, const char *name) /* disk save version */ if (UNDO_DISK) { - static int counter= 0; + static int counter = 0; char filepath[FILE_MAX]; char numstr[32]; int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */ /* calculate current filepath */ counter++; - counter= counter % U.undosteps; + counter = counter % U.undosteps; BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr); @@ -558,34 +558,34 @@ void BKE_write_undo(bContext *C, const char *name) BLI_strncpy(curundo->str, filepath, sizeof(curundo->str)); } else { - MemFile *prevfile=NULL; + MemFile *prevfile = NULL; - if (curundo->prev) prevfile= &(curundo->prev->memfile); + if (curundo->prev) prevfile = &(curundo->prev->memfile); - memused= MEM_get_memory_in_use(); + memused = MEM_get_memory_in_use(); /* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags); - curundo->undosize= MEM_get_memory_in_use() - memused; + curundo->undosize = MEM_get_memory_in_use() - memused; } if (U.undomemory != 0) { /* limit to maximum memory (afterwards, we can't know in advance) */ - totmem= 0; - maxmem= ((uintptr_t)U.undomemory)*1024*1024; + totmem = 0; + maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024; /* keep at least two (original + other) */ - uel= undobase.last; + uel = undobase.last; while (uel && uel->prev) { - totmem+= uel->undosize; - if (totmem>maxmem) break; - uel= uel->prev; + totmem += uel->undosize; + if (totmem > maxmem) break; + uel = uel->prev; } if (uel) { if (uel->prev && uel->prev->prev) - uel= uel->prev; + uel = uel->prev; - while (undobase.first!=uel) { - UndoElem *first= undobase.first; + while (undobase.first != uel) { + UndoElem *first = undobase.first; BLI_remlink(&undobase, first); /* the merge is because of compression */ BLO_merge_memfile(&first->memfile, &first->next->memfile); @@ -599,25 +599,25 @@ void BKE_write_undo(bContext *C, const char *name) void BKE_undo_step(bContext *C, int step) { - if (step==0) { + if (step == 0) { read_undosave(C, curundo); } - else if (step==1) { + else if (step == 1) { /* curundo should never be NULL, after restart or load file it should call undo_save */ - if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available"); + if (curundo == NULL || curundo->prev == NULL) ; // XXX error("No undo available"); else { if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name); - curundo= curundo->prev; + curundo = curundo->prev; read_undosave(C, curundo); } } else { /* curundo has to remain current situation! */ - if (curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available"); + if (curundo == NULL || curundo->next == NULL) ; // XXX error("No redo available"); else { read_undosave(C, curundo->next); - curundo= curundo->next; + curundo = curundo->next; if (G.debug & G_DEBUG) printf("redo %s\n", curundo->name); } } @@ -627,30 +627,30 @@ void BKE_reset_undo(void) { UndoElem *uel; - uel= undobase.first; + uel = undobase.first; while (uel) { BLO_free_memfile(&uel->memfile); - uel= uel->next; + uel = uel->next; } BLI_freelistN(&undobase); - curundo= NULL; + curundo = NULL; } /* based on index nr it does a restore */ void BKE_undo_number(bContext *C, int nr) { - curundo= BLI_findlink(&undobase, nr); + curundo = BLI_findlink(&undobase, nr); BKE_undo_step(C, 0); } /* go back to the last occurance of name in stack */ void BKE_undo_name(bContext *C, const char *name) { - UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); + UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); if (uel && uel->prev) { - curundo= uel->prev; + curundo = uel->prev; BKE_undo_step(C, 0); } } @@ -659,7 +659,7 @@ void BKE_undo_name(bContext *C, const char *name) int BKE_undo_valid(const char *name) { if (name) { - UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); + UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); return uel && uel->prev; } @@ -670,13 +670,13 @@ int BKE_undo_valid(const char *name) /* if active pointer, set it to 1 if true */ const char *BKE_undo_get_name(int nr, int *active) { - UndoElem *uel= BLI_findlink(&undobase, nr); + UndoElem *uel = BLI_findlink(&undobase, nr); - if (active) *active= 0; + if (active) *active = 0; if (uel) { - if (active && uel==curundo) - *active= 1; + if (active && uel == curundo) + *active = 1; return uel->name; } return NULL; @@ -685,23 +685,23 @@ const char *BKE_undo_get_name(int nr, int *active) char *BKE_undo_menu_string(void) { UndoElem *uel; - DynStr *ds= BLI_dynstr_new(); + DynStr *ds = BLI_dynstr_new(); char *menu; BLI_dynstr_append(ds, "Global Undo History %t"); - for (uel= undobase.first; uel; uel= uel->next) { + for (uel = undobase.first; uel; uel = uel->next) { BLI_dynstr_append(ds, "|"); BLI_dynstr_append(ds, uel->name); } - menu= BLI_dynstr_get_cstring(ds); + menu = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); return menu; } - /* saves quit.blend */ +/* saves quit.blend */ void BKE_undo_save_quit(void) { UndoElem *uel; @@ -709,16 +709,16 @@ void BKE_undo_save_quit(void) int file; char str[FILE_MAX]; - if ( (U.uiflag & USER_GLOBALUNDO)==0) return; + if ( (U.uiflag & USER_GLOBALUNDO) == 0) return; - uel= curundo; - if (uel==NULL) { + uel = curundo; + if (uel == NULL) { printf("No undo buffer to save recovery file\n"); return; } /* no undo state to save */ - if (undobase.first==undobase.last) return; + if (undobase.first == undobase.last) return; BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); @@ -728,28 +728,28 @@ void BKE_undo_save_quit(void) return; } - chunk= uel->memfile.chunks.first; + chunk = uel->memfile.chunks.first; while (chunk) { - if ( write(file, chunk->buf, chunk->size) != chunk->size) break; - chunk= chunk->next; + if (write(file, chunk->buf, chunk->size) != chunk->size) break; + chunk = chunk->next; } close(file); - if (chunk) ; //XXX error("Unable to save %s, internal error", str); + if (chunk) ; //XXX error("Unable to save %s, internal error", str); else printf("Saved session recovery to %s\n", str); } /* sets curscene */ Main *BKE_undo_get_main(Scene **scene) { - Main *mainp= NULL; - BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); + Main *mainp = NULL; + BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); if (bfd) { - mainp= bfd->main; + mainp = bfd->main; if (scene) - *scene= bfd->curscene; + *scene = bfd->curscene; MEM_freeN(bfd); } diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index f0bc2dddbad..24583c124e6 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -101,11 +101,11 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f sub_v3_v3v3(e1, v2, v0); A00 = dot_v3v3(e0, e0); - A01 = dot_v3v3(e0, e1 ); - A11 = dot_v3v3(e1, e1 ); - B0 = dot_v3v3(diff, e0 ); - B1 = dot_v3v3(diff, e1 ); - C = dot_v3v3(diff, diff ); + A01 = dot_v3v3(e0, e1); + A11 = dot_v3v3(e1, e1); + B0 = dot_v3v3(diff, e0); + B1 = dot_v3v3(diff, e1); + C = dot_v3v3(diff, diff); Det = fabs(A00 * A11 - A01 * A01); S = A01 * B1 - A11 * B0; T = A01 * B0 - A00 * B1; @@ -122,7 +122,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } else { if (fabsf(A00) > FLT_EPSILON) - S = -B0/A00; + S = -B0 / A00; else S = 0.0f; sqrDist = B0 * S + C; @@ -195,7 +195,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } } else { /* Region 0 */ - // Minimum at interior lv + /* Minimum at interior lv */ float invDet; if (fabsf(Det) > FLT_EPSILON) invDet = 1.0f / Det; @@ -203,8 +203,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f invDet = 0.0f; S *= invDet; T *= invDet; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; } } else { @@ -213,10 +213,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f if (S < 0.0f) { /* Region 2 */ tmp0 = A01 + B0; tmp1 = A11 + B1; - if ( tmp1 > tmp0 ) { + if (tmp1 > tmp0) { numer = tmp1 - tmp0; denom = A00 - 2.0f * A01 + A11; - if ( numer >= denom ) { + if (numer >= denom) { S = 1.0f; T = 0.0f; sqrDist = A00 + 2.0f * B0 + C; @@ -228,14 +228,14 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else S = 0.0f; T = 1.0f - S; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; le = 2; } } else { S = 0.0f; - if ( tmp1 <= 0.0f ) { + if (tmp1 <= 0.0f) { T = 1.0f; sqrDist = A11 + 2.0f * B1 + C; lv = 2; @@ -258,10 +258,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else if (T < 0.0f) { /* Region 6 */ tmp0 = A01 + B1; tmp1 = A00 + B0; - if ( tmp1 > tmp0 ) { + if (tmp1 > tmp0) { numer = tmp1 - tmp0; denom = A00 - 2.0f * A01 + A11; - if ( numer >= denom ) { + if (numer >= denom) { T = 1.0f; S = 0.0f; sqrDist = A11 + 2.0f * B1 + C; @@ -273,8 +273,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else T = 0.0f; S = 1.0f - T; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; le = 2; } } @@ -302,7 +302,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } else { /* Region 1 */ numer = A11 + B1 - A01 - B0; - if ( numer <= 0.0f ) { + if (numer <= 0.0f) { S = 0.0f; T = 1.0f; sqrDist = A11 + 2.0f * B1 + C; @@ -310,7 +310,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } else { denom = A00 - 2.0f * A01 + A11; - if ( numer >= denom ) { + if (numer >= denom) { S = 1.0f; T = 0.0f; sqrDist = A00 + 2.0f * B0 + C; @@ -322,8 +322,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else S = 0.0f; T = 1.0f - S; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; le = 2; } } @@ -331,7 +331,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } // Account for numerical round-off error - if ( sqrDist < FLT_EPSILON ) + if (sqrDist < FLT_EPSILON) sqrDist = 0.0f; { @@ -362,19 +362,18 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { - const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; - MVert *vert = data->vert; + const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; + MVert *vert = data->vert; MFace *face = data->face + index; float *t0, *t1, *t2, *t3; - t0 = vert[ face->v1 ].co; - t1 = vert[ face->v2 ].co; - t2 = vert[ face->v3 ].co; - t3 = face->v4 ? vert[ face->v4].co : NULL; + t0 = vert[face->v1].co; + t1 = vert[face->v2].co; + t2 = vert[face->v3].co; + t3 = face->v4 ? vert[face->v4].co : NULL; - do - { + do { float nearest_tmp[3], dist; int vertex, edge; @@ -397,8 +396,8 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3 // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) { - const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; - MVert *vert = data->vert; + const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; + MVert *vert = data->vert; MFace *face = data->face + index; float *t0, *t1, *t2, *t3; @@ -408,8 +407,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r t3 = face->v4 ? vert[face->v4].co : NULL; - do - { + do { float dist; if (data->sphere_radius == 0.0f) dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); @@ -435,14 +433,14 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { - const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; - MVert *vert = data->vert; + const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; + MVert *vert = data->vert; MEdge *edge = data->edge + index; float nearest_tmp[3], dist; float *t0, *t1; - t0 = vert[ edge->v1 ].co; - t1 = vert[ edge->v2 ].co; + t0 = vert[edge->v1].co; + t1 = vert[edge->v2].co; closest_to_line_segment_v3(nearest_tmp, co, t0, t1); dist = len_squared_v3v3(nearest_tmp, co); @@ -460,15 +458,15 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3 * BVH builders */ // Builds a bvh tree.. where nodes are the vertexs of the given mesh -BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES); //Not in cache if (tree == NULL) { int i; - int numVerts= mesh->getNumVerts(mesh); - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + int numVerts = mesh->getNumVerts(mesh); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); if (vert != NULL) { tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis); @@ -514,14 +512,14 @@ BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float } // Builds a bvh tree.. where nodes are the faces of the given mesh. -BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES); //Not in cache if (tree == NULL) { int i; - int numFaces= mesh->getNumTessFaces(mesh); + int numFaces = mesh->getNumTessFaces(mesh); /* BMESH specific check that we have tessfaces, * we _could_ tessellate here but rather not - campbell @@ -534,7 +532,7 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float /* Create a bvh-tree of the given target */ tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if (tree != NULL) { - BMEditMesh *em= data->em_evil; + BMEditMesh *em = data->em_evil; if (em) { /* data->em_evil is only set for snapping, and only for the mesh of the object * which is currently open in edit mode. When set, the bvhtree should not contain @@ -594,17 +592,17 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } } else { - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE); if (vert != NULL && face != NULL) { for (i = 0; i < numFaces; i++) { float co[4][3]; - copy_v3_v3(co[0], vert[ face[i].v1 ].co); - copy_v3_v3(co[1], vert[ face[i].v2 ].co); - copy_v3_v3(co[2], vert[ face[i].v3 ].co); + copy_v3_v3(co[0], vert[face[i].v1].co); + copy_v3_v3(co[1], vert[face[i].v2].co); + copy_v3_v3(co[2], vert[face[i].v3].co); if (face[i].v4) - copy_v3_v3(co[3], vert[ face[i].v4 ].co); + copy_v3_v3(co[3], vert[face[i].v4].co); BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); } @@ -644,15 +642,15 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } // Builds a bvh tree.. where nodes are the faces of the given mesh. -BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES); //Not in cache if (tree == NULL) { int i; - int numEdges= mesh->getNumEdges(mesh); - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + int numEdges = mesh->getNumEdges(mesh); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MEdge *edge = mesh->getEdgeDataArray(mesh, CD_MEDGE); if (vert != NULL && edge != NULL) { @@ -661,8 +659,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float if (tree != NULL) { for (i = 0; i < numEdges; i++) { float co[4][3]; - copy_v3_v3(co[0], vert[ edge[i].v1 ].co); - copy_v3_v3(co[1], vert[ edge[i].v2 ].co); + copy_v3_v3(co[0], vert[edge[i].v1].co); + copy_v3_v3(co[1], vert[edge[i].v2].co); BLI_bvhtree_insert(tree, i, co[0], 2); } @@ -712,8 +710,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data) /* BVHCache */ -typedef struct BVHCacheItem -{ +typedef struct BVHCacheItem { int type; BVHTree *tree; @@ -721,8 +718,8 @@ typedef struct BVHCacheItem static void bvhcacheitem_set_if_match(void *_cached, void *_search) { - BVHCacheItem * cached = (BVHCacheItem *)_cached; - BVHCacheItem * search = (BVHCacheItem *)_search; + BVHCacheItem *cached = (BVHCacheItem *)_cached; + BVHCacheItem *search = (BVHCacheItem *)_search; if (search->type == cached->type) { search->tree = cached->tree; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 15db0df1bad..db2362b58ce 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1,4 +1,4 @@ - /* +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -172,7 +172,7 @@ static void cdDM_copyPolyArray(DerivedMesh *dm, MPoly *poly_r) static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; int i; if (dm->numVertData) { @@ -188,7 +188,7 @@ static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) static void cdDM_getVertCo(DerivedMesh *dm, int index, float co_r[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; copy_v3_v3(co_r, cddm->mvert[index].co); } @@ -204,16 +204,16 @@ static void cdDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3]) static void cdDM_getVertNo(DerivedMesh *dm, int index, float no_r[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; normal_short_to_float_v3(no_r, cddm->mvert[index].no); } static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; if (!cddm->pmap && ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; create_vert_poly_map(&cddm->pmap, &cddm->pmap_mem, me->mpoly, me->mloop, @@ -225,7 +225,7 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; Mesh *me = ob->data; int deformed = 0; @@ -247,10 +247,10 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm) static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; if (!ob) { - cddm->pbvh= NULL; + cddm->pbvh = NULL; return NULL; } @@ -258,7 +258,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) return NULL; if (ob->sculpt->pbvh) { - cddm->pbvh= ob->sculpt->pbvh; + cddm->pbvh = ob->sculpt->pbvh; cddm->pbvh_draw = can_pbvh_draw(ob, dm); } @@ -286,7 +286,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) int totvert; totvert = deformdm->getNumVerts(deformdm); - vertCos = MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos"); + vertCos = MEM_callocN(3 * totvert * sizeof(float), "cdDM_getPBVH vertCos"); deformdm->getVertCos(deformdm, vertCos); BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos); MEM_freeN(vertCos); @@ -300,7 +300,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) * TODO: proper fix is to support the pbvh in all drawing modes */ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; float (*face_nors)[3]; if (!cddm->pbvh || !cddm->pbvh_draw || !dm->numTessFaceData) @@ -313,7 +313,7 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm) static void cdDM_drawVerts(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; int i; @@ -323,7 +323,7 @@ static void cdDM_drawVerts(DerivedMesh *dm) glVertex3fv(mv->co); glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); if (!GPU_buffer_legacy(dm)) { if (dm->drawObject->tot_triangle_point) @@ -337,7 +337,7 @@ static void cdDM_drawVerts(DerivedMesh *dm) static void cdDM_drawUVEdges(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MFace *mf = cddm->mface; MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); int i; @@ -346,7 +346,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) if (GPU_buffer_legacy(dm)) { glBegin(GL_LINES); for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) { - if (!(mf->flag&ME_HIDE)) { + if (!(mf->flag & ME_HIDE)) { glVertex2fv(tf->uv[0]); glVertex2fv(tf->uv[1]); @@ -377,19 +377,19 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) GPU_uvedge_setup(dm); if (!GPU_buffer_legacy(dm)) { for (i = 0; i < dm->numTessFaceData; i++, mf++) { - if (!(mf->flag&ME_HIDE)) { + if (!(mf->flag & ME_HIDE)) { draw = 1; } else { draw = 0; } - if ( prevdraw != draw ) { - if ( prevdraw > 0 && (curpos-prevstart) > 0) { - glDrawArrays(GL_LINES, prevstart, curpos-prevstart); + if (prevdraw != draw) { + if (prevdraw > 0 && (curpos - prevstart) > 0) { + glDrawArrays(GL_LINES, prevstart, curpos - prevstart); } prevstart = curpos; } - if ( mf->v4 ) { + if (mf->v4) { curpos += 8; } else { @@ -397,8 +397,8 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) } prevdraw = draw; } - if ( prevdraw > 0 && (curpos-prevstart) > 0 ) { - glDrawArrays(GL_LINES, prevstart, curpos-prevstart); + if (prevdraw > 0 && (curpos - prevstart) > 0) { + glDrawArrays(GL_LINES, prevstart, curpos - prevstart); } } GPU_buffer_unbind(); @@ -408,7 +408,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mvert = cddm->mvert; MEdge *medge = cddm->medge; int i; @@ -426,7 +426,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges } glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ int prevstart = 0; int prevdraw = 1; int draw = TRUE; @@ -442,16 +442,16 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges else { draw = FALSE; } - if ( prevdraw != draw ) { - if ( prevdraw > 0 && (i-prevstart) > 0 ) { + if (prevdraw != draw) { + if (prevdraw > 0 && (i - prevstart) > 0) { GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } prevstart = i; } prevdraw = draw; } - if ( prevdraw > 0 && (i-prevstart) > 0 ) { - GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i-prevstart) * 2); + if (prevdraw > 0 && (i - prevstart) > 0) { + GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } } GPU_buffer_unbind(); @@ -460,7 +460,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges static void cdDM_drawLooseEdges(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mvert = cddm->mvert; MEdge *medge = cddm->medge; int i; @@ -469,14 +469,14 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) DEBUG_VBO("Using legacy code. cdDM_drawLooseEdges\n"); glBegin(GL_LINES); for (i = 0; i < dm->numEdgeData; i++, medge++) { - if (medge->flag&ME_LOOSEEDGE) { + if (medge->flag & ME_LOOSEEDGE) { glVertex3fv(mvert[medge->v1].co); glVertex3fv(mvert[medge->v2].co); } } glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ int prevstart = 0; int prevdraw = 1; int draw = 1; @@ -484,21 +484,21 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) GPU_edge_setup(dm); if (!GPU_buffer_legacy(dm)) { for (i = 0; i < dm->numEdgeData; i++, medge++) { - if (medge->flag&ME_LOOSEEDGE) { + if (medge->flag & ME_LOOSEEDGE) { draw = 1; } else { draw = 0; } - if ( prevdraw != draw ) { - if ( prevdraw > 0 && (i-prevstart) > 0) { + if (prevdraw != draw) { + if (prevdraw > 0 && (i - prevstart) > 0) { GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } prevstart = i; } prevdraw = draw; } - if ( prevdraw > 0 && (i-prevstart) > 0 ) { + if (prevdraw > 0 && (i - prevstart) > 0) { GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } } @@ -507,13 +507,13 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) } static void cdDM_drawFacesSolid(DerivedMesh *dm, - float (*partial_redraw_planes)[4], - int UNUSED(fast), DMSetMaterial setMaterial) + float (*partial_redraw_planes)[4], + int UNUSED(fast), DMSetMaterial setMaterial) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mvert = cddm->mvert; MFace *mface = cddm->mface; - float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); + float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1; #define PASSVERT(index) { \ @@ -521,7 +521,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, short *no = mvert[index].no; \ glNormal3sv(no); \ } \ - glVertex3fv(mvert[index].co); \ + glVertex3fv(mvert[index].co); \ } if (cddm->pbvh && cddm->pbvh_draw) { @@ -541,9 +541,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, for (a = 0; a < dm->numTessFaceData; a++, mface++) { int new_glmode, new_matnr, new_shademodel; - new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; + new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES; new_matnr = mface->mat_nr + 1; - new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT; + new_shademodel = (mface->flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT; if (new_glmode != glmode || new_matnr != matnr || new_shademodel != shademodel) { glEnd(); @@ -584,7 +584,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); GPU_normal_setup(dm); if (!GPU_buffer_legacy(dm)) { @@ -604,16 +604,16 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } static void cdDM_drawFacesTex_common(DerivedMesh *dm, - DMSetDrawOptionsTex drawParams, - DMSetDrawOptions drawParamsMapped, - DMCompareDrawOptions compareDrawOptions, - void *userData) + DMSetDrawOptionsTex drawParams, + DMSetDrawOptions drawParamsMapped, + DMCompareDrawOptions compareDrawOptions, + void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE); MCol *realcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL); - float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); + float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); int i, j, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */; @@ -631,25 +631,25 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, unsigned char *cp = NULL; if (drawParams) { - draw_option = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr); + draw_option = drawParams(tf ? &tf[i] : NULL, (mcol != NULL), mf->mat_nr); } else { if (index) { orig = *index++; - if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; } + if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; } if (drawParamsMapped) draw_option = drawParamsMapped(userData, orig); - else { if (nors) nors += 3; continue; } + else { if (nors) nors += 3; continue; } } else - if (drawParamsMapped) draw_option = drawParamsMapped(userData, i); - else { if (nors) nors += 3; continue; } + if (drawParamsMapped) draw_option = drawParamsMapped(userData, i); + else { if (nors) nors += 3; continue; } } if (draw_option != DM_DRAW_OPTION_SKIP) { if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol) - cp = (unsigned char*) &mcol[i*4]; + cp = (unsigned char *) &mcol[i * 4]; - if (!(mf->flag&ME_SMOOTH)) { + if (!(mf->flag & ME_SMOOTH)) { if (nors) { glNormal3fv(nors); } @@ -665,30 +665,30 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } } - glBegin(mf->v4?GL_QUADS:GL_TRIANGLES); + glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES); if (tf) glTexCoord2fv(tf[i].uv[0]); if (cp) glColor3ub(cp[3], cp[2], cp[1]); mvert = &mv[mf->v1]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); if (tf) glTexCoord2fv(tf[i].uv[1]); if (cp) glColor3ub(cp[7], cp[6], cp[5]); mvert = &mv[mf->v2]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); if (tf) glTexCoord2fv(tf[i].uv[2]); if (cp) glColor3ub(cp[11], cp[10], cp[9]); mvert = &mv[mf->v3]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); if (mf->v4) { if (tf) glTexCoord2fv(tf[i].uv[3]); if (cp) glColor3ub(cp[15], cp[14], cp[13]); mvert = &mv[mf->v4]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); } glEnd(); @@ -705,7 +705,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, GPU_vertex_setup(dm); GPU_normal_setup(dm); GPU_uv_setup(dm); - if ( col != NULL ) { + if (col != NULL) { #if 0 if (realcol && dm->drawObject->colType == CD_TEXTURE_MCOL) { col = 0; @@ -717,13 +717,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if (col != 0) #endif { - unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common"); + unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm) * 4 * 3 * sizeof(unsigned char), "cdDM_drawFacesTex_common"); for (i = 0; i < dm->getNumTessFaces(dm); i++) { for (j = 0; j < 4; j++) { /* bgr -> rgb is intentional (and stupid), but how its stored internally */ - colors[i*12+j*3] = col[i*4+j].b; - colors[i*12+j*3+1] = col[i*4+j].g; - colors[i*12+j*3+2] = col[i*4+j].r; + colors[i * 12 + j * 3] = col[i * 4 + j].b; + colors[i * 12 + j * 3 + 1] = col[i * 4 + j].g; + colors[i * 12 + j * 3 + 2] = col[i * 4 + j].r; } } GPU_color3_upload(dm, colors); @@ -737,7 +737,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } if (!GPU_buffer_legacy(dm)) { - int tottri = dm->drawObject->tot_triangle_point/3; + int tottri = dm->drawObject->tot_triangle_point / 3; int next_actualFace = dm->drawObject->triangle_to_mface[0]; glShadeModel(GL_SMOOTH); @@ -747,11 +747,11 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; - if (i != tottri-1) - next_actualFace= dm->drawObject->triangle_to_mface[i+1]; + if (i != tottri - 1) + next_actualFace = dm->drawObject->triangle_to_mface[i + 1]; if (drawParams) { - draw_option = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr); + draw_option = drawParams(tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr); } else { if (index) { @@ -761,8 +761,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, draw_option = drawParamsMapped(userData, orig); } else - if (drawParamsMapped) - draw_option = drawParamsMapped(userData, actualFace); + if (drawParamsMapped) + draw_option = drawParamsMapped(userData, actualFace); } /* flush buffer if current triangle isn't drawable or it's last triangle */ @@ -771,13 +771,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if (!flush && compareDrawOptions) { /* also compare draw options and flush buffer if they're different * need for face selection highlight in edit mode */ - flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0; + flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0; } if (flush) { - int first = startFace*3; + int first = startFace * 3; /* Add one to the length if we're drawing at the end of the array */ - int count = (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; + int count = (i - startFace + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3; if (count) { if (col) @@ -799,24 +799,24 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } static void cdDM_drawFacesTex(DerivedMesh *dm, - DMSetDrawOptionsTex setDrawOptions, - DMCompareDrawOptions compareDrawOptions, - void *userData) + DMSetDrawOptionsTex setDrawOptions, + DMCompareDrawOptions compareDrawOptions, + void *userData) { cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData); } static void cdDM_drawMappedFaces(DerivedMesh *dm, - DMSetDrawOptions setDrawOptions, - DMSetMaterial setMaterial, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag flag) + DMSetDrawOptions setDrawOptions, + DMSetMaterial setMaterial, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag flag) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; MFace *mf = cddm->mface; MCol *mc; - float *nors= DM_get_tessface_data_layer(dm, CD_NORMAL); + float *nors = DM_get_tessface_data_layer(dm, CD_NORMAL); int useColors = flag & DM_DRAW_USE_COLORS; int i, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); @@ -836,12 +836,12 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH); DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; - orig = (index==NULL) ? i : *index++; + orig = (index == NULL) ? i : *index++; if (orig == ORIGINDEX_NONE) - draw_option= setMaterial(mf->mat_nr + 1, NULL); + draw_option = setMaterial(mf->mat_nr + 1, NULL); else if (setDrawOptions != NULL) - draw_option= setDrawOptions(userData, orig); + draw_option = setDrawOptions(userData, orig); if (draw_option != DM_DRAW_OPTION_SKIP) { unsigned char *cp = NULL; @@ -852,7 +852,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, /* no need to set shading mode to flat because * normals are already used to change shading */ glShadeModel(GL_SMOOTH); - glBegin(mf->v4?GL_QUADS:GL_TRIANGLES); + glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES); if (!drawSmooth) { if (nors) { @@ -907,10 +907,10 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int prevstart = 0; GPU_vertex_setup(dm); GPU_normal_setup(dm); - if ( useColors && mc ) + if (useColors && mc) GPU_color_setup(dm); if (!GPU_buffer_legacy(dm)) { - int tottri = dm->drawObject->tot_triangle_point/3; + int tottri = dm->drawObject->tot_triangle_point / 3; glShadeModel(GL_SMOOTH); if (tottri == 0) { @@ -932,15 +932,15 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; - if (i != tottri-1) - next_actualFace= dm->drawObject->triangle_to_mface[i+1]; + if (i != tottri - 1) + next_actualFace = dm->drawObject->triangle_to_mface[i + 1]; - orig = (index==NULL) ? actualFace : index[actualFace]; + orig = (index == NULL) ? actualFace : index[actualFace]; if (orig == ORIGINDEX_NONE) - draw_option= setMaterial(mface->mat_nr + 1, NULL); + draw_option = setMaterial(mface->mat_nr + 1, NULL); else if (setDrawOptions != NULL) - draw_option= setDrawOptions(userData, orig); + draw_option = setDrawOptions(userData, orig); /* Goal is to draw as long of a contiguous triangle * array as possible, so draw when we hit either an @@ -957,9 +957,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, } if (flush) { - int first = prevstart*3; + int first = prevstart * 3; /* Add one to the length if we're drawing at the end of the array */ - int count = (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; + int count = (i - prevstart + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3; if (count) glDrawArrays(GL_TRIANGLES, first, count); @@ -976,9 +976,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, } static void cdDM_drawMappedFacesTex(DerivedMesh *dm, - DMSetDrawOptions setDrawOptions, - DMCompareDrawOptions compareDrawOptions, - void *userData) + DMSetDrawOptions setDrawOptions, + DMCompareDrawOptions compareDrawOptions, + void *userData) { cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData); } @@ -1007,15 +1007,15 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int /* vertex colors */ for (b = 0; b < attribs->totmcol; b++) { - MCol *cp = &attribs->mcol[b].array[a*4 + vert]; + 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; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col); } /* tangent for normal mapping */ if (attribs->tottang) { - float *tang = attribs->tang.array[a*4 + vert]; + float *tang = attribs->tang.array[a * 4 + vert]; glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } @@ -1028,11 +1028,11 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int } static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, - DMSetMaterial setMaterial, - DMSetDrawOptions setDrawOptions, - void *userData) + DMSetMaterial setMaterial, + DMSetDrawOptions setDrawOptions, + void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; GPUVertexAttribs gattribs; DMVertexAttribs attribs; MVert *mvert = cddm->mvert; @@ -1049,7 +1049,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, glShadeModel(GL_SMOOTH); - if ( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) { + if (GPU_buffer_legacy(dm) || setDrawOptions != NULL) { DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n"); memset(&attribs, 0, sizeof(attribs)); @@ -1073,7 +1073,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, continue; } else if (setDrawOptions) { - orig = (index)? index[a]: a; + orig = (index) ? index[a] : a; if (orig == ORIGINDEX_NONE) { /* since the material is set by setMaterial(), faces with no @@ -1128,7 +1128,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_normal_setup(dm); if (!GPU_buffer_legacy(dm)) { - for (i = 0; i < dm->drawObject->tot_triangle_point/3; i++) { + for (i = 0; i < dm->drawObject->tot_triangle_point / 3; i++) { a = dm->drawObject->triangle_to_mface[i]; @@ -1148,7 +1148,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_interleaved_attrib_setup(buffer, datatypes, numdata); } - glDrawArrays(GL_TRIANGLES, start*3, numfaces*3); + glDrawArrays(GL_TRIANGLES, start * 3, numfaces * 3); if (numdata != 0) { @@ -1215,84 +1215,84 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } - if (dodraw && numdata != 0 ) { + if (dodraw && numdata != 0) { offset = 0; if (attribs.totorco) { - copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v1]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v2]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v3]); - offset += sizeof(float)*3; + copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]); + offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[0]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[1]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[2]); - offset += sizeof(float)*2; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]); + offset += sizeof(float) * 2; } for (b = 0; b < attribs.totmcol; b++) { - MCol *cp = &attribs.mcol[b].array[a*4 + 0]; + MCol *cp = &attribs.mcol[b].array[a * 4 + 0]; GLubyte col[4]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 1]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 2]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col); - offset += sizeof(unsigned char)*4; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 1]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 2]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; } if (attribs.tottang) { - float *tang = attribs.tang.array[a*4 + 0]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang); - tang = attribs.tang.array[a*4 + 1]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize], tang); - tang = attribs.tang.array[a*4 + 2]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); - offset += sizeof(float)*4; + float *tang = attribs.tang.array[a * 4 + 0]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); + tang = attribs.tang.array[a * 4 + 1]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); + tang = attribs.tang.array[a * 4 + 2]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); + offset += sizeof(float) * 4; } (void)offset; } curface++; if (mface->v4) { - if (dodraw && numdata != 0 ) { + if (dodraw && numdata != 0) { offset = 0; if (attribs.totorco) { - copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v3]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v4]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v1]); - offset += sizeof(float)*3; + copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]); + offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[2]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[3]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[0]); - offset += sizeof(float)*2; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]); + offset += sizeof(float) * 2; } for (b = 0; b < attribs.totmcol; b++) { - MCol *cp = &attribs.mcol[b].array[a*4 + 2]; + MCol *cp = &attribs.mcol[b].array[a * 4 + 2]; GLubyte col[4]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 3]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 0]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col); - offset += sizeof(unsigned char)*4; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 3]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 0]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; } if (attribs.tottang) { - float *tang = attribs.tang.array[a*4 + 2]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang); - tang = attribs.tang.array[a*4 + 3]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize], tang); - tang = attribs.tang.array[a*4 + 0]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); - offset += sizeof(float)*4; + float *tang = attribs.tang.array[a * 4 + 2]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); + tang = attribs.tang.array[a * 4 + 3]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); + tang = attribs.tang.array[a * 4 + 0]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); + offset += sizeof(float) * 4; } (void)offset; } @@ -1307,7 +1307,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_buffer_unlock(buffer); GPU_interleaved_attrib_setup(buffer, datatypes, numdata); } - glDrawArrays(GL_TRIANGLES, start*3, (curface-start)*3); + glDrawArrays(GL_TRIANGLES, start * 3, (curface - start) * 3); } } GPU_buffer_unbind(); @@ -1324,10 +1324,10 @@ static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) } static void cdDM_drawMappedFacesMat(DerivedMesh *dm, - void (*setMaterial)(void *userData, int, void *attribs), - int (*setFace)(void *userData, int index), void *userData) + void (*setMaterial)(void *userData, int, void *attribs), + int (*setFace)(void *userData, int index), void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; GPUVertexAttribs gattribs; DMVertexAttribs attribs; MVert *mvert = cddm->mvert; @@ -1363,7 +1363,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, /* skipping faces */ if (setFace) { - orig = (index)? index[a]: a; + orig = (index) ? index[a] : a; if (orig != ORIGINDEX_NONE && !setFace(userData, orig)) continue; @@ -1404,7 +1404,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *vert = cddm->mvert; MEdge *edge = cddm->medge; int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX); @@ -1450,7 +1450,7 @@ static void cdDM_foreachMappedEdge( void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; MEdge *med = cddm->medge; int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX); @@ -1471,7 +1471,7 @@ static void cdDM_foreachMappedFaceCenter( void (*func)(void *userData, int index, const float cent[3], const float no[3]), void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MVert *mv = cddm->mvert; MPoly *mp = cddm->mpoly; MLoop *ml = cddm->mloop; @@ -1492,7 +1492,7 @@ static void cdDM_foreachMappedFaceCenter( ml = &cddm->mloop[mp->loopstart]; cent[0] = cent[1] = cent[2] = 0.0f; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { add_v3_v3v3(cent, cent, mv[ml->v].co); } mul_v3_fl(cent, 1.0f / (float)j); @@ -1519,7 +1519,7 @@ static void cdDM_foreachMappedFaceCenter( void CDDM_recalc_tessellation_ex(DerivedMesh *dm, const int do_face_nor_cpy) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; dm->numTessFaceData = BKE_mesh_recalc_tessellation(&dm->faceData, &dm->loopData, &dm->polyData, cddm->mvert, @@ -1551,7 +1551,7 @@ static void cdDM_free_internal(CDDerivedMesh *cddm) static void cdDM_release(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (DM_release(dm)) { cdDM_free_internal(cddm); @@ -1671,18 +1671,18 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob)) /* this does a referenced copy, with an exception for fluidsim */ DM_init(dm, DM_TYPE_CDDM, mesh->totvert, mesh->totedge, mesh->totface, - mesh->totloop, mesh->totpoly); + mesh->totloop, mesh->totpoly); dm->deformedOnly = 1; - alloctype= CD_REFERENCE; + alloctype = CD_REFERENCE; CustomData_merge(&mesh->vdata, &dm->vertData, mask, alloctype, - mesh->totvert); + mesh->totvert); CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype, - mesh->totedge); - CustomData_merge(&mesh->fdata, &dm->faceData, mask|CD_MASK_POLYINDEX, alloctype, - mesh->totface); + mesh->totedge); + CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_POLYINDEX, alloctype, + mesh->totface); CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype, mesh->totloop); CustomData_merge(&mesh->pdata, &dm->polyData, mask, alloctype, @@ -1733,12 +1733,12 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) dm = CDDM_new(totvert, totedge, 0, totloop, totpoly); dm->deformedOnly = 1; - cddm = (CDDerivedMesh*)dm; + cddm = (CDDerivedMesh *)dm; - memcpy(cddm->mvert, allvert, totvert*sizeof(MVert)); - memcpy(cddm->medge, alledge, totedge*sizeof(MEdge)); - memcpy(cddm->mloop, allloop, totloop*sizeof(MLoop)); - memcpy(cddm->mpoly, allpoly, totpoly*sizeof(MPoly)); + memcpy(cddm->mvert, allvert, totvert * sizeof(MVert)); + memcpy(cddm->medge, alledge, totedge * sizeof(MEdge)); + memcpy(cddm->mloop, allloop, totloop * sizeof(MLoop)); + memcpy(cddm->mpoly, allpoly, totpoly * sizeof(MPoly)); MEM_freeN(allvert); MEM_freeN(alledge); @@ -1751,8 +1751,8 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) } static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, - int cdindex, BMLoop *l3[3], - int numCol, int numTex) + int cdindex, BMLoop *l3[3], + int numCol, int numTex) { BMLoop *l; BMFace *f = l3[0]->f; @@ -1769,7 +1769,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, ME_MTEXFACE_CPY(texface, texpoly); - for (j = 0 ; j < 3; j++) { + for (j = 0; j < 3; j++) { l = l3[j]; mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i); copy_v2_v2(texface->uv[j], mloopuv->uv); @@ -1807,7 +1807,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis bm->totloop, bm->totface); - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; BMIter iter, liter; BMVert *eve; BMEdge *eed; @@ -1833,7 +1833,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis /*don't add origindex layer if one already exists*/ add_orig = !CustomData_has_layer(&bm->pdata, CD_ORIGINDEX); - mask = use_mdisps ? CD_MASK_DERIVEDMESH|CD_MASK_MDISPS : CD_MASK_DERIVEDMESH; + mask = use_mdisps ? CD_MASK_DERIVEDMESH | CD_MASK_MDISPS : CD_MASK_DERIVEDMESH; /* don't process shapekeys, we only feed them through the modifier stack as needed, * e.g. for applying modifiers or the like*/ @@ -1867,7 +1867,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis mv->flag = BM_vert_flag_to_mflag(eve); if (has_vert_bweight) - mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT)*255.0f); + mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT) * 255.0f); if (add_orig) *index = i; @@ -1886,9 +1886,9 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis med->v2 = BM_elem_index_get(eed->v2); if (has_crease) - med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE)*255.0f); + med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE) * 255.0f); if (has_edge_bweight) - med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT)*255.0f); + med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT) * 255.0f); med->flag = BM_edge_flag_to_mflag(eed); @@ -1917,7 +1917,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis mf->mat_nr = efa->mat_nr; mf->flag = BM_face_flag_to_mflag(efa); - *index = add_orig ? BM_elem_index_get(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX); + *index = add_orig ? BM_elem_index_get(efa) : *(int *)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX); *polyindex = BM_elem_index_get(efa); loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex); @@ -1974,7 +1974,7 @@ static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces) /* this initializes dm, and copies all non mvert/medge/mface layers */ DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, - numLoops, numPolys); + numLoops, numPolys); dm->deformedOnly = source->deformedOnly; dm->dirty = source->dirty; @@ -2056,7 +2056,7 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source, void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MVert *vert; int i; @@ -2070,7 +2070,7 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3]) void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MVert *vert; int i; @@ -2084,7 +2084,7 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3]) void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; float (*face_nors)[3] = NULL; if (dm->numVertData == 0) return; @@ -2114,7 +2114,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals } - face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors"); + face_nors = MEM_mallocN(sizeof(float) * 3 * dm->numTessFaceData, "face_nors"); /* calculate face normals */ BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), @@ -2123,7 +2123,7 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals only_face_normals); CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, - face_nors, dm->numTessFaceData); + face_nors, dm->numTessFaceData); } @@ -2138,7 +2138,7 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm) /* bmesh note: this matches what we have in trunk */ void CDDM_calc_normals(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; float (*poly_nors)[3]; if (dm->numVertData == 0) return; @@ -2158,7 +2158,7 @@ void CDDM_calc_normals(DerivedMesh *dm) void CDDM_calc_normals_tessface(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; float (*face_nors)[3]; if (dm->numVertData == 0) return; @@ -2190,7 +2190,7 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm) */ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; CDDerivedMesh *cddm2 = NULL; MVert *mv, *mvert = NULL; BLI_array_declare(mvert); @@ -2209,9 +2209,9 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) totloop = dm->numLoopData; totpoly = dm->numPolyData; - newv = MEM_callocN(sizeof(int)*dm->numVertData, "newv vtable CDDM_merge_verts"); - newe = MEM_callocN(sizeof(int)*dm->numEdgeData, "newv etable CDDM_merge_verts"); - newl = MEM_callocN(sizeof(int)*totloop, "newv ltable CDDM_merge_verts"); + newv = MEM_callocN(sizeof(int) * dm->numVertData, "newv vtable CDDM_merge_verts"); + newe = MEM_callocN(sizeof(int) * dm->numEdgeData, "newv etable CDDM_merge_verts"); + newl = MEM_callocN(sizeof(int) * totloop, "newv ltable CDDM_merge_verts"); /*fill newl with destination vertex indices*/ mv = cddm->mvert; @@ -2247,7 +2247,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) if (LIKELY(med->v1 != med->v2)) { const unsigned int v1 = (vtargetmap[med->v1] != -1) ? vtargetmap[med->v1] : med->v1; const unsigned int v2 = (vtargetmap[med->v2] != -1) ? vtargetmap[med->v2] : med->v2; - void **eh_p= BLI_edgehash_lookup_p(ehash, v1, v2); + void **eh_p = BLI_edgehash_lookup_p(ehash, v1, v2); if (eh_p) { newe[i] = GET_INT_FROM_POINTER(*eh_p); @@ -2275,8 +2275,8 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) for (j = 0; j < mp->totloop; j++, ml++) { med = cddm->medge + ml->e; if (LIKELY(med->v1 != med->v2)) { - newl[j+mp->loopstart] = BLI_array_count(mloop); - BLI_array_append(oldl, j+mp->loopstart); + newl[j + mp->loopstart] = BLI_array_count(mloop); + BLI_array_append(oldl, j + mp->loopstart); BLI_array_append(mloop, *ml); c++; } @@ -2294,7 +2294,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) } /*create new cddm*/ - cddm2 = (CDDerivedMesh*) CDDM_from_template((DerivedMesh*)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly)); + cddm2 = (CDDerivedMesh *) CDDM_from_template((DerivedMesh *)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly)); /*update edge indices and copy customdata*/ med = medge; @@ -2331,10 +2331,10 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) } /*copy over data. CustomData_add_layer can do this, need to look it up.*/ - memcpy(cddm2->mvert, mvert, sizeof(MVert)*BLI_array_count(mvert)); - memcpy(cddm2->medge, medge, sizeof(MEdge)*BLI_array_count(medge)); - memcpy(cddm2->mloop, mloop, sizeof(MLoop)*BLI_array_count(mloop)); - memcpy(cddm2->mpoly, mpoly, sizeof(MPoly)*BLI_array_count(mpoly)); + memcpy(cddm2->mvert, mvert, sizeof(MVert) * BLI_array_count(mvert)); + memcpy(cddm2->medge, medge, sizeof(MEdge) * BLI_array_count(medge)); + memcpy(cddm2->mloop, mloop, sizeof(MLoop) * BLI_array_count(mloop)); + memcpy(cddm2->mpoly, mpoly, sizeof(MPoly) * BLI_array_count(mpoly)); BLI_array_free(mvert); BLI_array_free(medge); BLI_array_free(mloop); BLI_array_free(mpoly); if (newv) @@ -2358,13 +2358,13 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) dm->needsFree = 1; dm->release(dm); - return (DerivedMesh*)cddm2; + return (DerivedMesh *)cddm2; } #endif void CDDM_calc_edges_tessface(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; CustomData edgeData; EdgeHashIterator *ehi; MFace *mf = cddm->mface; @@ -2401,10 +2401,10 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm) med = CustomData_get_layer(&edgeData, CD_MEDGE); index = CustomData_get_layer(&edgeData, CD_ORIGINDEX); for (i = 0; !BLI_edgehashIterator_isDone(ehi); - BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { + BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); - med->flag = ME_EDGEDRAW|ME_EDGERENDER; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; *index = ORIGINDEX_NONE; } BLI_edgehashIterator_free(ehi); @@ -2422,7 +2422,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm) /* warning, this uses existing edges but CDDM_calc_edges_tessface() doesn't */ void CDDM_calc_edges(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; CustomData edgeData; EdgeHashIterator *ehi; MPoly *mp = cddm->mpoly; @@ -2438,7 +2438,7 @@ void CDDM_calc_edges(DerivedMesh *dm) med = cddm->medge; if (med) { for (i = 0; i < numEdges; i++, med++) { - BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i+1)); + BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i + 1)); } } @@ -2464,12 +2464,12 @@ void CDDM_calc_edges(DerivedMesh *dm) med = CustomData_get_layer(&edgeData, CD_MEDGE); index = CustomData_get_layer(&edgeData, CD_ORIGINDEX); for (i = 0; !BLI_edgehashIterator_isDone(ehi); - BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { + BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - med->flag = ME_EDGEDRAW|ME_EDGERENDER; - *index = j==0 ? ORIGINDEX_NONE : eindex[j-1]; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; + *index = j == 0 ? ORIGINDEX_NONE : eindex[j - 1]; BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i)); } @@ -2498,7 +2498,7 @@ void CDDM_calc_edges(DerivedMesh *dm) void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts) { if (numVerts < dm->numVertData) - CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData-numVerts); + CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData - numVerts); dm->numVertData = numVerts; } @@ -2506,7 +2506,7 @@ void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts) void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) { if (numEdges < dm->numEdgeData) - CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData-numEdges); + CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData - numEdges); dm->numEdgeData = numEdges; } @@ -2514,7 +2514,7 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces) { if (numTessFaces < dm->numTessFaceData) - CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData-numTessFaces); + CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData - numTessFaces); dm->numTessFaceData = numTessFaces; } @@ -2522,7 +2522,7 @@ void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces) void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) { if (numPolys < dm->numPolyData) - CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData-numPolys); + CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData - numPolys); dm->numPolyData = numPolys; } @@ -2531,60 +2531,60 @@ void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) MVert *CDDM_get_vert(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mvert[index]; + return &((CDDerivedMesh *)dm)->mvert[index]; } MEdge *CDDM_get_edge(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->medge[index]; + return &((CDDerivedMesh *)dm)->medge[index]; } MFace *CDDM_get_tessface(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mface[index]; + return &((CDDerivedMesh *)dm)->mface[index]; } MLoop *CDDM_get_loop(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mloop[index]; + return &((CDDerivedMesh *)dm)->mloop[index]; } MPoly *CDDM_get_poly(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mpoly[index]; + return &((CDDerivedMesh *)dm)->mpoly[index]; } /* array access functions */ MVert *CDDM_get_verts(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mvert; + return ((CDDerivedMesh *)dm)->mvert; } MEdge *CDDM_get_edges(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->medge; + return ((CDDerivedMesh *)dm)->medge; } MFace *CDDM_get_tessfaces(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mface; + return ((CDDerivedMesh *)dm)->mface; } MLoop *CDDM_get_loops(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mloop; + return ((CDDerivedMesh *)dm)->mloop; } MPoly *CDDM_get_polys(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mpoly; + return ((CDDerivedMesh *)dm)->mpoly; } void CDDM_tessfaces_to_faces(DerivedMesh *dm) { /*converts mfaces to mpolys/mloops*/ - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MFace *mf; MEdge *me; EdgeHash *eh = BLI_edgehash_new(); @@ -2628,13 +2628,13 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) MPoly *mp; int l, *polyindex; - cddm->mloop = MEM_callocN(sizeof(MLoop)*totloop, "cddm->mloop in CDDM_tessfaces_to_faces"); - cddm->mpoly = MEM_callocN(sizeof(MPoly)*cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces"); + cddm->mloop = MEM_callocN(sizeof(MLoop) * totloop, "cddm->mloop in CDDM_tessfaces_to_faces"); + cddm->mpoly = MEM_callocN(sizeof(MPoly) * cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces"); CustomData_add_layer(&cddm->dm.loopData, CD_MLOOP, CD_ASSIGN, cddm->mloop, totloop); CustomData_add_layer(&cddm->dm.polyData, CD_MPOLY, CD_ASSIGN, cddm->mpoly, cddm->dm.numPolyData); CustomData_merge(&cddm->dm.faceData, &cddm->dm.polyData, - CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData); + CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData); polyindex = CustomData_get_layer(&cddm->dm.faceData, CD_POLYINDEX); @@ -2657,12 +2657,12 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) ml++, l++; ml->v = mf->v3; - ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4?mf->v4:mf->v1)); + ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4 ? mf->v4 : mf->v1)); ml++, l++; if (mf->v4) { ml->v = mf->v4; - ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1)); + ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1)); ml++, l++; } @@ -2675,7 +2675,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->vertData, CD_MVERT)) CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData); @@ -2685,7 +2685,7 @@ void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert) void CDDM_set_medge(DerivedMesh *dm, MEdge *medge) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->edgeData, CD_MEDGE)) CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, medge, dm->numEdgeData); @@ -2695,7 +2695,7 @@ void CDDM_set_medge(DerivedMesh *dm, MEdge *medge) void CDDM_set_mface(DerivedMesh *dm, MFace *mface) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->faceData, CD_MFACE)) CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numTessFaceData); @@ -2705,7 +2705,7 @@ void CDDM_set_mface(DerivedMesh *dm, MFace *mface) void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->loopData, CD_MLOOP)) CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_ASSIGN, mloop, dm->numLoopData); @@ -2715,7 +2715,7 @@ void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop) void CDDM_set_mpoly(DerivedMesh *dm, MPoly *mpoly) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->polyData, CD_MPOLY)) CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_ASSIGN, mpoly, dm->numPolyData); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2955e20c9e2..7ba117861bb 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -62,9 +62,9 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa int a; float clipminx, clipminy, clipmaxx, clipmaxy; - cumap= MEM_callocN(sizeof(CurveMapping), "new curvemap"); - cumap->flag= CUMA_DO_CLIP; - if (tot==4) cumap->cur= 3; /* rhms, hack for 'col' curve? */ + cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap"); + cumap->flag = CUMA_DO_CLIP; + if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */ clipminx = MIN2(minx, maxx); clipminy = MIN2(miny, maxy); @@ -72,20 +72,20 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa clipmaxy = MAX2(miny, maxy); BLI_init_rctf(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); - cumap->clipr= cumap->curr; + cumap->clipr = cumap->curr; - cumap->white[0]= cumap->white[1]= cumap->white[2]= 1.0f; - cumap->bwmul[0]= cumap->bwmul[1]= cumap->bwmul[2]= 1.0f; + cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; + cumap->bwmul[0] = cumap->bwmul[1] = cumap->bwmul[2] = 1.0f; - for (a=0; acm[a].flag= CUMA_EXTEND_EXTRAPOLATE; - cumap->cm[a].totpoint= 2; - cumap->cm[a].curve= MEM_callocN(2*sizeof(CurveMapPoint), "curve points"); - - cumap->cm[a].curve[0].x= minx; - cumap->cm[a].curve[0].y= miny; - cumap->cm[a].curve[1].x= maxx; - cumap->cm[a].curve[1].y= maxy; + for (a = 0; a < tot; a++) { + cumap->cm[a].flag = CUMA_EXTEND_EXTRAPOLATE; + cumap->cm[a].totpoint = 2; + cumap->cm[a].curve = MEM_callocN(2 * sizeof(CurveMapPoint), "curve points"); + + cumap->cm[a].curve[0].x = minx; + cumap->cm[a].curve[0].y = miny; + cumap->cm[a].curve[1].x = maxx; + cumap->cm[a].curve[1].y = maxy; } cumap->changed_timestamp = 0; @@ -98,7 +98,7 @@ void curvemapping_free(CurveMapping *cumap) int a; if (cumap) { - for (a=0; acm[a].curve) MEM_freeN(cumap->cm[a].curve); if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table); if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable); @@ -112,14 +112,14 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap) int a; if (cumap) { - CurveMapping *cumapn= MEM_dupallocN(cumap); - for (a=0; acm[a].curve) - cumapn->cm[a].curve= MEM_dupallocN(cumap->cm[a].curve); + cumapn->cm[a].curve = MEM_dupallocN(cumap->cm[a].curve); if (cumap->cm[a].table) - cumapn->cm[a].table= MEM_dupallocN(cumap->cm[a].table); + cumapn->cm[a].table = MEM_dupallocN(cumap->cm[a].table); if (cumap->cm[a].premultable) - cumapn->cm[a].premultable= MEM_dupallocN(cumap->cm[a].premultable); + cumapn->cm[a].premultable = MEM_dupallocN(cumap->cm[a].premultable); } return cumapn; } @@ -135,11 +135,11 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con if (black) copy_v3_v3(cumap->black, black); - for (a=0; a<3; a++) { - if (cumap->white[a]==cumap->black[a]) - cumap->bwmul[a]= 0.0f; + for (a = 0; a < 3; a++) { + if (cumap->white[a] == cumap->black[a]) + cumap->bwmul[a] = 0.0f; else - cumap->bwmul[a]= 1.0f/(cumap->white[a] - cumap->black[a]); + cumap->bwmul[a] = 1.0f / (cumap->white[a] - cumap->black[a]); } } @@ -149,52 +149,52 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con /* removes with flag set */ void curvemap_remove(CurveMap *cuma, int flag) { - CurveMapPoint *cmp= MEM_mallocN((cuma->totpoint)*sizeof(CurveMapPoint), "curve points"); - int a, b, removed=0; + CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); + int a, b, removed = 0; /* well, lets keep the two outer points! */ - cmp[0]= cuma->curve[0]; - for (a=1, b=1; atotpoint-1; a++) { + cmp[0] = cuma->curve[0]; + for (a = 1, b = 1; a < cuma->totpoint - 1; a++) { if (!(cuma->curve[a].flag & flag)) { - cmp[b]= cuma->curve[a]; + cmp[b] = cuma->curve[a]; b++; } else removed++; } - cmp[b]= cuma->curve[a]; + cmp[b] = cuma->curve[a]; MEM_freeN(cuma->curve); - cuma->curve= cmp; + cuma->curve = cmp; cuma->totpoint -= removed; } void curvemap_insert(CurveMap *cuma, float x, float y) { - CurveMapPoint *cmp= MEM_callocN((cuma->totpoint+1)*sizeof(CurveMapPoint), "curve points"); - int a, b, foundloc= 0; + CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points"); + int a, b, foundloc = 0; /* insert fragments of the old one and the new point to the new curve */ cuma->totpoint++; - for (a=0, b=0; atotpoint; a++) { + for (a = 0, b = 0; a < cuma->totpoint; a++) { if ((x < cuma->curve[a].x) && !foundloc) { - cmp[a].x= x; - cmp[a].y= y; - cmp[a].flag= CUMA_SELECT; - foundloc= 1; + cmp[a].x = x; + cmp[a].y = y; + cmp[a].flag = CUMA_SELECT; + foundloc = 1; } else { - cmp[a].x= cuma->curve[b].x; - cmp[a].y= cuma->curve[b].y; - cmp[a].flag= cuma->curve[b].flag; + cmp[a].x = cuma->curve[b].x; + cmp[a].y = cuma->curve[b].y; + cmp[a].flag = cuma->curve[b].flag; cmp[a].flag &= ~CUMA_SELECT; /* make sure old points don't remain selected */ - cmp[a].shorty= cuma->curve[b].shorty; + cmp[a].shorty = cuma->curve[b].shorty; b++; } } /* free old curve and replace it with new one */ MEM_freeN(cuma->curve); - cuma->curve= cmp; + cuma->curve = cmp; } void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) @@ -203,91 +203,91 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) MEM_freeN(cuma->curve); switch (preset) { - case CURVE_PRESET_LINE: cuma->totpoint= 2; break; - case CURVE_PRESET_SHARP: cuma->totpoint= 4; break; - case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; - case CURVE_PRESET_MAX: cuma->totpoint= 2; break; - case CURVE_PRESET_MID9: cuma->totpoint= 9; break; - case CURVE_PRESET_ROUND: cuma->totpoint= 4; break; - case CURVE_PRESET_ROOT: cuma->totpoint= 4; break; + case CURVE_PRESET_LINE: cuma->totpoint = 2; break; + case CURVE_PRESET_SHARP: cuma->totpoint = 4; break; + case CURVE_PRESET_SMOOTH: cuma->totpoint = 4; break; + case CURVE_PRESET_MAX: cuma->totpoint = 2; break; + case CURVE_PRESET_MID9: cuma->totpoint = 9; break; + case CURVE_PRESET_ROUND: cuma->totpoint = 4; break; + case CURVE_PRESET_ROOT: cuma->totpoint = 4; break; } - cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); + cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), "curve points"); switch (preset) { case CURVE_PRESET_LINE: - cuma->curve[0].x= clipr->xmin; - cuma->curve[0].y= clipr->ymax; - cuma->curve[0].flag= 0; - cuma->curve[1].x= clipr->xmax; - cuma->curve[1].y= clipr->ymin; - cuma->curve[1].flag= 0; + cuma->curve[0].x = clipr->xmin; + cuma->curve[0].y = clipr->ymax; + cuma->curve[0].flag = 0; + cuma->curve[1].x = clipr->xmax; + cuma->curve[1].y = clipr->ymin; + cuma->curve[1].flag = 0; break; case CURVE_PRESET_SHARP: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.50; - cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.04; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.25; + cuma->curve[1].y = 0.50; + cuma->curve[2].x = 0.75; + cuma->curve[2].y = 0.04; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; case CURVE_PRESET_SMOOTH: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.94; - cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.06; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.25; + cuma->curve[1].y = 0.94; + cuma->curve[2].x = 0.75; + cuma->curve[2].y = 0.06; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; case CURVE_PRESET_MAX: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 1; - cuma->curve[1].y= 1; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 1; + cuma->curve[1].y = 1; break; case CURVE_PRESET_MID9: - { - int i; - for (i = 0; i < cuma->totpoint; i++) { - cuma->curve[i].x = i / ((float)cuma->totpoint - 1); - cuma->curve[i].y = 0.5; - } + { + int i; + for (i = 0; i < cuma->totpoint; i++) { + cuma->curve[i].x = i / ((float)cuma->totpoint - 1); + cuma->curve[i].y = 0.5; } - break; + } + break; case CURVE_PRESET_ROUND: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.5; - cuma->curve[1].y= 0.90; - cuma->curve[2].x= 0.86; - cuma->curve[2].y= 0.5; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.5; + cuma->curve[1].y = 0.90; + cuma->curve[2].x = 0.86; + cuma->curve[2].y = 0.5; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; case CURVE_PRESET_ROOT: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.95; - cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.44; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.25; + cuma->curve[1].y = 0.95; + cuma->curve[2].x = 0.75; + cuma->curve[2].y = 0.44; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; } /* mirror curve in x direction to have positive slope * rather than default negative slope */ if (slope == CURVEMAP_SLOPE_POSITIVE) { - int i, last=cuma->totpoint-1; - CurveMapPoint *newpoints= MEM_dupallocN(cuma->curve); + int i, last = cuma->totpoint - 1; + CurveMapPoint *newpoints = MEM_dupallocN(cuma->curve); - for (i=0; itotpoint; i++) { - newpoints[i].y = cuma->curve[last-i].y; + for (i = 0; i < cuma->totpoint; i++) { + newpoints[i].y = cuma->curve[last - i].y; } MEM_freeN(cuma->curve); @@ -296,7 +296,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) if (cuma->table) { MEM_freeN(cuma->table); - cuma->table= NULL; + cuma->table = NULL; } } @@ -305,7 +305,7 @@ void curvemap_sethandle(CurveMap *cuma, int type) { int a; - for (a=0; atotpoint; a++) { + for (a = 0; a < cuma->totpoint; a++) { if (cuma->curve[a].flag & CUMA_SELECT) { if (type) cuma->curve[a].flag |= CUMA_VECTOR; else cuma->curve[a].flag &= ~CUMA_VECTOR; @@ -322,65 +322,65 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex float len, len_a, len_b; float dvec_a[2], dvec_b[2]; - if (bezt->h1==0 && bezt->h2==0) { + if (bezt->h1 == 0 && bezt->h2 == 0) { return; } - p2= bezt->vec[1]; + p2 = bezt->vec[1]; - if (prev==NULL) { - p3= next->vec[1]; - pt[0]= 2.0f*p2[0] - p3[0]; - pt[1]= 2.0f*p2[1] - p3[1]; - p1= pt; + if (prev == NULL) { + p3 = next->vec[1]; + pt[0] = 2.0f * p2[0] - p3[0]; + pt[1] = 2.0f * p2[1] - p3[1]; + p1 = pt; } else { - p1= prev->vec[1]; + p1 = prev->vec[1]; } - if (next==NULL) { - p1= prev->vec[1]; - pt[0]= 2.0f*p2[0] - p1[0]; - pt[1]= 2.0f*p2[1] - p1[1]; - p3= pt; + if (next == NULL) { + p1 = prev->vec[1]; + pt[0] = 2.0f * p2[0] - p1[0]; + pt[1] = 2.0f * p2[1] - p1[1]; + p3 = pt; } else { - p3= next->vec[1]; + p3 = next->vec[1]; } sub_v2_v2v2(dvec_a, p2, p1); sub_v2_v2v2(dvec_b, p3, p2); - len_a= len_v2(dvec_a); - len_b= len_v2(dvec_b); + len_a = len_v2(dvec_a); + len_b = len_v2(dvec_b); - if (len_a==0.0f) len_a=1.0f; - if (len_b==0.0f) len_b=1.0f; + if (len_a == 0.0f) len_a = 1.0f; + if (len_b == 0.0f) len_b = 1.0f; - if (bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */ + if (bezt->h1 == HD_AUTO || bezt->h2 == HD_AUTO) { /* auto */ float tvec[2]; - tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a; - tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a; + tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a; + tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a; - len= len_v2(tvec) * 2.5614f; - if (len!=0.0f) { + len = len_v2(tvec) * 2.5614f; + if (len != 0.0f) { - if (bezt->h1==HD_AUTO) { - len_a/=len; - madd_v2_v2v2fl(p2-3, p2, tvec, -len_a); + if (bezt->h1 == HD_AUTO) { + len_a /= len; + madd_v2_v2v2fl(p2 - 3, p2, tvec, -len_a); } - if (bezt->h2==HD_AUTO) { - len_b/=len; - madd_v2_v2v2fl(p2+3, p2, tvec, len_b); + if (bezt->h2 == HD_AUTO) { + len_b /= len; + madd_v2_v2v2fl(p2 + 3, p2, tvec, len_b); } } } - if (bezt->h1==HD_VECT) { /* vector */ - madd_v2_v2v2fl(p2-3, p2, dvec_a, -1.0f/3.0f); + if (bezt->h1 == HD_VECT) { /* vector */ + madd_v2_v2v2fl(p2 - 3, p2, dvec_a, -1.0f / 3.0f); } - if (bezt->h2==HD_VECT) { - madd_v2_v2v2fl(p2+3, p2, dvec_b, 1.0f/3.0f); + if (bezt->h2 == HD_VECT) { + madd_v2_v2v2fl(p2 + 3, p2, dvec_b, 1.0f / 3.0f); } } @@ -389,27 +389,27 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2]) { if (x <= first[0]) { - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) { + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { /* no extrapolate */ return first[1]; } else { - if (cuma->ext_in[0]==0.0f) - return first[1] + cuma->ext_in[1]*10000.0f; + if (cuma->ext_in[0] == 0.0f) + return first[1] + cuma->ext_in[1] * 10000.0f; else - return first[1] + cuma->ext_in[1]*(x - first[0])/cuma->ext_in[0]; + return first[1] + cuma->ext_in[1] * (x - first[0]) / cuma->ext_in[0]; } } else if (x >= last[0]) { - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) { + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { /* no extrapolate */ return last[1]; } else { - if (cuma->ext_out[0]==0.0f) - return last[1] - cuma->ext_out[1]*10000.0f; + if (cuma->ext_out[0] == 0.0f) + return last[1] - cuma->ext_out[1] * 10000.0f; else - return last[1] + cuma->ext_out[1]*(x - last[0])/cuma->ext_out[0]; + return last[1] + cuma->ext_out[1] * (x - last[0]) / cuma->ext_out[0]; } } return 0.0f; @@ -418,74 +418,74 @@ static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], /* only creates a table for a single channel in CurveMapping */ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) { - CurveMapPoint *cmp= cuma->curve; + CurveMapPoint *cmp = cuma->curve; BezTriple *bezt; float *fp, *allpoints, *lastpoint, curf, range; int a, totpoint; - if (cuma->curve==NULL) return; + if (cuma->curve == NULL) return; /* default rect also is table range */ - cuma->mintable= clipr->xmin; - cuma->maxtable= clipr->xmax; + cuma->mintable = clipr->xmin; + cuma->maxtable = clipr->xmax; /* hrmf... we now rely on blender ipo beziers, these are more advanced */ - bezt= MEM_callocN(cuma->totpoint*sizeof(BezTriple), "beztarr"); + bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr"); - for (a=0; atotpoint; a++) { - cuma->mintable= MIN2(cuma->mintable, cmp[a].x); - cuma->maxtable= MAX2(cuma->maxtable, cmp[a].x); - bezt[a].vec[1][0]= cmp[a].x; - bezt[a].vec[1][1]= cmp[a].y; + for (a = 0; a < cuma->totpoint; a++) { + cuma->mintable = MIN2(cuma->mintable, cmp[a].x); + cuma->maxtable = MAX2(cuma->maxtable, cmp[a].x); + bezt[a].vec[1][0] = cmp[a].x; + bezt[a].vec[1][1] = cmp[a].y; if (cmp[a].flag & CUMA_VECTOR) - bezt[a].h1= bezt[a].h2= HD_VECT; + bezt[a].h1 = bezt[a].h2 = HD_VECT; else - bezt[a].h1= bezt[a].h2= HD_AUTO; + bezt[a].h1 = bezt[a].h2 = HD_AUTO; } - for (a=0; atotpoint; a++) { - if (a==0) - calchandle_curvemap(bezt, NULL, bezt+1, 0); - else if (a==cuma->totpoint-1) - calchandle_curvemap(bezt+a, bezt+a-1, NULL, 0); + for (a = 0; a < cuma->totpoint; a++) { + if (a == 0) + calchandle_curvemap(bezt, NULL, bezt + 1, 0); + else if (a == cuma->totpoint - 1) + calchandle_curvemap(bezt + a, bezt + a - 1, NULL, 0); else - calchandle_curvemap(bezt+a, bezt+a-1, bezt+a+1, 0); + calchandle_curvemap(bezt + a, bezt + a - 1, bezt + a + 1, 0); } /* first and last handle need correction, instead of pointing to center of next/prev, * we let it point to the closest handle */ - if (cuma->totpoint>2) { + if (cuma->totpoint > 2) { float hlen, nlen, vec[3]; - if (bezt[0].h2==HD_AUTO) { + if (bezt[0].h2 == HD_AUTO) { - hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ + hlen = len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ /* clip handle point */ copy_v3_v3(vec, bezt[1].vec[0]); if (vec[0] < bezt[0].vec[1][0]) - vec[0]= bezt[0].vec[1][0]; + vec[0] = bezt[0].vec[1][0]; sub_v3_v3(vec, bezt[0].vec[1]); - nlen= len_v3(vec); - if (nlen>FLT_EPSILON) { - mul_v3_fl(vec, hlen/nlen); + nlen = len_v3(vec); + if (nlen > FLT_EPSILON) { + mul_v3_fl(vec, hlen / nlen); add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]); sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec); } } - a= cuma->totpoint-1; - if (bezt[a].h2==HD_AUTO) { + a = cuma->totpoint - 1; + if (bezt[a].h2 == HD_AUTO) { - hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ + hlen = len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ /* clip handle point */ - copy_v3_v3(vec, bezt[a-1].vec[2]); + copy_v3_v3(vec, bezt[a - 1].vec[2]); if (vec[0] > bezt[a].vec[1][0]) - vec[0]= bezt[a].vec[1][0]; + vec[0] = bezt[a].vec[1][0]; sub_v3_v3(vec, bezt[a].vec[1]); - nlen= len_v3(vec); - if (nlen>FLT_EPSILON) { - mul_v3_fl(vec, hlen/nlen); + nlen = len_v3(vec); + if (nlen > FLT_EPSILON) { + mul_v3_fl(vec, hlen / nlen); add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]); sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec); } @@ -494,63 +494,63 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) /* make the bezier curve */ if (cuma->table) MEM_freeN(cuma->table); - totpoint= (cuma->totpoint-1)*CM_RESOL; - fp= allpoints= MEM_callocN(totpoint*2*sizeof(float), "table"); + totpoint = (cuma->totpoint - 1) * CM_RESOL; + fp = allpoints = MEM_callocN(totpoint * 2 * sizeof(float), "table"); - for (a=0; atotpoint-1; a++, fp += 2*CM_RESOL) { - correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]); - BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float)); - BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float)); + for (a = 0; a < cuma->totpoint - 1; a++, fp += 2 * CM_RESOL) { + correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 1].vec[1]); + BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a + 1].vec[0][0], bezt[a + 1].vec[1][0], fp, CM_RESOL - 1, 2 * sizeof(float)); + BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a + 1].vec[0][1], bezt[a + 1].vec[1][1], fp + 1, CM_RESOL - 1, 2 * sizeof(float)); } /* store first and last handle for extrapolation, unit length */ - cuma->ext_in[0]= bezt[0].vec[0][0] - bezt[0].vec[1][0]; - cuma->ext_in[1]= bezt[0].vec[0][1] - bezt[0].vec[1][1]; - range= sqrt(cuma->ext_in[0]*cuma->ext_in[0] + cuma->ext_in[1]*cuma->ext_in[1]); - cuma->ext_in[0]/= range; - cuma->ext_in[1]/= range; - - a= cuma->totpoint-1; - cuma->ext_out[0]= bezt[a].vec[1][0] - bezt[a].vec[2][0]; - cuma->ext_out[1]= bezt[a].vec[1][1] - bezt[a].vec[2][1]; - range= sqrt(cuma->ext_out[0]*cuma->ext_out[0] + cuma->ext_out[1]*cuma->ext_out[1]); - cuma->ext_out[0]/= range; - cuma->ext_out[1]/= range; + cuma->ext_in[0] = bezt[0].vec[0][0] - bezt[0].vec[1][0]; + cuma->ext_in[1] = bezt[0].vec[0][1] - bezt[0].vec[1][1]; + range = sqrt(cuma->ext_in[0] * cuma->ext_in[0] + cuma->ext_in[1] * cuma->ext_in[1]); + cuma->ext_in[0] /= range; + cuma->ext_in[1] /= range; + + a = cuma->totpoint - 1; + cuma->ext_out[0] = bezt[a].vec[1][0] - bezt[a].vec[2][0]; + cuma->ext_out[1] = bezt[a].vec[1][1] - bezt[a].vec[2][1]; + range = sqrt(cuma->ext_out[0] * cuma->ext_out[0] + cuma->ext_out[1] * cuma->ext_out[1]); + cuma->ext_out[0] /= range; + cuma->ext_out[1] /= range; /* cleanup */ MEM_freeN(bezt); - range= CM_TABLEDIV*(cuma->maxtable - cuma->mintable); - cuma->range= 1.0f/range; + range = CM_TABLEDIV * (cuma->maxtable - cuma->mintable); + cuma->range = 1.0f / range; /* now make a table with CM_TABLE equal x distances */ - fp= allpoints; - lastpoint= allpoints + 2*(totpoint-1); - cmp= MEM_callocN((CM_TABLE+1)*sizeof(CurveMapPoint), "dist table"); - - for (a=0; a<=CM_TABLE; a++) { - curf= cuma->mintable + range*(float)a; - cmp[a].x= curf; + fp = allpoints; + lastpoint = allpoints + 2 * (totpoint - 1); + cmp = MEM_callocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "dist table"); + + for (a = 0; a <= CM_TABLE; a++) { + curf = cuma->mintable + range * (float)a; + cmp[a].x = curf; /* get the first x coordinate larger than curf */ - while (curf >= fp[0] && fp!=lastpoint) { - fp+=2; + while (curf >= fp[0] && fp != lastpoint) { + fp += 2; } - if (fp==allpoints || (curf >= fp[0] && fp==lastpoint)) - cmp[a].y= curvemap_calc_extend(cuma, curf, allpoints, lastpoint); + if (fp == allpoints || (curf >= fp[0] && fp == lastpoint)) + cmp[a].y = curvemap_calc_extend(cuma, curf, allpoints, lastpoint); else { - float fac1= fp[0] - fp[-2]; - float fac2= fp[0] - curf; + float fac1 = fp[0] - fp[-2]; + float fac2 = fp[0] - curf; if (fac1 > FLT_EPSILON) - fac1= fac2/fac1; + fac1 = fac2 / fac1; else - fac1= 0.0f; - cmp[a].y= fac1*fp[-1] + (1.0f-fac1)*fp[1]; + fac1 = 0.0f; + cmp[a].y = fac1 * fp[-1] + (1.0f - fac1) * fp[1]; } } MEM_freeN(allpoints); - cuma->table= cmp; + cuma->table = cmp; } /* call when you do images etc, needs restore too. also verifies tables */ @@ -561,34 +561,34 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore) if (restore) { if (cumap->flag & CUMA_PREMULLED) { - for (a=0; a<3; a++) { + for (a = 0; a < 3; a++) { MEM_freeN(cumap->cm[a].table); - cumap->cm[a].table= cumap->cm[a].premultable; - cumap->cm[a].premultable= NULL; + cumap->cm[a].table = cumap->cm[a].premultable; + cumap->cm[a].premultable = NULL; } cumap->flag &= ~CUMA_PREMULLED; } } else { - if ((cumap->flag & CUMA_PREMULLED)==0) { + if ((cumap->flag & CUMA_PREMULLED) == 0) { /* verify and copy */ - for (a=0; a<3; a++) { - if (cumap->cm[a].table==NULL) - curvemap_make_table(cumap->cm+a, &cumap->clipr); - cumap->cm[a].premultable= cumap->cm[a].table; - cumap->cm[a].table= MEM_mallocN((CM_TABLE+1)*sizeof(CurveMapPoint), "premul table"); - memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE+1)*sizeof(CurveMapPoint)); + for (a = 0; a < 3; a++) { + if (cumap->cm[a].table == NULL) + curvemap_make_table(cumap->cm + a, &cumap->clipr); + cumap->cm[a].premultable = cumap->cm[a].table; + cumap->cm[a].table = MEM_mallocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "premul table"); + memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE + 1) * sizeof(CurveMapPoint)); } - if (cumap->cm[3].table==NULL) - curvemap_make_table(cumap->cm+3, &cumap->clipr); + if (cumap->cm[3].table == NULL) + curvemap_make_table(cumap->cm + 3, &cumap->clipr); /* premul */ - for (a=0; a<3; a++) { + for (a = 0; a < 3; a++) { int b; - for (b=0; b<=CM_TABLE; b++) { - cumap->cm[a].table[b].y= curvemap_evaluateF(cumap->cm+3, cumap->cm[a].table[b].y); + for (b = 0; b <= CM_TABLE; b++) { + cumap->cm[a].table[b].y = curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y); } } @@ -599,10 +599,10 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore) static int sort_curvepoints(const void *a1, const void *a2) { - const struct CurveMapPoint *x1=a1, *x2=a2; + const struct CurveMapPoint *x1 = a1, *x2 = a2; - if ( x1->x > x2->x ) return 1; - else if ( x1->x < x2->x) return -1; + if (x1->x > x2->x) return 1; + else if (x1->x < x2->x) return -1; return 0; } @@ -611,30 +611,30 @@ static int sort_curvepoints(const void *a1, const void *a2) /* note; only does current curvemap! */ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) { - CurveMap *cuma= cumap->cm+cumap->cur; - CurveMapPoint *cmp= cuma->curve; - rctf *clipr= &cumap->clipr; - float thresh= 0.01f*(clipr->xmax - clipr->xmin); - float dx= 0.0f, dy= 0.0f; + CurveMap *cuma = cumap->cm + cumap->cur; + CurveMapPoint *cmp = cuma->curve; + rctf *clipr = &cumap->clipr; + float thresh = 0.01f * (clipr->xmax - clipr->xmin); + float dx = 0.0f, dy = 0.0f; int a; cumap->changed_timestamp++; /* clamp with clip */ if (cumap->flag & CUMA_DO_CLIP) { - for (a=0; atotpoint; a++) { + for (a = 0; a < cuma->totpoint; a++) { if (cmp[a].flag & CUMA_SELECT) { if (cmp[a].x < clipr->xmin) - dx= MIN2(dx, cmp[a].x - clipr->xmin); + dx = MIN2(dx, cmp[a].x - clipr->xmin); else if (cmp[a].x > clipr->xmax) - dx= MAX2(dx, cmp[a].x - clipr->xmax); + dx = MAX2(dx, cmp[a].x - clipr->xmax); if (cmp[a].y < clipr->ymin) - dy= MIN2(dy, cmp[a].y - clipr->ymin); + dy = MIN2(dy, cmp[a].y - clipr->ymin); else if (cmp[a].y > clipr->ymax) - dy= MAX2(dy, cmp[a].y - clipr->ymax); + dy = MAX2(dy, cmp[a].y - clipr->ymax); } } - for (a=0; atotpoint; a++) { + for (a = 0; a < cuma->totpoint; a++) { if (cmp[a].flag & CUMA_SELECT) { cmp[a].x -= dx; cmp[a].y -= dy; @@ -646,25 +646,25 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints); /* remove doubles, threshold set on 1% of default range */ - if (rem_doubles && cuma->totpoint>2) { - for (a=0; atotpoint-1; a++) { - dx= cmp[a].x - cmp[a+1].x; - dy= cmp[a].y - cmp[a+1].y; - if ( sqrtf(dx*dx + dy*dy) < thresh ) { - if (a==0) { - cmp[a+1].flag|= 2; - if (cmp[a+1].flag & CUMA_SELECT) + if (rem_doubles && cuma->totpoint > 2) { + for (a = 0; a < cuma->totpoint - 1; a++) { + dx = cmp[a].x - cmp[a + 1].x; + dy = cmp[a].y - cmp[a + 1].y; + if (sqrtf(dx * dx + dy * dy) < thresh) { + if (a == 0) { + cmp[a + 1].flag |= 2; + if (cmp[a + 1].flag & CUMA_SELECT) cmp[a].flag |= CUMA_SELECT; } else { - cmp[a].flag|= 2; + cmp[a].flag |= 2; if (cmp[a].flag & CUMA_SELECT) - cmp[a+1].flag |= CUMA_SELECT; + cmp[a + 1].flag |= CUMA_SELECT; } - break; /* we assume 1 deletion per edit is ok */ + break; /* we assume 1 deletion per edit is ok */ } } - if (a != cuma->totpoint-1) + if (a != cuma->totpoint - 1) curvemap_remove(cuma, 2); } curvemap_make_table(cuma, clipr); @@ -677,31 +677,31 @@ float curvemap_evaluateF(CurveMap *cuma, float value) int i; /* index in table */ - fi= (value-cuma->mintable)*cuma->range; - i= (int)fi; + fi = (value - cuma->mintable) * cuma->range; + i = (int)fi; /* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */ - if (fi<0.0f || fi>CM_TABLE) + if (fi < 0.0f || fi > CM_TABLE) return curvemap_calc_extend(cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x); else { - if (i<0) return cuma->table[0].y; - if (i>=CM_TABLE) return cuma->table[CM_TABLE].y; + if (i < 0) return cuma->table[0].y; + if (i >= CM_TABLE) return cuma->table[CM_TABLE].y; - fi= fi-(float)i; - return (1.0f-fi)*cuma->table[i].y + (fi)*cuma->table[i+1].y; + fi = fi - (float)i; + return (1.0f - fi) * cuma->table[i].y + (fi) * cuma->table[i + 1].y; } } /* works with curve 'cur' */ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) { - CurveMap *cuma= cumap->cm+cur; + CurveMap *cuma = cumap->cm + cur; /* allocate or bail out */ - if (cuma->table==NULL) { + if (cuma->table == NULL) { curvemap_make_table(cuma, &cumap->clipr); - if (cuma->table==NULL) - return 1.0f-value; + if (cuma->table == NULL) + return 1.0f - value; } return curvemap_evaluateF(cuma, value); } @@ -709,17 +709,17 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) /* vector case */ void curvemapping_evaluate3F(CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0]= curvemapping_evaluateF(cumap, 0, vecin[0]); - vecout[1]= curvemapping_evaluateF(cumap, 1, vecin[1]); - vecout[2]= curvemapping_evaluateF(cumap, 2, vecin[2]); + vecout[0] = curvemapping_evaluateF(cumap, 0, vecin[0]); + vecout[1] = curvemapping_evaluateF(cumap, 1, vecin[1]); + vecout[2] = curvemapping_evaluateF(cumap, 2, vecin[2]); } /* RGB case, no black/white points, no premult */ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0]= curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0])); - vecout[1]= curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1])); - vecout[2]= curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2])); + vecout[0] = curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0])); + vecout[1] = curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1])); + vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2])); } @@ -728,14 +728,14 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], cons { float fac; - fac= (vecin[0] - cumap->black[0])*cumap->bwmul[0]; - vecout[0]= curvemap_evaluateF(cumap->cm, fac); + fac = (vecin[0] - cumap->black[0]) * cumap->bwmul[0]; + vecout[0] = curvemap_evaluateF(cumap->cm, fac); - fac= (vecin[1] - cumap->black[1])*cumap->bwmul[1]; - vecout[1]= curvemap_evaluateF(cumap->cm+1, fac); + fac = (vecin[1] - cumap->black[1]) * cumap->bwmul[1]; + vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); - fac= (vecin[2] - cumap->black[2])*cumap->bwmul[2]; - vecout[2]= curvemap_evaluateF(cumap->cm+2, fac); + fac = (vecin[2] - cumap->black[2]) * cumap->bwmul[2]; + vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); } @@ -746,14 +746,14 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) int pixel; float *pix_in; float col[3]; - int stride= 4; + int stride = 4; float *pix_out; - if (ibuf==NULL) + if (ibuf == NULL) return; - if (ibuf->rect_float==NULL) + if (ibuf->rect_float == NULL) IMB_float_from_rect(ibuf); - else if (ibuf->rect==NULL) + else if (ibuf->rect == NULL) imb_addrectImBuf(ibuf); if (!ibuf->rect || !ibuf->rect_float) @@ -765,27 +765,27 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) curvemapping_premultiply(cumap, 0); - pix_in= ibuf->rect_float; - pix_out= tmpbuf->rect_float; + pix_in = ibuf->rect_float; + pix_out = tmpbuf->rect_float; if (ibuf->channels) - stride= ibuf->channels; + stride = ibuf->channels; - for (pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=stride) { - if (stride<3) { - col[0]= curvemap_evaluateF(cumap->cm, *pix_in); + for (pixel = ibuf->x * ibuf->y; pixel > 0; pixel--, pix_in += stride, pix_out += stride) { + if (stride < 3) { + col[0] = curvemap_evaluateF(cumap->cm, *pix_in); - pix_out[1]= pix_out[2]= pix_out[3]= pix_out[0]= col[0]; + pix_out[1] = pix_out[2] = pix_out[3] = pix_out[0] = col[0]; } else { curvemapping_evaluate_premulRGBF(cumap, col, pix_in); - pix_out[0]= col[0]; - pix_out[1]= col[1]; - pix_out[2]= col[2]; - if (stride>3) - pix_out[3]= pix_in[3]; + pix_out[0] = col[0]; + pix_out[1] = col[1]; + pix_out[2] = col[2]; + if (stride > 3) + pix_out[3] = pix_in[3]; else - pix_out[3]= 1.f; + pix_out[3] = 1.f; } } @@ -800,16 +800,16 @@ int curvemapping_RGBA_does_something(CurveMapping *cumap) { int a; - if (cumap->black[0]!=0.0f) return 1; - if (cumap->black[1]!=0.0f) return 1; - if (cumap->black[2]!=0.0f) return 1; - if (cumap->white[0]!=1.0f) return 1; - if (cumap->white[1]!=1.0f) return 1; - if (cumap->white[2]!=1.0f) return 1; + if (cumap->black[0] != 0.0f) return 1; + if (cumap->black[1] != 0.0f) return 1; + if (cumap->black[2] != 0.0f) return 1; + if (cumap->white[0] != 1.0f) return 1; + if (cumap->white[1] != 1.0f) return 1; + if (cumap->white[2] != 1.0f) return 1; - for (a=0; acm[a].curve) { - if (cumap->cm[a].totpoint!=2) return 1; + if (cumap->cm[a].totpoint != 2) return 1; if (cumap->cm[a].curve[0].x != 0.0f) return 1; if (cumap->cm[a].curve[0].y != 0.0f) return 1; @@ -824,11 +824,11 @@ void curvemapping_initialize(CurveMapping *cumap) { int a; - if (cumap==NULL) return; + if (cumap == NULL) return; - for (a=0; acm[a].table==NULL) - curvemap_make_table(cumap->cm+a, &cumap->clipr); + for (a = 0; a < CM_TOT; a++) { + if (cumap->cm[a].table == NULL) + curvemap_make_table(cumap->cm + a, &cumap->clipr); } } @@ -836,29 +836,29 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) { int a; - *size = CM_TABLE+1; - *array = MEM_callocN(sizeof(float)*(*size)*4, "CurveMapping"); + *size = CM_TABLE + 1; + *array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping"); curvemapping_initialize(cumap); - for (a=0; a<*size; a++) { + for (a = 0; a < *size; a++) { if (cumap->cm[0].table) - (*array)[a*4+0]= cumap->cm[0].table[a].y; + (*array)[a * 4 + 0] = cumap->cm[0].table[a].y; if (cumap->cm[1].table) - (*array)[a*4+1]= cumap->cm[1].table[a].y; + (*array)[a * 4 + 1] = cumap->cm[1].table[a].y; if (cumap->cm[2].table) - (*array)[a*4+2]= cumap->cm[2].table[a].y; + (*array)[a * 4 + 2] = cumap->cm[2].table[a].y; if (cumap->cm[3].table) - (*array)[a*4+3]= cumap->cm[3].table[a].y; + (*array)[a * 4 + 3] = cumap->cm[3].table[a].y; } } /* ***************** Histogram **************** */ -#define INV_255 (1.f/255.f) +#define INV_255 (1.f / 255.f) DO_INLINE int get_bin_float(float f) { - int bin= (int)((f*255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */ + int bin = (int)((f * 255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */ /* note: clamp integer instead of float to avoid problems with NaN */ CLAMP(bin, 0, 255); @@ -907,17 +907,17 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) int x, y, c; unsigned int n, nl; double div, divl; - float *rf=NULL; - unsigned char *rc=NULL; + float *rf = NULL; + unsigned char *rc = NULL; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; float rgb[3], ycc[3], luma; - int ycc_mode=-1; + int ycc_mode = -1; const short is_float = (ibuf->rect_float != NULL); - if (ibuf->rect==NULL && ibuf->rect_float==NULL) return; + if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; - if (scopes->ok == 1 ) return; + if (scopes->ok == 1) return; if (scopes->hist.ymax == 0.f) scopes->hist.ymax = 1.f; @@ -950,19 +950,19 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) bin_lum = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); /* convert to number of lines with logarithmic scale */ - scopes->sample_lines = (scopes->accuracy*0.01f) * (scopes->accuracy*0.01f) * ibuf->y; + scopes->sample_lines = (scopes->accuracy * 0.01f) * (scopes->accuracy * 0.01f) * ibuf->y; if (scopes->sample_full) scopes->sample_lines = ibuf->y; /* scan the image */ - savedlines=0; - for (c=0; c<3; c++) { - scopes->minmax[c][0]=25500.0f; - scopes->minmax[c][1]=-25500.0f; + savedlines = 0; + for (c = 0; c < 3; c++) { + scopes->minmax[c][0] = 25500.0f; + scopes->minmax[c][1] = -25500.0f; } - scopes->waveform_tot = ibuf->x*scopes->sample_lines; + scopes->waveform_tot = ibuf->x * scopes->sample_lines; if (scopes->waveform_1) MEM_freeN(scopes->waveform_1); @@ -973,10 +973,10 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) if (scopes->vecscope) MEM_freeN(scopes->vecscope); - scopes->waveform_1= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); - scopes->waveform_2= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); - scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); - scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); + scopes->waveform_1 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); + scopes->waveform_2 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); + scopes->waveform_3 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); + scopes->vecscope = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); if (is_float) rf = ibuf->rect_float; @@ -984,7 +984,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) rc = (unsigned char *)ibuf->rect; for (y = 0; y < ibuf->y; y++) { - if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { + if (savedlines < scopes->sample_lines && y >= ((savedlines) * ibuf->y) / (scopes->sample_lines + 1)) { saveline = 1; } else { @@ -999,7 +999,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) copy_v3_v3(rgb, rf); } else { - for (c=0; c<3; c++) + for (c = 0; c < 3; c++) rgb[c] = rc[c] * INV_255; } @@ -1007,44 +1007,44 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) luma = rgb_to_luma(rgb); /* check for min max */ - if (ycc_mode == -1 ) { - for (c=0; c<3; c++) { + if (ycc_mode == -1) { + for (c = 0; c < 3; c++) { if (rgb[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = rgb[c]; if (rgb[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = rgb[c]; } } else { rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc[0], &ycc[1], &ycc[2], ycc_mode); - for (c=0; c<3; c++) { - ycc[c] *=INV_255; + for (c = 0; c < 3; c++) { + ycc[c] *= INV_255; if (ycc[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = ycc[c]; if (ycc[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = ycc[c]; } } /* increment count for histo*/ - bin_r[ get_bin_float(rgb[0]) ] += 1; - bin_g[ get_bin_float(rgb[1]) ] += 1; - bin_b[ get_bin_float(rgb[2]) ] += 1; - bin_lum[ get_bin_float(luma) ] += 1; + bin_r[get_bin_float(rgb[0])] += 1; + bin_g[get_bin_float(rgb[1])] += 1; + bin_b[get_bin_float(rgb[2])] += 1; + bin_lum[get_bin_float(luma)] += 1; /* save sample if needed */ if (saveline) { const float fx = (float)x / (float)ibuf->x; - const int idx = 2*(ibuf->x*savedlines+x); + const int idx = 2 * (ibuf->x * savedlines + x); save_sample_line(scopes, idx, fx, rgb, ycc); } - rf+= ibuf->channels; - rc+= ibuf->channels; + rf += ibuf->channels; + rc += ibuf->channels; } if (saveline) - savedlines +=1; + savedlines += 1; } /* convert hist data to float (proportional to max count) */ - n=0; - nl=0; - for (x=0; x<256; x++) { + n = 0; + nl = 0; + for (x = 0; x < 256; x++) { if (bin_r[x] > n) n = bin_r[x]; if (bin_g[x] > n) @@ -1054,9 +1054,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) if (bin_lum[x] > nl) nl = bin_lum[x]; } - div = 1.0/(double)n; - divl = 1.0/(double)nl; - for (x=0; x<256; x++) { + div = 1.0 / (double)n; + divl = 1.0 / (double)nl; + for (x = 0; x < 256; x++) { scopes->hist.data_r[x] = bin_r[x] * div; scopes->hist.data_g[x] = bin_g[x] * div; scopes->hist.data_b[x] = bin_b[x] * div; @@ -1092,14 +1092,14 @@ void scopes_free(Scopes *scopes) void scopes_new(Scopes *scopes) { - scopes->accuracy=30.0; - scopes->hist.mode=HISTO_MODE_RGB; - scopes->wavefrm_alpha=0.3; - scopes->vecscope_alpha=0.3; - scopes->wavefrm_height= 100; - scopes->vecscope_height= 100; - scopes->hist.height= 100; - scopes->ok= 0; + scopes->accuracy = 30.0; + scopes->hist.mode = HISTO_MODE_RGB; + scopes->wavefrm_alpha = 0.3; + scopes->vecscope_alpha = 0.3; + scopes->wavefrm_height = 100; + scopes->vecscope_height = 100; + scopes->hist.height = 100; + scopes->ok = 0; scopes->waveform_1 = NULL; scopes->waveform_2 = NULL; scopes->waveform_3 = NULL; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9e47d136863..eed5ec49012 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -69,7 +69,7 @@ #include "BKE_constraint.h" #include "BKE_displist.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" /* for geometry targets */ +#include "BKE_DerivedMesh.h" /* for geometry targets */ #include "BKE_cdderivedmesh.h" /* for geometry targets */ #include "BKE_object.h" #include "BKE_ipo.h" @@ -90,7 +90,7 @@ #endif #ifndef M_PI -#define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846 #endif @@ -113,15 +113,15 @@ void unique_constraint_name(bConstraint *con, ListBase *list) /* package an object/bone for use in constraint evaluation */ /* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */ -bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, short datatype) +bConstraintOb *constraints_make_evalob(Scene *scene, Object *ob, void *subdata, short datatype) { bConstraintOb *cob; /* create regardless of whether we have any data! */ - cob= MEM_callocN(sizeof(bConstraintOb), "bConstraintOb"); + cob = MEM_callocN(sizeof(bConstraintOb), "bConstraintOb"); /* for system time, part of deglobalization, code nicer later with local time (ton) */ - cob->scene= scene; + cob->scene = scene; /* based on type of available data */ switch (datatype) { @@ -139,7 +139,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, copy_m4_m4(cob->startmat, cob->matrix); } - break; + break; case CONSTRAINT_OBTYPE_BONE: { /* only set if we have valid bone, otherwise default */ @@ -150,11 +150,11 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, if (cob->pchan->rotmode > 0) { /* should be some type of Euler order */ - cob->rotOrder= cob->pchan->rotmode; + cob->rotOrder = cob->pchan->rotmode; } else { /* Quats, so eulers should just use default order */ - cob->rotOrder= EULER_ORDER_DEFAULT; + cob->rotOrder = EULER_ORDER_DEFAULT; } /* matrix in world-space */ @@ -165,7 +165,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, copy_m4_m4(cob->startmat, cob->matrix); } - break; + break; default: /* other types not yet handled */ unit_m4(cob->matrix); @@ -202,7 +202,7 @@ void constraints_clear_evalob(bConstraintOb *cob) invert_m4_m4(cob->ob->constinv, delta); } } - break; + break; case CONSTRAINT_OBTYPE_BONE: { /* cob->ob or cob->pchan might not exist */ @@ -214,7 +214,7 @@ void constraints_clear_evalob(bConstraintOb *cob) invert_m4_m4(cob->pchan->constinv, delta); } } - break; + break; } /* free tempolary struct */ @@ -278,7 +278,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] float imat[4][4]; /* prevent crashes in these unlikely events */ - if (ob==NULL || mat==NULL) return; + if (ob == NULL || mat == NULL) return; /* optimize trick - check if need to do anything */ if (from == to) return; @@ -298,8 +298,8 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); } } - break; - case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */ + break; + case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */ { /* pose to world */ if (to == CONSTRAINT_SPACE_WORLD) { @@ -331,7 +331,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] } } } - break; + break; case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */ { /* local to pose - do inverse procedure that was done for pose to local */ @@ -351,7 +351,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); } } - break; + break; case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */ { /* local + parent to pose */ @@ -366,12 +366,12 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); } } - break; + break; } } else { /* objects */ - if (from==CONSTRAINT_SPACE_WORLD && to==CONSTRAINT_SPACE_LOCAL) { + if (from == CONSTRAINT_SPACE_WORLD && to == CONSTRAINT_SPACE_LOCAL) { /* check if object has a parent */ if (ob->parent) { /* 'subtract' parent's effects from owner */ @@ -391,7 +391,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] mult_m4_m4m4(mat, imat, mat); } } - else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) { + else if (from == CONSTRAINT_SPACE_LOCAL && to == CONSTRAINT_SPACE_WORLD) { /* check that object has a parent - otherwise this won't work */ if (ob->parent) { /* 'add' parent's effect back to owner */ @@ -415,15 +415,15 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* ------------ General Target Matrix Tools ---------- */ /* function that sets the given matrix based on given vertex group in mesh */ -static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4]) +static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[][4]) { DerivedMesh *dm = NULL; - Mesh *me= ob->data; + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; float vec[3] = {0.0f, 0.0f, 0.0f}; float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3]; float imat[3][3], tmat[3][3]; - const int defgroup= defgroup_name_index(ob, substring); + const int defgroup = defgroup_name_index(ob, substring); short freeDM = 0; /* initialize target matrix using target matrix */ @@ -436,7 +436,7 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat if (em) { /* target is in editmode, so get a special derived mesh */ dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); - freeDM= 1; + freeDM = 1; } else { /* when not in EditMode, use the 'final' derived mesh, depsgraph @@ -454,10 +454,10 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat /* check that dvert is a valid pointers (just in case) */ if (dvert) { - MDeformVert *dv= dvert; + MDeformVert *dv = dvert; /* get the average of all verts with that are in the vertex-group */ for (i = 0; i < numVerts; i++, dv++) { - MDeformWeight *dw= defvert_find_index(dv, defgroup); + MDeformWeight *dw = defvert_find_index(dv, defgroup); if (dw && dw->weight != 0.0f) { dm->getVertCo(dm, i, co); dm->getVertNo(dm, i, nor); @@ -512,20 +512,20 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat } /* function that sets the given matrix based on given vertex group in lattice */ -static void contarget_get_lattice_mat (Object *ob, const char *substring, float mat[][4]) +static void contarget_get_lattice_mat(Object *ob, const char *substring, float mat[][4]) { - Lattice *lt= (Lattice *)ob->data; + Lattice *lt = (Lattice *)ob->data; DispList *dl = find_displist(&ob->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; + float *co = dl ? dl->verts : NULL; BPoint *bp = lt->def; MDeformVert *dv = lt->dvert; - int tot_verts= lt->pntsu*lt->pntsv*lt->pntsw; - float vec[3]= {0.0f, 0.0f, 0.0f}, tvec[3]; - int grouped=0; + int tot_verts = lt->pntsu * lt->pntsv * lt->pntsw; + float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3]; + int grouped = 0; int i, n; - const int defgroup= defgroup_name_index(ob, substring); + const int defgroup = defgroup_name_index(ob, substring); /* initialize target matrix using target matrix */ copy_m4_m4(mat, ob->obmat); @@ -537,9 +537,9 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* 1. Loop through control-points checking if in nominated vertex-group. * 2. If it is, add it to vec to find the average point. */ - for (i=0; i < tot_verts; i++, dv++) { - for (n= 0; n < dv->totweight; n++) { - MDeformWeight *dw= defvert_find_index(dv, defgroup); + for (i = 0; i < tot_verts; i++, dv++) { + for (n = 0; n < dv->totweight; n++) { + MDeformWeight *dw = defvert_find_index(dv, defgroup); if (dw && dw->weight > 0.0f) { /* copy coordinates of point to temporary vector, then add to find average */ memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float)); @@ -551,7 +551,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* advance pointer to coordinate data */ if (co) co += 3; - else bp++; + else bp++; } /* find average location, then multiply by ob->obmat to find world-space location */ @@ -565,14 +565,14 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* generic function to get the appropriate matrix for most target cases */ /* The cases where the target can be object data have not been implemented */ -static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) +static void constraint_target_to_mat4(Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) { /* Case OBJECT */ if (!strlen(substring)) { copy_m4_m4(mat, ob->obmat); constraint_mat_convertspace(ob, NULL, mat, from, to); } - /* Case VERTEXGROUP */ + /* Case VERTEXGROUP */ /* Current method just takes the average location of all the points in the * VertexGroup, and uses that as the location value of the targets. Where * possible, the orientation will also be calculated, by calculating an @@ -631,14 +631,14 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float */ /* Template for type-info data: - * - make a copy of this when creating new constraints, and just change the functions - * pointed to as necessary - * - although the naming of functions doesn't matter, it would help for code - * readability, to follow the same naming convention as is presented here - * - any functions that a constraint doesn't need to define, don't define - * for such cases, just use NULL - * - these should be defined after all the functions have been defined, so that - * forward-definitions/prototypes don't need to be used! + * - make a copy of this when creating new constraints, and just change the functions + * pointed to as necessary + * - although the naming of functions doesn't matter, it would help for code + * readability, to follow the same naming convention as is presented here + * - any functions that a constraint doesn't need to define, don't define + * for such cases, just use NULL + * - these should be defined after all the functions have been defined, so that + * forward-definitions/prototypes don't need to be used! * - keep this copy #if-def'd so that future constraints can get based off this */ #if 0 @@ -661,7 +661,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { /* This function should be used for the get_target_matrix member of all * constraints that are not picky about what happens to their target matrix. */ -static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) +static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); @@ -677,26 +677,26 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC // TODO: cope with getting rotation order... #define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \ { \ - ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ + ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ \ - ct->tar= datatar; \ + ct->tar = datatar; \ BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \ - ct->space= con->tarspace; \ - ct->flag= CONSTRAINT_TAR_TEMP; \ + ct->space = con->tarspace; \ + ct->flag = CONSTRAINT_TAR_TEMP; \ \ if (ct->tar) { \ - if ((ct->tar->type==OB_ARMATURE) && (ct->subtarget[0])) { \ - bPoseChannel *pchan= BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); \ + if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) { \ + 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; \ - }\ + ct->rotOrder = (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \ + } \ else if (OB_TYPE_SUPPORT_VGROUP(ct->tar->type) && (ct->subtarget[0])) { \ ct->type = CONSTRAINT_OBTYPE_VERT; \ ct->rotOrder = EULER_ORDER_DEFAULT; \ } \ - else {\ + else { \ ct->type = CONSTRAINT_OBTYPE_OBJECT; \ - ct->rotOrder= ct->tar->rotmode; \ + ct->rotOrder = ct->tar->rotmode; \ } \ } \ \ @@ -711,11 +711,11 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC // TODO: cope with getting rotation order... #define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \ { \ - ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ + ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ \ - ct->tar= datatar; \ - ct->space= con->tarspace; \ - ct->flag= CONSTRAINT_TAR_TEMP; \ + ct->tar = datatar; \ + ct->space = con->tarspace; \ + ct->flag = CONSTRAINT_TAR_TEMP; \ \ if (ct->tar) ct->type = CONSTRAINT_OBTYPE_OBJECT; \ \ @@ -733,13 +733,13 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC if (ct) { \ bConstraintTarget *ctn = ct->next; \ if (nocopy == 0) { \ - datatar= ct->tar; \ + datatar = ct->tar; \ BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \ - con->tarspace= (char)ct->space; \ + con->tarspace = (char)ct->space; \ } \ \ BLI_freelinkN(list, ct); \ - ct= ctn; \ + ct = ctn; \ } \ } @@ -754,39 +754,39 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC if (ct) { \ bConstraintTarget *ctn = ct->next; \ if (nocopy == 0) { \ - datatar= ct->tar; \ - con->tarspace= (char)ct->space; \ + datatar = ct->tar; \ + con->tarspace = (char)ct->space; \ } \ \ BLI_freelinkN(list, ct); \ - ct= ctn; \ + ct = ctn; \ } \ } /* --------- ChildOf Constraint ------------ */ -static void childof_new_data (void *cdata) +static void childof_new_data(void *cdata) { - bChildOfConstraint *data= (bChildOfConstraint *)cdata; + bChildOfConstraint *data = (bChildOfConstraint *)cdata; data->flag = (CHILDOF_LOCX | CHILDOF_LOCY | CHILDOF_LOCZ | - CHILDOF_ROTX |CHILDOF_ROTY | CHILDOF_ROTZ | - CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ); + CHILDOF_ROTX | CHILDOF_ROTY | CHILDOF_ROTZ | + CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ); unit_m4(data->invmat); } -static void childof_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void childof_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bChildOfConstraint *data= con->data; + bChildOfConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int childof_get_tars (bConstraint *con, ListBase *list) +static int childof_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bChildOfConstraint *data= con->data; + bChildOfConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -798,21 +798,21 @@ static int childof_get_tars (bConstraint *con, ListBase *list) return 0; } -static void childof_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void childof_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bChildOfConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bChildOfConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bChildOfConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bChildOfConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -849,15 +849,15 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta mat4_to_size(sizo, invmat); /* disable channels not enabled */ - if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; - if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f; - if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f; - if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f; - if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f; - if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f; - if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f; - if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f; - if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; + if (!(data->flag & CHILDOF_LOCX)) loc[0] = loco[0] = 0.0f; + if (!(data->flag & CHILDOF_LOCY)) loc[1] = loco[1] = 0.0f; + if (!(data->flag & CHILDOF_LOCZ)) loc[2] = loco[2] = 0.0f; + if (!(data->flag & CHILDOF_ROTX)) eul[0] = eulo[0] = 0.0f; + if (!(data->flag & CHILDOF_ROTY)) eul[1] = eulo[1] = 0.0f; + if (!(data->flag & CHILDOF_ROTZ)) eul[2] = eulo[2] = 0.0f; + if (!(data->flag & CHILDOF_SIZEX)) size[0] = sizo[0] = 1.0f; + if (!(data->flag & CHILDOF_SIZEY)) size[1] = sizo[1] = 1.0f; + if (!(data->flag & CHILDOF_SIZEZ)) size[2] = sizo[2] = 1.0f; /* make new target mat and offset mat */ loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder); @@ -877,9 +877,9 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* without this, changes to scale and rotation can change location * of a parentless bone or a disconnected bone. Even though its set * to zero above. */ - if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0]; - if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1]; - if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2]; + if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0] = tempmat[3][0]; + if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1] = tempmat[3][1]; + if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2] = tempmat[3][2]; } } } @@ -902,26 +902,26 @@ static bConstraintTypeInfo CTI_CHILDOF = { /* -------- TrackTo Constraint ------- */ -static void trackto_new_data (void *cdata) +static void trackto_new_data(void *cdata) { - bTrackToConstraint *data= (bTrackToConstraint *)cdata; + bTrackToConstraint *data = (bTrackToConstraint *)cdata; data->reserved1 = TRACK_Y; data->reserved2 = UP_Z; } -static void trackto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void trackto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bTrackToConstraint *data= con->data; + bTrackToConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int trackto_get_tars (bConstraint *con, ListBase *list) +static int trackto_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bTrackToConstraint *data= con->data; + bTrackToConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -933,11 +933,11 @@ static int trackto_get_tars (bConstraint *con, ListBase *list) return 0; } -static void trackto_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void trackto_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bTrackToConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bTrackToConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) @@ -945,9 +945,9 @@ static void trackto_flush_tars (bConstraint *con, ListBase *list, short nocopy) } -static int basis_cross (int n, int m) +static int basis_cross(int n, int m) { - switch (n-m) { + switch (n - m) { case 1: case -2: return 1; @@ -961,7 +961,7 @@ static int basis_cross (int n, int m) } } -static void vectomat (float *vec, float *target_up, short axis, short upflag, short flags, float m[][3]) +static void vectomat(float *vec, float *target_up, short axis, short upflag, short flags, float m[][3]) { float n[3]; float u[3]; /* vector specifying the up axis */ @@ -1025,10 +1025,10 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh } -static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bTrackToConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bTrackToConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float size[3], vec[3]; @@ -1039,23 +1039,23 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta mat4_to_size(size, cob->matrix); /* Clear the object's rotation */ - cob->matrix[0][0]=size[0]; - cob->matrix[0][1]=0; - cob->matrix[0][2]=0; - cob->matrix[1][0]=0; - cob->matrix[1][1]=size[1]; - cob->matrix[1][2]=0; - cob->matrix[2][0]=0; - cob->matrix[2][1]=0; - cob->matrix[2][2]=size[2]; + cob->matrix[0][0] = size[0]; + cob->matrix[0][1] = 0; + cob->matrix[0][2] = 0; + cob->matrix[1][0] = 0; + cob->matrix[1][1] = size[1]; + cob->matrix[1][2] = 0; + cob->matrix[2][0] = 0; + cob->matrix[2][1] = 0; + cob->matrix[2][2] = size[2]; /* targetmat[2] instead of ownermat[2] is passed to vectomat * for backwards compatibility it seems... (Aligorith) */ sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vectomat(vec, ct->matrix[2], - (short)data->reserved1, (short)data->reserved2, - data->flags, totmat); + (short)data->reserved1, (short)data->reserved2, + data->flags, totmat); copy_m4_m4(tmat, cob->matrix); mul_m4_m3m4(cob->matrix, totmat, tmat); @@ -1079,32 +1079,32 @@ static bConstraintTypeInfo CTI_TRACKTO = { /* --------- Inverse-Kinemetics --------- */ -static void kinematic_new_data (void *cdata) +static void kinematic_new_data(void *cdata) { - bKinematicConstraint *data= (bKinematicConstraint *)cdata; + bKinematicConstraint *data = (bKinematicConstraint *)cdata; - data->weight= 1.0f; - data->orientweight= 1.0f; + data->weight = 1.0f; + data->orientweight = 1.0f; data->iterations = 500; - data->dist= 1.0f; - data->flag= CONSTRAINT_IK_TIP|CONSTRAINT_IK_STRETCH|CONSTRAINT_IK_POS; + data->dist = 1.0f; + data->flag = CONSTRAINT_IK_TIP | CONSTRAINT_IK_STRETCH | CONSTRAINT_IK_POS; } -static void kinematic_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void kinematic_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bKinematicConstraint *data= con->data; + bKinematicConstraint *data = con->data; /* chain target */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); /* poletarget */ - func(con, (ID**)&data->poletar, FALSE, userdata); + func(con, (ID **)&data->poletar, FALSE, userdata); } -static int kinematic_get_tars (bConstraint *con, ListBase *list) +static int kinematic_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bKinematicConstraint *data= con->data; + bKinematicConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints is used twice here */ @@ -1117,11 +1117,11 @@ static int kinematic_get_tars (bConstraint *con, ListBase *list) return 0; } -static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void kinematic_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bKinematicConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bKinematicConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) @@ -1129,15 +1129,15 @@ static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy } } -static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { - bKinematicConstraint *data= con->data; + bKinematicConstraint *data = con->data; if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) { if (data->flag & CONSTRAINT_IK_AUTO) { - Object *ob= cob->ob; + Object *ob = cob->ob; if (ob == NULL) { unit_m4(ct->matrix); @@ -1172,9 +1172,9 @@ static bConstraintTypeInfo CTI_KINEMATIC = { /* -------- Follow-Path Constraint ---------- */ -static void followpath_new_data (void *cdata) +static void followpath_new_data(void *cdata) { - bFollowPathConstraint *data= (bFollowPathConstraint *)cdata; + bFollowPathConstraint *data = (bFollowPathConstraint *)cdata; data->trackflag = TRACK_Y; data->upflag = UP_Z; @@ -1182,18 +1182,18 @@ static void followpath_new_data (void *cdata) data->followflag = 0; } -static void followpath_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void followpath_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int followpath_get_tars (bConstraint *con, ListBase *list) +static int followpath_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -1205,25 +1205,25 @@ static int followpath_get_tars (bConstraint *con, ListBase *list) return 0; } -static void followpath_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void followpath_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bFollowPathConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bFollowPathConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) } } -static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; if (VALID_CONS_TARGET(ct)) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; float vec[4], dir[3], radius; - float totmat[4][4]= MAT4_UNITY; + float totmat[4][4] = MAT4_UNITY; float curvetime; unit_m4(ct->matrix); @@ -1233,7 +1233,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr */ /* only happens on reload file, but violates depsgraph still... fix! */ - if (cu->path==NULL || cu->path->data==NULL) + if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(cob->scene, ct->tar, 0); if (cu->path && cu->path->data) { @@ -1241,7 +1241,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr if ((data->followflag & FOLLOWPATH_STATIC) == 0) { /* animated position along curve depending on time */ Nurb *nu = cu->nurb.first; - curvetime= cu->ctime - data->offset; + curvetime = cu->ctime - data->offset; /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, * but this will only work if it actually is animated... @@ -1265,21 +1265,21 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } else { /* fixed position along curve */ - curvetime= data->offset_fac; + curvetime = data->offset_fac; } - if ( where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/ + if (where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/ if (data->followflag & FOLLOWPATH_FOLLOW) { #if 0 float x1, q[4]; vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag); normalize_v3(dir); - q[0]= (float)cos(0.5*vec[3]); - x1= (float)sin(0.5*vec[3]); - q[1]= -x1*dir[0]; - q[2]= -x1*dir[1]; - q[3]= -x1*dir[2]; + q[0] = (float)cos(0.5 * vec[3]); + x1 = (float)sin(0.5 * vec[3]); + q[1] = -x1 * dir[0]; + q[2] = -x1 * dir[1]; + q[3] = -x1 * dir[2]; mul_qt_qtqt(quat, q, quat); #else quat_apply_track(quat, data->trackflag, data->upflag); @@ -1305,15 +1305,15 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr unit_m4(ct->matrix); } -static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { float obmat[4][4]; float size[3]; - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; /* get Object transform (loc/rot/size) to determine transformation from path */ // TODO: this used to be local at one point, but is probably more useful as-is @@ -1326,7 +1326,7 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase mul_serie_m4(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL); /* un-apply scaling caused by path */ - if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ + if ((data->followflag & FOLLOWPATH_RADIUS) == 0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ float obsize[3]; mat4_to_size(obsize, cob->matrix); @@ -1358,7 +1358,7 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = { /* --------- Limit Location --------- */ -static void loclimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void loclimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bLocLimitConstraint *data = con->data; @@ -1405,7 +1405,7 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { /* -------- Limit Rotation --------- */ -static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bRotLimitConstraint *data = con->data; float loc[3]; @@ -1463,7 +1463,7 @@ static bConstraintTypeInfo CTI_ROTLIMIT = { /* --------- Limit Scaling --------- */ -static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bSizeLimitConstraint *data = con->data; float obsize[3], size[3]; @@ -1497,11 +1497,11 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } if (obsize[0]) - mul_v3_fl(cob->matrix[0], size[0]/obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); if (obsize[1]) - mul_v3_fl(cob->matrix[1], size[1]/obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); if (obsize[2]) - mul_v3_fl(cob->matrix[2], size[2]/obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } static bConstraintTypeInfo CTI_SIZELIMIT = { @@ -1521,25 +1521,25 @@ static bConstraintTypeInfo CTI_SIZELIMIT = { /* ----------- Copy Location ------------- */ -static void loclike_new_data (void *cdata) +static void loclike_new_data(void *cdata) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)cdata; + bLocateLikeConstraint *data = (bLocateLikeConstraint *)cdata; - data->flag = LOCLIKE_X|LOCLIKE_Y|LOCLIKE_Z; + data->flag = LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z; } -static void loclike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void loclike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bLocateLikeConstraint *data= con->data; + bLocateLikeConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int loclike_get_tars (bConstraint *con, ListBase *list) +static int loclike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bLocateLikeConstraint *data= con->data; + bLocateLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1551,21 +1551,21 @@ static int loclike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void loclike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void loclike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bLocateLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bLocateLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void loclike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void loclike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bLocateLikeConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bLocateLikeConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float offset[3] = {0.0f, 0.0f, 0.0f}; @@ -1611,25 +1611,25 @@ static bConstraintTypeInfo CTI_LOCLIKE = { /* ----------- Copy Rotation ------------- */ -static void rotlike_new_data (void *cdata) +static void rotlike_new_data(void *cdata) { - bRotateLikeConstraint *data= (bRotateLikeConstraint *)cdata; + bRotateLikeConstraint *data = (bRotateLikeConstraint *)cdata; - data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; + data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z; } -static void rotlike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void rotlike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bChildOfConstraint *data= con->data; + bChildOfConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int rotlike_get_tars (bConstraint *con, ListBase *list) +static int rotlike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bRotateLikeConstraint *data= con->data; + bRotateLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1641,26 +1641,26 @@ static int rotlike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void rotlike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void rotlike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bRotateLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bRotateLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bRotateLikeConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bRotateLikeConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { - float loc[3]; - float eul[3], obeul[3]; - float size[3]; + float loc[3]; + float eul[3], obeul[3]; + float size[3]; copy_v3_v3(loc, cob->matrix[3]); mat4_to_size(size, cob->matrix); @@ -1670,7 +1670,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */ mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix); - if ((data->flag & ROTLIKE_X)==0) + if ((data->flag & ROTLIKE_X) == 0) eul[0] = obeul[0]; else { if (data->flag & ROTLIKE_OFFSET) @@ -1680,7 +1680,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[0] *= -1; } - if ((data->flag & ROTLIKE_Y)==0) + if ((data->flag & ROTLIKE_Y) == 0) eul[1] = obeul[1]; else { if (data->flag & ROTLIKE_OFFSET) @@ -1690,7 +1690,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[1] *= -1; } - if ((data->flag & ROTLIKE_Z)==0) + if ((data->flag & ROTLIKE_Z) == 0) eul[2] = obeul[2]; else { if (data->flag & ROTLIKE_OFFSET) @@ -1723,25 +1723,25 @@ static bConstraintTypeInfo CTI_ROTLIKE = { /* ---------- Copy Scaling ---------- */ -static void sizelike_new_data (void *cdata) +static void sizelike_new_data(void *cdata) { - bSizeLikeConstraint *data= (bSizeLikeConstraint *)cdata; + bSizeLikeConstraint *data = (bSizeLikeConstraint *)cdata; - data->flag = SIZELIKE_X|SIZELIKE_Y|SIZELIKE_Z; + data->flag = SIZELIKE_X | SIZELIKE_Y | SIZELIKE_Z; } -static void sizelike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void sizelike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bSizeLikeConstraint *data= con->data; + bSizeLikeConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int sizelike_get_tars (bConstraint *con, ListBase *list) +static int sizelike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bSizeLikeConstraint *data= con->data; + bSizeLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1753,21 +1753,21 @@ static int sizelike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void sizelike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void sizelike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bSizeLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bSizeLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void sizelike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void sizelike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bSizeLikeConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bSizeLikeConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float obsize[3], size[3]; @@ -1819,18 +1819,18 @@ static bConstraintTypeInfo CTI_SIZELIKE = { /* ----------- Copy Transforms ------------- */ -static void translike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void translike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bTransLikeConstraint *data= con->data; + bTransLikeConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int translike_get_tars (bConstraint *con, ListBase *list) +static int translike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bTransLikeConstraint *data= con->data; + bTransLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1842,20 +1842,20 @@ static int translike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void translike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void translike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bTransLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bTransLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void translike_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) +static void translike_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { /* just copy the entire transform matrix of the target */ @@ -1880,17 +1880,17 @@ static bConstraintTypeInfo CTI_TRANSLIKE = { /* ---------- Maintain Volume ---------- */ -static void samevolume_new_data (void *cdata) +static void samevolume_new_data(void *cdata) { - bSameVolumeConstraint *data= (bSameVolumeConstraint *)cdata; + bSameVolumeConstraint *data = (bSameVolumeConstraint *)cdata; data->flag = SAMEVOL_Y; data->volume = 1.0f; } -static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { - bSameVolumeConstraint *data= con->data; + bSameVolumeConstraint *data = con->data; float volume = data->volume; float fac = 1.0f; @@ -1936,9 +1936,9 @@ static bConstraintTypeInfo CTI_SAMEVOL = { /* ----------- Python Constraint -------------- */ -static void pycon_free (bConstraint *con) +static void pycon_free(bConstraint *con) { - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; /* id-properties */ IDP_FreeProperty(data->prop); @@ -1948,7 +1948,7 @@ static void pycon_free (bConstraint *con) BLI_freelistN(&data->targets); } -static void pycon_copy (bConstraint *con, bConstraint *srccon) +static void pycon_copy(bConstraint *con, bConstraint *srccon) { bPythonConstraint *pycon = (bPythonConstraint *)con->data; bPythonConstraint *opycon = (bPythonConstraint *)srccon->data; @@ -1957,19 +1957,19 @@ static void pycon_copy (bConstraint *con, bConstraint *srccon) BLI_duplicatelist(&pycon->targets, &opycon->targets); } -static void pycon_new_data (void *cdata) +static void pycon_new_data(void *cdata) { - bPythonConstraint *data= (bPythonConstraint *)cdata; + bPythonConstraint *data = (bPythonConstraint *)cdata; /* everything should be set correctly by calloc, except for the prop->type constant.*/ data->prop = MEM_callocN(sizeof(IDProperty), "PyConstraintProps"); data->prop->type = IDP_GROUP; } -static int pycon_get_tars (bConstraint *con, ListBase *list) +static int pycon_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; list->first = data->targets.first; list->last = data->targets.last; @@ -1980,33 +1980,33 @@ static int pycon_get_tars (bConstraint *con, ListBase *list) return 0; } -static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; bConstraintTarget *ct; /* targets */ - for (ct= data->targets.first; ct; ct= ct->next) - func(con, (ID**)&ct->tar, FALSE, userdata); + for (ct = data->targets.first; ct; ct = ct->next) + func(con, (ID **)&ct->tar, FALSE, userdata); /* script */ - func(con, (ID**)&data->text, TRUE, userdata); + func(con, (ID **)&data->text, TRUE, userdata); } /* Whether this approach is maintained remains to be seen (aligorith) */ -static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { #ifdef WITH_PYTHON - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; #endif if (VALID_CONS_TARGET(ct)) { /* special exception for curves - depsgraph issues */ if (ct->tar->type == OB_CURVE) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* this check is to make sure curve objects get updated on file load correctly.*/ - if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */ + if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ makeDispListCurveTypes(cob->scene, ct->tar, 0); } @@ -2025,16 +2025,16 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT unit_m4(ct->matrix); } -static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { #ifndef WITH_PYTHON (void)con; (void)cob; (void)targets; /* unused */ return; #else - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; /* only evaluate in python if we're allowed to do so */ - if ((G.f & G_SCRIPT_AUTOEXEC)==0) return; + if ((G.f & G_SCRIPT_AUTOEXEC) == 0) return; /* currently removed, until I this can be re-implemented for multiple targets */ #if 0 @@ -2067,29 +2067,29 @@ static bConstraintTypeInfo CTI_PYTHON = { /* -------- Action Constraint ----------- */ -static void actcon_new_data (void *cdata) +static void actcon_new_data(void *cdata) { - bActionConstraint *data= (bActionConstraint *)cdata; + bActionConstraint *data = (bActionConstraint *)cdata; /* set type to 20 (Loc X), as 0 is Rot X for backwards compatibility */ data->type = 20; } -static void actcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void actcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bActionConstraint *data= con->data; + bActionConstraint *data = con->data; /* target */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); /* action */ - func(con, (ID**)&data->act, TRUE, userdata); + func(con, (ID **)&data->act, TRUE, userdata); } -static int actcon_get_tars (bConstraint *con, ListBase *list) +static int actcon_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bActionConstraint *data= con->data; + bActionConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2101,18 +2101,18 @@ static int actcon_get_tars (bConstraint *con, ListBase *list) return 0; } -static void actcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void actcon_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bActionConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bActionConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bActionConstraint *data = con->data; @@ -2130,33 +2130,33 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* determine where in transform range target is */ /* data->type is mapped as follows for backwards compatibility: * 00,01,02 - rotation (it used to be like this) - * 10,11,12 - scaling + * 10,11,12 - scaling * 20,21,22 - location */ if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ mat4_to_eul(vec, tempmat); mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */ - axis= data->type; + axis = data->type; } else if (data->type < 20) { /* extract scaling (is in whatever space target should be in) */ mat4_to_size(vec, tempmat); - axis= data->type - 10; + axis = data->type - 10; } else { /* extract location */ copy_v3_v3(vec, tempmat[3]); - axis= data->type - 20; + axis = data->type - 20; } /* Target defines the animation */ - s = (vec[axis]-data->min) / (data->max-data->min); + s = (vec[axis] - data->min) / (data->max - data->min); CLAMP(s, 0, 1); - t = (s * (data->end-data->start)) + data->start; + t = (s * (data->end - data->start)) + data->start; if (G.debug & G_DEBUG) - printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name+2, (cob->pchan)?cob->pchan->name:NULL); + printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name + 2, (cob->pchan) ? cob->pchan->name : NULL); /* Get the appropriate information from the action */ if (cob->type == CONSTRAINT_OBTYPE_BONE) { @@ -2172,8 +2172,8 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint */ pchan = cob->pchan; - tchan= BKE_pose_channel_verify(pose, pchan->name); - tchan->rotmode= pchan->rotmode; + 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); @@ -2200,9 +2200,9 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint } } -static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) +static void actcon_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float temp[4][4]; @@ -2232,26 +2232,26 @@ static bConstraintTypeInfo CTI_ACTION = { /* --------- Locked Track ---------- */ -static void locktrack_new_data (void *cdata) +static void locktrack_new_data(void *cdata) { - bLockTrackConstraint *data= (bLockTrackConstraint *)cdata; + bLockTrackConstraint *data = (bLockTrackConstraint *)cdata; data->trackflag = TRACK_Y; data->lockflag = LOCK_Z; } -static void locktrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void locktrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bLockTrackConstraint *data= con->data; + bLockTrackConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int locktrack_get_tars (bConstraint *con, ListBase *list) +static int locktrack_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bLockTrackConstraint *data= con->data; + bLockTrackConstraint *data = con->data; bConstraintTarget *ct; /* the following macro is used for all standard single-target constraints */ @@ -2263,21 +2263,21 @@ static int locktrack_get_tars (bConstraint *con, ListBase *list) return 0; } -static void locktrack_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void locktrack_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bLockTrackConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bLockTrackConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bLockTrackConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bLockTrackConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float vec[3], vec2[3]; @@ -2290,217 +2290,217 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* Vector object -> target */ sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]); switch (data->lockflag) { - case LOCK_X: /* LOCK X */ - { - switch (data->trackflag) { - case TRACK_Y: /* LOCK X TRACK Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); + case LOCK_X: /* LOCK X */ + { + switch (data->trackflag) { + case TRACK_Y: /* LOCK X TRACK Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_Z: /* LOCK X TRACK Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); + case TRACK_Z: /* LOCK X TRACK Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - case TRACK_nY: /* LOCK X TRACK -Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); - negate_v3(totmat[1]); + case TRACK_nY: /* LOCK X TRACK -Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_nZ: /* LOCK X TRACK -Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); - negate_v3(totmat[2]); + case TRACK_nZ: /* LOCK X TRACK -Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; + } } - } break; - case LOCK_Y: /* LOCK Y */ - { - switch (data->trackflag) { - case TRACK_X: /* LOCK Y TRACK X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); + case LOCK_Y: /* LOCK Y */ + { + switch (data->trackflag) { + case TRACK_X: /* LOCK Y TRACK X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_Z: /* LOCK Y TRACK Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); + case TRACK_Z: /* LOCK Y TRACK Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - case TRACK_nX: /* LOCK Y TRACK -X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); - negate_v3(totmat[0]); + case TRACK_nX: /* LOCK Y TRACK -X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_nZ: /* LOCK Y TRACK -Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); - negate_v3(totmat[2]); + case TRACK_nZ: /* LOCK Y TRACK -Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; + } } - } break; - case LOCK_Z: /* LOCK Z */ - { - switch (data->trackflag) { - case TRACK_X: /* LOCK Z TRACK X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); + case LOCK_Z: /* LOCK Z */ + { + switch (data->trackflag) { + case TRACK_X: /* LOCK Z TRACK X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - case TRACK_Y: /* LOCK Z TRACK Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); + case TRACK_Y: /* LOCK Z TRACK Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - case TRACK_nX: /* LOCK Z TRACK -X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); - negate_v3(totmat[0]); + case TRACK_nX: /* LOCK Z TRACK -X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - case TRACK_nY: /* LOCK Z TRACK -Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); - negate_v3(totmat[1]); + case TRACK_nY: /* LOCK Z TRACK -Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; + } } - } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; } /* Block to keep matrix heading */ @@ -2508,16 +2508,16 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_m3(tmpmat); invert_m3_m3(invmat, tmpmat); mul_m3_m3m3(tmpmat, totmat, invmat); - totmat[0][0] = tmpmat[0][0];totmat[0][1] = tmpmat[0][1];totmat[0][2] = tmpmat[0][2]; - totmat[1][0] = tmpmat[1][0];totmat[1][1] = tmpmat[1][1];totmat[1][2] = tmpmat[1][2]; - totmat[2][0] = tmpmat[2][0];totmat[2][1] = tmpmat[2][1];totmat[2][2] = tmpmat[2][2]; + totmat[0][0] = tmpmat[0][0]; totmat[0][1] = tmpmat[0][1]; totmat[0][2] = tmpmat[0][2]; + totmat[1][0] = tmpmat[1][0]; totmat[1][1] = tmpmat[1][1]; totmat[1][2] = tmpmat[1][2]; + totmat[2][0] = tmpmat[2][0]; totmat[2][1] = tmpmat[2][1]; totmat[2][2] = tmpmat[2][2]; copy_m4_m4(tmat, cob->matrix); mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2], totmat[1][0], totmat[1][1], totmat[1][2], totmat[2][0], totmat[2][1], totmat[2][2]); - if (mdet==0) { + if (mdet == 0) { unit_m3(totmat); } @@ -2543,25 +2543,25 @@ static bConstraintTypeInfo CTI_LOCKTRACK = { /* ---------- Limit Distance Constraint ----------- */ -static void distlimit_new_data (void *cdata) +static void distlimit_new_data(void *cdata) { - bDistLimitConstraint *data= (bDistLimitConstraint *)cdata; + bDistLimitConstraint *data = (bDistLimitConstraint *)cdata; - data->dist= 0.0f; + data->dist = 0.0f; } -static void distlimit_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void distlimit_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bDistLimitConstraint *data= con->data; + bDistLimitConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int distlimit_get_tars (bConstraint *con, ListBase *list) +static int distlimit_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bDistLimitConstraint *data= con->data; + bDistLimitConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2573,40 +2573,40 @@ static int distlimit_get_tars (bConstraint *con, ListBase *list) return 0; } -static void distlimit_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void distlimit_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bDistLimitConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bDistLimitConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bDistLimitConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bDistLimitConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { - float dvec[3], dist=0.0f, sfac=1.0f; - short clamp_surf= 0; + float dvec[3], dist = 0.0f, sfac = 1.0f; + short clamp_surf = 0; /* calculate our current distance from the target */ - dist= len_v3v3(cob->matrix[3], ct->matrix[3]); + dist = len_v3v3(cob->matrix[3], ct->matrix[3]); /* set distance (flag is only set when user demands it) */ if (data->dist == 0) - data->dist= dist; + data->dist = dist; /* check if we're which way to clamp from, and calculate interpolation factor (if needed) */ if (data->mode == LIMITDIST_OUTSIDE) { /* if inside, then move to surface */ if (dist <= data->dist) { - clamp_surf= 1; - if (dist != 0.0f) sfac= data->dist / dist; + clamp_surf = 1; + if (dist != 0.0f) sfac = data->dist / dist; } /* if soft-distance is enabled, start fading once owner is dist+softdist from the target */ else if (data->flag & LIMITDIST_USESOFT) { @@ -2618,24 +2618,24 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * else if (data->mode == LIMITDIST_INSIDE) { /* if outside, then move to surface */ if (dist >= data->dist) { - clamp_surf= 1; - if (dist != 0.0f) sfac= data->dist / dist; + clamp_surf = 1; + if (dist != 0.0f) sfac = data->dist / dist; } /* if soft-distance is enabled, start fading once owner is dist-soft from the target */ else if (data->flag & LIMITDIST_USESOFT) { // FIXME: there's a problem with "jumping" when this kicks in if (dist >= (data->dist - data->soft)) { - sfac = (float)( data->soft*(1.0f - expf(-(dist - data->dist)/data->soft)) + data->dist ); + sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist); if (dist != 0.0f) sfac /= dist; - clamp_surf= 1; + clamp_surf = 1; } } } else { - if (IS_EQF(dist, data->dist)==0) { - clamp_surf= 1; - if (dist != 0.0f) sfac= data->dist / dist; + if (IS_EQF(dist, data->dist) == 0) { + clamp_surf = 1; + if (dist != 0.0f) sfac = data->dist / dist; } } @@ -2667,9 +2667,9 @@ static bConstraintTypeInfo CTI_DISTLIMIT = { /* ---------- Stretch To ------------ */ -static void stretchto_new_data (void *cdata) +static void stretchto_new_data(void *cdata) { - bStretchToConstraint *data= (bStretchToConstraint *)cdata; + bStretchToConstraint *data = (bStretchToConstraint *)cdata; data->volmode = 0; data->plane = 0; @@ -2677,18 +2677,18 @@ static void stretchto_new_data (void *cdata) data->bulge = 1.0; } -static void stretchto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void stretchto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bStretchToConstraint *data= con->data; + bStretchToConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int stretchto_get_tars (bConstraint *con, ListBase *list) +static int stretchto_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bStretchToConstraint *data= con->data; + bStretchToConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2700,21 +2700,21 @@ static int stretchto_get_tars (bConstraint *con, ListBase *list) return 0; } -static void stretchto_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void stretchto_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bStretchToConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bStretchToConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bStretchToConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bStretchToConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -2750,40 +2750,40 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * if (data->bulge == 0) data->bulge = 1.0; - scale[1] = dist/data->orglength; + scale[1] = dist / data->orglength; switch (data->volmode) { - /* volume preserving scaling */ - case VOLUME_XZ : - scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge*(data->orglength/dist)); - scale[2] = scale[0]; - break; - case VOLUME_X: - scale[0] = 1.0f + data->bulge * (data->orglength /dist - 1); - scale[2] = 1.0; - break; - case VOLUME_Z: - scale[0] = 1.0; - scale[2] = 1.0f + data->bulge * (data->orglength /dist - 1); - break; + /* volume preserving scaling */ + case VOLUME_XZ: + scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge * (data->orglength / dist)); + scale[2] = scale[0]; + break; + case VOLUME_X: + scale[0] = 1.0f + data->bulge * (data->orglength / dist - 1); + scale[2] = 1.0; + break; + case VOLUME_Z: + scale[0] = 1.0; + scale[2] = 1.0f + data->bulge * (data->orglength / dist - 1); + break; /* don't care for volume */ - case NO_VOLUME: - scale[0] = 1.0; - scale[2] = 1.0; - break; - default: /* should not happen, but in case*/ - return; + case NO_VOLUME: + scale[0] = 1.0; + scale[2] = 1.0; + break; + default: /* should not happen, but in case*/ + return; } /* switch (data->volmode) */ /* Clear the object's rotation and scale */ - cob->matrix[0][0]=size[0]*scale[0]; - cob->matrix[0][1]=0; - cob->matrix[0][2]=0; - cob->matrix[1][0]=0; - cob->matrix[1][1]=size[1]*scale[1]; - cob->matrix[1][2]=0; - cob->matrix[2][0]=0; - cob->matrix[2][1]=0; - cob->matrix[2][2]=size[2]*scale[2]; + cob->matrix[0][0] = size[0] * scale[0]; + cob->matrix[0][1] = 0; + cob->matrix[0][2] = 0; + cob->matrix[1][0] = 0; + cob->matrix[1][1] = size[1] * scale[1]; + cob->matrix[1][2] = 0; + cob->matrix[2][0] = 0; + cob->matrix[2][1] = 0; + cob->matrix[2][2] = size[2] * scale[2]; sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); normalize_v3(vec); @@ -2791,32 +2791,32 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* new Y aligns object target connection*/ negate_v3_v3(totmat[1], vec); switch (data->plane) { - case PLANE_X: - /* build new Z vector */ - /* othogonal to "new Y" "old X! plane */ - cross_v3_v3v3(orth, vec, xx); - normalize_v3(orth); - - /* new Z*/ - copy_v3_v3(totmat[2], orth); - - /* we decided to keep X plane*/ - cross_v3_v3v3(xx, orth, vec); - normalize_v3_v3(totmat[0], xx); - break; - case PLANE_Z: - /* build new X vector */ - /* othogonal to "new Y" "old Z! plane */ - cross_v3_v3v3(orth, vec, zz); - normalize_v3(orth); - - /* new X */ - negate_v3_v3(totmat[0], orth); - - /* we decided to keep Z */ - cross_v3_v3v3(zz, orth, vec); - normalize_v3_v3(totmat[2], zz); - break; + case PLANE_X: + /* build new Z vector */ + /* othogonal to "new Y" "old X! plane */ + cross_v3_v3v3(orth, vec, xx); + normalize_v3(orth); + + /* new Z*/ + copy_v3_v3(totmat[2], orth); + + /* we decided to keep X plane*/ + cross_v3_v3v3(xx, orth, vec); + normalize_v3_v3(totmat[0], xx); + break; + case PLANE_Z: + /* build new X vector */ + /* othogonal to "new Y" "old Z! plane */ + cross_v3_v3v3(orth, vec, zz); + normalize_v3(orth); + + /* new X */ + negate_v3_v3(totmat[0], orth); + + /* we decided to keep Z */ + cross_v3_v3v3(zz, orth, vec); + normalize_v3_v3(totmat[2], zz); + break; } /* switch (data->plane) */ copy_m4_m4(tmat, cob->matrix); @@ -2841,9 +2841,9 @@ static bConstraintTypeInfo CTI_STRETCHTO = { /* ---------- Floor ------------ */ -static void minmax_new_data (void *cdata) +static void minmax_new_data(void *cdata) { - bMinMaxConstraint *data= (bMinMaxConstraint *)cdata; + bMinMaxConstraint *data = (bMinMaxConstraint *)cdata; data->minmaxflag = TRACK_Z; data->offset = 0.0f; @@ -2851,18 +2851,18 @@ static void minmax_new_data (void *cdata) data->flag = 0; } -static void minmax_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void minmax_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bMinMaxConstraint *data= con->data; + bMinMaxConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int minmax_get_tars (bConstraint *con, ListBase *list) +static int minmax_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bMinMaxConstraint *data= con->data; + bMinMaxConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2874,21 +2874,21 @@ static int minmax_get_tars (bConstraint *con, ListBase *list) return 0; } -static void minmax_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void minmax_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bMinMaxConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bMinMaxConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bMinMaxConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bMinMaxConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -2908,38 +2908,38 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar } switch (data->minmaxflag) { - case TRACK_Z: - val1 = tarmat[3][2]; - val2 = obmat[3][2]-data->offset; - index = 2; - break; - case TRACK_Y: - val1 = tarmat[3][1]; - val2 = obmat[3][1]-data->offset; - index = 1; - break; - case TRACK_X: - val1 = tarmat[3][0]; - val2 = obmat[3][0]-data->offset; - index = 0; - break; - case TRACK_nZ: - val2 = tarmat[3][2]; - val1 = obmat[3][2]-data->offset; - index = 2; - break; - case TRACK_nY: - val2 = tarmat[3][1]; - val1 = obmat[3][1]-data->offset; - index = 1; - break; - case TRACK_nX: - val2 = tarmat[3][0]; - val1 = obmat[3][0]-data->offset; - index = 0; - break; - default: - return; + case TRACK_Z: + val1 = tarmat[3][2]; + val2 = obmat[3][2] - data->offset; + index = 2; + break; + case TRACK_Y: + val1 = tarmat[3][1]; + val2 = obmat[3][1] - data->offset; + index = 1; + break; + case TRACK_X: + val1 = tarmat[3][0]; + val2 = obmat[3][0] - data->offset; + index = 0; + break; + case TRACK_nZ: + val2 = tarmat[3][2]; + val1 = obmat[3][2] - data->offset; + index = 2; + break; + case TRACK_nY: + val2 = tarmat[3][1]; + val1 = obmat[3][1] - data->offset; + index = 1; + break; + case TRACK_nX: + val2 = tarmat[3][0]; + val1 = obmat[3][0] - data->offset; + index = 0; + break; + default: + return; } if (val1 > val2) { @@ -2985,27 +2985,27 @@ static bConstraintTypeInfo CTI_MINMAX = { /* ------- RigidBody Joint ---------- */ -static void rbj_new_data (void *cdata) +static void rbj_new_data(void *cdata) { - bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint *)cdata; + bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata; // removed code which set target of this constraint - data->type=1; + data->type = 1; } -static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void rbj_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bRigidBodyJointConstraint *data= con->data; + bRigidBodyJointConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); - func(con, (ID**)&data->child, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); + func(con, (ID **)&data->child, FALSE, userdata); } -static int rbj_get_tars (bConstraint *con, ListBase *list) +static int rbj_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bRigidBodyJointConstraint *data= con->data; + bRigidBodyJointConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -3017,11 +3017,11 @@ static int rbj_get_tars (bConstraint *con, ListBase *list) return 0; } -static void rbj_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void rbj_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bRigidBodyJointConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bRigidBodyJointConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) @@ -3045,18 +3045,18 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = { /* -------- Clamp To ---------- */ -static void clampto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void clampto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bClampToConstraint *data= con->data; + bClampToConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int clampto_get_tars (bConstraint *con, ListBase *list) +static int clampto_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bClampToConstraint *data= con->data; + bClampToConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -3068,28 +3068,28 @@ static int clampto_get_tars (bConstraint *con, ListBase *list) return 0; } -static void clampto_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bClampToConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bClampToConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) } } -static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) */ /* only happens on reload file, but violates depsgraph still... fix! */ - if (cu->path==NULL || cu->path->data==NULL) + if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(cob->scene, ct->tar, 0); } @@ -3100,17 +3100,17 @@ static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bC unit_m4(ct->matrix); } -static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bClampToConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bClampToConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target and it is a curve */ if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) { - Curve *cu= data->tar->data; + Curve *cu = data->tar->data; float obmat[4][4], ownLoc[3]; float curveMin[3], curveMax[3]; - float targetMatrix[4][4]= MAT4_UNITY; + float targetMatrix[4][4] = MAT4_UNITY; copy_m4_m4(obmat, cob->matrix); copy_v3_v3(ownLoc, obmat[3]); @@ -3134,20 +3134,20 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta * extent. Otherwise, default to the x-axis, as that is quite * frequently used. */ - if ((size[2]>size[0]) && (size[2]>size[1])) - clamp_axis= CLAMPTO_Z - 1; - else if ((size[1]>size[0]) && (size[1]>size[2])) - clamp_axis= CLAMPTO_Y - 1; + if ((size[2] > size[0]) && (size[2] > size[1])) + clamp_axis = CLAMPTO_Z - 1; + else if ((size[1] > size[0]) && (size[1] > size[2])) + clamp_axis = CLAMPTO_Y - 1; else clamp_axis = CLAMPTO_X - 1; } else - clamp_axis= data->flag - 1; + clamp_axis = data->flag - 1; /* 2. determine position relative to curve on a 0-1 scale based on bounding box */ if (data->flag2 & CLAMPTO_CYCLIC) { /* cyclic, so offset within relative bounding box is used */ - float len= (curveMax[clamp_axis] - curveMin[clamp_axis]); + float len = (curveMax[clamp_axis] - curveMin[clamp_axis]); float offset; /* check to make sure len is not so close to zero that it'll cause errors */ @@ -3162,7 +3162,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta } else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) { /* bounding-box range is after */ - offset= curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len; + offset = curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len; /* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */ curvetime = (ownLoc[clamp_axis] - offset) / (len); @@ -3174,7 +3174,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta } else { /* as length is close to zero, curvetime by default should be 0 (i.e. the start) */ - curvetime= 0.0f; + curvetime = 0.0f; } } else { @@ -3183,7 +3183,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta curvetime = 0.0f; else if (ownLoc[clamp_axis] >= curveMax[clamp_axis]) curvetime = 1.0f; - else if ( IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0 ) + else if (IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0) curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (curveMax[clamp_axis] - curveMin[clamp_axis]); else curvetime = 0.0f; @@ -3220,27 +3220,27 @@ static bConstraintTypeInfo CTI_CLAMPTO = { /* ---------- Transform Constraint ----------- */ -static void transform_new_data (void *cdata) +static void transform_new_data(void *cdata) { - bTransformConstraint *data= (bTransformConstraint *)cdata; + bTransformConstraint *data = (bTransformConstraint *)cdata; - data->map[0]= 0; - data->map[1]= 1; - data->map[2]= 2; + data->map[0] = 0; + data->map[1] = 1; + data->map[2] = 2; } -static void transform_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void transform_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bTransformConstraint *data= con->data; + bTransformConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int transform_get_tars (bConstraint *con, ListBase *list) +static int transform_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bTransformConstraint *data= con->data; + bTransformConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -3252,21 +3252,21 @@ static int transform_get_tars (bConstraint *con, ListBase *list) return 0; } -static void transform_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void transform_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bTransformConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bTransformConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bTransformConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bTransformConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -3295,21 +3295,21 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* determine where in range current transforms lie */ if (data->expo) { - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { if (data->from_max[i] - data->from_min[i]) - sval[i]= (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); + sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); else - sval[i]= 0.0f; + sval[i] = 0.0f; } } else { /* clamp transforms out of range */ - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { CLAMP(dvec[i], data->from_min[i], data->from_max[i]); if (data->from_max[i] - data->from_min[i]) - sval[i]= (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); + sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); else - sval[i]= 0.0f; + sval[i] = 0.0f; } } @@ -3317,18 +3317,18 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* apply transforms */ switch (data->to) { case 2: /* scaling */ - for (i=0; i<3; i++) - size[i]= data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])); + for (i = 0; i < 3; i++) + size[i] = data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])); break; case 1: /* rotation */ - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { float tmin, tmax; - tmin= data->to_min[i]; - tmax= data->to_max[i]; + tmin = data->to_min[i]; + tmax = data->to_max[i]; /* all values here should be in degrees */ - eul[i]= tmin + (sval[(int)data->map[i]] * (tmax - tmin)); + eul[i] = tmin + (sval[(int)data->map[i]] * (tmax - tmin)); /* now convert final value back to radians */ eul[i] = DEG2RADF(eul[i]); @@ -3336,8 +3336,8 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; default: /* location */ /* get new location */ - for (i=0; i<3; i++) - loc[i]= (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]))); + for (i = 0; i < 3; i++) + loc[i] = (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]))); /* add original location back on (so that it can still be moved) */ add_v3_v3v3(loc, cob->matrix[3], loc); @@ -3366,15 +3366,15 @@ static bConstraintTypeInfo CTI_TRANSFORM = { /* ---------- Shrinkwrap Constraint ----------- */ -static void shrinkwrap_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void shrinkwrap_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { bShrinkwrapConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->target, FALSE, userdata); + func(con, (ID **)&data->target, FALSE, userdata); } -static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) +static int shrinkwrap_get_tars(bConstraint *con, ListBase *list) { if (con && list) { bShrinkwrapConstraint *data = con->data; @@ -3389,22 +3389,22 @@ static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) } -static void shrinkwrap_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { bShrinkwrapConstraint *data = con->data; - bConstraintTarget *ct= list->first; + bConstraintTarget *ct = list->first; SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, nocopy) } } -static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; - if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) { + if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) { int fail = FALSE; float co[3] = {0.0f, 0.0f, 0.0f}; float no[3] = {0.0f, 0.0f, 0.0f}; @@ -3415,7 +3415,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BVHTreeRayHit hit; BVHTreeNearest nearest; - BVHTreeFromMesh treeData= {NULL}; + BVHTreeFromMesh treeData = {NULL}; nearest.index = -1; nearest.dist = FLT_MAX; @@ -3448,10 +3448,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr dist = len_v3v3(co, nearest.co); if (dist != 0.0f) { - interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist) / dist); /* linear interpolation */ } space_transform_invert(&transform, co); - break; + break; case MOD_SHRINKWRAP_PROJECT: if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f; @@ -3477,7 +3477,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr break; } copy_v3_v3(co, hit.co); - break; + break; } free_bvhtree_from_mesh(&treeData); @@ -3496,9 +3496,9 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } } -static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) +static void shrinkwrap_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -3523,25 +3523,25 @@ static bConstraintTypeInfo CTI_SHRINKWRAP = { /* --------- Damped Track ---------- */ -static void damptrack_new_data (void *cdata) +static void damptrack_new_data(void *cdata) { - bDampTrackConstraint *data= (bDampTrackConstraint *)cdata; + bDampTrackConstraint *data = (bDampTrackConstraint *)cdata; data->trackflag = TRACK_Y; } -static void damptrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void damptrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bDampTrackConstraint *data= con->data; + bDampTrackConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int damptrack_get_tars (bConstraint *con, ListBase *list) +static int damptrack_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bDampTrackConstraint *data= con->data; + bDampTrackConstraint *data = con->data; bConstraintTarget *ct; /* the following macro is used for all standard single-target constraints */ @@ -3553,11 +3553,11 @@ static int damptrack_get_tars (bConstraint *con, ListBase *list) return 0; } -static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void damptrack_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bDampTrackConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bDampTrackConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) @@ -3566,14 +3566,14 @@ static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy /* array of direction vectors for the tracking flags */ static const float track_dir_vecs[6][3] = { - {+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */ - {-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */ + {+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */ + {-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */ }; -static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bDampTrackConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bDampTrackConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float obvec[3], tarvec[3], obloc[3]; @@ -3614,8 +3614,8 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * */ cross_v3_v3v3(raxis, obvec, tarvec); - rangle= dot_v3v3(obvec, tarvec); - rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); + rangle = dot_v3v3(obvec, tarvec); + rangle = acos(MAX2(-1.0f, MIN2(1.0f, rangle)) ); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first @@ -3650,43 +3650,43 @@ static bConstraintTypeInfo CTI_DAMPTRACK = { /* ----------- Spline IK ------------ */ -static void splineik_free (bConstraint *con) +static void splineik_free(bConstraint *con) { - bSplineIKConstraint *data= con->data; + bSplineIKConstraint *data = con->data; /* binding array */ if (data->points) MEM_freeN(data->points); } -static void splineik_copy (bConstraint *con, bConstraint *srccon) +static void splineik_copy(bConstraint *con, bConstraint *srccon) { - bSplineIKConstraint *src= srccon->data; - bSplineIKConstraint *dst= con->data; + bSplineIKConstraint *src = srccon->data; + bSplineIKConstraint *dst = con->data; /* copy the binding array */ - dst->points= MEM_dupallocN(src->points); + dst->points = MEM_dupallocN(src->points); } -static void splineik_new_data (void *cdata) +static void splineik_new_data(void *cdata) { - bSplineIKConstraint *data= (bSplineIKConstraint *)cdata; + bSplineIKConstraint *data = (bSplineIKConstraint *)cdata; - data->chainlen= 1; + data->chainlen = 1; } -static void splineik_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void splineik_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bSplineIKConstraint *data= con->data; + bSplineIKConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int splineik_get_tars (bConstraint *con, ListBase *list) +static int splineik_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bSplineIKConstraint *data= con->data; + bSplineIKConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -3698,28 +3698,28 @@ static int splineik_get_tars (bConstraint *con, ListBase *list) return 0; } -static void splineik_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bSplineIKConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bSplineIKConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) } } -static void splineik_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) */ /* only happens on reload file, but violates depsgraph still... fix! */ - if (cu->path==NULL || cu->path->data==NULL) + if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(cob->scene, ct->tar, 0); } @@ -3747,18 +3747,18 @@ static bConstraintTypeInfo CTI_SPLINEIK = { /* ----------- Pivot ------------- */ -static void pivotcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void pivotcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bPivotConstraint *data= con->data; + bPivotConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, FALSE, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int pivotcon_get_tars (bConstraint *con, ListBase *list) +static int pivotcon_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bPivotConstraint *data= con->data; + bPivotConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -3770,21 +3770,21 @@ static int pivotcon_get_tars (bConstraint *con, ListBase *list) return 0; } -static void pivotcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void pivotcon_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bPivotConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bPivotConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bPivotConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bPivotConstraint *data = con->data; + bConstraintTarget *ct = targets->first; float pivot[3], vec[3]; float rotMat[3][3]; @@ -3845,11 +3845,11 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t } /* perform the pivoting... */ - /* 1. take the vector from owner to the pivot */ + /* 1. take the vector from owner to the pivot */ sub_v3_v3v3(vec, cob->matrix[3], pivot); - /* 2. rotate this vector by the rotation of the object... */ + /* 2. rotate this vector by the rotation of the object... */ mul_m3_v3(rotMat, vec); - /* 3. make the rotation in terms of the pivot now */ + /* 3. make the rotation in terms of the pivot now */ add_v3_v3v3(cob->matrix[3], pivot, vec); } @@ -3883,9 +3883,9 @@ static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void { bFollowTrackConstraint *data = con->data; - func(con, (ID**)&data->clip, TRUE, userdata); - func(con, (ID**)&data->camera, FALSE, userdata); - func(con, (ID**)&data->depth_ob, FALSE, 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)) @@ -3896,10 +3896,10 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase MovieTracking *tracking; MovieTrackingTrack *track; MovieTrackingObject *tracking_object; - Object *camob= data->camera ? data->camera : scene->camera; + Object *camob = data->camera ? data->camera : scene->camera; if (data->flag & FOLLOWTRACK_ACTIVECLIP) - clip= scene->clip; + clip = scene->clip; if (!clip || !data->track[0] || !camob) return; @@ -3925,7 +3925,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase copy_m4_m4(obmat, cob->matrix); - if ((tracking_object->flag & TRACKING_OBJECT_CAMERA)==0) { + if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) { float imat[4][4]; copy_m4_m4(mat, camob->obmat); @@ -3947,7 +3947,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase else { MovieTrackingMarker *marker; float vec[3], disp[3], axis[3], mat[4][4]; - float aspect= (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); + float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); float len, d; BKE_object_where_is_calc_mat4(scene, camob, mat); @@ -3995,7 +3995,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase copy_v3_v3(cob->matrix[3], disp); } else { - d= (len * params.sensor_x) / (2.0f * params.lens); + d = (len * params.sensor_x) / (2.0f * params.lens); vec[0] = d * (2.0f * (pos[0] + params.shiftx) - 1.0f); vec[1] = d * (2.0f * (pos[1] + params.shifty) - 1.0f); @@ -4076,7 +4076,7 @@ static void camerasolver_id_looper(bConstraint *con, ConstraintIDFunc func, void { bCameraSolverConstraint *data = con->data; - func(con, (ID**)&data->clip, TRUE, userdata); + func(con, (ID **)&data->clip, TRUE, userdata); } static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -4129,10 +4129,10 @@ static void objectsolver_new_data(void *cdata) static void objectsolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bObjectSolverConstraint *data= con->data; + bObjectSolverConstraint *data = con->data; - func(con, (ID**)&data->clip, FALSE, userdata); - func(con, (ID**)&data->camera, FALSE, 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)) @@ -4143,7 +4143,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase Object *camob = data->camera ? data->camera : scene->camera; if (data->flag & OBJECTSOLVER_ACTIVECLIP) - clip= scene->clip; + clip = scene->clip; if (!camob || !clip) return; @@ -4196,46 +4196,46 @@ static bConstraintTypeInfo CTI_OBJECTSOLVER = { /* These globals only ever get directly accessed in this file */ static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES]; -static short CTI_INIT= 1; /* when non-zero, the list needs to be updated */ +static short CTI_INIT = 1; /* when non-zero, the list needs to be updated */ /* This function only gets called when CTI_INIT is non-zero */ -static void constraints_init_typeinfo (void) +static void constraints_init_typeinfo(void) { - constraintsTypeInfo[0]= NULL; /* 'Null' Constraint */ - constraintsTypeInfo[1]= &CTI_CHILDOF; /* ChildOf Constraint */ - constraintsTypeInfo[2]= &CTI_TRACKTO; /* TrackTo Constraint */ - constraintsTypeInfo[3]= &CTI_KINEMATIC; /* IK Constraint */ - constraintsTypeInfo[4]= &CTI_FOLLOWPATH; /* Follow-Path Constraint */ - constraintsTypeInfo[5]= &CTI_ROTLIMIT; /* Limit Rotation Constraint */ - constraintsTypeInfo[6]= &CTI_LOCLIMIT; /* Limit Location Constraint */ - constraintsTypeInfo[7]= &CTI_SIZELIMIT; /* Limit Scaling Constraint */ - constraintsTypeInfo[8]= &CTI_ROTLIKE; /* Copy Rotation Constraint */ - constraintsTypeInfo[9]= &CTI_LOCLIKE; /* Copy Location Constraint */ - constraintsTypeInfo[10]= &CTI_SIZELIKE; /* Copy Scaling Constraint */ - constraintsTypeInfo[11]= &CTI_PYTHON; /* Python/Script Constraint */ - constraintsTypeInfo[12]= &CTI_ACTION; /* Action Constraint */ - constraintsTypeInfo[13]= &CTI_LOCKTRACK; /* Locked-Track Constraint */ - constraintsTypeInfo[14]= &CTI_DISTLIMIT; /* Limit Distance Constraint */ - constraintsTypeInfo[15]= &CTI_STRETCHTO; /* StretchTo Constaint */ - constraintsTypeInfo[16]= &CTI_MINMAX; /* Floor Constraint */ - constraintsTypeInfo[17]= &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */ - constraintsTypeInfo[18]= &CTI_CLAMPTO; /* ClampTo Constraint */ - constraintsTypeInfo[19]= &CTI_TRANSFORM; /* Transformation Constraint */ - constraintsTypeInfo[20]= &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */ - constraintsTypeInfo[21]= &CTI_DAMPTRACK; /* Damped TrackTo Constraint */ - constraintsTypeInfo[22]= &CTI_SPLINEIK; /* Spline IK Constraint */ - constraintsTypeInfo[23]= &CTI_TRANSLIKE; /* Copy Transforms Constraint */ - constraintsTypeInfo[24]= &CTI_SAMEVOL; /* Maintain Volume Constraint */ - constraintsTypeInfo[25]= &CTI_PIVOT; /* Pivot Constraint */ - constraintsTypeInfo[26]= &CTI_FOLLOWTRACK; /* Follow Track Constraint */ - constraintsTypeInfo[27]= &CTI_CAMERASOLVER; /* Camera Solver Constraint */ - constraintsTypeInfo[28]= &CTI_OBJECTSOLVER; /* Object Solver Constraint */ + constraintsTypeInfo[0] = NULL; /* 'Null' Constraint */ + constraintsTypeInfo[1] = &CTI_CHILDOF; /* ChildOf Constraint */ + constraintsTypeInfo[2] = &CTI_TRACKTO; /* TrackTo Constraint */ + constraintsTypeInfo[3] = &CTI_KINEMATIC; /* IK Constraint */ + constraintsTypeInfo[4] = &CTI_FOLLOWPATH; /* Follow-Path Constraint */ + constraintsTypeInfo[5] = &CTI_ROTLIMIT; /* Limit Rotation Constraint */ + constraintsTypeInfo[6] = &CTI_LOCLIMIT; /* Limit Location Constraint */ + constraintsTypeInfo[7] = &CTI_SIZELIMIT; /* Limit Scaling Constraint */ + constraintsTypeInfo[8] = &CTI_ROTLIKE; /* Copy Rotation Constraint */ + constraintsTypeInfo[9] = &CTI_LOCLIKE; /* Copy Location Constraint */ + constraintsTypeInfo[10] = &CTI_SIZELIKE; /* Copy Scaling Constraint */ + constraintsTypeInfo[11] = &CTI_PYTHON; /* Python/Script Constraint */ + constraintsTypeInfo[12] = &CTI_ACTION; /* Action Constraint */ + constraintsTypeInfo[13] = &CTI_LOCKTRACK; /* Locked-Track Constraint */ + constraintsTypeInfo[14] = &CTI_DISTLIMIT; /* Limit Distance Constraint */ + constraintsTypeInfo[15] = &CTI_STRETCHTO; /* StretchTo Constaint */ + constraintsTypeInfo[16] = &CTI_MINMAX; /* Floor Constraint */ + constraintsTypeInfo[17] = &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */ + constraintsTypeInfo[18] = &CTI_CLAMPTO; /* ClampTo Constraint */ + constraintsTypeInfo[19] = &CTI_TRANSFORM; /* Transformation Constraint */ + constraintsTypeInfo[20] = &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */ + constraintsTypeInfo[21] = &CTI_DAMPTRACK; /* Damped TrackTo Constraint */ + constraintsTypeInfo[22] = &CTI_SPLINEIK; /* Spline IK Constraint */ + constraintsTypeInfo[23] = &CTI_TRANSLIKE; /* Copy Transforms Constraint */ + constraintsTypeInfo[24] = &CTI_SAMEVOL; /* Maintain Volume Constraint */ + constraintsTypeInfo[25] = &CTI_PIVOT; /* Pivot Constraint */ + constraintsTypeInfo[26] = &CTI_FOLLOWTRACK; /* Follow Track Constraint */ + constraintsTypeInfo[27] = &CTI_CAMERASOLVER; /* Camera Solver Constraint */ + constraintsTypeInfo[28] = &CTI_OBJECTSOLVER; /* Object Solver Constraint */ } /* This function should be used for getting the appropriate type-info when only * a constraint type is known */ -bConstraintTypeInfo *get_constraint_typeinfo (int type) +bConstraintTypeInfo *get_constraint_typeinfo(int type) { /* initialize the type-info list? */ if (CTI_INIT) { @@ -4245,7 +4245,7 @@ bConstraintTypeInfo *get_constraint_typeinfo (int type) /* only return for valid types */ if ( (type >= CONSTRAINT_TYPE_NULL) && - (type < NUM_CONSTRAINT_TYPES ) ) + (type < NUM_CONSTRAINT_TYPES) ) { /* there shouldn't be any segfaults here... */ return constraintsTypeInfo[type]; @@ -4260,7 +4260,7 @@ bConstraintTypeInfo *get_constraint_typeinfo (int type) /* This function should always be used to get the appropriate type-info, as it * has checks which prevent segfaults in some weird cases. */ -bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con) +bConstraintTypeInfo *constraint_get_typeinfo(bConstraint *con) { /* only return typeinfo for valid constraints */ if (con) @@ -4290,7 +4290,7 @@ static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isRe void free_constraint_data(bConstraint *con) { if (con->data) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (cti) { /* perform any special freeing constraint may have */ @@ -4313,7 +4313,7 @@ void free_constraints(ListBase *list) bConstraint *con; /* Free constraint data and also any extra data */ - for (con= list->first; con; con= con->next) + for (con = list->first; con; con = con->next) free_constraint_data(con); /* Free the whole list */ @@ -4342,8 +4342,8 @@ void remove_constraints_type(ListBase *list, short type, short last_only) return; /* remove from the end of the list to make it faster to find the last instance */ - for (con= list->last; con; con= conp) { - conp= con->prev; + for (con = list->last; con; con = conp) { + conp = con->prev; if (con->type == type) { remove_constraint(list, con); @@ -4356,10 +4356,10 @@ void remove_constraints_type(ListBase *list, short type, short last_only) /* ......... */ /* Creates a new constraint, initializes its data, and returns it */ -static bConstraint *add_new_constraint_internal (const char *name, short type) +static bConstraint *add_new_constraint_internal(const char *name, short type) { - bConstraint *con= MEM_callocN(sizeof(bConstraint), "Constraint"); - bConstraintTypeInfo *cti= get_constraint_typeinfo(type); + bConstraint *con = MEM_callocN(sizeof(bConstraint), "Constraint"); + bConstraintTypeInfo *cti = get_constraint_typeinfo(type); const char *newName; /* Set up a generic constraint datablock */ @@ -4377,12 +4377,12 @@ static bConstraint *add_new_constraint_internal (const char *name, short type) cti->new_data(con->data); /* if no name is provided, use the type of the constraint as the name */ - newName= (name && name[0]) ? name : cti->name; + newName = (name && name[0]) ? name : cti->name; } else { /* if no name is provided, use the generic "Const" name */ // NOTE: any constraint type that gets here really shouldn't get added... - newName= (name && name[0]) ? name : "Const"; + newName = (name && name[0]) ? name : "Const"; } /* copy the name */ @@ -4393,13 +4393,13 @@ static bConstraint *add_new_constraint_internal (const char *name, short type) } /* if pchan is not NULL then assume we're adding a pose constraint */ -static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type) +static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type) { bConstraint *con; ListBase *list; /* add the constraint */ - con= add_new_constraint_internal(name, type); + con = add_new_constraint_internal(name, type); /* find the constraint stack - bone or object? */ list = (pchan) ? (&pchan->constraints) : (&ob->constraints); @@ -4434,7 +4434,7 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c con->flag |= CONSTRAINT_SPACEONCE; } } - break; + break; } return con; @@ -4443,7 +4443,7 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c /* ......... */ /* Add new constraint for the given bone */ -bConstraint *add_pose_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type) +bConstraint *add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type) { if (pchan == NULL) return NULL; @@ -4485,8 +4485,8 @@ void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdat { bConstraint *con; - for (con= conlist->first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = conlist->first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (cti) { if (cti->id_looper) @@ -4517,11 +4517,11 @@ void copy_constraints(ListBase *dst, const ListBase *src, int do_extern) { bConstraint *con, *srccon; - dst->first= dst->last= NULL; + dst->first = dst->last = NULL; BLI_duplicatelist(dst, src); - for (con=dst->first, srccon=src->first; con && srccon; srccon=srccon->next, con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); /* make a new copy of the constraint's data */ con->data = MEM_dupallocN(con->data); @@ -4554,13 +4554,13 @@ bConstraint *constraints_findByName(ListBase *list, const char *name) } /* finds the 'active' constraint in a constraint stack */ -bConstraint *constraints_get_active (ListBase *list) +bConstraint *constraints_get_active(ListBase *list) { bConstraint *con; /* search for the first constraint with the 'active' flag set */ if (list) { - for (con= list->first; con; con= con->next) { + for (con = list->first; con; con = con->next) { if (con->flag & CONSTRAINT_ACTIVE) return con; } @@ -4576,7 +4576,7 @@ void constraints_set_active(ListBase *list, bConstraint *con) bConstraint *c; if (list) { - for (c= list->first; c; c= c->next) { + for (c = list->first; c; c = c->next) { if (c == con) c->flag |= CONSTRAINT_ACTIVE; else @@ -4593,8 +4593,8 @@ void extract_proxylocal_constraints(ListBase *dst, ListBase *src) bConstraint *con, *next; /* for each tagged constraint, remove from src and move to dst */ - for (con= src->first; con; con= next) { - next= con->next; + for (con = src->first; con; con = next) { + next = con->next; /* check if tagged */ if (con->flag & CONSTRAINT_PROXY_LOCAL) { @@ -4610,7 +4610,7 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan) /* Currently, constraints can only be on object or bone level */ if (ob && ob->proxy) { if (ob->pose && pchan) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; /* On bone-level, check if bone is on proxy-protected layer */ if ((pchan->bone) && (pchan->bone->layer & arm->layer_protected)) @@ -4636,21 +4636,21 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan) */ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintOb *cob; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { /* make 'constraint-ob' */ - cob= MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb"); - cob->type= ownertype; + cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb"); + cob->type = ownertype; cob->scene = scene; switch (ownertype) { case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */ { - cob->ob= (Object *)ownerdata; - cob->pchan= NULL; + cob->ob = (Object *)ownerdata; + cob->pchan = NULL; if (cob->ob) { copy_m4_m4(cob->matrix, cob->ob->obmat); copy_m4_m4(cob->startmat, cob->matrix); @@ -4660,11 +4660,11 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, unit_m4(cob->startmat); } } - break; + break; case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */ { - cob->ob= NULL; /* this might not work at all :/ */ - cob->pchan= (bPoseChannel *)ownerdata; + cob->ob = NULL; /* this might not work at all :/ */ + cob->pchan = (bPoseChannel *)ownerdata; if (cob->pchan) { copy_m4_m4(cob->matrix, cob->pchan->pose_mat); copy_m4_m4(cob->startmat, cob->matrix); @@ -4674,16 +4674,16 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, unit_m4(cob->startmat); } } - break; + break; } /* get targets - we only need the first one though (and there should only be one) */ cti->get_constraint_targets(con, &targets); /* only calculate the target matrix on the first target */ - ct= (bConstraintTarget *)targets.first; + ct = (bConstraintTarget *)targets.first; while (ct && n-- > 0) - ct= ct->next; + ct = ct->next; if (ct) { if (cti->get_target_matrix) @@ -4705,26 +4705,26 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, /* Get the list of targets required for solving a constraint */ void get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; /* get targets - * - constraints should use ct->matrix, not directly accessing values + * - constraints should use ct->matrix, not directly accessing values * - ct->matrix members have not yet been calculated here! */ cti->get_constraint_targets(con, targets); /* set matrices - * - calculate if possible, otherwise just initialize as identity matrix + * - calculate if possible, otherwise just initialize as identity matrix */ if (cti->get_target_matrix) { - for (ct= targets->first; ct; ct= ct->next) + for (ct = targets->first; ct; ct = ct->next) cti->get_target_matrix(con, cob, ct, ctime); } else { - for (ct= targets->first; ct; ct= ct->next) + for (ct = targets->first; ct; ct = ct->next) unit_m4(ct->matrix); } } @@ -4749,20 +4749,20 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime) return; /* loop over available constraints, solving and blending them */ - for (con= conlist->first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = conlist->first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; /* these we can skip completely (invalid constraints...) */ if (cti == NULL) continue; - if (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF)) continue; + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) continue; /* these constraints can't be evaluated anyway */ if (cti->evaluate_constraint == NULL) continue; /* influence == 0 should be ignored */ if (con->enforce == 0.0f) continue; /* influence of constraint - * - value should have been set from animation data already + * - value should have been set from animation data already */ enf = con->enforce; @@ -4791,9 +4791,9 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime) constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD); /* Interpolate the enforcement, to blend result of constraint into final owner transform - * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), - * since some constraints may not convert the solution back to the input space before blending - * but all are guaranteed to end up in good "worldspace" result + * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), + * since some constraints may not convert the solution back to the input space before blending + * but all are guaranteed to end up in good "worldspace" result */ /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ if (enf < 1.0f) { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index bd47e7cbd37..d736309f605 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -92,14 +92,14 @@ bContext *CTX_create(void) { bContext *C; - C= MEM_callocN(sizeof(bContext), "bContext"); + C = MEM_callocN(sizeof(bContext), "bContext"); return C; } bContext *CTX_copy(const bContext *C) { - bContext *newC= MEM_dupallocN((void*)C); + bContext *newC = MEM_dupallocN((void *)C); return newC; } @@ -118,23 +118,23 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p /* ensure we have a context to put the entry in, if it was already used * we have to copy the context to ensure */ - ctx= contexts->last; + ctx = contexts->last; if (!ctx || ctx->used) { if (ctx) { - lastctx= ctx; - ctx= MEM_dupallocN(lastctx); + lastctx = ctx; + ctx = MEM_dupallocN(lastctx); BLI_duplicatelist(&ctx->entries, &lastctx->entries); } else - ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); + ctx = MEM_callocN(sizeof(bContextStore), "bContextStore"); BLI_addtail(contexts, ctx); } - entry= MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry"); + entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry"); BLI_strncpy(entry->name, name, sizeof(entry->name)); - entry->ptr= *ptr; + entry->ptr = *ptr; BLI_addtail(&ctx->entries, entry); @@ -148,22 +148,22 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context) /* ensure we have a context to put the entries in, if it was already used * we have to copy the context to ensure */ - ctx= contexts->last; + ctx = contexts->last; if (!ctx || ctx->used) { if (ctx) { - lastctx= ctx; - ctx= MEM_dupallocN(lastctx); + lastctx = ctx; + ctx = MEM_dupallocN(lastctx); BLI_duplicatelist(&ctx->entries, &lastctx->entries); } else - ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); + ctx = MEM_callocN(sizeof(bContextStore), "bContextStore"); BLI_addtail(contexts, ctx); } - for (tentry= context->entries.first; tentry; tentry= tentry->next) { - entry= MEM_dupallocN(tentry); + for (tentry = context->entries.first; tentry; tentry = tentry->next) { + entry = MEM_dupallocN(tentry); BLI_addtail(&ctx->entries, entry); } @@ -172,14 +172,14 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context) void CTX_store_set(bContext *C, bContextStore *store) { - C->wm.store= store; + C->wm.store = store; } bContextStore *CTX_store_copy(bContextStore *store) { bContextStore *ctx; - ctx= MEM_dupallocN(store); + ctx = MEM_dupallocN(store); BLI_duplicatelist(&ctx->entries, &store->entries); return ctx; @@ -195,7 +195,7 @@ void CTX_store_free_list(ListBase *contexts) { bContextStore *ctx; - while ((ctx= contexts->first)) { + while ((ctx = contexts->first)) { BLI_remlink(contexts, ctx); CTX_store_free(ctx); } @@ -209,7 +209,7 @@ int CTX_py_init_get(bContext *C) } void CTX_py_init_set(bContext *C, int value) { - C->data.py_init= value; + C->data.py_init = value; } void *CTX_py_dict_get(const bContext *C) @@ -218,7 +218,7 @@ void *CTX_py_dict_get(const bContext *C) } void CTX_py_dict_set(bContext *C, void *value) { - C->data.py_context= value; + C->data.py_context = value; } /* data context utility functions */ @@ -237,8 +237,8 @@ static void *ctx_wm_python_context_get(const bContext *C, const char *member, vo if (C && CTX_py_dict_get(C)) { memset(&result, 0, sizeof(bContextDataResult)); - BPY_context_member_get((bContext*)C, member, &result); - if(result.ptr.data) + BPY_context_member_get((bContext *)C, member, &result); + if (result.ptr.data) return result.ptr.data; } #endif @@ -251,8 +251,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res bScreen *sc; ScrArea *sa; ARegion *ar; - int done= 0, recursion= C->data.recursion; - int ret= 0; + int done = 0, recursion = C->data.recursion; + int ret = 0; memset(result, 0, sizeof(bContextDataResult)); #ifdef WITH_PYTHON @@ -271,42 +271,42 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res * Values in order of importance * (0, -1, 1) - Where 1 is highest priority * */ - if (done!=1 && recursion < 1 && C->wm.store) { + if (done != 1 && recursion < 1 && C->wm.store) { bContextStoreEntry *entry; - C->data.recursion= 1; + C->data.recursion = 1; - entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); + entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); if (entry) { - result->ptr= entry->ptr; - done= 1; + result->ptr = entry->ptr; + done = 1; } } - if (done!=1 && recursion < 2 && (ar=CTX_wm_region(C))) { - C->data.recursion= 2; + if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) { + C->data.recursion = 2; if (ar->type && ar->type->context) { ret = ar->type->context(C, member, result); - if (ret) done= -(-ret | -done); + if (ret) done = -(-ret | -done); } } - if (done!=1 && recursion < 3 && (sa=CTX_wm_area(C))) { - C->data.recursion= 3; + if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) { + C->data.recursion = 3; if (sa->type && sa->type->context) { ret = sa->type->context(C, member, result); - if (ret) done= -(-ret | -done); + if (ret) done = -(-ret | -done); } } - if (done!=1 && recursion < 4 && (sc=CTX_wm_screen(C))) { - bContextDataCallback cb= sc->context; - C->data.recursion= 4; + if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) { + bContextDataCallback cb = sc->context; + C->data.recursion = 4; if (cb) { ret = cb(C, member, result); - if (ret) done= -(-ret | -done); + if (ret) done = -(-ret | -done); } } - C->data.recursion= recursion; + C->data.recursion = recursion; return done; } @@ -315,7 +315,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member) { bContextDataResult result; - if (C && ctx_data_get((bContext*)C, member, &result)==1) + if (C && ctx_data_get((bContext *)C, member, &result) == 1) return result.ptr.data; return NULL; @@ -327,15 +327,15 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void * /* if context is NULL, pointer must be NULL too and that is a valid return */ if (C == NULL) { - *pointer= NULL; + *pointer = NULL; return 1; } - else if (ctx_data_get((bContext*)C, member, &result)==1) { - *pointer= result.ptr.data; + else if (ctx_data_get((bContext *)C, member, &result) == 1) { + *pointer = result.ptr.data; return 1; } else { - *pointer= NULL; + *pointer = NULL; return 0; } } @@ -344,13 +344,13 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa { bContextDataResult result; - if (ctx_data_get((bContext*)C, member, &result)==1) { - *list= result.list; + if (ctx_data_get((bContext *)C, member, &result) == 1) { + *list = result.list; return 1; } - list->first= NULL; - list->last= NULL; + list->first = NULL; + list->last = NULL; return 0; } @@ -359,7 +359,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member) { bContextDataResult result; - if (ctx_data_get((bContext*)C, member, &result)==1) + if (ctx_data_get((bContext *)C, member, &result) == 1) return result.ptr; else return PointerRNA_NULL; @@ -379,11 +379,11 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) { bContextDataResult result; - if (ctx_data_get((bContext*)C, member, &result)==1) { + if (ctx_data_get((bContext *)C, member, &result) == 1) { return result.list; } else { - ListBase list= {NULL, NULL}; + ListBase list = {NULL, NULL}; return list; } } @@ -392,17 +392,17 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type) { bContextDataResult result; - int ret= ctx_data_get((bContext*)C, member, &result); + int ret = ctx_data_get((bContext *)C, member, &result); - if (ret==1) { - *r_ptr= result.ptr; - *r_lb= result.list; - *r_type= result.type; + if (ret == 1) { + *r_ptr = result.ptr; + *r_lb = result.list; + *r_type = result.type; } else { memset(r_ptr, 0, sizeof(*r_ptr)); memset(r_lb, 0, sizeof(*r_lb)); - *r_type= 0; + *r_type = 0; } return ret; @@ -418,8 +418,8 @@ static void data_dir_add(ListBase *lb, const char *member) if (BLI_findstring(lb, member, offsetof(LinkData, data))) return; - link= MEM_callocN(sizeof(LinkData), "LinkData"); - link->data= (void*)member; + link = MEM_callocN(sizeof(LinkData), "LinkData"); + link->data = (void *)member; BLI_addtail(lb, link); } @@ -437,32 +437,32 @@ ListBase CTX_data_dir_get(const bContext *C) if (C->wm.store) { bContextStoreEntry *entry; - for (entry=C->wm.store->entries.first; entry; entry=entry->next) + for (entry = C->wm.store->entries.first; entry; entry = entry->next) data_dir_add(&lb, entry->name); } - if ((ar=CTX_wm_region(C)) && ar->type && ar->type->context) { + if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) { memset(&result, 0, sizeof(result)); ar->type->context(C, "", &result); if (result.dir) - for (a=0; result.dir[a]; a++) + for (a = 0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } - if ((sa=CTX_wm_area(C)) && sa->type && sa->type->context) { + if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) { memset(&result, 0, sizeof(result)); sa->type->context(C, "", &result); if (result.dir) - for (a=0; result.dir[a]; a++) + for (a = 0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } - if ((sc=CTX_wm_screen(C)) && sc->context) { - bContextDataCallback cb= sc->context; + if ((sc = CTX_wm_screen(C)) && sc->context) { + bContextDataCallback cb = sc->context; memset(&result, 0, sizeof(result)); cb(C, "", &result); if (result.dir) - for (a=0; result.dir[a]; a++) + for (a = 0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } @@ -493,7 +493,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id) { CollectionPointerLink *link; - link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add"); + link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add"); RNA_id_pointer_create(id, &link->ptr); BLI_addtail(&result->list, link); @@ -503,18 +503,18 @@ void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void { CollectionPointerLink *link; - link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add"); + link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add"); RNA_pointer_create(id, type, data, &link->ptr); BLI_addtail(&result->list, link); } -int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*)) +int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *)) { ListBase list; if (func(C, &list)) { - int tot= BLI_countlist(&list); + int tot = BLI_countlist(&list); BLI_freelistN(&list); return tot; } @@ -524,12 +524,12 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase void CTX_data_dir_set(bContextDataResult *result, const char **dir) { - result->dir= dir; + result->dir = dir; } void CTX_data_type_set(bContextDataResult *result, short type) { - result->type= type; + result->type = type; } short CTX_data_type_get(bContextDataResult *result) @@ -564,7 +564,7 @@ ScrArea *CTX_wm_area(const bContext *C) SpaceLink *CTX_wm_space_data(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - return (sa)? sa->spacedata.first: NULL; + return (sa) ? sa->spacedata.first : NULL; } ARegion *CTX_wm_region(const bContext *C) @@ -575,7 +575,7 @@ ARegion *CTX_wm_region(const bContext *C) void *CTX_wm_region_data(const bContext *C) { ARegion *ar = CTX_wm_region(C); - return (ar)? ar->regiondata: NULL; + return (ar) ? ar->regiondata : NULL; } struct ARegion *CTX_wm_menu(const bContext *C) @@ -594,7 +594,7 @@ struct ReportList *CTX_wm_reports(const bContext *C) View3D *CTX_wm_view3d(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_VIEW3D) + if (sa && sa->spacetype == SPACE_VIEW3D) return sa->spacedata.first; return NULL; } @@ -604,7 +604,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - if (sa && sa->spacetype==SPACE_VIEW3D) + if (sa && sa->spacetype == SPACE_VIEW3D) if (ar) return ar->regiondata; return NULL; @@ -613,7 +613,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C) struct SpaceText *CTX_wm_space_text(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_TEXT) + if (sa && sa->spacetype == SPACE_TEXT) return sa->spacedata.first; return NULL; } @@ -621,7 +621,7 @@ struct SpaceText *CTX_wm_space_text(const bContext *C) struct SpaceConsole *CTX_wm_space_console(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_CONSOLE) + if (sa && sa->spacetype == SPACE_CONSOLE) return sa->spacedata.first; return NULL; } @@ -629,7 +629,7 @@ struct SpaceConsole *CTX_wm_space_console(const bContext *C) struct SpaceImage *CTX_wm_space_image(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_IMAGE) + if (sa && sa->spacetype == SPACE_IMAGE) return sa->spacedata.first; return NULL; } @@ -637,7 +637,7 @@ struct SpaceImage *CTX_wm_space_image(const bContext *C) struct SpaceButs *CTX_wm_space_buts(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_BUTS) + if (sa && sa->spacetype == SPACE_BUTS) return sa->spacedata.first; return NULL; } @@ -645,7 +645,7 @@ struct SpaceButs *CTX_wm_space_buts(const bContext *C) struct SpaceFile *CTX_wm_space_file(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_FILE) + if (sa && sa->spacetype == SPACE_FILE) return sa->spacedata.first; return NULL; } @@ -653,7 +653,7 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C) struct SpaceSeq *CTX_wm_space_seq(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_SEQ) + if (sa && sa->spacetype == SPACE_SEQ) return sa->spacedata.first; return NULL; } @@ -661,7 +661,7 @@ struct SpaceSeq *CTX_wm_space_seq(const bContext *C) struct SpaceOops *CTX_wm_space_outliner(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_OUTLINER) + if (sa && sa->spacetype == SPACE_OUTLINER) return sa->spacedata.first; return NULL; } @@ -669,7 +669,7 @@ struct SpaceOops *CTX_wm_space_outliner(const bContext *C) struct SpaceNla *CTX_wm_space_nla(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_NLA) + if (sa && sa->spacetype == SPACE_NLA) return sa->spacedata.first; return NULL; } @@ -677,7 +677,7 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C) struct SpaceTime *CTX_wm_space_time(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_TIME) + if (sa && sa->spacetype == SPACE_TIME) return sa->spacedata.first; return NULL; } @@ -685,7 +685,7 @@ struct SpaceTime *CTX_wm_space_time(const bContext *C) struct SpaceNode *CTX_wm_space_node(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_NODE) + if (sa && sa->spacetype == SPACE_NODE) return sa->spacedata.first; return NULL; } @@ -693,7 +693,7 @@ struct SpaceNode *CTX_wm_space_node(const bContext *C) struct SpaceLogic *CTX_wm_space_logic(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_LOGIC) + if (sa && sa->spacetype == SPACE_LOGIC) return sa->spacedata.first; return NULL; } @@ -701,7 +701,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C) struct SpaceIpo *CTX_wm_space_graph(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_IPO) + if (sa && sa->spacetype == SPACE_IPO) return sa->spacedata.first; return NULL; } @@ -709,7 +709,7 @@ struct SpaceIpo *CTX_wm_space_graph(const bContext *C) struct SpaceAction *CTX_wm_space_action(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_ACTION) + if (sa && sa->spacetype == SPACE_ACTION) return sa->spacedata.first; return NULL; } @@ -717,7 +717,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C) struct SpaceInfo *CTX_wm_space_info(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_INFO) + if (sa && sa->spacetype == SPACE_INFO) return sa->spacedata.first; return NULL; } @@ -725,7 +725,7 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C) struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_USERPREF) + if (sa && sa->spacetype == SPACE_USERPREF) return sa->spacedata.first; return NULL; } @@ -733,58 +733,58 @@ struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) struct SpaceClip *CTX_wm_space_clip(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_CLIP) + if (sa && sa->spacetype == SPACE_CLIP) return sa->spacedata.first; return NULL; } void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { - C->wm.manager= wm; - C->wm.window= NULL; - C->wm.screen= NULL; - C->wm.area= NULL; - C->wm.region= NULL; + C->wm.manager = wm; + C->wm.window = NULL; + C->wm.screen = NULL; + C->wm.area = NULL; + C->wm.region = NULL; } void CTX_wm_window_set(bContext *C, wmWindow *win) { - C->wm.window= win; - C->wm.screen= (win)? win->screen: NULL; + C->wm.window = win; + C->wm.screen = (win) ? win->screen : NULL; if (C->wm.screen) - C->data.scene= C->wm.screen->scene; - C->wm.area= NULL; - C->wm.region= NULL; + C->data.scene = C->wm.screen->scene; + C->wm.area = NULL; + C->wm.region = NULL; } void CTX_wm_screen_set(bContext *C, bScreen *screen) { - C->wm.screen= screen; + C->wm.screen = screen; if (C->wm.screen) - C->data.scene= C->wm.screen->scene; - C->wm.area= NULL; - C->wm.region= NULL; + C->data.scene = C->wm.screen->scene; + C->wm.area = NULL; + C->wm.region = NULL; } void CTX_wm_area_set(bContext *C, ScrArea *area) { - C->wm.area= area; - C->wm.region= NULL; + C->wm.area = area; + C->wm.region = NULL; } void CTX_wm_region_set(bContext *C, ARegion *region) { - C->wm.region= region; + C->wm.region = region; } void CTX_wm_menu_set(bContext *C, ARegion *menu) { - C->wm.menu= menu; + C->wm.menu = menu; } void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) { - C->wm.operator_poll_msg= msg; + C->wm.operator_poll_msg = msg; } const char *CTX_wm_operator_poll_msg_get(bContext *C) @@ -798,7 +798,7 @@ Main *CTX_data_main(const bContext *C) { Main *bmain; - if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain)) + if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) return bmain; else return C->data.main; @@ -806,14 +806,14 @@ Main *CTX_data_main(const bContext *C) void CTX_data_main_set(bContext *C, Main *bmain) { - C->data.main= bmain; + C->data.main = bmain; } Scene *CTX_data_scene(const bContext *C) { Scene *scene; - if (ctx_data_pointer_verify(C, "scene", (void*)&scene)) + if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) return scene; else return C->data.scene; @@ -821,7 +821,7 @@ Scene *CTX_data_scene(const bContext *C) int CTX_data_mode_enum(const bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit) { switch (obedit->type) { @@ -846,7 +846,7 @@ int CTX_data_mode_enum(const bContext *C) if (ob) { if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE; - else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; + else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT; else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX; else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE; @@ -884,7 +884,7 @@ const char *CTX_data_mode_string(const bContext *C) void CTX_data_scene_set(bContext *C, Scene *scene) { - C->data.scene= scene; + C->data.scene = scene; } ToolSettings *CTX_data_tool_settings(const bContext *C) diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 54655cf8582..51f8815fbd1 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -82,10 +82,10 @@ * the queue store a list of freenodes to avoid successive alloc/dealloc */ -DagNodeQueue * queue_create (int slots) +DagNodeQueue *queue_create(int slots) { - DagNodeQueue * queue; - DagNodeQueueElem * elem; + DagNodeQueue *queue; + DagNodeQueueElem *elem; int i; queue = MEM_mallocN(sizeof(DagNodeQueue), "DAG queue"); @@ -98,7 +98,7 @@ DagNodeQueue * queue_create (int slots) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i node = NULL; elem->next = NULL; @@ -111,7 +111,7 @@ DagNodeQueue * queue_create (int slots) void queue_raz(DagNodeQueue *queue) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; elem = queue->first; if (queue->freenodes->last) @@ -132,8 +132,8 @@ void queue_raz(DagNodeQueue *queue) void queue_delete(DagNodeQueue *queue) { - DagNodeQueueElem * elem; - DagNodeQueueElem * temp; + DagNodeQueueElem *elem; + DagNodeQueueElem *temp; elem = queue->first; while (elem) { @@ -156,7 +156,7 @@ void queue_delete(DagNodeQueue *queue) /* insert in queue, remove in front */ void push_queue(DagNodeQueue *queue, DagNode *node) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; int i; if (node == NULL) { @@ -168,7 +168,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node) elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; - if ( queue->freenodes->last == elem) { + if (queue->freenodes->last == elem) { queue->freenodes->last = NULL; queue->freenodes->first = NULL; } @@ -180,7 +180,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i node = NULL; elem->next = NULL; @@ -207,13 +207,13 @@ void push_queue(DagNodeQueue *queue, DagNode *node) /* insert in front, remove in front */ void push_stack(DagNodeQueue *queue, DagNode *node) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; int i; elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; - if ( queue->freenodes->last == elem) { + if (queue->freenodes->last == elem) { queue->freenodes->last = NULL; queue->freenodes->first = NULL; } @@ -225,7 +225,7 @@ void push_stack(DagNodeQueue *queue, DagNode *node) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i node = NULL; elem->next = NULL; @@ -246,24 +246,24 @@ void push_stack(DagNodeQueue *queue, DagNode *node) } -DagNode * pop_queue(DagNodeQueue *queue) +DagNode *pop_queue(DagNodeQueue *queue) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; DagNode *node; elem = queue->first; if (elem) { queue->first = elem->next; if (queue->last == elem) { - queue->last=NULL; - queue->first=NULL; + queue->last = NULL; + queue->first = NULL; } queue->count--; if (queue->freenodes->last) - queue->freenodes->last->next=elem; - queue->freenodes->last=elem; + queue->freenodes->last->next = elem; + queue->freenodes->last = elem; if (queue->freenodes->first == NULL) - queue->freenodes->first=elem; + queue->freenodes->first = elem; node = elem->node; elem->node = NULL; elem->next = NULL; @@ -276,17 +276,17 @@ DagNode * pop_queue(DagNodeQueue *queue) } } -void *pop_ob_queue(struct DagNodeQueue *queue) +void *pop_ob_queue(struct DagNodeQueue *queue) { return(pop_queue(queue)->ob); } -DagNode * get_top_node_queue(DagNodeQueue *queue) +DagNode *get_top_node_queue(DagNodeQueue *queue) { return queue->first->node; } -int queue_count(struct DagNodeQueue *queue) +int queue_count(struct DagNodeQueue *queue) { return queue->count; } @@ -307,37 +307,37 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node FCurve *fcu; DagNode *node1; - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { - ChannelDriver *driver= fcu->driver; + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { + ChannelDriver *driver = fcu->driver; DriverVar *dvar; int isdata_fcu = isdata || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); /* loop over variables to get the target relationships */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* only used targets */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id) { // FIXME: other data types need to be added here so that they can work! - if (GS(dtar->id->name)==ID_OB) { - Object *ob= (Object *)dtar->id; + if (GS(dtar->id->name) == ID_OB) { + Object *ob = (Object *)dtar->id; /* normal channel-drives-channel */ node1 = dag_get_node(dag, dtar->id); /* check if bone... */ - if ((ob->type==OB_ARMATURE) && - ( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) || - ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) )) + if ((ob->type == OB_ARMATURE) && + ( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) || + ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) )) { - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver"); } /* check if ob data */ else if (dtar->rna_path && strstr(dtar->rna_path, "data.")) - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver"); /* normal */ else - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_OB_DATA : DAG_RL_OB_OB, "Driver"); } } } @@ -353,12 +353,12 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec // would be nice to have a list of colliders here // so for now walk all objects in scene check 'same layer rule' - for (base = scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->lay & ob->lay) && base->object->pd) { - Object *ob1= base->object; + Object *ob1 = base->object; if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { node2 = dag_get_node(dag, ob1); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision"); } } } @@ -367,16 +367,16 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, Object *ob, int mask) { bConstraint *con; - DagNode * node; - DagNode * node2; - DagNode * node3; + DagNode *node; + DagNode *node2; + DagNode *node3; Key *key; ParticleSystem *psys; - int addtoroot= 1; + int addtoroot = 1; node = dag_get_node(dag, ob); - if ((ob->data) && (mask&DAG_RL_DATA)) { + if ((ob->data) && (mask & DAG_RL_DATA)) { node2 = dag_get_node(dag, ob->data); dag_add_relation(dag, node, node2, DAG_RL_DATA, "Object-Data Relation"); node2->first_ancestor = ob; @@ -384,34 +384,34 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* also build a custom data mask for dependencies that need certain layers */ - node->customdata_mask= 0; + node->customdata_mask = 0; if (ob->type == OB_ARMATURE) { if (ob->pose) { bPoseChannel *pchan; bConstraint *con; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar && ct->tar != ob) { // fprintf(stderr, "armature %s target :%s\n", ob->id.name, target->id.name); node3 = dag_get_node(dag, ct->tar); if (ct->subtarget[0]) { - dag_add_relation(dag, node3, node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, cti->name); if (ct->tar->type == OB_MESH) node3->customdata_mask |= CD_MASK_MDEFORMVERT; } else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) - dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, cti->name); else dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name); } @@ -431,13 +431,13 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ob->nlastrips.first) { bActionStrip *strip; bActionChannel *chan; - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->modifiers.first) { bActionModifier *amod; - for (amod= strip->modifiers.first; amod; amod= amod->next) { + for (amod = strip->modifiers.first; amod; amod = amod->next) { if (amod->ob) { node2 = dag_get_node(dag, amod->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "NLA Strip Modifier"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "NLA Strip Modifier"); } } } @@ -445,16 +445,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } #endif // XXX old animation system if (ob->adt) - dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation + dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation - key= ob_get_key(ob); + key = ob_get_key(ob); if (key && key->adt) dag_add_driver_relation(key->adt, dag, node, 1); if (ob->modifiers.first) { ModifierData *md; - for (md=ob->modifiers.first; md; md=md->next) { + for (md = ob->modifiers.first; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->updateDepgraph) mti->updateDepgraph(md, dag, scene, ob, node); @@ -465,22 +465,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O switch (ob->partype) { case PARSKEL: - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Parent"); break; case PARVERT1: case PARVERT3: - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Vertex Parent"); node2->customdata_mask |= CD_MASK_ORIGINDEX; break; case PARBONE: - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Bone Parent"); break; default: - if (ob->parent->type==OB_LATTICE) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent"); - else if (ob->parent->type==OB_CURVE) { - Curve *cu= ob->parent->data; + if (ob->parent->type == OB_LATTICE) + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Lattice Parent"); + else if (ob->parent->type == OB_CURVE) { + Curve *cu = ob->parent->data; if (cu->flag & CU_PATH) - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Curve Parent"); else dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Curve Parent"); } @@ -488,22 +488,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Parent"); } /* exception case: parent is duplivert */ - if (ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Duplivert"); + if (ob->type == OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Duplivert"); } addtoroot = 0; } if (ob->proxy) { node2 = dag_get_node(dag, ob->proxy); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Proxy"); + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Proxy"); /* inverted relation, so addtoroot shouldn't be set to zero */ } if (ob->transflag & OB_DUPLI) { if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { GroupObject *go; - for (go= ob->dup_group->gobject.first; go; go= go->next) { + for (go = ob->dup_group->gobject.first; go; go = go->next) { if (go->ob) { node2 = dag_get_node(dag, go->ob); /* node2 changes node1, this keeps animations updated in groups?? not logical? */ @@ -514,14 +514,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* softbody collision */ - if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) { + if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { if (modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first) - dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ + dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ } /* object data drivers */ if (ob->data) { - AnimData *adt= BKE_animdata_from_id((ID *)ob->data); + AnimData *adt = BKE_animdata_from_id((ID *)ob->data); if (adt) dag_add_driver_relation(adt, dag, node, 1); } @@ -537,49 +537,49 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Camera DoF"); } } - break; + break; case OB_MBALL: { - Object *mom= BKE_metaball_basis_find(scene, ob); + Object *mom = BKE_metaball_basis_find(scene, ob); - if (mom!=ob) { + if (mom != ob) { node2 = dag_get_node(dag, mom); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children! + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); // mom depends on children! } } - break; + break; case OB_CURVE: case OB_FONT: { - Curve *cu= ob->data; + Curve *cu = ob->data; if (cu->bevobj) { node2 = dag_get_node(dag, cu->bevobj); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Bevel"); } if (cu->taperobj) { node2 = dag_get_node(dag, cu->taperobj); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Taper"); } if (ob->type == OB_FONT) { if (cu->textoncurve) { node2 = dag_get_node(dag, cu->textoncurve); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Texture On Curve"); } } } - break; + break; } /* particles */ - psys= ob->particlesystem.first; + psys = ob->particlesystem.first; if (psys) { GroupObject *go; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { BoidRule *rule = NULL; BoidState *state = NULL; - ParticleSettings *part= psys->part; + ParticleSettings *part = psys->part; ListBase *effectors = NULL; EffectorCache *eff; @@ -591,12 +591,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { ParticleTarget *pt = psys->targets.first; - for (; pt; pt=pt->next) { - if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys-1)) { + for (; pt; pt = pt->next) { + if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys - 1)) { node2 = dag_get_node(dag, pt->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Targets"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Targets"); } - } + } } if (part->ren_as == PART_DRAW_OB && part->dup_ob) { @@ -610,7 +610,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } if (part->ren_as == PART_DRAW_GR && part->dup_group) { - for (go=part->dup_group->gobject.first; go; go=go->next) { + for (go = part->dup_group->gobject.first; go; go = go->next) { node2 = dag_get_node(dag, go->ob); dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation"); } @@ -618,23 +618,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O effectors = pdInitEffectors(scene, ob, psys, part->effector_weights); - if (effectors) for (eff = effectors->first; eff; eff=eff->next) { - if (eff->psys) { - node2 = dag_get_node(dag, eff->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Field"); + if (effectors) { + for (eff = effectors->first; eff; eff = eff->next) { + if (eff->psys) { + node2 = dag_get_node(dag, eff->ob); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Field"); + } } } pdEndEffectors(&effectors); if (part->boids) { - for (state = part->boids->states.first; state; state=state->next) { - for (rule = state->rules.first; rule; rule=rule->next) { + for (state = part->boids->states.first; state; state = state->next) { + for (rule = state->rules.first; rule; rule = rule->next) { Object *ruleob = NULL; - if (rule->type==eBoidRuleType_Avoid) - ruleob = ((BoidRuleGoalAvoid*)rule)->ob; - else if (rule->type==eBoidRuleType_FollowLeader) - ruleob = ((BoidRuleFollowLeader*)rule)->ob; + if (rule->type == eBoidRuleType_Avoid) + ruleob = ((BoidRuleGoalAvoid *)rule)->ob; + else if (rule->type == eBoidRuleType_FollowLeader) + ruleob = ((BoidRuleFollowLeader *)rule)->ob; if (ruleob) { node2 = dag_get_node(dag, ruleob); @@ -647,8 +649,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* object constraints */ - for (con = ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -657,25 +659,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O /* special case for camera tracking -- it doesn't use targets to define relations */ if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) { - int depends_on_camera= 0; + int depends_on_camera = 0; - if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) { - bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data; + if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) { + bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data; - if ((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0]) - depends_on_camera= 1; + if ((data->clip || data->flag & FOLLOWTRACK_ACTIVECLIP) && data->track[0]) + depends_on_camera = 1; if (data->depth_ob) { node2 = dag_get_node(dag, data->depth_ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); } } - else if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) - depends_on_camera= 1; + else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) + depends_on_camera = 1; if (depends_on_camera && scene->camera) { node2 = dag_get_node(dag, scene->camera); - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); } dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); @@ -684,20 +686,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O else if (cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { Object *obt; if (ct->tar) - obt= ct->tar; + obt = ct->tar; else continue; node2 = dag_get_node(dag, obt); if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); else { if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); if (obt->type == OB_MESH) node2->customdata_mask |= CD_MASK_MDEFORMVERT; } @@ -712,12 +714,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } } - if (addtoroot == 1 ) + if (addtoroot == 1) dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); } -struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) -{ +struct DagForest *build_dag(Main *bmain, Scene *sce, short mask){ Base *base; Object *ob; Group *group; @@ -728,8 +729,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) DagAdjList *itA; dag = sce->theDag; - sce->dagisvalid=1; - if ( dag) + sce->dagisvalid = 1; + if (dag) free_forest(dag); else { dag = dag_init(); @@ -740,8 +741,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) scenenode = dag_add_node(dag, sce); /* add current scene objects */ - for (base = sce->base.first; base; base= base->next) { - ob= base->object; + for (base = sce->base.first; base; base = base->next) { + ob = base->object; build_dag_object(dag, scenenode, sce, ob, mask); if (ob->proxy) @@ -753,9 +754,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) } /* add groups used in current scene objects */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { build_dag_object(dag, scenenode, sce, go->ob, mask); } group->id.flag &= ~LIB_DOIT; @@ -767,23 +768,23 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) * the relation type has to be synced. One of the parents can change, and should give same event to child */ /* nodes were callocced, so we can use node->color for temporal storage */ - for (node = sce->theDag->DagNode.first; node; node= node->next) { - if (node->type==ID_OB) { - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { itA->node->color |= itA->type; } } /* also flush custom data mask */ - ((Object*)node->ob)->customdata_mask= node->customdata_mask; + ((Object *)node->ob)->customdata_mask = node->customdata_mask; } } /* now set relations equal, so that when only one parent changes, the correct recalcs are found */ - for (node = sce->theDag->DagNode.first; node; node= node->next) { - if (node->type==ID_OB) { - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { itA->type |= itA->node->color; } } @@ -825,14 +826,14 @@ void free_forest(DagForest *Dag) } BLI_ghash_free(Dag->nodeHash, NULL, NULL); - Dag->nodeHash= NULL; + Dag->nodeHash = NULL; Dag->DagNode.first = NULL; Dag->DagNode.last = NULL; Dag->numNodes = 0; } -DagNode * dag_find_node (DagForest *forest, void * fob) +DagNode *dag_find_node(DagForest *forest, void *fob) { if (forest->nodeHash) return BLI_ghash_lookup(forest->nodeHash, fob); @@ -840,11 +841,11 @@ DagNode * dag_find_node (DagForest *forest, void * fob) return NULL; } -static int ugly_hack_sorry= 1; // prevent type check -static int dag_print_dependencies= 0; // debugging +static int ugly_hack_sorry = 1; // prevent type check +static int dag_print_dependencies = 0; // debugging /* no checking of existence, use dag_find_node first or dag_get_node */ -DagNode * dag_add_node (DagForest *forest, void * fob) +DagNode *dag_add_node(DagForest *forest, void *fob) { DagNode *node; @@ -853,7 +854,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) node->ob = fob; node->color = DAG_WHITE; - if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting + if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting if (forest->numNodes) { ((DagNode *) forest->DagNode.last)->next = node; forest->DagNode.last = node; @@ -866,18 +867,18 @@ DagNode * dag_add_node (DagForest *forest, void * fob) } if (!forest->nodeHash) - forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); + forest->nodeHash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); BLI_ghash_insert(forest->nodeHash, fob, node); } return node; } -DagNode * dag_get_node (DagForest *forest, void * fob) +DagNode *dag_get_node(DagForest *forest, void *fob) { DagNode *node; - node = dag_find_node (forest, fob); + node = dag_find_node(forest, fob); if (!node) node = dag_add_node(forest, fob); return node; @@ -885,10 +886,10 @@ DagNode * dag_get_node (DagForest *forest, void * fob) -DagNode * dag_get_sub_node (DagForest *forest, void * fob) +DagNode *dag_get_sub_node(DagForest *forest, void *fob) { DagNode *node; - DagAdjList *mainchild, *prev=NULL; + DagAdjList *mainchild, *prev = NULL; mainchild = ((DagNode *) forest->DagNode.first)->child; /* remove from first node (scene) adj list if present */ @@ -908,7 +909,7 @@ DagNode * dag_get_sub_node (DagForest *forest, void * fob) prev = mainchild; mainchild = mainchild->next; } - node = dag_find_node (forest, fob); + node = dag_find_node(forest, fob); if (!node) node = dag_add_node(forest, fob); return node; @@ -966,9 +967,9 @@ static const char *dag_node_name(DagNode *node) if (node->ob == NULL) return "null"; else if (ugly_hack_sorry) - return ((ID*)(node->ob))->name+2; + return ((ID *)(node->ob))->name + 2; else - return ((bPoseChannel*)(node->ob))->name; + return ((bPoseChannel *)(node->ob))->name; } static void dag_node_print_dependencies(DagNode *node) @@ -977,7 +978,7 @@ static void dag_node_print_dependencies(DagNode *node) printf("%s depends on:\n", dag_node_name(node)); - for (itA= node->parent; itA; itA= itA->next) + for (itA = node->parent; itA; itA = itA->next) printf(" %s through %s\n", dag_node_name(itA->node), itA->name); printf("\n"); } @@ -989,12 +990,12 @@ static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) if (node->color == DAG_BLACK) return 0; - node->color= DAG_BLACK; + node->color = DAG_BLACK; if (node == endnode) return 1; - for (itA= node->parent; itA; itA= itA->next) { + for (itA = node->parent; itA; itA = itA->next) { if (dag_node_print_dependency_recurs(itA->node, endnode)) { printf(" %s depends on %s through %s.\n", dag_node_name(node), dag_node_name(itA->node), itA->name); return 1; @@ -1008,8 +1009,8 @@ static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode, { DagNode *node; - for (node = dag->DagNode.first; node; node= node->next) - node->color= DAG_WHITE; + for (node = dag->DagNode.first; node; node = node->next) + node->color = DAG_WHITE; printf(" %s depends on %s through %s.\n", dag_node_name(endnode), dag_node_name(startnode), name); dag_node_print_dependency_recurs(startnode, endnode); @@ -1021,16 +1022,16 @@ static int dag_node_recurs_level(DagNode *node, int level) DagAdjList *itA; int newlevel; - node->color= DAG_BLACK; /* done */ - newlevel= ++level; + node->color = DAG_BLACK; /* done */ + newlevel = ++level; - for (itA= node->parent; itA; itA= itA->next) { - if (itA->node->color==DAG_WHITE) { - itA->node->ancestor_count= dag_node_recurs_level(itA->node, level); - newlevel= MAX2(newlevel, level+itA->node->ancestor_count); + for (itA = node->parent; itA; itA = itA->next) { + if (itA->node->color == DAG_WHITE) { + itA->node->ancestor_count = dag_node_recurs_level(itA->node, level); + newlevel = MAX2(newlevel, level + itA->node->ancestor_count); } else - newlevel= MAX2(newlevel, level+itA->node->ancestor_count); + newlevel = MAX2(newlevel, level + itA->node->ancestor_count); } return newlevel; @@ -1043,22 +1044,22 @@ static void dag_check_cycle(DagForest *dag) /* debugging print */ if (dag_print_dependencies) - for (node = dag->DagNode.first; node; node= node->next) + for (node = dag->DagNode.first; node; node = node->next) dag_node_print_dependencies(node); /* tag nodes unchecked */ - for (node = dag->DagNode.first; node; node= node->next) - node->color= DAG_WHITE; + for (node = dag->DagNode.first; node; node = node->next) + node->color = DAG_WHITE; - for (node = dag->DagNode.first; node; node= node->next) { - if (node->color==DAG_WHITE) { - node->ancestor_count= dag_node_recurs_level(node, 0); + for (node = dag->DagNode.first; node; node = node->next) { + if (node->color == DAG_WHITE) { + node->ancestor_count = dag_node_recurs_level(node, 0); } } /* check relations, and print errors */ - for (node = dag->DagNode.first; node; node= node->next) { - for (itA= node->parent; itA; itA= itA->next) { + for (node = dag->DagNode.first; node; node = node->next) { + for (itA = node->parent; itA; itA = itA->next) { if (itA->node->ancestor_count > node->ancestor_count) { if (node->ob && itA->node->ob) { printf("Dependency cycle detected:\n"); @@ -1069,7 +1070,7 @@ static void dag_check_cycle(DagForest *dag) } /* parent relations are only needed for cycle checking, so free now */ - for (node = dag->DagNode.first; node; node= node->next) { + for (node = dag->DagNode.first; node; node = node->next) { while (node->parent) { itA = node->parent->next; MEM_freeN(node->parent); @@ -1082,7 +1083,7 @@ static void dag_check_cycle(DagForest *dag) * MainDAG is the DAG of all objects in current scene * used only for drawing there is one also in each scene */ -static DagForest * MainDag = NULL; +static DagForest *MainDag = NULL; DagForest *getMainDag(void) { @@ -1121,7 +1122,7 @@ void graph_bfs(void) /* fprintf(stderr, "starting BFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); - for ( i=0; i<50; i++) + for (i = 0; i < 50; i++) pos[i] = 0; /* Init @@ -1160,14 +1161,14 @@ void graph_bfs(void) itA = itA->next; } - if (pos[node->BFS_dist] > node->k ) { + if (pos[node->BFS_dist] > node->k) { pos[node->BFS_dist] += 1; node->k = (float) pos[node->BFS_dist]; } else { - pos[node->BFS_dist] = (int) node->k +1; + pos[node->BFS_dist] = (int) node->k + 1; } - set_node_xy(node, node->BFS_dist*DEPSX*2, pos[node->BFS_dist]*DEPSY*2); + set_node_xy(node, node->BFS_dist * DEPSX * 2, pos[node->BFS_dist] * DEPSY * 2); node->color = DAG_BLACK; // fprintf(stderr, "BFS node : %20s %i %5.0f %5.0f\n", ((ID *) node->ob)->name, node->BFS_dist, node->x, node->y); @@ -1190,7 +1191,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a DagNode *node; DagNodeQueue *nqueue; DagAdjList *itA; - int retval = 0; + int retval = 0; /* fprintf(stderr, "starting BFS\n ------------\n"); */ /* Init @@ -1238,7 +1239,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a } /* non recursive version of DFS, return queue -- outer loop present to catch odd cases (first level cycles)*/ -DagNodeQueue * graph_dfs(void) +DagNodeQueue *graph_dfs(void) { DagNode *node; DagNodeQueue *nqueue; @@ -1249,14 +1250,14 @@ DagNodeQueue * graph_dfs(void) int time; int skip = 0; int minheight; - int maxpos=0; + int maxpos = 0; /* int is_cycle = 0; */ /* UNUSED */ /* - *fprintf(stderr, "starting DFS\n ------------\n"); + *fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); retqueue = queue_create(MainDag->numNodes); - for ( i=0; i<50; i++) + for (i = 0; i < 50; i++) pos[i] = 0; /* Init @@ -1276,86 +1277,86 @@ DagNodeQueue * graph_dfs(void) node = MainDag->DagNode.first; do { - if (node->color == DAG_WHITE) { - node->color = DAG_GRAY; - node->DFS_dist = 1; - node->DFS_dvtm = time; - time++; - push_stack(nqueue, node); + if (node->color == DAG_WHITE) { + node->color = DAG_GRAY; + node->DFS_dist = 1; + node->DFS_dvtm = time; + time++; + push_stack(nqueue, node); - while (nqueue->count) { - //graph_print_queue(nqueue); + while (nqueue->count) { + //graph_print_queue(nqueue); - skip = 0; - node = get_top_node_queue(nqueue); + skip = 0; + node = get_top_node_queue(nqueue); - minheight = pos[node->DFS_dist]; + minheight = pos[node->DFS_dist]; - itA = node->child; - while (itA != NULL) { - if (itA->node->color == DAG_WHITE) { - itA->node->DFS_dvtm = time; - itA->node->color = DAG_GRAY; + itA = node->child; + while (itA != NULL) { + if (itA->node->color == DAG_WHITE) { + itA->node->DFS_dvtm = time; + itA->node->color = DAG_GRAY; - time++; - itA->node->DFS_dist = node->DFS_dist + 1; - itA->node->k = (float) minheight; - push_stack(nqueue, itA->node); - skip = 1; - break; - } - else { - if (itA->node->color == DAG_GRAY) { // back edge - fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); - /* is_cycle = 1; */ /* UNUSED */ + time++; + itA->node->DFS_dist = node->DFS_dist + 1; + itA->node->k = (float) minheight; + push_stack(nqueue, itA->node); + skip = 1; + break; } - else if (itA->node->color == DAG_BLACK) { - /* already processed node but we may want later to change distance either to shorter to longer. - * DFS_dist is the first encounter - */ + else { + if (itA->node->color == DAG_GRAY) { // back edge + fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); + /* is_cycle = 1; */ /* UNUSED */ + } + else if (itA->node->color == DAG_BLACK) { + /* already processed node but we may want later to change distance either to shorter to longer. + * DFS_dist is the first encounter + */ #if 0 - if (node->DFS_dist >= itA->node->DFS_dist) - itA->node->DFS_dist = node->DFS_dist + 1; + if (node->DFS_dist >= itA->node->DFS_dist) + itA->node->DFS_dist = node->DFS_dist + 1; fprintf(stderr, "dfs forward or cross edge :%15s %i-%i %15s %i-%i\n", - ((ID *) node->ob)->name, - node->DFS_dvtm, - node->DFS_fntm, - ((ID *) itA->node->ob)->name, - itA->node->DFS_dvtm, - itA->node->DFS_fntm); + ((ID *) node->ob)->name, + node->DFS_dvtm, + node->DFS_fntm, + ((ID *) itA->node->ob)->name, + itA->node->DFS_dvtm, + itA->node->DFS_fntm); #endif + } + else + fprintf(stderr, "dfs unknown edge\n"); } - else - fprintf(stderr, "dfs unknown edge\n"); + itA = itA->next; } - itA = itA->next; - } - if (!skip) { - node = pop_queue(nqueue); - node->color = DAG_BLACK; + if (!skip) { + node = pop_queue(nqueue); + node->color = DAG_BLACK; - node->DFS_fntm = time; - time++; - if (node->DFS_dist > maxpos) - maxpos = node->DFS_dist; - if (pos[node->DFS_dist] > node->k ) { - pos[node->DFS_dist] += 1; - node->k = (float) pos[node->DFS_dist]; - } - else { - pos[node->DFS_dist] = (int) node->k +1; - } - set_node_xy(node, node->DFS_dist*DEPSX*2, pos[node->DFS_dist]*DEPSY*2); + node->DFS_fntm = time; + time++; + if (node->DFS_dist > maxpos) + maxpos = node->DFS_dist; + if (pos[node->DFS_dist] > node->k) { + pos[node->DFS_dist] += 1; + node->k = (float) pos[node->DFS_dist]; + } + else { + pos[node->DFS_dist] = (int) node->k + 1; + } + set_node_xy(node, node->DFS_dist * DEPSX * 2, pos[node->DFS_dist] * DEPSY * 2); - // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); + // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); - push_stack(retqueue, node); + push_stack(retqueue, node); + } } } - } node = node->next; } while (node); // fprintf(stderr, "i size : %i\n", maxpos); @@ -1382,7 +1383,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a int skip = 0; int retval = 0; /* - *fprintf(stderr, "starting DFS\n ------------\n"); + * fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); @@ -1429,7 +1430,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a break; } else { - if (itA->node->color == DAG_GRAY) {// back edge + if (itA->node->color == DAG_GRAY) { // back edge retval = 1; } // else if (itA->node->color == DAG_BLACK) { // cross or forward @@ -1457,14 +1458,13 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a // used to get the obs owning a datablock -struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) -{ - DagNode * node, *node1; +struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob){ + DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; node = dag_find_node(dag, ob); - if (node==NULL) { + if (node == NULL) { return NULL; } else if (node->ancestor_count == 1) { // simple case @@ -1491,9 +1491,8 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) return nqueue; } -struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) -{ - DagNode * node, *node1; +struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob){ + DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; @@ -1520,8 +1519,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) } // standard DFS list -struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) -{ +struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob){ DagNode *node; DagNodeQueue *nqueue; DagNodeQueue *retqueue; @@ -1581,9 +1579,9 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) /* unused */ #if 0 -short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) +short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) { - DagNode * node; + DagNode *node; DagAdjList *itA; node = dag_find_node(dag, ob1); @@ -1599,7 +1597,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) } #endif -int is_acyclic(DagForest *dag) +int is_acyclic(DagForest *dag) { return dag->is_acyclic; } @@ -1634,9 +1632,9 @@ void graph_print_queue_dist(DagNodeQueue *nqueue) count = 0; while (queueElem) { fprintf(stderr, "** %25s %2.2i-%2.2i ", ((ID *) queueElem->node->ob)->name, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm); - while (count < queueElem->node->DFS_dvtm-1) { fputc(' ', stderr); count++;} + while (count < queueElem->node->DFS_dvtm - 1) { fputc(' ', stderr); count++; } fputc('|', stderr); - while (count < queueElem->node->DFS_fntm-2) { fputc('-', stderr); count++;} + while (count < queueElem->node->DFS_fntm - 2) { fputc('-', stderr); count++; } fputc('|', stderr); fputc('\n', stderr); count = 0; @@ -1668,13 +1666,13 @@ void graph_print_adj_list(void) /* mechanism to allow editors to be informed of depsgraph updates, * to do their own updates based on changes... */ -static void (*EditorsUpdateIDCb)(Main *bmain, ID *id)= NULL; -static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated)= NULL; +static void (*EditorsUpdateIDCb)(Main *bmain, ID *id) = NULL; +static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated) = NULL; void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated)) { - EditorsUpdateIDCb= id_func; - EditorsUpdateSceneCb= scene_func; + EditorsUpdateIDCb = id_func; + EditorsUpdateSceneCb = scene_func; } static void dag_editors_id_update(Main *bmain, ID *id) @@ -1698,37 +1696,37 @@ static void scene_sort_groups(Main *bmain, Scene *sce) Object *ob; /* test; are group objects all in this scene? */ - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ob->id.flag &= ~LIB_DOIT; - ob->id.newid= NULL; /* newid abuse for GroupObject */ + ob->id.newid = NULL; /* newid abuse for GroupObject */ } - for (base = sce->base.first; base; base= base->next) + for (base = sce->base.first; base; base = base->next) base->object->id.flag |= LIB_DOIT; - for (group= bmain->group.first; group; group= group->id.next) { - for (go= group->gobject.first; go; go= go->next) { - if ((go->ob->id.flag & LIB_DOIT)==0) + for (group = bmain->group.first; group; group = group->id.next) { + for (go = group->gobject.first; go; go = go->next) { + if ((go->ob->id.flag & LIB_DOIT) == 0) break; } /* this group is entirely in this scene */ - if (go==NULL) { - ListBase listb= {NULL, NULL}; + if (go == NULL) { + ListBase listb = {NULL, NULL}; - for (go= group->gobject.first; go; go= go->next) - go->ob->id.newid= (ID *)go; + for (go = group->gobject.first; go; go = go->next) + go->ob->id.newid = (ID *)go; /* in order of sorted bases we reinsert group objects */ - for (base = sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { if (base->object->id.newid) { - go= (GroupObject *)base->object->id.newid; - base->object->id.newid= NULL; + go = (GroupObject *)base->object->id.newid; + base->object->id.newid = NULL; BLI_remlink(&group->gobject, go); BLI_addtail(&listb, go); } } /* copy the newly sorted listbase */ - group->gobject= listb; + group->gobject = listb; } } } @@ -1744,7 +1742,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) ListBase tempbase; Base *base; - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA); @@ -1752,7 +1750,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) nqueue = queue_create(DAGQUEUEALLOC); - for (node = sce->theDag->DagNode.first; node; node= node->next) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { node->color = DAG_WHITE; } @@ -1785,7 +1783,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == sce) // we are done + if (node->ob == sce) // we are done break; node->color = DAG_BLACK; @@ -1807,7 +1805,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) BLI_remlink(&sce->base, base); BLI_addhead(&tempbase, base); //if (G.debug & G_DEBUG) - printf("cyclic %s\n", base->object->id.name); + printf("cyclic %s\n", base->object->id.name); base = sce->base.first; } @@ -1819,12 +1817,12 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (G.debug & G_DEBUG) { printf("\nordered\n"); - for (base = sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { printf(" %s\n", base->object->id.name); } } /* temporal...? */ - sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ + sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ } static void lib_id_recalc_tag(Main *bmain, ID *id) @@ -1842,26 +1840,26 @@ static void lib_id_recalc_data_tag(Main *bmain, ID *id) /* node was checked to have lasttime != curtime and is if type ID_OB */ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) { - Main *bmain= G.main; + Main *bmain = G.main; DagAdjList *itA; Object *ob, *obc; - int oldflag, changed=0; + int oldflag, changed = 0; unsigned int all_layer; - node->lasttime= curtime; + node->lasttime = curtime; - ob= node->ob; + ob = node->ob; if (ob && (ob->recalc & OB_RECALC_ALL)) { - all_layer= node->scelay; + all_layer = node->scelay; /* got an object node that changes, now check relations */ - for (itA = node->child; itA; itA= itA->next) { + for (itA = node->child; itA; itA = itA->next) { all_layer |= itA->lay; /* the relationship is visible */ if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) - if (itA->node->type==ID_OB) { - obc= itA->node->ob; - oldflag= obc->recalc; + if (itA->node->type == ID_OB) { + obc = itA->node->ob; + oldflag = obc->recalc; /* got a ob->obc relation, now check if flag needs flush */ if (ob->recalc & OB_RECALC_OB) { @@ -1888,12 +1886,12 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) lib_id_recalc_data_tag(bmain, &obc->id); } } - if (oldflag!=obc->recalc) changed= 1; + if (oldflag != obc->recalc) changed = 1; } } } /* even nicer, we can clear recalc flags... */ - if ((all_layer & layer)==0) { // XXX && (ob != obedit)) { + if ((all_layer & layer) == 0) { // XXX && (ob != obedit)) { /* but existing displaylists or derivedmesh should be freed */ if (ob->recalc & OB_RECALC_DATA) BKE_object_free_display(ob); @@ -1905,15 +1903,15 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) /* check case where child changes and parent forcing obdata to change */ /* should be done regardless if this ob has recalc set */ /* could merge this in with loop above...? (ton) */ - for (itA = node->child; itA; itA= itA->next) { + for (itA = node->child; itA; itA = itA->next) { /* the relationship is visible */ - if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) - if (itA->node->type==ID_OB) { - obc= itA->node->ob; + if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) + if (itA->node->type == ID_OB) { + obc = itA->node->ob; /* child moves */ - if ((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) { + if ((obc->recalc & OB_RECALC_ALL) == OB_RECALC_OB) { /* parent has deforming info */ - if (itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) { + if (itA->type & (DAG_RL_OB_DATA | DAG_RL_DATA_DATA)) { // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obc->id); @@ -1924,8 +1922,8 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) } /* we only go deeper if node not checked or something changed */ - for (itA = node->child; itA; itA= itA->next) { - if (changed || itA->node->lasttime!=curtime) + for (itA = node->child; itA; itA = itA->next) { + if (changed || itA->node->lasttime != curtime) flush_update_node(itA->node, layer, curtime); } @@ -1936,15 +1934,15 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) { DagAdjList *itA; - node->lasttime= curtime; - node->lay= node->scelay; + node->lasttime = curtime; + node->lay = node->scelay; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { - if (itA->node->lasttime!=curtime) { - itA->lay= flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { + if (itA->node->lasttime != curtime) { + itA->lay = flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation } - else itA->lay= itA->node->lay; + else itA->lay = itA->node->lay; node->lay |= itA->lay; } @@ -1956,16 +1954,16 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) /* node was checked to have lasttime != curtime, and is of type ID_OB */ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset) { - Main *bmain= G.main; + Main *bmain = G.main; DagAdjList *itA; Object *ob; - node->lasttime= curtime; + node->lasttime = curtime; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { - if (itA->node->lasttime!=curtime) { - ob= (Object*)(itA->node->ob); + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { + if (itA->node->lasttime != curtime) { + ob = (Object *)(itA->node->ob); if (reset || (ob->recalc & OB_RECALC_ALL)) { if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) { @@ -1990,18 +1988,18 @@ static void dag_scene_flush_layers(Scene *sce, int lay) Base *base; int lasttime; - firstnode= sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; // always scene node - for (itA = firstnode->child; itA; itA= itA->next) - itA->lay= 0; + for (itA = firstnode->child; itA; itA = itA->next) + itA->lay = 0; - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; /* update layer flags in nodes */ - for (base= sce->base.first; base; base= base->next) { - node= dag_get_node(sce->theDag, base->object); - node->scelay= base->object->lay; + for (base = sce->base.first; base; base = base->next) { + node = dag_get_node(sce->theDag, base->object); + node->scelay = base->object->lay; } /* ensure cameras are set as if they are on a visible layer, because @@ -2009,7 +2007,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay) * * XXX, this wont work for local view / unlocked camera's */ if (sce->camera) { - node= dag_get_node(sce->theDag, sce->camera); + node = dag_get_node(sce->theDag, sce->camera); node->scelay |= lay; } @@ -2017,9 +2015,9 @@ static void dag_scene_flush_layers(Scene *sce, int lay) { TimeMarker *m; - for (m= sce->markers.first; m; m= m->next) { + for (m = sce->markers.first; m; m = m->next) { if (m->camera) { - node= dag_get_node(sce->theDag, m->camera); + node = dag_get_node(sce->theDag, m->camera); node->scelay |= lay; } } @@ -2027,8 +2025,8 @@ static void dag_scene_flush_layers(Scene *sce, int lay) #endif /* flush layer nodes to dependencies */ - for (itA = firstnode->child; itA; itA= itA->next) - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) + for (itA = firstnode->child; itA; itA = itA->next) + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) flush_layer_node(sce, itA->node, lasttime); } @@ -2037,16 +2035,16 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay) if (sce->nodetree) { bNode *node; Base *base; - unsigned int lay_changed= 0; + unsigned int lay_changed = 0; - for (base= sce->base.first; base; base= base->next) + for (base = sce->base.first; base; base = base->next) if (base->lay & lay) if (base->object->recalc) lay_changed |= base->lay; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)sce) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)sce) { + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl && (srl->lay & lay_changed)) nodeUpdate(sce->nodetree, node); } @@ -2062,30 +2060,30 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho Object *ob; int lasttime; - if (sce->theDag==NULL) { + if (sce->theDag == NULL) { printf("DAG zero... not allowed to happen!\n"); DAG_scene_sort(bmain, sce); } - firstnode= sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; // always scene node /* first we flush the layer flags */ dag_scene_flush_layers(sce, lay); /* then we use the relationships + layer info to flush update events */ - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; - for (itA = firstnode->child; itA; itA= itA->next) - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; + for (itA = firstnode->child; itA; itA = itA->next) + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) flush_update_node(itA->node, lay, lasttime); /* if update is not due to time change, do pointcache clears */ if (!time) { - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; - for (itA = firstnode->child; itA; itA= itA->next) { - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) { - ob= (Object*)(itA->node->ob); + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; + for (itA = firstnode->child; itA; itA = itA->next) { + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) { + ob = (Object *)(itA->node->ob); if (ob->recalc & OB_RECALC_ALL) { if (BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) { @@ -2109,7 +2107,7 @@ static int object_modifiers_use_time(Object *ob) ModifierData *md; /* check if a modifier in modifier stack needs time input */ - for (md=ob->modifiers.first; md; md=md->next) + for (md = ob->modifiers.first; md; md = md->next) if (modifier_dependsOnTime(md)) return 1; @@ -2148,14 +2146,14 @@ static short animdata_use_time(AnimData *adt) { NlaTrack *nlt; - if (adt==NULL) return 0; + if (adt == NULL) return 0; /* check action - only if assigned, and it has anim curves */ if (adt->action && adt->action->curves.first) return 1; /* check NLA tracks + strips */ - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { if (nlt->strips.first) return 1; } @@ -2184,8 +2182,8 @@ static void dag_object_time_update_flags(Object *ob) { if (ob->constraints.first) { bConstraint *con; - for (con = ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -2197,7 +2195,7 @@ static void dag_object_time_update_flags(Object *ob) else if (cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar) { ob->recalc |= OB_RECALC_OB; break; @@ -2214,7 +2212,7 @@ static void dag_object_time_update_flags(Object *ob) if (ob->parent) { /* motion path or bone child */ - if (ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB; + if (ob->parent->type == OB_CURVE || ob->parent->type == OB_ARMATURE) ob->recalc |= OB_RECALC_OB; } #if 0 // XXX old animation system @@ -2222,7 +2220,7 @@ static void dag_object_time_update_flags(Object *ob) if (ob->dup_group) { bActionStrip *strip; /* this case is for groups with nla, whilst nla target has no action or nla */ - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) strip->object->recalc |= OB_RECALC_ALL; } @@ -2235,20 +2233,20 @@ static void dag_object_time_update_flags(Object *ob) ob->adt->recalc |= ADT_RECALC_ANIM; } - if ((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA; + if ((ob->adt) && (ob->type == OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA; if (object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA; if ((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA; { - AnimData *adt= BKE_animdata_from_id((ID *)ob->data); + AnimData *adt = BKE_animdata_from_id((ID *)ob->data); Mesh *me; Curve *cu; Lattice *lt; switch (ob->type) { case OB_MESH: - me= ob->data; + me = ob->data; if (me->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; @@ -2259,7 +2257,7 @@ static void dag_object_time_update_flags(Object *ob) break; case OB_CURVE: case OB_SURF: - cu= ob->data; + cu = ob->data; if (cu->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; @@ -2267,18 +2265,18 @@ static void dag_object_time_update_flags(Object *ob) } break; case OB_FONT: - cu= ob->data; - if (cu->nurb.first==NULL && cu->str && cu->vfont) + cu = ob->data; + if (cu->nurb.first == NULL && cu->str && cu->vfont) ob->recalc |= OB_RECALC_DATA; break; case OB_LATTICE: - lt= ob->data; + lt = ob->data; if (lt->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; } } - break; + break; case OB_MBALL: if (ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA; break; @@ -2290,9 +2288,9 @@ static void dag_object_time_update_flags(Object *ob) } if (ob->particlesystem.first) { - ParticleSystem *psys= ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { if (psys_check_enabled(ob, psys)) { ob->recalc |= OB_RECALC_DATA; break; @@ -2319,7 +2317,7 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s /* set ob flags where animated systems are */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (do_time) { /* now if DagNode were part of base, the node->lay could be checked... */ @@ -2334,22 +2332,22 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s if (do_time) { /* we do groups each once */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { dag_object_time_update_flags(go->ob); } } } } - for (sce_iter= scene; sce_iter; sce_iter= sce_iter->set) + for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) DAG_scene_flush_update(bmain, sce_iter, lay, 1); if (do_time) { /* test: set time flag, to disable baked systems to update */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (ob->recalc) ob->recalc |= OB_RECALC_TIME; } @@ -2360,10 +2358,10 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s } /* and store the info in groupobject */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { - go->recalc= go->ob->recalc; + for (go = group->gobject.first; go; go = go->next) { + go->recalc = go->ob->recalc; // printf("ob %s recalc %d\n", go->ob->id.name, go->recalc); } group->id.flag &= ~LIB_DOIT; @@ -2380,22 +2378,22 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay /* only one scene supported currently, making more scenes work * correctly requires changes beyond just the dependency graph */ - *sce= NULL; - *lay= 0; + *sce = NULL; + *lay = 0; - if ((wm= bmain->wm.first)) { + if ((wm = bmain->wm.first)) { /* if we have a windowmanager, look into windows */ - for (win=wm->windows.first; win; win=win->next) { + for (win = wm->windows.first; win; win = win->next) { if (win->screen) { - if (!*sce) *sce= win->screen->scene; + if (!*sce) *sce = win->screen->scene; *lay |= BKE_screen_visible_layers(win->screen, win->screen->scene); } } } else { /* if not, use the first sce */ - *sce= bmain->scene.first; - if (*sce) *lay= (*sce)->lay; + *sce = bmain->scene.first; + if (*sce) *lay = (*sce)->lay; /* XXX for background mode, we should get the scene * from somewhere, for the -S option, but it's in @@ -2435,9 +2433,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) dag_scene_flush_layers(scene, lay); for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; - node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL; - oblay= (node)? node->lay: ob->lay; + ob = base->object; + node = (sce_iter->theDag) ? dag_get_node(sce_iter->theDag, ob) : NULL; + oblay = (node) ? node->lay : ob->lay; if ((oblay & lay) & ~scene->lay_updated) { if (ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) @@ -2447,9 +2445,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) } } - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) go->ob->recalc |= OB_RECALC_DATA; if (go->ob->proxy_from) @@ -2473,7 +2471,7 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS { struct { ID *id; int is_dependent; } *data = userData; - if (*idpoin && GS((*idpoin)->name)==ID_TE) { + if (*idpoin && GS((*idpoin)->name) == ID_TE) { if (data->id == (*idpoin)) data->is_dependent = 1; } @@ -2481,8 +2479,8 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS static void dag_id_flush_update(Scene *sce, ID *id) { - Main *bmain= G.main; - Object *obt, *ob= NULL; + Main *bmain = G.main; + Object *obt, *ob = NULL; short idtype; /* here we flush a few things before actual scene wide flush, mostly @@ -2490,27 +2488,27 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags & pointcache for object */ if (GS(id->name) == ID_OB) { - ob= (Object*)id; + ob = (Object *)id; BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); if (ob->recalc & OB_RECALC_DATA) { /* all users of this ob->data should be checked */ - id= ob->data; + id = ob->data; /* no point in trying in this cases */ if (id && id->us <= 1) { dag_editors_id_update(bmain, id); - id= NULL; + id = NULL; } } } /* set flags & pointcache for object data */ if (id) { - idtype= GS(id->name); + idtype = GS(id->name); if (ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { if (!(ob && obt == ob) && obt->data == id) { obt->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obt->id); @@ -2521,10 +2519,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on textures - can influence depgraph via modifiers */ if (idtype == ID_TE) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { struct { ID *id; int is_dependent; } data; - data.id= id; - data.is_dependent= 0; + data.id = id; + data.is_dependent = 0; modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); if (data.is_dependent) { @@ -2537,11 +2535,11 @@ static void dag_id_flush_update(Scene *sce, ID *id) ParticleSystem *psys = obt->particlesystem.first; MTex **mtexp, *mtex; int a; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { mtexp = psys->part->mtex; - for (a=0; atex == (Tex*)id) { + if (mtex && mtex->tex == (Tex *)id) { obt->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obt->id); @@ -2560,10 +2558,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on ShapeKey */ if (idtype == ID_KE) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { - Key *key= ob_get_key(obt); + for (obt = bmain->object.first; obt; obt = obt->id.next) { + Key *key = ob_get_key(obt); if (!(ob && obt == ob) && ((ID *)key == id)) { - obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA); + obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA); lib_id_recalc_tag(bmain, &obt->id); lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); @@ -2574,8 +2572,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on particle settings */ if (idtype == ID_PA) { ParticleSystem *psys; - for (obt=bmain->object.first; obt; obt= obt->id.next) - for (psys=obt->particlesystem.first; psys; psys=psys->next) + for (obt = bmain->object.first; obt; obt = obt->id.next) + for (psys = obt->particlesystem.first; psys; psys = psys->next) if (&psys->part->id == id) BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } @@ -2585,12 +2583,12 @@ static void dag_id_flush_update(Scene *sce, ID *id) BKE_tracking_dopesheet_tag_update(&clip->tracking); - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { bConstraint *con; - for (con = obt->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = obt->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, - CONSTRAINT_TYPE_OBJECTSOLVER)) + CONSTRAINT_TYPE_OBJECTSOLVER)) { obt->recalc |= OB_RECALC_OB; break; @@ -2601,8 +2599,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) if (sce->nodetree) { bNode *node; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==id) { + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == id) { nodeUpdate(sce->nodetree, node); } } @@ -2646,8 +2644,8 @@ void DAG_ids_flush_tagged(Main *bmain) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - for (; id; id=id->next) { - if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) { + for (; id; id = id->next) { + if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) { dag_id_flush_update(sce, id); do_flush = 1; } @@ -2675,7 +2673,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - updated= 1; + updated = 1; break; } } @@ -2698,9 +2696,9 @@ void DAG_ids_clear_recalc(Main *bmain) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - for (; id; id=id->next) - if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) - id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA); + for (; id; id = id->next) + if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) + id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA); } } @@ -2709,15 +2707,15 @@ void DAG_ids_clear_recalc(Main *bmain) void DAG_id_tag_update(ID *id, short flag) { - Main *bmain= G.main; + Main *bmain = G.main; - if (id==NULL) return; + if (id == NULL) return; /* tag ID for update */ if (flag) { if (flag & OB_RECALC_OB) lib_id_recalc_tag(bmain, id); - if (flag & (OB_RECALC_DATA|PSYS_RECALC)) + if (flag & (OB_RECALC_DATA | PSYS_RECALC)) lib_id_recalc_data_tag(bmain, id); } else @@ -2730,14 +2728,14 @@ void DAG_id_tag_update(ID *id, short flag) if (idtype == ID_OB) { /* only quick tag */ - ob = (Object*)id; + ob = (Object *)id; ob->recalc |= (flag & OB_RECALC_ALL); } else if (idtype == ID_PA) { ParticleSystem *psys; /* this is weak still, should be done delayed as well */ - for (ob=bmain->object.first; ob; ob=ob->id.next) { - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { if (&psys->part->id == id) { ob->recalc |= (flag & OB_RECALC_ALL); psys->recalc |= (flag & PSYS_RECALC); @@ -2757,12 +2755,12 @@ void DAG_id_tag_update(ID *id, short flag) void DAG_id_type_tag(struct Main *bmain, short idtype) { - bmain->id_tag_update[((char*)&idtype)[0]] = 1; + bmain->id_tag_update[((char *)&idtype)[0]] = 1; } int DAG_id_type_tagged(Main *bmain, short idtype) { - return bmain->id_tag_update[((char*)&idtype)[0]]; + return bmain->id_tag_update[((char *)&idtype)[0]]; } #if 0 // UNUSED @@ -2772,22 +2770,22 @@ static int parent_check_node(DagNode *node, int curtime) { DagAdjList *itA; - node->lasttime= curtime; + node->lasttime = curtime; - if (node->color==DAG_GRAY) + if (node->color == DAG_GRAY) return DAG_GRAY; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { - if (itA->node->color==DAG_GRAY) + if (itA->node->color == DAG_GRAY) return DAG_GRAY; /* descend if not done */ - if (itA->node->lasttime!=curtime) { - itA->node->color= parent_check_node(itA->node, curtime); + if (itA->node->lasttime != curtime) { + itA->node->color = parent_check_node(itA->node, curtime); - if (itA->node->color==DAG_GRAY) + if (itA->node->color == DAG_GRAY) return DAG_GRAY; } } @@ -2802,7 +2800,7 @@ static int parent_check_node(DagNode *node, int curtime) /* we assume its an armature with pose */ void DAG_pose_sort(Object *ob) { - bPose *pose= ob->pose; + bPose *pose = ob->pose; bPoseChannel *pchan; bConstraint *con; DagNode *node; @@ -2815,12 +2813,12 @@ void DAG_pose_sort(Object *ob) int skip = 0; dag = dag_init(); - ugly_hack_sorry= 0; // no ID structs + ugly_hack_sorry = 0; // no ID structs - rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL + rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL /* we add the hierarchy and the constraints */ - for (pchan = pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { int addtoroot = 1; node = dag_get_node(dag, pchan); @@ -2830,40 +2828,40 @@ void DAG_pose_sort(Object *ob) dag_add_relation(dag, node2, node, 0, "Parent Relation"); addtoroot = 0; } - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { - if (ct->tar==ob && ct->subtarget[0]) { - bPoseChannel *target= BKE_pose_channel_find_name(ob->pose, ct->subtarget); + for (ct = targets.first; ct; ct = ct->next) { + if (ct->tar == ob && ct->subtarget[0]) { + bPoseChannel *target = BKE_pose_channel_find_name(ob->pose, ct->subtarget); if (target) { - node2= dag_get_node(dag, target); + node2 = dag_get_node(dag, target); dag_add_relation(dag, node2, node, 0, "Pose Constraint"); - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = (bKinematicConstraint *)con->data; bPoseChannel *parchan; - int segcount= 0; + int segcount = 0; /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) - parchan= pchan->parent; + parchan = pchan->parent; else - parchan= pchan; + parchan = pchan; /* Walk to the chain's root */ while (parchan) { - node3= dag_get_node(dag, parchan); + node3 = dag_get_node(dag, parchan); dag_add_relation(dag, node2, node3, 0, "IK Constraint"); segcount++; - if (segcount==data->rootbone || segcount>255) break; // 255 is weak - parchan= parchan->parent; + if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + parchan = parchan->parent; } } } @@ -2874,7 +2872,7 @@ void DAG_pose_sort(Object *ob) cti->flush_constraint_targets(con, &targets, 1); } } - if (addtoroot == 1 ) { + if (addtoroot == 1) { dag_add_relation(dag, rootnode, node, 0, "Root Bone Relation"); } } @@ -2882,12 +2880,12 @@ void DAG_pose_sort(Object *ob) dag_check_cycle(dag); /* now we try to sort... */ - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; nqueue = queue_create(DAGQUEUEALLOC); /* tag nodes unchecked */ - for (node = dag->DagNode.first; node; node= node->next) + for (node = dag->DagNode.first; node; node = node->next) node->color = DAG_WHITE; rootnode->color = DAG_GRAY; @@ -2912,7 +2910,7 @@ void DAG_pose_sort(Object *ob) if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == NULL) // we are done + if (node->ob == NULL) // we are done break; node->color = DAG_BLACK; @@ -2925,7 +2923,7 @@ void DAG_pose_sort(Object *ob) /* temporal correction for circular dependencies */ while (pose->chanbase.first) { - pchan= pose->chanbase.first; + pchan = pose->chanbase.first; BLI_remlink(&pose->chanbase, pchan); BLI_addhead(&tempbase, pchan); @@ -2943,7 +2941,7 @@ void DAG_pose_sort(Object *ob) free_forest(dag); MEM_freeN(dag); - ugly_hack_sorry= 1; + ugly_hack_sorry = 1; } /* ************************ DAG DEBUGGING ********************* */ @@ -2951,17 +2949,17 @@ void DAG_pose_sort(Object *ob) void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob) { /* utility for debugging dependencies */ - dag_print_dependencies= 1; + dag_print_dependencies = 1; if (ob && (ob->mode & OB_MODE_POSE)) { - printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2); + printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name + 2); DAG_pose_sort(ob); } else { - printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2); + printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name + 2); DAG_scene_sort(bmain, scene); } - dag_print_dependencies= 0; + dag_print_dependencies = 0; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 04e559388ca..d74a688f121 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -81,11 +81,11 @@ void freedisplist(ListBase *lb) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { BLI_remlink(lb, dl); free_disp_elem(dl); - dl= lb->first; + dl = lb->first; } } @@ -93,14 +93,14 @@ DispList *find_displist_create(ListBase *lb, int type) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { - if (dl->type==type) return dl; - dl= dl->next; + if (dl->type == type) return dl; + dl = dl->next; } - dl= MEM_callocN(sizeof(DispList), "find_disp"); - dl->type= type; + dl = MEM_callocN(sizeof(DispList), "find_disp"); + dl->type = type; BLI_addtail(lb, dl); return dl; @@ -110,10 +110,10 @@ DispList *find_displist(ListBase *lb, int type) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { - if (dl->type==type) return dl; - dl= dl->next; + if (dl->type == type) return dl; + dl = dl->next; } return NULL; @@ -122,7 +122,7 @@ DispList *find_displist(ListBase *lb, int type) int displist_has_faces(ListBase *lb) { DispList *dl; - for (dl= lb->first; dl; dl= dl->next) { + for (dl = lb->first; dl; dl = dl->next) { if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { return 1; } @@ -136,21 +136,21 @@ void copy_displist(ListBase *lbn, ListBase *lb) freedisplist(lbn); - dl= lb->first; + dl = lb->first; while (dl) { - dln= MEM_dupallocN(dl); + dln = MEM_dupallocN(dl); BLI_addtail(lbn, dln); - dln->verts= MEM_dupallocN(dl->verts); - dln->nors= MEM_dupallocN(dl->nors); - dln->index= MEM_dupallocN(dl->index); - dln->col1= MEM_dupallocN(dl->col1); - dln->col2= MEM_dupallocN(dl->col2); + dln->verts = MEM_dupallocN(dl->verts); + dln->nors = MEM_dupallocN(dl->nors); + dln->index = MEM_dupallocN(dl->index); + dln->col1 = MEM_dupallocN(dl->col1); + dln->col2 = MEM_dupallocN(dl->col2); if (dl->bevelSplitFlag) - dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag); + dln->bevelSplitFlag = MEM_dupallocN(dl->bevelSplitFlag); - dl= dl->next; + dl = dl->next; } } @@ -163,38 +163,38 @@ void addnormalsDispList(ListBase *lb) int a, b, p1, p2, p3, p4; - dl= lb->first; + dl = lb->first; while (dl) { - if (dl->type==DL_INDEX3) { - if (dl->nors==NULL) { - dl->nors= MEM_callocN(sizeof(float)*3, "dlnors"); - if (dl->verts[2] < 0.0f) dl->nors[2]= -1.0f; - else dl->nors[2]= 1.0f; + if (dl->type == DL_INDEX3) { + if (dl->nors == NULL) { + dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors"); + if (dl->verts[2] < 0.0f) dl->nors[2] = -1.0f; + else dl->nors[2] = 1.0f; } } - else if (dl->type==DL_SURF) { - if (dl->nors==NULL) { - dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors"); + else if (dl->type == DL_SURF) { + if (dl->nors == NULL) { + dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors"); - vdata= dl->verts; - ndata= dl->nors; + vdata = dl->verts; + ndata = dl->nors; - for (a=0; aparts; a++) { + for (a = 0; a < dl->parts; a++) { - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - v1= vdata+ 3*p1; - n1= ndata+ 3*p1; - v2= vdata+ 3*p2; - n2= ndata+ 3*p2; - v3= vdata+ 3*p3; - n3= ndata+ 3*p3; - v4= vdata+ 3*p4; - n4= ndata+ 3*p4; + v1 = vdata + 3 * p1; + n1 = ndata + 3 * p1; + v2 = vdata + 3 * p2; + n2 = ndata + 3 * p2; + v3 = vdata + 3 * p3; + n3 = ndata + 3 * p3; + v4 = vdata + 3 * p4; + n4 = ndata + 3 * p4; - for (; bnr; b++) { + for (; b < dl->nr; b++) { normal_quad_v3(nor, v1, v3, v4, v2); @@ -203,21 +203,21 @@ void addnormalsDispList(ListBase *lb) add_v3_v3(n3, nor); add_v3_v3(n4, nor); - v2= v1; v1+= 3; - v4= v3; v3+= 3; - n2= n1; n1+= 3; - n4= n3; n3+= 3; + v2 = v1; v1 += 3; + v4 = v3; v3 += 3; + n2 = n1; n1 += 3; + n4 = n3; n3 += 3; } } - a= dl->parts*dl->nr; - v1= ndata; + a = dl->parts * dl->nr; + v1 = ndata; while (a--) { normalize_v3(v1); - v1+= 3; + v1 += 3; } } } - dl= dl->next; + dl = dl->next; } } @@ -225,52 +225,52 @@ void count_displist(ListBase *lb, int *totvert, int *totface) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { switch (dl->type) { case DL_SURF: - *totvert+= dl->nr*dl->parts; - *totface+= (dl->nr-1)*(dl->parts-1); + *totvert += dl->nr * dl->parts; + *totface += (dl->nr - 1) * (dl->parts - 1); break; case DL_INDEX3: case DL_INDEX4: - *totvert+= dl->nr; - *totface+= dl->parts; + *totvert += dl->nr; + *totface += dl->parts; break; case DL_POLY: case DL_SEGM: - *totvert+= dl->nr*dl->parts; + *totvert += dl->nr * dl->parts; } - dl= dl->next; + dl = dl->next; } } int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) { - if ((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) { + if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) { return 0; } if (dl->flag & DL_CYCL_U) { - (*p1)= dl->nr*a; - (*p2)= (*p1)+ dl->nr-1; - (*p3)= (*p1)+ dl->nr; - (*p4)= (*p2)+ dl->nr; - (*b)= 0; + (*p1) = dl->nr * a; + (*p2) = (*p1) + dl->nr - 1; + (*p3) = (*p1) + dl->nr; + (*p4) = (*p2) + dl->nr; + (*b) = 0; } else { - (*p2)= dl->nr*a; - (*p1)= (*p2)+1; - (*p4)= (*p2)+ dl->nr; - (*p3)= (*p1)+ dl->nr; - (*b)= 1; + (*p2) = dl->nr * a; + (*p1) = (*p2) + 1; + (*p4) = (*p2) + dl->nr; + (*p3) = (*p1) + dl->nr; + (*b) = 1; } - if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) { - (*p3)-= dl->nr*dl->parts; - (*p4)-= dl->nr*dl->parts; + if ( (dl->flag & DL_CYCL_V) && a == dl->parts - 1) { + (*p3) -= dl->nr * dl->parts; + (*p4) -= dl->nr * dl->parts; } return 1; @@ -287,70 +287,70 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i float *data; int a, len, resolu; - nu= nubase->first; + nu = nubase->first; while (nu) { - if (nu->hide==0) { + if (nu->hide == 0) { - if (forRender && cu->resolu_ren!=0) - resolu= cu->resolu_ren; + if (forRender && cu->resolu_ren != 0) + resolu = cu->resolu_ren; else - resolu= nu->resolu; + resolu = nu->resolu; - if (!BKE_nurb_check_valid_u(nu)); + if (!BKE_nurb_check_valid_u(nu)) ; else if (nu->type == CU_BEZIER) { /* count */ - len= 0; - a= nu->pntsu-1; + len = 0; + a = nu->pntsu - 1; if (nu->flagu & CU_NURB_CYCLIC) a++; - prevbezt= nu->bezt; - bezt= prevbezt+1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; while (a--) { - if (a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt; + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) bezt = nu->bezt; - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++; - else len+= resolu; + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) len++; + else len += resolu; - if (a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++; + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) len++; - prevbezt= bezt; + prevbezt = bezt; bezt++; } - dl= MEM_callocN(sizeof(DispList), "makeDispListbez"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbez"); /* len+1 because of 'forward_diff_bezier' function */ - dl->verts= MEM_callocN((len+1)*3*sizeof(float), "dlverts"); + dl->verts = MEM_callocN((len + 1) * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; - data= dl->verts; + data = dl->verts; if (nu->flagu & CU_NURB_CYCLIC) { - dl->type= DL_POLY; - a= nu->pntsu; + dl->type = DL_POLY; + a = nu->pntsu; } else { - dl->type= DL_SEGM; - a= nu->pntsu-1; + dl->type = DL_SEGM; + a = nu->pntsu - 1; } - prevbezt= nu->bezt; - bezt= prevbezt+1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; while (a--) { - if (a==0 && dl->type== DL_POLY) bezt= nu->bezt; + if (a == 0 && dl->type == DL_POLY) bezt = nu->bezt; - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) { + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { copy_v3_v3(data, prevbezt->vec[1]); - data+= 3; + data += 3; } else { int j; - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], @@ -358,58 +358,58 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i data + j, resolu, 3 * sizeof(float)); } - data+= 3*resolu; + data += 3 * resolu; } - if (a==0 && dl->type==DL_SEGM) { + if (a == 0 && dl->type == DL_SEGM) { copy_v3_v3(data, bezt->vec[1]); } - prevbezt= bezt; + prevbezt = bezt; bezt++; } } else if (nu->type == CU_NURBS) { - len= (resolu*SEGMENTSU(nu)); + len = (resolu * SEGMENTSU(nu)); - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; + dl->parts = 1; - dl->nr= len; - dl->col= nu->mat_nr; + dl->nr = len; + dl->col = nu->mat_nr; dl->charidx = nu->charidx; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } else if (nu->type == CU_POLY) { - len= nu->pntsu; - dl= MEM_callocN(sizeof(DispList), "makeDispListpoly"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + len = nu->pntsu; + dl = MEM_callocN(sizeof(DispList), "makeDispListpoly"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; dl->charidx = nu->charidx; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; - a= len; - bp= nu->bp; + a = len; + bp = nu->bp; while (a--) { copy_v3_v3(data, bp->vec); bp++; - data+= 3; + data += 3; } } } - nu= nu->next; + nu = nu->next; } } @@ -419,99 +419,99 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) ScanFillContext sf_ctx; ScanFillVert *eve, *v1, *vlast; ScanFillFace *efa; - DispList *dlnew=NULL, *dl; + DispList *dlnew = NULL, *dl; float *f1; - int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; + int colnr = 0, charidx = 0, cont = 1, tot, a, *index, nextcol = 0; intptr_t totvert; - if (dispbase==NULL) return; - if (dispbase->first==NULL) return; + if (dispbase == NULL) return; + if (dispbase->first == NULL) return; while (cont) { - cont= 0; - totvert= 0; - nextcol= 0; + cont = 0; + totvert = 0; + nextcol = 0; BLI_scanfill_begin(&sf_ctx); - dl= dispbase->first; + dl = dispbase->first; while (dl) { - if (dl->type==DL_POLY) { - if (charidxcharidx) cont= 1; - else if (charidx==dl->charidx) { /* character with needed index */ - if (colnr==dl->col) { + if (dl->type == DL_POLY) { + if (charidx < dl->charidx) cont = 1; + else if (charidx == dl->charidx) { /* character with needed index */ + if (colnr == dl->col) { /* make editverts and edges */ - f1= dl->verts; - a= dl->nr; - eve= v1= NULL; + f1 = dl->verts; + a = dl->nr; + eve = v1 = NULL; while (a--) { - vlast= eve; + vlast = eve; eve = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; - if (vlast==NULL) v1= eve; + if (vlast == NULL) v1 = eve; else { BLI_scanfill_edge_add(&sf_ctx, vlast, eve); } - f1+=3; + f1 += 3; } - if (eve!=NULL && v1!=NULL) { + if (eve != NULL && v1 != NULL) { BLI_scanfill_edge_add(&sf_ctx, eve, v1); } } - else if (colnrcol) { + else if (colnr < dl->col) { /* got poly with next material at current char */ - cont= 1; - nextcol= 1; + cont = 1; + nextcol = 1; } } } - dl= dl->next; + dl = dl->next; } - if (totvert && (tot= BLI_scanfill_calc(&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; - dlnew->col= colnr; - dlnew->nr= totvert; - dlnew->parts= tot; + dlnew = MEM_callocN(sizeof(DispList), "filldisplist"); + dlnew->type = DL_INDEX3; + dlnew->col = colnr; + dlnew->nr = totvert; + dlnew->parts = tot; - dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex"); - dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts"); + dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex"); + dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts"); /* vert data */ - f1= dlnew->verts; - totvert= 0; - eve= sf_ctx.fillvertbase.first; + f1 = dlnew->verts; + totvert = 0; + eve = sf_ctx.fillvertbase.first; while (eve) { copy_v3_v3(f1, eve->co); - f1+= 3; + f1 += 3; /* index number */ eve->tmp.l = totvert; totvert++; - eve= eve->next; + eve = eve->next; } /* index data */ efa = sf_ctx.fillfacebase.first; - index= dlnew->index; + index = dlnew->index; while (efa) { - index[0]= (intptr_t)efa->v1->tmp.l; - index[1]= (intptr_t)efa->v2->tmp.l; - index[2]= (intptr_t)efa->v3->tmp.l; + index[0] = (intptr_t)efa->v1->tmp.l; + index[1] = (intptr_t)efa->v2->tmp.l; + index[2] = (intptr_t)efa->v3->tmp.l; if (flipnormal) SWAP(int, index[0], index[2]); - index+= 3; - efa= efa->next; + index += 3; + efa = efa->next; } } @@ -527,7 +527,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) else { /* switch to next char and start filling from first material */ charidx++; - colnr= 0; + colnr = 0; } } @@ -542,55 +542,55 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) float *fp, *fp1; int a, dpoly; - front.first= front.last= back.first= back.last= NULL; + front.first = front.last = back.first = back.last = NULL; - dl= dispbase->first; + dl = dispbase->first; while (dl) { - if (dl->type==DL_SURF) { - if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) { + if (dl->type == DL_SURF) { + if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) { - dlnew= MEM_callocN(sizeof(DispList), "filldisp"); + dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&front, dlnew); - dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1"); - dlnew->nr= dl->parts; - dlnew->parts= 1; - dlnew->type= DL_POLY; - dlnew->col= dl->col; + dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->nr = dl->parts; + dlnew->parts = 1; + dlnew->type = DL_POLY; + dlnew->col = dl->col; dlnew->charidx = dl->charidx; - fp= dl->verts; - dpoly= 3*dl->nr; + fp = dl->verts; + dpoly = 3 * dl->nr; - a= dl->parts; + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); - fp1+= 3; - fp+= dpoly; + fp1 += 3; + fp += dpoly; } } if ( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) { - dlnew= MEM_callocN(sizeof(DispList), "filldisp"); + dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&back, dlnew); - dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1"); - dlnew->nr= dl->parts; - dlnew->parts= 1; - dlnew->type= DL_POLY; - dlnew->col= dl->col; - dlnew->charidx= dl->charidx; + dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->nr = dl->parts; + dlnew->parts = 1; + dlnew->type = DL_POLY; + dlnew->col = dl->col; + dlnew->charidx = dl->charidx; - fp= dl->verts+3*(dl->nr-1); - dpoly= 3*dl->nr; + fp = dl->verts + 3 * (dl->nr - 1); + dpoly = 3 * dl->nr; - a= dl->parts; + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); - fp1+= 3; - fp+= dpoly; + fp1 += 3; + fp += dpoly; } } } } - dl= dl->next; + dl = dl->next; } filldisplist(&front, dispbase, 1); @@ -607,7 +607,7 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis { if (cu->flag & CU_3D) return; - if (dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) { + if (dispbase->first && ((DispList *) dispbase->first)->type == DL_SURF) { bevels_to_filledpoly(cu, dispbase); } else { @@ -624,37 +624,37 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) { DispList *dl; - if (taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; + if (taperobj == NULL || taperobj->type != OB_CURVE) return 1.0; - dl= taperobj->disp.first; - if (dl==NULL) { + dl = taperobj->disp.first; + if (dl == NULL) { makeDispListCurveTypes(scene, taperobj, 0); - dl= taperobj->disp.first; + dl = taperobj->disp.first; } if (dl) { - float fac= ((float)cur)/(float)(tot-1); + float fac = ((float)cur) / (float)(tot - 1); float minx, dx, *fp; int a; /* horizontal size */ - minx= dl->verts[0]; - dx= dl->verts[3*(dl->nr-1)] - minx; + minx = dl->verts[0]; + dx = dl->verts[3 * (dl->nr - 1)] - minx; if (dx > 0.0f) { - fp= dl->verts; - for (a=0; anr; a++, fp+=3) { - if ( (fp[0]-minx)/dx >= fac) { + fp = dl->verts; + for (a = 0; a < dl->nr; a++, fp += 3) { + if ( (fp[0] - minx) / dx >= fac) { /* interpolate with prev */ - if (a>0) { - float fac1= (fp[-3]-minx)/dx; - float fac2= (fp[0]-minx)/dx; - if (fac1!=fac2) - return fp[1]*(fac1-fac)/(fac1-fac2) + fp[-2]*(fac-fac2)/(fac1-fac2); + if (a > 0) { + float fac1 = (fp[-3] - minx) / dx; + float fac2 = (fp[0] - minx) / dx; + if (fac1 != fac2) + return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2); } return fp[1]; } } - return fp[-2]; // last y coord + return fp[-2]; // last y coord } } @@ -663,7 +663,7 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) void makeDispListMBall(Scene *scene, Object *ob) { - if (!ob || ob->type!=OB_MBALL) return; + if (!ob || ob->type != OB_MBALL) return; // XXX: mball stuff uses plenty of global variables // while this is unchanged updating during render is unsafe @@ -671,8 +671,8 @@ void makeDispListMBall(Scene *scene, Object *ob) freedisplist(&(ob->disp)); - if (ob->type==OB_MBALL) { - if (ob==BKE_metaball_basis_find(scene, ob)) { + if (ob->type == OB_MBALL) { + if (ob == BKE_metaball_basis_find(scene, ob)) { BKE_metaball_polygonize(scene, ob, &ob->disp); BKE_metaball_texspace_calc(ob); @@ -703,7 +703,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo if (editmode) required_mode |= eModifierMode_Editmode; pretessellatePoint = NULL; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (!modifier_isEnabled(scene, md, required_mode)) continue; @@ -717,7 +717,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo * for incformation button in modifier's header */ md->mode |= eModifierMode_ApplyOnSpline; } - else if (md->mode&eModifierMode_ApplyOnSpline) { + else if (md->mode & eModifierMode_ApplyOnSpline) { pretessellatePoint = md; } } @@ -729,13 +729,13 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs_get(cu); + Curve *cu = ob->data; + ListBase *nurb = BKE_curve_nurbs_get(cu); int numVerts = 0; int editmode = (!forRender && cu->editnurb); float (*originalVerts)[3] = NULL; float (*deformedVerts)[3] = NULL; - float *keyVerts= NULL; + float *keyVerts = NULL; int required_mode; if (forRender) required_mode = eModifierMode_Render; @@ -745,29 +745,29 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl if (editmode) required_mode |= eModifierMode_Editmode; - if (cu->editnurb==NULL) { - keyVerts= do_ob_key(scene, ob); + if (cu->editnurb == NULL) { + keyVerts = do_ob_key(scene, ob); if (keyVerts) { /* split coords from key data, the latter also includes * tilts, which is passed through in the modifier stack. * this is also the reason curves do not use a virtual * shape key modifier yet. */ - deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); - originalVerts= MEM_dupallocN(deformedVerts); + deformedVerts = BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); + originalVerts = MEM_dupallocN(deformedVerts); numVerts = BKE_nurbList_verts_count_without_handles(nurb); } } if (pretessellatePoint) { - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform) continue; + if (mti->type != eModifierTypeType_OnlyDeform) continue; if (!deformedVerts) { deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts); @@ -776,7 +776,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, forRender, editmode); - if (md==pretessellatePoint) + if (md == pretessellatePoint) break; } } @@ -794,22 +794,22 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl *numVerts_r = numVerts; } -static float (*displist_get_allverts (ListBase *dispbase, int *totvert))[3] +static float (*displist_get_allverts(ListBase * dispbase, int *totvert))[3] { DispList *dl; float (*allverts)[3], *fp; - *totvert= 0; + *totvert = 0; - for (dl=dispbase->first; dl; dl=dl->next) - *totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; + for (dl = dispbase->first; dl; dl = dl->next) + *totvert += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr; - allverts= MEM_mallocN((*totvert)*sizeof(float)*3, "displist_get_allverts allverts"); - fp= (float*)allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + allverts = MEM_mallocN((*totvert) * sizeof(float) * 3, "displist_get_allverts allverts"); + fp = (float *)allverts; + for (dl = dispbase->first; dl; dl = dl->next) { + int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); memcpy(fp, dl->verts, sizeof(float) * offs); - fp+= offs; + fp += offs; } return allverts; @@ -820,24 +820,24 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3]) DispList *dl; float *fp; - fp= (float*)allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + fp = (float *)allverts; + for (dl = dispbase->first; dl; dl = dl->next) { + int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); memcpy(dl->verts, fp, sizeof(float) * offs); - fp+= offs; + fp += offs; } } static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) + DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs_get(cu); + Curve *cu = ob->data; + ListBase *nurb = BKE_curve_nurbs_get(cu); int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); - DerivedMesh *dm= NULL, *ndm; + DerivedMesh *dm = NULL, *ndm; float (*vertCos)[3] = NULL; int useCache = !forRender; @@ -853,19 +853,19 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } if (derivedFinal && *derivedFinal) { - (*derivedFinal)->release (*derivedFinal); + (*derivedFinal)->release(*derivedFinal); } - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; if (mti->type == eModifierTypeType_OnlyDeform || - (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { + (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { if (dm) { if (!vertCos) { totvert = dm->getNumVerts(dm); @@ -877,7 +877,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } else { if (!vertCos) { - vertCos= displist_get_allverts(dispbase, &totvert); + vertCos = displist_get_allverts(dispbase, &totvert); } mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode); @@ -910,7 +910,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba curve_to_filledpoly(cu, nurb, dispbase); } - dm= CDDM_from_curve_customDB(ob, dispbase); + dm = CDDM_from_curve_customDB(ob, dispbase); CDDM_calc_normals_mapping(dm); } @@ -918,7 +918,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if (vertCos) { /* Vertex coordinates were applied to necessary data, could free it */ MEM_freeN(vertCos); - vertCos= NULL; + vertCos = NULL; } ndm = mti->applyModifier(md, ob, dm, forRender, useCache); @@ -927,7 +927,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba /* Modifier returned a new derived mesh */ if (dm && dm != ndm) /* Modifier */ - dm->release (dm); + dm->release(dm); dm = ndm; } } @@ -946,12 +946,12 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba else { displist_apply_allverts(dispbase, vertCos); MEM_freeN(vertCos); - vertCos= NULL; + vertCos = NULL; } } if (derivedFinal) { - if (dm) DM_ensure_tessface(dm); /* needed for drawing */ + if (dm) DM_ensure_tessface(dm); /* needed for drawing */ (*derivedFinal) = dm; } @@ -967,25 +967,25 @@ static void displist_surf_indices(DispList *dl) int a, b, p1, p2, p3, p4; int *index; - dl->totindex= 0; + dl->totindex = 0; - index=dl->index= MEM_mallocN(4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs"); + index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1), "index array nurbs"); - for (a=0; aparts; a++) { + for (a = 0; a < dl->parts; a++) { - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - for (; bnr; b++, index+=4) { - index[0]= p1; - index[1]= p2; - index[2]= p4; - index[3]= p3; + for (; b < dl->nr; b++, index += 4) { + index[0] = p1; + index[1] = p2; + index[2] = p4; + index[3] = p3; dl->totindex++; - p2= p1; p1++; - p4= p3; p3++; + p2 = p1; p1++; + p4 = p3; p3++; } } @@ -995,11 +995,11 @@ static void displist_surf_indices(DispList *dl) static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) { DerivedMesh *dm; - ListBase disp= {NULL, NULL}; + ListBase disp = {NULL, NULL}; /* OrcoDM should be created from underformed disp lists */ makeDispListCurveTypes_forOrco(scene, ob, &disp); - dm= CDDM_from_curve_customDB(ob, &disp); + dm = CDDM_from_curve_customDB(ob, &disp); freedisplist(&disp); @@ -1010,12 +1010,12 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * { float (*orco)[3], (*layerorco)[3]; int totvert, a; - Curve *cu= ob->data; + Curve *cu = ob->data; - totvert= dm->getNumVerts(dm); + totvert = dm->getNumVerts(dm); if (orcodm) { - orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco"); + orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco"); if (orcodm->getNumVerts(orcodm) == totvert) orcodm->getVertCos(orcodm, orco); @@ -1023,18 +1023,18 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * dm->getVertCos(dm, orco); } else { - orco= (float(*)[3])BKE_curve_make_orco(scene, ob); + orco = (float(*)[3])BKE_curve_make_orco(scene, ob); } - for (a=0; aloc[0])/cu->size[0]; - co[1] = (co[1]-cu->loc[1])/cu->size[1]; - co[2] = (co[2]-cu->loc[2])/cu->size[2]; + co[0] = (co[0] - cu->loc[0]) / cu->size[0]; + co[1] = (co[1] - cu->loc[1]) / cu->size[1]; + co[2] = (co[2] - cu->loc[2]) / cu->size[2]; } if ((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) { - memcpy(layerorco, orco, sizeof(float)*totvert); + memcpy(layerorco, orco, sizeof(float) * totvert); MEM_freeN(orco); } else @@ -1048,10 +1048,10 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; + Curve *cu = ob->data; int required_mode; int editmode = (!forRender && cu->editnurb); - DerivedMesh *ndm, *orcodm= NULL; + DerivedMesh *ndm, *orcodm = NULL; if (forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -1064,17 +1064,17 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina md = pretessellatePoint->next; } - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) continue; if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_Constructive) continue; + if (mti->type != eModifierTypeType_Constructive) continue; if (!orcodm) - orcodm= create_orco_dm(scene, ob); + orcodm = create_orco_dm(scene, ob); ndm = mti->applyModifier(md, ob, orcodm, forRender, 0); @@ -1095,7 +1095,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina } void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco) { ListBase *nubase; Nurb *nu; @@ -1108,65 +1108,65 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, float (*deformedVerts)[3]; if (!forRender && cu->editnurb) - nubase= BKE_curve_editNurbs_get(cu); + nubase = BKE_curve_editNurbs_get(cu); else - nubase= &cu->nurb; + nubase = &cu->nurb; if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); - for (nu=nubase->first; nu; nu=nu->next) { - if (forRender || nu->hide==0) { - int resolu= nu->resolu, resolv= nu->resolv; + for (nu = nubase->first; nu; nu = nu->next) { + if (forRender || nu->hide == 0) { + int resolu = nu->resolu, resolv = nu->resolv; if (forRender) { - if (cu->resolu_ren) resolu= cu->resolu_ren; - if (cu->resolv_ren) resolv= cu->resolv_ren; + if (cu->resolu_ren) resolu = cu->resolu_ren; + if (cu->resolv_ren) resolv = cu->resolv_ren; } - if (nu->pntsv==1) { - len= SEGMENTSU(nu)*resolu; + if (nu->pntsv == 1) { + len = SEGMENTSU(nu) * resolu; - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } else { - len= (nu->pntsu*resolu) * (nu->pntsv*resolv); + len = (nu->pntsu * resolu) * (nu->pntsv * resolv); - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - data= dl->verts; - dl->type= DL_SURF; + data = dl->verts; + dl->type = DL_SURF; - dl->parts= (nu->pntsu*resolu); /* in reverse, because makeNurbfaces works that way */ - dl->nr= (nu->pntsv*resolv); - if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ - if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V; + dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */ + dl->nr = (nu->pntsv * resolv); + if (nu->flagv & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_U; /* reverse too! */ + if (nu->flagu & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_V; BKE_nurb_makeFaces(nu, data, 0, resolu, resolv); @@ -1187,7 +1187,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, - forRender, originalVerts, deformedVerts); + forRender, originalVerts, deformedVerts); } static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r) @@ -1196,24 +1196,24 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid int b; fp = dlb->verts; - for (b = 0; bnr; b++, fp += 3, data += 3) { + for (b = 0; b < dlb->nr; b++, fp += 3, data += 3) { if (cu->flag & CU_3D) { float vec[3]; - vec[0] = fp[1]+widfac; + vec[0] = fp[1] + widfac; vec[1] = fp[2]; - vec[2 ]= 0.0; + vec[2] = 0.0; mul_qt_v3(bevp->quat, vec); - data[0] = bevp->vec[0] + fac*vec[0]; - data[1] = bevp->vec[1] + fac*vec[1]; - data[2] = bevp->vec[2] + fac*vec[2]; + data[0] = bevp->vec[0] + fac * vec[0]; + data[1] = bevp->vec[1] + fac * vec[1]; + data[2] = bevp->vec[2] + fac * vec[2]; } else { - data[0] = bevp->vec[0] + fac*(widfac+fp[1])*bevp->sina; - data[1] = bevp->vec[1] + fac*(widfac+fp[1])*bevp->cosa; - data[2] = bevp->vec[2] + fac*fp[2]; + data[0] = bevp->vec[0] + fac * (widfac + fp[1]) * bevp->sina; + data[1] = bevp->vec[1] + fac * (widfac + fp[1]) * bevp->cosa; + data[2] = bevp->vec[2] + fac * fp[2]; } } @@ -1226,19 +1226,19 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp float *data; int b; - dl= MEM_callocN(sizeof(DispList), "makeDispListbev2"); - dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbev2"); + dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr, "dlverts"); - dl->type= DL_POLY; + dl->type = DL_POLY; - dl->parts= 1; - dl->nr= dlb->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = dlb->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3) copy_v3_v3(data, prev_fp); @@ -1247,14 +1247,14 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp } static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco) { Curve *cu = ob->data; /* we do allow duplis... this is only displist on curve level */ if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; - if (ob->type==OB_SURF) { + if (ob->type == OB_SURF) { makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { @@ -1264,14 +1264,14 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float (*deformedVerts)[3]; int numVerts; - nubase= BKE_curve_nurbs_get(cu); + nubase = BKE_curve_nurbs_get(cu); BLI_freelistN(&(cu->bev)); if (cu->path) free_path(cu->path); - cu->path= NULL; + cu->path = NULL; - if (ob->type==OB_FONT) BKE_vfont_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); @@ -1281,15 +1281,15 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba BKE_curve_bevel_make(scene, ob, &dlbev, forRender); /* no bevel or extrude, and no width correction? */ - if (!dlbev.first && cu->width==1.0f) { + if (!dlbev.first && cu->width == 1.0f) { curve_to_displist(cu, nubase, dispbase, forRender); } else { - float widfac= cu->width - 1.0f; - BevList *bl= cu->bev.first; - Nurb *nu= nubase->first; + float widfac = cu->width - 1.0f; + BevList *bl = cu->bev.first; + Nurb *nu = nubase->first; - for (; bl && nu; bl=bl->next, nu=nu->next) { + for (; bl && nu; bl = bl->next, nu = nu->next) { DispList *dl; float *data; BevPoint *bevp; @@ -1298,34 +1298,34 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (bl->nr) { /* blank bevel lists can happen */ /* exception handling; curve without bevel or extrude, with width correction */ - if (dlbev.first==NULL) { - dl= MEM_callocN(sizeof(DispList), "makeDispListbev"); - dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts"); + if (dlbev.first == NULL) { + dl = MEM_callocN(sizeof(DispList), "makeDispListbev"); + dl->verts = MEM_callocN(3 * sizeof(float) * bl->nr, "dlverts"); BLI_addtail(dispbase, dl); - if (bl->poly!= -1) dl->type= DL_POLY; - else dl->type= DL_SEGM; + if (bl->poly != -1) dl->type = DL_POLY; + else dl->type = DL_SEGM; - if (dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE); + if (dl->type == DL_SEGM) dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE); - dl->parts= 1; - dl->nr= bl->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = bl->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - a= dl->nr; - bevp= (BevPoint *)(bl+1); - data= dl->verts; + a = dl->nr; + bevp = (BevPoint *)(bl + 1); + data = dl->verts; while (a--) { - data[0]= bevp->vec[0]+widfac*bevp->sina; - data[1]= bevp->vec[1]+widfac*bevp->cosa; - data[2]= bevp->vec[2]; + data[0] = bevp->vec[0] + widfac * bevp->sina; + data[1] = bevp->vec[1] + widfac * bevp->cosa; + data[2] = bevp->vec[2]; bevp++; - data+=3; + data += 3; } } else { @@ -1333,7 +1333,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase bottom_capbase = {NULL, NULL}; ListBase top_capbase = {NULL, NULL}; - for (dlb=dlbev.first; dlb; dlb=dlb->next) { + 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; @@ -1341,10 +1341,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba 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)); + 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; @@ -1352,35 +1352,35 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } /* 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*steps, "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbev1"); + dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr * steps, "dlverts"); BLI_addtail(dispbase, dl); - dl->type= DL_SURF; + dl->type = DL_SURF; - 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->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= steps; - dl->nr= dlb->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = steps; + dl->nr = dlb->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+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) + start; - for (i=start, a=0; ataperobj==NULL) { - if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) + if (cu->taperobj == NULL) { + if ( (cu->bevobj != NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { @@ -1388,14 +1388,14 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (bevp->split_tag) { - dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F); + dl->bevelSplitFlag[a >> 5] |= 1 << (a & 0x1F); } /* 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; + 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) { @@ -1416,7 +1416,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { if (a == 1) - fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase); + fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase); if (a == steps - 1) fillBevelCap(nu, dlb, cur_data, &top_capbase); } @@ -1464,7 +1464,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) { - Curve *cu= ob->data; + Curve *cu = ob->data; ListBase *dispbase; /* The same check for duplis as in do_makeDispListCurveTypes. @@ -1473,7 +1473,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; freedisplist(&(ob->disp)); - dispbase= &(ob->disp); + dispbase = &(ob->disp); freedisplist(dispbase); /* free displist used for textspace */ @@ -1482,21 +1482,21 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); if (ob->derivedFinal) { - DM_set_object_boundbox (ob, ob->derivedFinal); + DM_set_object_boundbox(ob, ob->derivedFinal); } else { - boundbox_displist (ob); + boundbox_displist(ob); /* if there is no derivedMesh, object's boundbox is unneeded */ if (ob->bb) { MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; } } } void makeDispListCurveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forOrco) + DerivedMesh **derivedFinal, int forOrco) { do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco); } @@ -1512,16 +1512,16 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int float *orco; if (derivedFinal == NULL) - derivedFinal= ob->derivedFinal; + derivedFinal = ob->derivedFinal; if (!derivedFinal->getVertDataArray(derivedFinal, CD_ORCO)) { curve_calc_orcodm(scene, ob, derivedFinal, forRender); } - orco= derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); + orco = derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); if (orco) { - orco= MEM_dupallocN(orco); + orco = MEM_dupallocN(orco); } return orco; @@ -1530,34 +1530,34 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int /* this is confusing, there's also min_max_object, appplying the obmat... */ static void boundbox_displist(Object *ob) { - BoundBox *bb=NULL; + BoundBox *bb = NULL; float min[3], max[3]; DispList *dl; float *vert; - int a, tot=0; + int a, tot = 0; INIT_MINMAX(min, max); if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - Curve *cu= ob->data; - int doit= 0; + Curve *cu = ob->data; + int doit = 0; - if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= cu->bb; + if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = cu->bb; - dl= ob->disp.first; + dl = ob->disp.first; while (dl) { - if (dl->type==DL_INDEX3) tot= dl->nr; - else tot= dl->nr*dl->parts; + if (dl->type == DL_INDEX3) tot = dl->nr; + else tot = dl->nr * dl->parts; - vert= dl->verts; - for (a=0; averts; + for (a = 0; a < tot; a++, vert += 3) { + doit = 1; DO_MINMAX(vert, min, max); } - dl= dl->next; + dl = dl->next; } if (!doit) { diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index f1942b24810..9d878cd185f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -107,19 +107,19 @@ void free_fcurves(ListBase *list) * as we store reference to next, and freeing only touches the curve * it's given */ - for (fcu= list->first; fcu; fcu= fcn) { - fcn= fcu->next; + for (fcu = list->first; fcu; fcu = fcn) { + fcn = fcu->next; free_fcurve(fcu); } /* clear pointers just in case */ - list->first= list->last= NULL; + list->first = list->last = NULL; } /* ---------------------- Copy --------------------------- */ /* duplicate an F-Curve */ -FCurve *copy_fcurve (FCurve *fcu) +FCurve *copy_fcurve(FCurve *fcu) { FCurve *fcu_d; @@ -128,20 +128,20 @@ FCurve *copy_fcurve (FCurve *fcu) return NULL; /* make a copy */ - fcu_d= MEM_dupallocN(fcu); + fcu_d = MEM_dupallocN(fcu); - fcu_d->next= fcu_d->prev= NULL; - fcu_d->grp= NULL; + fcu_d->next = fcu_d->prev = NULL; + fcu_d->grp = NULL; /* copy curve data */ - fcu_d->bezt= MEM_dupallocN(fcu_d->bezt); - fcu_d->fpt= MEM_dupallocN(fcu_d->fpt); + fcu_d->bezt = MEM_dupallocN(fcu_d->bezt); + fcu_d->fpt = MEM_dupallocN(fcu_d->fpt); /* copy rna-path */ - fcu_d->rna_path= MEM_dupallocN(fcu_d->rna_path); + fcu_d->rna_path = MEM_dupallocN(fcu_d->rna_path); /* copy driver */ - fcu_d->driver= fcurve_copy_driver(fcu_d->driver); + fcu_d->driver = fcurve_copy_driver(fcu_d->driver); /* copy modifiers */ copy_fmodifiers(&fcu_d->modifiers, &fcu->modifiers); @@ -160,11 +160,11 @@ void copy_fcurves(ListBase *dst, ListBase *src) return; /* clear destination list first */ - dst->first= dst->last= NULL; + dst->first = dst->last = NULL; /* copy one-by-one */ - for (sfcu= src->first; sfcu; sfcu= sfcu->next) { - dfcu= copy_fcurve(sfcu); + for (sfcu = src->first; sfcu; sfcu = sfcu->next) { + dfcu = copy_fcurve(sfcu); BLI_addtail(dst, dfcu); } } @@ -175,8 +175,8 @@ void copy_fcurves(ListBase *dst, ListBase *src) FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, char *driven) { /* anim vars */ - AnimData *adt= BKE_animdata_from_id(id); - FCurve *fcu= NULL; + AnimData *adt = BKE_animdata_from_id(id); + FCurve *fcu = NULL; /* rna vars */ PointerRNA ptr; @@ -194,16 +194,16 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro prop = RNA_struct_find_property(&ptr, prop_name); if (prop) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { /* animation takes priority over drivers */ if ((adt->action) && (adt->action->curves.first)) - fcu= list_find_fcurve(&adt->action->curves, path, index); + fcu = list_find_fcurve(&adt->action->curves, path, index); /* if not animated, check if driven */ if ((fcu == NULL) && (adt->drivers.first)) { - fcu= list_find_fcurve(&adt->drivers, path, index); + fcu = list_find_fcurve(&adt->drivers, path, index); if (fcu && driven) *driven = TRUE; fcu = NULL; @@ -218,16 +218,16 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro /* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */ -FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array_index) +FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index) { FCurve *fcu; /* sanity checks */ - if ( ELEM(NULL, list, rna_path) || (array_index < 0) ) + if (ELEM(NULL, list, rna_path) || (array_index < 0) ) return NULL; /* check paths of curves, then array indices... */ - for (fcu= list->first; fcu; fcu= fcu->next) { + for (fcu = list->first; fcu; fcu = fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { /* now check indices */ @@ -241,7 +241,7 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array } /* quick way to loop over all fcurves of a given 'path' */ -FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) +FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[]) { FCurve *fcu; @@ -250,7 +250,7 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) return NULL; /* check paths of curves, then array indices... */ - for (fcu= fcu_iter; fcu; fcu= fcu->next) { + for (fcu = fcu_iter; fcu; fcu = fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { return fcu; @@ -267,8 +267,8 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) * List must be freed after use, and is assumed to be empty when passed. * - src: list of F-Curves to search through * Filters... - * - dataPrefix: i.e. 'pose.bones[' or 'nodes[' - * - dataName: name of entity within "" immediately following the prefix + * - dataPrefix: i.e. 'pose.bones[' or 'nodes[' + * - dataName: name of entity within "" immediately following the prefix */ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName) { @@ -282,17 +282,17 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, return 0; /* search each F-Curve one by one */ - for (fcu= src->first; fcu; fcu= fcu->next) { + for (fcu = src->first; fcu; fcu = fcu->next) { /* check if quoted string matches the path */ if ((fcu->rna_path) && strstr(fcu->rna_path, dataPrefix)) { - char *quotedName= BLI_getQuotedStr(fcu->rna_path, dataPrefix); + char *quotedName = BLI_getQuotedStr(fcu->rna_path, dataPrefix); if (quotedName) { /* check if the quoted name matches the required name */ if (strcmp(quotedName, dataName) == 0) { - LinkData *ld= MEM_callocN(sizeof(LinkData), "list_find_data_fcurves"); + LinkData *ld = MEM_callocN(sizeof(LinkData), "list_find_data_fcurves"); - ld->data= fcu; + ld->data = fcu; BLI_addtail(dst, ld); matches++; @@ -308,37 +308,37 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, return matches; } -FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) +FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) { - FCurve *fcu= NULL; + FCurve *fcu = NULL; - *driven= 0; + *driven = 0; /* there must be some RNA-pointer + property combon */ if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { - AnimData *adt= BKE_animdata_from_id(ptr->id.data); + AnimData *adt = BKE_animdata_from_id(ptr->id.data); char *path; if (adt) { if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) { /* XXX this function call can become a performance bottleneck */ - path= RNA_path_from_ID_to_property(ptr, prop); + path = RNA_path_from_ID_to_property(ptr, prop); if (path) { /* animation takes priority over drivers */ if (adt->action && adt->action->curves.first) - fcu= list_find_fcurve(&adt->action->curves, path, rnaindex); + fcu = list_find_fcurve(&adt->action->curves, path, rnaindex); /* if not animated, check if driven */ if (!fcu && (adt->drivers.first)) { - fcu= list_find_fcurve(&adt->drivers, path, rnaindex); + fcu = list_find_fcurve(&adt->drivers, path, rnaindex); if (fcu) - *driven= 1; + *driven = 1; } if (fcu && action) - *action= adt->action; + *action = adt->action; MEM_freeN(path); } @@ -352,18 +352,18 @@ FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bActio /* ----------------- Finding Keyframes/Extents -------------------------- */ /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */ -#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ +#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ /* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve) * Returns the index to insert at (data already at that index will be offset if replace is 0) */ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short *replace) { - int start=0, end=arraylen; - int loopbreaker= 0, maxloop= arraylen * 2; + int start = 0, end = arraylen; + int loopbreaker = 0, maxloop = arraylen * 2; /* initialize replace-flag first */ - *replace= 0; + *replace = 0; /* sneaky optimisations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds @@ -378,7 +378,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short float framenum; /* 'First' Keyframe (when only one keyframe, this case is used) */ - framenum= array[0].vec[1][0]; + framenum = array[0].vec[1][0]; if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) { *replace = 1; return 0; @@ -387,9 +387,9 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short return 0; /* 'Last' Keyframe */ - framenum= array[(arraylen-1)].vec[1][0]; + framenum = array[(arraylen - 1)].vec[1][0]; if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) { - *replace= 1; + *replace = 1; return (arraylen - 1); } else if (frame > framenum) @@ -400,10 +400,10 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* most of the time, this loop is just to find where to put it * 'loopbreaker' is just here to prevent infinite loops */ - for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { + for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { /* compute and get midpoint */ - int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ - float midfra= array[mid].vec[1][0]; + int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ + float midfra = array[mid].vec[1][0]; /* check if exactly equal to midpoint */ if (IS_EQT(frame, midfra, BEZT_BINARYSEARCH_THRESH)) { @@ -413,13 +413,13 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* repeat in upper/lower half */ if (frame > midfra) - start= mid + 1; + start = mid + 1; else if (frame < midfra) - end= mid - 1; + end = mid - 1; } /* print error if loop-limit exceeded */ - if (loopbreaker == (maxloop-1)) { + if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_bezt_index() was taking too long\n"); // include debug info @@ -433,8 +433,8 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* ...................................... */ /* helper for calc_fcurve_* functions -> find first and last BezTriple to be used */ -static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last, - const short do_sel_only) +static void get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple **last, + const short do_sel_only) { /* init outputs */ *first = NULL; @@ -451,18 +451,18 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple /* find first selected */ bezt = fcu->bezt; - for (i=0; i < fcu->totvert; bezt++, i++) { + for (i = 0; i < fcu->totvert; bezt++, i++) { if (BEZSELECTED(bezt)) { - *first= bezt; + *first = bezt; break; } } /* find last selected */ bezt = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, sizeof(BezTriple), fcu->totvert); - for (i=0; i < fcu->totvert; bezt--, i++) { + for (i = 0; i < fcu->totvert; bezt--, i++) { if (BEZSELECTED(bezt)) { - *last= bezt; + *last = bezt; break; } } @@ -479,14 +479,14 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, const short do_sel_only) { - float xminv=999999999.0f, xmaxv=-999999999.0f; - float yminv=999999999.0f, ymaxv=-999999999.0f; - short foundvert= FALSE; + float xminv = 999999999.0f, xmaxv = -999999999.0f; + float yminv = 999999999.0f, ymaxv = -999999999.0f; + short foundvert = FALSE; unsigned int i; if (fcu->totvert) { if (fcu->bezt) { - BezTriple *bezt_first= NULL, *bezt_last= NULL; + BezTriple *bezt_first = NULL, *bezt_last = NULL; if (xmin || xmax) { /* get endpoint keyframes */ @@ -495,8 +495,8 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa if (bezt_first) { BLI_assert(bezt_last != NULL); - xminv= MIN2(xminv, bezt_first->vec[1][0]); - xmaxv= MAX2(xmaxv, bezt_last->vec[1][0]); + xminv = MIN2(xminv, bezt_first->vec[1][0]); + xmaxv = MAX2(xmaxv, bezt_last->vec[1][0]); } } @@ -504,13 +504,13 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa if (ymin || ymax) { BezTriple *bezt; - for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) { + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { if ((do_sel_only == 0) || BEZSELECTED(bezt)) { if (bezt->vec[1][1] < yminv) - yminv= bezt->vec[1][1]; + yminv = bezt->vec[1][1]; if (bezt->vec[1][1] > ymaxv) - ymaxv= bezt->vec[1][1]; - foundvert= TRUE; + ymaxv = bezt->vec[1][1]; + foundvert = TRUE; } } } @@ -518,42 +518,42 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa else if (fcu->fpt) { /* frame range can be directly calculated from end verts */ if (xmin || xmax) { - xminv= MIN2(xminv, fcu->fpt[0].vec[0]); - xmaxv= MAX2(xmaxv, fcu->fpt[fcu->totvert-1].vec[0]); + xminv = MIN2(xminv, fcu->fpt[0].vec[0]); + xmaxv = MAX2(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]); } /* only loop over keyframes to find extents for values if needed */ if (ymin || ymax) { FPoint *fpt; - for (fpt=fcu->fpt, i=0; i < fcu->totvert; fpt++, i++) { + for (fpt = fcu->fpt, i = 0; i < fcu->totvert; fpt++, i++) { if (fpt->vec[1] < yminv) - yminv= fpt->vec[1]; + yminv = fpt->vec[1]; if (fpt->vec[1] > ymaxv) - ymaxv= fpt->vec[1]; + ymaxv = fpt->vec[1]; - foundvert= TRUE; + foundvert = TRUE; } } } } if (foundvert) { - if (xmin) *xmin= xminv; - if (xmax) *xmax= xmaxv; + if (xmin) *xmin = xminv; + if (xmax) *xmax = xmaxv; - if (ymin) *ymin= yminv; - if (ymax) *ymax= ymaxv; + if (ymin) *ymin = yminv; + if (ymax) *ymax = ymaxv; } else { if (G.debug & G_DEBUG) printf("F-Curve calc bounds didn't find anything, so assuming minimum bounds of 1.0\n"); - if (xmin) *xmin= 0.0f; - if (xmax) *xmax= 1.0f; + if (xmin) *xmin = 0.0f; + if (xmax) *xmax = 1.0f; - if (ymin) *ymin= 0.0f; - if (ymax) *ymax= 1.0f; + if (ymin) *ymin = 0.0f; + if (ymax) *ymax = 1.0f; } } @@ -561,12 +561,12 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa void calc_fcurve_range(FCurve *fcu, float *start, float *end, const short do_sel_only, const short do_min_length) { - float min=999999999.0f, max=-999999999.0f; - short foundvert= FALSE; + float min = 999999999.0f, max = -999999999.0f; + short foundvert = FALSE; if (fcu->totvert) { if (fcu->bezt) { - BezTriple *bezt_first= NULL, *bezt_last= NULL; + BezTriple *bezt_first = NULL, *bezt_last = NULL; /* get endpoint keyframes */ get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only); @@ -574,23 +574,23 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end, if (bezt_first) { BLI_assert(bezt_last != NULL); - min= MIN2(min, bezt_first->vec[1][0]); - max= MAX2(max, bezt_last->vec[1][0]); + min = MIN2(min, bezt_first->vec[1][0]); + max = MAX2(max, bezt_last->vec[1][0]); - foundvert= TRUE; + foundvert = TRUE; } } else if (fcu->fpt) { - min= MIN2(min, fcu->fpt[0].vec[0]); - max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]); + min = MIN2(min, fcu->fpt[0].vec[0]); + max = MAX2(max, fcu->fpt[fcu->totvert - 1].vec[0]); - foundvert= TRUE; + foundvert = TRUE; } } if (foundvert == FALSE) { - min= max= 0.0f; + min = max = 0.0f; } if (do_min_length) { @@ -600,8 +600,8 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end, } } - *start= min; - *end= max; + *start = min; + *end = max; } /* ----------------- Status Checks -------------------------- */ @@ -628,7 +628,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu) // TODO: optionally, only check modifier if it is the active one... for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { /* ignore if muted/disabled */ - if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) + if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) continue; /* type checks */ @@ -647,7 +647,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu) if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) return 0; } - break; + break; case FMODIFIER_TYPE_FN_GENERATOR: { FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; @@ -655,7 +655,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu) if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) return 0; } - break; + break; /* always harmful - cannot allow */ default: @@ -692,10 +692,10 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt) { CfraElem *ce, *cen; - for (ce= lb->first; ce; ce= ce->next) { + for (ce = lb->first; ce; ce = ce->next) { /* double key? */ if (ce->cfra == bezt->vec[1][0]) { - if (bezt->f2 & SELECT) ce->sel= bezt->f2; + if (bezt->f2 & SELECT) ce->sel = bezt->f2; return; } /* should key be inserted before this column? */ @@ -703,12 +703,12 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt) } /* create a new column */ - cen= MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); + cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); if (ce) BLI_insertlinkbefore(lb, ce, cen); else BLI_addtail(lb, cen); - cen->cfra= bezt->vec[1][0]; - cen->sel= bezt->f2; + cen->cfra = bezt->vec[1][0]; + cen->sel = bezt->f2; } /* ***************************** Samples Utilities ******************************* */ @@ -748,12 +748,12 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample } /* set up sample data */ - fpt= new_fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "FPoint Samples"); + fpt = new_fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "FPoint Samples"); /* use the sampling callback at 1-frame intervals from start to end frames */ - for (cfra= start; cfra <= end; cfra++, fpt++) { - fpt->vec[0]= (float)cfra; - fpt->vec[1]= sample_cb(fcu, data, (float)cfra); + for (cfra = start; cfra <= end; cfra++, fpt++) { + fpt->vec[0] = (float)cfra; + fpt->vec[1] = sample_cb(fcu, data, (float)cfra); } /* free any existing sample/keyframe data on curve */ @@ -761,9 +761,9 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample if (fcu->fpt) MEM_freeN(fcu->fpt); /* store the samples */ - fcu->bezt= NULL; - fcu->fpt= new_fpt; - fcu->totvert= end - start + 1; + fcu->bezt = NULL; + fcu->fpt = new_fpt; + fcu->totvert = end - start + 1; } /* ***************************** F-Curve Sanity ********************************* */ @@ -778,7 +778,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample void calchandles_fcurve(FCurve *fcu) { BezTriple *bezt, *prev, *next; - int a= fcu->totvert; + int a = fcu->totvert; /* Error checking: * - need at least two points @@ -789,33 +789,33 @@ void calchandles_fcurve(FCurve *fcu) return; /* get initial pointers */ - bezt= fcu->bezt; - prev= NULL; - next= (bezt + 1); + bezt = fcu->bezt; + prev = NULL; + next = (bezt + 1); /* loop over all beztriples, adjusting handles */ while (a--) { /* clamp timing of handles to be on either side of beztriple */ - if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0]= bezt->vec[1][0]; - if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0]; + if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0] = bezt->vec[1][0]; + if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0] = bezt->vec[1][0]; /* calculate auto-handles */ - BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ + BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ /* for automatic ease in and out */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* only do this on first or last beztriple */ - if ((a == 0) || (a == fcu->totvert-1)) { + if ((a == 0) || (a == fcu->totvert - 1)) { /* set both handles to have same horizontal value as keyframe */ if (fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) { - bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1]; + bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1]; } } } /* advance pointers for next iteration */ - prev= bezt; - if (a == 1) next= NULL; + prev = bezt; + if (a == 1) next = NULL; else next++; bezt++; } @@ -824,8 +824,8 @@ void calchandles_fcurve(FCurve *fcu) /* Use when F-Curve with handles has changed * It treats all BezTriples with the following rules: * - PHASE 1: do types have to be altered? - * -> Auto handles: become aligned when selection status is NOT(000 || 111) - * -> Vector handles: become 'nothing' when (one half selected AND other not) + * -> Auto handles: become aligned when selection status is NOT(000 || 111) + * -> Vector handles: become 'nothing' when (one half selected AND other not) * - PHASE 2: recalculate handles */ void testhandles_fcurve(FCurve *fcu, const short use_handle) @@ -838,41 +838,41 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle) return; /* loop over beztriples */ - for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) { - short flag= 0; + for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) { + short flag = 0; /* flag is initialized as selection status * of beztriple control-points (labelled 0,1,2) */ - if (bezt->f2 & SELECT) flag |= (1<<1); // == 2 + if (bezt->f2 & SELECT) flag |= (1 << 1); // == 2 if (use_handle == FALSE) { if (flag & 2) { - flag |= (1<<0) | (1<<2); + flag |= (1 << 0) | (1 << 2); } } else { - if (bezt->f1 & SELECT) flag |= (1<<0); // == 1 - if (bezt->f3 & SELECT) flag |= (1<<2); // == 4 + if (bezt->f1 & SELECT) flag |= (1 << 0); // == 1 + if (bezt->f3 & SELECT) flag |= (1 << 2); // == 4 } /* one or two handles selected only */ - if (ELEM(flag, 0, 7)==0) { + if (ELEM(flag, 0, 7) == 0) { /* auto handles become aligned */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) - bezt->h1= HD_ALIGN; + bezt->h1 = HD_ALIGN; if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) - bezt->h2= HD_ALIGN; + bezt->h2 = HD_ALIGN; /* vector handles become 'free' when only one half selected */ - if (bezt->h1==HD_VECT) { + if (bezt->h1 == HD_VECT) { /* only left half (1 or 2 or 1+2) */ if (flag < 4) - bezt->h1= 0; + bezt->h1 = 0; } - if (bezt->h2==HD_VECT) { + if (bezt->h2 == HD_VECT) { /* only right half (4 or 2+4) */ if (flag > 3) - bezt->h2= 0; + bezt->h2 = 0; } } } @@ -886,11 +886,11 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle) */ void sort_time_fcurve(FCurve *fcu) { - short ok= 1; + short ok = 1; /* keep adjusting order of beztriples until nothing moves (bubble-sort) */ while (ok) { - ok= 0; + ok = 0; /* currently, will only be needed when there are beztriples */ if (fcu->bezt) { @@ -898,13 +898,13 @@ void sort_time_fcurve(FCurve *fcu) unsigned int a; /* loop over ALL points to adjust position in array and recalculate handles */ - for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) { + for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) { /* check if thee's a next beztriple which we could try to swap with current */ - if (a < (fcu->totvert-1)) { + if (a < (fcu->totvert - 1)) { /* swap if one is after the other (and indicate that order has changed) */ - if (bezt->vec[1][0] > (bezt+1)->vec[1][0]) { - SWAP(BezTriple, *bezt, *(bezt+1)); - ok= 1; + if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) { + SWAP(BezTriple, *bezt, *(bezt + 1)); + ok = 1; } /* if either one of both of the points exceeds crosses over the keyframe time... */ @@ -916,9 +916,9 @@ void sort_time_fcurve(FCurve *fcu) else { /* clamp handles */ if (bezt->vec[0][0] > bezt->vec[1][0]) - bezt->vec[0][0]= bezt->vec[1][0]; + bezt->vec[0][0] = bezt->vec[1][0]; if (bezt->vec[2][0] < bezt->vec[1][0]) - bezt->vec[2][0]= bezt->vec[1][0]; + bezt->vec[2][0] = bezt->vec[1][0]; } } } @@ -940,8 +940,8 @@ short test_time_fcurve(FCurve *fcu) BezTriple *bezt; /* loop through all BezTriples, stopping when one exceeds the one after it */ - for (a=0, bezt= fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) { - if (bezt->vec[1][0] > (bezt+1)->vec[1][0]) + for (a = 0, bezt = fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) { + if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) return 1; } } @@ -949,8 +949,8 @@ short test_time_fcurve(FCurve *fcu) FPoint *fpt; /* loop through all FPoints, stopping when one exceeds the one after it */ - for (a=0, fpt= fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) { - if (fpt->vec[0] > (fpt+1)->vec[0]) + for (a = 0, fpt = fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) { + if (fpt->vec[0] > (fpt + 1)->vec[0]) return 1; } } @@ -969,9 +969,9 @@ typedef struct DriverVarTypeInfo { float (*get_value)(ChannelDriver *driver, DriverVar *dvar); /* allocation of target slots */ - int num_targets; /* number of target slots required */ - const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */ - int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */ + int num_targets; /* number of target slots required */ + const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */ + int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */ } DriverVarTypeInfo; /* Macro to begin definitions */ @@ -986,25 +986,25 @@ typedef struct DriverVarTypeInfo { static ID *dtar_id_ensure_proxy_from(ID *id) { - if (id && GS(id->name)==ID_OB && ((Object *)id)->proxy_from) + if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from) return (ID *)(((Object *)id)->proxy_from); return id; } /* Helper function to obtain a value using RNA from the specified source (for evaluating drivers) */ -static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) +static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar) { PointerRNA id_ptr, ptr; PropertyRNA *prop; ID *id; int index; - float value= 0.0f; + float value = 0.0f; /* sanity check */ if (ELEM(NULL, driver, dtar)) return 0.0f; - id= dtar_id_ensure_proxy_from(dtar->id); + id = dtar_id_ensure_proxy_from(dtar->id); /* error check for missing pointer... */ // TODO: tag the specific target too as having issues @@ -1024,37 +1024,37 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) /* array */ if (index < RNA_property_array_length(&ptr, prop)) { switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - value= (float)RNA_property_boolean_get_index(&ptr, prop, index); - break; - case PROP_INT: - value= (float)RNA_property_int_get_index(&ptr, prop, index); - break; - case PROP_FLOAT: - value= RNA_property_float_get_index(&ptr, prop, index); - break; - default: - break; + case PROP_BOOLEAN: + value = (float)RNA_property_boolean_get_index(&ptr, prop, index); + break; + case PROP_INT: + value = (float)RNA_property_int_get_index(&ptr, prop, index); + break; + case PROP_FLOAT: + value = RNA_property_float_get_index(&ptr, prop, index); + break; + default: + break; } } } else { /* not an array */ switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - value= (float)RNA_property_boolean_get(&ptr, prop); - break; - case PROP_INT: - value= (float)RNA_property_int_get(&ptr, prop); - break; - case PROP_FLOAT: - value= RNA_property_float_get(&ptr, prop); - break; - case PROP_ENUM: - value= (float)RNA_property_enum_get(&ptr, prop); - break; - default: - break; + case PROP_BOOLEAN: + value = (float)RNA_property_boolean_get(&ptr, prop); + break; + case PROP_INT: + value = (float)RNA_property_int_get(&ptr, prop); + break; + case PROP_FLOAT: + value = RNA_property_float_get(&ptr, prop); + break; + case PROP_ENUM: + value = (float)RNA_property_enum_get(&ptr, prop); + break; + default: + break; } } @@ -1071,18 +1071,18 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) } /* Helper function to obtain a pointer to a Pose Channel (for evaluating drivers) */ -static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dtar) +static bPoseChannel *dtar_get_pchan_ptr(ChannelDriver *driver, DriverTarget *dtar) { ID *id; /* sanity check */ if (ELEM(NULL, driver, dtar)) return NULL; - id= dtar_id_ensure_proxy_from(dtar->id); + id = dtar_id_ensure_proxy_from(dtar->id); /* check if the ID here is a valid object */ if (id && GS(id->name)) { - Object *ob= (Object *)id; + Object *ob = (Object *)id; /* get pose, and subsequently, posechannel */ return BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); @@ -1096,21 +1096,21 @@ static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dt /* ......... */ /* evaluate 'single prop' driver variable */ -static float dvar_eval_singleProp (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_singleProp(ChannelDriver *driver, DriverVar *dvar) { /* just evaluate the first target slot */ return dtar_get_prop_val(driver, &dvar->targets[0]); } /* evaluate 'rotation difference' driver variable */ -static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar) { bPoseChannel *pchan, *pchan2; float q1[4], q2[4], quat[4], angle; /* get pose channels, and check if we've got two */ - pchan= dtar_get_pchan_ptr(driver, &dvar->targets[0]); - pchan2= dtar_get_pchan_ptr(driver, &dvar->targets[1]); + pchan = dtar_get_pchan_ptr(driver, &dvar->targets[0]); + pchan2 = dtar_get_pchan_ptr(driver, &dvar->targets[1]); if (ELEM(NULL, pchan, pchan2)) { /* disable this driver, since it doesn't work correctly... */ @@ -1135,14 +1135,14 @@ static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar) invert_qt(q1); mul_qt_qtqt(quat, q1, q2); angle = 2.0f * (saacos(quat[0])); - angle= ABS(angle); + angle = ABS(angle); return (angle > (float)M_PI) ? (float)((2.0f * (float)M_PI) - angle) : (float)(angle); } /* evaluate 'location difference' driver variable */ // TODO: this needs to take into account space conversions... -static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) { float loc1[3] = {0.0f, 0.0f, 0.0f}; float loc2[3] = {0.0f, 0.0f, 0.0f}; @@ -1152,7 +1152,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) DRIVER_TARGETS_USED_LOOPER(dvar) { /* get pointer to loc values to store in */ - Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); + Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float tmp_loc[3]; @@ -1164,7 +1164,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) } /* try to get posechannel */ - pchan= BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); + pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); /* check if object or bone */ if (pchan) { @@ -1234,14 +1234,14 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) } /* evaluate 'transform channel' driver variable */ -static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; - Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); + DriverTarget *dtar = &dvar->targets[0]; + Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float mat[4][4]; float oldEul[3] = {0.0f, 0.0f, 0.0f}; - short useEulers=0, rotOrder=ROT_MODE_EUL; + short useEulers = 0, rotOrder = ROT_MODE_EUL; /* check if this target has valid data */ if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) { @@ -1251,7 +1251,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) } /* try to get posechannel */ - pchan= BKE_pose_channel_find_name(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 @@ -1263,7 +1263,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* bone */ if (pchan->rotmode > 0) { copy_v3_v3(oldEul, pchan->eul); - rotOrder= pchan->rotmode; + rotOrder = pchan->rotmode; useEulers = 1; } @@ -1290,7 +1290,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* object */ if (ob->rotmode > 0) { copy_v3_v3(oldEul, ob->rot); - rotOrder= ob->rotmode; + rotOrder = ob->rotmode; useEulers = 1; } @@ -1353,36 +1353,36 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* Table of Driver Varaiable Type Info Data */ static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = { BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP) - dvar_eval_singleProp, /* eval callback */ - 1, /* number of targets used */ - {"Property"}, /* UI names for targets */ - {0} /* flags */ + dvar_eval_singleProp, /* eval callback */ + 1, /* number of targets used */ + {"Property"}, /* UI names for targets */ + {0} /* flags */ END_DVAR_TYPEDEF, BEGIN_DVAR_TYPEDEF(DVAR_TYPE_ROT_DIFF) - dvar_eval_rotDiff, /* eval callback */ - 2, /* number of targets used */ - {"Bone 1", "Bone 2"}, /* UI names for targets */ - {DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */ + dvar_eval_rotDiff, /* eval callback */ + 2, /* number of targets used */ + {"Bone 1", "Bone 2"}, /* UI names for targets */ + {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */ END_DVAR_TYPEDEF, BEGIN_DVAR_TYPEDEF(DVAR_TYPE_LOC_DIFF) - dvar_eval_locDiff, /* eval callback */ - 2, /* number of targets used */ - {"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */ - {DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */ + dvar_eval_locDiff, /* eval callback */ + 2, /* number of targets used */ + {"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */ + {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */ END_DVAR_TYPEDEF, BEGIN_DVAR_TYPEDEF(DVAR_TYPE_TRANSFORM_CHAN) - dvar_eval_transChan, /* eval callback */ - 1, /* number of targets used */ - {"Object/Bone"}, /* UI names for targets */ - {DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */ + dvar_eval_transChan, /* eval callback */ + 1, /* number of targets used */ + {"Object/Bone"}, /* UI names for targets */ + {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */ END_DVAR_TYPEDEF, }; /* Get driver variable typeinfo */ -static DriverVarTypeInfo *get_dvar_typeinfo (int type) +static DriverVarTypeInfo *get_dvar_typeinfo(int type) { /* check if valid type */ if ((type >= 0) && (type < MAX_DVAR_TYPES)) @@ -1403,7 +1403,7 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) /* free target vars * - need to go over all of them, not just up to the ones that are used * currently, since there may be some lingering RNA paths from - * previous users needing freeing + * previous users needing freeing */ DRIVER_TARGETS_LOOPER(dvar) { @@ -1418,7 +1418,7 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ - if (driver->type==DRIVER_TYPE_PYTHON) + if (driver->type == DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif } @@ -1426,15 +1426,15 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) /* Change the type of driver variable */ void driver_change_variable_type(DriverVar *dvar, int type) { - DriverVarTypeInfo *dvti= get_dvar_typeinfo(type); + DriverVarTypeInfo *dvti = get_dvar_typeinfo(type); /* sanity check */ if (ELEM(NULL, dvar, dvti)) return; /* set the new settings */ - dvar->type= type; - dvar->num_targets= dvti->num_targets; + dvar->type = type; + dvar->num_targets = dvti->num_targets; /* make changes to the targets based on the defines for these types * NOTE: only need to make sure the ones we're using here are valid... @@ -1448,13 +1448,13 @@ void driver_change_variable_type(DriverVar *dvar, int type) /* object ID types only, or idtype not yet initialized*/ if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0)) - dtar->idtype= ID_OB; + dtar->idtype = ID_OB; } DRIVER_TARGETS_LOOPER_END } /* Add a new driver variable */ -DriverVar *driver_add_new_variable (ChannelDriver *driver) +DriverVar *driver_add_new_variable(ChannelDriver *driver) { DriverVar *dvar; @@ -1463,7 +1463,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) return NULL; /* make a new variable */ - dvar= MEM_callocN(sizeof(DriverVar), "DriverVar"); + dvar = MEM_callocN(sizeof(DriverVar), "DriverVar"); BLI_addtail(&driver->variables, dvar); /* give the variable a 'unique' name */ @@ -1475,7 +1475,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ - if (driver->type==DRIVER_TYPE_PYTHON) + if (driver->type == DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif @@ -1492,11 +1492,11 @@ void fcurve_free_driver(FCurve *fcu) /* sanity checks */ if (ELEM(NULL, fcu, fcu->driver)) return; - driver= fcu->driver; + driver = fcu->driver; /* free driver targets */ - for (dvar= driver->variables.first; dvar; dvar= dvarn) { - dvarn= dvar->next; + for (dvar = driver->variables.first; dvar; dvar = dvarn) { + dvarn = dvar->next; driver_free_variable(driver, dvar); } @@ -1508,11 +1508,11 @@ void fcurve_free_driver(FCurve *fcu) /* free driver itself, then set F-Curve's point to this to NULL (as the curve may still be used) */ MEM_freeN(driver); - fcu->driver= NULL; + fcu->driver = NULL; } /* This makes a copy of the given driver */ -ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) +ChannelDriver *fcurve_copy_driver(ChannelDriver *driver) { ChannelDriver *ndriver; DriverVar *dvar; @@ -1522,14 +1522,14 @@ ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) return NULL; /* copy all data */ - ndriver= MEM_dupallocN(driver); - ndriver->expr_comp= NULL; + ndriver = MEM_dupallocN(driver); + ndriver->expr_comp = NULL; /* copy variables */ - ndriver->variables.first= ndriver->variables.last= NULL; + ndriver->variables.first = ndriver->variables.last = NULL; BLI_duplicatelist(&ndriver->variables, &driver->variables); - for (dvar= ndriver->variables.first; dvar; dvar= dvar->next) { + for (dvar = ndriver->variables.first; dvar; dvar = dvar->next) { /* need to go over all targets so that we don't leave any dangling paths */ DRIVER_TARGETS_LOOPER(dvar) { @@ -1559,21 +1559,21 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar) * using the variable type info, storing the obtained value * in dvar->curval so that drivers can be debugged */ - dvti= get_dvar_typeinfo(dvar->type); + dvti = get_dvar_typeinfo(dvar->type); if (dvti && dvti->get_value) - dvar->curval= dvti->get_value(driver, dvar); + dvar->curval = dvti->get_value(driver, dvar); else - dvar->curval= 0.0f; + dvar->curval = 0.0f; return dvar->curval; } /* Evaluate an Channel-Driver to get a 'time' value to use instead of "evaltime" * - "evaltime" is the frame at which F-Curve is being evaluated - * - has to return a float value + * - has to return a float value */ -static float evaluate_driver (ChannelDriver *driver, const float evaltime) +static float evaluate_driver(ChannelDriver *driver, const float evaltime) { DriverVar *dvar; @@ -1588,8 +1588,8 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) /* check how many variables there are first (i.e. just one?) */ if (driver->variables.first == driver->variables.last) { /* just one target, so just use that */ - dvar= driver->variables.first; - driver->curval= driver_get_variable_value(driver, dvar); + dvar = driver->variables.first; + driver->curval = driver_get_variable_value(driver, dvar); } else { /* more than one target, so average the values of the targets */ @@ -1597,19 +1597,19 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) int tot = 0; /* loop through targets, adding (hopefully we don't get any overflow!) */ - for (dvar= driver->variables.first; dvar; dvar=dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { value += driver_get_variable_value(driver, dvar); tot++; } /* perform operations on the total if appropriate */ if (driver->type == DRIVER_TYPE_AVERAGE) - driver->curval= (value / (float)tot); + driver->curval = (value / (float)tot); else - driver->curval= value; + driver->curval = value; } } - break; + break; case DRIVER_TYPE_MIN: /* smallest value */ case DRIVER_TYPE_MAX: /* largest value */ @@ -1617,9 +1617,9 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) float value = 0.0f; /* loop through the variables, getting the values and comparing them to existing ones */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* get value */ - float tmp_val= driver_get_variable_value(driver, dvar); + float tmp_val = driver_get_variable_value(driver, dvar); /* store this value if appropriate */ if (dvar->prev) { @@ -1627,51 +1627,51 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) if (driver->type == DRIVER_TYPE_MAX) { /* max? */ if (tmp_val > value) - value= tmp_val; + value = tmp_val; } else { /* min? */ if (tmp_val < value) - value= tmp_val; + value = tmp_val; } } else { /* first item - make this the baseline for comparisons */ - value= tmp_val; + value = tmp_val; } } /* store value in driver */ - driver->curval= value; + driver->curval = value; } - break; + break; case DRIVER_TYPE_PYTHON: /* expression */ { #ifdef WITH_PYTHON /* check for empty or invalid expression */ if ( (driver->expression[0] == '\0') || - (driver->flag & DRIVER_FLAG_INVALID) ) + (driver->flag & DRIVER_FLAG_INVALID) ) { - driver->curval= 0.0f; + driver->curval = 0.0f; } else { /* this evaluates the expression using Python, and returns its result: - * - on errors it reports, then returns 0.0f + * - on errors it reports, then returns 0.0f */ - driver->curval= BPY_driver_exec(driver, evaltime); + driver->curval = BPY_driver_exec(driver, evaltime); } #else /* WITH_PYTHON*/ - (void)evaltime; + (void)evaltime; #endif /* WITH_PYTHON*/ } - break; + break; default: { /* special 'hack' - just use stored value * This is currently used as the mechanism which allows animated settings to be able - * to be changed via the UI. + * to be changed via the UI. */ } } @@ -1691,127 +1691,127 @@ void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2]) float h1[2], h2[2], len1, len2, len, fac; /* calculate handle deltas */ - h1[0]= v1[0] - v2[0]; - h1[1]= v1[1] - v2[1]; + h1[0] = v1[0] - v2[0]; + h1[1] = v1[1] - v2[1]; - h2[0]= v4[0] - v3[0]; - h2[1]= v4[1] - v3[1]; + h2[0] = v4[0] - v3[0]; + h2[1] = v4[1] - v3[1]; /* calculate distances: - * - len = span of time between keyframes + * - len = span of time between keyframes * - len1 = length of handle of start key - * - len2 = length of handle of end key + * - len2 = length of handle of end key */ - len= v4[0]- v1[0]; - len1= fabsf(h1[0]); - len2= fabsf(h2[0]); + len = v4[0] - v1[0]; + len1 = fabsf(h1[0]); + len2 = fabsf(h2[0]); /* if the handles have no length, no need to do any corrections */ - if ((len1+len2) == 0.0f) + if ((len1 + len2) == 0.0f) return; /* the two handles cross over each other, so force them * apart using the proportion they overlap */ - if ((len1+len2) > len) { - fac= len / (len1+len2); + if ((len1 + len2) > len) { + fac = len / (len1 + len2); - v2[0]= (v1[0] - fac*h1[0]); - v2[1]= (v1[1] - fac*h1[1]); + v2[0] = (v1[0] - fac * h1[0]); + v2[1] = (v1[1] - fac * h1[1]); - v3[0]= (v4[0] - fac*h2[0]); - v3[1]= (v4[1] - fac*h2[1]); + v3[0] = (v4[0] - fac * h2[0]); + v3[1] = (v4[1] - fac * h2[1]); } } /* find root ('zero') */ -static int findzero (float x, float q0, float q1, float q2, float q3, float *o) +static int findzero(float x, float q0, float q1, float q2, float q3, float *o) { double c0, c1, c2, c3, a, b, c, p, q, d, t, phi; - int nr= 0; + int nr = 0; - c0= q0 - x; - c1= 3.0f * (q1 - q0); - c2= 3.0f * (q0 - 2.0f*q1 + q2); - c3= q3 - q0 + 3.0f * (q1 - q2); + c0 = q0 - x; + c1 = 3.0f * (q1 - q0); + c2 = 3.0f * (q0 - 2.0f * q1 + q2); + c3 = q3 - q0 + 3.0f * (q1 - q2); if (c3 != 0.0) { - a= c2/c3; - b= c1/c3; - c= c0/c3; - a= a/3; - - p= b/3 - a*a; - q= (2*a*a*a - a*b + c) / 2; - d= q*q + p*p*p; + a = c2 / c3; + b = c1 / c3; + c = c0 / c3; + a = a / 3; + + p = b / 3 - a * a; + q = (2 * a * a * a - a * b + c) / 2; + d = q * q + p * p * p; if (d > 0.0) { - t= sqrt(d); - o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a); + t = sqrt(d); + o[0] = (float)(sqrt3d(-q + t) + sqrt3d(-q - t) - a); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } else if (d == 0.0) { - t= sqrt3d(-q); - o[0]= (float)(2*t - a); + t = sqrt3d(-q); + o[0] = (float)(2 * t - a); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; - o[nr]= (float)(-t-a); + o[nr] = (float)(-t - a); - if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1; else return nr; } else { - phi= acos(-q / sqrt(-(p*p*p))); - t= sqrt(-p); - p= cos(phi/3); - q= sqrt(3 - 3*p*p); - o[0]= (float)(2*t*p - a); + phi = acos(-q / sqrt(-(p * p * p))); + t = sqrt(-p); + p = cos(phi / 3); + q = sqrt(3 - 3 * p * p); + o[0] = (float)(2 * t * p - a); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; - o[nr]= (float)(-t * (p + q) - a); + o[nr] = (float)(-t * (p + q) - a); if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) nr++; - o[nr]= (float)(-t * (p - q) - a); + o[nr] = (float)(-t * (p - q) - a); - if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1; else return nr; } } else { - a=c2; - b=c1; - c=c0; + a = c2; + b = c1; + c = c0; if (a != 0.0) { // discriminant - p= b*b - 4*a*c; + p = b * b - 4 * a * c; if (p > 0) { - p= sqrt(p); - o[0]= (float)((-b-p) / (2 * a)); + p = sqrt(p); + o[0] = (float)((-b - p) / (2 * a)); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; - o[nr]= (float)((-b+p)/(2*a)); + o[nr] = (float)((-b + p) / (2 * a)); - if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1; else return nr; } else if (p == 0) { - o[0]= (float)(-b / (2 * a)); + o[0] = (float)(-b / (2 * a)); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } } else if (b != 0.0) { - o[0]= (float)(-c/b); + o[0] = (float)(-c / b); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } else if (c == 0.0) { - o[0]= 0.0; + o[0] = 0.0; return 1; } @@ -1819,36 +1819,36 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) } } -static void berekeny (float f1, float f2, float f3, float f4, float *o, int b) +static void berekeny(float f1, float f2, float f3, float f4, float *o, int b) { float t, c0, c1, c2, c3; int a; - c0= f1; - c1= 3.0f * (f2 - f1); - c2= 3.0f * (f1 - 2.0f*f2 + f3); - c3= f4 - f1 + 3.0f * (f2 - f3); - - for (a=0; a < b; a++) { - t= o[a]; - o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3; + c0 = f1; + c1 = 3.0f * (f2 - f1); + c2 = 3.0f * (f1 - 2.0f * f2 + f3); + c3 = f4 - f1 + 3.0f * (f2 - f3); + + for (a = 0; a < b; a++) { + t = o[a]; + o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3; } } #if 0 -static void berekenx (float *f, float *o, int b) +static void berekenx(float *f, float *o, int b) { float t, c0, c1, c2, c3; int a; - c0= f[0]; - c1= 3.0f * (f[3] - f[0]); - c2= 3.0f * (f[0] - 2.0f*f[3] + f[6]); - c3= f[9] - f[0] + 3.0f * (f[3] - f[6]); - - for (a=0; a < b; a++) { - t= o[a]; - o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3; + c0 = f[0]; + c1 = 3.0f * (f[3] - f[0]); + c2 = 3.0f * (f[0] - 2.0f * f[3] + f[6]); + c3 = f[9] - f[0] + 3.0f * (f[3] - f[6]); + + for (a = 0; a < b; a++) { + t = o[a]; + o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3; } } #endif @@ -1857,7 +1857,7 @@ static void berekenx (float *f, float *o, int b) /* -------------------------- */ /* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */ -static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltime) +static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime) { BezTriple *bezt, *prevbezt, *lastbezt; float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac; @@ -1866,37 +1866,37 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim float cvalue = 0.0f; /* get pointers */ - a= fcu->totvert-1; - prevbezt= bezts; - bezt= prevbezt+1; - lastbezt= prevbezt + a; + a = fcu->totvert - 1; + prevbezt = bezts; + bezt = prevbezt + 1; + lastbezt = prevbezt + a; /* evaluation time at or past endpoints? */ if (prevbezt->vec[1][0] >= evaltime) { /* before or on first keyframe */ if ( (fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (prevbezt->ipo != BEZT_IPO_CONST) && - !(fcu->flag & FCURVE_DISCRETE_VALUES) ) + !(fcu->flag & FCURVE_DISCRETE_VALUES) ) { /* linear or bezier interpolation */ - if (prevbezt->ipo==BEZT_IPO_LIN) { + if (prevbezt->ipo == BEZT_IPO_LIN) { /* Use the next center point instead of our own handle for * linear interpolated extrapolate */ if (fcu->totvert == 1) { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } else { - bezt = prevbezt+1; - dx= prevbezt->vec[1][0] - evaltime; - fac= bezt->vec[1][0] - prevbezt->vec[1][0]; + bezt = prevbezt + 1; + dx = prevbezt->vec[1][0] - evaltime; + fac = bezt->vec[1][0] - prevbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac; - cvalue= prevbezt->vec[1][1] - (fac * dx); + fac = (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac; + cvalue = prevbezt->vec[1][1] - (fac * dx); } else { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } } @@ -1904,16 +1904,16 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* Use the first handle (earlier) of first BezTriple to calculate the * gradient and thus the value of the curve at evaltime */ - dx= prevbezt->vec[1][0] - evaltime; - fac= prevbezt->vec[1][0] - prevbezt->vec[0][0]; + dx = prevbezt->vec[1][0] - evaltime; + fac = prevbezt->vec[1][0] - prevbezt->vec[0][0]; /* prevent division by zero */ if (fac) { - fac= (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac; - cvalue= prevbezt->vec[1][1] - (fac * dx); + fac = (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac; + cvalue = prevbezt->vec[1][1] - (fac * dx); } else { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } } @@ -1921,34 +1921,34 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation, * so just extend first keyframe's value */ - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } else if (lastbezt->vec[1][0] <= evaltime) { /* after or on last keyframe */ if ( (fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (lastbezt->ipo != BEZT_IPO_CONST) && - !(fcu->flag & FCURVE_DISCRETE_VALUES) ) + !(fcu->flag & FCURVE_DISCRETE_VALUES) ) { /* linear or bezier interpolation */ - if (lastbezt->ipo==BEZT_IPO_LIN) { + if (lastbezt->ipo == BEZT_IPO_LIN) { /* Use the next center point instead of our own handle for * linear interpolated extrapolate */ if (fcu->totvert == 1) { - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } else { prevbezt = lastbezt - 1; - dx= evaltime - lastbezt->vec[1][0]; - fac= lastbezt->vec[1][0] - prevbezt->vec[1][0]; + dx = evaltime - lastbezt->vec[1][0]; + fac = lastbezt->vec[1][0] - prevbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac; - cvalue= lastbezt->vec[1][1] + (fac * dx); + fac = (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac; + cvalue = lastbezt->vec[1][1] + (fac * dx); } else { - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } } } @@ -1956,16 +1956,16 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* Use the gradient of the second handle (later) of last BezTriple to calculate the * gradient and thus the value of the curve at evaltime */ - dx= evaltime - lastbezt->vec[1][0]; - fac= lastbezt->vec[2][0] - lastbezt->vec[1][0]; + dx = evaltime - lastbezt->vec[1][0]; + fac = lastbezt->vec[2][0] - lastbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac; - cvalue= lastbezt->vec[1][1] + (fac * dx); + fac = (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac; + cvalue = lastbezt->vec[1][1] + (fac * dx); } else { - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } } } @@ -1973,57 +1973,57 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation, * so just extend last keyframe's value */ - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } } else { /* evaltime occurs somewhere in the middle of the curve */ - for (a=0; prevbezt && bezt && (a < fcu->totvert-1); a++, prevbezt=bezt, bezt++) { + for (a = 0; prevbezt && bezt && (a < fcu->totvert - 1); a++, prevbezt = bezt, bezt++) { /* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */ if (fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) { - cvalue= bezt->vec[1][1]; + cvalue = bezt->vec[1][1]; } /* evaltime occurs within the interval defined by these two keyframes */ else if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) { /* value depends on interpolation mode */ if ((prevbezt->ipo == BEZT_IPO_CONST) || (fcu->flag & FCURVE_DISCRETE_VALUES)) { /* constant (evaltime not relevant, so no interpolation needed) */ - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } else if (prevbezt->ipo == BEZT_IPO_LIN) { /* linear - interpolate between values of the two keyframes */ - fac= bezt->vec[1][0] - prevbezt->vec[1][0]; + fac = bezt->vec[1][0] - prevbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (evaltime - prevbezt->vec[1][0]) / fac; - cvalue= prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1])); + fac = (evaltime - prevbezt->vec[1][0]) / fac; + cvalue = prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1])); } else { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } else { /* bezier interpolation */ - /* v1,v2 are the first keyframe and its 2nd handle */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; - v2[0]= prevbezt->vec[2][0]; - v2[1]= prevbezt->vec[2][1]; - /* v3,v4 are the last keyframe's 1st handle + the last keyframe */ - v3[0]= bezt->vec[0][0]; - v3[1]= bezt->vec[0][1]; - v4[0]= bezt->vec[1][0]; - v4[1]= bezt->vec[1][1]; + /* v1,v2 are the first keyframe and its 2nd handle */ + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; + v2[0] = prevbezt->vec[2][0]; + v2[1] = prevbezt->vec[2][1]; + /* v3,v4 are the last keyframe's 1st handle + the last keyframe */ + v3[0] = bezt->vec[0][0]; + v3[1] = bezt->vec[0][1]; + v4[0] = bezt->vec[1][0]; + v4[1] = bezt->vec[1][1]; /* adjust handles so that they don't overlap (forming a loop) */ correct_bezpart(v1, v2, v3, v4); /* try to get a value for this position - if failure, try another set of points */ - b= findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl); + b = findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl); if (b) { berekeny(v1[1], v2[1], v3[1], v4[1], opl, 1); - cvalue= opl[0]; + cvalue = opl[0]; break; } } @@ -2036,35 +2036,35 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim } /* Calculate F-Curve value for 'evaltime' using FPoint samples */ -static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime) +static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime) { FPoint *prevfpt, *lastfpt, *fpt; - float cvalue= 0.0f; + float cvalue = 0.0f; /* get pointers */ - prevfpt= fpts; - lastfpt= prevfpt + fcu->totvert-1; + prevfpt = fpts; + lastfpt = prevfpt + fcu->totvert - 1; /* evaluation time at or past endpoints? */ if (prevfpt->vec[0] >= evaltime) { /* before or on first sample, so just extend value */ - cvalue= prevfpt->vec[1]; + cvalue = prevfpt->vec[1]; } else if (lastfpt->vec[0] <= evaltime) { /* after or on last sample, so just extend value */ - cvalue= lastfpt->vec[1]; + cvalue = lastfpt->vec[1]; } else { - float t= (float)abs(evaltime - (int)evaltime); + float t = (float)abs(evaltime - (int)evaltime); /* find the one on the right frame (assume that these are spaced on 1-frame intervals) */ - fpt= prevfpt + (int)(evaltime - prevfpt->vec[0]); + fpt = prevfpt + (int)(evaltime - prevfpt->vec[0]); /* if not exactly on the frame, perform linear interpolation with the next one */ if (t != 0.0f) - cvalue= interpf(fpt->vec[1], (fpt+1)->vec[1], t); + cvalue = interpf(fpt->vec[1], (fpt + 1)->vec[1], t); else - cvalue= fpt->vec[1]; + cvalue = fpt->vec[1]; } /* return value */ @@ -2078,7 +2078,7 @@ static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime) */ float evaluate_fcurve(FCurve *fcu, float evaltime) { - float cvalue= 0.0f; + float cvalue = 0.0f; float devaltime; /* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime" @@ -2087,20 +2087,20 @@ float evaluate_fcurve(FCurve *fcu, float evaltime) */ if (fcu->driver) { /* evaltime now serves as input for the curve */ - evaltime= cvalue= evaluate_driver(fcu->driver, evaltime); + evaltime = cvalue = evaluate_driver(fcu->driver, evaltime); } /* evaluate modifiers which modify time to evaluate the base curve at */ - devaltime= evaluate_time_fmodifiers(&fcu->modifiers, fcu, cvalue, evaltime); + devaltime = evaluate_time_fmodifiers(&fcu->modifiers, fcu, cvalue, evaltime); /* evaluate curve-data * - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying * F-Curve modifier on the stack requested the curve to be evaluated at */ if (fcu->bezt) - cvalue= fcurve_eval_keyframes(fcu, fcu->bezt, devaltime); + cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime); else if (fcu->fpt) - cvalue= fcurve_eval_samples(fcu, fcu->fpt, devaltime); + cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime); /* evaluate modifiers */ evaluate_value_fmodifiers(&fcu->modifiers, fcu, &cvalue, evaltime); @@ -2109,7 +2109,7 @@ float evaluate_fcurve(FCurve *fcu, float evaltime) * here so that the curve can be sampled correctly */ if (fcu->flag & FCURVE_INT_VALUES) - cvalue= floorf(cvalue + 0.5f); + cvalue = floorf(cvalue + 0.5f); /* return evaluated value */ return cvalue; @@ -2125,7 +2125,7 @@ void calculate_fcurve(FCurve *fcu, float ctime) list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE)) { /* calculate and set curval (evaluates driver too if necessary) */ - fcu->curval= evaluate_fcurve(fcu, ctime); + fcu->curval = evaluate_fcurve(fcu, ctime); } } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 92c73b23239..59c8a529d85 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -68,14 +68,14 @@ */ /* Template for type-info data: - * - make a copy of this when creating new modifiers, and just change the functions - * pointed to as necessary - * - although the naming of functions doesn't matter, it would help for code - * readability, to follow the same naming convention as is presented here - * - any functions that a constraint doesn't need to define, don't define - * for such cases, just use NULL - * - these should be defined after all the functions have been defined, so that - * forward-definitions/prototypes don't need to be used! + * - make a copy of this when creating new modifiers, and just change the functions + * pointed to as necessary + * - although the naming of functions doesn't matter, it would help for code + * readability, to follow the same naming convention as is presented here + * - any functions that a constraint doesn't need to define, don't define + * for such cases, just use NULL + * - these should be defined after all the functions have been defined, so that + * forward-definitions/prototypes don't need to be used! * - keep this copy #if-def'd so that future constraints can get based off this */ #if 0 @@ -99,74 +99,74 @@ static FModifierTypeInfo FMI_MODNAME = { /* Generator F-Curve Modifier --------------------------- */ /* Generators available: - * 1) simple polynomial generator: + * 1) simple polynomial generator: * - Exanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n]) * - Factorized form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1])) */ -static void fcm_generator_free (FModifier *fcm) +static void fcm_generator_free(FModifier *fcm) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; /* free polynomial coefficients array */ if (data->coefficients) MEM_freeN(data->coefficients); } -static void fcm_generator_copy (FModifier *fcm, FModifier *src) +static void fcm_generator_copy(FModifier *fcm, FModifier *src) { - FMod_Generator *gen= (FMod_Generator *)fcm->data; - FMod_Generator *ogen= (FMod_Generator *)src->data; + FMod_Generator *gen = (FMod_Generator *)fcm->data; + FMod_Generator *ogen = (FMod_Generator *)src->data; /* copy coefficients array? */ if (ogen->coefficients) - gen->coefficients= MEM_dupallocN(ogen->coefficients); + gen->coefficients = MEM_dupallocN(ogen->coefficients); } -static void fcm_generator_new_data (void *mdata) +static void fcm_generator_new_data(void *mdata) { - FMod_Generator *data= (FMod_Generator *)mdata; + FMod_Generator *data = (FMod_Generator *)mdata; float *cp; /* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */ - data->poly_order= 1; - data->arraysize= 2; - cp= data->coefficients= MEM_callocN(sizeof(float)*2, "FMod_Generator_Coefs"); + data->poly_order = 1; + data->arraysize = 2; + cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs"); cp[0] = 0; // y-offset cp[1] = 1; // gradient } -static void fcm_generator_verify (FModifier *fcm) +static void fcm_generator_verify(FModifier *fcm) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; /* requirements depend on mode */ switch (data->mode) { case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */ { /* arraysize needs to be order+1, so resize if not */ - if (data->arraysize != (data->poly_order+1)) { + if (data->arraysize != (data->poly_order + 1)) { float *nc; /* make new coefficients array, and copy over as much data as can fit */ - nc= MEM_callocN(sizeof(float)*(data->poly_order+1), "FMod_Generator_Coefs"); + nc = MEM_callocN(sizeof(float) * (data->poly_order + 1), "FMod_Generator_Coefs"); if (data->coefficients) { - if ((int)data->arraysize > (data->poly_order+1)) - memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order+1)); + if ((int)data->arraysize > (data->poly_order + 1)) + memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order + 1)); else - memcpy(nc, data->coefficients, sizeof(float)*data->arraysize); + memcpy(nc, data->coefficients, sizeof(float) * data->arraysize); /* free the old data */ MEM_freeN(data->coefficients); } /* set the new data */ - data->coefficients= nc; - data->arraysize= data->poly_order+1; + data->coefficients = nc; + data->arraysize = data->poly_order + 1; } } - break; + break; case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* expanded polynomial expression */ { @@ -175,30 +175,30 @@ static void fcm_generator_verify (FModifier *fcm) float *nc; /* make new coefficients array, and copy over as much data as can fit */ - nc= MEM_callocN(sizeof(float)*(data->poly_order*2), "FMod_Generator_Coefs"); + nc = MEM_callocN(sizeof(float) * (data->poly_order * 2), "FMod_Generator_Coefs"); if (data->coefficients) { if (data->arraysize > (unsigned int)(data->poly_order * 2)) - memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order * 2)); + memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order * 2)); else - memcpy(nc, data->coefficients, sizeof(float)*data->arraysize); + memcpy(nc, data->coefficients, sizeof(float) * data->arraysize); /* free the old data */ MEM_freeN(data->coefficients); } /* set the new data */ - data->coefficients= nc; - data->arraysize= data->poly_order * 2; + data->coefficients = nc; + data->arraysize = data->poly_order * 2; } } - break; + break; } } -static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; /* behavior depends on mode * NOTE: the data in its default state is fine too @@ -207,23 +207,23 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float * case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */ { /* we overwrite cvalue with the sum of the polynomial */ - float *powers = MEM_callocN(sizeof(float)*data->arraysize, "Poly Powers"); - float value= 0.0f; + float *powers = MEM_callocN(sizeof(float) * data->arraysize, "Poly Powers"); + float value = 0.0f; unsigned int i; /* for each x^n, precalculate value based on previous one first... this should be * faster that calling pow() for each entry */ - for (i=0; i < data->arraysize; i++) { + for (i = 0; i < data->arraysize; i++) { /* first entry is x^0 = 1, otherwise, calculate based on previous */ if (i) - powers[i]= powers[i-1] * evaltime; + powers[i] = powers[i - 1] * evaltime; else - powers[0]= 1; + powers[0] = 1; } /* for each coefficient, add to value, which we'll write to *cvalue in one go */ - for (i=0; i < data->arraysize; i++) + for (i = 0; i < data->arraysize; i++) value += data->coefficients[i] * powers[i]; /* only if something changed, write *cvalue in one go */ @@ -231,33 +231,33 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float * if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else - *cvalue= value; + *cvalue = value; } /* cleanup */ if (powers) MEM_freeN(powers); } - break; + break; case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial */ { - float value= 1.0f, *cp=NULL; + float value = 1.0f, *cp = NULL; unsigned int i; /* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */ - for (cp=data->coefficients, i=0; (cp) && (i < (unsigned int)data->poly_order); cp+=2, i++) - value *= (cp[0]*evaltime + cp[1]); + for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order); cp += 2, i++) + value *= (cp[0] * evaltime + cp[1]); /* only if something changed, write *cvalue in one go */ if (data->poly_order) { if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else - *cvalue= value; + *cvalue = value; } } - break; + break; } } @@ -279,7 +279,7 @@ static FModifierTypeInfo FMI_GENERATOR = { /* Built-In Function Generator F-Curve Modifier --------------------------- */ /* This uses the general equation for equations: - * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset + * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset * * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients, * x is the evaluation 'time', and 'y' is the resultant value @@ -288,20 +288,20 @@ static FModifierTypeInfo FMI_GENERATOR = { * sin, cos, tan, sinc (normalised sin), natural log, square root */ -static void fcm_fn_generator_new_data (void *mdata) +static void fcm_fn_generator_new_data(void *mdata) { - FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)mdata; + FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)mdata; /* set amplitude and phase multiplier to 1.0f so that something is generated */ - data->amplitude= 1.0f; - data->phase_multiplier= 1.0f; + data->amplitude = 1.0f; + data->phase_multiplier = 1.0f; } /* Unary 'normalised sine' function - * y = sin(PI + x) / (PI * x), + * y = sin(PI + x) / (PI * x), * except for x = 0 when y = 1. */ -static double sinc (double x) +static double sinc(double x) { if (fabs(x) < 0.0001) return 1.0; @@ -309,10 +309,10 @@ static double sinc (double x) return sin(M_PI * x) / (M_PI * x); } -static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data; - double arg= data->phase_multiplier*evaltime + data->phase_offset; + FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; + double arg = data->phase_multiplier * evaltime + data->phase_offset; double (*fn)(double v) = NULL; /* get function pointer to the func to use: @@ -321,13 +321,13 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa switch (data->type) { /* simple ones */ case FCM_GENERATOR_FN_SIN: /* sine wave */ - fn= sin; + fn = sin; break; case FCM_GENERATOR_FN_COS: /* cosine wave */ - fn= cos; + fn = cos; break; case FCM_GENERATOR_FN_SINC: /* normalised sine wave */ - fn= sinc; + fn = sinc; break; /* validation required */ @@ -336,36 +336,36 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* check that argument is not on one of the discontinuities (i.e. 90deg, 270 deg, etc) */ if (IS_EQ(fmod((arg - M_PI_2), M_PI), 0.0)) { if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) - *cvalue = 0.0f; /* no value possible here */ + *cvalue = 0.0f; /* no value possible here */ } else - fn= tan; + fn = tan; } - break; + break; case FCM_GENERATOR_FN_LN: /* natural log */ { /* check that value is greater than 1? */ if (arg > 1.0) { - fn= log; + fn = log; } else { if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) - *cvalue = 0.0f; /* no value possible here */ + *cvalue = 0.0f; /* no value possible here */ } } - break; + break; case FCM_GENERATOR_FN_SQRT: /* square root */ { /* no negative numbers */ if (arg > 0.0) { - fn= sqrt; + fn = sqrt; } else { if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) - *cvalue = 0.0f; /* no value possible here */ + *cvalue = 0.0f; /* no value possible here */ } } - break; + break; default: printf("Invalid Function-Generator for F-Modifier - %d\n", data->type); @@ -373,12 +373,12 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* execute function callback to set value if appropriate */ if (fn) { - float value= (float)(data->amplitude*(float)fn(arg) + data->value_offset); + float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset); if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else - *cvalue= value; + *cvalue = value; } } @@ -399,37 +399,37 @@ static FModifierTypeInfo FMI_FN_GENERATOR = { /* Envelope F-Curve Modifier --------------------------- */ -static void fcm_envelope_free (FModifier *fcm) +static void fcm_envelope_free(FModifier *fcm) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; /* free envelope data array */ if (env->data) MEM_freeN(env->data); } -static void fcm_envelope_copy (FModifier *fcm, FModifier *src) +static void fcm_envelope_copy(FModifier *fcm, FModifier *src) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; - FMod_Envelope *oenv= (FMod_Envelope *)src->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; + FMod_Envelope *oenv = (FMod_Envelope *)src->data; /* copy envelope data array */ if (oenv->data) - env->data= MEM_dupallocN(oenv->data); + env->data = MEM_dupallocN(oenv->data); } -static void fcm_envelope_new_data (void *mdata) +static void fcm_envelope_new_data(void *mdata) { - FMod_Envelope *env= (FMod_Envelope *)mdata; + FMod_Envelope *env = (FMod_Envelope *)mdata; /* set default min/max ranges */ - env->min= -1.0f; - env->max= 1.0f; + env->min = -1.0f; + env->max = 1.0f; } -static void fcm_envelope_verify (FModifier *fcm) +static void fcm_envelope_verify(FModifier *fcm) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; /* if the are points, perform bubble-sort on them, as user may have changed the order */ if (env->data) { @@ -437,44 +437,44 @@ static void fcm_envelope_verify (FModifier *fcm) } } -static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed, *prevfed, *lastfed; - float min=0.0f, max=0.0f, fac=0.0f; + float min = 0.0f, max = 0.0f, fac = 0.0f; int a; /* get pointers */ if (env->data == NULL) return; - prevfed= env->data; - fed= prevfed + 1; - lastfed= prevfed + (env->totvert-1); + prevfed = env->data; + fed = prevfed + 1; + lastfed = prevfed + (env->totvert - 1); /* get min/max values for envelope at evaluation time (relative to mid-value) */ if (prevfed->time >= evaltime) { /* before or on first sample, so just extend value */ - min= prevfed->min; - max= prevfed->max; + min = prevfed->min; + max = prevfed->max; } else if (lastfed->time <= evaltime) { /* after or on last sample, so just extend value */ - min= lastfed->min; - max= lastfed->max; + min = lastfed->min; + max = lastfed->max; } else { /* evaltime occurs somewhere between segments */ // TODO: implement binary search for this to make it faster? - for (a=0; prevfed && fed && (a < env->totvert-1); a++, prevfed=fed, fed++) { + for (a = 0; prevfed && fed && (a < env->totvert - 1); a++, prevfed = fed, fed++) { /* evaltime occurs within the interval defined by these two envelope points */ if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) { float afac, bfac, diff; - diff= fed->time - prevfed->time; - afac= (evaltime - prevfed->time) / diff; - bfac= (fed->time - evaltime) / diff; + diff = fed->time - prevfed->time; + afac = (evaltime - prevfed->time) / diff; + bfac = (fed->time - evaltime) / diff; - min= bfac*prevfed->min + afac*fed->min; - max= bfac*prevfed->max + afac*fed->max; + min = bfac * prevfed->min + afac * fed->min; + max = bfac * prevfed->max + afac * fed->max; break; } @@ -485,8 +485,8 @@ static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *c * - fac is the ratio of how the current y-value corresponds to the reference range * - thus, the new value is found by mapping the old range to the new! */ - fac= (*cvalue - (env->midval + env->min)) / (env->max - env->min); - *cvalue= min + fac*(max - min); + fac = (*cvalue - (env->midval + env->min)) / (env->max - env->min); + *cvalue = min + fac * (max - min); } static FModifierTypeInfo FMI_ENVELOPE = { @@ -520,23 +520,23 @@ static FModifierTypeInfo FMI_ENVELOPE = { /* temp data used during evaluation */ typedef struct tFCMED_Cycles { - float cycyofs; /* y-offset to apply */ + float cycyofs; /* y-offset to apply */ } tFCMED_Cycles; -static void fcm_cycles_new_data (void *mdata) +static void fcm_cycles_new_data(void *mdata) { - FMod_Cycles *data= (FMod_Cycles *)mdata; + FMod_Cycles *data = (FMod_Cycles *)mdata; /* turn on cycles by default */ - data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC; + data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC; } -static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime) +static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime) { - FMod_Cycles *data= (FMod_Cycles *)fcm->data; - float prevkey[2], lastkey[2], cycyofs=0.0f; - short side=0, mode=0; - int cycles=0, ofs=0; + FMod_Cycles *data = (FMod_Cycles *)fcm->data; + float prevkey[2], lastkey[2], cycyofs = 0.0f; + short side = 0, mode = 0; + int cycles = 0, ofs = 0; /* check if modifier is first in stack, otherwise disable ourself... */ // FIXME... @@ -547,24 +547,24 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), /* calculate new evaltime due to cyclic interpolation */ if (fcu && fcu->bezt) { - BezTriple *prevbezt= fcu->bezt; - BezTriple *lastbezt= prevbezt + fcu->totvert-1; + BezTriple *prevbezt = fcu->bezt; + BezTriple *lastbezt = prevbezt + fcu->totvert - 1; - prevkey[0]= prevbezt->vec[1][0]; - prevkey[1]= prevbezt->vec[1][1]; + prevkey[0] = prevbezt->vec[1][0]; + prevkey[1] = prevbezt->vec[1][1]; - lastkey[0]= lastbezt->vec[1][0]; - lastkey[1]= lastbezt->vec[1][1]; + lastkey[0] = lastbezt->vec[1][0]; + lastkey[1] = lastbezt->vec[1][1]; } else if (fcu && fcu->fpt) { - FPoint *prevfpt= fcu->fpt; - FPoint *lastfpt= prevfpt + fcu->totvert-1; + FPoint *prevfpt = fcu->fpt; + FPoint *lastfpt = prevfpt + fcu->totvert - 1; - prevkey[0]= prevfpt->vec[0]; - prevkey[1]= prevfpt->vec[1]; + prevkey[0] = prevfpt->vec[0]; + prevkey[1] = prevfpt->vec[1]; - lastkey[0]= lastfpt->vec[0]; - lastkey[1]= lastfpt->vec[1]; + lastkey[0] = lastfpt->vec[0]; + lastkey[1] = lastfpt->vec[1]; } else return evaltime; @@ -575,18 +575,18 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), */ if (evaltime < prevkey[0]) { if (data->before_mode) { - side= -1; - mode= data->before_mode; - cycles= data->before_cycles; - ofs= prevkey[0]; + side = -1; + mode = data->before_mode; + cycles = data->before_cycles; + ofs = prevkey[0]; } } else if (evaltime > lastkey[0]) { if (data->after_mode) { - side= 1; - mode= data->after_mode; - cycles= data->after_cycles; - ofs= lastkey[0]; + side = 1; + mode = data->after_mode; + cycles = data->after_cycles; + ofs = lastkey[0]; } } if ((ELEM(0, side, mode))) @@ -594,22 +594,22 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), /* find relative place within a cycle */ { - float cycdx=0, cycdy=0; - float cycle= 0, cyct=0; + float cycdx = 0, cycdy = 0; + float cycle = 0, cyct = 0; /* calculate period and amplitude (total height) of a cycle */ - cycdx= lastkey[0] - prevkey[0]; - cycdy= lastkey[1] - prevkey[1]; + cycdx = lastkey[0] - prevkey[0]; + cycdy = lastkey[1] - prevkey[1]; /* check if cycle is infinitely small, to be point of being impossible to use */ if (cycdx == 0) return evaltime; /* calculate the 'number' of the cycle */ - cycle= ((float)side * (evaltime - ofs) / cycdx); + cycle = ((float)side * (evaltime - ofs) / cycdx); /* calculate the time inside the cycle */ - cyct= fmod(evaltime - ofs, cycdx); + cyct = fmod(evaltime - ofs, cycdx); /* check that cyclic is still enabled for the specified time */ if (cycles == 0) { @@ -641,19 +641,19 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), evaltime = (side == 1 ? prevkey[0] : lastkey[0]); } /* calculate where in the cycle we are (overwrite evaltime to reflect this) */ - else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle+1) % 2)) { + else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) { /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse * - for 'before' extrapolation, we need to flip in a different way, otherwise values past * then end of the curve get referenced (result of fmod will be negative, and with different phase) */ if (side < 0) - evaltime= prevkey[0] - cyct; + evaltime = prevkey[0] - cyct; else - evaltime= lastkey[0] - cyct; + evaltime = lastkey[0] - cyct; } else { /* the cycle is played normally... */ - evaltime= prevkey[0] + cyct; + evaltime = prevkey[0] + cyct; } if (evaltime < prevkey[0]) evaltime += cycdx; } @@ -663,17 +663,17 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), tFCMED_Cycles *edata; /* for now, this is just a float, but we could get more stuff... */ - fcm->edata= edata= MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles"); - edata->cycyofs= cycyofs; + fcm->edata = edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles"); + edata->cycyofs = cycyofs; } /* return the new frame to evaluate */ return evaltime; } -static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) +static void fcm_cycles_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { - tFCMED_Cycles *edata= (tFCMED_Cycles *)fcm->edata; + tFCMED_Cycles *edata = (tFCMED_Cycles *)fcm->edata; /* use temp data */ if (edata) { @@ -682,7 +682,7 @@ static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cva /* free temp data */ MEM_freeN(edata); - fcm->edata= NULL; + fcm->edata = NULL; } } @@ -703,21 +703,21 @@ static FModifierTypeInfo FMI_CYCLES = { /* Noise F-Curve Modifier --------------------------- */ -static void fcm_noise_new_data (void *mdata) +static void fcm_noise_new_data(void *mdata) { - FMod_Noise *data= (FMod_Noise *)mdata; + FMod_Noise *data = (FMod_Noise *)mdata; /* defaults */ - data->size= 1.0f; - data->strength= 1.0f; - data->phase= 1.0f; + data->size = 1.0f; + data->strength = 1.0f; + data->phase = 1.0f; data->depth = 0; data->modification = FCM_NOISE_MODIF_REPLACE; } -static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_Noise *data= (FMod_Noise *)fcm->data; + FMod_Noise *data = (FMod_Noise *)fcm->data; float noise; /* generate noise using good ol' Blender Noise @@ -729,17 +729,17 @@ static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cval /* combine the noise with existing motion data */ switch (data->modification) { case FCM_NOISE_MODIF_ADD: - *cvalue= *cvalue + noise * data->strength; + *cvalue = *cvalue + noise * data->strength; break; case FCM_NOISE_MODIF_SUBTRACT: - *cvalue= *cvalue - noise * data->strength; + *cvalue = *cvalue - noise * data->strength; break; case FCM_NOISE_MODIF_MULTIPLY: - *cvalue= *cvalue * noise * data->strength; + *cvalue = *cvalue * noise * data->strength; break; case FCM_NOISE_MODIF_REPLACE: default: - *cvalue= *cvalue + (noise - 0.5f) * data->strength; + *cvalue = *cvalue + (noise - 0.5f) * data->strength; break; } } @@ -781,25 +781,25 @@ static FModifierTypeInfo FMI_FILTER = { /* Python F-Curve Modifier --------------------------- */ -static void fcm_python_free (FModifier *fcm) +static void fcm_python_free(FModifier *fcm) { - FMod_Python *data= (FMod_Python *)fcm->data; + FMod_Python *data = (FMod_Python *)fcm->data; /* id-properties */ IDP_FreeProperty(data->prop); MEM_freeN(data->prop); } -static void fcm_python_new_data (void *mdata) +static void fcm_python_new_data(void *mdata) { - FMod_Python *data= (FMod_Python *)mdata; + FMod_Python *data = (FMod_Python *)mdata; /* everything should be set correctly by calloc, except for the prop->type constant.*/ data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps"); data->prop->type = IDP_GROUP; } -static void fcm_python_copy (FModifier *fcm, FModifier *src) +static void fcm_python_copy(FModifier *fcm, FModifier *src) { FMod_Python *pymod = (FMod_Python *)fcm->data; FMod_Python *opymod = (FMod_Python *)src->data; @@ -807,7 +807,7 @@ static void fcm_python_copy (FModifier *fcm, FModifier *src) pymod->prop = IDP_CopyProperty(opymod->prop); } -static void fcm_python_evaluate (FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime)) +static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime)) { #ifdef WITH_PYTHON //FMod_Python *data= (FMod_Python *)fcm->data; @@ -836,9 +836,9 @@ static FModifierTypeInfo FMI_PYTHON = { /* Limits F-Curve Modifier --------------------------- */ -static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) +static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { - FMod_Limits *data= (FMod_Limits *)fcm->data; + FMod_Limits *data = (FMod_Limits *)fcm->data; /* check for the time limits */ if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin)) @@ -850,15 +850,15 @@ static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED( return evaltime; } -static void fcm_limits_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) +static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { - FMod_Limits *data= (FMod_Limits *)fcm->data; + FMod_Limits *data = (FMod_Limits *)fcm->data; /* value limits now */ if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin)) - *cvalue= data->rect.ymin; + *cvalue = data->rect.ymin; if ((data->flag & FCM_LIMIT_YMAX) && (*cvalue > data->rect.ymax)) - *cvalue= data->rect.ymax; + *cvalue = data->rect.ymax; } static FModifierTypeInfo FMI_LIMITS = { @@ -878,18 +878,18 @@ static FModifierTypeInfo FMI_LIMITS = { /* Stepped F-Curve Modifier --------------------------- */ -static void fcm_stepped_new_data (void *mdata) +static void fcm_stepped_new_data(void *mdata) { - FMod_Stepped *data= (FMod_Stepped *)mdata; + FMod_Stepped *data = (FMod_Stepped *)mdata; /* just need to set the step-size to 2-frames by default */ // XXX: or would 5 be more normal? data->step_size = 2.0f; } -static float fcm_stepped_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) +static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { - FMod_Stepped *data= (FMod_Stepped *)fcm->data; + FMod_Stepped *data = (FMod_Stepped *)fcm->data; int snapblock; /* check range clamping to see if we should alter the timing to achieve the desired results */ @@ -936,27 +936,27 @@ static FModifierTypeInfo FMI_STEPPED = { /* These globals only ever get directly accessed in this file */ static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES]; -static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */ +static short FMI_INIT = 1; /* when non-zero, the list needs to be updated */ /* This function only gets called when FMI_INIT is non-zero */ -static void fmods_init_typeinfo (void) +static void fmods_init_typeinfo(void) { - fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */ - fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */ - fmodifiersTypeInfo[2]= &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */ - fmodifiersTypeInfo[3]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */ - fmodifiersTypeInfo[4]= &FMI_CYCLES; /* Cycles F-Curve Modifier */ - fmodifiersTypeInfo[5]= &FMI_NOISE; /* Apply-Noise F-Curve Modifier */ - fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented - fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */ - fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */ - fmodifiersTypeInfo[9]= &FMI_STEPPED; /* Stepped F-Curve Modifier */ + fmodifiersTypeInfo[0] = NULL; /* 'Null' F-Curve Modifier */ + fmodifiersTypeInfo[1] = &FMI_GENERATOR; /* Generator F-Curve Modifier */ + fmodifiersTypeInfo[2] = &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */ + fmodifiersTypeInfo[3] = &FMI_ENVELOPE; /* Envelope F-Curve Modifier */ + fmodifiersTypeInfo[4] = &FMI_CYCLES; /* Cycles F-Curve Modifier */ + fmodifiersTypeInfo[5] = &FMI_NOISE; /* Apply-Noise F-Curve Modifier */ + fmodifiersTypeInfo[6] = NULL /*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented + fmodifiersTypeInfo[7] = &FMI_PYTHON; /* Custom Python F-Curve Modifier */ + fmodifiersTypeInfo[8] = &FMI_LIMITS; /* Limits F-Curve Modifier */ + fmodifiersTypeInfo[9] = &FMI_STEPPED; /* Stepped F-Curve Modifier */ } /* This function should be used for getting the appropriate type-info when only * a F-Curve modifier type is known */ -FModifierTypeInfo *get_fmodifier_typeinfo (int type) +FModifierTypeInfo *get_fmodifier_typeinfo(int type) { /* initialize the type-info list? */ if (FMI_INIT) { @@ -966,7 +966,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type) /* only return for valid types */ if ( (type >= FMODIFIER_TYPE_NULL) && - (type <= FMODIFIER_NUM_TYPES ) ) + (type <= FMODIFIER_NUM_TYPES) ) { /* there shouldn't be any segfaults here... */ return fmodifiersTypeInfo[type]; @@ -981,7 +981,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type) /* This function should always be used to get the appropriate type-info, as it * has checks which prevent segfaults in some weird cases. */ -FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm) +FModifierTypeInfo *fmodifier_get_typeinfo(FModifier *fcm) { /* only return typeinfo for valid modifiers */ if (fcm) @@ -993,9 +993,9 @@ FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm) /* API --------------------------- */ /* Add a new F-Curve Modifier to the given F-Curve of a certain type */ -FModifier *add_fmodifier (ListBase *modifiers, int type) +FModifier *add_fmodifier(ListBase *modifiers, int type) { - FModifierTypeInfo *fmi= get_fmodifier_typeinfo(type); + FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type); FModifier *fcm; /* sanity checks */ @@ -1011,7 +1011,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) } /* add modifier itself */ - fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier"); + fcm = MEM_callocN(sizeof(FModifier), "F-Curve Modifier"); fcm->type = type; fcm->flag = FMODIFIER_FLAG_EXPANDED; fcm->influence = 1.0f; @@ -1022,7 +1022,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) fcm->flag |= FMODIFIER_FLAG_ACTIVE; /* add modifier's data */ - fcm->data= MEM_callocN(fmi->size, fmi->structName); + fcm->data = MEM_callocN(fmi->size, fmi->structName); /* init custom settings if necessary */ if (fmi->new_data) @@ -1033,9 +1033,9 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) } /* Make a copy of the specified F-Modifier */ -FModifier *copy_fmodifier (FModifier *src) +FModifier *copy_fmodifier(FModifier *src) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(src); + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src); FModifier *dst; /* sanity check */ @@ -1065,11 +1065,11 @@ void copy_fmodifiers(ListBase *dst, ListBase *src) if (ELEM(NULL, dst, src)) return; - dst->first= dst->last= NULL; + dst->first = dst->last = NULL; BLI_duplicatelist(dst, src); - for (fcm=dst->first, srcfcm=src->first; fcm && srcfcm; srcfcm=srcfcm->next, fcm=fcm->next) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); /* make a new copy of the F-Modifier's data */ fcm->data = MEM_dupallocN(fcm->data); @@ -1083,7 +1083,7 @@ void copy_fmodifiers(ListBase *dst, ListBase *src) /* Remove and free the given F-Modifier from the given stack */ int remove_fmodifier(ListBase *modifiers, FModifier *fcm) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); /* sanity check */ if (fcm == NULL) @@ -1121,14 +1121,14 @@ void free_fmodifiers(ListBase *modifiers) return; /* free each modifier in order - modifier is unlinked from list and freed */ - for (fcm= modifiers->first; fcm; fcm= fmn) { - fmn= fcm->next; + for (fcm = modifiers->first; fcm; fcm = fmn) { + fmn = fcm->next; remove_fmodifier(modifiers, fcm); } } /* Find the active F-Modifier */ -FModifier *find_active_fmodifier (ListBase *modifiers) +FModifier *find_active_fmodifier(ListBase *modifiers) { FModifier *fcm; @@ -1137,7 +1137,7 @@ FModifier *find_active_fmodifier (ListBase *modifiers) return NULL; /* loop over modifiers until 'active' one is found */ - for (fcm= modifiers->first; fcm; fcm= fcm->next) { + for (fcm = modifiers->first; fcm; fcm = fcm->next) { if (fcm->flag & FMODIFIER_FLAG_ACTIVE) return fcm; } @@ -1156,7 +1156,7 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm) return; /* deactivate all, and set current one active */ - for (fm= modifiers->first; fm; fm= fm->next) + for (fm = modifiers->first; fm; fm = fm->next) fm->flag &= ~FMODIFIER_FLAG_ACTIVE; /* make given modifier active */ @@ -1181,15 +1181,15 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype) return 0; /* find the first mdifier fitting these criteria */ - for (fcm= modifiers->first; fcm; fcm= fcm->next) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); - short mOk=1, aOk=1; /* by default 1, so that when only one test, won't fail */ + for (fcm = modifiers->first; fcm; fcm = fcm->next) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); + short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */ /* check if applicable ones are fullfilled */ if (mtype) - mOk= (fcm->type == mtype); + mOk = (fcm->type == mtype); if (acttype > -1) - aOk= (fmi->acttype == acttype); + aOk = (fmi->acttype == acttype); /* if both are ok, we've found a hit */ if (mOk && aOk) @@ -1203,7 +1203,7 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype) /* Evaluation API --------------------------- */ /* helper function - calculate influence of FModifier */ -static float eval_fmodifier_influence (FModifier *fcm, float evaltime) +static float eval_fmodifier_influence(FModifier *fcm, float evaltime) { float influence; @@ -1270,8 +1270,8 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f * effect, which should get us the desired effects when using layered time manipulations * (such as multiple 'stepped' modifiers in sequence, causing different stepping rates) */ - for (fcm= modifiers->last; fcm; fcm= fcm->prev) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + for (fcm = modifiers->last; fcm; fcm = fcm->prev) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); if (fmi == NULL) continue; @@ -1279,12 +1279,12 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f /* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results) * hence we shouldn't bother seeing what it would do given the chance */ - if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 || - ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) + if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) { /* only evaluate if there's a callback for this */ if (fmi->evaluate_modifier_time) { - if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) { + if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) { float influence = eval_fmodifier_influence(fcm, evaltime); float nval = fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime); @@ -1310,18 +1310,18 @@ void evaluate_value_fmodifiers(ListBase *modifiers, FCurve *fcu, float *cvalue, return; /* evaluate modifiers */ - for (fcm= modifiers->first; fcm; fcm= fcm->next) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + for (fcm = modifiers->first; fcm; fcm = fcm->next) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); if (fmi == NULL) continue; /* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */ - if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 || - ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) + if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) { if (fmi->evaluate_modifier) { - if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) { + if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) { float influence = eval_fmodifier_influence(fcm, evaltime); float nval = *cvalue; @@ -1350,8 +1350,8 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end) } /* temporarily, disable driver while we sample, so that they don't influence the outcome */ - driver= fcu->driver; - fcu->driver= NULL; + driver = fcu->driver; + fcu->driver = NULL; /* bake the modifiers, by sampling the curve at each frame */ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve); @@ -1360,5 +1360,5 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end) free_fmodifiers(&fcu->modifiers); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index dfe73ae20db..e3735cfd374 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -47,16 +47,16 @@ static char idp_size_table[] = { 1, /*strings*/ sizeof(int), sizeof(float), - sizeof(float)*3, /*Vector type, deprecated*/ - sizeof(float)*16, /*Matrix type, deprecated*/ + sizeof(float) * 3, /*Vector type, deprecated*/ + sizeof(float) * 16, /*Matrix type, deprecated*/ 0, /*arrays don't have a fixed size*/ sizeof(ListBase), /*Group type*/ - sizeof(void*), + sizeof(void *), sizeof(double) }; /* ------------Property Array Type ----------- */ -#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i)) +#define GETPROP(prop, i) (((IDProperty *)(prop)->data.pointer) + (i)) /* --------- property array type -------------*/ @@ -78,10 +78,10 @@ IDProperty *IDP_CopyIDPArray(IDProperty *array) IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp; int i; - *narray= *array; + *narray = *array; narray->data.pointer = MEM_dupallocN(array->data.pointer); - for (i=0; ilen; i++) { + for (i = 0; i < narray->len; i++) { /* ok, the copy functions always allocate a new structure, * which doesn't work here. instead, simply copy the * contents of the new structure into the array cell, @@ -100,7 +100,7 @@ void IDP_FreeIDPArray(IDProperty *prop) { int i; - for (i=0; ilen; i++) + for (i = 0; i < prop->len; i++) IDP_FreeProperty(GETPROP(prop, i)); if (prop->data.pointer) @@ -124,22 +124,22 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index) IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item) { - IDP_ResizeIDPArray(prop, prop->len+1); - IDP_SetIndexArray(prop, prop->len-1, item); + IDP_ResizeIDPArray(prop, prop->len + 1); + IDP_SetIndexArray(prop, prop->len - 1, item); return item; } void IDP_ResizeIDPArray(IDProperty *prop, int newlen) { void *newarr; - int newsize=newlen; + int newsize = newlen; /*first check if the array buffer size has room*/ /*if newlen is 200 chars less then totallen, reallocate anyway*/ if (newlen <= prop->totallen && prop->totallen - newlen < 200) { int i; - for (i=newlen; ilen; i++) + for (i = newlen; i < prop->len; i++) IDP_FreeProperty(GETPROP(prop, i)); prop->len = newlen; @@ -156,18 +156,18 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen) */ newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize; - newarr = MEM_callocN(sizeof(IDProperty)*newsize, "idproperty array resized"); + newarr = MEM_callocN(sizeof(IDProperty) * newsize, "idproperty array resized"); if (newlen >= prop->len) { /* newlen is bigger*/ - memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty)); + memcpy(newarr, prop->data.pointer, prop->len * sizeof(IDProperty)); } else { int i; /* newlen is smaller*/ - for (i=newlen; ilen; i++) { + for (i = newlen; i < prop->len; i++) { IDP_FreeProperty(GETPROP(prop, i)); } - memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty)); + memcpy(newarr, prop->data.pointer, newlen * sizeof(IDProperty)); } if (prop->data.pointer) @@ -185,21 +185,21 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr) if (newlen >= prop->len) { /* bigger */ - IDProperty **array= newarr; + IDProperty **array = newarr; IDPropertyTemplate val; int a; - for (a=prop->len; alen; a < newlen; a++) { val.i = 0; /* silence MSVC warning about uninitialized var when debugging */ - array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group"); + array[a] = IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group"); } } else { /* smaller */ - IDProperty **array= prop->data.pointer; + IDProperty **array = prop->data.pointer; int a; - for (a=newlen; alen; a++) { + for (a = newlen; a < prop->len; a++) { IDP_FreeProperty(array[a]); MEM_freeN(array[a]); } @@ -210,7 +210,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr) void IDP_ResizeArray(IDProperty *prop, int newlen) { void *newarr; - int newsize=newlen; + int newsize = newlen; /*first check if the array buffer size has room*/ /*if newlen is 200 chars less then totallen, reallocate anyway*/ @@ -230,16 +230,16 @@ void IDP_ResizeArray(IDProperty *prop, int newlen) */ newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize; - newarr = MEM_callocN(idp_size_table[(int)prop->subtype]*newsize, "idproperty array resized"); + newarr = MEM_callocN(idp_size_table[(int)prop->subtype] * newsize, "idproperty array resized"); if (newlen >= prop->len) { /* newlen is bigger*/ - memcpy(newarr, prop->data.pointer, prop->len*idp_size_table[(int)prop->subtype]); + memcpy(newarr, prop->data.pointer, prop->len * idp_size_table[(int)prop->subtype]); idp_resize_group_array(prop, newlen, newarr); } else { /* newlen is smaller*/ idp_resize_group_array(prop, newlen, newarr); - memcpy(newarr, prop->data.pointer, newlen*idp_size_table[(int)prop->subtype]); + memcpy(newarr, prop->data.pointer, newlen * idp_size_table[(int)prop->subtype]); } MEM_freeN(prop->data.pointer); @@ -257,8 +257,8 @@ void IDP_FreeArray(IDProperty *prop) } - static IDProperty *idp_generic_copy(IDProperty *prop) - { +static IDProperty *idp_generic_copy(IDProperty *prop) +{ IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup"); BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME); @@ -268,7 +268,7 @@ void IDP_FreeArray(IDProperty *prop) newp->data.val2 = prop->data.val2; return newp; - } +} static IDProperty *IDP_CopyArray(IDProperty *prop) { @@ -278,11 +278,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop) newp->data.pointer = MEM_dupallocN(prop->data.pointer); if (prop->type == IDP_GROUP) { - IDProperty **array= newp->data.pointer; + IDProperty **array = newp->data.pointer; int a; - for (a=0; alen; a++) - array[a]= IDP_CopyProperty(array[a]); + for (a = 0; a < prop->len; a++) + array[a] = IDP_CopyProperty(array[a]); } } newp->len = prop->len; @@ -294,12 +294,12 @@ static IDProperty *IDP_CopyArray(IDProperty *prop) /*taken from readfile.c*/ #define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } + char s_i, *p_i; \ + p_i = (char *)& (a); \ + s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \ + s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \ + s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \ + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; } @@ -350,7 +350,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen) int stlen = strlen(st); if (maxlen > 0 && maxlen < stlen) - stlen= maxlen; + stlen = maxlen; if (prop->subtype == IDP_STRING_SUB_BYTE) { IDP_ResizeArray(prop, stlen); @@ -396,14 +396,14 @@ void IDP_FreeString(IDProperty *prop) void IDP_LinkID(IDProperty *prop, ID *id) { - if (prop->data.pointer) ((ID*)prop->data.pointer)->us--; + if (prop->data.pointer) ((ID *)prop->data.pointer)->us--; prop->data.pointer = id; id_us_plus(id); } void IDP_UnlinkID(IDProperty *prop) { - ((ID*)prop->data.pointer)->us--; + ((ID *)prop->data.pointer)->us--; } /*-------- Group Functions -------*/ @@ -414,7 +414,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop) IDProperty *newp = idp_generic_copy(prop), *link; newp->len = prop->len; - for (link=prop->data.group.first; link; link=link->next) { + for (link = prop->data.group.first; link; link = link->next) { BLI_addtail(&newp->data.group, IDP_CopyProperty(link)); } @@ -426,22 +426,22 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop) void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) { IDProperty *other, *prop; - for (prop=src->data.group.first; prop; prop=prop->next) { - other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name)); - if (other && prop->type==other->type) { + for (prop = src->data.group.first; prop; prop = prop->next) { + other = BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name)); + if (other && prop->type == other->type) { switch (prop->type) { case IDP_INT: case IDP_FLOAT: case IDP_DOUBLE: - other->data= prop->data; + other->data = prop->data; break; case IDP_GROUP: IDP_SyncGroupValues(other, prop); break; default: { - IDProperty *tmp= other; - IDProperty *copy= IDP_CopyProperty(prop); + IDProperty *tmp = other; + IDProperty *copy = IDP_CopyProperty(prop); BLI_insertlinkafter(&dest->data.group, other, copy); BLI_remlink(&dest->data.group, tmp); @@ -460,8 +460,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) { IDProperty *loop, *prop; - for (prop=src->data.group.first; prop; prop=prop->next) { - for (loop=dest->data.group.first; loop; loop=loop->next) { + for (prop = src->data.group.first; prop; prop = prop->next) { + for (loop = dest->data.group.first; loop; loop = loop->next) { if (strcmp(loop->name, prop->name) == 0) { IDProperty *copy = IDP_CopyProperty(prop); @@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) { IDProperty *loop; - if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) { + if ((loop = IDP_GetPropertyFromGroup(group, prop->name))) { BLI_insertlink(&group->data.group, loop, prop); BLI_remlink(&group->data.group, loop); @@ -539,7 +539,7 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type) { - IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name); + IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name); return (idprop && idprop->type == type) ? idprop : NULL; } @@ -553,20 +553,20 @@ void *IDP_GetGroupIterator(IDProperty *prop) IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter"); iter->next = prop->data.group.first; iter->parent = prop; - return (void*) iter; + return (void *) iter; } IDProperty *IDP_GroupIterNext(void *vself) { - IDPIter *self = (IDPIter*) vself; - Link *next = (Link*) self->next; + IDPIter *self = (IDPIter *) vself; + Link *next = (Link *) self->next; if (self->next == NULL) { MEM_freeN(self); return NULL; } self->next = next->next; - return (void*) next; + return (void *) next; } void IDP_FreeIterBeforeEnd(void *vself) @@ -581,7 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself) static void IDP_FreeGroup(IDProperty *prop) { IDProperty *loop; - for (loop=prop->data.group.first; loop; loop=loop->next) { + for (loop = prop->data.group.first; loop; loop = loop->next) { IDP_FreeProperty(loop); } BLI_freelistN(&prop->data.group); @@ -635,7 +635,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0); else if (prop1->type == IDP_ARRAY) { if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) - return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype]*prop1->len); + return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len); else return 0; } @@ -645,8 +645,8 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) return 0; - for (link1=prop1->data.group.first; link1; link1=link1->next) { - link2= IDP_GetPropertyFromGroup(prop2, link1->name); + for (link1 = prop1->data.group.first; link1; link1 = link1->next) { + link2 = IDP_GetPropertyFromGroup(prop2, link1->name); if (!IDP_EqualsProperties(link1, link2)) return 0; @@ -655,14 +655,14 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return 1; } else if (prop1->type == IDP_IDPARRAY) { - IDProperty *array1= IDP_IDPArray(prop1); - IDProperty *array2= IDP_IDPArray(prop2); + IDProperty *array1 = IDP_IDPArray(prop1); + IDProperty *array2 = IDP_IDPArray(prop2); int i; if (prop1->len != prop2->len) return 0; - for (i=0; ilen; i++) + for (i = 0; i < prop1->len; i++) if (!IDP_EqualsProperties(&array1[i], &array2[i])) return 0; } @@ -673,7 +673,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) /* 'val' is never NULL, don't check */ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) { - IDProperty *prop=NULL; + IDProperty *prop = NULL; switch (type) { case IDP_INT: @@ -682,11 +682,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n break; case IDP_FLOAT: prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); - *(float*)&prop->data.val = val->f; + *(float *)&prop->data.val = val->f; break; case IDP_DOUBLE: prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); - *(double*)&prop->data.val = val->d; + *(double *)&prop->data.val = val->d; break; case IDP_ARRAY: { @@ -699,7 +699,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n prop = MEM_callocN(sizeof(IDProperty), "IDProperty array"); prop->subtype = val->array.type; if (val->array.len) - prop->data.pointer = MEM_callocN(idp_size_table[val->array.type]*val->array.len, "id property array"); + prop->data.pointer = MEM_callocN(idp_size_table[val->array.type] * val->array.len, "id property array"); prop->len = prop->totallen = val->array.len; break; } @@ -724,7 +724,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n prop->len = prop->totallen = val->string.len; memcpy(prop->data.pointer, st, val->string.len); } - prop->subtype= IDP_STRING_SUB_BYTE; + prop->subtype = IDP_STRING_SUB_BYTE; } else { if (st == NULL) { @@ -738,7 +738,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n prop->len = prop->totallen = stlen; memcpy(prop->data.pointer, st, stlen); } - prop->subtype= IDP_STRING_SUB_UTF8; + prop->subtype = IDP_STRING_SUB_UTF8; } break; } diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 1441bd7b12b..4579e6f92aa 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -39,10 +39,10 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, /* blank image */ if (rect_float) { - for (y= 0; y 0) { - rect_float[0]= rect_float[1]= rect_float[2]= 0.25f; - rect_float[3]= 1.0f; + rect_float[0] = rect_float[1] = rect_float[2] = 0.25f; + rect_float[3] = 1.0f; } else { - rect_float[0]= rect_float[1]= rect_float[2]= 0.58f; - rect_float[3]= 1.0f; + rect_float[0] = rect_float[1] = rect_float[2] = 0.58f; + rect_float[3] = 1.0f; } - rect_float+= 4; + rect_float += 4; } else { if (dark > 0) { - rect[0]= rect[1]= rect[2]= 64; - rect[3]= 255; + rect[0] = rect[1] = rect[2] = 64; + rect[3] = 255; } else { - rect[0]= rect[1]= rect[2]= 150; - rect[3]= 255; + rect[0] = rect[1] = rect[2] = 150; + rect[3] = 255; } - rect+= 4; + rect += 4; } } } - rect= rect_orig; - rect_float= rect_float_orig; + rect = rect_orig; + rect_float = rect_float_orig; /* 2nd pass, colored + */ - for (y= 0; yname, lib->filepath}; + char *bpath_user_data[2] = {bmain->name, lib->filepath}; BLI_bpath_traverse_id(bmain, id, - BLI_bpath_relocate_visitor, - BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, - bpath_user_data); + BLI_bpath_relocate_visitor, + BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, + bpath_user_data); } void id_lib_extern(ID *id) @@ -166,7 +166,7 @@ void id_us_min(ID *id) { if (id) { if (id->us < 2 && (id->flag & LIB_FAKEUSER)) { - id->us= 1; + id->us = 1; } else if (id->us <= 0) { printf("ID user decrement error: %s\n", id->name); @@ -274,7 +274,7 @@ int id_make_local(ID *id, int test) int id_copy(ID *id, ID **newid, int test) { - if (!test) *newid= NULL; + if (!test) *newid = NULL; /* conventions: * - make shallow copy, only this ID block @@ -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 *)BKE_object_copy((Object*)id); + if (!test) *newid = (ID *)BKE_object_copy((Object *)id); return 1; case ID_ME: - if (!test) *newid = (ID *)BKE_mesh_copy((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 *)BKE_material_copy((Material*)id); + if (!test) *newid = (ID *)BKE_material_copy((Material *)id); return 1; case ID_TE: - if (!test) *newid = (ID *)BKE_texture_copy((Tex*)id); + if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id); return 1; case ID_IM: - if (!test) *newid = (ID *)BKE_image_copy((Image*)id); + if (!test) *newid = (ID *)BKE_image_copy((Image *)id); return 1; case ID_LT: - if (!test) *newid = (ID *)BKE_lattice_copy((Lattice*)id); + if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id); return 1; case ID_LA: - if (!test) *newid = (ID *)BKE_lamp_copy((Lamp*)id); + if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id); return 1; case ID_SPK: - if (!test) *newid = (ID *)BKE_speaker_copy((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 *)BKE_key_copy((Key*)id); + if (!test) *newid = (ID *)BKE_key_copy((Key *)id); return 1; case ID_WO: - if (!test) *newid = (ID *)BKE_world_copy((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 *)BKE_text_copy((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 *)BKE_group_copy((Group*)id); + if (!test) *newid = (ID *)BKE_group_copy((Group *)id); return 1; case ID_AR: - if (!test) *newid = (ID *)BKE_armature_copy((bArmature*)id); + if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id); return 1; case ID_AC: - if (!test) *newid = (ID *)BKE_action_copy((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 *)BKE_particlesettings_copy((ParticleSettings*)id); + if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id); return 1; case ID_WM: return 0; /* can't be copied from here */ @@ -365,7 +365,7 @@ int id_copy(ID *id, ID **newid, int test) int id_unlink(ID *id, int test) { - Main *mainlib= G.main; + Main *mainlib = G.main; ListBase *lb; switch (GS(id->name)) { @@ -386,7 +386,7 @@ int id_unlink(ID *id, int test) if (id->us == 0) { if (test) return 1; - lb= which_libbase(mainlib, GS(id->name)); + lb = which_libbase(mainlib, GS(id->name)); BKE_libblock_free(lb, id); return 1; @@ -425,7 +425,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) ListBase *which_libbase(Main *mainlib, short type) { - switch ( type ) { + switch (type) { case ID_SCE: return &(mainlib->scene); case ID_LI: @@ -495,11 +495,11 @@ void flag_listbase_ids(ListBase *lb, short flag, short value) { ID *id; if (value) { - for (id= lb->first; id; id= id->next) id->flag |= flag; + for (id = lb->first; id; id = id->next) id->flag |= flag; } else { flag = ~flag; - for (id= lb->first; id; id= id->next) id->flag &= flag; + for (id = lb->first; id; id = id->next) id->flag &= flag; } } @@ -508,8 +508,8 @@ void flag_all_listbases_ids(short flag, short value) { ListBase *lbarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(G.main, lbarray); - while (a--) flag_listbase_ids(lbarray[a], flag, value); + a = set_listbasepointers(G.main, lbarray); + while (a--) flag_listbase_ids(lbarray[a], flag, value); } void recalc_all_library_objects(Main *main) @@ -517,9 +517,9 @@ void recalc_all_library_objects(Main *main) Object *ob; /* flag for full recalc */ - for (ob=main->object.first; ob; ob=ob->id.next) + for (ob = main->object.first; ob; ob = ob->id.next) if (ob->id.lib) - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } /* note: MAX_LIBARRAY define should match this code */ @@ -530,47 +530,47 @@ int set_listbasepointers(Main *main, ListBase **lb) /* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last. * This is important because freeing data decreases usercounts of other datablocks, * if this data is its self freed it can crash. */ - lb[a++]= &(main->ipo); - lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith) - lb[a++]= &(main->key); - lb[a++]= &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */ - lb[a++]= &(main->nodetree); - lb[a++]= &(main->image); - lb[a++]= &(main->tex); - lb[a++]= &(main->mat); - lb[a++]= &(main->vfont); + lb[a++] = &(main->ipo); + lb[a++] = &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith) + lb[a++] = &(main->key); + lb[a++] = &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */ + lb[a++] = &(main->nodetree); + lb[a++] = &(main->image); + lb[a++] = &(main->tex); + lb[a++] = &(main->mat); + lb[a++] = &(main->vfont); /* Important!: When adding a new object type, * the specific data should be inserted here */ - lb[a++]= &(main->armature); + lb[a++] = &(main->armature); - lb[a++]= &(main->mesh); - lb[a++]= &(main->curve); - lb[a++]= &(main->mball); + lb[a++] = &(main->mesh); + lb[a++] = &(main->curve); + lb[a++] = &(main->mball); - lb[a++]= &(main->latt); - lb[a++]= &(main->lamp); - lb[a++]= &(main->camera); + lb[a++] = &(main->latt); + lb[a++] = &(main->lamp); + lb[a++] = &(main->camera); - lb[a++]= &(main->text); - lb[a++]= &(main->sound); - lb[a++]= &(main->group); - lb[a++]= &(main->brush); - lb[a++]= &(main->script); - lb[a++]= &(main->particle); - lb[a++]= &(main->speaker); + lb[a++] = &(main->text); + lb[a++] = &(main->sound); + lb[a++] = &(main->group); + lb[a++] = &(main->brush); + lb[a++] = &(main->script); + lb[a++] = &(main->particle); + lb[a++] = &(main->speaker); - lb[a++]= &(main->world); - lb[a++]= &(main->screen); - lb[a++]= &(main->object); - lb[a++]= &(main->scene); - lb[a++]= &(main->library); - lb[a++]= &(main->wm); - lb[a++]= &(main->movieclip); + lb[a++] = &(main->world); + lb[a++] = &(main->screen); + lb[a++] = &(main->object); + lb[a++] = &(main->scene); + lb[a++] = &(main->library); + lb[a++] = &(main->wm); + lb[a++] = &(main->movieclip); - lb[a]= NULL; + lb[a] = NULL; return a; } @@ -587,74 +587,74 @@ int set_listbasepointers(Main *main, ListBase **lb) static ID *alloc_libblock_notest(short type) { - ID *id= NULL; + ID *id = NULL; - switch ( type ) { + switch (type) { case ID_SCE: - id= MEM_callocN(sizeof(Scene), "scene"); + id = MEM_callocN(sizeof(Scene), "scene"); break; case ID_LI: - id= MEM_callocN(sizeof(Library), "library"); + id = MEM_callocN(sizeof(Library), "library"); break; case ID_OB: - id= MEM_callocN(sizeof(Object), "object"); + id = MEM_callocN(sizeof(Object), "object"); break; case ID_ME: - id= MEM_callocN(sizeof(Mesh), "mesh"); + id = MEM_callocN(sizeof(Mesh), "mesh"); break; case ID_CU: - id= MEM_callocN(sizeof(Curve), "curve"); + id = MEM_callocN(sizeof(Curve), "curve"); break; case ID_MB: - id= MEM_callocN(sizeof(MetaBall), "mball"); + id = MEM_callocN(sizeof(MetaBall), "mball"); break; case ID_MA: - id= MEM_callocN(sizeof(Material), "mat"); + id = MEM_callocN(sizeof(Material), "mat"); break; case ID_TE: - id= MEM_callocN(sizeof(Tex), "tex"); + id = MEM_callocN(sizeof(Tex), "tex"); break; case ID_IM: - id= MEM_callocN(sizeof(Image), "image"); + id = MEM_callocN(sizeof(Image), "image"); break; case ID_LT: - id= MEM_callocN(sizeof(Lattice), "latt"); + id = MEM_callocN(sizeof(Lattice), "latt"); break; case ID_LA: - id= MEM_callocN(sizeof(Lamp), "lamp"); + id = MEM_callocN(sizeof(Lamp), "lamp"); break; case ID_CA: - id= MEM_callocN(sizeof(Camera), "camera"); + id = MEM_callocN(sizeof(Camera), "camera"); break; case ID_IP: - id= MEM_callocN(sizeof(Ipo), "ipo"); + id = MEM_callocN(sizeof(Ipo), "ipo"); break; case ID_KE: - id= MEM_callocN(sizeof(Key), "key"); + id = MEM_callocN(sizeof(Key), "key"); break; case ID_WO: - id= MEM_callocN(sizeof(World), "world"); + id = MEM_callocN(sizeof(World), "world"); break; case ID_SCR: - id= MEM_callocN(sizeof(bScreen), "screen"); + id = MEM_callocN(sizeof(bScreen), "screen"); break; case ID_VF: - id= MEM_callocN(sizeof(VFont), "vfont"); + id = MEM_callocN(sizeof(VFont), "vfont"); break; case ID_TXT: - id= MEM_callocN(sizeof(Text), "text"); + id = MEM_callocN(sizeof(Text), "text"); break; case ID_SCRIPT: //XXX id= MEM_callocN(sizeof(Script), "script"); break; case ID_SPK: - id= MEM_callocN(sizeof(Speaker), "speaker"); + id = MEM_callocN(sizeof(Speaker), "speaker"); break; case ID_SO: - id= MEM_callocN(sizeof(bSound), "sound"); + id = MEM_callocN(sizeof(bSound), "sound"); break; case ID_GR: - id= MEM_callocN(sizeof(Group), "group"); + id = MEM_callocN(sizeof(Group), "group"); break; case ID_AR: id = MEM_callocN(sizeof(bArmature), "armature"); @@ -687,14 +687,14 @@ static ID *alloc_libblock_notest(short type) /* used everywhere in blenkernel and text.c */ void *BKE_libblock_alloc(ListBase *lb, short type, const char *name) { - ID *id= NULL; + ID *id = NULL; - id= alloc_libblock_notest(type); + id = alloc_libblock_notest(type); if (id) { BLI_addtail(lb, id); - id->us= 1; + id->us = 1; id->icon_id = 0; - *( (short *)id->name )= type; + *( (short *)id->name) = type; new_id(lb, id, name); /* alphabetic insterion: is in new_id */ } @@ -705,11 +705,11 @@ void *BKE_libblock_alloc(ListBase *lb, short type, const char *name) /* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */ static void id_copy_animdata(ID *id, const short do_action) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - iat->adt= BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ + iat->adt = BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ } } @@ -730,20 +730,20 @@ void *BKE_libblock_copy(ID *id) ListBase *lb; size_t idn_len; - lb= which_libbase(G.main, GS(id->name)); - idn= BKE_libblock_alloc(lb, GS(id->name), id->name+2); + lb = which_libbase(G.main, GS(id->name)); + idn = BKE_libblock_alloc(lb, GS(id->name), id->name + 2); assert(idn != NULL); - idn_len= MEM_allocN_len(idn); + idn_len = MEM_allocN_len(idn); if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */ - const char *cp= (const char *)id; - char *cpn= (char *)idn; + const char *cp = (const char *)id; + char *cpn = (char *)idn; - memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID)); + memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID)); } - id->newid= idn; + id->newid = idn; idn->flag |= LIB_NEW; BKE_libblock_copy_data(idn, id, FALSE); @@ -756,11 +756,11 @@ static void BKE_library_free(Library *UNUSED(lib)) /* no freeing needed for libraries yet */ } -static void (*free_windowmanager_cb)(bContext *, wmWindowManager *)= NULL; +static void (*free_windowmanager_cb)(bContext *, wmWindowManager *) = NULL; void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) ) { - free_windowmanager_cb= func; + free_windowmanager_cb = func; } static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata) @@ -769,16 +769,16 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata FCurve *fcu; /* find the driver this belongs to and update it */ - for (fcu=adt->drivers.first; fcu; fcu=fcu->next) { - driver= fcu->driver; + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { + driver = fcu->driver; if (driver) { DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id == userdata) - dtar->id= NULL; + dtar->id = NULL; } DRIVER_TARGETS_LOOPER_END } @@ -790,13 +790,13 @@ 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 BKE_libblock_free(ListBase *lb, void *idv) { - ID *id= idv; + ID *id = idv; #ifdef WITH_PYTHON BPY_id_release(id); #endif - switch ( GS(id->name) ) { /* GetShort from util.h */ + switch (GS(id->name) ) { /* GetShort from util.h */ case ID_SCE: BKE_scene_free((Scene *)id); break; @@ -903,18 +903,18 @@ void BKE_libblock_free(ListBase *lb, void *idv) MEM_freeN(id); } -void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */ +void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */ { - ID *id= idv; + ID *id = idv; id->us--; - if (id->us<0) { + if (id->us < 0) { if (id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us); else printf("ERROR block %s users %d\n", id->name, id->us); } - if (id->us==0) { - if ( GS(id->name)==ID_OB ) BKE_object_unlink((Object *)id); + if (id->us == 0) { + if (GS(id->name) == ID_OB) BKE_object_unlink((Object *)id); BKE_libblock_free(lb, id); } @@ -927,12 +927,12 @@ void free_main(Main *mainvar) ListBase *lbarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(mainvar, lbarray); + a = set_listbasepointers(mainvar, lbarray); while (a--) { - ListBase *lb= lbarray[a]; + ListBase *lb = lbarray[a]; ID *id; - while ( (id= lb->first) ) { + while ( (id = lb->first) ) { BKE_libblock_free(lb, id); } } @@ -943,7 +943,7 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *BKE_libblock_find_name(const short 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, type); BLI_assert(lb != NULL); @@ -952,76 +952,76 @@ ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or static void get_flags_for_id(ID *id, char *buf) { - int isfake= id->flag & LIB_FAKEUSER; - int isnode=0; - /* Writeout the flags for the entry, note there - * is a small hack that writes 5 spaces instead - * of 4 if no flags are displayed... this makes - * things usually line up ok - better would be - * to have that explicit, oh well - zr - */ + int isfake = id->flag & LIB_FAKEUSER; + int isnode = 0; + /* Writeout the flags for the entry, note there + * is a small hack that writes 5 spaces instead + * of 4 if no flags are displayed... this makes + * things usually line up ok - better would be + * to have that explicit, oh well - zr + */ - if (GS(id->name)==ID_MA) - isnode= ((Material *)id)->use_nodes; - if (GS(id->name)==ID_TE) - isnode= ((Tex *)id)->use_nodes; + if (GS(id->name) == ID_MA) + isnode = ((Material *)id)->use_nodes; + if (GS(id->name) == ID_TE) + isnode = ((Tex *)id)->use_nodes; - if (id->us<0) + if (id->us < 0) strcpy(buf, "-1W "); else if (!id->lib && !isfake && id->us && !isnode) strcpy(buf, " "); else if (isnode) - sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); + sprintf(buf, "%c%cN%c ", id->lib ? 'L' : ' ', isfake ? 'F' : ' ', (id->us == 0) ? 'O' : ' '); else - sprintf(buf, "%c%c%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); + sprintf(buf, "%c%c%c ", id->lib ? 'L' : ' ', isfake ? 'F' : ' ', (id->us == 0) ? 'O' : ' '); } #define IDPUP_NO_VIEWER 1 static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int hideflag) { - int i, nids= BLI_countlist(lb); + int i, nids = BLI_countlist(lb); - if (nr) *nr= -1; + if (nr) *nr = -1; - if (nr && nids>MAX_IDPUP) { + if (nr && nids > MAX_IDPUP) { BLI_dynstr_append(pupds, "DataBrowse %x-2"); - *nr= -2; + *nr = -2; } else { ID *id; - for (i=0, id= lb->first; id; id= id->next, i++) { + for (i = 0, id = lb->first; id; id = id->next, i++) { char numstr[32]; - if (nr && id==link) *nr= i+1; + if (nr && id == link) *nr = i + 1; - if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.') + if (U.uiflag & USER_HIDE_DOT && id->name[2] == '.') continue; if (hideflag & IDPUP_NO_VIEWER) - if (GS(id->name)==ID_IM) - if ( ((Image *)id)->source==IMA_SRC_VIEWER ) + if (GS(id->name) == ID_IM) + if ( ((Image *)id)->source == IMA_SRC_VIEWER) continue; get_flags_for_id(id, numstr); BLI_dynstr_append(pupds, numstr); - BLI_dynstr_append(pupds, id->name+2); - BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i+1); + BLI_dynstr_append(pupds, id->name + 2); + BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i + 1); BLI_dynstr_append(pupds, numstr); /* icon */ switch (GS(id->name)) { - case ID_MA: /* fall through */ - case ID_TE: /* fall through */ - case ID_IM: /* fall through */ - case ID_WO: /* fall through */ - case ID_LA: /* fall through */ - BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id)); - BLI_dynstr_append(pupds, numstr); - break; - default: - break; + case ID_MA: /* fall through */ + case ID_TE: /* fall through */ + case ID_IM: /* fall through */ + case ID_WO: /* fall through */ + case ID_LA: /* fall through */ + BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id)); + BLI_dynstr_append(pupds, numstr); + break; + default: + break; } if (id->next) @@ -1035,7 +1035,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor /* if nr==NULL no MAX_IDPUP, this for non-header browsing */ void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { - DynStr *pupds= BLI_dynstr_new(); + DynStr *pupds = BLI_dynstr_new(); if (title) { BLI_dynstr_append(pupds, title); @@ -1050,7 +1050,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra IDnames_to_dyn_pupstring(pupds, lb, link, nr, 0); - *str= BLI_dynstr_get_cstring(pupds); + *str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); } @@ -1058,7 +1058,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra #if 0 /* unused */ void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { - DynStr *pupds= BLI_dynstr_new(); + DynStr *pupds = BLI_dynstr_new(); if (title) { BLI_dynstr_append(pupds, title); @@ -1073,7 +1073,7 @@ void IMAnames_to_pupstring(const char **str, const char *title, const char *extr IDnames_to_dyn_pupstring(pupds, lb, link, nr, IDPUP_NO_VIEWER); - *str= BLI_dynstr_get_cstring(pupds); + *str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); } #endif @@ -1083,19 +1083,19 @@ void id_sort_by_name(ListBase *lb, ID *id) ID *idtest; /* insert alphabetically */ - if (lb->first!=lb->last) { + if (lb->first != lb->last) { BLI_remlink(lb, id); - idtest= lb->first; + idtest = lb->first; while (idtest) { - if (BLI_strcasecmp(idtest->name, id->name)>0 || (idtest->lib && !id->lib)) { + if (BLI_strcasecmp(idtest->name, id->name) > 0 || (idtest->lib && !id->lib)) { BLI_insertlinkbefore(lb, idtest, id); break; } - idtest= idtest->next; + idtest = idtest->next; } /* as last */ - if (idtest==NULL) { + if (idtest == NULL) { BLI_addtail(lb, id); } } @@ -1108,15 +1108,15 @@ void id_sort_by_name(ListBase *lb, ID *id) */ static ID *is_dupid(ListBase *lb, ID *id, const char *name) { - ID *idtest=NULL; + ID *idtest = NULL; - for ( idtest = lb->first; idtest; idtest = idtest->next ) { + for (idtest = lb->first; idtest; idtest = idtest->next) { /* if idtest is not a lib */ - if ( id != idtest && idtest->lib == NULL ) { + if (id != idtest && idtest->lib == NULL) { /* do not test alphabetic! */ /* optimized */ - if ( idtest->name[2] == name[0] ) { - if (strcmp(name, idtest->name+2)==0) break; + if (idtest->name[2] == name[0]) { + if (strcmp(name, idtest->name + 2) == 0) break; } } } @@ -1137,7 +1137,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; - int nr= 0, nrtest, a, left_len; + int nr = 0, nrtest, a, left_len; char in_use[64]; /* use as a boolean array, unrelated to name length */ char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8]; @@ -1152,43 +1152,44 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) idtest = is_dupid(lb, id, name); /* if there is no double, done */ - if ( idtest == NULL ) return 0; + if (idtest == NULL) return 0; /* we have a dup; need to make a new name */ /* quick check so we can reuse one of first 64 ids if vacant */ memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ - left_len= BLI_split_name_num(left, &nr, name, '.'); + left_len = BLI_split_name_num(left, &nr, name, '.'); /* if new name will be too long, truncate it */ if (nr > 999 && left_len > (MAX_ID_NAME - 8)) { - left[MAX_ID_NAME - 8]= 0; - left_len= MAX_ID_NAME - 8; + left[MAX_ID_NAME - 8] = 0; + left_len = MAX_ID_NAME - 8; } else if (left_len > (MAX_ID_NAME - 7)) { - left[MAX_ID_NAME - 7]= 0; - left_len= MAX_ID_NAME - 7; + left[MAX_ID_NAME - 7] = 0; + left_len = MAX_ID_NAME - 7; } - for (idtest= lb->first; idtest; idtest= idtest->next) { - if ( (id != idtest) && - (idtest->lib == NULL) && - (*name == *(idtest->name+2)) && - (strncmp(name, idtest->name+2, left_len)==0) && - (BLI_split_name_num(leftest, &nrtest, idtest->name+2, '.') == left_len) - ) { + for (idtest = lb->first; idtest; idtest = idtest->next) { + if ( (id != idtest) && + (idtest->lib == NULL) && + (*name == *(idtest->name + 2)) && + (strncmp(name, idtest->name + 2, left_len) == 0) && + (BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len) + ) + { if (nrtest < sizeof(in_use)) - in_use[nrtest]= 1; /* mark as used */ + in_use[nrtest] = 1; /* mark as used */ if (nr <= nrtest) - nr= nrtest+1; /* track largest unused */ + nr = nrtest + 1; /* track largest unused */ } } /* decide which value of nr to use */ - for (a=0; a < sizeof(in_use); a++) { - if (a>=nr) break; /* stop when we've check up to biggest */ - if ( in_use[a]==0 ) { /* found an unused value */ + for (a = 0; a < sizeof(in_use); a++) { + if (a >= nr) break; /* stop when we've check up to biggest */ + if (in_use[a] == 0) { /* found an unused value */ nr = a; break; } @@ -1198,13 +1199,13 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) * rather than just chopping and adding numbers, * shave off the end chars until we have a unique name. * Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */ - if (nr==0 && name[left_len]== '\0') { - int len = left_len-1; - idtest= is_dupid(lb, id, name); + if (nr == 0 && name[left_len] == '\0') { + int len = left_len - 1; + idtest = is_dupid(lb, id, name); - while (idtest && len> 1) { + while (idtest && len > 1) { name[len--] = '\0'; - idtest= is_dupid(lb, id, name); + idtest = is_dupid(lb, id, name); } if (idtest == NULL) return 1; /* otherwise just continue and use a number suffix */ @@ -1234,24 +1235,24 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) int new_id(ListBase *lb, ID *id, const char *tname) { int result; - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; /* if library, don't rename */ if (id->lib) return 0; /* if no libdata given, look up based on ID */ - if (lb==NULL) lb= which_libbase(G.main, GS(id->name)); + if (lb == NULL) lb = which_libbase(G.main, GS(id->name)); /* if no name given, use name of current ID * else make a copy (tname args can be const) */ - if (tname==NULL) - tname= id->name+2; + if (tname == NULL) + tname = id->name + 2; - strncpy(name, tname, sizeof(name)-1); + strncpy(name, tname, sizeof(name) - 1); /* if result > MAX_ID_NAME-3, strncpy don't put the final '\0' to name. * easier to assign each time then to check if its needed */ - name[sizeof(name)-1]= 0; + name[sizeof(name) - 1] = 0; if (name[0] == '\0') { /* disallow empty names */ @@ -1264,14 +1265,14 @@ int new_id(ListBase *lb, ID *id, const char *tname) } result = check_for_dupid(lb, id, name); - strcpy(id->name+2, name); + strcpy(id->name + 2, name); /* This was in 2.43 and previous releases * however all data in blender should be sorted, not just duplicate names * sorting should not hurt, but noting just incause it alters the way other * functions work, so sort every time */ #if 0 - if ( result ) + if (result) id_sort_by_name(lb, id); #endif @@ -1286,8 +1287,8 @@ void id_clear_lib_data(Main *bmain, ID *id) { BKE_id_lib_local_paths(bmain, id->lib, id); - id->lib= NULL; - id->flag= LIB_LOCAL; + id->lib = NULL; + id->flag = LIB_LOCAL; new_id(which_libbase(bmain, GS(id->name)), id, NULL); } @@ -1298,18 +1299,18 @@ void clear_id_newpoins(void) ID *id; int a; - a= set_listbasepointers(G.main, lbarray); + a = set_listbasepointers(G.main, lbarray); while (a--) { - id= lbarray[a]->first; + id = lbarray[a]->first; while (id) { - id->newid= NULL; + id->newid = NULL; id->flag &= ~LIB_NEW; - id= id->next; + id = id->next; } } } -#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;} +#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } static void lib_indirect_test_id(ID *id, Library *lib) { @@ -1323,17 +1324,17 @@ static void lib_indirect_test_id(ID *id, Library *lib) return; } - if (GS(id->name)==ID_OB) { - Object *ob= (Object *)id; + if (GS(id->name) == ID_OB) { + Object *ob = (Object *)id; Mesh *me; int a; -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ // XXX old animation system! -------------------------------------- { bActionStrip *strip; - for (strip=ob->nlastrips.first; strip; strip=strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { LIBTAG(strip->object); LIBTAG(strip->act); LIBTAG(strip->ipo); @@ -1342,14 +1343,14 @@ static void lib_indirect_test_id(ID *id, Library *lib) // XXX: new animation system needs something like this? #endif - for (a=0; atotcol; a++) { + for (a = 0; a < ob->totcol; a++) { LIBTAG(ob->mat[a]); } LIBTAG(ob->dup_group); LIBTAG(ob->proxy); - me= ob->data; + me = ob->data; LIBTAG(me); } } @@ -1358,12 +1359,12 @@ void tag_main_lb(ListBase *lb, const short tag) { ID *id; if (tag) { - for (id= lb->first; id; id= id->next) { + for (id = lb->first; id; id = id->next) { id->flag |= LIB_DOIT; } } else { - for (id= lb->first; id; id= id->next) { + for (id = lb->first; id; id = id->next) { id->flag &= ~LIB_DOIT; } } @@ -1371,7 +1372,7 @@ void tag_main_lb(ListBase *lb, const short tag) void tag_main_idcode(struct Main *mainvar, const short type, const short tag) { - ListBase *lb= which_libbase(mainvar, type); + ListBase *lb = which_libbase(mainvar, type); tag_main_lb(lb, tag); } @@ -1381,7 +1382,7 @@ void tag_main(struct Main *mainvar, const short tag) ListBase *lbarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(mainvar, lbarray); + a = set_listbasepointers(mainvar, lbarray); while (a--) { tag_main_lb(lbarray[a], tag); } @@ -1391,27 +1392,27 @@ void tag_main(struct Main *mainvar, const short tag) * bmain is almost certainly G.main */ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) { - ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL}; + ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL}; ID *id, *idn; int a; - a= set_listbasepointers(bmain, lbarray); + a = set_listbasepointers(bmain, lbarray); while (a--) { - id= lbarray[a]->first; + id = lbarray[a]->first; while (id) { - id->newid= NULL; - idn= id->next; /* id is possibly being inserted again */ + id->newid = NULL; + idn = id->next; /* id is possibly being inserted again */ /* The check on the second line (LIB_PRE_EXISTING) is done so its * possible to tag data you don't want to be made local, used for * appending data, so any libdata already linked wont become local * (very nasty to discover all your links are lost after appending) * */ - if (id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) && - (untagged_only==0 || !(id->flag & LIB_PRE_EXISTING))) + if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) && + (untagged_only == 0 || !(id->flag & LIB_PRE_EXISTING))) { - if (lib==NULL || id->lib==lib) { + if (lib == NULL || id->lib == lib) { if (id->lib) { id_clear_lib_data(bmain, id); /* sets 'id->flag' */ @@ -1420,15 +1421,15 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) id_sort_by_name(lbarray[a], id); } else { - id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW); + id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW); } } } - id= idn; + id = idn; } /* patch2: make it aphabetically */ - while ( (id=tempbase.first) ) { + while ( (id = tempbase.first) ) { BLI_remlink(&tempbase, id); BLI_addtail(lbarray[a], id); new_id(lbarray[a], id, NULL); @@ -1436,9 +1437,9 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) } /* patch 3: make sure library data isn't indirect falsely... */ - a= set_listbasepointers(bmain, lbarray); + a = set_listbasepointers(bmain, lbarray); while (a--) { - for (id= lbarray[a]->first; id; id=id->next) + for (id = lbarray[a]->first; id; id = id->next) lib_indirect_test_id(id, lib); } } @@ -1451,34 +1452,34 @@ void test_idbutton(char *name) ID *idtest; - lb= which_libbase(G.main, GS(name-2) ); - if (lb==NULL) return; + lb = which_libbase(G.main, GS(name - 2) ); + if (lb == NULL) return; /* search for id */ - idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2); + idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2); - if (idtest) if ( new_id(lb, idtest, name)==0 ) id_sort_by_name(lb, idtest); + if (idtest) if (new_id(lb, idtest, name) == 0) id_sort_by_name(lb, idtest); } void text_idbutton(struct ID *id, char *text) { if (id) { - if (GS(id->name)==ID_SCE) + if (GS(id->name) == ID_SCE) strcpy(text, "SCE: "); - else if (GS(id->name)==ID_SCR) + else if (GS(id->name) == ID_SCR) strcpy(text, "SCR: "); - else if (GS(id->name)==ID_MA && ((Material*)id)->use_nodes) + else if (GS(id->name) == ID_MA && ((Material *)id)->use_nodes) strcpy(text, "NT: "); else { - text[0]= id->name[0]; - text[1]= id->name[1]; - text[2]= ':'; - text[3]= ' '; - text[4]= 0; + text[0] = id->name[0]; + text[1] = id->name[1]; + text[2] = ':'; + text[3] = ' '; + text[4] = 0; } } else { - text[0]= '\0'; + text[0] = '\0'; } } @@ -1486,19 +1487,19 @@ void rename_id(ID *id, const char *name) { ListBase *lb; - BLI_strncpy(id->name+2, name, sizeof(id->name)-2); - lb= which_libbase(G.main, GS(id->name) ); + BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2); + lb = which_libbase(G.main, GS(id->name) ); new_id(lb, id, name); } void name_uiprefix_id(char *name, ID *id) { - name[0] = id->lib ? 'L':' '; - name[1] = id->flag & LIB_FAKEUSER ? 'F': (id->us==0)?'0':' '; + name[0] = id->lib ? 'L' : ' '; + name[1] = id->flag & LIB_FAKEUSER ? 'F' : (id->us == 0) ? '0' : ' '; name[2] = ' '; - strcpy(name+3, id->name+2); + strcpy(name + 3, id->name + 2); } void BKE_library_filepath_set(Library *lib, const char *filepath) @@ -1519,7 +1520,7 @@ void BKE_library_filepath_set(Library *lib, const char *filepath) * outliner, and its not really supported but allow from here for now * since making local could cause this to be directly linked - campbell */ - const char *basepath= lib->parent ? lib->parent->filepath : G.main->name; + const char *basepath = lib->parent ? lib->parent->filepath : G.main->name; BLI_path_abs(lib->filepath, basepath); } } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 5b824c04836..e212d45742a 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -68,12 +68,12 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) { - static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL}; + static ModifierTypeInfo *types[NUM_MODIFIER_TYPES] = {NULL}; static int types_init = 1; if (types_init) { modifier_type_init(types); /* MOD_utils.c */ - types_init= 0; + types_init = 0; } /* type unsigned, no need to check < 0 */ @@ -97,7 +97,7 @@ ModifierData *modifier_new(int type) md->type = type; md->mode = eModifierMode_Realtime - | eModifierMode_Render | eModifierMode_Expanded; + | eModifierMode_Render | eModifierMode_Expanded; if (mti->flags & eModifierTypeFlag_EnableInEditmode) md->mode |= eModifierMode_Editmode; @@ -137,8 +137,8 @@ int modifier_supportsMapping(ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - return (mti->type==eModifierTypeType_OnlyDeform || - (mti->flags & eModifierTypeFlag_SupportsMapping)); + return (mti->type == eModifierTypeType_OnlyDeform || + (mti->flags & eModifierTypeFlag_SupportsMapping)); } int modifier_isPreview(ModifierData *md) @@ -158,8 +158,8 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) - if (md->type==type) + for (; md; md = md->next) + if (md->type == type) break; return md; @@ -175,7 +175,7 @@ void modifiers_clearErrors(Object *ob) ModifierData *md = ob->modifiers.first; /* int qRedraw = 0; */ - for (; md; md=md->next) { + for (; md; md = md->next) { if (md->error) { MEM_freeN(md->error); md->error = NULL; @@ -186,11 +186,11 @@ void modifiers_clearErrors(Object *ob) } void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk, - void *userData) + void *userData) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->foreachObjectLink) @@ -202,7 +202,7 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData); @@ -218,7 +218,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->foreachTexLink) @@ -240,12 +240,12 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; - return ( (md->mode & eModifierMode_Realtime) && - (md->mode & eModifierMode_Editmode) && - (!mti->isDisabled || !mti->isDisabled(md, 0)) && - modifier_supportsMapping(md)); + return ((md->mode & eModifierMode_Realtime) && + (md->mode & eModifierMode_Editmode) && + (!mti->isDisabled || !mti->isDisabled(md, 0)) && + modifier_supportsMapping(md)); } int modifier_sameTopology(ModifierData *md) @@ -269,7 +269,7 @@ void modifier_setError(ModifierData *md, const char *format, ...) va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - buffer[sizeof(buffer) - 1]= '\0'; + buffer[sizeof(buffer) - 1] = '\0'; if (md->error) MEM_freeN(md->error); @@ -287,19 +287,19 @@ void modifier_setError(ModifierData *md, const char *format, ...) */ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) { - ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; + ModifierData *md = (virtual_) ? modifiers_getVirtualModifierList(ob) : ob->modifiers.first; int i, cageIndex = -1; if (lastPossibleCageIndex_r) { /* ensure the value is initialized */ - *lastPossibleCageIndex_r= -1; + *lastPossibleCageIndex_r = -1; } /* Find the last modifier acting on the cage. */ - for (i=0; md; i++, md=md->next) { + for (i = 0; md; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if (!(md->mode & eModifierMode_Realtime)) continue; if (!(md->mode & eModifierMode_Editmode)) continue; @@ -344,7 +344,7 @@ int modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) return 0; if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0; @@ -396,7 +396,7 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat } /* reverse the list so it's in the correct order */ - BLI_linklist_reverse((LinkNode**)&dataMasks); + BLI_linklist_reverse((LinkNode **)&dataMasks); return dataMasks; } @@ -431,19 +431,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) if (init) { md = modifier_new(eModifierType_Armature); - amd = *((ArmatureModifierData*) md); + amd = *((ArmatureModifierData *) md); modifier_free(md); md = modifier_new(eModifierType_Curve); - cmd = *((CurveModifierData*) md); + cmd = *((CurveModifierData *) md); modifier_free(md); md = modifier_new(eModifierType_Lattice); - lmd = *((LatticeModifierData*) md); + lmd = *((LatticeModifierData *) md); modifier_free(md); md = modifier_new(eModifierType_ShapeKey); - smd = *((ShapeKeyModifierData*) md); + smd = *((ShapeKeyModifierData *) md); modifier_free(md); amd.modifier.mode |= eModifierMode_Virtual; @@ -457,19 +457,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) md = ob->modifiers.first; if (ob->parent) { - if (ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) { + if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) { amd.object = ob->parent; amd.modifier.next = md; - amd.deformflag= ((bArmature *)(ob->parent->data))->deformflag; + amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag; md = &amd.modifier; } - else if (ob->parent->type==OB_CURVE && ob->partype==PARSKEL) { + else if (ob->parent->type == OB_CURVE && ob->partype == PARSKEL) { cmd.object = ob->parent; cmd.defaxis = ob->trackflag + 1; cmd.modifier.next = md; md = &cmd.modifier; } - else if (ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + else if (ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) { lmd.object = ob->parent; lmd.modifier.next = md; md = &lmd.modifier; @@ -479,9 +479,9 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) /* shape key modifier, not yet for curves */ if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) { if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE)) - smd.modifier.mode |= eModifierMode_Editmode|eModifierMode_OnCage; + smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage; else - smd.modifier.mode &= ~eModifierMode_Editmode|eModifierMode_OnCage; + smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage; smd.modifier.next = md; md = &smd.modifier; @@ -496,12 +496,12 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) Object *modifiers_isDeformedByArmature(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); - ArmatureModifierData *amd= NULL; + ArmatureModifierData *amd = NULL; /* return the first selected armature, this lets us use multiple armatures */ - for (; md; md=md->next) { - if (md->type==eModifierType_Armature) { - amd = (ArmatureModifierData*) md; + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + amd = (ArmatureModifierData *) md; if (amd->object && (amd->object->flag & SELECT)) return amd->object; } @@ -520,12 +520,12 @@ Object *modifiers_isDeformedByArmature(Object *ob) Object *modifiers_isDeformedByLattice(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); - LatticeModifierData *lmd= NULL; + LatticeModifierData *lmd = NULL; /* return the first selected lattice, this lets us use multiple lattices */ - for (; md; md=md->next) { - if (md->type==eModifierType_Lattice) { - lmd = (LatticeModifierData*) md; + for (; md; md = md->next) { + if (md->type == eModifierType_Lattice) { + lmd = (LatticeModifierData *) md; if (lmd->object && (lmd->object->flag & SELECT)) return lmd->object; } @@ -543,10 +543,10 @@ int modifiers_usesArmature(Object *ob, bArmature *arm) { ModifierData *md = modifiers_getVirtualModifierList(ob); - for (; md; md=md->next) { - if (md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if (amd->object && amd->object->data==arm) + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *) md; + if (amd->object && amd->object->data == arm) return 1; } } @@ -556,9 +556,9 @@ int modifiers_usesArmature(Object *ob, bArmature *arm) int modifier_isCorrectableDeformed(ModifierData *md) { - if (md->type==eModifierType_Armature) + if (md->type == eModifierType_Armature) return 1; - if (md->type==eModifierType_ShapeKey) + if (md->type == eModifierType_ShapeKey) return 1; return 0; @@ -568,11 +568,11 @@ int modifiers_isCorrectableDeformed(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); - for (; md; md=md->next) { - if (ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0); + for (; md; md = md->next) { + if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) ; else - if (modifier_isCorrectableDeformed(md)) - return 1; + if (modifier_isCorrectableDeformed(md)) + return 1; } return 0; } @@ -593,22 +593,22 @@ int modifiers_isPreview(Object *ob) int modifiers_indexInObject(Object *ob, ModifierData *md_seek) { - int i= 0; + int i = 0; ModifierData *md; - for (md=ob->modifiers.first; (md && md_seek!=md); md=md->next, i++); - if (!md) return -1; /* modifier isn't in the object */ + for (md = ob->modifiers.first; (md && md_seek != md); md = md->next, i++) ; + if (!md) return -1; /* modifier isn't in the object */ return i; } void modifier_freeTemporaryData(ModifierData *md) { if (md->type == eModifierType_Armature) { - ArmatureModifierData *amd= (ArmatureModifierData*)md; + ArmatureModifierData *amd = (ArmatureModifierData *)md; if (amd->prevCos) { MEM_freeN(amd->prevCos); - amd->prevCos= NULL; + amd->prevCos = NULL; } } } @@ -625,7 +625,7 @@ void test_object_modifiers(Object *ob) for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Multires) { - MultiresModifierData *mmd = (MultiresModifierData*)md; + MultiresModifierData *mmd = (MultiresModifierData *)md; multiresModifier_set_levels_from_disps(mmd, ob); } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 35ee0549554..6c3032cb279 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -82,30 +82,30 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm void multires_customdata_delete(Mesh *me) { if (me->edit_btmesh) { - BMEditMesh *em= me->edit_btmesh; + BMEditMesh *em = me->edit_btmesh; /* CustomData_external_remove is used here only to mark layer * as non-external for further free-ing, so zero element count * looks safer than em->totface */ CustomData_external_remove(&em->bm->ldata, &me->id, - CD_MDISPS, 0); + CD_MDISPS, 0); BM_data_layer_free(em->bm, &em->bm->ldata, CD_MDISPS); } else { CustomData_external_remove(&me->ldata, &me->id, - CD_MDISPS, me->totloop); + CD_MDISPS, me->totloop); CustomData_free_layer_active(&me->ldata, CD_MDISPS, - me->totloop); + me->totloop); } } /** Grid hiding **/ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, - int lo_level, - int hi_level, + int lo_level, + int hi_level, - /* assumed to be at hi_level (or - * null) */ - BLI_bitmap prev_hidden) + /* assumed to be at hi_level (or + * null) */ + BLI_bitmap prev_hidden) { BLI_bitmap subd; int hi_gridsize = ccg_gridsize(hi_level); @@ -163,8 +163,8 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, } static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden, - int old_level, - int new_level) + int old_level, + int new_level) { BLI_bitmap new_hidden; int new_gridsize = ccg_gridsize(new_level); @@ -174,16 +174,16 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden, BLI_assert(new_level <= old_level); factor = ccg_factor(new_level, old_level); new_hidden = BLI_BITMAP_NEW(new_gridsize * new_gridsize, - "downsample hidden"); + "downsample hidden"); for (y = 0; y < new_gridsize; y++) { for (x = 0; x < new_gridsize; x++) { old_value = BLI_BITMAP_GET(old_hidden, - factor*y*old_gridsize + x*factor); + factor * y * old_gridsize + x * factor); - BLI_BITMAP_MODIFY(new_hidden, y*new_gridsize + x, old_value); + BLI_BITMAP_MODIFY(new_hidden, y * new_gridsize + x, old_value); } } @@ -191,7 +191,7 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden, } static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, - Mesh *me, int level) + Mesh *me, int level) { const MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); BLI_bitmap *grid_hidden = ccgdm->gridHidden; @@ -208,7 +208,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, if (gh) { grid_hidden[g] = - multires_mdisps_downsample_hidden(gh, md->level, level); + multires_mdisps_downsample_hidden(gh, md->level, level); } } } @@ -227,9 +227,9 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level) return; subd = multires_mdisps_upsample_hidden(md->hidden, - md->level, - new_level, - NULL); + md->level, + new_level, + NULL); /* swap in the subdivided data */ MEM_freeN(md->hidden); @@ -239,7 +239,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level) static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level) { MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, - CD_CALLOC, 0, me->totloop); + CD_CALLOC, 0, me->totloop); int gridsize = ccg_gridsize(level); int gridarea = gridsize * gridsize; int i, j, k; @@ -274,7 +274,7 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level) DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob) { - ModifierData *md= (ModifierData *)mmd; + ModifierData *md = (ModifierData *)mmd; ModifierTypeInfo *mti = modifierType_getInfo(md->type); DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); DerivedMesh *dm; @@ -294,7 +294,7 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * for (md = lastmd; md; md = md->prev) { if (md->type == eModifierType_Multires) { if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) - return (MultiresModifierData*)md; + return (MultiresModifierData *)md; } } @@ -307,16 +307,16 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first) { ModifierData *md; - MultiresModifierData *mmd= NULL, *firstmmd= NULL; + MultiresModifierData *mmd = NULL, *firstmmd = NULL; /* find first active multires modifier */ for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Multires) { if (!firstmmd) - firstmmd= (MultiresModifierData*)md; + firstmmd = (MultiresModifierData *)md; if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) { - mmd= (MultiresModifierData*)md; + mmd = (MultiresModifierData *)md; break; } } @@ -334,11 +334,11 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) { if (render) - return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl): mmd->renderlvl; + return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl) : mmd->renderlvl; else if (ob->mode == OB_MODE_SCULPT) return mmd->sculptlvl; else - return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl): mmd->lvl; + return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl; } static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) @@ -354,7 +354,7 @@ static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lv static void multires_dm_mark_as_modified(DerivedMesh *dm, MultiresModifiedFlags flags) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm->multires.modified_flags |= flags; } @@ -368,13 +368,13 @@ void multires_force_update(Object *ob) { if (ob) { if (ob->derivedFinal) { - ob->derivedFinal->needsFree =1; + ob->derivedFinal->needsFree = 1; ob->derivedFinal->release(ob->derivedFinal); ob->derivedFinal = NULL; } if (ob->sculpt && ob->sculpt->pbvh) { BLI_pbvh_free(ob->sculpt->pbvh); - ob->sculpt->pbvh= NULL; + ob->sculpt->pbvh = NULL; } } } @@ -394,9 +394,9 @@ void multires_force_render_update(Object *ob) } int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, - Object *ob, DerivedMesh *srcdm) + Object *ob, DerivedMesh *srcdm) { - DerivedMesh *mrdm = get_multires_dm (scene, mmd, ob); + DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob); if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) { multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm)); @@ -422,7 +422,7 @@ int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *ds } int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd, - Object *ob, ModifierData *md) + Object *ob, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); DerivedMesh *dm, *ndm; @@ -434,20 +434,20 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm /* Create DerivedMesh for deformation modifier */ dm = get_multires_dm(scene, mmd, ob); - numVerts= dm->getNumVerts(dm); - deformedVerts= MEM_callocN(sizeof(float)*numVerts*3, "multiresReshape_deformVerts"); + numVerts = dm->getNumVerts(dm); + deformedVerts = MEM_callocN(sizeof(float) * numVerts * 3, "multiresReshape_deformVerts"); dm->getVertCos(dm, deformedVerts); mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); - ndm= CDDM_copy(dm); + ndm = CDDM_copy(dm); CDDM_apply_vert_coords(ndm, deformedVerts); MEM_freeN(deformedVerts); dm->release(dm); /* Reshaping */ - result= multiresModifier_reshapeFromDM(scene, mmd, ob, ndm); + result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm); /* Cleanup */ ndm->release(ndm); @@ -460,19 +460,19 @@ static int get_levels_from_disps(Object *ob) { Mesh *me = ob->data; MDisps *mdisp, *md; - int i, j, totlvl= 0; + int i, j, totlvl = 0; mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS); for (i = 0; i < me->totpoly; ++i) { md = mdisp + me->mpoly[i].loopstart; - for (j=0; jmpoly[i].totloop; j++, md++) { + for (j = 0; j < me->mpoly[i].totloop; j++, md++) { if (md->totdisp == 0) continue; while (1) { - int side = (1 << (totlvl-1)) + 1; - int lvl_totdisp = side*side; + int side = (1 << (totlvl - 1)) + 1; + int lvl_totdisp = side * side; if (md->totdisp == lvl_totdisp) break; else if (md->totdisp < lvl_totdisp) @@ -510,7 +510,7 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o static void multires_set_tot_mdisps(Mesh *me, int lvl) { - MDisps *mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); int i; if (mdisps) { @@ -554,18 +554,18 @@ static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA, int x, y, j, skip; if (sizeA > sizeB) { - skip = (sizeA-1)/(sizeB-1); + skip = (sizeA - 1) / (sizeB - 1); for (j = 0, y = 0; y < sizeB; y++) for (x = 0; x < sizeB; x++, j++) - copy_v3_v3(gridA[y*skip*sizeA + x*skip], gridB[j]); + copy_v3_v3(gridA[y * skip * sizeA + x * skip], gridB[j]); } else { - skip = (sizeB-1)/(sizeA-1); + skip = (sizeB - 1) / (sizeA - 1); for (j = 0, y = 0; y < sizeA; y++) for (x = 0; x < sizeA; x++, j++) - copy_v3_v3(gridA[j], gridB[y*skip*sizeB + x*skip]); + copy_v3_v3(gridA[j], gridB[y * skip * sizeB + x * skip]); } } @@ -574,30 +574,30 @@ static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int size int x, y, j, skip; if (sizeA > sizeB) { - skip = (sizeA-1)/(sizeB-1); + skip = (sizeA - 1) / (sizeB - 1); for (j = 0, y = 0; y < sizeB; y++) for (x = 0; x < sizeB; x++, j++) - copy_v3_v3(gridA[y*skip*sizeA + x*skip].co, gridB[j].co); + copy_v3_v3(gridA[y * skip * sizeA + x * skip].co, gridB[j].co); } else { - skip = (sizeB-1)/(sizeA-1); + skip = (sizeB - 1) / (sizeA - 1); for (j = 0, y = 0; y < sizeA; y++) for (x = 0; x < sizeA; x++, j++) - copy_v3_v3(gridA[j].co, gridB[y*skip*sizeB + x*skip].co); + copy_v3_v3(gridA[j].co, gridB[y * skip * sizeB + x * skip].co); } } static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) { - Mesh *me = (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; int levels = mmd->totlvl - lvl; MDisps *mdisps; multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); - mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); multires_force_update(ob); @@ -609,8 +609,8 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) int i, j; for (i = 0; i < me->totpoly; ++i) { - for (j=0; jmpoly[i].totloop; j++) { - MDisps *mdisp= &mdisps[me->mpoly[i].loopstart+j]; + for (j = 0; j < me->mpoly[i].totloop; j++) { + MDisps *mdisp = &mdisps[me->mpoly[i].loopstart + j]; float (*disps)[3], (*ndisps)[3], (*hdisps)[3]; int totdisp = multires_grid_tot[lvl]; @@ -622,15 +622,15 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) multires_copy_grid(ndisps, hdisps, nsize, hsize); if (mdisp->hidden) { BLI_bitmap gh = - multires_mdisps_downsample_hidden(mdisp->hidden, - mdisp->level, - lvl); + multires_mdisps_downsample_hidden(mdisp->hidden, + mdisp->level, + lvl); MEM_freeN(mdisp->hidden); mdisp->hidden = gh; } - ndisps += nsize*nsize; - hdisps += hsize*hsize; + ndisps += nsize * nsize; + hdisps += hsize * hsize; MEM_freeN(mdisp->disps); mdisp->disps = disps; @@ -657,7 +657,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); - mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); multires_force_update(ob); @@ -670,7 +670,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple) { - MultiresModifierData mmd= {{NULL}}; + MultiresModifierData mmd = {{NULL}}; mmd.lvl = lvl; mmd.sculptlvl = lvl; @@ -683,7 +683,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv) { - SubsurfModifierData smd= {{NULL}}; + SubsurfModifierData smd = {{NULL}}; smd.levels = smd.renderLevels = lvl; if (!plain_uv) @@ -742,8 +742,8 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) cddm = CDDM_from_mesh(me, NULL); pmap = cddm->getPolyMap(ob, cddm); - origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco"); - for (i = 0; i < me->totvert ;++i) + origco = MEM_callocN(sizeof(float) * 3 * me->totvert, "multires apply base origco"); + for (i = 0; i < me->totvert; ++i) copy_v3_v3(origco[i], me->mvert[i].co); for (i = 0; i < me->totvert; ++i) { @@ -833,7 +833,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl { Mesh *me = ob->data; MDisps *mdisps; - int lvl= mmd->totlvl; + int lvl = mmd->totlvl; if ((totlvl > multires_max_levels) || (me->totpoly == 0)) return; @@ -867,12 +867,12 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl lowGridSize = lowdm->getGridSize(lowdm); lowGridData = lowdm->getGridData(lowdm); - subGridData = MEM_callocN(sizeof(float*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(float *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; ++i) { /* backup subsurf grids */ - subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData"); - memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize); + subGridData[i] = MEM_callocN(sizeof(DMGridData) * highGridSize * highGridSize, "subGridData"); + memcpy(subGridData[i], highGridData[i], sizeof(DMGridData) * highGridSize * highGridSize); /* overwrite with current displaced grids */ multires_copy_dm_grid(highGridData[i], lowGridData[i], highGridSize, lowGridSize); @@ -882,7 +882,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl lowdm->release(lowdm); /* subsurf higher levels again with displaced data */ - ss= ((CCGDerivedMesh*)highdm)->ss; + ss = ((CCGDerivedMesh *)highdm)->ss; ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0); ccgSubSurf_updateLevels(ss, lvl, NULL, 0); @@ -908,7 +908,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { - multires_subdivide(mmd, ob, mmd->totlvl+1, updateblock, simple); + multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple); } void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3]) @@ -916,28 +916,28 @@ void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData ** if (axis == 0) { if (x == gridSize - 1) { if (y == gridSize - 1) - sub_v3_v3v3(t, gridData[index][x + gridSize*(y - 1)].co, gridData[index][x - 1 + gridSize*(y - 1)].co); + sub_v3_v3v3(t, gridData[index][x + gridSize * (y - 1)].co, gridData[index][x - 1 + gridSize * (y - 1)].co); else - sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x - 1 + gridSize*y].co); + sub_v3_v3v3(t, gridData[index][x + gridSize * y].co, gridData[index][x - 1 + gridSize * y].co); } else - sub_v3_v3v3(t, gridData[index][x + 1 + gridSize*y].co, gridData[index][x + gridSize*y].co); + sub_v3_v3v3(t, gridData[index][x + 1 + gridSize * y].co, gridData[index][x + gridSize * y].co); } else if (axis == 1) { if (y == gridSize - 1) { if (x == gridSize - 1) - sub_v3_v3v3(t, gridData[index][x - 1 + gridSize*y].co, gridData[index][x - 1 + gridSize*(y - 1)].co); + sub_v3_v3v3(t, gridData[index][x - 1 + gridSize * y].co, gridData[index][x - 1 + gridSize * (y - 1)].co); else - sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x + gridSize*(y - 1)].co); + sub_v3_v3v3(t, gridData[index][x + gridSize * y].co, gridData[index][x + gridSize * (y - 1)].co); } else - sub_v3_v3v3(t, gridData[index][x + gridSize*(y + 1)].co, gridData[index][x + gridSize*y].co); + sub_v3_v3v3(t, gridData[index][x + gridSize * (y + 1)].co, gridData[index][x + gridSize * y].co); } } static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; DMGridData **gridData, **subGridData; MPoly *mpoly = me->mpoly; MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); @@ -968,10 +968,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm gridSize = dm->getGridSize(dm); gridData = dm->getGridData(dm); gridOffset = dm->getGridOffset(dm); - subGridData = (oldGridData)? oldGridData: gridData; + subGridData = (oldGridData) ? oldGridData : gridData; dGridSize = multires_side_tot[totlvl]; - dSkip = (dGridSize-1)/(gridSize-1); + dSkip = (dGridSize - 1) / (gridSize - 1); k = 0; /*current loop/mdisp index within the mloop array*/ @@ -982,7 +982,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm int S, x, y, gIndex = gridOffset[i]; for (S = 0; S < numVerts; ++S, ++gIndex, ++k) { - MDisps *mdisp = &mdisps[mpoly[i].loopstart+S]; + MDisps *mdisp = &mdisps[mpoly[i].loopstart + S]; DMGridData *grid = gridData[gIndex]; DMGridData *subgrid = subGridData[gIndex]; float (*dispgrid)[3] = NULL; @@ -998,10 +998,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *co = grid[x + y*gridSize].co; - float *sco = subgrid[x + y*gridSize].co; - float *no = subgrid[x + y*gridSize].no; - float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; + float *co = grid[x + y * gridSize].co; + float *sco = subgrid[x + y * gridSize].co; + float *no = subgrid[x + y * gridSize].no; + float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; float mat[3][3], tx[3], ty[3], disp[3], d[3]; /* construct tangent space matrix */ @@ -1018,26 +1018,26 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm column_vectors_to_mat3(mat, tx, ty, no); switch (op) { - case APPLY_DISPLACEMENTS: - /* Convert displacement to object space - * and add to grid points */ - mul_v3_m3v3(disp, mat, data); - add_v3_v3v3(co, sco, disp); - break; - case CALC_DISPLACEMENTS: - /* Calculate displacement between new and old - * grid points and convert to tangent space */ - sub_v3_v3v3(disp, co, sco); - invert_m3(mat); - mul_v3_m3v3(data, mat, disp); - break; - case ADD_DISPLACEMENTS: - /* Convert subdivided displacements to tangent - * space and add to the original displacements */ - invert_m3(mat); - mul_v3_m3v3(d, mat, co); - add_v3_v3(data, d); - break; + case APPLY_DISPLACEMENTS: + /* Convert displacement to object space + * and add to grid points */ + mul_v3_m3v3(disp, mat, data); + add_v3_v3v3(co, sco, disp); + break; + case CALC_DISPLACEMENTS: + /* Calculate displacement between new and old + * grid points and convert to tangent space */ + sub_v3_v3v3(disp, co, sco); + invert_m3(mat); + mul_v3_m3v3(data, mat, disp); + break; + case ADD_DISPLACEMENTS: + /* Convert subdivided displacements to tangent + * space and add to the original displacements */ + invert_m3(mat); + mul_v3_m3v3(d, mat, co); + add_v3_v3(data, d); + break; } } } @@ -1052,7 +1052,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm void multires_modifier_update_mdisps(struct DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; Object *ob; Mesh *me; MDisps *mdisps; @@ -1095,16 +1095,16 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) lowGridData = lowdm->getGridData(lowdm); gridData = dm->getGridData(dm); - subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*"); - diffGrid = MEM_callocN(sizeof(DMGridData)*lowGridSize*lowGridSize, "diff"); + subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*"); + diffGrid = MEM_callocN(sizeof(DMGridData) * lowGridSize * lowGridSize, "diff"); for (i = 0; i < numGrids; ++i) { /* backup subsurf grids */ - subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData"); - memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize); + subGridData[i] = MEM_callocN(sizeof(DMGridData) * highGridSize * highGridSize, "subGridData"); + memcpy(subGridData[i], highGridData[i], sizeof(DMGridData) * highGridSize * highGridSize); /* write difference of subsurf and displaced low level into high subsurf */ - for (j = 0; j < lowGridSize*lowGridSize; ++j) + for (j = 0; j < lowGridSize * lowGridSize; ++j) sub_v3_v3v3(diffGrid[j].co, gridData[i][j].co, lowGridData[i][j].co); multires_copy_dm_grid(highGridData[i], diffGrid, highGridSize, lowGridSize); @@ -1115,7 +1115,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) lowdm->release(lowdm); /* subsurf higher levels again with difference of coordinates */ - ss= ((CCGDerivedMesh*)highdm)->ss; + ss = ((CCGDerivedMesh *)highdm)->ss; ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0); ccgSubSurf_updateLevels(ss, lvl, NULL, 0); @@ -1147,8 +1147,8 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) void multires_modifier_update_hidden(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - BLI_bitmap *grid_hidden= ccgdm->gridHidden; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + BLI_bitmap *grid_hidden = ccgdm->gridHidden; Mesh *me = ccgdm->multires.ob->data; MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); int totlvl = ccgdm->multires.totlvl; @@ -1167,7 +1167,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm) } else if (gh) { gh = multires_mdisps_upsample_hidden(gh, lvl, totlvl, - md->hidden); + md->hidden); if (md->hidden) MEM_freeN(md->hidden); @@ -1180,7 +1180,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm) void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) { DerivedMesh *ccgdm = NULL, *subsurf = NULL; - DMGridData **gridData, **subGridData=NULL; + DMGridData **gridData, **subGridData = NULL; MPoly *mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY); MDisps *mdisps; MultiresModifierData *mmd = get_multires_modifier(NULL, ob, 1); @@ -1200,26 +1200,26 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple); subsurf = subsurf_dm_create_local(ob, dm, totlvl, - mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv); + mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv); numGrids = subsurf->getNumGrids(subsurf); gridSize = subsurf->getGridSize(subsurf); gridData = subsurf->getGridData(subsurf); - subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; i++) { - subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData"); - memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); + subGridData[i] = MEM_callocN(sizeof(DMGridData) * gridSize * gridSize, "subGridData"); + memcpy(subGridData[i], gridData[i], sizeof(DMGridData) * gridSize * gridSize); } /*numGrids = ccgdm->dm->getNumGrids((DerivedMesh*)ccgdm);*/ /*UNUSED*/ - gridSize = ccgdm->getGridSize((DerivedMesh*)ccgdm); - gridData = ccgdm->getGridData((DerivedMesh*)ccgdm); - gridOffset = ccgdm->getGridOffset((DerivedMesh*)ccgdm); + gridSize = ccgdm->getGridSize((DerivedMesh *)ccgdm); + gridData = ccgdm->getGridData((DerivedMesh *)ccgdm); + gridOffset = ccgdm->getGridOffset((DerivedMesh *)ccgdm); dGridSize = multires_side_tot[totlvl]; - dSkip = (dGridSize-1)/(gridSize-1); + dSkip = (dGridSize - 1) / (gridSize - 1); k = 0; /*current loop/mdisp index within the mloop array*/ @@ -1230,25 +1230,25 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) int S, x, y, gIndex = gridOffset[i]; for (S = 0; S < numVerts; ++S, ++gIndex, ++k) { - MDisps *mdisp = &mdisps[mpoly[i].loopstart+S]; + MDisps *mdisp = &mdisps[mpoly[i].loopstart + S]; /* DMGridData *grid = gridData[gIndex]; */ /* UNUSED */ DMGridData *subgrid = subGridData[gIndex]; float (*dispgrid)[3] = NULL; /* when adding new faces in edit mode, need to allocate disps */ if (!mdisp->disps) { - mdisp->totdisp = gridSize*gridSize; + mdisp->totdisp = gridSize * gridSize; mdisp->level = totlvl; - mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space"); + mdisp->disps = MEM_callocN(sizeof(float) * 3 * mdisp->totdisp, "disp in multires_set_space"); } dispgrid = mdisp->disps; for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; - float *no = subgrid[x + y*gridSize].no; - float *co = subgrid[x + y*gridSize].co; + float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; + float *no = subgrid[x + y * gridSize].no; + float *co = subgrid[x + y * gridSize].co; float mat[3][3], tx[3], ty[3], dco[3]; /* construct tangent space matrix */ @@ -1308,12 +1308,12 @@ void multires_stitch_grids(Object *ob) { /* utility for smooth brush */ if (ob && ob->derivedFinal) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)ob->derivedFinal; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)ob->derivedFinal; CCGFace **faces; int totface; if (ccgdm->pbvh) { - BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void***)&faces, &totface); + BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void ***)&faces, &totface); if (totface) { ccgSubSurf_stitchFaces(ccgdm->ss, 0, faces, totface); @@ -1324,25 +1324,25 @@ void multires_stitch_grids(Object *ob) } DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, - int local_mmd, DerivedMesh *dm, - Object *ob, int useRenderParams) + int local_mmd, DerivedMesh *dm, + Object *ob, int useRenderParams) { - Mesh *me= ob->data; + Mesh *me = ob->data; DerivedMesh *result; CCGDerivedMesh *ccgdm = NULL; DMGridData **gridData, **subGridData; - int lvl= multires_get_level(ob, mmd, useRenderParams); + int lvl = multires_get_level(ob, mmd, useRenderParams); int i, gridSize, numGrids; if (lvl == 0) return dm; result = subsurf_dm_create_local(ob, dm, lvl, - mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, - mmd->flags & eMultiresModifierFlag_PlainUv); + mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, + mmd->flags & eMultiresModifierFlag_PlainUv); if (!local_mmd) { - ccgdm = (CCGDerivedMesh*)result; + ccgdm = (CCGDerivedMesh *)result; ccgdm->multires.ob = ob; ccgdm->multires.mmd = mmd; @@ -1356,11 +1356,11 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, gridSize = result->getGridSize(result); gridData = result->getGridData(result); - subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(DMGridData *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; i++) { - subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData"); - memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); + subGridData[i] = MEM_callocN(sizeof(DMGridData) * gridSize * gridSize, "subGridData"); + memcpy(subGridData[i], gridData[i], sizeof(DMGridData) * gridSize * gridSize); } multires_set_tot_mdisps(me, mmd->totlvl); @@ -1430,22 +1430,22 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, int y, float *u, float *v) { - float offset = oldside*0.5f - 0.5f; + float offset = oldside * 0.5f - 0.5f; - if (S == 1) { *u= offset + x; *v = offset - y; } - if (S == 2) { *u= offset + y; *v = offset + x; } - if (S == 3) { *u= offset - x; *v = offset + y; } - if (S == 0) { *u= offset - y; *v = offset - x; } + if (S == 1) { *u = offset + x; *v = offset - y; } + if (S == 2) { *u = offset + y; *v = offset + x; } + if (S == 3) { *u = offset - x; *v = offset + y; } + if (S == 0) { *u = offset - y; *v = offset - x; } } static void old_mdisps_convert(MFace *mface, MDisps *mdisp) { - int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2; - int oldlvl = newlvl+1; + int newlvl = log(sqrt(mdisp->totdisp) - 1) / M_LN2; + int oldlvl = newlvl + 1; int oldside = multires_side_tot[oldlvl]; int newside = multires_side_tot[newlvl]; - int nvert = (mface->v4)? 4: 3; - int newtotdisp = multires_grid_tot[newlvl]*nvert; + int nvert = (mface->v4) ? 4 : 3; + int newtotdisp = multires_grid_tot[newlvl] * nvert; int x, y, S; float (*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */ @@ -1458,19 +1458,19 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp) old_mdisps_rotate(S, newside, oldside, x, y, &u, &v); old_mdisps_bilinear(*out, mdisp->disps, oldside, u, v); - if (S == 1) { (*out)[1]= -(*out)[1]; } + if (S == 1) { (*out)[1] = -(*out)[1]; } else if (S == 2) { SWAP(float, (*out)[0], (*out)[1]); } - else if (S == 3) { (*out)[0]= -(*out)[0]; } - else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0]= -(*out)[0]; (*out)[1]= -(*out)[1]; }; + else if (S == 3) { (*out)[0] = -(*out)[0]; } + else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0] = -(*out)[0]; (*out)[1] = -(*out)[1]; }; } } } MEM_freeN(mdisp->disps); - mdisp->totdisp= newtotdisp; - mdisp->level= newlvl; - mdisp->disps= disps; + mdisp->totdisp = newtotdisp; + mdisp->level = newlvl; + mdisp->disps = disps; } void multires_load_old_250(Mesh *me) @@ -1479,10 +1479,10 @@ void multires_load_old_250(Mesh *me) MFace *mf; int i, j, k; - mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); if (mdisps) { - for (i=0; itotface; i++) + for (i = 0; i < me->totface; i++) if (mdisps[i].totdisp) old_mdisps_convert(&me->mface[i], &mdisps[i]); @@ -1491,15 +1491,15 @@ void multires_load_old_250(Mesh *me) k = 0; mf = me->mface; - for (i=0; itotface; i++, mf++) { + for (i = 0; i < me->totface; i++, mf++) { int nvert = mf->v4 ? 4 : 3; int totdisp = mdisps[i].totdisp / nvert; - for (j=0; j < mf->v4 ? 4 : 3; j++, k++) { - mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion"); + for (j = 0; j < mf->v4 ? 4 : 3; j++, k++) { + mdisps2[k].disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disp in conversion"); mdisps2[k].totdisp = totdisp; mdisps2[k].level = mdisps[i].level; - memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp); + memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp); } } @@ -1519,7 +1519,7 @@ static void multires_free_level(MultiresLevel *lvl) void multires_free(Multires *mr) { if (mr) { - MultiresLevel* lvl= mr->levels.first; + MultiresLevel *lvl = mr->levels.first; /* Free the first-level data */ if (lvl) { @@ -1533,7 +1533,7 @@ void multires_free(Multires *mr) while (lvl) { multires_free_level(lvl); - lvl= lvl->next; + lvl = lvl->next; } MEM_freeN(mr->verts); @@ -1551,12 +1551,12 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult IndexNode *node = NULL; (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert face map"); - (*mem) = MEM_callocN(sizeof(IndexNode) * totface*4, "vert face map mem"); + (*mem) = MEM_callocN(sizeof(IndexNode) * totface * 4, "vert face map mem"); node = *mem; /* Find the users */ for (i = 0; i < totface; ++i) { - for (j = 0; j < (mface[i].v[3]?4:3); ++j, ++node) { + for (j = 0; j < (mface[i].v[3] ? 4 : 3); ++j, ++node) { node->index = i; BLI_addtail(&(*map)[mface[i].v[j]], node); } @@ -1564,13 +1564,13 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult } static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const MultiresEdge *medge, - const int totvert, const int totedge) + const int totvert, const int totedge) { int i, j; IndexNode *node = NULL; (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map"); - (*mem) = MEM_callocN(sizeof(IndexNode) * totedge*2, "vert edge map mem"); + (*mem) = MEM_callocN(sizeof(IndexNode) * totedge * 2, "vert edge map mem"); node = *mem; /* Find the users */ @@ -1587,10 +1587,10 @@ static MultiresFace *find_old_face(ListBase *map, MultiresFace *faces, int v1, i IndexNode *n1; int v[4], i, j; - v[0]= v1; - v[1]= v2; - v[2]= v3; - v[3]= v4; + v[0] = v1; + v[1] = v2; + v[2] = v3; + v[3] = v4; for (n1 = map[v1].first; n1; n1 = n1->next) { int fnd[4] = {0, 0, 0, 0}; @@ -1635,7 +1635,7 @@ static void multires_load_old_edges(ListBase **emap, MultiresLevel *lvl, int *vv } static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLevel *lvl, int *vvmap, int dst, - int v1, int v2, int v3, int v4, int st2, int st3) + int v1, int v2, int v3, int v4, int st2, int st3) { int fmid; int emid13, emid14, emid23, emid24; @@ -1651,16 +1651,16 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst + st2 * st3 + st3, - fmid, v2, emid23, emid24, st2, st3 / 2); + fmid, v2, emid23, emid24, st2, st3 / 2); multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 + st3, - emid14, emid24, fmid, v4, st2, st3 / 2); + emid14, emid24, fmid, v4, st2, st3 / 2); multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst + st2 * st3 - st3, - emid13, emid23, v3, fmid, st2, st3 / 2); + emid13, emid23, v3, fmid, st2, st3 / 2); multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 - st3, - v1, fmid, emid13, emid14, st2, st3 / 2); + v1, fmid, emid13, emid14, st2, st3 / 2); if (lvl->next->next) { multires_load_old_edges(emap, lvl->next, vvmap, dst, emid24, fmid, st3); @@ -1673,7 +1673,7 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; DMGridData *vd; int index; @@ -1687,13 +1687,13 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) CCGFace *f = ccgdm->faceMap[index].face; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - vd= ccgSubSurf_getFaceCenterData(f); + vd = ccgSubSurf_getFaceCenterData(f); copy_v3_v3(vd->co, mvert[i].co); i++; for (S = 0; S < numVerts; S++) { for (x = 1; x < gridSize - 1; x++, i++) { - vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x); + vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x); copy_v3_v3(vd->co, mvert[i].co); } } @@ -1701,7 +1701,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) for (S = 0; S < numVerts; S++) { for (y = 1; y < gridSize - 1; y++) { for (x = 1; x < gridSize - 1; x++, i++) { - vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y); + vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y); copy_v3_v3(vd->co, mvert[i].co); } } @@ -1714,7 +1714,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) int x; for (x = 1; x < edgeSize - 1; x++, i++) { - vd= ccgSubSurf_getEdgeData(ss, e, x); + vd = ccgSubSurf_getEdgeData(ss, e, x); copy_v3_v3(vd->co, mvert[i].co); } } @@ -1723,7 +1723,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) for (index = 0; index < totvert; index++) { CCGVert *v = ccgdm->vertMap[index].vert; - vd= ccgSubSurf_getVertData(ss, v); + vd = ccgSubSurf_getVertData(ss, v); copy_v3_v3(vd->co, mvert[i].co); i++; } @@ -1735,7 +1735,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) { MultiresLevel *lvl, *lvl1; - Multires *mr= me->mr; + Multires *mr = me->mr; MVert *vsrc, *vdst; unsigned int src, dst; int st = multires_side_tot[totlvl - 1] - 1; @@ -1834,10 +1834,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) } /* calculate vert to edge/face maps for each level (except the last) */ - fmap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires fmap"); - emap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires emap"); - fmem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires fmem"); - emem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires emem"); + fmap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires fmap"); + emap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires emap"); + fmem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires fmem"); + emem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires emem"); lvl = lvl1; for (i = 0; i < (unsigned int)mr->level_count - 1; ++i) { create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface); @@ -1862,10 +1862,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) int pv = lvl1->faces[j].v[s == 0 ? sides - 1 : s - 1]; multires_load_old_faces(fmap, emap, lvl1->next, vvmap, mid, - vvmap[dst], cv, - find_old_edge(emap[0], lvl1->edges, pv, cv)->mid, - find_old_edge(emap[0], lvl1->edges, cv, nv)->mid, - st2, st4); + vvmap[dst], cv, + find_old_edge(emap[0], lvl1->edges, pv, cv)->mid, + find_old_edge(emap[0], lvl1->edges, cv, nv)->mid, + st2, st4); ldst += (st - 1) * (st - 1); } @@ -1920,10 +1920,10 @@ static void multires_load_old_vcols(Mesh *me) for (i = 0; i < me->totface; ++i) { for (j = 0; j < 4; ++j) { - mcol[i*4 + j].a = colface[i].col[j].a; - mcol[i*4 + j].r = colface[i].col[j].r; - mcol[i*4 + j].g = colface[i].col[j].g; - mcol[i*4 + j].b = colface[i].col[j].b; + mcol[i * 4 + j].a = colface[i].col[j].a; + mcol[i * 4 + j].r = colface[i].col[j].r; + mcol[i * 4 + j].g = colface[i].col[j].g; + mcol[i * 4 + j].b = colface[i].col[j].b; } } } @@ -1982,7 +1982,7 @@ void multires_load_old(Object *ob, Mesh *me) md = ob->modifiers.first; while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) md = md->next; - mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires); + mmd = (MultiresModifierData *)modifier_new(eModifierType_Multires); BLI_insertlinkbefore(&ob->modifiers, md, mmd); for (i = 0; i < me->mr->level_count - 1; ++i) @@ -1992,7 +1992,7 @@ void multires_load_old(Object *ob, Mesh *me) orig = CDDM_from_mesh(me, NULL); dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0); - multires_load_old_dm(dm, me, mmd->totlvl+1); + multires_load_old_dm(dm, me, mmd->totlvl + 1); multires_dm_mark_as_modified(dm, MULTIRES_COORDS_MODIFIED); dm->release(dm); @@ -2011,13 +2011,13 @@ void multires_load_old(Object *ob, Mesh *me) /* Remove the old multires */ multires_free(me->mr); - me->mr= NULL; + me->mr = NULL; } static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) { - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); - MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1); + MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); + MultiresModifierData *to_mmd = get_multires_modifier(scene, to_ob, 1); if (!mmd) { /* object could have MDISP even when there is no multires modifier @@ -2030,77 +2030,77 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) if (!mmd || !to_mmd) return; - if (mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); + if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); } static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) { - DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL; + DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL; DMGridData **gridData, **subGridData; - Mesh *me= (Mesh*)ob->data; - MPoly *mpoly= me->mpoly; + Mesh *me = (Mesh *)ob->data; + MPoly *mpoly = me->mpoly; /* MLoop *mloop = me->mloop; */ /* UNUSED */ MDisps *mdisps; int *gridOffset; int i, /*numGrids, */ gridSize, dGridSize, dSkip, totvert; float (*vertCos)[3] = NULL; - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); + MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); MultiresModifierData high_mmd; CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); - mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); if (!mdisps || !mmd || !mmd->totlvl) return; /* we need derived mesh created from highest resolution */ - high_mmd= *mmd; - high_mmd.lvl= high_mmd.totlvl; + high_mmd = *mmd; + high_mmd.lvl = high_mmd.totlvl; /* unscaled multires with applied displacement */ - subdm= get_multires_dm(scene, &high_mmd, ob); + subdm = get_multires_dm(scene, &high_mmd, ob); /* prepare scaled CDDM to create ccgDN */ - cddm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); + cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - totvert= cddm->getNumVerts(cddm); - vertCos= MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos"); + totvert = cddm->getNumVerts(cddm); + vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos"); cddm->getVertCos(cddm, vertCos); - for (i=0; iflags & eMultiresModifierFlag_PlainUv); + dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); cddm->release(cddm); /*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/ - gridSize= dm->getGridSize(dm); - gridData= dm->getGridData(dm); - gridOffset= dm->getGridOffset(dm); - subGridData= subdm->getGridData(subdm); + gridSize = dm->getGridSize(dm); + gridData = dm->getGridData(dm); + gridOffset = dm->getGridOffset(dm); + subGridData = subdm->getGridData(subdm); - dGridSize= multires_side_tot[high_mmd.totlvl]; - dSkip= (dGridSize-1)/(gridSize-1); + dGridSize = multires_side_tot[high_mmd.totlvl]; + dSkip = (dGridSize - 1) / (gridSize - 1); #pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT) for (i = 0; i < me->totpoly; ++i) { - const int numVerts= mpoly[i].totloop; - MDisps *mdisp= &mdisps[mpoly[i].loopstart]; + const int numVerts = mpoly[i].totloop; + MDisps *mdisp = &mdisps[mpoly[i].loopstart]; int S, x, y, gIndex = gridOffset[i]; for (S = 0; S < numVerts; ++S, ++gIndex, mdisp++) { - DMGridData *grid= gridData[gIndex]; - DMGridData *subgrid= subGridData[gIndex]; - float (*dispgrid)[3]= mdisp->disps; + DMGridData *grid = gridData[gIndex]; + DMGridData *subgrid = subGridData[gIndex]; + float (*dispgrid)[3] = mdisp->disps; for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *co= grid[x + y*gridSize].co; - float *sco= subgrid[x + y*gridSize].co; - float *no= grid[x + y*gridSize].no; - float *data= dispgrid[dGridSize*y*dSkip + x*dSkip]; + float *co = grid[x + y * gridSize].co; + float *sco = subgrid[x + y * gridSize].co; + float *no = grid[x + y * gridSize].no; + float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; float mat[3][3], tx[3], ty[3], disp[3]; /* construct tangent space matrix */ @@ -2130,11 +2130,11 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) int multires_mdisp_corners(MDisps *s) { - int lvl= 13; + int lvl = 13; while (lvl > 0) { - int side = (1 << (lvl-1)) + 1; - if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side); + int side = (1 << (lvl - 1)) + 1; + if ((s->totdisp % (side * side)) == 0) return s->totdisp / (side * side); lvl--; } @@ -2204,14 +2204,14 @@ void multires_topology_changed(Mesh *me) /* Find per-corner coordinate with given per-face UV coord */ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y) { - const float offset = face_side*0.5f - 0.5f; + const float offset = face_side * 0.5f - 0.5f; int S = 0; if (corners == 4) { if (u <= offset && v <= offset) S = 0; else if (u > offset && v <= offset) S = 1; else if (u > offset && v > offset) S = 2; - else if (u <= offset && v >= offset) S = 3; + else if (u <= offset && v >= offset) S = 3; if (S == 0) { *y = offset - u; @@ -2226,7 +2226,7 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, *x = v - offset; } else if (S == 3) { - *x= offset - u; + *x = offset - u; *y = v - offset; } } @@ -2235,15 +2235,15 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, float w = (face_side - 1) - u - v; float W1, W2; - if (u >= v && u >= w) {S = 0; W1= w; W2= v;} - else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w;} - else {S = 2; W1 = v; W2 = u;} + if (u >= v && u >= w) {S = 0; W1 = w; W2 = v; } + else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w; } + else {S = 2; W1 = v; W2 = u; } - W1 /= (face_side-1); - W2 /= (face_side-1); + W1 /= (face_side - 1); + W2 /= (face_side - 1); - *x = (1-(2*W1)/(1-W2)) * grid_size; - *y = (1-(2*W2)/(1-W1)) * grid_size; + *x = (1 - (2 * W1) / (1 - W2)) * grid_size; + *y = (1 - (2 * W2) / (1 - W1)) * grid_size; } return S; diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 3b5b4b766fb..a2c89967f44 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -73,17 +73,17 @@ int seekPackedFile(PackedFile *pf, int offset, int whence) if (pf) { oldseek = pf->seek; switch (whence) { - case SEEK_CUR: - seek = oldseek + offset; - break; - case SEEK_END: - seek = pf->size + offset; - break; - case SEEK_SET: - seek = offset; - break; - default: - oldseek = -1; + case SEEK_CUR: + seek = oldseek + offset; + break; + case SEEK_END: + seek = pf->size + offset; + break; + case SEEK_SET: + seek = offset; + break; + default: + oldseek = -1; } if (seek < 0) { seek = 0; @@ -133,15 +133,15 @@ int countPackedFiles(Main *bmain) int count = 0; // let's check if there are packed files... - for (ima=bmain->image.first; ima; ima=ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) count++; - for (vf=bmain->vfont.first; vf; vf=vf->id.next) + for (vf = bmain->vfont.first; vf; vf = vf->id.next) if (vf->packedfile) count++; - for (sound=bmain->sound.first; sound; sound=sound->id.next) + for (sound = bmain->sound.first; sound; sound = sound->id.next) if (sound->packedfile) count++; @@ -176,7 +176,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char /* render result has no filename and can be ignored * any other files with no name can be ignored too */ - if (filename[0]=='\0') + if (filename[0] == '\0') return NULL; //XXX waitcursor(1); @@ -189,7 +189,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char // open the file // and create a PackedFile structure - file= BLI_open(name, O_BINARY|O_RDONLY, 0); + file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file <= 0) { BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); } @@ -222,23 +222,23 @@ void packAll(Main *bmain, ReportList *reports) VFont *vf; bSound *sound; - for (ima=bmain->image.first; ima; ima=ima->id.next) { - if (ima->packedfile == NULL && ima->id.lib==NULL) { - if (ima->source==IMA_SRC_FILE) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { + if (ima->packedfile == NULL && ima->id.lib == NULL) { + if (ima->source == IMA_SRC_FILE) { ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id)); } else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { - BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2); + BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name + 2); } } } - for (vf=bmain->vfont.first; vf; vf=vf->id.next) - if (vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) + for (vf = bmain->vfont.first; vf; vf = vf->id.next) + if (vf->packedfile == NULL && vf->id.lib == NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) vf->packedfile = newPackedFile(reports, vf->name, bmain->name); - for (sound=bmain->sound.first; sound; sound=sound->id.next) - if (sound->packedfile == NULL && sound->id.lib==NULL) + for (sound = bmain->sound.first; sound; sound = sound->id.next) + if (sound->packedfile == NULL && sound->id.lib == NULL) sound->packedfile = newPackedFile(reports, sound->name, bmain->name); } @@ -257,12 +257,12 @@ static char *find_new_name(char *name) if (fop_exists(name)) { for (number = 1; number <= 999; number++) { BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number); - if (! fop_exists(tempname)) { + if (!fop_exists(tempname)) { break; } } } - len= strlen(tempname) + 1; + len = strlen(tempname) + 1; newname = MEM_mallocN(len, "find_new_name"); memcpy(newname, tempname, len * sizeof(char)); return newname; @@ -275,7 +275,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i int ret_value = RET_OK; char name[FILE_MAX]; char tempname[FILE_MAX]; -/* void *data; */ +/* void *data; */ if (guimode) {} //XXX waitcursor(1); @@ -285,7 +285,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i if (BLI_exists(name)) { for (number = 1; number <= 999; number++) { BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number); - if (! BLI_exists(tempname)) { + if (!BLI_exists(tempname)) { if (BLI_copy(name, tempname) == RET_OK) { remove_tmp = TRUE; } @@ -409,7 +409,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na case PF_KEEP: break; case PF_REMOVE: - temp= abs_name; + temp = abs_name; break; case PF_USE_LOCAL: // if file exists use it @@ -417,7 +417,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = local_name; break; } - // else fall through and create it + // else fall through and create it case PF_WRITE_LOCAL: if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { temp = local_name; @@ -429,7 +429,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = abs_name; break; } - // else fall through and create it + // else fall through and create it case PF_WRITE_ORIGINAL: if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { temp = abs_name; @@ -441,7 +441,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na } if (temp) { - newname= BLI_strdup(temp); + newname = BLI_strdup(temp); } } @@ -533,15 +533,15 @@ void unpackAll(Main *bmain, ReportList *reports, int how) VFont *vf; bSound *sound; - for (ima=bmain->image.first; ima; ima=ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) unpackImage(reports, ima, how); - for (vf=bmain->vfont.first; vf; vf=vf->id.next) + for (vf = bmain->vfont.first; vf; vf = vf->id.next) if (vf->packedfile) unpackVFont(reports, vf, how); - for (sound=bmain->sound.first; sound; sound=sound->id.next) + for (sound = bmain->sound.first; sound; sound = sound->id.next) if (sound->packedfile) unpackSound(bmain, reports, sound, how); } diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index e7247be7f51..b82521504dd 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -57,7 +57,7 @@ void free_properties(ListBase *lb) { bProperty *prop; - while ( (prop= lb->first) ) { + while ( (prop = lb->first) ) { BLI_remlink(lb, prop); free_property(prop); } @@ -67,11 +67,11 @@ bProperty *copy_property(bProperty *prop) { bProperty *propn; - propn= MEM_dupallocN(prop); + propn = MEM_dupallocN(prop); if (prop->poin && prop->poin != &prop->data) { - propn->poin= MEM_dupallocN(prop->poin); + propn->poin = MEM_dupallocN(prop->poin); } - else propn->poin= &propn->data; + else propn->poin = &propn->data; return propn; } @@ -80,11 +80,11 @@ void copy_properties(ListBase *lbn, ListBase *lbo) { bProperty *prop, *propn; free_properties(lbn); /* in case we are copying to an object with props */ - prop= lbo->first; + prop = lbo->first; while (prop) { - propn= copy_property(prop); + propn = copy_property(prop); BLI_addtail(lbn, propn); - prop= prop->next; + prop = prop->next; } @@ -95,20 +95,20 @@ void init_property(bProperty *prop) /* also use when property changes type */ if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin); - prop->poin= NULL; + prop->poin = NULL; - prop->data= 0; + prop->data = 0; switch (prop->type) { - case GPROP_BOOL: - case GPROP_INT: - case GPROP_FLOAT: - case GPROP_TIME: - prop->poin= &prop->data; - break; - case GPROP_STRING: - prop->poin= MEM_callocN(MAX_PROPSTRING, "property string"); - break; + case GPROP_BOOL: + case GPROP_INT: + case GPROP_FLOAT: + case GPROP_TIME: + prop->poin = &prop->data; + break; + case GPROP_STRING: + prop->poin = MEM_callocN(MAX_PROPSTRING, "property string"); + break; } } @@ -117,8 +117,8 @@ bProperty *new_property(int type) { bProperty *prop; - prop= MEM_callocN(sizeof(bProperty), "property"); - prop->type= type; + prop = MEM_callocN(sizeof(bProperty), "property"); + prop->type = type; init_property(prop); @@ -131,8 +131,8 @@ bProperty *new_property(int type) static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name) { bProperty *p; - for (p= first; p; p= p->next) { - if (p!=self && (strcmp(p->name, name)==0)) + for (p = first; p; p = p->next) { + if (p != self && (strcmp(p->name, name) == 0)) return p; } return NULL; @@ -142,10 +142,10 @@ void unique_property(bProperty *first, bProperty *prop, int force) bProperty *p; /* set the first if its not set */ - if (first==NULL) { - first= prop; + if (first == NULL) { + first = prop; while (first->prev) { - first= first->prev; + first = first->prev; } } @@ -162,14 +162,14 @@ void unique_property(bProperty *first, bProperty *prop, int force) char new_name[sizeof(prop->name)]; char base_name[sizeof(prop->name)]; char num[sizeof(prop->name)]; - int i= 0; + int i = 0; /* strip numbers */ BLI_strncpy(base_name, prop->name, sizeof(base_name)); - for (i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) { - base_name[i]= '\0'; + for (i = strlen(base_name) - 1; (i >= 0 && isdigit(base_name[i])); i--) { + base_name[i] = '\0'; } - i= 0; + i = 0; do { /* ensure we have enough chars for the new number in the name */ BLI_snprintf(num, sizeof(num), "%d", i++); @@ -190,7 +190,7 @@ bProperty *get_ob_property(Object *ob, const char *name) void set_ob_property(Object *ob, bProperty *propc) { bProperty *prop; - prop= get_ob_property(ob, propc->name); + prop = get_ob_property(ob, propc->name); if (prop) { free_property(prop); BLI_remlink(&ob->prop, prop); @@ -207,32 +207,32 @@ int compare_property(bProperty *prop, const char *str) float fvalue, ftest; switch (prop->type) { - case GPROP_BOOL: - if (BLI_strcasecmp(str, "true")==0) { - if (prop->data==1) return 0; - else return 1; - } - else if (BLI_strcasecmp(str, "false")==0) { - if (prop->data==0) return 0; - else return 1; - } + case GPROP_BOOL: + if (BLI_strcasecmp(str, "true") == 0) { + if (prop->data == 1) return 0; + else return 1; + } + else if (BLI_strcasecmp(str, "false") == 0) { + if (prop->data == 0) return 0; + else return 1; + } /* no break, do GPROP_int too! */ - case GPROP_INT: - return prop->data - atoi(str); + case GPROP_INT: + return prop->data - atoi(str); - case GPROP_FLOAT: - case GPROP_TIME: - // WARNING: untested for GPROP_TIME - // function isn't used currently - fvalue= *((float *)&prop->data); - ftest= (float)atof(str); - if ( fvalue > ftest) return 1; - else if ( fvalue < ftest) return -1; - return 0; + case GPROP_FLOAT: + case GPROP_TIME: + // WARNING: untested for GPROP_TIME + // function isn't used currently + fvalue = *((float *)&prop->data); + ftest = (float)atof(str); + if (fvalue > ftest) return 1; + else if (fvalue < ftest) return -1; + return 0; - case GPROP_STRING: - return strcmp(prop->poin, str); + case GPROP_STRING: + return strcmp(prop->poin, str); } return 0; @@ -243,21 +243,21 @@ void set_property(bProperty *prop, const char *str) // extern int Gdfra; /* sector.c */ switch (prop->type) { - case GPROP_BOOL: - if (BLI_strcasecmp(str, "true")==0) prop->data= 1; - else if (BLI_strcasecmp(str, "false")==0) prop->data= 0; - else prop->data= (atoi(str)!=0); - break; - case GPROP_INT: - prop->data= atoi(str); - break; - case GPROP_FLOAT: - case GPROP_TIME: - *((float *)&prop->data)= (float)atof(str); - break; - case GPROP_STRING: - strcpy(prop->poin, str); /* TODO - check size? */ - break; + case GPROP_BOOL: + if (BLI_strcasecmp(str, "true") == 0) prop->data = 1; + else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0; + else prop->data = (atoi(str) != 0); + break; + case GPROP_INT: + prop->data = atoi(str); + break; + case GPROP_FLOAT: + case GPROP_TIME: + *((float *)&prop->data) = (float)atof(str); + break; + case GPROP_STRING: + strcpy(prop->poin, str); /* TODO - check size? */ + break; } } @@ -267,17 +267,17 @@ void add_property(bProperty *prop, const char *str) // extern int Gdfra; /* sector.c */ switch (prop->type) { - case GPROP_BOOL: - case GPROP_INT: - prop->data+= atoi(str); - break; - case GPROP_FLOAT: - case GPROP_TIME: - *((float *)&prop->data)+= (float)atof(str); - break; - case GPROP_STRING: - /* strcpy(prop->poin, str); */ - break; + case GPROP_BOOL: + case GPROP_INT: + prop->data += atoi(str); + break; + case GPROP_FLOAT: + case GPROP_TIME: + *((float *)&prop->data) += (float)atof(str); + break; + case GPROP_STRING: + /* strcpy(prop->poin, str); */ + break; } } @@ -289,17 +289,17 @@ void set_property_valstr(bProperty *prop, char *str) if (str == NULL) return; switch (prop->type) { - case GPROP_BOOL: - case GPROP_INT: - sprintf(str, "%d", prop->data); - break; - case GPROP_FLOAT: - case GPROP_TIME: - sprintf(str, "%f", *((float *)&prop->data)); - break; - case GPROP_STRING: - BLI_strncpy(str, prop->poin, MAX_PROPSTRING); - break; + case GPROP_BOOL: + case GPROP_INT: + sprintf(str, "%d", prop->data); + break; + case GPROP_FLOAT: + case GPROP_TIME: + sprintf(str, "%f", *((float *)&prop->data)); + break; + case GPROP_STRING: + BLI_strncpy(str, prop->poin, MAX_PROPSTRING); + break; } } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 98f5f45f525..2c868ca2601 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1492,7 +1492,7 @@ void BKE_free_pointdensity(PointDensity *pd) /* ------------------------------------------------------------------------- */ -void BKE_free_voxeldatadata(struct VoxelData *vd) +void BKE_free_voxeldatadata(VoxelData *vd) { if (vd->dataset) { MEM_freeN(vd->dataset); @@ -1501,17 +1501,17 @@ void BKE_free_voxeldatadata(struct VoxelData *vd) } -void BKE_free_voxeldata(struct VoxelData *vd) +void BKE_free_voxeldata(VoxelData *vd) { BKE_free_voxeldatadata(vd); MEM_freeN(vd); } -struct VoxelData *BKE_add_voxeldata(void) +VoxelData *BKE_add_voxeldata(void) { VoxelData *vd; - vd = MEM_callocN(sizeof(struct VoxelData), "voxeldata"); + vd = MEM_callocN(sizeof(VoxelData), "voxeldata"); vd->dataset = NULL; vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; vd->interp_type = TEX_VD_LINEAR; @@ -1525,7 +1525,7 @@ struct VoxelData *BKE_add_voxeldata(void) return vd; } -struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) +VoxelData *BKE_copy_voxeldata(VoxelData *vd) { VoxelData *vdn; @@ -1537,7 +1537,7 @@ struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) /* ------------------------------------------------------------------------- */ -struct OceanTex *BKE_add_oceantex(void) +OceanTex *BKE_add_oceantex(void) { OceanTex *ot; @@ -1548,7 +1548,7 @@ struct OceanTex *BKE_add_oceantex(void) return ot; } -struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot) +OceanTex *BKE_copy_oceantex(struct OceanTex *ot) { OceanTex *otn = MEM_dupallocN(ot); From 3d9d26d6bf6058e0f6af4bdf7305a01b3da702c2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 18:04:37 +0000 Subject: [PATCH 113/143] fix [#31197] Limited dissolve leaves faces/edges/verts behind bad bug where vertices could be in a face more then once (which isn't allowed), now check for this when creating a face. --- source/blender/bmesh/intern/bmesh_construct.c | 13 +++++++++++++ source/blender/bmesh/intern/bmesh_private.h | 1 + 2 files changed, 14 insertions(+) diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 0169caa8f61..684237b79c5 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -214,6 +214,9 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i BLI_array_append(verts, v); BLI_array_append(edges2, e); + /* we only flag the verts to check if they are in the face more then once */ + BM_ELEM_API_FLAG_ENABLE(v, _FLAG_MV); + do { e2 = bmesh_disk_edge_next(e2, v); if (e2 != e && BM_ELEM_API_FLAG_TEST(e2, _FLAG_MF)) { @@ -269,6 +272,12 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i if (!edges2[i]) { goto err; } + + /* check if vert is in face more then once. if the flag is disabled. we've already visited */ + if (!BM_ELEM_API_FLAG_TEST(verts[i], _FLAG_MV)) { + goto err; + } + BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); } f = BM_face_create(bm, verts, edges2, len, nodouble); @@ -286,6 +295,10 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i err: for (i = 0; i < len; i++) { BM_ELEM_API_FLAG_DISABLE(edges[i], _FLAG_MF); + /* vert count may != len */ + if (i < BLI_array_count(verts)) { + BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); + } } BLI_array_free(verts); diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index 23d0a1e3906..0827901f5c2 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -60,6 +60,7 @@ int bmesh_disk_count(BMVert *v); * on using these internal flags!*/ #define _FLAG_JF 1 /* join faces */ #define _FLAG_MF 2 /* make face */ +#define _FLAG_MV 2 /* make face, vertex */ #define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->oflags[0].pflag |= (f)) #define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f)) From 32ba51c4a1a4c4a67eee3658b959f9569b7e6f56 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 18:37:08 +0000 Subject: [PATCH 114/143] fix for limited dissolve (after sine intended fixes - not cleaning up before vertex dissolve would skip dissolving some verts that should be dissolved). now do this: - edge dissolve - cleanup (removing edges left over from dissolving faces) cleanup removes verts and NULL vertex input array - dissolve verts which haven't been removed. --- source/blender/bmesh/operators/bmo_dissolve.c | 97 ++++++++++++------- 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index ae1773af05e..1451625d3bb 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -34,14 +34,14 @@ #include "intern/bmesh_operators_private.h" /* own include */ -#define FACE_MARK 1 -#define FACE_ORIG 2 -#define FACE_NEW 4 -#define EDGE_MARK 1 +#define FACE_MARK 1 +#define FACE_ORIG 2 +#define FACE_NEW 4 +#define EDGE_MARK 1 -#define VERT_MARK 1 +#define VERT_MARK 1 -static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) +static int UNUSED_FUNCTION(check_hole_in_region) (BMesh * bm, BMFace * f) { BMWalker regwalker; BMIter liter2; @@ -60,8 +60,8 @@ static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) l2 = BM_iter_new(&liter2, bm, BM_LOOPS_OF_FACE, f2); for ( ; l2; l2 = BM_iter_step(&liter2)) { l3 = l2->radial_next; - if ( BMO_elem_flag_test(bm, l3->f, FACE_MARK) != - BMO_elem_flag_test(bm, l2->f, FACE_MARK)) + if (BMO_elem_flag_test(bm, l3->f, FACE_MARK) != + BMO_elem_flag_test(bm, l2->f, FACE_MARK)) { if (!BMO_elem_flag_test(bm, l2->e, EDGE_MARK)) { return FALSE; @@ -433,8 +433,8 @@ void dummy_exec(BMesh *bm, BMOperator *op) fe = l->e; for ( ; l; l = BM_iter_step(&liter)) { f2 = BM_iter_new(&fiter, bm, - BM_FACES_OF_EDGE, l->e); - for ( ; f2; f2 = BM_iter_step(&fiter)) { + BM_FACES_OF_EDGE, l->e); + for (; f2; f2 = BM_iter_step(&fiter)) { if (f2 != f) { BM_faces_join_pair(bm, f, f2, l->e); found2 = 1; @@ -520,23 +520,28 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) const float angle_max = (float)M_PI / 2.0f; const float angle_limit = minf(angle_max, BMO_slot_float_get(op, "angle_limit")); DissolveElemWeight *weight_elems = MEM_mallocN(MAX2(einput->len, vinput->len) * - sizeof(DissolveElemWeight), __func__); + sizeof(DissolveElemWeight), __func__); int i, tot_found; BMIter iter; BMEdge *e_iter; BMEdge **earray; + int *vert_reverse_lookup; + + BMEdge **einput_arr = (BMEdge **)einput->data.p; + BMVert **vinput_arr = (BMVert **)vinput->data.p; + /* --- first edges --- */ /* wire -> tag */ - BM_ITER_MESH(e_iter, &iter, bm, BM_EDGES_OF_MESH) { + 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]; + BMEdge *e = einput_arr[i]; const float angle = BM_edge_calc_face_angle(e); if (angle < angle_limit) { @@ -573,10 +578,51 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) } } + /* prepare for cleanup */ + BM_mesh_elem_index_ensure(bm, BM_VERT); + vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__); + fill_vn_i(vert_reverse_lookup, bm->totvert, -1); + for (i = 0, tot_found = 0; i < vinput->len; i++) { + BMVert *v = vinput_arr[i]; + vert_reverse_lookup[BM_elem_index_get(v)] = i; + } + + /* --- 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, NULL'ing the vertex array so we dont re-use */ + 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 */ + int vidx_reverse; + BMVert *v1 = e_iter->v1; + BMVert *v2 = e_iter->v2; + BM_edge_kill(bm, e_iter); + if (v1->e == NULL) { + vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)]; + if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + BM_vert_kill(bm, v1); + } + if (v2->e == NULL) { + vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)]; + if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + BM_vert_kill(bm, v2); + } + } + } + MEM_freeN(vert_reverse_lookup); + + MEM_freeN(earray); + + /* --- second verts --- */ for (i = 0, tot_found = 0; i < vinput->len; i++) { - BMVert *v = ((BMVert **)vinput->data.p)[i]; - const float angle = bm_vert_edge_face_angle(v); + BMVert *v = vinput_arr[i]; + const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit; if (angle < angle_limit) { weight_elems[i].ele = (BMHeader *)v; @@ -609,25 +655,4 @@ 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); } From 2314b77ebacc97e05495480bc1f66460b07001cc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 6 May 2012 22:06:14 +0000 Subject: [PATCH 115/143] Fix float image loading crash in cycles after multithreading changes. --- intern/cycles/render/image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 3e6052338c0..856363491ca 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -344,7 +344,7 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl } if(is_float) { - string filename = path_filename(float_images[slot]->filename); + string filename = path_filename(float_images[slot - TEX_IMAGE_FLOAT_START]->filename); progress->set_status("Updating Images", "Loading " + filename); device_vector& tex_img = dscene->tex_float_image[slot - TEX_IMAGE_FLOAT_START]; From a8e8775cb8a5bd694611aa124f886b5c1a5dbdbe Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 6 May 2012 22:12:26 +0000 Subject: [PATCH 116/143] Code cleanup: make changes suggested by check_style for sculpt-related files. --- .../editors/sculpt_paint/paint_stroke.c | 14 ++++++--- .../editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 31 ++++++++++++------- .../editors/sculpt_paint/sculpt_undo.c | 10 ++++-- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index fe228839c47..9832bcf1528 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -188,7 +188,11 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev output[1] = event->y; if ((stroke->brush->flag & BRUSH_SMOOTH_STROKE) && - !ELEM4(stroke->brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK) && + !ELEM4(stroke->brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK) && !(stroke->brush->flag & BRUSH_ANCHORED) && !(stroke->brush->flag & BRUSH_RESTORE_MESH)) { @@ -279,7 +283,7 @@ PaintStroke *paint_stroke_new(bContext *C, void paint_stroke_data_free(struct wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static void stroke_done(struct bContext *C, struct wmOperator *op) @@ -323,13 +327,13 @@ struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf) { 0 } }; - static const char *name= "Paint Stroke Modal"; + static const char *name = "Paint Stroke Modal"; - struct wmKeyMap *keymap= WM_modalkeymap_get(keyconf, name); + 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); + keymap = WM_modalkeymap_add(keyconf, name, modal_items); /* items for modal map */ WM_modalkeymap_add_item( diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 03817eeb6c4..c01da3a816f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -239,7 +239,7 @@ static void do_shared_vertex_tesscol(Mesh *me) mface = me->mface; mcol = (char *)me->mcol; for (a = me->totface; a > 0; a--, mface++, mcol += 16) { - if ((use_face_sel == FALSE)|| (mface->flag & ME_FACE_SEL)) { + if ((use_face_sel == FALSE) || (mface->flag & ME_FACE_SEL)) { scol = scolmain + 4 * mface->v1; mcol[1] = scol[1]; mcol[2] = scol[2]; mcol[3] = scol[3]; scol = scolmain + 4 * mface->v2; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 921b52d89a3..3edda91e4e4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -108,7 +108,7 @@ float *ED_sculpt_get_last_stroke(struct Object *ob) int ED_sculpt_minmax(bContext *C, float *min, float *max) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (ob && ob->sculpt && ob->sculpt->last_stroke_valid) { copy_v3_v3(min, ob->sculpt->last_stroke); @@ -1239,6 +1239,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod float offset[3], area_normal[3]; float bstrength = ss->cache->bstrength; float flippedbstrength, crease_correction; + float brush_alpha; int n; calc_sculpt_normal(sd, ob, area_normal, nodes, totnode); @@ -1249,11 +1250,10 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_v3_fl(offset, bstrength); /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ - - 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; + crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; + brush_alpha = BKE_brush_alpha_get(scene, brush); + if (brush_alpha > 0.0f) + crease_correction /= brush_alpha * brush_alpha; /* we always want crease to pinch or blob to relax even when draw is negative */ flippedbstrength = (bstrength < 0) ? -crease_correction * bstrength : crease_correction * bstrength; @@ -1928,7 +1928,8 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3 static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) { - return !(brush->flag & BRUSH_PLANE_TRIM) || (dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared); + return (!(brush->flag & BRUSH_PLANE_TRIM) || + ((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared))); } static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip) @@ -2371,7 +2372,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) for (a = 0; a < me->totvert; a++, mvert++) copy_v3_v3(mvert->co, vertCos[a]); - BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, + me->mpoly, me->totloop, me->totpoly, + NULL, NULL, 0, NULL, NULL); } /* apply new coords on active key block */ @@ -2389,7 +2392,11 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) data.ss = ss; data.sd = sd; data.radius_squared = ss->cache->radius_squared; - data.original = ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_LAYER); + data.original = ELEM4(brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_LAYER); BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); /* Only act if some verts are inside the brush area */ @@ -3134,7 +3141,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, if (cache->first_time) { 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)); + 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 { @@ -3515,7 +3524,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str } /* update last stroke position */ - ob->sculpt->last_stroke_valid= 1; + 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); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index b021608a095..801bfabc748 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -76,7 +76,10 @@ static void update_cb(PBVHNode *node, void *rebuild) BLI_pbvh_node_fully_hidden_set(node, 0); } -static void sculpt_undo_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3]) +static void sculpt_undo_restore_deformed(const SculptSession *ss, + SculptUndoNode *unode, + int uindex, int oindex, + float coord[3]) { if (unode->orig_co) { swap_v3_v3(coord, unode->orig_co[uindex]); @@ -385,7 +388,10 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, case SCULPT_UNDO_COORDS: unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co"); unode->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no"); - undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * 3 + sizeof(short) * 3 + sizeof(int)) * allvert); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, + (sizeof(float) * 3 + + sizeof(short) * 3 + + sizeof(int)) * allvert); break; case SCULPT_UNDO_HIDDEN: if (maxgrid) From d7f214b58181189518f1a3db18b5a8d629c3834c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 6 May 2012 22:36:51 +0000 Subject: [PATCH 117/143] Fix mac build error after ghost cocoa changes. --- intern/ghost/intern/GHOST_SystemCocoa.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 77d9e39a752..d95f7727747 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1487,7 +1487,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) break; } - case NSMouseMoved: + case NSMouseMoved: + { GHOST_TGrabCursorMode grab_mode = window->getCursorGrabMode(); /* TODO: CHECK IF THIS IS A TABLET EVENT */ @@ -1572,7 +1573,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) } break; } - break; + } + break; case NSScrollWheel: { From d881f9225c8bd8ddcf7005a7fb1afcdf6c8c071e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 06:32:14 +0000 Subject: [PATCH 118/143] Style cleanup in readfile versioning files --- .../blenloader/intern/versioning_250.c | 1644 ++++++------ .../blenloader/intern/versioning_legacy.c | 2380 +++++++++-------- 2 files changed, 2067 insertions(+), 1957 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index ebbfbd32cb5..8a8705532cb 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -25,10 +25,10 @@ * */ -/** \file blender/blenloader/intern/readfile_250.c +/** \file blender/blenloader/intern/versioning_250.c * \ingroup blenloader */ - + #include "zlib.h" #ifndef WIN32 @@ -111,20 +111,20 @@ /* 2.50 patch */ static void area_add_header_region(ScrArea *sa, ListBase *lb) { - ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - + 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; + ar->regiontype = RGN_TYPE_HEADER; + if (sa->headertype == HEADERDOWN) + ar->alignment = RGN_ALIGN_BOTTOM; else - ar->alignment= RGN_ALIGN_TOP; - + 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.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); } @@ -133,23 +133,23 @@ 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->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.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; + 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) @@ -161,271 +161,271 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) /* first channels for ipo action nla... */ switch (sl->spacetype) { case SPACE_IPO: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + 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"); + 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->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"); + 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->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"); + 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->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"); + + /* 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->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"); + ar = MEM_callocN(sizeof(ARegion), "nodetree area for node"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_LEFT; + 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"); + ar = MEM_callocN(sizeof(ARegion), "nodetree area for node"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - ar= MEM_callocN(sizeof(ARegion), "ui area for file"); + ar = MEM_callocN(sizeof(ARegion), "ui area for file"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_TOP; break; case SPACE_SEQ: - ar_main = (ARegion*)lb->first; + 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"); + 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"); - + ar = MEM_callocN(sizeof(ARegion), "toolbar for view3d"); + BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_TOOLS; - ar->alignment= RGN_ALIGN_LEFT; + 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"); - + 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->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"); - + ar = MEM_callocN(sizeof(ARegion), "buttons for view3d"); + BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + 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"); + 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->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; + break; #endif } } /* main region */ - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); - ar->winrct= sa->totrct; - - ar->regiontype= RGN_TYPE_WINDOW; - + 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; - + 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; - } + { + 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; - } + { + 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; + { + SpaceIpo *sipo = (SpaceIpo *)sl; + memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D)); - 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; - } + /* 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; - } + { + 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; - } + { + 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; - } + { + 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; - } + { + // 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; - } + { + 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; @@ -437,35 +437,34 @@ static void do_versions_windowmanager_2_50(bScreen *screen) { ScrArea *sa; SpaceLink *sl; - + /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - + 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 */ + 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 */ + 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; - + 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) { + 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); @@ -476,61 +475,60 @@ static void do_versions_windowmanager_2_50(bScreen *screen) static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name) { - BLI_addtail(lb, id); - id->us= 1; - id->flag= LIB_FAKEUSER; + 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); + 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; + 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; + v3d->gpd = NULL; } } - else if (sl->spacetype==SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; + 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; + snode->gpd = NULL; } } - else if (sl->spacetype==SPACE_SEQ) { - SpaceSeq *sseq= (SpaceSeq *)sl; + 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; + sseq->gpd = NULL; } } - else if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; + 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; + sima->gpd = NULL; } #else - sima->gpd= NULL; + sima->gpd = NULL; #endif } } - } + } } static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) @@ -542,57 +540,57 @@ static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) if (!mtex_array) return; - for (a=0; amaptoneg; - varfac= mtex->varfac; - colfac= mtex->colfac; + neg = mtex->maptoneg; + 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; + 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->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->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->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; + 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; + mtex->colfac = (neg & MAP_COL)? -colfac: colfac; else if (idtype == ID_LA) - mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac; + mtex->colfac = (neg & LAMAP_COL)? -colfac: colfac; else if (idtype == ID_WO) - mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac; + mtex->colfac = (neg & WOMAP_HORIZ)? -colfac: colfac; } } } @@ -603,16 +601,16 @@ static void do_version_mdef_250(Main *main) ModifierData *md; MeshDeformModifierData *mmd; - for (ob= main->object.first; ob; ob=ob->id.next) { - for (md=ob->modifiers.first; md; md=md->next) { + 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; + 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; + mmd->bindcagecos = mmd->bindcos; + mmd->bindcos = NULL; modifier_mdef_compact_influences(md); } @@ -625,43 +623,41 @@ 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) { + 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); + 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) { + else if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = con->data; - data->poleangle *= (float)(M_PI/180.0); + data->poleangle *= (float)(M_PI / 180.0); } - else if (con->type==CONSTRAINT_TYPE_ROTLIMIT) { + 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); + 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) +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); + do_versions_seq_unique_name_all_strips(sce, &seq->seqbase); } - seq=seq->next; + seq = seq->next; } } @@ -669,10 +665,10 @@ 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); } @@ -680,9 +676,9 @@ static void do_version_bone_roll_256(Bone *bone) static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree) { bNodeSocket *sock; - for (sock=ntree->inputs.first; sock; sock=sock->next) + for (sock = ntree->inputs.first; sock; sock = sock->next) sock->flag |= SOCK_DYNAMIC; - for (sock=ntree->outputs.first; sock; sock=sock->next) + for (sock = ntree->outputs.first; sock; sock = sock->next) sock->flag |= SOCK_DYNAMIC; } @@ -717,8 +713,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + 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) { @@ -754,55 +750,51 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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... */ + /* 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); + 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) { + 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) { + 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); + 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) { + 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); + 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 = blo_do_versions_newlibadr(fd, lib, ob->data); cam->flag |= CAM_PANORAMA; } } @@ -810,8 +802,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->r.mode &= ~R_PANORAMA; } } + /* and texture trees */ - for (tx= main->tex.first; tx; tx= tx->id.next) { + for (tx = main->tex.first; tx; tx = tx->id.next) { bNode *node; if (tx->nodetree) { @@ -819,19 +812,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) strcpy(tx->nodetree->id.name, "NTTexture Nodetree"); /* which_output 0 is now "not specified" */ - for (node=tx->nodetree->nodes.first; node; node=node->next) + 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; + 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) { + 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; @@ -848,22 +841,23 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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) + //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) { + for (cu = main->curve.first; cu; cu = cu->id.next) { Nurb *nu; - for (nu= cu->nurb.first; nu; nu= nu->next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { nu->flag |= (nu->type & CU_2D); nu->type &= CU_TYPE; } @@ -882,7 +876,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + //for (pid = pidlist.first; pid; pid = pid->next) { // if (pid->ptcaches->first == NULL) // pid->ptcaches->first = pid->ptcaches->last = pid->cache; //} @@ -896,7 +890,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + if (me && me->id.lib == NULL && me->mr && me->mr->level_count > 1) { multires_load_old(ob, me); } @@ -906,26 +900,28 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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<matbits = MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits"); + for (a = 0; a < ob->totcol; a++) + ob->matbits[a] = ob->colbits & (1<tex.first; tex; tex = tex->id.next) { if (tex->afmax == 0) - tex->afmax= 8; + 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->material_type = MA_TYPE_WIRE; ma->mode &= ~MA_WIRE; } + if (ma->mode & MA_HALO) { - ma->material_type= MA_TYPE_HALO; + ma->material_type = MA_TYPE_HALO; ma->mode &= ~MA_HALO; } @@ -938,15 +934,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* set new bump for unused slots */ - for (a=0; amtex[a]) { - tex= ma->mtex[a]->tex; + 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); + 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; @@ -954,7 +950,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - + /* volume rendering settings */ if (ma->vol.stepsize < 0.0001f) { ma->vol.density = 1.0f; @@ -972,24 +968,24 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } for (sce = main->scene.first; sce; sce = sce->id.next) { - ts= sce->toolsettings; + 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; - + 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 + * 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; + 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 + /* Dome */ sce->gm.dome.angle = sce->r.domeangle; sce->gm.dome.mode = sce->r.domemode; sce->gm.dome.res = sce->r.domeres; @@ -997,7 +993,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.dome.tilt = sce->r.dometilt; sce->gm.dome.warptext = sce->r.dometext; - //Stand Alone + /* Stand Alone */ sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0); sce->gm.xplay = sce->r.xplay; sce->gm.yplay = sce->r.yplay; @@ -1005,31 +1001,31 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.depth = sce->r.depth; sce->gm.attrib = sce->r.attrib; - //Stereo + /* 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 + 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 + 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 + /* 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; + sce->gm.freqplay = sce->r.freqplay; + sce->gm.depth = sce->r.depth; - //Physic (previously stored in world) + /* 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.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; @@ -1065,15 +1061,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; if (fd->fileflags & G_FILE_GAME_MAT_GLSL) - sce->gm.matmode= GAME_MAT_GLSL; + sce->gm.matmode = GAME_MAT_GLSL; else if (fd->fileflags & G_FILE_GAME_MAT) - sce->gm.matmode= GAME_MAT_MULTITEX; + sce->gm.matmode = GAME_MAT_MULTITEX; else - sce->gm.matmode= GAME_MAT_TEXFACE; + 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; @@ -1092,18 +1088,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) for (sce = main->scene.first; sce; sce = sce->id.next) if (sce->unit.scale_length == 0.0f) - sce->unit.scale_length= 1.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; - + 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; + ob->rotmode = ROT_MODE_EUL; } - - for (ma = main->mat.first; ma; ma=ma->id.next) { + + 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; @@ -1113,18 +1110,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) do_version_mtex_factor_2_50(ma->mtex, ID_MA); } - for (la = main->lamp.first; la; la=la->id.next) + 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) + 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) + 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) { + + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->audio.main == 0.0f) sce->audio.main = 1.0f; @@ -1136,7 +1133,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* Add default gravity to scenes */ - for (sce= main->scene.first; sce; sce= sce->id.next) { + 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) { @@ -1148,15 +1145,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* 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; + 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); + 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; } @@ -1169,7 +1168,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) @@ -1183,26 +1182,26 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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; - + 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) { + + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* just need to initalise rotation axis properly... */ - pchan->rotAxis[1]= 1.0f; + pchan->rotAxis[1] = 1.0f; } } } - for (la = main->lamp.first; la; la=la->id.next) - la->compressthresh= 0.05f; + for (la = main->lamp.first; la; la = la->id.next) + la->compressthresh = 0.05f; } if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) { @@ -1217,48 +1216,47 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + 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); + 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) { + 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); + 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) { + 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; + data = key->refkey->data; - for (nu=cu->nurb.first; nu; nu=nu->next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu->bezt) { BezTriple *bezt = nu->bezt; - for (a=0; apntsu; a++, bezt++) { + for (a = 0; a < nu->pntsu; 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++; + 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++; + for (a = 0; a < nu->pntsu*nu->pntsv; a++, bp++) { + copy_v3_v3(bp->vec, data); data += 3; + bp->alfa = *data; data++; } } } @@ -1268,69 +1266,72 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) { { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; while (sce) { - if (sce->r.frame_step==0) - sce->r.frame_step= 1; - if (sce->r.mblur_samples==0) + 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); + do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase); } - - sce= sce->id.next; + + sce = sce->id.next; } } + { /* ensure all nodes have unique names */ - bNodeTree *ntree= main->nodetree.first; + bNodeTree *ntree = main->nodetree.first; while (ntree) { - bNode *node=ntree->nodes.first; - + bNode *node = ntree->nodes.first; + while (node) { nodeUniqueName(ntree, node); - node= node->next; + node = node->next; } - - ntree= ntree->id.next; + + ntree = ntree->id.next; } } + { - Object *ob=main->object.first; + 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; + 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; + + 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; - + 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, @@ -1339,76 +1340,77 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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; + 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++) { + for (i = 0; i < band->tot; 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++) { + for (i = 0; i < band->tot; 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; + ma = ma->id.next; } - + while (tex) { if (tex->coba) { ColorBand *band = (ColorBand *)tex->coba; - for (i=0; itot; i++) { + for (i = 0; i < band->tot; i++) { CBData *data = band->data + i; srgb_to_linearrgb_v3_v3(&data->r, &data->r); } } - tex=tex->id.next; + 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; + 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) + for (sce = main->scene.first; sce; sce = sce->id.next) if (!sce->toolsettings->particle.selectmode) - sce->toolsettings->particle.selectmode= SCE_SELECT_PATH; + sce->toolsettings->particle.selectmode = SCE_SELECT_PATH; if (main->versionfile == 250 && main->subversionfile > 1) { - for (me=main->mesh.first; me; me=me->id.next) + 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); + 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; + mmd->sculptlvl = mmd->lvl; + mmd->renderlvl = mmd->lvl; } } } @@ -1420,7 +1422,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + 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) @@ -1437,12 +1439,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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; @@ -1453,14 +1454,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; } - - for ( ar = regionbase->first; ar; ar = ar->next) { + 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); + SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); BKE_area_region_free(st, ar); BLI_freelinkN(regionbase, ar); } @@ -1477,11 +1477,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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; @@ -1494,15 +1493,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; } - if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE; - if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF; + 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"); + ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer"); BLI_insertlinkbefore(regionbase, ar_main, ar); sequencer_init_preview_region(ar); } @@ -1517,61 +1518,61 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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 + + /* 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); + 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; - + 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; + 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; + avs->ghost_sf = 1; + avs->ghost_ef = 100; } - + /* type */ if (arm->ghostep == 0) - avs->ghost_type= GHOST_TYPE_NONE; + avs->ghost_type = GHOST_TYPE_NONE; else - avs->ghost_type= arm->ghosttype + 1; - + avs->ghost_type = arm->ghosttype + 1; + /* stepsize */ - avs->ghost_step= arm->ghostsize; + avs->ghost_step = arm->ghostsize; if (avs->ghost_step == 0) - avs->ghost_step= 1; - + avs->ghost_step = 1; + /* path settings --------------------- */ /* ranges */ - avs->path_bc= arm->pathbc; - avs->path_ac= arm->pathac; + 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; + 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; + avs->path_sf = 1; + avs->path_ef = 250; } - + /* flags */ if (arm->pathflag & ARM_PATH_FNUMS) avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS; @@ -1579,84 +1580,84 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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; + avs->path_step = arm->pathsize; if (avs->path_step == 0) - avs->path_step= 1; + avs->path_step = 1; } else animviz_settings_init(&ob->pose->avs); } } - + /* brush texture changes */ - for (brush= main->brush.first; brush; brush= brush->id.next) { + for (brush = main->brush.first; brush; brush = brush->id.next) { default_mtex(&brush->mtex); } - for (ma= main->mat.first; ma; ma= ma->id.next) { + 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; + 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) { + 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); + 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) { + + 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) { + 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; @@ -1667,38 +1668,38 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - + 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) + for (ma = main->mat.first; ma; ma = ma->id.next) ma->amb *= 2.0f; - for (wo= main->world.first; wo; wo=wo->id.next) { + 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; + wo->ao_env_energy = wo->aoenergy; + wo->aoenergy = 1.0f; if (wo->ao_indirect_bounces == 0) - wo->ao_indirect_bounces= 1; + wo->ao_indirect_bounces = 1; else wo->mode |= WO_INDIRECT_LIGHT; if (wo->aomix == WO_AOSUB) - wo->ao_env_energy= -wo->ao_env_energy; + wo->ao_env_energy = -wo->ao_env_energy; else if (wo->aomix == WO_AOADDSUB) wo->mode |= WO_AMB_OCC; - wo->aomix= WO_AOMUL; + 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; @@ -1707,7 +1708,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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.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; @@ -1725,15 +1727,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* 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; + 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) + for (ma = main->mat.first; ma; ma = ma->id.next) if (ma->mode & MA_TRACEBLE) ma->shade_flag |= MA_APPROX_OCCLUSION; @@ -1743,10 +1745,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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; @@ -1757,7 +1759,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; } - ar_preview = (ARegion*)regionbase->first; + ar_preview = (ARegion*) regionbase->first; for (; ar_preview; ar_preview = ar_preview->next) { if (ar_preview->regiontype == RGN_TYPE_PREVIEW) break; @@ -1771,20 +1773,20 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } /* 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. + * 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) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + 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) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { View3D* v3d = (View3D *)sl; v3d->flag2 &= ~V3D_RENDER_OVERRIDE; } @@ -1798,81 +1800,84 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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; + + 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) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Fluidsim) { - FluidsimModifierData *fmd = (FluidsimModifierData *)md; - fmd->fss->flag |= OB_FLUIDSIM_ACTIVE; + 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) { + for (scene = main->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { - bNode *node=scene->nodetree->nodes.first; - + bNode *node = scene->nodetree->nodes.first; + while (node) { if (node->type == CMP_NODE_COLORBALANCE) { - NodeColorBalance *n= (NodeColorBalance *)node->storage; + NodeColorBalance *n = (NodeColorBalance *) node->storage; n->lift[0] += 1.f; n->lift[1] += 1.f; n->lift[2] += 1.f; } - node= node->next; + node = node->next; } } } /* check inside node groups too */ - for (ntree= main->nodetree.first; ntree; ntree=ntree->id.next) { - bNode *node=ntree->nodes.first; - + 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; + NodeColorBalance *n = (NodeColorBalance *) node->storage; n->lift[0] += 1.f; n->lift[1] += 1.f; n->lift[2] += 1.f; } - node= node->next; + + 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) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + + 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; + + 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; @@ -1881,13 +1886,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Tex *tex; Brush *brush; - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { + + for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; + SpaceNode *snode = (SpaceNode *) sl; ListBase *regionbase; ARegion *ar; @@ -1897,22 +1903,22 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; if (snode->v2d.minzoom > 0.09f) - snode->v2d.minzoom= 0.09f; + snode->v2d.minzoom = 0.09f; if (snode->v2d.maxzoom < 2.31f) - snode->v2d.maxzoom= 2.31f; + snode->v2d.maxzoom = 2.31f; - for (ar= regionbase->first; ar; ar= ar->next) { + 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; + ar->v2d.minzoom = 0.09f; if (ar->v2d.maxzoom < 2.31f) - ar->v2d.maxzoom= 2.31f; + ar->v2d.maxzoom = 2.31f; } } } else if (sl->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)sl; - + SpaceTime *stime = (SpaceTime *) sl; + /* enable all cache display */ stime->cache_display |= TIME_CACHE_DISPLAY; stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); @@ -1927,19 +1933,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *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); + 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) { + if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) { ArmatureModifierData *amd; - bArmature *arm= (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data); + 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; + amd->deformflag = arm->deformflag; ob->partype = PAROBJECT; } - else if (parent->type==OB_LATTICE && ob->partype==PARSKEL) { + else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) { LatticeModifierData *lmd; lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice); @@ -1947,7 +1953,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) BLI_addtail((ListBase*)&ob->modifiers, lmd); ob->partype = PAROBJECT; } - else if (parent->type==OB_CURVE && ob->partype==PARCURVE) { + else if (parent->type == OB_CURVE && ob->partype == PARCURVE) { CurveModifierData *cmd; cmd = (CurveModifierData*) modifier_new(eModifierType_Curve); @@ -1958,39 +1964,39 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - + /* initialize scene active layer */ - for (scene= main->scene.first; scene; scene=scene->id.next) { + for (scene = main->scene.first; scene; scene = scene->id.next) { int i; - for (i=0; i<20; i++) { + for (i = 0; i < 20; i++) { if (scene->lay & (1<layact= 1<layact = 1<tex.first; tex; tex= tex->id.next) { + for (tex = main->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; + 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 (cu = main->curve.first; cu; cu = cu->id.next) { + cu->smallcaps_scale = 0.75f; } } - for (scene= main->scene.first; scene; scene=scene->id.next) { + 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; + if (seq->sat == 0.0f) { + seq->sat = 1.0f; } } SEQ_END @@ -1999,46 +2005,46 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* GSOC 2010 Sculpt - New settings for Brush */ - for (brush= main->brush.first; brush; brush= brush->id.next) { + for (brush = main->brush.first; brush; brush = brush->id.next) { /* Sanity Check */ - // infinite number of dabs + /* infinite number of dabs */ if (brush->spacing == 0) brush->spacing = 10; - // will have no effect + /* will have no effect */ if (brush->alpha == 0) brush->alpha = 0.5f; - // bad radius + /* bad radius */ if (brush->unprojected_radius == 0) brush->unprojected_radius = 0.125f; - // unusable size + /* unusable size */ if (brush->size == 0) brush->size = 35; - // can't see overlay + /* can't see overlay */ if (brush->texture_overlay_alpha == 0) brush->texture_overlay_alpha = 33; - // same as draw brush + /* same as draw brush */ if (brush->crease_pinch_factor == 0) brush->crease_pinch_factor = 0.5f; - // will sculpt no vertexes + /* will sculpt no vertexes */ if (brush->plane_trim == 0) brush->plane_trim = 0.5f; - // same as smooth stroke off + /* same as smooth stroke off */ if (brush->smooth_stroke_radius == 0) - brush->smooth_stroke_radius= 75; + brush->smooth_stroke_radius = 75; - // will keep cursor in one spot + /* will keep cursor in one spot */ if (brush->smooth_stroke_radius == 1) - brush->smooth_stroke_factor= 0.9f; + brush->smooth_stroke_factor = 0.9f; - // same as dots + /* same as dots */ if (brush->rate == 0) brush->rate = 0.1f; @@ -2046,9 +2052,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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)); + /* 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 && @@ -2056,7 +2063,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { brush->add_col[0] = 1.00f; brush->add_col[1] = 0.39f; - brush->add_col[2] = 0.39f; + brush->add_col[2] = 0.39f; } if (brush->sub_col[0] == 0 && @@ -2074,11 +2081,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + 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) + 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) @@ -2087,50 +2094,50 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) { - Object *ob; + 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; + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; - if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - smd->domain->vorticity = 2.0f; - smd->domain->time_scale = 1.0f; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; - if (!(smd->domain->flags & (1<<4))) - continue; + if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { + smd->domain->vorticity = 2.0f; + smd->domain->time_scale = 1.0f; - /* delete old MOD_SMOKE_INITVELOCITY flag */ - smd->domain->flags &= ~(1<<4); + if (!(smd->domain->flags & (1<<4))) + continue; - /* 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; + /* delete old MOD_SMOKE_INITVELOCITY flag */ + smd->domain->flags &= ~(1<<4); - if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { - smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY; - } + /* 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; } } + 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; @@ -2138,9 +2145,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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 (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) { @@ -2151,25 +2158,25 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) part->kink_amp_clump = 1.f; /* keep old files looking similar */ } - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_INFO) { - SpaceInfo *sinfo= (SpaceInfo *)sl; + SpaceInfo *sinfo = (SpaceInfo *) sl; ARegion *ar; - sinfo->rpt_mask= INFO_RPT_OP; + sinfo->rpt_mask = INFO_RPT_OP; - for (ar= sa->regionbase.first; ar; ar= ar->next) { + 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; + ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; } } } @@ -2179,30 +2186,30 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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; + for (ob = main->object.first; ob; ob = ob->id.next) { + bActuator *act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { + if (act->type == ACT_OBJECT) { /* multiply velocity with 50 in old files */ - bObjectActuator *oa= act->data; + bObjectActuator *oa = act->data; mul_v3_fl(oa->drot, 0.8726646259971648f); } - act= act->next; + act = act->next; } } } - - // init facing axis property of steering actuators - { + + /* 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) { + 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 (stact->facingaxis == 0) { + stact->facingaxis = 1; + } } } } @@ -2214,55 +2221,55 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + 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; + 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 ) + 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; + 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; + bArmature *arm; + Bone *bone; Object *ob; for (arm = main->armature.first; arm; arm = arm->id.next) @@ -2271,7 +2278,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (is_zero_v4(ob->dquat)) { unit_qt(ob->dquat); } @@ -2283,11 +2290,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) 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) { + 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) @@ -2296,22 +2303,23 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)) { + 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; + transp_tex = 0; + + for (tex_nr = 0; tex_nr < MAX_MTEX; tex_nr++) { + if (!mat->mtex[tex_nr]) + continue; + if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) + transp_tex = 1; } /* weak! material alpha could be animated */ @@ -2323,7 +2331,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* redraws flag in SpaceTime has been moved to Screen level */ - for (sc = main->screen.first; sc; sc= sc->id.next) { + 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... @@ -2331,19 +2339,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (brush= main->brush.first; brush; brush= brush->id.next) { + for (brush = main->brush.first; brush; brush = brush->id.next) { if (brush->height == 0) - brush->height= 0.4f; + 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) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Solidify) { - SolidifyModifierData *smd = (SolidifyModifierData *)md; + SolidifyModifierData *smd = (SolidifyModifierData *) md; if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) { - smd->mat_ofs_rim= 1; + smd->mat_ofs_rim = 1; smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL; } } @@ -2368,11 +2376,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) + 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; + 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; } @@ -2383,27 +2391,29 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) * 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) { + + 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) { + 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) { + 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; + 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) { + + 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) { + 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; + View2D *v2d = &ar->v2d; + v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom = v2d->keepofs = v2d->align = 0; } } } @@ -2414,14 +2424,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* Initialize texture point density curve falloff */ Tex *tex; - for (tex= main->tex.first; tex; tex= tex->id.next) { + 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); @@ -2435,10 +2445,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* 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) { + 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; + bCameraActuator *ba = act->data; ba->damping = 1.0/32.0; } @@ -2460,7 +2470,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Scene *scene; Sequence *seq; - for (scene=main->scene.first; scene; scene=scene->id.next) { + 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) @@ -2470,29 +2480,31 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) SEQ_END } } + { bScreen *screen; - for (screen= main->screen.first; screen; screen= screen->id.next) { + 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) { + 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) { + 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; + ar->v2d.min[1] = 0.5f; } } } - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { + 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) { + 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; + ar->v2d.min[1] = 0.5f; } } } @@ -2500,8 +2512,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } + { - /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve + /* 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). @@ -2510,28 +2523,31 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) */ 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; + 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; @@ -2539,12 +2555,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bIpoActuator *ia; bActionActuator *aa; - for (ob= main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + 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"); + ia = act->data; + aa = MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); // Copy values aa->type = ia->type; @@ -2561,8 +2577,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) // Assign the new actuator act->data = aa; - act->type= act->otype= ACT_ACTION; - + act->type = act->otype = ACT_ACTION; } else if (act->type == ACT_SHAPEACTION) { act->type = act->otype = ACT_ACTION; @@ -2579,32 +2594,36 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Material *mat; Tex *tex; bNodeTree *ntree; - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + + 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) + + 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) + 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) + 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; - } + 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) { + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { do_versions_nodetree_dynamic_sockets(ntree); ntree->update |= NTREE_UPDATE; } @@ -2617,7 +2636,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) */ bNodeTree *ntree; /* all node trees in main->nodetree are considered groups */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) ntree->nodetype = NODE_GROUP; } } @@ -2668,9 +2687,4 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - - /* 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 index 759a2ea595f..2f7ff055b91 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -25,7 +25,7 @@ * */ -/** \file blender/blenloader/intern/readfile_pre250.c +/** \file blender/blenloader/intern/versioning_legacy.c * \ingroup blenloader */ @@ -101,9 +101,6 @@ #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" @@ -121,39 +118,53 @@ static void vcol_to_fcol(Mesh *me) unsigned int *mcol, *mcoln, *mcolmain; int a; - if (me->totface==0 || me->mcol==NULL) return; + if (me->totface == 0 || me->mcol == NULL) + return; - mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln"); + 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; + 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; + 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; + 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; } } @@ -170,21 +181,22 @@ static void do_version_bone_head_tail_237(Bone *bone) 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) + 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; - + + 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; + if (bone->dist<=0.0f) + bone->dist = 0.0f; } bone_version_238(&bone->childbase); } @@ -193,10 +205,10 @@ static void bone_version_238(ListBase *lb) static void bone_version_239(ListBase *lb) { Bone *bone; - - for (bone= lb->first; bone; bone= bone->next) { - if (bone->layer==0) - bone->layer= 1; + + for (bone = lb->first; bone; bone = bone->next) { + if (bone->layer == 0) + bone->layer = 1; bone_version_239(&bone->childbase); } } @@ -204,25 +216,25 @@ static void bone_version_239(ListBase *lb) 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; + + 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; + 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; } } } @@ -232,23 +244,24 @@ static void ntree_version_241(bNodeTree *ntree) 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 (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; + 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) + 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"); + node->storage = MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); } - + } static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) @@ -259,22 +272,22 @@ static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) Image *image; ImageUser *iuser; - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { + 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; + ntf = MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); + node->storage = ntf; if (node->custom1) - ntf->x= 1.0f; + ntf->x = 1.0f; } } - + /* fix for temporary flag changes during 245 cycle */ - nodeid= blo_do_versions_newlibadr(fd, lib, node->id); + nodeid = blo_do_versions_newlibadr(fd, lib, node->id); if (node->storage && nodeid && GS(nodeid->name) == ID_IM) { - image= (Image*)nodeid; - iuser= node->storage; + image = (Image*)nodeid; + iuser = node->storage; if (iuser->flag & IMA_OLD_PREMUL) { iuser->flag &= ~IMA_OLD_PREMUL; iuser->flag |= IMA_DO_PREMUL; @@ -292,11 +305,12 @@ 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); + + 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; @@ -306,8 +320,8 @@ static void idproperties_fix_groups_lengths_recurse(IDProperty *prop) static void idproperties_fix_group_lengths(ListBase idlist) { ID *id; - - for (id=idlist.first; id; id=id->next) { + + for (id = idlist.first; id; id = id->next) { if (id->properties) { idproperties_fix_groups_lengths_recurse(id->properties); } @@ -322,35 +336,35 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) int a, b, texalpha; /* verify we have a tface layer */ - for (b=0; bfdata.totlayer; b++) + for (b = 0; b < me->fdata.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++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (mf->mat_nr < me->totcol) { - ma= blo_do_versions_newlibadr(fd, lib, me->mat[mf->mat_nr]); + 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; + ma = NULL; - for (b=0; ma && bmtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA) texalpha = 1; } else { - ma= NULL; + ma = NULL; texalpha = 0; } - for (b=0; bfdata.totlayer; b++) { + for (b = 0; b < me->fdata.totlayer; b++) { if (me->fdata.layers[b].type == CD_MTFACE) { tf = ((MTFace*)me->fdata.layers[b].data) + a; @@ -382,7 +396,7 @@ static void customdata_version_242(Mesh *me) 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); @@ -390,40 +404,40 @@ static void customdata_version_242(Mesh *me) 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); + 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; + mtf = me->mtface; + mcol = me->mcol; + tf = me->tface; - for (a=0; a < me->totface; a++, mtf++, tf++, mcol+=4) { + 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; + 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; + me->tface = NULL; } else if (me->mcol) { - me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface); + 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; + me->tface = NULL; } - for (a=0, mtfacen=0, mcoln=0; a < me->fdata.totlayer; a++) { - layer= &me->fdata.layers[a]; + 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) { @@ -434,8 +448,10 @@ static void customdata_version_242(Mesh *me) } 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); + if (mcoln == 0) + strcpy(layer->name, "Col"); + else + BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); } mcoln++; } @@ -450,8 +466,8 @@ static void customdata_version_243(Mesh *me) CustomDataLayer *layer; int a; - for (a=0; a < me->fdata.totlayer; a++) { - layer= &me->fdata.layers[a]; + for (a = 0; a < me->fdata.totlayer; a++) { + layer = &me->fdata.layers[a]; layer->active_rnd = layer->active; } } @@ -460,30 +476,30 @@ static void customdata_version_243(Mesh *me) 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 (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"); + 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; + 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; + ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user"); + iuser->sfra = 1; + iuser->fie_ima = 2; + iuser->ok = 1; } } } @@ -494,9 +510,10 @@ 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); + if (eff->type == EFF_PARTICLE) { + paf = (PartEff *)eff; + if (paf->keys) + MEM_freeN(paf->keys); } MEM_freeN(eff); } @@ -505,11 +522,11 @@ static void do_version_free_effects_245(ListBase *lb) { Effect *eff; - eff= lb->first; + eff = lb->first; while (eff) { BLI_remlink(lb, eff); do_version_free_effect_245(eff); - eff= lb->first; + eff = lb->first; } } @@ -517,10 +534,11 @@ PartEff *blo_do_version_give_parteff_245(Object *ob) { PartEff *paf; - paf= ob->effect.first; + paf = ob->effect.first; while (paf) { - if (paf->type==EFF_PARTICLE) return paf; - paf= paf->next; + if (paf->type == EFF_PARTICLE) + return paf; + paf = paf->next; } return NULL; } @@ -530,15 +548,15 @@ 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); + 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; } @@ -553,50 +571,57 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) while (tex) { if (tex->id.flag & LIB_NEEDLINK) { - if (tex->extend==0) { - if (tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT; + if (tex->extend == 0) { + if (tex->xrepeat || tex->yrepeat) { + tex->extend = TEX_REPEAT; + } else { - tex->extend= TEX_EXTEND; - tex->xrepeat= tex->yrepeat= 1; + tex->extend = TEX_EXTEND; + tex->xrepeat = tex->yrepeat = 1; } } } - tex= tex->id.next; + 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; + 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; + 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; + ob->colbits = 0; if (ob->totcol) { - for (a=0; atotcol; a++) { - if (ob->mat[a]) ob->colbits |= (1<totcol; a++) { + if (ob->mat[a]) + ob->colbits |= (1<id.next; + ob = ob->id.next; } } + if (main->versionfile <= 104) { /* timeoffs moved */ Object *ob = main->object.first; @@ -605,68 +630,79 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob->transflag -= 1; //ob->ipoflag |= OB_OFFS_OB; } - ob= ob->id.next; + 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; + 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 (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; + sce = sce->id.next; } - ob= main->object.first; + ob = main->object.first; while (ob) { //ob->ipoflag |= OB_OFFS_PARENT; - if (ob->dt==0) ob->dt= OB_SOLID; - ob= ob->id.next; + 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; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; - if (v3d->gridlines==0) v3d->gridlines= 20; + if (v3d->gridlines == 0) + v3d->gridlines = 20; } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.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 (ma->flaresize == 0.0f) + ma->flaresize = 1.0f; + ma->subsize = 1.0f; + ma->flareboost = 1.0f; + ma = ma->id.next; } } @@ -675,7 +711,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) while (tex) { if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && - (tex->bfac == 0.0f)) { + (tex->bfac == 0.0f)) + { tex->rfac = 1.0f; tex->gfac = 1.0f; tex->bfac = 1.0f; @@ -684,13 +721,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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->bfac == 0.0f)) + { tex->rfac = 1.0f; tex->gfac = 1.0f; tex->bfac = 1.0f; @@ -699,86 +738,93 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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 (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 (sce->r.frs_sec == 0) + sce->r.frs_sec = 25; + sce = sce->id.next; } } + if (main->versionfile <= 164) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; while (me) { - me->smoothresh= 30; - me= me->id.next; + me->smoothresh = 30; + me = me->id.next; } } + if (main->versionfile <= 165) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; TFace *tface; int nr; char *cp; while (me) { if (me->tface) { - nr= me->totface; - tface= 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; + 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; + me = me->id.next; } } if (main->versionfile <= 169) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; while (me) { - if (me->subdiv==0) me->subdiv= 1; - me= me->id.next; + if (me->subdiv == 0) + me->subdiv = 1; + me = me->id.next; } } if (main->versionfile <= 169) { - bScreen *sc= main->screen.first; + bScreen *sc = main->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_IPO) { - SpaceIpo *sipo= (SpaceIpo*) sl; - sipo->v2d.max[0]= 15000.0; + if (sl->spacetype == SPACE_IPO) { + SpaceIpo *sipo = (SpaceIpo*) sl; + sipo->v2d.max[0] = 15000.0; } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } @@ -789,7 +835,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) paf = blo_do_version_give_parteff_245(ob); if (paf) { if (paf->staticstep == 0) { - paf->staticstep= 5; + paf->staticstep = 5; } } ob = ob->id.next; @@ -797,87 +843,88 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } if (main->versionfile <= 171) { - bScreen *sc= main->screen.first; + bScreen *sc = main->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText*) sl; - st->lheight= 12; + if (sl->spacetype == SPACE_TEXT) { + SpaceText *st = (SpaceText*) sl; + st->lheight = 12; } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } if (main->versionfile <= 173) { int a, b; - Mesh *me= main->mesh.first; + 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; + TFace *tface = me->tface; + for (a = 0; a < me->totface; a++, tface++) { + for (b = 0; b < 4; b++) { + tface->uv[b][0] /= 32767.0f; + tface->uv[b][1] /= 32767.0f; } } } - me= me->id.next; + me = me->id.next; } } if (main->versionfile <= 191) { - Object *ob= main->object.first; + 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; + 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; + 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; + Object *ob = main->object.first; while (ob) { - ob->inertia= 1.0f; - ob->rdamping= 0.1f; - ob= ob->id.next; + ob->inertia = 1.0f; + ob->rdamping = 0.1f; + ob = ob->id.next; } } if (main->versionfile <= 196) { - Mesh *me= main->mesh.first; + 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 *tface = me->tface; + for (a = 0; a < me->totface; a++, tface++) { + for (b = 0; b < 4; b++) { tface->mode |= TF_DYNAMIC; tface->mode &= ~TF_INVISIBLE; } } } - me= me->id.next; + me = me->id.next; } } if (main->versionfile <= 200) { - Object *ob= main->object.first; + 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 */ @@ -888,7 +935,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 201) { /* add-object + end-object are joined to edit-object actuator */ - Object *ob = main->object.first; + Object *ob = main->object.first; bProperty *prop; bActuator *act; bIpoActuator *ia; @@ -897,30 +944,30 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) while (ob) { act = ob->actuators.first; while (act) { - if (act->type==ACT_IPO) { - ia= act->data; - prop= get_ob_property(ob, ia->name); + if (act->type == ACT_IPO) { + ia = act->data; + prop = get_ob_property(ob, ia->name); if (prop) { - ia->type= ACT_IPO_FROM_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; + 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; + 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; + 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; + act = act->next; } ob = ob->id.next; } @@ -929,25 +976,25 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 202) { /* add-object and end-object are joined to edit-object * actuator */ - Object *ob= main->object.first; + Object *ob = main->object.first; bActuator *act; bObjectActuator *oa; while (ob) { - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { - oa= act->data; + 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; + act = act->next; } - ob= ob->id.next; + ob = ob->id.next; } } if (main->versionfile <= 204) { /* patches for new physics */ - Object *ob= main->object.first; + Object *ob = main->object.first; bActuator *act; bObjectActuator *oa; bSound *sound; @@ -956,22 +1003,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* please check this for demo20 files like * original Egypt levels etc. converted * rotation factor of 50 is not workable */ - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { - oa= act->data; + if (act->type == ACT_OBJECT) { + oa = act->data; - oa->forceloc[0]*= 25.0f; - oa->forceloc[1]*= 25.0f; - oa->forceloc[2]*= 25.0f; + 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; + oa->forcerot[0] *= 10.0f; + oa->forcerot[1] *= 10.0f; + oa->forcerot[2] *= 10.0f; } - act= act->next; + act = act->next; } - ob= ob->id.next; + ob = ob->id.next; } sound = main->sound.first; @@ -985,7 +1032,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 205) { /* patches for new physics */ - Object *ob= main->object.first; + Object *ob = main->object.first; bActuator *act; bSensor *sens; bEditObjectActuator *oa; @@ -999,21 +1046,21 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob->anisotropicFriction[1] = 1.0; ob->anisotropicFriction[2] = 1.0; - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_EDIT_OBJECT) { + if (act->type == ACT_EDIT_OBJECT) { /* Zero initial velocity for newly * added objects */ - oa= act->data; + oa = act->data; oa->linVelocity[0] = 0.0; oa->linVelocity[1] = 0.0; oa->linVelocity[2] = 0.0; oa->localflag = 0; } - act= act->next; + act = act->next; } - sens= ob->sensors.first; + sens = ob->sensors.first; while (sens) { /* Extra fields for radar sensors. */ if (sens->type == SENS_RADAR) { @@ -1046,7 +1093,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } sens = sens->next; } - ob= ob->id.next; + ob = ob->id.next; } /* have to check the exact multiplier */ } @@ -1060,41 +1107,40 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Object *ob; /* added alpha in obcolor */ - ob= main->object.first; + ob = main->object.first; while (ob) { - ob->col[3]= 1.0; - ob= ob->id.next; + ob->col[3] = 1.0; + ob = ob->id.next; } /* added alpha in obcolor */ - ob= main->object.first; + ob = main->object.first; while (ob) { - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { + if (act->type == ACT_OBJECT) { /* multiply velocity with 50 in old files */ - oa= act->data; + 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) + if (fabsf(oa->angularvelocity[0]) >= 0.01f) oa->angularvelocity[0] *= 50.0f; - if (fabsf(oa->angularvelocity[1])>=0.01f) + if (fabsf(oa->angularvelocity[1]) >= 0.01f) oa->angularvelocity[1] *= 50.0f; - if (fabsf(oa->angularvelocity[2])>=0.01f) + if (fabsf(oa->angularvelocity[2]) >= 0.01f) oa->angularvelocity[2] *= 50.0f; } - act= act->next; + act = act->next; } - ob= ob->id.next; + ob = ob->id.next; } } if (main->versionfile <= 212) { - bSound* sound; bProperty *prop; Object *ob; @@ -1117,33 +1163,33 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = main->object.first; while (ob) { - prop= ob->prop.first; + 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; + 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 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; + me->subdiv = 1; } else { - if (me->subdiv<2) - me->subdiv= 1; + if (me->subdiv < 2) + me->subdiv = 1; else me->subdiv--; } @@ -1157,113 +1203,116 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = main->object.first; /* adapt form factor in order to get the 'old' physics - * behavior back...*/ + * behavior back... + */ while (ob) { /* in future, distinguish between different - * object bounding shapes */ + * object bounding shapes + */ ob->formfactor = 0.4f; /* patch form factor, note that inertia equiv radius - * of a rotation symmetrical obj */ + * 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) { + /* 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; + for (i = 0; i < me->totface * 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 (i = 0; i < me->totface; i++) { + TFace *tf = &((TFace*) me->tface)[i]; - for (j=0; j<4; j++) { - char *col= (char*) &tf->col[j]; + for (j = 0; j < 4; j++) { + char *col = (char*) &tf->col[j]; - col[0]= 255; + col[0] = 255; } } } } } + if (main->versionfile <= 221) { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; - // new variables for std-alone player and runtime + /* new variables for std-alone player and runtime */ while (sce) { + sce->r.xplay = 640; + sce->r.yplay = 480; + sce->r.freqplay = 60; - sce->r.xplay= 640; - sce->r.yplay= 480; - sce->r.freqplay= 60; - - sce= sce->id.next; + sce = sce->id.next; } } + if (main->versionfile <= 222) { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; - // new variables for std-alone player and runtime + /* new variables for std-alone player and runtime */ while (sce) { + sce->r.depth = 32; - sce->r.depth= 32; - - sce= sce->id.next; + 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) { + 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) { + 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) { + /* 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; + 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); + 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) { + for (sound = main->sound.first; sound; sound = sound->id.next) { if (sound->packedfile) { if (sound->newpackedfile == NULL) { sound->newpackedfile = sound->packedfile; @@ -1272,38 +1321,36 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } /* 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 (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) { + 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) { + /* 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) { + 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; + 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) { + for (wo = main->world.first; wo; wo = wo->id.next) { wo->physicsEngine = 2; } } @@ -1324,11 +1371,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) list = &ob->constraints; /* check for already existing TrackTo constraint - * set their track and up flag correctly */ + * set their track and up flag correctly + */ if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; data->reserved1 = ob->trackflag; @@ -1341,10 +1389,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + 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; @@ -1357,53 +1403,55 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* 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) { + 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; + + /* 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) { + + /* 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) { + 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; + 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; + 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.*/ + * to the new full constraint Track is painless for everyone. + */ ob = main->object.first; while (ob) { @@ -1415,7 +1463,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; data->reserved1 = ob->trackflag; @@ -1428,10 +1476,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + 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; @@ -1445,125 +1491,131 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = ob->id.next; } - for (sce= main->scene.first; sce; sce= sce->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) { + /* 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) { + 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; + 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; + 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_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_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_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_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_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_GAME) { + sbuts->mainb = CONTEXT_LOGIC; } - else if (sbuts->mainb==BUTS_FPAINT) { - sbuts->mainb= CONTEXT_EDITING; + 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_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_CONSTRAINT) { + sbuts->mainb = CONTEXT_OBJECT; } - else if (sbuts->mainb==BUTS_SCRIPT) { - 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 if (sbuts->mainb == BUTS_EDIT) { + sbuts->mainb = CONTEXT_EDITING; } - else sbuts->mainb= CONTEXT_SCENE; + 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() */ + * 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) { + /* 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) { + 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; + 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 (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) { + 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; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } + if (main->versionfile <= 231) { - Material *ma= main->mat.first; + Material *ma = main->mat.first; bScreen *sc = main->screen.first; Scene *sce; Lamp *la; @@ -1571,68 +1623,78 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* 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; + 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->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; + ma = ma->id.next; } - sce= main->scene.first; + sce = main->scene.first; while (sce) { - if (sce->r.gauss==0.0f) sce->r.gauss= 1.0f; - sce= sce->id.next; + if (sce->r.gauss == 0.0f) + sce->r.gauss = 1.0f; + sce = sce->id.next; } - la= main->lamp.first; + 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; + 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; + wrld = main->world.first; while (wrld) { - if (wrld->range==0.0f) { - wrld->range= 1.0f/wrld->exposure; + if (wrld->range == 0.0f) { + wrld->range = 1.0f / wrld->exposure; } - wrld= wrld->id.next; + wrld = wrld->id.next; } /* new bit flags for showing/hiding grid floor and axes */ while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; - if (v3d->gridflag==0) { + 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; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } + if (main->versionfile <= 232) { - Tex *tex= main->tex.first; - World *wrld= main->world.first; + Tex *tex = main->tex.first; + World *wrld = main->world.first; bScreen *sc; Scene *sce; @@ -1641,7 +1703,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex->flag |= TEX_CHECKER_ODD; } /* copied from kernel texture.c */ - if (tex->ns_outscale==0.0f) { + if (tex->ns_outscale == 0.0f) { /* musgrave */ tex->mg_H = 1.0f; tex->mg_lacunarity = 2.0f; @@ -1655,70 +1717,79 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex->vn_w1 = 1.0f; tex->vn_mexp = 2.5f; } - tex= tex->id.next; + tex = tex->id.next; } while (wrld) { - if (wrld->aodist==0.0f) { - wrld->aodist= 10.0f; - wrld->aobias= 0.05f; + 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; + 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) { + /* 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) { + 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; + 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; + if (sl->spacetype == SPACE_NLA) { + SpaceNla *snla = (SpaceNla *) sl; + snla->v2d.maxzoom = 50; } } } } - sce= main->scene.first; + sce = main->scene.first; while (sce) { - if (sce->r.ocres==0) sce->r.ocres= 64; - sce= sce->id.next; + 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; */ - + 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; + 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; + if (ob->ipowin == 0) + ob->ipowin = ID_OB; + ob = ob->id.next; } #endif - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + 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; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; v3d->flag |= V3D_SELECT_OUTLINE; } } @@ -1726,108 +1797,114 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - - - 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; + + /* 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) { + + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + 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; + 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; + 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; + 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; + if (tex->nabla == 0.0f) + tex->nabla = 0.025f; + tex = tex->id.next; } while (sce) { - ed= sce->ed; + ed = sce->ed; if (ed) { SEQ_BEGIN (sce->ed, seq) { - if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE) + if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) seq->flag |= SEQ_MAKE_PREMUL; } SEQ_END } - - sce= sce->id.next; + + sce = sce->id.next; } } + if (main->versionfile <= 236) { Object *ob; - Camera *cam= main->camera.first; + 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"); + 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; + 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) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + 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; + 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; + /* 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) { + 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->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) { + if (ob->soft && ob->soft->vertgroup == 0) { bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL"); if (locGroup) { /* retrieve index for that group */ @@ -1836,125 +1913,130 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } + 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) { + + /* armature recode checks */ + for (arm = main->armature.first; arm; arm = arm->id.next) { BKE_armature_where_is(arm); - for (bone= arm->bonebase.first; bone; bone= bone->next) + 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) { + 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) + Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent); + if (parent && parent->type == OB_LATTICE) ob->partype = PARSKEL; } - // btw. BKE_pose_rebuild is further only called on leave editmode - if (ob->type==OB_ARMATURE) { + /* 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 + + /* cannot call stuff now (pointers!), done in setup_app_data */ + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* new generic xray option */ - arm= blo_do_versions_newlibadr(fd, lib, ob->data); + arm = blo_do_versions_newlibadr(fd, lib, ob->data); if (arm->flag & ARM_DRAWXRAY) { ob->dtx |= OB_DRAWXRAY; } } - else if (ob->type==OB_MESH) { + 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) + if (me->subdiv != 0) smd->modifier.mode |= 1; - if (me->subdivr!=0) + if (me->subdivr != 0) smd->modifier.mode |= 2; - if (me->flag&ME_OPT_EDGES) + 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) { + + /* 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; + 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; + 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->cornertype =0; + sce->toolsettings->degr = 90; sce->toolsettings->step = 9; - sce->toolsettings->turn = 1; - sce->toolsettings->extr_offs = 1; + 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; + 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) { + 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) { + 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) { + 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) { + 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) { + while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { md = md->next; } @@ -1966,28 +2048,29 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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 + 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) { + 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 */ + data->rootbone = -1; + + /* update_pose_etc handles rootbone == -1 */ ob->pose->flag |= POSE_RECALC; - } + } } } } @@ -2003,13 +2086,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) paf->omat = 1; } } - - for (arm=main->armature.first; arm; arm= arm->id.next) { + + 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) { + for (me = main->mesh.first; me; me = me->id.next) { if (!me->medge) { BKE_mesh_make_edges(me, 1); /* 1 = use mface->edcode */ } @@ -2017,18 +2100,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) BKE_mesh_strip_loose_faces(me); } } - - for (key= main->key.first; key; key= key->id.next) { + + 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) + 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) { + if (kb->name[0] == 0) { BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index); } index++; @@ -2036,73 +2119,78 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } + 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; - + 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) { + 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) { + + 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; + 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; + 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; + if (arm->layer == 0) + arm->layer = 1; } - - for (;sce;sce= sce->id.next) { + + for (; sce; sce = sce->id.next) { /* make 'innervert' the default subdivide type, for backwards compat */ - sce->toolsettings->cornertype=1; - + sce->toolsettings->cornertype = 1; + if (sce->r.scemode & R_PASSEPARTOUT) { - set_passepartout= 1; + 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.filtertype = R_FILTER_GAUSS; sce->r.mode &= ~R_GAUSS; } } - - for (;cam; cam= cam->id.next) { + + 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; + 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; + + 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 (ma->mode & MA_TRACEBLE) + ma->mode |= MA_SHADBUF; } } - + if (main->versionfile <= 241) { Object *ob; Tex *tex; @@ -2112,39 +2200,44 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Material *ma; bArmature *arm; bNodeTree *ntree; - - for (wo = main->world.first; wo; wo= wo->id.next) { + + 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; + 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; + /* 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) + if (sce->r.layers.first == NULL) BKE_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) { + 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); @@ -2162,64 +2255,65 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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; + 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) + + 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 (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) { + 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) { + + 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) + 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; + 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) { + 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; @@ -2233,16 +2327,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) BPoint *bp; bNodeTree *ntree; int a; - - for (sc= main->screen.first; sc; sc= sc->id.next) { + + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - sa= sc->areabase.first; + 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; + 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; } @@ -2250,45 +2344,47 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sa = sa->next; } } - - for (sce= main->scene.first; sce; sce= sce->id.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->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.threads == 0) { if (sce->r.mode & R_THREADS) - sce->r.threads= 2; + sce->r.threads = 2; else - sce->r.threads= 1; + sce->r.threads = 1; } if (sce->nodetree) ntree_version_242(sce->nodetree); } - - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + + 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) { + 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; + for (bezt = nu->bezt, a = 0; a < nu->pntsu; 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 (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) { + if (!bp->radius) + bp->radius = 1.0; } } } } } - - for (ob = main->object.first; ob; ob= ob->id.next) { + + for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; ListBase *list; list = &ob->constraints; @@ -2298,23 +2394,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { switch (curcon->type) { case CONSTRAINT_TYPE_MINMAX: { bMinMaxConstraint *data = curcon->data; - if (data->sticky==1) + if (data->sticky == 1) data->flag |= MINMAX_STICKY; - else + else data->flag &= ~MINMAX_STICKY; } break; case CONSTRAINT_TYPE_ROTLIKE: { bRotateLikeConstraint *data = curcon->data; - + /* version patch from buttons_object.c */ - if (data->flag==0) + if (data->flag == 0) data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; } break; @@ -2326,184 +2422,186 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + 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; - } + { + 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; + { + 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; - } + { + 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) { + 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; + 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; + + 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) + 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; + + 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; + 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; + 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); + 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; + 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; + 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) { + 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) + 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) + 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) { + + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + 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; + 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; + 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; + 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) { + 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 (sce->toolsettings->jointrilimit == 0.0f) + sce->toolsettings->jointrilimit = 0.8f; } } } + if (main->versionfile <= 243) { - Object *ob= main->object.first; + 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; + 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_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; + 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) { + + for (; ob; ob = ob->id.next) { bDeformGroup *curdef; - - for (curdef= ob->defbase.first; curdef; curdef=curdef->next) { + + 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); @@ -2514,8 +2612,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Mirror) { MirrorModifierData *mmd = (MirrorModifierData*) md; switch (mmd->axis) { @@ -2535,40 +2633,40 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + /* 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) + 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) + 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) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - sa= sc->areabase.first; + 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; - + 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; } @@ -2577,29 +2675,30 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - if (main->versionfile != 244 || main->subversionfile < 3) { + + 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) { + + 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) { + + 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; @@ -2613,69 +2712,69 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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)) ) + 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) { + 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) { + 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; - + bLocLimitConstraint *data = (bLocLimitConstraint *) curcon->data; + /* old limit without parent option for objects */ if (data->flag2) curcon->ownspace = CONSTRAINT_SPACE_LOCAL; } - break; - } + 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) { + + 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) { + 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; - + 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; + } + break; } } - + /* correctly initialize constinv matrix */ unit_m4(pchan->constinv); } @@ -2683,44 +2782,44 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + /* 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) { + 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) { + 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); + ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches); - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + 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) { + 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); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); } - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Cloth) { + 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); + 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) { + for (me = main->mesh.first; me; me = me->id.next) { if (me->mr && !me->mr->verts) { MultiresLevel *lvl = me->mr->levels.last; if (lvl) { @@ -2734,99 +2833,99 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + 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; - + 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) { + } + + 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->gloss_mir = ma->gloss_tra = 1.0f; ma->aniso_gloss_mir = 1.0f; - ma->samp_gloss_mir = ma->samp_gloss_tra= 18; + 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; + 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; + 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; + 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) { + for (wrld = main->world.first; wrld; wrld = wrld->id.next) { if (wrld->ao_approx_error == 0.0f) - wrld->ao_approx_error= 0.25f; + wrld->ao_approx_error = 0.25f; } - for (sce= main->scene.first; sce; sce= sce->id.next) { + 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; + 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; + sce->r.cineonblack = 95; + sce->r.cineonwhite = 685; + sce->r.cineongamma = 1.7f; } } - for (ntree=main->nodetree.first; ntree; ntree= ntree->id.next) + 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) { + 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) { + 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); + 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 - * */ + + /* sanity check for skgen */ { Scene *sce; - for (sce=main->scene.first; sce; sce = sce->id.next) { + 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]) @@ -2837,30 +2936,29 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + 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; + 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) + + 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; + + 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; } } } @@ -2868,55 +2966,55 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + 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) { + 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) { + + 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) { + 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; + bPythonConstraint *data = (bPythonConstraint *)con->data; if (data->tar) { /* version patching needs to be done */ - ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - + 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'; + data->subtarget[0] = '\0'; } } else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; - + bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; + /* new headtail functionality makes Bone-Tip function obsolete */ if (data->flag & LOCLIKE_TIP) con->headtail = 1.0f; @@ -2924,29 +3022,29 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - - for (con=ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data= (bPythonConstraint *)con->data; + + 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 = 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'; + data->subtarget[0] = '\0'; } } else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; - + bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; + /* new headtail functionality makes Bone-Tip function obsolete */ if (data->flag & LOCLIKE_TIP) con->headtail = 1.0f; @@ -2957,7 +3055,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) SoftBody *sb = ob->soft; int k; - for (k=0; ktotkey; k++) { + for (k = 0; k < sb->totkey; k++) { if (sb->keys[k]) MEM_freeN(sb->keys[k]); } @@ -2973,14 +3071,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) { Scene *sce; Object *ob; - PartEff *paf=NULL; + PartEff *paf = NULL; - for (ob = main->object.first; ob; ob= ob->id.next) { + 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++) { + for (k = 0; k < sb->totkey; k++) { if (sb->keys[k]) MEM_freeN(sb->keys[k]); } @@ -3003,23 +3101,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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.lib = ob->id.lib; part->id.us--; part->id.flag |= (ob->id.flag & LIB_NEEDLINK); - - psys->totpart=0; - psys->flag= PSYS_ENABLED|PSYS_CURRENT; + + psys->totpart = 0; + psys->flag = PSYS_ENABLED|PSYS_CURRENT; BLI_addtail(&ob->particlesystem, psys); - md= modifier_new(eModifierType_ParticleSystem); + md = modifier_new(eModifierType_ParticleSystem); BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); - psmd= (ParticleSystemModifierData*) md; - psmd->psys=psys; + psmd = (ParticleSystemModifierData*) md; + psmd->psys = psys; BLI_addtail(&ob->modifiers, md); /* convert settings from old particle system */ @@ -3067,7 +3165,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } 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; @@ -3084,7 +3182,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (ob->transflag & OB_DUPLIVERTS) { Object *dup = main->object.first; - for (; dup; dup= dup->id.next) { + for (; dup; dup = dup->id.next) { if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) { part->dup_ob = dup; ob->transflag |= OB_DUPLIPARTS; @@ -3098,7 +3196,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE) @@ -3111,24 +3208,24 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (sce= main->scene.first; sce; sce=sce->id.next) { - ParticleEditSettings *pset= &sce->toolsettings->particle; + 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; + 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; + for (a = 0; a < PE_TOT_BRUSH; a++) { + pset->brush[a].strength = 50; + pset->brush[a].size = 50; + pset->brush[a].step = 10; } - pset->brush[PE_BRUSH_CUT].strength= 100; + pset->brush[PE_BRUSH_CUT].strength = 100; } } } @@ -3136,45 +3233,47 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Material *ma; int a; - for (ma=main->mat.first; ma; ma= ma->id.next) + 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) + 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) { + + /* 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; + repeat = 1.0f; else - repeat= strip->repeat; - + repeat = strip->repeat; + length = strip->end-strip->start; - if (length == 0.0f) length= 1.0f; + 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 (strip->scale == 0.0f) + strip->scale = 1.0f; + } if (ob->soft) { ob->soft->inpush = ob->soft->inspring; - ob->soft->shearstiff = 1.0f; + ob->soft->shearstiff = 1.0f; } } } @@ -3182,8 +3281,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) { Scene *sce; Sequence *seq; - - for (sce=main->scene.first; sce; sce=sce->id.next) { + + for (sce = main->scene.first; sce; sce = sce->id.next) { SEQ_BEGIN (sce->ed, seq) { if (seq->blend_mode == 0) @@ -3192,8 +3291,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) SEQ_END } } - - /*fix broken group lengths in id properties*/ + + /* 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); @@ -3220,7 +3319,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) idproperties_fix_group_lengths(main->action); idproperties_fix_group_lengths(main->nodetree); idproperties_fix_group_lengths(main->brush); - idproperties_fix_group_lengths(main->particle); + idproperties_fix_group_lengths(main->particle); } /* sun/sky */ @@ -3229,10 +3328,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + 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; + bObjectActuator *ba = act->data; ba->drot[0] = -ba->drot[0]; ba->drot[1] = -ba->drot[1]; @@ -3241,39 +3340,39 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - - // convert fluids to modifier + + /* 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) { + + 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) + 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) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) ob->pd->f_noise = 0.0f; } @@ -3281,7 +3380,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) { Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { ob->gameflag |= OB_COLLISION; ob->margin = 0.06f; } @@ -3289,9 +3388,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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 + 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 */ @@ -3299,23 +3398,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } 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; + 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) { + + 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 @@ -3328,13 +3427,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } + /* 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) { + + 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) { @@ -3346,21 +3446,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } 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; + 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) { + + 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); @@ -3376,7 +3477,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 248) { Lamp *la; - for (la=main->lamp.first; la; la= la->id.next) { + 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; @@ -3395,9 +3496,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->toolsettings->imapaint.seam_bleed = 2; sce->toolsettings->imapaint.normal_angle = 80; @@ -3417,47 +3518,48 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { + + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { + + 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; - } + { + SpaceAction *sact = (SpaceAction *)sl; + + sact->mode = SACTCONT_DOPESHEET; + sact->autosnap = SACTSNAP_FRAME; + } break; case SPACE_IPO: - { - SpaceIpo *sipo= (SpaceIpo *)sl; - sipo->autosnap= SACTSNAP_FRAME; - } + { + SpaceIpo *sipo = (SpaceIpo *)sl; + sipo->autosnap = SACTSNAP_FRAME; + } break; case SPACE_NLA: - { - SpaceNla *snla= (SpaceNla *)sl; - snla->autosnap= SACTSNAP_FRAME; - } + { + SpaceNla *snla = (SpaceNla *)sl; + snla->autosnap = SACTSNAP_FRAME; + } break; } } @@ -3469,18 +3571,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Object *ob; /* Adjustments needed after Bullets update */ - for (ob = main->object.first; ob; ob= ob->id.next) { + 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) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->r.domeangle = 180; sce->r.domemode = 1; sce->r.domeres = 4; @@ -3488,7 +3590,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sce->r.dometilt = 0; } /* DBVT culling by default */ - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + for (wrld = main->world.first; wrld; wrld = wrld->id.next) { wrld->mode |= WO_DBVT_CULLING; wrld->occlusionRes = 128; } @@ -3497,12 +3599,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) 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 + for (ob = main->object.first; ob; ob = ob->id.next) { + /* pad3 is used for m_contactProcessingThreshold */ + ob->m_contactProcessingThreshold = 1.0f; 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); + 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); } @@ -3512,31 +3615,31 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + 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 + + /* 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) { + 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; + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer())) + 1) % 128; } - + } if (main->versionfile < 249 && main->subversionfile < 2) { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; Sequence *seq; Editing *ed; - + while (sce) { - ed= sce->ed; + ed = sce->ed; if (ed) { SEQP_BEGIN (ed, seq) { @@ -3546,15 +3649,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } SEQ_END } - - sce= sce->id.next; + + 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 c7b20e79cdd055cb9f42d39764f868f0c48e60a2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 06:38:41 +0000 Subject: [PATCH 119/143] Style cleanup: rename BKE_metaball* to BKE_mball -- mball is more commonly used term in Blender --- source/blender/blenkernel/BKE_mball.h | 36 +++++++-------- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/displist.c | 10 ++--- source/blender/blenkernel/intern/library.c | 6 +-- source/blender/blenkernel/intern/mball.c | 44 +++++++++---------- source/blender/blenkernel/intern/object.c | 6 +-- source/blender/editors/metaball/mball_edit.c | 2 +- source/blender/editors/object/object_add.c | 4 +- source/blender/editors/object/object_edit.c | 2 +- .../blender/editors/object/object_relations.c | 2 +- .../blender/editors/object/object_transform.c | 6 +-- .../blender/editors/space_view3d/drawobject.c | 8 ++-- source/blender/makesrna/intern/rna_main_api.c | 2 +- source/blender/makesrna/intern/rna_meta.c | 4 +- .../blender/makesrna/intern/rna_object_api.c | 2 +- .../render/intern/source/convertblender.c | 6 +-- .../windowmanager/intern/wm_init_exit.c | 2 +- 17 files changed, 72 insertions(+), 72 deletions(-) diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 8a35690442d..356f2c8901c 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -37,30 +37,30 @@ struct Object; struct Scene; struct MetaElem; -void BKE_metaball_unlink(struct MetaBall *mb); -void BKE_metaball_free(struct MetaBall *mb); -struct MetaBall *BKE_metaball_add(const char *name); -struct MetaBall *BKE_metaball_copy(struct MetaBall *mb); +void BKE_mball_unlink(struct MetaBall *mb); +void BKE_mball_free(struct MetaBall *mb); +struct MetaBall *BKE_mball_add(const char *name); +struct MetaBall *BKE_mball_copy(struct MetaBall *mb); -void BKE_metaball_make_local(struct MetaBall *mb); +void BKE_mball_make_local(struct MetaBall *mb); -void BKE_metaball_cubeTable_free(void); +void BKE_mball_cubeTable_free(void); -void BKE_metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -int BKE_metaball_is_basis_for(struct Object *ob1, struct Object *ob2); -int BKE_metaball_is_basis(struct Object *ob); -struct Object *BKE_metaball_basis_find(struct Scene *scene, struct Object *ob); +void BKE_mball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +int BKE_mball_is_basis_for(struct Object *ob1, struct Object *ob2); +int BKE_mball_is_basis(struct Object *ob); +struct Object *BKE_mball_basis_find(struct Scene *scene, struct Object *ob); -void BKE_metaball_texspace_calc(struct Object *ob); -float *BKE_metaball_make_orco(struct Object *ob, struct ListBase *dispbase); +void BKE_mball_texspace_calc(struct Object *ob); +float *BKE_mball_make_orco(struct Object *ob, struct ListBase *dispbase); -void BKE_metaball_properties_copy(struct Scene *scene, struct Object *active_object); +void BKE_mball_properties_copy(struct Scene *scene, struct Object *active_object); -int BKE_metaball_minmax(struct MetaBall *mb, float min[3], float max[3]); -int BKE_metaball_center_median(struct MetaBall *mb, float cent[3]); -int BKE_metaball_center_bounds(struct MetaBall *mb, float cent[3]); -void BKE_metaball_translate(struct MetaBall *mb, float offset[3]); +int BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]); +int BKE_mball_center_median(struct MetaBall *mb, float cent[3]); +int BKE_mball_center_bounds(struct MetaBall *mb, float cent[3]); +void BKE_mball_translate(struct MetaBall *mb, float offset[3]); -struct MetaElem *BKE_metaball_element_add(struct MetaBall *mb, const int type); +struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type); #endif diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 51f8815fbd1..fc54ea6eed5 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -540,7 +540,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O break; case OB_MBALL: { - Object *mom = BKE_metaball_basis_find(scene, ob); + Object *mom = BKE_mball_basis_find(scene, ob); if (mom != ob) { node2 = dag_get_node(dag, mom); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index d74a688f121..f43a133c339 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -672,9 +672,9 @@ void makeDispListMBall(Scene *scene, Object *ob) freedisplist(&(ob->disp)); if (ob->type == OB_MBALL) { - if (ob == BKE_metaball_basis_find(scene, ob)) { - BKE_metaball_polygonize(scene, ob, &ob->disp); - BKE_metaball_texspace_calc(ob); + if (ob == BKE_mball_basis_find(scene, ob)) { + BKE_mball_polygonize(scene, ob, &ob->disp); + BKE_mball_texspace_calc(ob); object_deform_mball(ob, &ob->disp); } @@ -685,8 +685,8 @@ void makeDispListMBall(Scene *scene, Object *ob) void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) { - BKE_metaball_polygonize(scene, ob, dispbase); - BKE_metaball_texspace_calc(ob); + BKE_mball_polygonize(scene, ob, dispbase); + BKE_mball_texspace_calc(ob); object_deform_mball(ob, dispbase); } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index a6f7a204004..25e34bf1879 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -203,7 +203,7 @@ int id_make_local(ID *id, int test) } return 1; case ID_MB: - if (!test) BKE_metaball_make_local((MetaBall *)id); + if (!test) BKE_mball_make_local((MetaBall *)id); return 1; case ID_MA: if (!test) BKE_material_make_local((Material *)id); @@ -294,7 +294,7 @@ int id_copy(ID *id, ID **newid, int test) 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_mball_copy((MetaBall *)id); return 1; case ID_MA: if (!test) *newid = (ID *)BKE_material_copy((Material *)id); @@ -813,7 +813,7 @@ void BKE_libblock_free(ListBase *lb, void *idv) BKE_curve_free((Curve *)id); break; case ID_MB: - BKE_metaball_free((MetaBall *)id); + BKE_mball_free((MetaBall *)id); break; case ID_MA: BKE_material_free((Material *)id); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index ba0efe5fbba..5da54b497be 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -173,7 +173,7 @@ static MetaElem **mainb; static octal_tree *metaball_tree = NULL; /* Functions */ -void BKE_metaball_unlink(MetaBall *mb) +void BKE_mball_unlink(MetaBall *mb) { int a; @@ -185,9 +185,9 @@ void BKE_metaball_unlink(MetaBall *mb) /* do not free mball itself */ -void BKE_metaball_free(MetaBall *mb) +void BKE_mball_free(MetaBall *mb) { - BKE_metaball_unlink(mb); + BKE_mball_unlink(mb); if (mb->adt) { BKE_free_animdata((ID *)mb); @@ -199,7 +199,7 @@ void BKE_metaball_free(MetaBall *mb) if (mb->disp.first) freedisplist(&mb->disp); } -MetaBall *BKE_metaball_add(const char *name) +MetaBall *BKE_mball_add(const char *name) { MetaBall *mb; @@ -215,7 +215,7 @@ MetaBall *BKE_metaball_add(const char *name) return mb; } -MetaBall *BKE_metaball_copy(MetaBall *mb) +MetaBall *BKE_mball_copy(MetaBall *mb) { MetaBall *mbn; int a; @@ -243,7 +243,7 @@ static void extern_local_mball(MetaBall *mb) } } -void BKE_metaball_make_local(MetaBall *mb) +void BKE_mball_make_local(MetaBall *mb) { Main *bmain = G.main; Object *ob; @@ -274,7 +274,7 @@ void BKE_metaball_make_local(MetaBall *mb) extern_local_mball(mb); } else if (is_local && is_lib) { - MetaBall *mb_new = BKE_metaball_copy(mb); + MetaBall *mb_new = BKE_mball_copy(mb); mb_new->id.us = 0; /* Remap paths of new ID using old library as base. */ @@ -294,7 +294,7 @@ void BKE_metaball_make_local(MetaBall *mb) /* most simple meta-element adding function * don't do context manipulation here (rna uses) */ -MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) +MetaElem *BKE_mball_element_add(MetaBall *mb, const int type) { MetaElem *ml = MEM_callocN(sizeof(MetaElem), "metaelem"); @@ -346,7 +346,7 @@ MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) * basic MetaBall (usually with name Meta). All other MetaBalls (with * names Meta.001, Meta.002, etc) are included in this Bounding Box. */ -void BKE_metaball_texspace_calc(Object *ob) +void BKE_mball_texspace_calc(Object *ob) { DispList *dl; BoundBox *bb; @@ -390,7 +390,7 @@ void BKE_metaball_texspace_calc(Object *ob) BKE_boundbox_init_from_minmax(bb, min, max); } -float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) +float *BKE_mball_make_orco(Object *ob, ListBase *dispbase) { BoundBox *bb; DispList *dl; @@ -442,7 +442,7 @@ float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) * It test last character of Object ID name. If last character * is digit it return 0, else it return 1. */ -int BKE_metaball_is_basis(Object *ob) +int BKE_mball_is_basis(Object *ob) { int len; @@ -453,7 +453,7 @@ int BKE_metaball_is_basis(Object *ob) } /* return nonzero if ob1 is a basis mball for ob */ -int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) +int BKE_mball_is_basis_for(Object *ob1, Object *ob2) { int basis1nr, basis2nr; char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; @@ -461,7 +461,7 @@ int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.'); BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.'); - if (!strcmp(basis1name, basis2name)) return BKE_metaball_is_basis(ob1); + if (!strcmp(basis1name, basis2name)) return BKE_mball_is_basis(ob1); else return 0; } @@ -471,7 +471,7 @@ int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) * are copied to all metaballs in same "group" (metaballs with same base name: MBall, * MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball, * because this metaball influence polygonisation of metaballs. */ -void BKE_metaball_properties_copy(Scene *scene, Object *active_object) +void BKE_mball_properties_copy(Scene *scene, Object *active_object) { Scene *sce_iter = scene; Base *base; @@ -516,7 +516,7 @@ void BKE_metaball_properties_copy(Scene *scene, Object *active_object) * * warning!, is_basis_mball() can fail on returned object, see long note above. */ -Object *BKE_metaball_basis_find(Scene *scene, Object *basis) +Object *BKE_mball_basis_find(Scene *scene, Object *basis) { Scene *sce_iter = scene; Base *base; @@ -1174,7 +1174,7 @@ static void makecubetable(void) } } -void BKE_metaball_cubeTable_free(void) +void BKE_mball_cubeTable_free(void) { int i; INTLISTS *lists, *nlists; @@ -2277,7 +2277,7 @@ static void init_metaball_octal_tree(int depth) subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth); } -void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) +void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) { PROCESS mbproc; MetaBall *mb; @@ -2390,7 +2390,7 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) } /* basic vertex data functions */ -int BKE_metaball_minmax(MetaBall *mb, float min[3], float max[3]) +int BKE_mball_minmax(MetaBall *mb, float min[3], float max[3]) { MetaElem *ml; @@ -2403,7 +2403,7 @@ int BKE_metaball_minmax(MetaBall *mb, float min[3], float max[3]) return (mb->elems.first != NULL); } -int BKE_metaball_center_median(MetaBall *mb, float cent[3]) +int BKE_mball_center_median(MetaBall *mb, float cent[3]) { MetaElem *ml; int total = 0; @@ -2420,11 +2420,11 @@ int BKE_metaball_center_median(MetaBall *mb, float cent[3]) return (total != 0); } -int BKE_metaball_center_bounds(MetaBall *mb, float cent[3]) +int BKE_mball_center_bounds(MetaBall *mb, float cent[3]) { float min[3], max[3]; - if (BKE_metaball_minmax(mb, min, max)) { + if (BKE_mball_minmax(mb, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } @@ -2432,7 +2432,7 @@ int BKE_metaball_center_bounds(MetaBall *mb, float cent[3]) return 0; } -void BKE_metaball_translate(MetaBall *mb, float offset[3]) +void BKE_mball_translate(MetaBall *mb, float offset[3]) { MetaElem *ml; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bf279040760..282ce5cf349 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -301,7 +301,7 @@ void BKE_object_free(Object *ob) if (id->us == 0) { if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data); else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data); - else if (ob->type == OB_MBALL) BKE_metaball_unlink(ob->data); + else if (ob->type == OB_MBALL) BKE_mball_unlink(ob->data); } ob->data = NULL; } @@ -440,7 +440,7 @@ void BKE_object_unlink(Object *ob) } } else if (ELEM(OB_MBALL, ob->type, obt->type)) { - if (BKE_metaball_is_basis_for(obt, ob)) + if (BKE_mball_is_basis_for(obt, ob)) obt->recalc |= OB_RECALC_DATA; } @@ -734,7 +734,7 @@ void *BKE_object_obdata_add_from_type(int type) 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_MBALL: return BKE_mball_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"); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index fd842ce4f7c..1653a084bf2 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -111,7 +111,7 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNU ml= ml->next; } - ml= BKE_metaball_element_add(mball, type); + ml= BKE_mball_element_add(mball, type); copy_v3_v3(&ml->x, mat[3]); ml->flag |= SELECT; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 9506836ab82..5a2370eb518 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1479,7 +1479,7 @@ static int convert_exec(bContext *C, wmOperator *op) base->flag &= ~SELECT; ob->flag &= ~SELECT; - baseob = BKE_metaball_basis_find(scene, ob); + baseob = BKE_mball_basis_find(scene, ob); if (ob != baseob) { /* if motherball is converting it would be marked as done later */ @@ -1736,7 +1736,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_MBALL) { ID_NEW_US2(obn->data) else { - obn->data = BKE_metaball_copy(obn->data); + obn->data = BKE_mball_copy(obn->data); didit = 1; } id->us--; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 96099d51dc9..d062ea549cb 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -749,7 +749,7 @@ static void copy_texture_space(Object *to, Object *ob) /* pass */ } else if (to->type == OB_MBALL) { - BKE_metaball_texspace_calc(to); + BKE_mball_texspace_calc(to); } else { BKE_curve_texspace_calc(to->data); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index d31e0b69473..9d4f6326278 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1495,7 +1495,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) // ipo_idnew(me->key->ipo); /* drivers */ break; case OB_MBALL: - ob->data = BKE_metaball_copy(ob->data); + ob->data = BKE_mball_copy(ob->data); break; case OB_CURVE: case OB_SURF: diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 4825697f8c3..34395163ad3 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -867,11 +867,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) MetaBall *mb = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } - else { BKE_metaball_center_bounds(mb, cent); } + else if (around == V3D_CENTROID) { BKE_mball_center_median(mb, cent); } + else { BKE_mball_center_bounds(mb, cent); } negate_v3_v3(cent_neg, cent); - BKE_metaball_translate(mb, cent_neg); + BKE_mball_translate(mb, cent_neg); tot_change++; mb->id.flag |= LIB_DOIT; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b1f86fa5e69..466e9886f19 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3982,7 +3982,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas break; case OB_MBALL: - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { lb = &ob->disp; if (lb->first == NULL) makeDispListMBall(scene, ob); if (lb->first == NULL) return 1; @@ -6159,7 +6159,7 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) bb = ob->bb ? ob->bb : ( (Curve *)ob->data)->bb; } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { bb = ob->bb; if (bb == NULL) { makeDispListMBall(scene, ob); @@ -6250,7 +6250,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { if ((base->flag & OB_FROMDUPLI) == 0) drawDispListwire(&ob->disp); } @@ -6310,7 +6310,7 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { drawDispListwire(&ob->disp); } } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 0451d7c239c..76cd8279beb 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -329,7 +329,7 @@ void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) { - MetaBall *mb = BKE_metaball_add(name); + MetaBall *mb = BKE_mball_add(name); id_us_min(&mb->id); return mb; } diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index f7ef0c5c89a..eda38a43d54 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -99,7 +99,7 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) if (mb->id.us > 0) { for (ob = bmain->object.first; ob; ob = ob->id.next) if (ob->data == mb) - BKE_metaball_properties_copy(scene, ob); + BKE_mball_properties_copy(scene, ob); DAG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, mb); @@ -115,7 +115,7 @@ static void rna_MetaBall_update_rotation(Main *bmain, Scene *scene, PointerRNA * static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type) { - MetaElem *ml = BKE_metaball_element_add(mb, type); + MetaElem *ml = BKE_mball_element_add(mb, type); /* cheating way for importers to avoid slow updates */ if (mb->id.us > 0) { diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index f7531e1b556..f58471797e4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -124,7 +124,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ case OB_MBALL: { /* metaballs don't have modifiers, so just convert to mesh */ - Object *basis_ob = BKE_metaball_basis_find(sce, ob); + Object *basis_ob = BKE_mball_basis_find(sce, ob); /* todo, re-generatre for render-res */ /* metaball_polygonize(scene, ob) */ diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 8d2456b3001..c1d60760004 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2437,7 +2437,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) int a, need_orco, vlakindex, *index, negative_scale; ListBase dispbase= {NULL, NULL}; - if (ob!=BKE_metaball_basis_find(re->scene, ob)) + if (ob!=BKE_mball_basis_find(re->scene, ob)) return; mult_m4_m4m4(mat, re->viewmat, ob->obmat); @@ -2463,7 +2463,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) if (!orco) { /* orco hasn't been found in cache - create new one and add to cache */ - orco= BKE_metaball_make_orco(ob, &dispbase); + orco= BKE_mball_make_orco(ob, &dispbase); set_object_orco(re, ob, orco); } } @@ -4725,7 +4725,7 @@ static int allow_render_object(Render *re, Object *ob, int nolamps, int onlysele return 0; /* don't add non-basic meta objects, ends up having renderobjects with no geometry */ - if (ob->type == OB_MBALL && ob!=BKE_metaball_basis_find(re->scene, ob)) + if (ob->type == OB_MBALL && ob!=BKE_mball_basis_find(re->scene, ob)) return 0; if (nolamps && (ob->type==OB_LAMP)) diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 1a1cb9d6507..ab377d53ec7 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -364,7 +364,7 @@ void WM_exit_ext(bContext *C, const short do_python) free_openrecent(); - BKE_metaball_cubeTable_free(); + BKE_mball_cubeTable_free(); ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ From 3ef11693f56429239771f8c043bf2fe2838a5fc7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 06:58:03 +0000 Subject: [PATCH 120/143] Style cleanup: displist module --- source/blender/blenkernel/BKE_displist.h | 37 +- .../blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/constraint.c | 10 +- source/blender/blenkernel/intern/curve.c | 12 +- source/blender/blenkernel/intern/displist.c | 453 ++++++++++-------- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/lattice.c | 8 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/object.c | 10 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/collada/MeshImporter.cpp | 4 +- source/blender/editors/mesh/editmesh_select.c | 4 +- source/blender/editors/object/object_add.c | 10 +- .../blender/editors/object/object_modifier.c | 4 +- .../blender/editors/object/object_relations.c | 2 +- .../blender/editors/space_info/info_stats.c | 4 +- .../blender/editors/space_view3d/drawobject.c | 20 +- .../blender/makesrna/intern/rna_object_api.c | 6 +- source/blender/modifiers/intern/MOD_array.c | 2 +- .../python/mathutils/mathutils_geometry.c | 12 +- .../render/intern/source/convertblender.c | 18 +- 24 files changed, 336 insertions(+), 294 deletions(-) diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index c5684e83903..cb8ddbf0b00 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -78,29 +78,28 @@ typedef struct DispList { unsigned int *bevelSplitFlag; } DispList; -extern void copy_displist(struct ListBase *lbn, struct ListBase *lb); -extern void free_disp_elem(DispList *dl); -extern DispList *find_displist_create(struct ListBase *lb, int type); -extern DispList *find_displist(struct ListBase *lb, int type); -extern void addnormalsDispList(struct ListBase *lb); -extern void count_displist(struct ListBase *lb, int *totvert, int *totface); -extern void freedisplist(struct ListBase *lb); -extern int displist_has_faces(struct ListBase *lb); +void BKE_displist_copy(struct ListBase *lbn, struct ListBase *lb); +void BKE_displist_elem_free(DispList *dl); +DispList *BKE_displist_find_or_create(struct ListBase *lb, int type); +DispList *BKE_displist_find(struct ListBase *lb, int type); +void BKE_displist_normals_add(struct ListBase *lb); +void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface); +void BKE_displist_free(struct ListBase *lb); +int BKE_displist_has_faces(struct ListBase *lb); -extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); -extern void makeDispListCurveTypes(struct Scene *scene, struct Object *ob, int forOrco); -extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); -extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -extern void makeDispListMBall(struct Scene *scene, struct Object *ob); -extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); +void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, int forOrco); +void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); +void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +void BKE_displist_make_mball(struct Scene *scene, struct Object *ob); +void BKE_displist_make_mball_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); -void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); +int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); +void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, int flipnormal); -float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); +float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *makeOrcoDispList(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender); +float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender); #endif - diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 2024a5ce091..a814ca81beb 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2097,7 +2097,7 @@ static void clear_mesh_caches(Object *ob) me->bb = NULL; } - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); if (ob->derivedFinal) { ob->derivedFinal->needsFree = 1; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 1f4259c6d86..09b295aabf1 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1818,7 +1818,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos /* only happens on reload file, but violates depsgraph still... fix! */ if ((cu->path == NULL) || (cu->path->data == NULL)) - makeDispListCurveTypes(scene, ikData->tar, 0); + BKE_displist_make_curveTypes(scene, ikData->tar, 0); } /* find the root bone and the chain of bones from the root to the tip diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index eed5ec49012..868da0fda94 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -516,7 +516,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m { Lattice *lt = (Lattice *)ob->data; - DispList *dl = find_displist(&ob->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&ob->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; BPoint *bp = lt->def; @@ -1234,7 +1234,7 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra /* only happens on reload file, but violates depsgraph still... fix! */ if (cu->path == NULL || cu->path->data == NULL) - makeDispListCurveTypes(cob->scene, ct->tar, 0); + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); if (cu->path && cu->path->data) { float quat[4]; @@ -2007,7 +2007,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa /* this check is to make sure curve objects get updated on file load correctly.*/ if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ - makeDispListCurveTypes(cob->scene, ct->tar, 0); + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* firstly calculate the matrix the normal way, then let the py-function override @@ -3090,7 +3090,7 @@ static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bCo /* only happens on reload file, but violates depsgraph still... fix! */ if (cu->path == NULL || cu->path->data == NULL) - makeDispListCurveTypes(cob->scene, ct->tar, 0); + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* technically, this isn't really needed for evaluation, but we don't know what else @@ -3720,7 +3720,7 @@ static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bC /* only happens on reload file, but violates depsgraph still... fix! */ if (cu->path == NULL || cu->path->data == NULL) - makeDispListCurveTypes(cob->scene, ct->tar, 0); + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* technically, this isn't really needed for evaluation, but we don't know what else diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 190d9f654f6..45dbf96fd60 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -136,7 +136,7 @@ void BKE_curve_free(Curve *cu) { BKE_nurbList_free(&cu->nurb); BLI_freelistN(&cu->bev); - freedisplist(&cu->disp); + BKE_displist_free(&cu->disp); BKE_curve_editfont_free(cu); BKE_curve_editNurb_free(cu); @@ -1234,7 +1234,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) float *fp, *coord_array; ListBase disp = {NULL, NULL}; - makeDispListCurveTypes_forOrco(scene, ob, &disp); + BKE_displist_make_curveTypes_forOrco(scene, ob, &disp); numVerts = 0; for (dl = disp.first; dl; dl = dl->next) { @@ -1306,7 +1306,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) } } - freedisplist(&disp); + BKE_displist_free(&disp); return coord_array; } @@ -1337,13 +1337,13 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende facy = cu->bevobj->size[1]; if (forRender) { - makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); + BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); dl = bevdisp.first; } else { dl = cu->bevobj->disp.first; if (dl == NULL) { - makeDispListCurveTypes(scene, cu->bevobj, 0); + BKE_displist_make_curveTypes(scene, cu->bevobj, 0); dl = cu->bevobj->disp.first; } } @@ -1370,7 +1370,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende dl = dl->next; } - freedisplist(&bevdisp); + BKE_displist_free(&bevdisp); } } else if (cu->ext1 == 0.0f && cu->ext2 == 0.0f) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index f43a133c339..8b4d699006d 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -64,7 +64,7 @@ static void boundbox_displist(Object *ob); -void free_disp_elem(DispList *dl) +void BKE_displist_elem_free(DispList *dl) { if (dl) { if (dl->verts) MEM_freeN(dl->verts); @@ -77,25 +77,26 @@ void free_disp_elem(DispList *dl) } } -void freedisplist(ListBase *lb) +void BKE_displist_free(ListBase *lb) { DispList *dl; dl = lb->first; while (dl) { BLI_remlink(lb, dl); - free_disp_elem(dl); + BKE_displist_elem_free(dl); dl = lb->first; } } -DispList *find_displist_create(ListBase *lb, int type) +DispList *BKE_displist_find_or_create(ListBase *lb, int type) { DispList *dl; - + dl = lb->first; while (dl) { - if (dl->type == type) return dl; + if (dl->type == type) + return dl; dl = dl->next; } @@ -106,39 +107,41 @@ DispList *find_displist_create(ListBase *lb, int type) return dl; } -DispList *find_displist(ListBase *lb, int type) +DispList *BKE_displist_find(ListBase *lb, int type) { DispList *dl; - + dl = lb->first; while (dl) { - if (dl->type == type) return dl; + if (dl->type == type) + return dl; dl = dl->next; } return NULL; } -int displist_has_faces(ListBase *lb) +int BKE_displist_has_faces(ListBase *lb) { DispList *dl; + for (dl = lb->first; dl; dl = dl->next) { if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { - return 1; + return TRUE; } } - return 0; + + return FALSE; } -void copy_displist(ListBase *lbn, ListBase *lb) +void BKE_displist_copy(ListBase *lbn, ListBase *lb) { DispList *dln, *dl; - - freedisplist(lbn); - + + BKE_displist_free(lbn); + dl = lb->first; while (dl) { - dln = MEM_dupallocN(dl); BLI_addtail(lbn, dln); dln->verts = MEM_dupallocN(dl->verts); @@ -154,7 +157,7 @@ void copy_displist(ListBase *lbn, ListBase *lb) } } -void addnormalsDispList(ListBase *lb) +void BKE_displist_normals_add(ListBase *lb) { DispList *dl = NULL; float *vdata, *ndata, nor[3]; @@ -162,29 +165,31 @@ void addnormalsDispList(ListBase *lb) float *n1, *n2, *n3, *n4; int a, b, p1, p2, p3, p4; - dl = lb->first; - + while (dl) { if (dl->type == DL_INDEX3) { if (dl->nors == NULL) { dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors"); - if (dl->verts[2] < 0.0f) dl->nors[2] = -1.0f; - else dl->nors[2] = 1.0f; + + if (dl->verts[2] < 0.0f) + dl->nors[2] = -1.0f; + else + dl->nors[2] = 1.0f; } } else if (dl->type == DL_SURF) { if (dl->nors == NULL) { dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors"); - + vdata = dl->verts; ndata = dl->nors; - + for (a = 0; a < dl->parts; a++) { - - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0) + + if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - + v1 = vdata + 3 * p1; n1 = ndata + 3 * p1; v2 = vdata + 3 * p2; @@ -193,16 +198,15 @@ void addnormalsDispList(ListBase *lb) n3 = ndata + 3 * p3; v4 = vdata + 3 * p4; n4 = ndata + 3 * p4; - + for (; b < dl->nr; b++) { - normal_quad_v3(nor, v1, v3, v4, v2); - + add_v3_v3(n1, nor); add_v3_v3(n2, nor); add_v3_v3(n3, nor); add_v3_v3(n4, nor); - + v2 = v1; v1 += 3; v4 = v3; v3 += 3; n2 = n1; n1 += 3; @@ -221,13 +225,12 @@ void addnormalsDispList(ListBase *lb) } } -void count_displist(ListBase *lb, int *totvert, int *totface) +void BKE_displist_count(ListBase *lb, int *totvert, int *totface) { DispList *dl; - + dl = lb->first; while (dl) { - switch (dl->type) { case DL_SURF: *totvert += dl->nr * dl->parts; @@ -241,18 +244,19 @@ void count_displist(ListBase *lb, int *totvert, int *totface) case DL_POLY: case DL_SEGM: *totvert += dl->nr * dl->parts; + break; } - + dl = dl->next; } } -int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) +int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) { if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) { return 0; } - + if (dl->flag & DL_CYCL_U) { (*p1) = dl->nr * a; (*p2) = (*p1) + dl->nr - 1; @@ -267,12 +271,12 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i (*p3) = (*p1) + dl->nr; (*b) = 1; } - - if ( (dl->flag & DL_CYCL_V) && a == dl->parts - 1) { + + if ((dl->flag & DL_CYCL_V) && a == dl->parts - 1) { (*p3) -= dl->nr * dl->parts; (*p4) -= dl->nr * dl->parts; } - + return 1; } @@ -286,19 +290,17 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i BPoint *bp; float *data; int a, len, resolu; - + nu = nubase->first; while (nu) { if (nu->hide == 0) { - if (forRender && cu->resolu_ren != 0) resolu = cu->resolu_ren; else resolu = nu->resolu; - + if (!BKE_nurb_check_valid_u(nu)) ; else if (nu->type == CU_BEZIER) { - /* count */ len = 0; a = nu->pntsu - 1; @@ -307,17 +309,21 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i prevbezt = nu->bezt; bezt = prevbezt + 1; while (a--) { - if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) bezt = nu->bezt; - - if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) len++; - else len += resolu; - - if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) len++; - + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) + bezt = nu->bezt; + + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) + len++; + else + len += resolu; + + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) + len++; + prevbezt = bezt; bezt++; } - + dl = MEM_callocN(sizeof(DispList), "makeDispListbez"); /* len+1 because of 'forward_diff_bezier' function */ dl->verts = MEM_callocN((len + 1) * 3 * sizeof(float), "dlverts"); @@ -337,13 +343,14 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i dl->type = DL_SEGM; a = nu->pntsu - 1; } - + prevbezt = nu->bezt; bezt = prevbezt + 1; - + while (a--) { - if (a == 0 && dl->type == DL_POLY) bezt = nu->bezt; - + if (a == 0 && dl->type == DL_POLY) + bezt = nu->bezt; + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { copy_v3_v3(data, prevbezt->vec[1]); data += 3; @@ -357,32 +364,33 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i bezt->vec[1][j], data + j, resolu, 3 * sizeof(float)); } - + data += 3 * resolu; } - + if (a == 0 && dl->type == DL_SEGM) { copy_v3_v3(data, bezt->vec[1]); } - + prevbezt = bezt; bezt++; } } else if (nu->type == CU_NURBS) { len = (resolu * SEGMENTSU(nu)); - + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); dl->parts = 1; - + dl->nr = len; dl->col = nu->mat_nr; dl->charidx = nu->charidx; data = dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + if (nu->flagu & CU_NURB_CYCLIC) + dl->type = DL_POLY; else dl->type = DL_SEGM; BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } @@ -399,7 +407,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i data = dl->verts; if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; else dl->type = DL_SEGM; - + a = len; bp = nu->bp; while (a--) { @@ -414,7 +422,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i } -void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) +void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal) { ScanFillContext sf_ctx; ScanFillVert *eve, *v1, *vlast; @@ -423,36 +431,39 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) float *f1; int colnr = 0, charidx = 0, cont = 1, tot, a, *index, nextcol = 0; intptr_t totvert; - - if (dispbase == NULL) return; - if (dispbase->first == NULL) return; + + if (dispbase == NULL) + return; + if (dispbase->first == NULL) + return; while (cont) { cont = 0; totvert = 0; nextcol = 0; - + BLI_scanfill_begin(&sf_ctx); - + dl = dispbase->first; while (dl) { - if (dl->type == DL_POLY) { - if (charidx < dl->charidx) cont = 1; + if (charidx < dl->charidx) + cont = 1; else if (charidx == dl->charidx) { /* character with needed index */ if (colnr == dl->col) { /* make editverts and edges */ f1 = dl->verts; a = dl->nr; eve = v1 = NULL; - + while (a--) { vlast = eve; eve = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; - if (vlast == NULL) v1 = eve; + if (vlast == NULL) + v1 = eve; else { BLI_scanfill_edge_add(&sf_ctx, vlast, eve); } @@ -472,7 +483,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) } dl = dl->next; } - + 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"); @@ -483,7 +494,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex"); dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts"); - + /* vert data */ f1 = dlnew->verts; totvert = 0; @@ -491,14 +502,14 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) while (eve) { copy_v3_v3(f1, eve->co); f1 += 3; - + /* index number */ eve->tmp.l = totvert; totvert++; - + eve = eve->next; } - + /* index data */ efa = sf_ctx.fillfacebase.first; index = dlnew->index; @@ -509,14 +520,13 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) if (flipnormal) SWAP(int, index[0], index[2]); - + index += 3; efa = efa->next; } } BLI_addhead(to, dlnew); - } BLI_scanfill_end(&sf_ctx); @@ -530,9 +540,8 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) colnr = 0; } } - + /* do not free polys, needed for wireframe display */ - } static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) @@ -541,14 +550,14 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) DispList *dl, *dlnew; float *fp, *fp1; int a, dpoly; - + front.first = front.last = back.first = back.last = NULL; - + dl = dispbase->first; while (dl) { if (dl->type == DL_SURF) { - if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { - if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) { + if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { + if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) { dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&front, dlnew); dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); @@ -557,10 +566,10 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) dlnew->type = DL_POLY; dlnew->col = dl->col; dlnew->charidx = dl->charidx; - + fp = dl->verts; dpoly = 3 * dl->nr; - + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); @@ -568,7 +577,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) fp += dpoly; } } - if ( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) { + if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) { dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&back, dlnew); dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); @@ -577,10 +586,10 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) dlnew->type = DL_POLY; dlnew->col = dl->col; dlnew->charidx = dl->charidx; - + fp = dl->verts + 3 * (dl->nr - 1); dpoly = 3 * dl->nr; - + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); @@ -593,25 +602,25 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) dl = dl->next; } - filldisplist(&front, dispbase, 1); - filldisplist(&back, dispbase, 0); - - freedisplist(&front); - freedisplist(&back); + BKE_displist_fill(&front, dispbase, 1); + BKE_displist_fill(&back, dispbase, 0); - filldisplist(dispbase, dispbase, 0); - + BKE_displist_free(&front); + BKE_displist_free(&back); + + BKE_displist_fill(dispbase, dispbase, 0); } static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dispbase) { - if (cu->flag & CU_3D) return; + if (cu->flag & CU_3D) + return; if (dispbase->first && ((DispList *) dispbase->first)->type == DL_SURF) { bevels_to_filledpoly(cu, dispbase); } else { - filldisplist(dispbase, dispbase, 0); + BKE_displist_fill(dispbase, dispbase, 0); } } @@ -620,30 +629,30 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis * - first point left, last point right * - based on subdivided points in original curve, not on points in taper curve (still) */ -float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) +float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot) { DispList *dl; - - if (taperobj == NULL || taperobj->type != OB_CURVE) return 1.0; - + + if (taperobj == NULL || taperobj->type != OB_CURVE) + return 1.0; + dl = taperobj->disp.first; if (dl == NULL) { - makeDispListCurveTypes(scene, taperobj, 0); + BKE_displist_make_curveTypes(scene, taperobj, 0); dl = taperobj->disp.first; } if (dl) { float fac = ((float)cur) / (float)(tot - 1); float minx, dx, *fp; int a; - + /* horizontal size */ minx = dl->verts[0]; dx = dl->verts[3 * (dl->nr - 1)] - minx; if (dx > 0.0f) { - fp = dl->verts; for (a = 0; a < dl->nr; a++, fp += 3) { - if ( (fp[0] - minx) / dx >= fac) { + if ((fp[0] - minx) / dx >= fac) { /* interpolate with prev */ if (a > 0) { float fac1 = (fp[-3] - minx) / dx; @@ -657,19 +666,22 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) return fp[-2]; // last y coord } } - + return 1.0; } -void makeDispListMBall(Scene *scene, Object *ob) +void BKE_displist_make_mball(Scene *scene, Object *ob) { - if (!ob || ob->type != OB_MBALL) return; + if (!ob || ob->type != OB_MBALL) + return; - // XXX: mball stuff uses plenty of global variables - // while this is unchanged updating during render is unsafe - if (G.rendering) return; + /* XXX: mball stuff uses plenty of global variables + * while this is unchanged updating during render is unsafe + */ + if (G.rendering) + return; - freedisplist(&(ob->disp)); + BKE_displist_free(&(ob->disp)); if (ob->type == OB_MBALL) { if (ob == BKE_mball_basis_find(scene, ob)) { @@ -679,15 +691,15 @@ void makeDispListMBall(Scene *scene, Object *ob) object_deform_mball(ob, &ob->disp); } } - + boundbox_displist(ob); } -void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) +void BKE_displist_make_mball_forRender(Scene *scene, Object *ob, ListBase *dispbase) { BKE_mball_polygonize(scene, ob, dispbase); BKE_mball_texspace_calc(ob); - + object_deform_mball(ob, dispbase); } @@ -697,24 +709,30 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo ModifierData *pretessellatePoint; int required_mode; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) + required_mode = eModifierMode_Render; + else + required_mode = eModifierMode_Realtime; - if (editmode) required_mode |= eModifierMode_Editmode; + if (editmode) + required_mode |= eModifierMode_Editmode; pretessellatePoint = NULL; for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (!modifier_isEnabled(scene, md, required_mode)) continue; - if (mti->type == eModifierTypeType_Constructive) return pretessellatePoint; + if (!modifier_isEnabled(scene, md, required_mode)) + continue; + if (mti->type == eModifierTypeType_Constructive) + return pretessellatePoint; if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { pretessellatePoint = md; /* this modifiers are moving point of tessellation automatically * (some of them even can't be applied on tessellated curve), set flag - * for incformation button in modifier's header */ + * for incformation button in modifier's header + */ md->mode |= eModifierMode_ApplyOnSpline; } else if (md->mode & eModifierMode_ApplyOnSpline) { @@ -738,12 +756,15 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl float *keyVerts = NULL; int required_mode; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) + required_mode = eModifierMode_Render; + else + required_mode = eModifierMode_Realtime; pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); - - if (editmode) required_mode |= eModifierMode_Editmode; + + if (editmode) + required_mode |= eModifierMode_Editmode; if (cu->editnurb == NULL) { keyVerts = do_ob_key(scene, ob); @@ -758,16 +779,19 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl numVerts = BKE_nurbList_verts_count_without_handles(nurb); } } - + if (pretessellatePoint) { for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); md->scene = scene; - - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type != eModifierTypeType_OnlyDeform) continue; + + if ((md->mode & required_mode) != required_mode) + continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) + continue; + if (mti->type != eModifierTypeType_OnlyDeform) + continue; if (!deformedVerts) { deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts); @@ -828,8 +852,8 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3]) } } -static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) +static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, DerivedMesh **derivedFinal, + int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; @@ -841,12 +865,15 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba float (*vertCos)[3] = NULL; int useCache = !forRender; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) + required_mode = eModifierMode_Render; + else + required_mode = eModifierMode_Realtime; pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); - - if (editmode) required_mode |= eModifierMode_Editmode; + + if (editmode) + required_mode |= eModifierMode_Editmode; if (pretessellatePoint) { md = pretessellatePoint->next; @@ -861,8 +888,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba md->scene = scene; - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; + if ((md->mode & required_mode) != required_mode) + continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) + continue; if (mti->type == eModifierTypeType_OnlyDeform || (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { @@ -885,9 +914,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } else { if (!derivedFinal) { - /* makeDisplistCurveTypes could be used for beveling, where derived mesh */ - /* is totally unnecessary, so we could stop modifiers applying */ - /* when we found constructive modifier but derived mesh is unwanted result */ + /* makeDisplistCurveTypes could be used for beveling, where derived mesh + * is totally unnecessary, so we could stop modifiers applying + * when we found constructive modifier but derived mesh is unwanted result + */ break; } @@ -951,7 +981,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba } if (derivedFinal) { - if (dm) DM_ensure_tessface(dm); /* needed for drawing */ + if (dm) + DM_ensure_tessface(dm); /* needed for drawing */ (*derivedFinal) = dm; } @@ -966,30 +997,28 @@ static void displist_surf_indices(DispList *dl) { int a, b, p1, p2, p3, p4; int *index; - + dl->totindex = 0; - + index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1), "index array nurbs"); - + for (a = 0; a < dl->parts; a++) { - - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4) == 0) + + if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - + for (; b < dl->nr; b++, index += 4) { index[0] = p1; index[1] = p2; index[2] = p4; index[3] = p3; - + dl->totindex++; - + p2 = p1; p1++; p4 = p3; p3++; - } } - } static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) @@ -998,10 +1027,10 @@ static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) ListBase disp = {NULL, NULL}; /* OrcoDM should be created from underformed disp lists */ - makeDispListCurveTypes_forOrco(scene, ob, &disp); + BKE_displist_make_curveTypes_forOrco(scene, ob, &disp); dm = CDDM_from_curve_customDB(ob, &disp); - freedisplist(&disp); + BKE_displist_free(&disp); return dm; } @@ -1043,8 +1072,9 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) { - /* this function represents logic of mesh's orcodm calculation */ - /* for displist-based objects */ + /* this function represents logic of mesh's orcodm calculation + * for displist-based objects + */ ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; @@ -1053,12 +1083,15 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina int editmode = (!forRender && cu->editnurb); DerivedMesh *ndm, *orcodm = NULL; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) + required_mode = eModifierMode_Render; + else + required_mode = eModifierMode_Realtime; pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); - if (editmode) required_mode |= eModifierMode_Editmode; + if (editmode) + required_mode |= eModifierMode_Editmode; if (pretessellatePoint) { md = pretessellatePoint->next; @@ -1069,9 +1102,12 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina md->scene = scene; - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type != eModifierTypeType_Constructive) continue; + if ((md->mode & required_mode) != required_mode) + continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) + continue; + if (mti->type != eModifierTypeType_Constructive) + continue; if (!orcodm) orcodm = create_orco_dm(scene, ob); @@ -1094,8 +1130,8 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina orcodm->release(orcodm); } -void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) +void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forRender, int forOrco) { ListBase *nubase; Nurb *nu; @@ -1120,8 +1156,10 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int resolu = nu->resolu, resolv = nu->resolv; if (forRender) { - if (cu->resolu_ren) resolu = cu->resolu_ren; - if (cu->resolv_ren) resolv = cu->resolv_ren; + if (cu->resolu_ren) + resolu = cu->resolu_ren; + if (cu->resolv_ren) + resolv = cu->resolv_ren; } if (nu->pntsv == 1) { @@ -1148,7 +1186,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, } else { len = (nu->pntsu * resolu) * (nu->pntsv * resolv); - + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); @@ -1169,7 +1207,7 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, if (nu->flagu & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_V; BKE_nurb_makeFaces(nu, data, 0, resolu, resolv); - + /* gl array drawing: using indices */ displist_surf_indices(dl); } @@ -1179,15 +1217,16 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, /* make copy of 'undeformed" displist for texture space calculation * actually, it's not totally undeformed -- pre-tessellation modifiers are * already applied, thats how it worked for years, so keep for compatibility (sergey) */ - copy_displist(&cu->disp, dispbase); + BKE_displist_copy(&cu->disp, dispbase); if (!forRender) { BKE_curve_texspace_calc(cu); } - if (!forOrco) + if (!forOrco) { curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); + } } static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r) @@ -1255,7 +1294,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; if (ob->type == OB_SURF) { - makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco); + BKE_displist_make_surf(scene, ob, dispbase, derivedFinal, forRender, forOrco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { ListBase dlbev; @@ -1271,9 +1310,11 @@ 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_vfont_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); + if (!forOrco) + curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); BKE_curve_bevelList_make(ob); @@ -1355,9 +1396,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl = MEM_callocN(sizeof(DispList), "makeDispListbev1"); dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr * steps, "dlverts"); BLI_addtail(dispbase, dl); - + dl->type = DL_SURF; - + 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; @@ -1372,7 +1413,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl->rt = nu->flag & ~CU_2D; dl->bevelSplitFlag = MEM_callocN(sizeof(*dl->col2) * ((steps + 0x1F) >> 5), "bevelSplitFlag"); - + /* for each point of poly make a bevel piece */ bevp = (BevPoint *)(bl + 1) + start; for (i = start, a = 0; a < steps; i++, bevp++, a++) { @@ -1384,13 +1425,13 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba fac = bevp->radius; } else { - fac = calc_taper(scene, cu->taperobj, i, bl->nr); + fac = BKE_displist_calc_taper(scene, cu->taperobj, i, bl->nr); } if (bevp->split_tag) { dl->bevelSplitFlag[a >> 5] |= 1 << (a & 0x1F); } - + /* rotate bevel piece and write in data */ rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); @@ -1415,7 +1456,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { - if (a == 1) + if (a == 1) fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase); if (a == steps - 1) fillBevelCap(nu, dlb, cur_data, &top_capbase); @@ -1427,34 +1468,36 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (bottom_capbase.first) { - filldisplist(&bottom_capbase, dispbase, 1); - filldisplist(&top_capbase, dispbase, 0); - freedisplist(&bottom_capbase); - freedisplist(&top_capbase); + BKE_displist_fill(&bottom_capbase, dispbase, 1); + BKE_displist_fill(&top_capbase, dispbase, 0); + BKE_displist_free(&bottom_capbase); + BKE_displist_free(&top_capbase); } } } } - freedisplist(&dlbev); + BKE_displist_free(&dlbev); } if (!(cu->flag & CU_DEFORM_FILL)) { curve_to_filledpoly(cu, nubase, dispbase); } - if ((cu->flag & CU_PATH) && !forOrco) calc_curvepath(ob); + if ((cu->flag & CU_PATH) && !forOrco) + calc_curvepath(ob); /* make copy of 'undeformed" displist for texture space calculation * actually, it's not totally undeformed -- pre-tessellation modifiers are * already applied, thats how it worked for years, so keep for compatibility (sergey) */ - copy_displist(&cu->disp, dispbase); + BKE_displist_copy(&cu->disp, dispbase); if (!forRender) { BKE_curve_texspace_calc(cu); } - if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); + if (!forOrco) + curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) { curve_to_filledpoly(cu, nubase, dispbase); @@ -1462,7 +1505,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } } -void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) +void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco) { Curve *cu = ob->data; ListBase *dispbase; @@ -1470,14 +1513,15 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) /* The same check for duplis as in do_makeDispListCurveTypes. * Happens when curve used for constraint/bevel was converted to mesh. * check there is still needed for render displist and orco displists. */ - if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; + if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) + return; - freedisplist(&(ob->disp)); + BKE_displist_free(&(ob->disp)); dispbase = &(ob->disp); - freedisplist(dispbase); + BKE_displist_free(dispbase); /* free displist used for textspace */ - freedisplist(&cu->disp); + BKE_displist_free(&cu->disp); do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); @@ -1495,19 +1539,19 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) } } -void makeDispListCurveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, +void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, DerivedMesh **derivedFinal, int forOrco) { do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco); } -void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) +void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) { do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1); } /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) +float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) { float *orco; @@ -1535,7 +1579,7 @@ static void boundbox_displist(Object *ob) DispList *dl; float *vert; int a, tot = 0; - + INIT_MINMAX(min, max); if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { @@ -1544,13 +1588,13 @@ static void boundbox_displist(Object *ob) if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); bb = cu->bb; - + dl = ob->disp.first; while (dl) { if (dl->type == DL_INDEX3) tot = dl->nr; else tot = dl->nr * dl->parts; - + vert = dl->verts; for (a = 0; a < tot; a++, vert += 3) { doit = 1; @@ -1559,17 +1603,16 @@ static void boundbox_displist(Object *ob) dl = dl->next; } - + if (!doit) { /* there's no geometry in displist, use zero-sized boundbox */ zero_v3(min); zero_v3(max); } - + } - + if (bb) { BKE_boundbox_init_from_minmax(bb, min, max); } } - diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 4024deee1e8..1d109d5f616 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -181,7 +181,7 @@ static void precalculate_effector(EffectorCache *eff) Curve *cu= eff->ob->data; if (cu->flag & CU_PATH) { if (cu->path==NULL || cu->path->data==NULL) - makeDispListCurveTypes(eff->scene, eff->ob, 0); + BKE_displist_make_curveTypes(eff->scene, eff->ob, 0); if (cu->path && cu->path->data) { where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 0ec0c16073b..fda078f5c42 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -846,7 +846,7 @@ makebreak: cucu->flag |= (CU_PATH + CU_FOLLOW); - if (cucu->path == NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0); + if (cucu->path == NULL) BKE_displist_make_curveTypes(scene, cu->textoncurve, 0); if (cucu->path) { float distfac, imat[4][4], imat3[3][3], cmat[3][3]; float minx, maxx, miny, maxy; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 4076031fa18..8ac8acf6edf 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -149,7 +149,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) lt->typeu = lt->typev = lt->typew = KEY_LINEAR; /* prevent using deformed locations */ - freedisplist(<Ob->disp); + BKE_displist_free(<Ob->disp); copy_m4_m4(mat, ltOb->obmat); unit_m4(ltOb->obmat); @@ -294,7 +294,7 @@ void init_latt_deform(Object *oblatt, Object *ob) /* we make an array with all differences */ Lattice *lt = oblatt->data; BPoint *bp; - DispList *dl = find_displist(&oblatt->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&oblatt->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; float *fp, imat[4][4]; float fu, fv, fw; @@ -541,7 +541,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3], /* to be sure, mostly after file load */ if (cu->path == NULL) { - makeDispListCurveTypes(scene, par, 0); + BKE_displist_make_curveTypes(scene, par, 0); if (cu->path == NULL) return 0; // happens on append... } @@ -963,7 +963,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) float (*vertexCos)[3] = NULL; int numVerts, editmode = (lt->editlatt != NULL); - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 7507442a4d5..0eeb16be699 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1172,7 +1172,7 @@ int object_remove_material_slot(Object *ob) /* check indices from mesh */ if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) { data_delete_material_index_id((ID *)ob->data, actcol - 1); - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); } return TRUE; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 5da54b497be..8075aaa21d3 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -196,7 +196,7 @@ void BKE_mball_free(MetaBall *mb) if (mb->mat) MEM_freeN(mb->mat); if (mb->bb) MEM_freeN(mb->bb); BLI_freelistN(&mb->elems); - if (mb->disp.first) freedisplist(&mb->disp); + if (mb->disp.first) BKE_displist_free(&mb->disp); } MetaBall *BKE_mball_add(const char *name) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 282ce5cf349..e43c0999698 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -242,7 +242,7 @@ void BKE_object_free_display(Object *ob) ob->derivedFinal = NULL; } - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); } void free_sculptsession_deformMats(SculptSession *ss) @@ -1638,7 +1638,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) cu = par->data; if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ - makeDispListCurveTypes(scene, par, 0); + BKE_displist_make_curveTypes(scene, par, 0); if (cu->path == NULL) return; /* catch exceptions: feature for nla stride editing */ @@ -1846,7 +1846,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) else if (par->type == OB_LATTICE) { Lattice *latt = par->data; BPoint *bp; - DispList *dl = find_displist(&par->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&par->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; if (latt->editlatt) latt = latt->editlatt->latt; @@ -2593,13 +2593,13 @@ void BKE_object_handle_update(Scene *scene, Object *ob) break; case OB_MBALL: - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); break; case OB_CURVE: case OB_SURF: case OB_FONT: - makeDispListCurveTypes(scene, ob, 0); + BKE_displist_make_curveTypes(scene, ob, 0); break; case OB_LATTICE: diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a254e892289..8676a3e75a0 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2188,7 +2188,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) /* curve taper */ if (cu->taperobj) - mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100)); + mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100)); else { /* curve size*/ if (cu->flag & CU_PATH_RADIUS) { diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 9ce0ce6c3a2..73d1f42b340 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -346,7 +346,7 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve vert += 3; } - filldisplist(&dispbase, &dispbase, 0); + BKE_displist_fill(&dispbase, &dispbase, 0); int tottri = 0; dl= (DispList*)dispbase.first; @@ -368,7 +368,7 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve } } - freedisplist(&dispbase); + BKE_displist_free(&dispbase); return tottri; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index d38ec6436b9..2d403d03fb2 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -150,7 +150,7 @@ static void draw_triangulated(int mcords[][2], short tot) } /* do the fill */ - filldisplist(&lb, &lb, 0); + BKE_displist_fill(&lb, &lb, 0); /* do the draw */ dl = lb.first; /* filldisplist adds in head of list */ @@ -170,7 +170,7 @@ static void draw_triangulated(int mcords[][2], short tot) glEnd(); } - freedisplist(&lb); + BKE_displist_free(&lb); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 5a2370eb518..466338a736f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1239,7 +1239,7 @@ static EnumPropertyItem convert_target_items[] = { static void curvetomesh(Scene *scene, Object *ob) { if (ob->disp.first == NULL) - makeDispListCurveTypes(scene, ob, 0); /* force creation */ + BKE_displist_make_curveTypes(scene, ob, 0); /* force creation */ BKE_mesh_from_nurbs(ob); /* also does users */ @@ -1405,7 +1405,7 @@ static int convert_exec(bContext *C, wmOperator *op) cu = newob->data; if (!newob->disp.first) - makeDispListCurveTypes(scene, newob, 0); + BKE_displist_make_curveTypes(scene, newob, 0); newob->type = OB_CURVE; cu->type = OB_CURVE; @@ -1446,7 +1446,7 @@ static int convert_exec(bContext *C, wmOperator *op) curvetomesh(scene, newob); /* meshes doesn't use displist */ - freedisplist(&newob->disp); + BKE_displist_free(&newob->disp); } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { @@ -1467,7 +1467,7 @@ static int convert_exec(bContext *C, wmOperator *op) newob = ob; /* meshes doesn't use displist */ - freedisplist(&newob->disp); + BKE_displist_free(&newob->disp); } curvetomesh(scene, newob); @@ -1487,7 +1487,7 @@ static int convert_exec(bContext *C, wmOperator *op) } if (!baseob->disp.first) { - makeDispListMBall(scene, baseob); + BKE_displist_make_mball(scene, baseob); } if (!(baseob->flag & OB_DONE)) { diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index f6bf9ba2f15..17f4ea73d6d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1372,10 +1372,10 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) BKE_lattice_modifiers_calc(scene, ob); } else if (ob->type == OB_MBALL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - makeDispListCurveTypes(scene, ob, 0); + BKE_displist_make_curveTypes(scene, ob, 0); } mmd->bindfunc = NULL; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 9d4f6326278..b3e16c8d4eb 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -533,7 +533,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object if ((cu->flag & CU_PATH) == 0) { cu->flag |= CU_PATH | CU_FOLLOW; - makeDispListCurveTypes(scene, par, 0); /* force creation of path data */ + BKE_displist_make_curveTypes(scene, par, 0); /* force creation of path data */ } else cu->flag |= CU_FOLLOW; diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 0cc212f9c34..7870e64228a 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -107,7 +107,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totcurve += totob; if (ob->disp.first) - count_displist(&ob->disp, &tot, &totf); + BKE_displist_count(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; @@ -124,7 +124,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) case OB_MBALL: { int tot = 0, totf = 0; - count_displist(&ob->disp, &tot, &totf); + BKE_displist_count(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 466e9886f19..f93d4bea94d 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1924,7 +1924,7 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo Object *obedit = vc->obedit; Lattice *lt = obedit->data; BPoint *bp = lt->editlatt->latt->def; - DispList *dl = find_displist(&obedit->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; short s[2] = {IS_CLIPPED, 0}; @@ -1972,7 +1972,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) BKE_lattice_modifiers_calc(scene, ob); - dl = find_displist(&ob->disp, DL_VERTS); + dl = BKE_displist_find(&ob->disp, DL_VERTS); if (is_edit) { lt = lt->editlatt->latt; @@ -3917,10 +3917,10 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); index3_nors_incr = 0; - if (displist_has_faces(lb) == 0) { + if (BKE_displist_has_faces(lb) == 0) { if (!render_only) { draw_index_wire = 0; drawDispListwire(lb); @@ -3948,7 +3948,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas index3_nors_incr = 1; } else { - if (!render_only || (render_only && displist_has_faces(lb))) { + if (!render_only || (render_only && BKE_displist_has_faces(lb))) { draw_index_wire = 0; retval = drawDispListwire(lb); draw_index_wire = 1; @@ -3963,7 +3963,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); @@ -3984,7 +3984,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas if (BKE_mball_is_basis(ob)) { lb = &ob->disp; - if (lb->first == NULL) makeDispListMBall(scene, ob); + if (lb->first == NULL) BKE_displist_make_mball(scene, ob); if (lb->first == NULL) return 1; if (solid) { @@ -6162,7 +6162,7 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) if (BKE_mball_is_basis(ob)) { bb = ob->bb; if (bb == NULL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); bb = ob->bb; } } @@ -6235,7 +6235,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) hasfaces = dm->getNumTessFaces(dm); } else { - hasfaces = displist_has_faces(&ob->disp); + hasfaces = BKE_displist_has_faces(&ob->disp); } if (hasfaces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -6574,7 +6574,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* bad exception, solve this! otherwise outline shows too late */ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); + if (ob->disp.first == NULL) BKE_displist_make_curveTypes(scene, ob, 0); } /* draw outline for selected objects, mesh does itself */ diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index f58471797e4..7ed0304ebb4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -105,7 +105,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ copycu->editnurb = tmpcu->editnurb; /* get updated display list, and convert to a mesh */ - makeDispListCurveTypes(sce, tmpobj, 0); + BKE_displist_make_curveTypes(sce, tmpobj, 0); copycu->editfont = NULL; copycu->editnurb = NULL; @@ -135,9 +135,9 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ if (render) { ListBase disp = {NULL, NULL}; - makeDispListMBall_forRender(sce, ob, &disp); + BKE_displist_make_mball_forRender(sce, ob, &disp); BKE_mesh_from_metaball(&disp, tmpmesh); - freedisplist(&disp); + BKE_displist_free(&disp); } else BKE_mesh_from_metaball(&ob->disp, tmpmesh); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 482f330275b..fa4c90a4eb4 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -360,7 +360,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if (!cu->path) { cu->flag |= CU_PATH; // needed for path & bevlist - makeDispListCurveTypes(scene, amd->curve_ob, 0); + BKE_displist_make_curveTypes(scene, amd->curve_ob, 0); } if (cu->path) length = scale * cu->path->totdist; diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 9e9b96a885b..c6bfeff1651 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1055,7 +1055,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject for (i = 0; i < len_polylines; i++) { polyLine = PySequence_GetItem(polyLineSeq, i); if (!PySequence_Check(polyLine)) { - freedisplist(&dispbase); + BKE_displist_free(&dispbase); Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ PyErr_SetString(PyExc_TypeError, "One or more of the polylines is not a sequence of mathutils.Vector's"); @@ -1109,7 +1109,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject } if (ls_error) { - freedisplist(&dispbase); /* possible some dl was allocated */ + BKE_displist_free(&dispbase); /* possible some dl was allocated */ PyErr_SetString(PyExc_TypeError, "A point in one of the polylines " "is not a mathutils.Vector type"); @@ -1117,7 +1117,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject } else if (totpoints) { /* now make the list to return */ - filldisplist(&dispbase, &dispbase, 0); + BKE_displist_fill(&dispbase, &dispbase, 0); /* The faces are stored in a new DisplayList * thats added to the head of the listbase */ @@ -1125,7 +1125,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject tri_list = PyList_New(dl->parts); if (!tri_list) { - freedisplist(&dispbase); + BKE_displist_free(&dispbase); PyErr_SetString(PyExc_RuntimeError, "failed to make a new list"); return NULL; @@ -1138,11 +1138,11 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject dl_face += 3; index++; } - freedisplist(&dispbase); + BKE_displist_free(&dispbase); } else { /* no points, do this so scripts don't barf */ - freedisplist(&dispbase); /* possible some dl was allocated */ + BKE_displist_free(&dispbase); /* possible some dl was allocated */ tri_list = PyList_New(0); } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c1d60760004..1fd10f83389 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2452,7 +2452,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) need_orco= 1; } - makeDispListMBall_forRender(re->scene, ob, &dispbase); + BKE_displist_make_mball_forRender(re->scene, ob, &dispbase); dl= dispbase.first; if (dl==0) return; @@ -2526,7 +2526,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) } /* enforce display lists remade */ - freedisplist(&dispbase); + BKE_displist_free(&dispbase); } /* ------------------------------------------------------------------------- */ @@ -2828,11 +2828,11 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; - makeDispListSurf(re->scene, ob, &displist, &dm, 1, 0); + BKE_displist_make_surf(re->scene, ob, &displist, &dm, 1, 0); if (dm) { if (need_orco) { - orco= makeOrcoDispList(re->scene, ob, dm, 1); + orco= BKE_displist_make_orco(re->scene, ob, dm, 1); if (orco) { set_object_orco(re, ob, orco); } @@ -2854,7 +2854,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) } } - freedisplist(&displist); + BKE_displist_free(&displist); MEM_freeN(matar); } @@ -2878,7 +2878,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (ob->type==OB_FONT && cu->str==NULL) return; else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return; - makeDispListCurveTypes_forRender(re->scene, ob, &disp, &dm, 0); + BKE_displist_make_curveTypes_forRender(re->scene, ob, &disp, &dm, 0); dl= disp.first; if (dl==NULL) return; @@ -2898,7 +2898,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (dm) { if (need_orco) { - orco= makeOrcoDispList(re->scene, ob, dm, 1); + orco= BKE_displist_make_orco(re->scene, ob, dm, 1); if (orco) { set_object_orco(re, ob, orco); } @@ -3005,7 +3005,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for (a=0; aparts; a++) { - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4)==0) break; p1+= startvert; @@ -3062,7 +3062,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } } - freedisplist(&disp); + BKE_displist_free(&disp); MEM_freeN(matar); } From c79892c5cdb74fdb6fb2534055877e5965d07850 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 08:53:59 +0000 Subject: [PATCH 121/143] Style cleanup of own modules using style checker from Campbell. --- source/blender/blenkernel/intern/curve.c | 759 ++++++++++-------- source/blender/blenkernel/intern/displist.c | 9 +- source/blender/blenkernel/intern/movieclip.c | 6 +- source/blender/blenkernel/intern/tracking.c | 161 ++-- .../blender/editors/space_clip/clip_buttons.c | 35 +- .../editors/space_clip/clip_dopesheet_draw.c | 4 +- .../editors/space_clip/clip_dopesheet_ops.c | 4 +- source/blender/editors/space_clip/clip_draw.c | 101 +-- .../blender/editors/space_clip/clip_editor.c | 11 +- .../editors/space_clip/clip_graph_draw.c | 9 +- .../editors/space_clip/clip_graph_ops.c | 18 +- source/blender/editors/space_clip/clip_ops.c | 53 +- .../blender/editors/space_clip/clip_toolbar.c | 2 +- .../blender/editors/space_clip/clip_utils.c | 13 +- .../blender/editors/space_clip/space_clip.c | 62 +- .../blender/editors/space_clip/tracking_ops.c | 321 ++++---- 16 files changed, 871 insertions(+), 697 deletions(-) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 45dbf96fd60..43cc63aefa6 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -32,7 +32,7 @@ #include // floor #include -#include +#include #include "MEM_guardedalloc.h" @@ -42,24 +42,24 @@ #include "BLI_utildefines.h" #include "BLI_ghash.h" -#include "DNA_curve_types.h" -#include "DNA_material_types.h" +#include "DNA_curve_types.h" +#include "DNA_material_types.h" /* for dereferencing pointers */ -#include "DNA_key_types.h" -#include "DNA_scene_types.h" -#include "DNA_vfont_types.h" +#include "DNA_key_types.h" +#include "DNA_scene_types.h" +#include "DNA_vfont_types.h" #include "DNA_object_types.h" #include "BKE_animsys.h" -#include "BKE_anim.h" -#include "BKE_curve.h" -#include "BKE_displist.h" -#include "BKE_font.h" -#include "BKE_global.h" -#include "BKE_key.h" -#include "BKE_library.h" -#include "BKE_main.h" +#include "BKE_anim.h" +#include "BKE_curve.h" +#include "BKE_displist.h" +#include "BKE_font.h" +#include "BKE_global.h" +#include "BKE_key.h" +#include "BKE_library.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_material.h" @@ -73,24 +73,29 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c void BKE_curve_unlink(Curve *cu) { int a; - + for (a = 0; a < cu->totcol; a++) { if (cu->mat[a]) cu->mat[a]->id.us--; cu->mat[a] = NULL; } - if (cu->vfont) cu->vfont->id.us--; + if (cu->vfont) + cu->vfont->id.us--; cu->vfont = NULL; - if (cu->vfontb) cu->vfontb->id.us--; + if (cu->vfontb) + cu->vfontb->id.us--; cu->vfontb = NULL; - if (cu->vfonti) cu->vfonti->id.us--; + if (cu->vfonti) + cu->vfonti->id.us--; cu->vfonti = NULL; - if (cu->vfontbi) cu->vfontbi->id.us--; + if (cu->vfontbi) + cu->vfontbi->id.us--; cu->vfontbi = NULL; - - if (cu->key) cu->key->id.us--; + + if (cu->key) + cu->key->id.us--; cu->key = NULL; } @@ -99,14 +104,20 @@ void BKE_curve_editfont_free(Curve *cu) { if (cu->editfont) { EditFont *ef = cu->editfont; - - if (ef->oldstr) MEM_freeN(ef->oldstr); - if (ef->oldstrinfo) MEM_freeN(ef->oldstrinfo); - if (ef->textbuf) MEM_freeN(ef->textbuf); - if (ef->textbufinfo) MEM_freeN(ef->textbufinfo); - if (ef->copybuf) MEM_freeN(ef->copybuf); - if (ef->copybufinfo) MEM_freeN(ef->copybufinfo); - + + if (ef->oldstr) + MEM_freeN(ef->oldstr); + if (ef->oldstrinfo) + MEM_freeN(ef->oldstrinfo); + if (ef->textbuf) + MEM_freeN(ef->textbuf); + if (ef->textbufinfo) + MEM_freeN(ef->textbufinfo); + if (ef->copybuf) + MEM_freeN(ef->copybuf); + if (ef->copybufinfo) + MEM_freeN(ef->copybufinfo); + MEM_freeN(ef); cu->editfont = NULL; } @@ -142,13 +153,19 @@ void BKE_curve_free(Curve *cu) BKE_curve_editNurb_free(cu); BKE_curve_unlink(cu); BKE_free_animdata((ID *)cu); - - if (cu->mat) MEM_freeN(cu->mat); - if (cu->str) MEM_freeN(cu->str); - if (cu->strinfo) MEM_freeN(cu->strinfo); - if (cu->bb) MEM_freeN(cu->bb); - if (cu->path) free_path(cu->path); - if (cu->tb) MEM_freeN(cu->tb); + + if (cu->mat) + MEM_freeN(cu->mat); + if (cu->str) + MEM_freeN(cu->str); + if (cu->strinfo) + MEM_freeN(cu->strinfo); + if (cu->bb) + MEM_freeN(cu->bb); + if (cu->path) + free_path(cu->path); + if (cu->tb) + MEM_freeN(cu->tb); } Curve *BKE_curve_add(const char *name, int type) @@ -164,10 +181,11 @@ Curve *BKE_curve_add(const char *name, int type) cu->wordspace = 1.0; cu->spacing = cu->linedist = 1.0; cu->fsize = 1.0; - cu->ulheight = 0.05; + cu->ulheight = 0.05; cu->texflag = CU_AUTOSPACE; 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... + /* XXX: this one seems to be the best one in most cases, at least for curve deform... */ + cu->twist_mode = CU_TWIST_MINIMUM; cu->type = type; cu->bevfac1 = 0.0f; cu->bevfac2 = 1.0f; @@ -185,7 +203,7 @@ Curve *BKE_curve_add(const char *name, int type) cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "textbox"); cu->tb[0].w = cu->tb[0].h = 0.0; } - + return cu; } @@ -193,7 +211,7 @@ Curve *BKE_curve_copy(Curve *cu) { Curve *cun; int a; - + cun = BKE_libblock_copy(&cu->id); cun->nurb.first = cun->nurb.last = NULL; BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); @@ -202,7 +220,7 @@ Curve *BKE_curve_copy(Curve *cu) for (a = 0; a < cun->totcol; a++) { id_us_plus((ID *)cun->mat[a]); } - + cun->str = MEM_dupallocN(cu->str); cun->strinfo = MEM_dupallocN(cu->strinfo); cun->tb = MEM_dupallocN(cu->tb); @@ -225,20 +243,20 @@ Curve *BKE_curve_copy(Curve *cu) #endif // XXX old animation system id_us_plus((ID *)cun->vfont); - id_us_plus((ID *)cun->vfontb); + id_us_plus((ID *)cun->vfontb); id_us_plus((ID *)cun->vfonti); id_us_plus((ID *)cun->vfontbi); - + return cun; } static void extern_local_curve(Curve *cu) -{ +{ id_lib_extern((ID *)cu->vfont); - id_lib_extern((ID *)cu->vfontb); + id_lib_extern((ID *)cu->vfontb); id_lib_extern((ID *)cu->vfonti); id_lib_extern((ID *)cu->vfontbi); - + if (cu->mat) { extern_local_matarar(cu->mat, cu->totcol); } @@ -249,13 +267,14 @@ void BKE_curve_make_local(Curve *cu) Main *bmain = G.main; Object *ob; int is_local = FALSE, is_lib = FALSE; - + /* - when there are only lib users: don't do * - when there are only local users: set flag * - mixed: do a copy */ - - if (cu->id.lib == NULL) return; + + if (cu->id.lib == NULL) + return; if (cu->id.us == 1) { id_clear_lib_data(bmain, &cu->id); @@ -360,15 +379,15 @@ void BKE_curve_texspace_calc(Curve *cu) BoundBox *bb; float *fp, min[3], max[3]; int tot, doit = 0; - - if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + + if (cu->bb == NULL) + cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); bb = cu->bb; - + INIT_MINMAX(min, max); dl = cu->disp.first; while (dl) { - tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts; if (tot) doit = 1; @@ -414,12 +433,14 @@ int BKE_nurbList_verts_count(ListBase *nurb) { Nurb *nu; int tot = 0; - + nu = nurb->first; while (nu) { - if (nu->bezt) tot += 3 * nu->pntsu; - else if (nu->bp) tot += nu->pntsu * nu->pntsv; - + if (nu->bezt) + tot += 3 * nu->pntsu; + else if (nu->bp) + tot += nu->pntsu * nu->pntsv; + nu = nu->next; } return tot; @@ -429,12 +450,14 @@ int BKE_nurbList_verts_count_without_handles(ListBase *nurb) { Nurb *nu; int tot = 0; - + nu = nurb->first; while (nu) { - if (nu->bezt) tot += nu->pntsu; - else if (nu->bp) tot += nu->pntsu * nu->pntsv; - + if (nu->bezt) + tot += nu->pntsu; + else if (nu->bp) + tot += nu->pntsu * nu->pntsv; + nu = nu->next; } return tot; @@ -447,13 +470,17 @@ void BKE_nurb_free(Nurb *nu) if (nu == NULL) return; - if (nu->bezt) MEM_freeN(nu->bezt); + if (nu->bezt) + MEM_freeN(nu->bezt); nu->bezt = NULL; - if (nu->bp) MEM_freeN(nu->bp); + if (nu->bp) + MEM_freeN(nu->bp); nu->bp = NULL; - if (nu->knotsu) MEM_freeN(nu->knotsu); + if (nu->knotsu) + MEM_freeN(nu->knotsu); nu->knotsu = NULL; - if (nu->knotsv) MEM_freeN(nu->knotsv); + if (nu->knotsv) + MEM_freeN(nu->knotsv); nu->knotsv = NULL; /* if (nu->trim.first) freeNurblist(&(nu->trim)); */ @@ -496,9 +523,9 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) newnu->bp = (BPoint *)MEM_mallocN((len) * sizeof(BPoint), "duplicateNurb3"); memcpy(newnu->bp, nu->bp, len * sizeof(BPoint)); - + newnu->knotsu = newnu->knotsv = NULL; - + if (nu->knotsu) { len = KNOTSU(nu); if (len) { @@ -520,14 +547,14 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2) { Nurb *nu, *nun; - + BKE_nurbList_free(lb1); - + nu = lb2->first; while (nu) { nun = BKE_nurb_duplicate(nu); BLI_addtail(lb1, nun); - + nu = nu->next; } } @@ -537,7 +564,7 @@ void BKE_nurb_test2D(Nurb *nu) BezTriple *bezt; BPoint *bp; int a; - + if ((nu->flag & CU_2D) == 0) return; @@ -643,7 +670,8 @@ static void calcknots(float *knots, const short pnts, const short order, const s k = 0.0; for (a = 1; a <= pnts_order; a++) { knots[a - 1] = k; - if (a >= order && a <= pnts) k += 1.0f; + if (a >= order && a <= pnts) + k += 1.0f; } break; case CU_NURB_BEZIER: @@ -659,7 +687,8 @@ static void calcknots(float *knots, const short pnts, const short order, const s else if (order == 3) { k = 0.6f; for (a = 0; a < pnts_order; a++) { - if (a >= order && a <= pnts) k += 0.5f; + if (a >= order && a <= pnts) + k += 0.5f; knots[a] = floorf(k); } } @@ -680,7 +709,8 @@ static void makecyclicknots(float *knots, short pnts, short order) { int a, b, order2, c; - if (knots == NULL) return; + if (knots == NULL) + return; order2 = order - 1; @@ -688,9 +718,11 @@ static void makecyclicknots(float *knots, short pnts, short order) if (order > 2) { b = pnts + order2; for (a = 1; a < order2; a++) { - if (knots[b] != knots[b - a]) break; + if (knots[b] != knots[b - a]) + break; } - if (a == order2) knots[pnts + order - 2] += 1.0f; + if (a == order2) + knots[pnts + order - 2] += 1.0f; } b = order; @@ -707,7 +739,8 @@ static void makeknots(Nurb *nu, short uv) { if (nu->type == CU_NURBS) { if (uv == 1) { - if (nu->knotsu) MEM_freeN(nu->knotsu); + if (nu->knotsu) + MEM_freeN(nu->knotsu); if (BKE_nurb_check_valid_u(nu)) { nu->knotsu = MEM_callocN(4 + sizeof(float) * KNOTSU(nu), "makeknots"); if (nu->flagu & CU_NURB_CYCLIC) { @@ -718,11 +751,12 @@ static void makeknots(Nurb *nu, short uv) calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu); } } - else nu->knotsu = NULL; - + else + nu->knotsu = NULL; } else if (uv == 2) { - if (nu->knotsv) MEM_freeN(nu->knotsv); + if (nu->knotsv) + MEM_freeN(nu->knotsv); if (BKE_nurb_check_valid_v(nu)) { nu->knotsv = MEM_callocN(4 + sizeof(float) * KNOTSV(nu), "makeknots"); if (nu->flagv & CU_NURB_CYCLIC) { @@ -757,8 +791,10 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas opp2 = orderpluspnts - 1; /* this is for float inaccuracy */ - if (t < knots[0]) t = knots[0]; - else if (t > knots[opp2]) t = knots[opp2]; + if (t < knots[0]) + t = knots[0]; + else + if (t > knots[opp2]) t = knots[opp2]; /* this part is order '1' */ o2 = order + 1; @@ -775,10 +811,11 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas } break; } - else basis[i] = 0.0; + else + basis[i] = 0.0; } basis[i] = 0.0; - + /* this is order 2, 3, ... */ for (j = 2; j <= order; j++) { @@ -819,22 +856,25 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, float u, v, ustart, uend, ustep, vstart, vend, vstep, sumdiv; int i, j, iofs, jofs, cycl, len, curu, curv; int istart, iend, jsta, jen, *jstart, *jend, ratcomp; - + int totu = nu->pntsu * resolu, totv = nu->pntsv * resolv; - - if (nu->knotsu == NULL || nu->knotsv == NULL) return; - if (nu->orderu > nu->pntsu) return; - if (nu->orderv > nu->pntsv) return; - if (coord_array == NULL) return; - + + if (nu->knotsu == NULL || nu->knotsv == NULL) + return; + if (nu->orderu > nu->pntsu) + return; + if (nu->orderv > nu->pntsv) + return; + if (coord_array == NULL) + return; + /* allocate and initialize */ len = totu * totv; - if (len == 0) return; - + if (len == 0) + return; - sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbfaces1"); - + len = totu * totv; if (len == 0) { MEM_freeN(sum); @@ -851,11 +891,13 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, } bp++; } - + fp = nu->knotsu; ustart = fp[nu->orderu - 1]; - if (nu->flagu & CU_NURB_CYCLIC) uend = fp[nu->pntsu + nu->orderu - 1]; - else uend = fp[nu->pntsu]; + if (nu->flagu & CU_NURB_CYCLIC) + uend = fp[nu->pntsu + nu->orderu - 1]; + else + uend = fp[nu->pntsu]; ustep = (uend - ustart) / ((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1); basisu = (float *)MEM_mallocN(sizeof(float) * KNOTSU(nu), "makeNurbfaces3"); @@ -863,8 +905,10 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, fp = nu->knotsv; vstart = fp[nu->orderv - 1]; - if (nu->flagv & CU_NURB_CYCLIC) vend = fp[nu->pntsv + nu->orderv - 1]; - else vend = fp[nu->pntsv]; + if (nu->flagv & CU_NURB_CYCLIC) + vend = fp[nu->pntsv + nu->orderv - 1]; + else + vend = fp[nu->pntsv]; vstep = (vend - vstart) / ((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1); len = KNOTSV(nu); @@ -873,7 +917,8 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, jend = (int *)MEM_mallocN(sizeof(float) * totv, "makeNurbfaces5"); /* precalculation of basisv and jstart, jend */ - if (nu->flagv & CU_NURB_CYCLIC) cycl = nu->orderv - 1; + if (nu->flagv & CU_NURB_CYCLIC) + cycl = nu->orderv - 1; else cycl = 0; v = vstart; basis = basisv; @@ -884,19 +929,19 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, v += vstep; } - if (nu->flagu & CU_NURB_CYCLIC) cycl = nu->orderu - 1; - else cycl = 0; + if (nu->flagu & CU_NURB_CYCLIC) + cycl = nu->orderu - 1; + else + cycl = 0; in = coord_array; u = ustart; curu = totu; while (curu--) { - basisNurb(u, nu->orderu, (short)(nu->pntsu + cycl), nu->knotsu, basisu, &istart, &iend); basis = basisv; curv = totv; while (curv--) { - jsta = jstart[curv]; jen = jend[curv]; @@ -906,26 +951,29 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, for (j = jsta; j <= jen; j++) { - if (j >= nu->pntsv) jofs = (j - nu->pntsv); - else jofs = j; + if (j >= nu->pntsv) + jofs = (j - nu->pntsv); + else + jofs = j; bp = nu->bp + nu->pntsu * jofs + istart - 1; for (i = istart; i <= iend; i++, fp++) { - if (i >= nu->pntsu) { iofs = i - nu->pntsu; bp = nu->bp + nu->pntsu * jofs + iofs; } - else bp++; + else + bp++; if (ratcomp) { *fp = basisu[i] * basis[j] * bp->vec[3]; sumdiv += *fp; } - else *fp = basisu[i] * basis[j]; + else + *fp = basisu[i] * basis[j]; } } - + if (ratcomp) { fp = sum; for (j = jsta; j <= jen; j++) { @@ -939,17 +987,19 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, fp = sum; for (j = jsta; j <= jen; j++) { - if (j >= nu->pntsv) jofs = (j - nu->pntsv); - else jofs = j; + if (j >= nu->pntsv) + jofs = (j - nu->pntsv); + else + jofs = j; bp = nu->bp + nu->pntsu * jofs + istart - 1; for (i = istart; i <= iend; i++, fp++) { - if (i >= nu->pntsu) { iofs = i - nu->pntsu; bp = nu->bp + nu->pntsu * jofs + iofs; } - else bp++; + else + bp++; if (*fp != 0.0f) { in[0] += (*fp) * bp->vec[0]; @@ -963,7 +1013,8 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, basis += KNOTSV(nu); } u += ustep; - if (rowstride != 0) in = (float *) (((unsigned char *) in) + (rowstride - 3 * totv * sizeof(*in))); + if (rowstride != 0) + in = (float *) (((unsigned char *) in) + (rowstride - 3 * totv * sizeof(*in))); } /* free */ @@ -974,7 +1025,8 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, MEM_freeN(jend); } -void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) +void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, + int resolu, int stride) /* coord_array has to be 3*4*pntsu*resolu in size and zero-ed * tilt_array and radius_array will be written to if valid */ { @@ -984,17 +1036,21 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * float *coord_fp = coord_array, *tilt_fp = tilt_array, *radius_fp = radius_array, *weight_fp = weight_array; int i, len, istart, iend, cycl; - if (nu->knotsu == NULL) return; - if (nu->orderu > nu->pntsu) return; - if (coord_array == NULL) return; + if (nu->knotsu == NULL) + return; + if (nu->orderu > nu->pntsu) + return; + if (coord_array == NULL) + return; /* allocate and initialize */ len = nu->pntsu; - if (len == 0) return; + if (len == 0) + return; sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbcurve1"); - + resolu = (resolu * SEGMENTSU(nu)); - + if (resolu == 0) { MEM_freeN(sum); return; @@ -1002,27 +1058,32 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * fp = nu->knotsu; ustart = fp[nu->orderu - 1]; - if (nu->flagu & CU_NURB_CYCLIC) uend = fp[nu->pntsu + nu->orderu - 1]; - else uend = fp[nu->pntsu]; + if (nu->flagu & CU_NURB_CYCLIC) + uend = fp[nu->pntsu + nu->orderu - 1]; + else + uend = fp[nu->pntsu]; ustep = (uend - ustart) / (resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1)); - + basisu = (float *)MEM_mallocN(sizeof(float) * KNOTSU(nu), "makeNurbcurve3"); - if (nu->flagu & CU_NURB_CYCLIC) cycl = nu->orderu - 1; - else cycl = 0; + if (nu->flagu & CU_NURB_CYCLIC) + cycl = nu->orderu - 1; + else + cycl = 0; u = ustart; while (resolu--) { - basisNurb(u, nu->orderu, (short)(nu->pntsu + cycl), nu->knotsu, basisu, &istart, &iend); + /* calc sum */ sumdiv = 0.0; fp = sum; bp = nu->bp + istart - 1; for (i = istart; i <= iend; i++, fp++) { - - if (i >= nu->pntsu) bp = nu->bp + (i - nu->pntsu); - else bp++; + if (i >= nu->pntsu) + bp = nu->bp + (i - nu->pntsu); + else + bp++; *fp = basisu[i] * bp->vec[3]; sumdiv += *fp; @@ -1039,34 +1100,36 @@ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float * fp = sum; bp = nu->bp + istart - 1; for (i = istart; i <= iend; i++, fp++) { - - if (i >= nu->pntsu) bp = nu->bp + (i - nu->pntsu); - else bp++; + if (i >= nu->pntsu) + bp = nu->bp + (i - nu->pntsu); + else + bp++; if (*fp != 0.0f) { - coord_fp[0] += (*fp) * bp->vec[0]; coord_fp[1] += (*fp) * bp->vec[1]; coord_fp[2] += (*fp) * bp->vec[2]; - + if (tilt_fp) (*tilt_fp) += (*fp) * bp->alfa; - + if (radius_fp) (*radius_fp) += (*fp) * bp->radius; if (weight_fp) (*weight_fp) += (*fp) * bp->weight; - } } coord_fp = (float *)(((char *)coord_fp) + stride); - - if (tilt_fp) tilt_fp = (float *)(((char *)tilt_fp) + stride); - if (radius_fp) radius_fp = (float *)(((char *)radius_fp) + stride); - if (weight_fp) weight_fp = (float *)(((char *)weight_fp) + stride); - + + if (tilt_fp) + tilt_fp = (float *)(((char *)tilt_fp) + stride); + if (radius_fp) + radius_fp = (float *)(((char *)radius_fp) + stride); + if (weight_fp) + weight_fp = (float *)(((char *)weight_fp) + stride); + u += ustep; } @@ -1134,7 +1197,7 @@ float *BKE_curve_surf_make_orco(Object *ob) int sizeu, sizev; int resolu, resolv; float *fp, *coord_array; - + /* first calculate the size of the datablock */ nu = cu->nurb.first; while (nu) { @@ -1149,18 +1212,18 @@ float *BKE_curve_surf_make_orco(Object *ob) resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; - + sizeu = nu->pntsu * resolu; sizev = nu->pntsv * resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; if (nu->pntsv > 1) tot += sizeu * sizev; - + nu = nu->next; } /* makeNurbfaces wants zeros */ fp = coord_array = MEM_callocN(3 * sizeof(float) * tot, "make_orco"); - + nu = cu->nurb.first; while (nu) { resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; @@ -1169,31 +1232,39 @@ float *BKE_curve_surf_make_orco(Object *ob) if (nu->pntsv > 1) { sizeu = nu->pntsu * resolu; sizev = nu->pntsv * resolv; - if (nu->flagu & CU_NURB_CYCLIC) sizeu++; - if (nu->flagv & CU_NURB_CYCLIC) sizev++; - + + if (nu->flagu & CU_NURB_CYCLIC) + sizeu++; + if (nu->flagv & CU_NURB_CYCLIC) + sizev++; + if (cu->flag & CU_UV_ORCO) { for (b = 0; b < sizeu; b++) { for (a = 0; a < sizev; a++) { - - if (sizev < 2) fp[0] = 0.0f; - else fp[0] = -1.0f + 2.0f * ((float)a) / (sizev - 1); - - if (sizeu < 2) fp[1] = 0.0f; - else fp[1] = -1.0f + 2.0f * ((float)b) / (sizeu - 1); - + + if (sizev < 2) + fp[0] = 0.0f; + else + fp[0] = -1.0f + 2.0f * ((float)a) / (sizev - 1); + + if (sizeu < 2) + fp[1] = 0.0f; + else + fp[1] = -1.0f + 2.0f * ((float)b) / (sizeu - 1); + fp[2] = 0.0; - + fp += 3; } } } else { - float *_tdata = MEM_callocN((nu->pntsu * resolu) * (nu->pntsv * resolv) * 3 * sizeof(float), "temp data"); + int size = (nu->pntsu * resolu) * (nu->pntsv * resolv) * 3 * sizeof(float); + float *_tdata = MEM_callocN(size, "temp data"); float *tdata = _tdata; - + BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv); - + for (b = 0; b < sizeu; b++) { int use_b = b; if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC)) @@ -1212,13 +1283,13 @@ float *BKE_curve_surf_make_orco(Object *ob) fp += 3; } } - + MEM_freeN(_tdata); } } nu = nu->next; } - + return coord_array; } @@ -1242,7 +1313,9 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) numVerts += dl->nr; } else if (dl->type == DL_SURF) { - /* convertblender.c uses the Surface code for creating renderfaces when cyclic U only (closed circle beveling) */ + /* convertblender.c uses the Surface code for creating renderfaces when cyclic U only + * (closed circle beveling) + */ if (dl->flag & DL_CYCL_U) { if (dl->flag & DL_CYCL_V) numVerts += (dl->parts + 1) * (dl->nr + 1); @@ -1274,14 +1347,14 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) } else if (dl->type == DL_SURF) { int sizeu = dl->nr, sizev = dl->parts; - + /* exception as handled in convertblender.c too */ if (dl->flag & DL_CYCL_U) { sizeu++; if (dl->flag & DL_CYCL_V) sizev++; } - + for (u = 0; u < sizev; u++) { for (v = 0; v < sizeu; v++, fp += 3) { if (cu->flag & CU_UV_ORCO) { @@ -1293,7 +1366,7 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) float *vert; int realv = v % dl->nr; int realu = u % dl->parts; - + vert = dl->verts + 3 * (dl->nr * realu + realv); copy_v3_v3(fp, vert); @@ -1328,7 +1401,8 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende // XXX if ( ob == obedit && ob->type == OB_FONT ) return; if (cu->bevobj) { - if (cu->bevobj->type != OB_CURVE) return; + if (cu->bevobj->type != OB_CURVE) + return; bevcu = cu->bevobj->data; if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) { @@ -1355,7 +1429,8 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende dlnew->verts = MEM_mallocN(3 * sizeof(float) * dl->parts * dl->nr, "makebevelcurve1"); memcpy(dlnew->verts, dl->verts, 3 * sizeof(float) * dl->parts * dl->nr); - if (dlnew->type == DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE); + if (dlnew->type == DL_SEGM) + dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE); BLI_addtail(disp, dlnew); fp = dlnew->verts; @@ -1392,9 +1467,8 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende fp[5] = cu->ext1; } else if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0 && cu->ext1 == 0.0f) { // we make a full round bevel in that case - nr = 4 + 2 * cu->bevresol; - + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1"); dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1"); BLI_addtail(disp, dl); @@ -1418,7 +1492,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende } else { short dnr; - + /* bevel now in three parts, for proper vertex normals */ /* part 1, back */ @@ -1448,11 +1522,11 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende fp += 3; } } - + /* part 2, sidefaces */ if (cu->ext1 != 0.0f) { nr = 2; - + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p2"); dl->verts = MEM_callocN(nr * 3 * sizeof(float), "makebevelcurve p2"); BLI_addtail(disp, dl); @@ -1470,7 +1544,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende dl = MEM_dupallocN(dl); dl->verts = MEM_dupallocN(dl->verts); BLI_addtail(disp, dl); - + fp = dl->verts; fp[1] = -fp[1]; fp[2] = -fp[2]; @@ -1478,7 +1552,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende fp[5] = -fp[5]; } } - + /* part 3, front */ if ((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) { dnr = nr = 2 + cu->bevresol; @@ -1522,7 +1596,8 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c float deler; deler = (v1[cox] - v2[cox]) * (v3[coy] - v4[coy]) - (v3[cox] - v4[cox]) * (v1[coy] - v2[coy]); - if (deler == 0.0f) return -1; + if (deler == 0.0f) + return -1; *labda = (v1[coy] - v3[coy]) * (v3[cox] - v4[cox]) - (v1[cox] - v3[cox]) * (v3[coy] - v4[coy]); *labda = -(*labda / deler); @@ -1539,7 +1614,8 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c vec[coy] = *labda * (v2[coy] - v1[coy]) + v1[coy]; if (*labda >= 0.0f && *labda <= 1.0f && *mu >= 0.0f && *mu <= 1.0f) { - if (*labda == 0.0f || *labda == 1.0f || *mu == 0.0f || *mu == 1.0f) return 1; + if (*labda == 0.0f || *labda == 1.0f || *mu == 0.0f || *mu == 1.0f) + return 1; return 2; } return 0; @@ -1593,8 +1669,9 @@ static short bevelinside(BevList *bl1, BevList *bl2) prevbevp = bevp; bevp++; } - - if ( (links & 1) && (rechts & 1) ) return 1; + + if ( (links & 1) && (rechts & 1) ) + return 1; return 0; } @@ -1609,8 +1686,10 @@ static int vergxcobev(const void *a1, const void *a2) { const struct bevelsort *x1 = a1, *x2 = a2; - if (x1->left > x2->left) return 1; - else if (x1->left < x2->left) return -1; + if (x1->left > x2->left) + return 1; + else if (x1->left < x2->left) + return -1; return 0; } @@ -1622,8 +1701,10 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si t01 = (float)sqrt(x1 * x1 + y1 * y1); t02 = (float)sqrt(x2 * x2 + y2 * y2); - if (t01 == 0.0f) t01 = 1.0f; - if (t02 == 0.0f) t02 = 1.0f; + if (t01 == 0.0f) + t01 = 1.0f; + if (t02 == 0.0f) + t02 = 1.0f; x1 /= t01; y1 /= t01; @@ -1631,11 +1712,14 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si y2 /= t02; t02 = x1 * x2 + y1 * y2; - if (fabs(t02) >= 1.0) t02 = .5 * M_PI; - else t02 = (saacos(t02)) / 2.0f; + if (fabs(t02) >= 1.0) + t02 = .5 * M_PI; + else + t02 = (saacos(t02)) / 2.0f; t02 = (float)sin(t02); - if (t02 == 0.0f) t02 = 1.0f; + if (t02 == 0.0f) + t02 = 1.0f; x3 = x1 - x2; y3 = y1 - y2; @@ -1654,69 +1738,80 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si } -static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) +static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, + float *weight_array, int resolu, int stride) { BezTriple *pprev, *next, *last; float fac, dfac, t[4]; int a; - + if (tilt_array == NULL && radius_array == NULL) return; - + last = nu->bezt + (nu->pntsu - 1); - + /* returns a point */ if (prevbezt == nu->bezt) { - if (nu->flagu & CU_NURB_CYCLIC) pprev = last; - else pprev = prevbezt; + if (nu->flagu & CU_NURB_CYCLIC) + pprev = last; + else + pprev = prevbezt; } - else pprev = prevbezt - 1; - + else + pprev = prevbezt - 1; + /* next point */ if (bezt == last) { - if (nu->flagu & CU_NURB_CYCLIC) next = nu->bezt; - else next = bezt; + if (nu->flagu & CU_NURB_CYCLIC) + next = nu->bezt; + else + next = bezt; } - else next = bezt + 1; - + else + next = bezt + 1; + fac = 0.0; dfac = 1.0f / (float)resolu; - + for (a = 0; a < resolu; a++, fac += dfac) { if (tilt_array) { if (nu->tilt_interp == KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */ - *tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa) * (3.0f * fac * fac - 2.0f * fac * fac * fac); + *tilt_array = prevbezt->alfa + + (bezt->alfa - prevbezt->alfa) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { key_curve_position_weights(fac, t, nu->tilt_interp); *tilt_array = t[0] * pprev->alfa + t[1] * prevbezt->alfa + t[2] * bezt->alfa + t[3] * next->alfa; } - - tilt_array = (float *)(((char *)tilt_array) + stride); + + tilt_array = (float *)(((char *)tilt_array) + stride); } - + if (radius_array) { if (nu->radius_interp == KEY_CU_EASE) { /* Support 2.47 ease interp * Note! - this only takes the 2 points into account, * giving much more localized results to changes in radius, sometimes you want that */ - *radius_array = prevbezt->radius + (bezt->radius - prevbezt->radius) * (3.0f * fac * fac - 2.0f * fac * fac * fac); + *radius_array = prevbezt->radius + + (bezt->radius - prevbezt->radius) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { - + /* reuse interpolation from tilt if we can */ if (tilt_array == NULL || nu->tilt_interp != nu->radius_interp) { key_curve_position_weights(fac, t, nu->radius_interp); } - *radius_array = t[0] * pprev->radius + t[1] * prevbezt->radius + t[2] * bezt->radius + t[3] * next->radius; + *radius_array = t[0] * pprev->radius + t[1] * prevbezt->radius + + t[2] * bezt->radius + t[3] * next->radius; } - - radius_array = (float *)(((char *)radius_array) + stride); + + radius_array = (float *)(((char *)radius_array) + stride); } if (weight_array) { /* basic interpolation for now, could copy tilt interp too */ - *weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight) * (3.0f * fac * fac - 2.0f * fac * fac * fac); + *weight_array = prevbezt->weight + + (bezt->weight - prevbezt->weight) * (3.0f * fac * fac - 2.0f * fac * fac * fac); weight_array = (float *)(((char *)weight_array) + stride); } @@ -1744,6 +1839,7 @@ static void bevel_list_cyclic_fix_3D(BevList *bl) copy_v3_v3(bevp->dir, bevp1->dir); copy_v3_v3(bevp->tan, bevp1->tan); } + /* utility for make_bevel_list_3D_* funcs */ static void bevel_list_calc_bisect(BevList *bl) { @@ -1814,7 +1910,6 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) int a; for (a = 0; a < smooth_iter; a++) { - bevp2 = (BevPoint *)(bl + 1); bevp1 = bevp2 + (bl->nr - 1); bevp0 = bevp1 - 1; @@ -1832,7 +1927,6 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) bevp1 = bevp2; bevp2++; nr--; - } copy_qt_qt(bevp0_quat, bevp0->quat); @@ -1853,7 +1947,6 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5); normalize_qt(bevp1->quat); - /* bevp0= bevp1; */ /* UNUSED */ bevp1 = bevp2; bevp2++; @@ -2003,7 +2096,6 @@ static void make_bevel_list_3D_tangent(BevList *bl) nr = bl->nr; while (nr--) { - cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir); normalize_v3(bevp1->tan); @@ -2023,7 +2115,6 @@ static void make_bevel_list_3D_tangent(BevList *bl) nr = bl->nr; while (nr--) { - /* make perpendicular, modify tan in place, is ok */ float cross_tmp[3]; float zero[3] = {0, 0, 0}; @@ -2060,8 +2151,6 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode) bevel_list_apply_tilt(bl); } - - /* only for 2 points */ static void make_bevel_list_segment_3D(BevList *bl) { @@ -2083,8 +2172,6 @@ static void make_bevel_list_segment_3D(BevList *bl) copy_qt_qt(bevp2->quat, bevp1->quat); } - - void BKE_curve_bevelList_make(Object *ob) { /* @@ -2103,13 +2190,13 @@ void BKE_curve_bevelList_make(Object *ob) struct bevelsort *sortdata, *sd, *sd1; int a, b, nr, poly, resolu = 0, len = 0; int do_tilt, do_radius, do_weight; - + /* this function needs an object, because of tflag and upflag */ cu = ob->data; /* do we need to calculate the radius for each point? */ /* do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 : 1; */ - + /* STEP 1: MAKE POLYS */ BLI_freelistN(&(cu->bev)); @@ -2120,14 +2207,13 @@ void BKE_curve_bevelList_make(Object *ob) else { nu = cu->nurb.first; } - + while (nu) { - /* check if we will calculate tilt data */ do_tilt = CU_DO_TILT(cu, nu); do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */ do_weight = 1; - + /* check we are a single point? also check we are not a surface and that the orderu is sane, * enforced in the UI but can go wrong possibly */ if (!BKE_nurb_check_valid_u(nu)) { @@ -2140,19 +2226,19 @@ void BKE_curve_bevelList_make(Object *ob) resolu = cu->resolu_ren; else resolu = nu->resolu; - + if (nu->type == CU_POLY) { len = nu->pntsu; bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList2"); BLI_addtail(&(cu->bev), bl); - + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; else bl->poly = -1; bl->nr = len; bl->dupe_nr = 0; bevp = (BevPoint *)(bl + 1); bp = nu->bp; - + while (len--) { copy_v3_v3(bevp->vec, bp->vec); bevp->alfa = bp->alfa; @@ -2164,15 +2250,15 @@ void BKE_curve_bevelList_make(Object *ob) } } else if (nu->type == CU_BEZIER) { - - len = resolu * (nu->pntsu + (nu->flagu & CU_NURB_CYCLIC) - 1) + 1; /* in case last point is not cyclic */ + /* in case last point is not cyclic */ + len = resolu * (nu->pntsu + (nu->flagu & CU_NURB_CYCLIC) - 1) + 1; bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelBPoints"); BLI_addtail(&(cu->bev), bl); - + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; else bl->poly = -1; bevp = (BevPoint *)(bl + 1); - + a = nu->pntsu - 1; bezt = nu->bezt; if (nu->flagu & CU_NURB_CYCLIC) { @@ -2183,7 +2269,7 @@ void BKE_curve_bevelList_make(Object *ob) prevbezt = bezt; bezt++; } - + while (a--) { if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { @@ -2200,14 +2286,14 @@ void BKE_curve_bevelList_make(Object *ob) else { /* always do all three, to prevent data hanging around */ int j; - + /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */ for (j = 0; j < 3; j++) { BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], bezt->vec[1][j], &(bevp->vec[j]), resolu, sizeof(BevPoint)); } - + /* if both arrays are NULL do nothiong */ alfa_bezpart(prevbezt, bezt, nu, do_tilt ? &bevp->alfa : NULL, @@ -2215,7 +2301,7 @@ void BKE_curve_bevelList_make(Object *ob) do_weight ? &bevp->weight : NULL, resolu, sizeof(BevPoint)); - + if (cu->twist_mode == CU_TWIST_TANGENT) { forward_diff_bezier_cotangent(prevbezt->vec[1], prevbezt->vec[2], bezt->vec[0], bezt->vec[1], @@ -2224,11 +2310,14 @@ void BKE_curve_bevelList_make(Object *ob) /* indicate with handlecodes double points */ if (prevbezt->h1 == prevbezt->h2) { - if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) bevp->split_tag = TRUE; + if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) + bevp->split_tag = TRUE; } else { - if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) bevp->split_tag = TRUE; - else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) bevp->split_tag = TRUE; + if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) + bevp->split_tag = TRUE; + else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) + bevp->split_tag = TRUE; } bl->nr += resolu; bevp += resolu; @@ -2236,7 +2325,7 @@ void BKE_curve_bevelList_make(Object *ob) prevbezt = bezt; bezt++; } - + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic: endpoint */ copy_v3_v3(bevp->vec, prevbezt->vec[1]); bevp->alfa = prevbezt->alfa; @@ -2248,7 +2337,7 @@ void BKE_curve_bevelList_make(Object *ob) else if (nu->type == CU_NURBS) { if (nu->pntsv == 1) { len = (resolu * SEGMENTSU(nu)); - + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList3"); BLI_addtail(&(cu->bev), bl); bl->nr = len; @@ -2256,7 +2345,7 @@ void BKE_curve_bevelList_make(Object *ob) if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; else bl->poly = -1; bevp = (BevPoint *)(bl + 1); - + BKE_nurb_makeCurve(nu, &bevp->vec[0], do_tilt ? &bevp->alfa : NULL, do_radius ? &bevp->radius : NULL, @@ -2329,7 +2418,6 @@ void BKE_curve_bevelList_make(Object *ob) } bl = bl->next; } - /* find extreme left points, also test (turning) direction */ if (poly > 0) { @@ -2352,16 +2440,23 @@ void BKE_curve_bevelList_make(Object *ob) sd->left = min; bevp = (BevPoint *)(bl + 1); - if (bevp1 == bevp) bevp0 = bevp + (bl->nr - 1); - else bevp0 = bevp1 - 1; + if (bevp1 == bevp) + bevp0 = bevp + (bl->nr - 1); + else + bevp0 = bevp1 - 1; bevp = bevp + (bl->nr - 1); - if (bevp1 == bevp) bevp2 = (BevPoint *)(bl + 1); - else bevp2 = bevp1 + 1; + if (bevp1 == bevp) + bevp2 = (BevPoint *)(bl + 1); + else + bevp2 = bevp1 + 1; - inp = (bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) + (bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]); + inp = (bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) + + (bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]); - if (inp > 0.0f) sd->dir = 1; - else sd->dir = 0; + if (inp > 0.0f) + sd->dir = 1; + else + sd->dir = 0; sd++; } @@ -2555,18 +2650,20 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n if (len != 0.0f) { int leftviolate = 0, rightviolate = 0; /* for mode==2 */ - - if (len_a > 5.0f * len_b) len_a = 5.0f * len_b; - if (len_b > 5.0f * len_a) len_b = 5.0f * len_a; - + + if (len_a > 5.0f * len_b) + len_a = 5.0f * len_b; + if (len_b > 5.0f * len_a) + len_b = 5.0f * len_a; + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { len_a /= len; madd_v3_v3v3fl(p2 - 3, p2, tvec, -len_a); - + if ((bezt->h1 == HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ float ydiff1 = prev->vec[1][1] - bezt->vec[1][1]; float ydiff2 = next->vec[1][1] - bezt->vec[1][1]; - if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { + if ((ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f)) { bezt->vec[0][1] = bezt->vec[1][1]; } else { /* handles should not be beyond y coord of two others */ @@ -2588,7 +2685,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { len_b /= len; madd_v3_v3v3fl(p2 + 3, p2, tvec, len_b); - + if ((bezt->h2 == HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ float ydiff1 = prev->vec[1][1] - bezt->vec[1][1]; float ydiff2 = next->vec[1][1] - bezt->vec[1][1]; @@ -2614,7 +2711,7 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n if (leftviolate || rightviolate) { /* align left handle */ float h1[3], h2[3]; float dot; - + sub_v3_v3v3(h1, p2 - 3, p2); sub_v3_v3v3(h2, p2, p2 + 3); @@ -2632,7 +2729,6 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n add_v3_v3v3(p2 - 3, p2, h2); } } - } } @@ -2652,8 +2748,10 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n len_b = len_v3v3(p2, p2 + 3); len_a = len_v3v3(p2, p2 - 3); - if (len_a == 0.0f) len_a = 1.0f; - if (len_b == 0.0f) len_b = 1.0f; + if (len_a == 0.0f) + len_a = 1.0f; + if (len_b == 0.0f) + len_b = 1.0f; if (bezt->f1 & SELECT) { /* order of calculation */ if (bezt->h2 == HD_ALIGN) { /* aligned */ @@ -2698,9 +2796,11 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align) BezTriple *bezt, *prev, *next; short a; - if (nu->type != CU_BEZIER) return; - if (nu->pntsu < 2) return; - + if (nu->type != CU_BEZIER) + return; + if (nu->pntsu < 2) + return; + a = nu->pntsu; bezt = nu->bezt; if (nu->flagu & CU_NURB_CYCLIC) prev = bezt + (a - 1); @@ -2711,10 +2811,13 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align) calchandleNurb_intern(bezt, prev, next, 0, skip_align); prev = bezt; if (a == 1) { - if (nu->flagu & CU_NURB_CYCLIC) next = nu->bezt; - else next = NULL; + if (nu->flagu & CU_NURB_CYCLIC) + next = nu->bezt; + else + next = NULL; } - else next++; + else + next++; bezt++; } @@ -2749,10 +2852,13 @@ void BKE_nurb_handles_test(Nurb *nu) a = nu->pntsu; while (a--) { flag = 0; - if (bezt->f1 & SELECT) flag++; - if (bezt->f2 & SELECT) flag += 2; - if (bezt->f3 & SELECT) flag += 4; - + if (bezt->f1 & SELECT) + flag++; + if (bezt->f2 & SELECT) + flag += 2; + if (bezt->f3 & SELECT) + flag += 4; + if (!(flag == 0 || flag == 7) ) { if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ bezt->h1 = HD_ALIGN; @@ -2760,7 +2866,7 @@ void BKE_nurb_handles_test(Nurb *nu) if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ bezt->h2 = HD_ALIGN; } - + if (bezt->h1 == HD_VECT) { /* vector */ if (flag < 4) bezt->h1 = 0; } @@ -2770,28 +2876,28 @@ void BKE_nurb_handles_test(Nurb *nu) } bezt++; } - + BKE_nurb_handles_calc(nu); } void BKE_nurb_handles_autocalc(Nurb *nu, int flag) { /* checks handle coordinates and calculates type */ - + BezTriple *bezt2, *bezt1, *bezt0; int i, align, leftsmall, rightsmall; - if (nu == NULL || nu->bezt == NULL) return; - + if (nu == NULL || nu->bezt == NULL) + return; + bezt2 = nu->bezt; bezt1 = bezt2 + (nu->pntsu - 1); bezt0 = bezt1 - 1; i = nu->pntsu; while (i--) { - align = leftsmall = rightsmall = 0; - + /* left handle: */ if (flag == 0 || (bezt1->f1 & flag) ) { bezt1->h1 = 0; @@ -2809,7 +2915,6 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) /* or vector handle? */ if (dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f) bezt1->h1 = HD_VECT; - } } /* right handle: */ @@ -2827,16 +2932,19 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) /* or vector handle? */ if (dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f) bezt1->h2 = HD_VECT; - } } - if (leftsmall && bezt1->h2 == HD_ALIGN) bezt1->h2 = 0; - if (rightsmall && bezt1->h1 == HD_ALIGN) bezt1->h1 = 0; - + if (leftsmall && bezt1->h2 == HD_ALIGN) + bezt1->h2 = 0; + if (rightsmall && bezt1->h1 == HD_ALIGN) + bezt1->h1 = 0; + /* undesired combination: */ - if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT) bezt1->h1 = 0; - if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT) bezt1->h2 = 0; - + if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT) + bezt1->h1 = 0; + if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT) + bezt1->h2 = 0; + bezt0 = bezt1; bezt1 = bezt2; bezt2++; @@ -2848,7 +2956,7 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag) { Nurb *nu; - + nu = editnurb->first; while (nu) { BKE_nurb_handles_autocalc(nu, flag); @@ -2876,11 +2984,15 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) a = nu->pntsu; while (a--) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1 = code; - if (bezt->f3 & SELECT) bezt->h2 = code; + if (bezt->f1 & SELECT) + bezt->h1 = code; + if (bezt->f3 & SELECT) + bezt->h2 = code; if (bezt->h1 != bezt->h2) { - if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO)) bezt->h1 = HD_FREE; - if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO)) bezt->h2 = HD_FREE; + if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO)) + bezt->h1 = HD_FREE; + if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO)) + bezt->h2 = HD_FREE; } } bezt++; @@ -2892,7 +3004,6 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) } else { /* there is 1 handle not FREE: FREE it all, else make ALIGNED */ - nu = editnurb->first; if (code == 5) { ok = HD_ALIGN; @@ -2926,7 +3037,7 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) while (a--) { if (bezt->f1 & SELECT) bezt->h1 = ok; if (bezt->f3 & SELECT) bezt->h2 = ok; - + bezt++; } BKE_nurb_handles_calc(nu); @@ -2975,14 +3086,16 @@ void BKE_nurb_direction_switch(Nurb *nu) if (a & 1) a += 1; /* if odd, also swap middle content */ a /= 2; while (a > 0) { - if (bezt1 != bezt2) SWAP(BezTriple, *bezt1, *bezt2); + if (bezt1 != bezt2) + SWAP(BezTriple, *bezt1, *bezt2); swapdata(bezt1->vec[0], bezt1->vec[2], 12); - if (bezt1 != bezt2) swapdata(bezt2->vec[0], bezt2->vec[2], 12); + if (bezt1 != bezt2) + swapdata(bezt2->vec[0], bezt2->vec[2], 12); SWAP(char, bezt1->h1, bezt1->h2); SWAP(short, bezt1->f1, bezt1->f3); - + if (bezt1 != bezt2) { SWAP(char, bezt2->h1, bezt2->h2); SWAP(short, bezt2->f1, bezt2->f3); @@ -2990,7 +3103,7 @@ void BKE_nurb_direction_switch(Nurb *nu) bezt2->alfa = -bezt2->alfa; } a--; - bezt1++; + bezt1++; bezt2--; } } @@ -3004,7 +3117,7 @@ void BKE_nurb_direction_switch(Nurb *nu) a--; bp1->alfa = -bp1->alfa; bp2->alfa = -bp2->alfa; - bp1++; + bp1++; bp2--; } if (nu->type == CU_NURBS) { @@ -3018,7 +3131,7 @@ void BKE_nurb_direction_switch(Nurb *nu) while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; - fp1++; + fp1++; fp2--; } /* and make in increasing order again */ @@ -3030,7 +3143,7 @@ void BKE_nurb_direction_switch(Nurb *nu) fp1++; fp2++; } - + a = KNOTSU(nu) - 1; fp1 = nu->knotsu; fp2 = tempf; @@ -3046,18 +3159,16 @@ void BKE_nurb_direction_switch(Nurb *nu) } } else { - for (b = 0; b < nu->pntsv; b++) { - bp1 = nu->bp + b * nu->pntsu; a = nu->pntsu; bp2 = bp1 + (a - 1); a /= 2; - + while (bp1 != bp2 && a > 0) { SWAP(BPoint, *bp1, *bp2); a--; - bp1++; + bp1++; bp2--; } } @@ -3182,31 +3293,46 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) int BKE_nurb_check_valid_u(struct Nurb *nu) { - if (nu == NULL) return 0; - if (nu->pntsu <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ + if (nu == NULL) + return 0; + if (nu->pntsu <= 1) + return 0; + if (nu->type != CU_NURBS) + return 1; /* not a nurb, lets assume its valid */ if (nu->pntsu < nu->orderu) return 0; if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ if (nu->orderu == 4) { - if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */ + if (nu->pntsu < 5) + return 0; /* bezier with 4 orderu needs 5 points */ + } + else { + if (nu->orderu != 3) + return 0; /* order must be 3 or 4 */ } - else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */ } return 1; } int BKE_nurb_check_valid_v(struct Nurb *nu) { - if (nu == NULL) return 0; - if (nu->pntsv <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ + if (nu == NULL) + return 0; + if (nu->pntsv <= 1) + return 0; + if (nu->type != CU_NURBS) + return 1; /* not a nurb, lets assume its valid */ - if (nu->pntsv < nu->orderv) return 0; + if (nu->pntsv < nu->orderv) + return 0; if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ if (nu->orderv == 4) { - if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */ + if (nu->pntsv < 5) + return 0; /* bezier with 4 orderu needs 5 points */ + } + else { + if (nu->orderv != 3) + return 0; /* order must be 3 or 4 */ } - else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */ } return 1; } @@ -3366,7 +3492,8 @@ void BKE_curve_delete_material_index(Curve *cu, int index) for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu->mat_nr && nu->mat_nr >= index) { nu->mat_nr--; - if (curvetype == OB_CURVE) nu->charidx--; + if (curvetype == OB_CURVE) + nu->charidx--; } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 8b4d699006d..a3f5c5c23c6 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -484,7 +484,8 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal) dl = dl->next; } - if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { + /* XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { */ + if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, FALSE))) { if (tot) { dlnew = MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type = DL_INDEX3; @@ -743,7 +744,8 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo return pretessellatePoint; } -static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r) +static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, float (**originalVerts_r)[3], + float (**deformedVerts_r)[3], int *numVerts_r) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; @@ -1412,7 +1414,8 @@ 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) * ((steps + 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) + start; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 31741718a09..cf63fb267e8 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -635,7 +635,8 @@ static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *use return cache->postprocessed.ibuf; } -static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag) +static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, + int flag, int postprocess_flag) { MovieClipCache *cache = clip->cache; MovieTrackingCamera *camera = &clip->tracking.camera; @@ -851,7 +852,8 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user return stableibuf; } -ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag) +ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, + int postprocess_flag) { ImBuf *ibuf, *stableibuf = NULL; int framenr = user->framenr; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index b68102885ea..b27a065730b 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -166,11 +166,11 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) /* search shouldn't be moved inside pattern */ if (track->search_min[a] > pat_min[a]) { track->search_min[a] = pat_min[a]; - track->search_max[a] = track->search_min[a]+dim[a]; + track->search_max[a] = track->search_min[a] + dim[a]; } if (track->search_max[a] < pat_max[a]) { track->search_max[a] = pat_max[a]; - track->search_min[a] = track->search_max[a]-dim[a]; + track->search_min[a] = track->search_max[a] - dim[a]; } } } @@ -196,8 +196,8 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) sub_v2_v2v2(dim, track->pat_max, track->pat_min); for (a = 0; a < 2; a++) { - track->pat_min[a] = -dim[a]/2.0f; - track->pat_max[a] = dim[a]/2.0f; + track->pat_min[a] = -dim[a] / 2.0f; + track->pat_max[a] = dim[a] / 2.0f; } } } @@ -302,8 +302,9 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie else track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers"); - memmove(track->markers+a+2, track->markers+a+1, (track->markersnr-a-2)*sizeof(MovieTrackingMarker)); - track->markers[a+1] = *marker; + memmove(track->markers + a + 2, track->markers + a + 1, + (track->markersnr - a - 2) * sizeof(MovieTrackingMarker)); + track->markers[a + 1] = *marker; track->last_marker = a + 1; @@ -315,12 +316,13 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) { int a = 0; - while (amarkersnr) { + while (a < track->markersnr) { if (track->markers[a].framenr == framenr) { if (track->markersnr > 1) { - memmove(track->markers+a, track->markers+a+1, (track->markersnr-a-1)*sizeof(MovieTrackingMarker)); + memmove(track->markers + a, track->markers + a + 1, + (track->markersnr - a - 1) * sizeof(MovieTrackingMarker)); track->markersnr--; - track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr); + track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr); } else { MEM_freeN(track->markers); @@ -337,7 +339,7 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int framenr) { - int a = track->markersnr-1; + int a = track->markersnr - 1; if (!track->markersnr) return NULL; @@ -360,7 +362,7 @@ MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int fram } /* if there's no marker for exact position, use nearest marker from left side */ - return &track->markers[a-1]; + return &track->markers[a - 1]; } else { while (a >= 0 && track->markers[a].framenr >= framenr) { @@ -461,16 +463,16 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio } if (track->markersnr) - put_disabled_marker(track, &track->markers[track->markersnr-1], 0, 1); + 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) { - memmove(track->markers, track->markers+a, (track->markersnr-a)*sizeof(MovieTrackingMarker)); + memmove(track->markers, track->markers + a, (track->markersnr - a) * sizeof(MovieTrackingMarker)); - track->markersnr = track->markersnr-a; + track->markersnr = track->markersnr - a; track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr); break; @@ -521,8 +523,8 @@ void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack markers[i] = dst_track->markers[b++]; } else { - if ((src_track->markers[a].flag & MARKER_DISABLED)==0) { - if ((dst_track->markers[b].flag & MARKER_DISABLED)==0) { + if ((src_track->markers[a].flag & MARKER_DISABLED) == 0) { + if ((dst_track->markers[b].flag & MARKER_DISABLED) == 0) { /* both tracks are enabled on this frame, so find the whole segment * on which tracks are intersecting and blend tracks using linear * interpolation to prevent jumps */ @@ -532,8 +534,8 @@ void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack int j, inverse = 0; inverse = (b == 0) || - (dst_track->markers[b-1].flag & MARKER_DISABLED) || - (dst_track->markers[b-1].framenr != frame - 1); + (dst_track->markers[b - 1].flag & MARKER_DISABLED) || + (dst_track->markers[b - 1].framenr != frame - 1); /* find length of intersection */ while (a < src_track->markersnr && b < dst_track->markersnr) { @@ -969,7 +971,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u /* count */ track = tracksbase->first; while (track) { - if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN))==0) { + if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN)) == 0) { MovieTrackingMarker *marker = BKE_tracking_get_marker(track, user->framenr); if ((marker->flag & MARKER_DISABLED) == 0) @@ -1000,13 +1002,13 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u #ifdef WITH_LIBMV { - float patx = (int)((track->pat_max[0]-track->pat_min[0])*width), - paty = (int)((track->pat_max[1]-track->pat_min[1])*height); + float patx = (int)((track->pat_max[0] - track->pat_min[0]) * width), + paty = (int)((track->pat_max[1] - track->pat_min[1]) * height); - float search_size_x = (track->search_max[0]-track->search_min[0])*width; - float search_size_y = (track->search_max[1]-track->search_min[1])*height; - float pattern_size_x = (track->pat_max[0]-track->pat_min[0])*width; - float pattern_size_y = (track->pat_max[1]-track->pat_min[1])*height; + float search_size_x = (track->search_max[0] - track->search_min[0]) * width; + float search_size_y = (track->search_max[1] - track->search_min[1]) * height; + float pattern_size_x = (track->pat_max[0] - track->pat_min[0]) * width; + float pattern_size_y = (track->pat_max[1] - track->pat_min[1]) * height; int wndx = (int)patx / 2, wndy = (int)paty / 2; int half_wnd = MAX2(wndx, wndy); @@ -1021,17 +1023,20 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u * than the search size */ int level = MIN2(track->pyramid_levels, max_pyramid_levels); + struct libmv_RegionTracker *region_tracker; + if (track->tracker == TRACKER_KLT) { - track_context.region_tracker = - libmv_pyramidRegionTrackerNew(100, level, half_wnd, track->minimum_correlation); + region_tracker = libmv_pyramidRegionTrackerNew(100, level, half_wnd, + track->minimum_correlation); } else if (track->tracker == TRACKER_HYBRID) { - track_context.region_tracker = - libmv_hybridRegionTrackerNew(100, half_wnd, track->minimum_correlation); + region_tracker = 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); + region_tracker = libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); } + + track_context.region_tracker = region_tracker; } #endif @@ -1094,7 +1099,8 @@ void BKE_tracking_context_free(MovieTrackingContext *context) /* zap channels from the imbuf that are disabled by the user. this can lead to * better tracks sometimes. however, instead of simply zeroing the channels * out, do a partial grayscale conversion so the display is better. */ -void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, int grayscale) +void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, + int grayscale) { int x, y; float scale; @@ -1181,13 +1187,13 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki h = (max[1] - min[1]) * ibuf->y; /* dimensions should be odd */ - w = w|1; - h = h|1; + w = w | 1; + h = h | 1; - x1 = x-(int)(w * (-min[0] / (max[0] - min[0]))); - y1 = y-(int)(h * (-min[1] / (max[1] - min[1]))); + x1 = x - (int)(w * (-min[0] / (max[0] - min[0]))); + y1 = y - (int)(h * (-min[1] / (max[1] - min[1]))); - tmpibuf = IMB_allocImBuf(w+margin*2, h+margin*2, 32, IB_rect); + tmpibuf = IMB_allocImBuf(w + margin * 2, h + margin * 2, 32, IB_rect); IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1 - margin, y1 - margin, w + margin * 2, h + margin * 2); if (pos != NULL) { @@ -1310,17 +1316,17 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra MovieTrackingMarker *marker, MovieTrackingMarker **marker_keyed) { int framenr = marker->framenr; - int a = marker-track->markers; + int a = marker - track->markers; *marker_keyed = marker; while (a >= 0 && a < track->markersnr) { - int next = (context->backwards) ? a+1 : a-1; + int next = (context->backwards) ? a + 1 : a - 1; int is_keyframed = FALSE; MovieTrackingMarker *cur_marker = &track->markers[a]; MovieTrackingMarker *next_marker = NULL; - if (next>=0 && nextmarkersnr) + if (next >= 0 && next < track->markersnr) next_marker = &track->markers[next]; /* if next mrker is disabled, stop searching keyframe and use current frame as keyframe */ @@ -1442,8 +1448,8 @@ int BKE_tracking_next(MovieTrackingContext *context) margin[1] = MAX2(margin[1], (float)track->margin / ibuf_new->y); /* do not track markers which are too close to boundary */ - if (marker->pos[0]pos[0]>1.0f-margin[0] || - marker->pos[1]pos[1]>1.0f-margin[1]) + if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] || + marker->pos[1] < margin[1] || marker->pos[1] > 1.0f - margin[1]) { onbound = TRUE; } @@ -1669,7 +1675,8 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M reconstruction->camnr = 0; reconstruction->cameras = NULL; - reconstructed = MEM_callocN((efra-sfra+1)*sizeof(MovieReconstructedCamera), "temp reconstructed camera"); + reconstructed = MEM_callocN((efra - sfra + 1) * sizeof(MovieReconstructedCamera), + "temp reconstructed camera"); for (a = sfra; a <= efra; a++) { double matd[4][4]; @@ -1704,8 +1711,9 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M } if (reconstruction->camnr) { - reconstruction->cameras = MEM_callocN(reconstruction->camnr * sizeof(MovieReconstructedCamera), "reconstructed camera"); - memcpy(reconstruction->cameras, reconstructed, reconstruction->camnr * sizeof(MovieReconstructedCamera)); + int size = reconstruction->camnr * sizeof(MovieReconstructedCamera); + reconstruction->cameras = MEM_callocN(size, "reconstructed camera"); + memcpy(reconstruction->cameras, reconstructed, size); } if (origin_set) { @@ -1783,7 +1791,8 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o return TRUE; } else if (count_tracks_on_both_keyframes(tracking, tracksbase) < 8) { - BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size); + BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", + error_size); return FALSE; } @@ -1818,7 +1827,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * track = tracksbase->first; while (track) { - int first = 0, last = track->markersnr-1; + int first = 0, last = track->markersnr - 1; MovieTrackingMarker *first_marker = &track->markers[0]; MovieTrackingMarker *last_marker = &track->markers[track->markersnr - 1]; @@ -1834,7 +1843,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * last_marker--; } - if (firstmarkersnr - 1) + if (first < track->markersnr - 1) sfra = MIN2(sfra, first_marker->framenr); if (last >= 0) @@ -2010,21 +2019,21 @@ static int reconstruction_camera_index(MovieTrackingReconstruction *reconstructi if (!reconstruction->camnr) return -1; - if (framenrcameras[reconstruction->camnr - 1].framenr) { + if (framenr > cameras[reconstruction->camnr - 1].framenr) { if (nearest) return reconstruction->camnr - 1; else return -1; } - if (reconstruction->last_cameracamnr) + if (reconstruction->last_camera < reconstruction->camnr) a = reconstruction->last_camera; if (cameras[a].framenr >= framenr) @@ -2106,9 +2115,9 @@ void BKE_tracking_get_interpolated_camera(MovieTracking *tracking, MovieTracking } if (cameras[a].framenr != framenr && a > 0 && a < reconstruction->camnr - 1) { - float t = ((float)framenr-cameras[a].framenr) / (cameras[a + 1].framenr-cameras[a].framenr); + float t = ((float)framenr - cameras[a].framenr) / (cameras[a + 1].framenr - cameras[a].framenr); - blend_m4_m4m4(mat, cameras[a].mat, cameras[a+1].mat, t); + blend_m4_m4m4(mat, cameras[a].mat, cameras[a + 1].mat, t); } else { copy_m4_m4(mat, cameras[a].mat); @@ -2135,8 +2144,8 @@ void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4]) void BKE_tracking_camera_shift(MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty) { /* indeed in both of cases it should be winx -- it's just how camera shift works for blender's camera */ - *shiftx = (0.5f * winx-tracking->camera.principal[0]) / winx; - *shifty = (0.5f * winy-tracking->camera.principal[1]) / winx; + *shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx; + *shifty = (0.5f * winy - tracking->camera.principal[1]) / winx; } void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camera *camera, int width, int height) @@ -2145,9 +2154,9 @@ void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camer camera->sensor_x = tracking->camera.sensor_width; camera->sensor_fit = CAMERA_SENSOR_FIT_AUTO; - camera->lens = focal*camera->sensor_x/width; + camera->lens = focal * camera->sensor_x / width; - scene->r.xsch = width*tracking->camera.pixel_aspect; + scene->r.xsch = width * tracking->camera.pixel_aspect; scene->r.ysch = height; scene->r.xasp = 1.0f; @@ -2160,7 +2169,7 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject int framenr, int winx, int winy, float mat[4][4]) { MovieReconstructedCamera *camera; - float lens = tracking->camera.focal*tracking->camera.sensor_width/(float)winx; + float lens = tracking->camera.focal * tracking->camera.sensor_width / (float)winx; float viewfac, pixsize, left, right, bottom, top, clipsta, clipend; float winmat[4][4]; float ycor = 1.0f / tracking->camera.pixel_aspect; @@ -2172,11 +2181,11 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject clipend = 1000.0f; if (winx >= winy) - viewfac = (lens*winx)/tracking->camera.sensor_width; + viewfac = (lens * winx) / tracking->camera.sensor_width; else - viewfac = (ycor*lens*winy)/tracking->camera.sensor_width; + viewfac = (ycor * lens * winy) / tracking->camera.sensor_width; - pixsize = clipsta/viewfac; + pixsize = clipsta / viewfac; left = -0.5f * (float)winx + shiftx * winside; bottom = -0.5f * (ycor) * (float)winy + shifty * winside; @@ -2278,7 +2287,7 @@ void BKE_tracking_apply_intrinsics(MovieTracking *tracking, float co[2], float n #ifdef WITH_LIBMV double x, y; - float aspy = 1.0f/tracking->camera.pixel_aspect; + float aspy = 1.0f / tracking->camera.pixel_aspect; /* normalize coords */ x = (co[0] - camera->principal[0]) / camera->focal; @@ -2326,7 +2335,7 @@ static int point_in_stroke(bGPDstroke *stroke, float x, float y) prev = stroke->totpoints - 1; - for (i = 0; itotpoints; i++) { + for (i = 0; i < stroke->totpoints; i++) { if ((points[i].y < y && points[prev].y >= y) || (points[prev].y < y && points[i].y >= y)) { float fac = (y - points[i].y) / (points[prev].y - points[i].y); @@ -2507,7 +2516,7 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width b[0] *= width; b[1] *= height; - *angle = -atan2(a[0]*b[1]-a[1]*b[0], a[0]*b[0]+a[1]*b[1]); + *angle = -atan2(a[0] * b[1] - a[1] * b[0], a[0] * b[0] + a[1] * b[1]); *angle *= stab->rotinf; /* convert to rotation around image center */ @@ -2563,10 +2572,10 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width, for (i = 0; i < 4; i++) { int j; - float a[3] = {0.0f, 0.0f, 0.0f}, b[3]= {0.0f, 0.0f, 0.0f}; + float a[3] = {0.0f, 0.0f, 0.0f}, b[3] = {0.0f, 0.0f, 0.0f}; copy_v3_v3(a, points[i]); - copy_v3_v3(b, points[(i+1)%4]); + copy_v3_v3(b, points[(i + 1) % 4]); mul_m4_v3(mat, a); mul_m4_v3(mat, b); @@ -2622,7 +2631,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width, stab->scale = scale; - if (stab->maxscale>0.0f) + if (stab->maxscale > 0.0f) stab->scale = MIN2(stab->scale, stab->maxscale); } else { @@ -2663,7 +2672,8 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill) return cacheibuf; } -void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int width, int height, float loc[2], float *scale, float *angle) +void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int width, int height, + float loc[2], float *scale, float *angle) { float firstmedian[2], median[2]; MovieTrackingStabilization *stab = &tracking->stabilization; @@ -2701,7 +2711,8 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w } } -ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, float loc[2], float *scale, float *angle) +ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, + float loc[2], float *scale, float *angle) { float tloc[2], tscale, tangle; MovieTrackingStabilization *stab = &tracking->stabilization; @@ -2798,10 +2809,11 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, return tmpibuf; } -void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, float loc[2], float scale, float angle, float mat[4][4]) +void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, + float loc[2], float scale, float angle, float mat[4][4]) { float lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4], amat[4][4], iamat[4][4]; - float svec[3]= {scale, scale, scale}; + float svec[3] = {scale, scale, scale}; unit_m4(rmat); unit_m4(lmat); @@ -3013,7 +3025,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob MovieTrackingTrack *track; int index = BLI_findindex(&tracking->objects, object); - if (index<0) + if (index < 0) return; if (object->flag & TRACKING_OBJECT_CAMERA) { @@ -3034,7 +3046,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob tracking->tot_object--; - if (index>0) + if (index > 0) tracking->objectnr = index - 1; else tracking->objectnr = 0; @@ -3042,7 +3054,8 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object) { - BLI_uniquename(&tracking->objects, object, "Object", '.', offsetof(MovieTrackingObject, name), sizeof(object->name)); + BLI_uniquename(&tracking->objects, object, "Object", '.', + offsetof(MovieTrackingObject, name), sizeof(object->name)); } MovieTrackingObject *BKE_tracking_named_object(MovieTracking *tracking, const char *name) diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 5761a285d72..18f191a46a6 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -165,9 +165,10 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) block = uiLayoutAbsoluteBlock(layout); - scopes->track_preview_height = (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height; + scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y)?UI_UNIT_Y : scopes->track_preview_height; - uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, + scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } /********************* Marker Template ************************/ @@ -213,7 +214,7 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) marker->flag = cb->marker_flag; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } static void marker_block_handler(bContext *C, void *arg_cb, int event) @@ -227,12 +228,12 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) marker = BKE_tracking_ensure_marker(cb->track, cb->framenr); if (event == B_MARKER_POS) { - marker->pos[0] = cb->marker_pos[0]/width; - marker->pos[1] = cb->marker_pos[1]/height; + marker->pos[0] = cb->marker_pos[0] / width; + marker->pos[1] = cb->marker_pos[1] / height; /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); ok = TRUE; } @@ -278,17 +279,17 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min); - dim[0] = cb->track_search[0]/width; - dim[1] = cb->track_search[1]/height; + dim[0] = cb->track_search[0] / width; + dim[1] = cb->track_search[1] / height; sub_v2_v2(dim, search_dim); mul_v2_fl(dim, 0.5f); - cb->track->search_min[0]-= dim[0]; - cb->track->search_min[1]-= dim[1]; + cb->track->search_min[0] -= dim[0]; + cb->track->search_min[1] -= dim[1]; - cb->track->search_max[0]+= dim[0]; - cb->track->search_max[1]+= dim[1]; + cb->track->search_max[0] += dim[0]; + cb->track->search_max[1] += dim[1]; BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM); @@ -314,16 +315,17 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); ok = TRUE; } if (ok) - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, cb->clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, cb->clip); } -void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact) +void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, + PointerRNA *trackptr, int compact) { PropertyRNA *prop; uiBlock *block; @@ -375,7 +377,8 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P else 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); + 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); } else { diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 574eb5b2570..84209f7b744 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -122,13 +122,13 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); /* anti-aliased lines for more consistent appearance */ glEnable(GL_LINE_SMOOTH); if (sel) - UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255*(1.0f-alpha)); + UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); else glColor4f(0.91f, 0.91f, 0.91f, alpha); diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 9b9190e3e05..0fd17523425 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -100,7 +100,7 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op) current_channel_index++; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -129,7 +129,7 @@ void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot) ot->poll = dopesheet_select_channel_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 33bc67db8e4..f92f639586d 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -87,7 +87,7 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); UI_ThemeColor(TH_TEXT); - BLF_position(fontid, x+2.0f, y+2.0f, 0.0f); + BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f); BLF_draw(fontid, numstr, sizeof(numstr)); } @@ -128,7 +128,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc int framenr; MovieTrackingMarker *marker; - while (amarkersnr) { + while (a < track->markersnr) { if (track->markers[a].framenr >= i) break; @@ -191,7 +191,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx; UI_ThemeColor(TH_CFRAME); - glRecti(x, 0, x+framelen, 8); + glRecti(x, 0, x + framelen, 8); clip_draw_curfra_label(sc, x, 8.0f); } @@ -267,7 +267,7 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, * be binder fallback to simple draw pixels solution */ if (need_fallback) { /* set zoom */ - glPixelZoom(zoomx*width/ibuf->x, zoomy*height/ibuf->y); + glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); @@ -346,7 +346,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin b = count; i = framenr; - while (i <= framenr+count) { + while (i <= framenr + count) { marker = BKE_tracking_get_marker(track, i); if (!marker || marker->flag & MARKER_DISABLED) @@ -357,7 +357,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin curindex = b; add_v2_v2v2(path[b++], marker->pos, track->offset); - ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]); + ED_clip_point_undistorted_pos(sc, path[b - 1], path[b - 1]); } else break; @@ -414,7 +414,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin glPointSize(1.0f); } -static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height) +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 show_search = FALSE; @@ -434,7 +435,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT ED_clip_point_undistorted_pos(sc, pos, pos); - if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (BLI_in_rctf(&r, pos[0] - marker_pos[0], pos[1] - marker_pos[1])) { if (tiny) glPointSize(3.0f); else glPointSize(4.0f); glBegin(GL_POINTS); @@ -513,7 +514,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) +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; @@ -521,8 +523,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra track_colors(track, act, col, scol); - px[0]= 1.0f / width / sc->zoom; - px[1]= 1.0f / height / sc->zoom; + px[0] = 1.0f / width / sc->zoom; + px[1] = 1.0f / height / sc->zoom; /* marker position and offset position */ if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) { @@ -548,7 +550,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra add_v2_v2v2(pos, marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, pos, pos); - if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (BLI_in_rctf(&r, pos[0] - marker_pos[0], pos[1] - marker_pos[1])) { if (!tiny) glPointSize(2.0f); @@ -768,18 +770,18 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } glBegin(GL_QUADS); - glVertex3f(x-tdx, y+tdy, 0); - glVertex3f(x+tdx, y+tdy, 0); - glVertex3f(x+tdx, y-tdy, 0); - glVertex3f(x-tdx, y-tdy, 0); + glVertex3f(x - tdx, y + tdy, 0); + glVertex3f(x + tdx, y + tdy, 0); + glVertex3f(x + tdx, y - tdy, 0); + glVertex3f(x - tdx, y - tdy, 0); glEnd(); /* search re-sizing triangle */ x = track->search_max[0]; y = track->search_min[1]; - tdx = searchdx*2.0f; - tdy = searchdy*2.0f; + tdx = searchdx * 2.0f; + tdy = searchdy * 2.0f; if (outline) { tdx += px[0]; @@ -788,12 +790,12 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glBegin(GL_TRIANGLES); glVertex3f(x, y, 0); - glVertex3f(x-tdx, y, 0); - glVertex3f(x, y+tdy, 0); + glVertex3f(x - tdx, y, 0); + glVertex3f(x, y + tdy, 0); glEnd(); } - if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT)==sel || outline)) { + if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) { if (!outline) { if (track->pat_flag & SELECT) glColor3fv(scol); @@ -814,10 +816,10 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } glBegin(GL_QUADS); - glVertex3f(x-tdx, y+tdy, 0); - glVertex3f(x+tdx, y+tdy, 0); - glVertex3f(x+tdx, y-tdy, 0); - glVertex3f(x-tdx, y-tdy, 0); + glVertex3f(x - tdx, y + tdy, 0); + glVertex3f(x + tdx, y + tdy, 0); + glVertex3f(x + tdx, y - tdy, 0); + glVertex3f(x - tdx, y - tdy, 0); glEnd(); /* pattern re-sizing triangle */ @@ -834,8 +836,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glBegin(GL_TRIANGLES); glVertex3f(x, y, 0); - glVertex3f(x-tdx, y, 0); - glVertex3f(x, y+tdy, 0); + glVertex3f(x - tdx, y, 0); + glVertex3f(x, y + tdy, 0); glEnd(); } @@ -845,8 +847,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glLineWidth(1.0f); } -static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int act, - int width, int height, float zoomx, float zoomy) +static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int act, 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]; @@ -971,7 +973,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* count */ track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) @@ -988,7 +990,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1009,7 +1011,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if (sc->flag & SC_SHOW_TRACK_PATH) { track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) + if ((track->flag & TRACK_HIDDEN) == 0) draw_track_path(sc, clip, track); track = track->next; @@ -1020,7 +1022,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1044,7 +1046,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { int act = track == act_track; marker = BKE_tracking_get_marker(track, framenr); @@ -1066,7 +1068,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* active marker would be displayed on top of everything else */ if (act_track) { - if ((act_track->flag & TRACK_HIDDEN)==0) { + if ((act_track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(act_track, framenr); if (MARKER_VISIBLE(sc, act_track, marker)) { @@ -1096,7 +1098,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if (MARKER_VISIBLE(sc, track, marker)) { float npos[2]; copy_v4_v4(vec, track->bundle_pos); - vec[3]=1; + vec[3] = 1; mul_v4_m4v4(pos, mat, vec); @@ -1111,7 +1113,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, sub_v2_v2(vec, npos); - if (len_v2(vec)< 3.0f) + if (len_v2(vec) < 3.0f) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); @@ -1165,7 +1167,8 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, MEM_freeN(marker_pos); } -static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int width, int height, float zoomx, float zoomy) +static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, + int width, int height, float zoomx, float zoomy) { float x, y; const int n = 10; @@ -1199,9 +1202,9 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid for (a = 0; a < 4; a++) { if (a < 2) - val[a][a%2] = FLT_MAX; + val[a][a % 2] = FLT_MAX; else - val[a][a%2] = -FLT_MAX; + val[a][a % 2] = -FLT_MAX; } zero_v2(pos); @@ -1213,10 +1216,10 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid for (a = 0; a < 4; a++) { int ok; - if (a<2) - ok = tpos[a%2] < val[a][a%2]; + 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); @@ -1310,11 +1313,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid pos[0] = stroke->points[i].x * width; pos[1] = stroke->points[i].y * height * aspy; - npos[0] = stroke->points[i+1].x * width; - npos[1] = stroke->points[i+1].y * height * aspy; + npos[0] = stroke->points[i + 1].x * width; + 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) { @@ -1323,11 +1326,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } sub_v2_v2v2(dpos, npos, pos); - mul_v2_fl(dpos, 1.0f/steps); + mul_v2_fl(dpos, 1.0f / steps); for (j = 0; j <= steps; j++) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); - glVertex2f(tpos[0]/width, tpos[1]/(height*aspy)); + glVertex2f(tpos[0] / width, tpos[1] / (height*aspy)); add_v2_v2(pos, dpos); } @@ -1434,7 +1437,7 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) if (onlyv2d) { /* if manual calibration is used then grease pencil data is already * drawed in draw_distortion */ - if ((sc->flag & SC_MANUAL_CALIBRATION)==0 || sc->mode != SC_MODE_DISTORTION) { + if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || sc->mode != SC_MODE_DISTORTION) { ibuf = ED_space_clip_get_buffer(sc); if (ibuf) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index bd34a51819c..94422e51891 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -162,7 +162,7 @@ void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *c } if (C) - WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); } MovieClip *ED_space_clip(SpaceClip *sc) @@ -220,8 +220,8 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) ED_space_clip_size(sc, &width, &height); - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); + *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); + *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); } void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -317,7 +317,8 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) return FALSE; /* center view */ - clip_view_center_to_point(sc, (max[0]+min[0])/(2*frame_width), (max[1]+min[1])/(2*frame_height)); + clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -337,7 +338,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) newzoom = 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)); - if (fit || sc->zoom>newzoom) + if (fit || sc->zoom > newzoom) sc->zoom = newzoom; } diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 9f9bdcb6cd2..853a7d7cad1 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -81,7 +81,7 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float glPushMatrix(); glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); glCallList(displist); glPopMatrix(); @@ -166,7 +166,8 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) /* draw graph lines */ glEnable(GL_BLEND); - clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, tracking_segment_start_cb, tracking_segment_end_cb); + clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, + tracking_segment_start_cb, tracking_segment_end_cb); glDisable(GL_BLEND); /* selected knot handles on top of curves */ @@ -183,10 +184,10 @@ static void draw_frame_curves(SpaceClip *sc) glColor3f(0.0f, 0.0f, 1.0f); - for (i = 0; icamnr; i++) { + for (i = 0; i < reconstruction->camnr; i++) { MovieReconstructedCamera *camera = &reconstruction->cameras[i]; - if (lines && camera->framenr!=prevfra+1) { + if (lines && camera->framenr != prevfra + 1) { glEnd(); lines = 0; } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index efe48cd4b36..10692ada5d9 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -144,7 +144,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr float d = dx * dx + dy * dy; if (data->marker == NULL || d < data->min_dist) { - float co[2]= {marker->framenr, val}; + float co[2] = {marker->framenr, val}; data->track = track; data->marker = marker; @@ -252,7 +252,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } if (sel) - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -358,7 +358,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, border_select_cb, NULL, NULL); if (userdata.change) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -430,7 +430,7 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -447,7 +447,7 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -481,7 +481,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** delete knot operator ********************/ @@ -522,7 +522,7 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** view all operator ********************/ @@ -662,7 +662,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -686,7 +686,7 @@ void CLIP_OT_graph_disable_markers(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 485830dbe6c..fb99bf37a24 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -93,8 +93,8 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { ED_space_clip_size(sc, &width, &height); - sc->xof += ((location[0] - 0.5f) * width-sc->xof) * (sc->zoom-oldzoom) / sc->zoom; - sc->yof += ((location[1] - 0.5f) * height-sc->yof) * (sc->zoom-oldzoom) / sc->zoom; + sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; + sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; } } @@ -164,7 +164,8 @@ static int open_exec(bContext *C, wmOperator *op) if (op->customdata) MEM_freeN(op->customdata); - BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, errno ? strerror(errno) : "Unsupported movie clip format"); + BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, + errno ? strerror(errno) : "Unsupported movie clip format"); return OPERATOR_CANCELLED; } @@ -188,7 +189,7 @@ static int open_exec(bContext *C, wmOperator *op) ED_space_clip_set(C, screen, sc, clip); } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_ADDED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_ADDED, clip); MEM_freeN(op->customdata); @@ -233,10 +234,11 @@ void CLIP_OT_open(wmOperatorType *ot) ot->cancel = open_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* reload clip operator *********************/ @@ -250,7 +252,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) BKE_movieclip_reload(clip); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -412,7 +414,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING; + ot->flag = OPTYPE _ BLOCKING; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, @@ -500,7 +502,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) switch (event->type) { case MOUSEMOVE: - factor = 1.0f + (vpd->x-event->x + vpd->y - event->y) / 300.0f; + factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -539,7 +541,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; /* properties */ RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX, @@ -586,7 +588,8 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) 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); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in screen coordinates", -10.0f, 10.0f); } static int view_zoom_out_exec(bContext *C, wmOperator *op) @@ -627,7 +630,8 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) 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); + 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); } /********************** view zoom ratio operator *********************/ @@ -781,7 +785,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) /* do updates */ sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } static int change_frame_exec(bContext *C, wmOperator *op) @@ -867,7 +871,7 @@ void CLIP_OT_change_frame(wmOperatorType *ot) ot->poll = change_frame_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -904,16 +908,16 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto int size_nr = undistort ? 1 : 0; if (size_flag & size_flags[size_nr][0]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_25; if (size_flag & size_flags[size_nr][1]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_50; if (size_flag & size_flags[size_nr][2]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_75; if (size_flag & size_flags[size_nr][3]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_100; return build_count; } @@ -958,7 +962,8 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if (clip->source != MCLIP_SRC_MOVIE) BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, NULL, cfra, build_sizes, build_count, 0); - BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1); + BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, + build_undistort_sizes, build_undistort_count, 1); if (*stop || G.afbreek) break; @@ -986,7 +991,7 @@ static void proxy_endjob(void *pjv) BKE_movieclip_reload(pj->clip); - WM_main_add_notifier(NC_MOVIECLIP|ND_DISPLAY, pj->clip); + WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, pj->clip); } static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1015,7 +1020,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) } WM_jobs_customdata(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0); + WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); G.afbreek = 0; @@ -1057,7 +1062,7 @@ static int mode_set_exec(bContext *C, wmOperator *op) sc->mode = mode; } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CLIP, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); return OPERATOR_FINISHED; } @@ -1094,14 +1099,14 @@ void ED_operatormacros_clip(void) wmOperatorTypeMacro *otmacro; 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); + "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", "Add new marker and slide it with mouse until mouse button release", - OPTYPE_UNDO|OPTYPE_REGISTER); + 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_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index da8bf8fedd9..3ffba75f2ef 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -151,7 +151,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa) BLI_insertlinkafter(&sa->regionbase, artool, arprops); arprops->regiontype = RGN_TYPE_TOOL_PROPS; - arprops->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; } return artool; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 2545106d132..4142c30d825 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -190,20 +190,21 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); if (update_stab) { tracking->stabilization.ok = FALSE; - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + 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); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); } -void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingMarker *marker) +void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, + MovieTrackingTrack *track, MovieTrackingMarker *marker) { if (track->markersnr == 1) { clip_delete_track(C, clip, tracksbase, track); @@ -211,7 +212,7 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, Movi else { BKE_tracking_delete_marker(track, marker->framenr); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); } } @@ -253,7 +254,7 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 1c0d2db91a9..a3e17d420b3 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -81,7 +81,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) if (sc->view == SC_VIEW_DOPESHEET) { ar->v2d.tot.xmin = -10.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(sa->winx); ar->v2d.tot.ymax = 0.0f; @@ -95,7 +95,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.minzoom = 0.01f; ar->v2d.maxzoom = 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); ar->v2d.keepzoom = V2D_LOCKZOOM_Y; ar->v2d.keepofs = V2D_KEEPOFS_Y; @@ -116,8 +116,8 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = FLT_MAX; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); ar->v2d.minzoom = 0.0f; ar->v2d.maxzoom = 0.0f; @@ -232,7 +232,8 @@ static SpaceLink *clip_new(const bContext *C) sc = MEM_callocN(sizeof(SpaceClip), "initclip"); sc->spacetype = SPACE_CLIP; - sc->flag = SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES; + sc->flag = SC_SHOW_MARKER_PATTERN | SC_SHOW_TRACK_PATH | SC_MANUAL_CALIBRATION | + SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES; sc->zoom = 1.0f; sc->path_length = 20; sc->scopes.track_preview_height = 120; @@ -256,7 +257,7 @@ static SpaceLink *clip_new(const bContext *C) BLI_addtail(&sc->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_PROPS; - ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; /* properties view */ ar = MEM_callocN(sizeof(ARegion), "properties for clip"); @@ -369,12 +370,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SCREEN: - if (wmn->data ==ND_ANIMPLAY) { + if (wmn->data == ND_ANIMPLAY) { ED_area_tag_redraw(sa); } break; case NC_SPACE: - if (wmn->data ==ND_SPACE_CLIP) { + if (wmn->data == ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -512,7 +513,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "backwards", FALSE); RNA_boolean_set(kmi->ptr, "sequence", TRUE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "backwards", TRUE); RNA_boolean_set(kmi->ptr, "sequence", TRUE); @@ -560,16 +561,16 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* jump to special frame */ - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 0); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 1); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 2); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 3); /* "timeline" */ @@ -645,7 +646,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO); RNA_boolean_set(kmi->ptr, "clear_active", FALSE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", FALSE); @@ -690,7 +691,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); @@ -708,7 +709,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", TRUE); /* toggle */ } -const char *clip_context_dir[]= {"edit_movieclip", NULL}; +const char *clip_context_dir[] = {"edit_movieclip", NULL}; static int clip_context(const bContext *C, const char *member, bContextDataResult *result) { @@ -879,8 +880,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = TRUE; } - if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) { - ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) { + ar_tool_props->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; view_changed = TRUE; } } @@ -984,8 +985,8 @@ 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; @@ -1146,7 +1147,8 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) /* time grid */ unit = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, + V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -1298,11 +1300,11 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (wmn->data ==ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if (wmn->action ==NA_EDITED) + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1336,7 +1338,7 @@ void ED_spacetype_clip(void) art->init = clip_main_area_init; art->draw = clip_main_area_draw; art->listener = clip_main_area_listener; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); @@ -1347,7 +1349,7 @@ void ED_spacetype_clip(void) art->init = clip_preview_area_init; art->draw = clip_preview_area_draw; art->listener = clip_preview_area_listener; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); @@ -1355,7 +1357,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region properties"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->init = clip_properties_area_init; art->draw = clip_properties_area_draw; art->listener = clip_properties_area_listener; @@ -1366,7 +1368,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region tools"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_props_area_listener; art->init = clip_tools_area_init; art->draw = clip_tools_area_draw; @@ -1378,7 +1380,7 @@ void ED_spacetype_clip(void) art->regionid = RGN_TYPE_TOOL_PROPS; art->prefsizex = 0; art->prefsizey = 120; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_props_area_listener; art->init = clip_tools_area_init; art->draw = clip_tools_area_draw; @@ -1390,7 +1392,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; art->init = clip_header_area_init; art->draw = clip_header_area_draw; @@ -1403,7 +1405,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip channels region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_channels_area_listener; art->init = clip_channels_area_init; art->draw = clip_channels_area_draw; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 56f50d41a12..8e11269254f 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -116,7 +116,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) sc->xlockof = 0; sc->ylockof = 0; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -145,7 +145,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX, @@ -190,7 +190,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** delete marker operator *********************/ @@ -211,7 +211,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr); if (marker) { - has_selection |= track->markersnr>1; + has_selection |= track->markersnr > 1; clip_delete_marker(C, clip, tracksbase, track, marker); } @@ -241,7 +241,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** slide marker operator *********************/ @@ -357,8 +357,8 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + tdx && co[1] >= crn[1] - tdy && co[1] <= crn[1] + dy; } else { - crn[0] = marker->pos[0]+min[0]; - crn[1] = marker->pos[1]+max[1]; + crn[0] = marker->pos[0] + min[0]; + crn[1] = marker->pos[1] + max[1]; inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + dx && co[1] >= crn[1] - dy && co[1] <= crn[1] + dy; } @@ -374,7 +374,7 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki add_v2_v2v2(pos, marker->pos, track->offset); dx = 12.0f / width / sc->zoom; - dy = 12.0f / height /sc->zoom; + dy = 12.0f / height / sc->zoom; dx = MIN2(dx, (track->pat_max[0] - track->pat_min[0]) / 2.0f); dy = MIN2(dy, (track->pat_max[1] - track->pat_min[1]) / 2.0f); @@ -421,21 +421,26 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) if ((marker->flag & MARKER_DISABLED) == 0) { if (!customdata) if (mouse_on_offset(sc, track, marker, co, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, + SLIDE_ACTION_POS, width, height); if (sc->flag & SC_SHOW_MARKER_SEARCH) { if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_OFFSET, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, + SLIDE_ACTION_OFFSET, width, height); else if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, + SLIDE_ACTION_SIZE, width, height); } if (!customdata && (sc->flag & SC_SHOW_MARKER_PATTERN)) { if (mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_OFFSET, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, + SLIDE_ACTION_OFFSET, width, height); if (!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, + SLIDE_ACTION_SIZE, width, height); } if (customdata) @@ -465,7 +470,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) hide_cursor(C); WM_event_add_modal_handler(C, op); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_RUNNING_MODAL; } @@ -490,7 +495,7 @@ static void cancel_mouse_slide(SlideMarkerData *data) else { int a; - for (a = 0; atrack->markersnr; a++) + for (a = 0; a < data->track->markersnr; a++) copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]); copy_v2_v2(data->offset, data->soff); @@ -527,8 +532,8 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) /* no break! update area size */ case MOUSEMOVE: - mdelta[0] = event->mval[0]-data->mval[0]; - mdelta[1] = event->mval[1]-data->mval[1]; + mdelta[0] = event->mval[0] - data->mval[0]; + mdelta[1] = event->mval[1] - data->mval[1]; dx = mdelta[0] / data->width / sc->zoom; @@ -554,7 +559,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) data->marker->flag &= ~MARKER_TRACKED; } - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); DAG_id_tag_update(&sc->clip->id, 0); } else { @@ -580,7 +585,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) else { int a; - for (a = 0; atrack->markersnr; a++) + for (a = 0; a < data->track->markersnr; a++) add_v2_v2v2(data->track->markers[a].pos, data->smarkers[a], d); sub_v2_v2v2(data->offset, data->soff, d); @@ -591,7 +596,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) } } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); break; @@ -613,7 +618,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) show_cursor(C); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_CANCELLED; } @@ -634,7 +639,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) ot->modal = slide_marker_modal; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_GRAB_POINTER|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, @@ -657,10 +662,10 @@ static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, fl static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], float epsx, float epsy) { - return mouse_on_side(co, pos[0]+min[0], pos[1]+min[1], pos[0]+max[0], pos[1]+min[1], epsx, epsy) || - mouse_on_side(co, pos[0]+min[0], pos[1]+min[1], pos[0]+min[0], pos[1]+max[1], epsx, epsy) || - mouse_on_side(co, pos[0]+min[0], pos[1]+max[1], pos[0]+max[0], pos[1]+max[1], epsx, epsy) || - mouse_on_side(co, pos[0]+max[0], pos[1]+min[1], pos[0]+max[0], pos[1]+max[1], epsx, epsy); + return mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + max[0], pos[1] + min[1], epsx, epsy) || + mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + min[0], pos[1] + max[1], epsx, epsy) || + mouse_on_side(co, pos[0] + min[0], pos[1] + max[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy) || + mouse_on_side(co, pos[0] + max[0], pos[1] + min[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy); } static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) @@ -671,9 +676,9 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac ED_space_clip_size(sc, &width, &height); - epsx = MIN4(track->pat_min[0]-track->search_min[0], track->search_max[0]-track->pat_max[0], + epsx = MIN4(track->pat_min[0] - track->search_min[0], track->search_max[0] - track->pat_max[0], fabsf(track->pat_min[0]), fabsf(track->pat_max[0])) / 2; - epsy = MIN4(track->pat_min[1]-track->search_min[1], track->search_max[1]-track->pat_max[1], + epsy = MIN4(track->pat_min[1] - track->search_min[1], track->search_max[1] - track->pat_max[1], fabsf(track->pat_min[1]), fabsf(track->pat_max[1])) / 2; epsx = MAX2(epsx, 2.0f / width); @@ -684,7 +689,7 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac return TRACK_AREA_SEARCH; } - if ((marker->flag & MARKER_DISABLED)== 0) { + if ((marker->flag & MARKER_DISABLED) == 0) { if (sc->flag & SC_SHOW_MARKER_PATTERN) if (mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) return TRACK_AREA_PAT; @@ -692,8 +697,11 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac epsx = 12.0f / width; epsy = 12.0f / height; - if (fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) + if (fabsf(co[0] - marker->pos[0] - track->offset[0]) < epsx && + fabsf(co[1] - marker->pos[1] - track->offset[1]) <= epsy) + { return TRACK_AREA_POINT; + } } return TRACK_AREA_NONE; @@ -702,7 +710,7 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2]) { float d1, d2, d3, d4; - float p[2] = {co[0]-pos[0], co[1]-pos[1]}; + float p[2] = {co[0] - pos[0], co[1] - pos[1]}; float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}, v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; @@ -726,8 +734,9 @@ 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])+ - (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */ + /* distance to marker point */ + 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 pattern boundbox */ if (sc->flag & SC_SHOW_MARKER_PATTERN) @@ -740,7 +749,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas /* choose minimal distance. useful for cases of overlapped markers. */ dist = MIN3(d1, d2, d3); - if (track == NULL || disttracking.act_track = slidedata->track; - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); MEM_freeN(slidedata); @@ -890,7 +899,7 @@ static int border_select_exec(bContext *C, wmOperator *op) 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); + BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT); } else if (!extend) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1); @@ -906,7 +915,7 @@ static int border_select_exec(bContext *C, wmOperator *op) if (change) { BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -981,7 +990,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); 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); + BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT); change = TRUE; } @@ -993,7 +1002,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) if (change) { BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -1015,7 +1024,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); @@ -1057,7 +1066,7 @@ static int select_all_exec(bContext *C, wmOperator *op) track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1092,7 +1101,7 @@ static int select_all_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -1109,7 +1118,7 @@ void CLIP_OT_select_all(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -1133,7 +1142,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) marker = BKE_tracking_get_marker(track, sc->user.framenr); if (group == 0) { /* Keyframed */ - ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED)==0; + ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED) == 0; } else if (group == 1) { /* Estimated */ ok = marker->framenr != sc->user.framenr; @@ -1174,7 +1183,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); return OPERATOR_FINISHED; } @@ -1202,7 +1211,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* proeprties */ RNA_def_enum(ot->srna, "group", select_group_items, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); @@ -1254,10 +1263,10 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); int hidden = 0; - if ((sc->flag & SC_SHOW_MARKER_PATTERN)==0) + if ((sc->flag & SC_SHOW_MARKER_PATTERN) == 0) hidden |= TRACK_AREA_PAT; - if ((sc->flag & SC_SHOW_MARKER_SEARCH)==0) + if ((sc->flag & SC_SHOW_MARKER_SEARCH) == 0) hidden |= TRACK_AREA_SEARCH; if (hidden) { @@ -1284,7 +1293,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - if ((track->flag & TRACK_HIDDEN)==0 && (track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { BKE_tracking_ensure_marker(track, framenr); if (track->frames_limit) { @@ -1391,15 +1400,15 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo if (!BKE_tracking_next(tmj->context)) break; - exec_time = PIL_check_seconds_timer()-start_time; + exec_time = PIL_check_seconds_timer() - start_time; if (tmj->delay > (float)exec_time) - PIL_sleep_ms(tmj->delay-(float)exec_time); + PIL_sleep_ms(tmj->delay - (float)exec_time); } else if (!BKE_tracking_next(tmj->context)) break; *do_update = TRUE; - *progress = (float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); + *progress = (float)(framenr - tmj->sfra) / (tmj->efra - tmj->sfra); if (tmj->backwards) framenr--; @@ -1435,7 +1444,7 @@ static void track_markers_freejob(void *tmv) MEM_freeN(tmj); - WM_main_add_notifier(NC_SCENE|ND_FRAME, tmj->scene); + WM_main_add_notifier(NC_SCENE | ND_FRAME, tmj->scene); } static int track_markers_exec(bContext *C, wmOperator *op) @@ -1450,7 +1459,7 @@ static int track_markers_exec(bContext *C, wmOperator *op) int sequence = RNA_boolean_get(op->ptr, "sequence"); int frames_limit; - if (track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip) == 0) return OPERATOR_CANCELLED; track_init_markers(sc, clip, &frames_limit); @@ -1462,8 +1471,10 @@ static int track_markers_exec(bContext *C, wmOperator *op) /* limit frames to be tracked by user setting */ if (frames_limit) { - if (backwards) efra = MAX2(efra, sfra-frames_limit); - else efra = MIN2(efra, sfra+frames_limit); + if (backwards) + efra = MAX2(efra, sfra - frames_limit); + else + efra = MIN2(efra, sfra + frames_limit); } if (!track_markers_check_direction(backwards, framenr, efra)) @@ -1489,8 +1500,8 @@ static int track_markers_exec(bContext *C, wmOperator *op) /* update scene current frame to the lastes tracked frame */ scene->r.cfra = framenr; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -1513,7 +1524,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve if (clip->tracking_context) return OPERATOR_CANCELLED; - if (track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip) == 0) return OPERATOR_CANCELLED; if (!sequence) @@ -1534,8 +1545,10 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ - if (tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); - else WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|NA_EVALUATED, 0); + if (tmj->delay > 0) + WM_jobs_timer(steve, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); + else + WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); @@ -1554,7 +1567,7 @@ static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *eve { /* no running tracking, remove handler and pass through */ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ switch (event->type) { @@ -1691,8 +1704,8 @@ static void solve_camera_freejob(void *scv) DAG_id_tag_update(&clip->id, 0); - WM_main_add_notifier(NC_MOVIECLIP|NA_EVALUATED, clip); - WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, NULL); + WM_main_add_notifier(NC_MOVIECLIP | NA_EVALUATED, clip); + WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, NULL); /* update active clip displayed in scene buttons */ WM_main_add_notifier(NC_SCENE, scene); @@ -1753,12 +1766,12 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even /* hide reconstruction statistics from previous solve */ reconstruction->flag &= ~TRACKING_RECONSTRUCTED; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); /* setup job */ steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS); WM_jobs_customdata(steve, scj, solve_camera_freejob); - WM_jobs_timer(steve, 0.1, NC_MOVIECLIP|NA_EVALUATED, 0); + WM_jobs_timer(steve, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); G.afbreek = 0; @@ -1776,7 +1789,7 @@ static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *even { /* no running solver, remove handler and pass through */ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ switch (event->type) { @@ -1802,7 +1815,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clear solution operator *********************/ @@ -1832,8 +1845,8 @@ static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); return OPERATOR_FINISHED; } @@ -1850,7 +1863,7 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clear track operator *********************/ @@ -1878,7 +1891,7 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -1902,7 +1915,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* proeprties */ RNA_def_enum(ot->srna, "action", clear_path_actions, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); @@ -1921,7 +1934,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr); if (action == 0) @@ -1936,7 +1949,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -1960,7 +1973,7 @@ void CLIP_OT_disable_markers(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); @@ -1973,13 +1986,13 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) Object *camera = scene->camera; Base *base; - if (camera && BKE_object_movieclip_get(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 (BKE_object_movieclip_get(scene, base->object, 0)==clip) { + if (BKE_object_movieclip_get(scene, base->object, 0) == clip) { camera = base->object; break; } @@ -2144,7 +2157,7 @@ static int set_origin_exec(bContext *C, wmOperator *op) track = track->next; } - mul_v3_fl(median, 1.0f/selected_count); + mul_v3_fl(median, 1.0f / selected_count); BKE_get_tracking_mat(scene, camera, mat); @@ -2162,8 +2175,8 @@ static int set_origin_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2180,7 +2193,7 @@ void CLIP_OT_set_origin(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "use_median", 0, "Use Median", "Set origin to median point of selected bundles"); @@ -2254,7 +2267,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb else { copy_v3_v3(mat[1], vec); - if (is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2]) < 1e-3f) { mat[1][2] = 0.0f; mat[2][0] = 0.0f; mat[2][1] = 0.0f; mat[2][2] = 1.0f; cross_v3_v3v3(mat[0], mat[1], mat[2]); @@ -2318,7 +2331,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */ - if (count_selected_bundles(C)!=3) { + if (count_selected_bundles(C) != 3) { BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor"); return OPERATOR_CANCELLED; @@ -2339,7 +2352,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) /* get 3 bundles to use as reference */ track = tracksbase->first; - while (track && tot<3) { + while (track && tot < 3) { if (track->flag & TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); @@ -2389,7 +2402,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) BKE_object_apply_mat4(object, newmat, 0, 0); /* make camera have positive z-coordinate */ - if (object->loc[2]<0) { + if (object->loc[2] < 0) { invert_m4(rot); mult_m4_m4m4(newmat, rot, mat); BKE_object_apply_mat4(object, newmat, 0, 0); @@ -2405,8 +2418,8 @@ static int set_plane_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2429,7 +2442,7 @@ void CLIP_OT_set_plane(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "plane", plane_items, 0, "Plane", "Plane to be used for orientation"); @@ -2449,7 +2462,7 @@ static int set_axis_exec(bContext *C, wmOperator *op) ListBase *tracksbase; int axis = RNA_enum_get(op->ptr, "axis"); - if (count_selected_bundles(C)!=1) { + if (count_selected_bundles(C) != 1) { BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis"); return OPERATOR_CANCELLED; @@ -2477,8 +2490,8 @@ static int set_axis_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2501,7 +2514,7 @@ void CLIP_OT_set_axis(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "axis", axis_actions, 0, "Axis", "Axis to use to align bundle along"); @@ -2551,7 +2564,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) sub_v3_v3(vec[0], vec[1]); - if (len_v3(vec[0])>1e-5f) { + if (len_v3(vec[0]) > 1e-5f) { scale = dist / len_v3(vec[0]); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { @@ -2561,7 +2574,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) else if (!scale_solution) { Object *solver_camera = object_solver_camera(scene, object); - object->size[0] = object->size[1] = object->size[2] = 1.0f/scale; + object->size[0] = object->size[1] = object->size[2] = 1.0f / scale; if (solver_camera) { object->size[0] /= solver_camera->size[0]; @@ -2578,8 +2591,8 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) if (object) DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); } return OPERATOR_FINISHED; @@ -2614,7 +2627,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX, @@ -2666,7 +2679,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) ot->poll = set_solution_scale_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX, @@ -2686,10 +2699,10 @@ static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) if (width == 0 || height == 0) return OPERATOR_CANCELLED; - clip->tracking.camera.principal[0] = ((float)width)/2.0f; - clip->tracking.camera.principal[1] = ((float)height)/2.0f; + clip->tracking.camera.principal[0] = ((float)width) / 2.0f; + clip->tracking.camera.principal[1] = ((float)height) / 2.0f; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -2706,7 +2719,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** hide tracks operator *********************/ @@ -2745,7 +2758,7 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2762,7 +2775,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected tracks"); @@ -2787,7 +2800,7 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2804,7 +2817,7 @@ void CLIP_OT_hide_tracks_clear(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** detect features operator *********************/ @@ -2862,7 +2875,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) IMB_freeImBuf(ibuf); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2886,7 +2899,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_frame_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "placement", placement_items, 0, "Placement", "Placement for detected features"); @@ -2914,8 +2927,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op) delta = pos == 1 ? 1 : -1; - while (sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { - MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr+delta); + while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) { + MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr + delta); if (!marker || marker->flag & MARKER_DISABLED) break; @@ -2933,7 +2946,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) a += delta; - while (a+delta >= SFRA && a+delta <= EFRA) { + while (a + delta >= SFRA && a + delta <= EFRA) { MovieReconstructedCamera *cam; cam = BKE_tracking_get_reconstructed_camera(tracking, object, a); @@ -2953,10 +2966,10 @@ static int frame_jump_exec(bContext *C, wmOperator *op) CFRA = sc->user.framenr; sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2981,7 +2994,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "position", position_items, 0, "Position", "Position to jump to"); @@ -3021,7 +3034,7 @@ static int join_tracks_exec(bContext *C, wmOperator *op) track = next; } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3038,7 +3051,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** lock tracks operator *********************/ @@ -3064,7 +3077,7 @@ static int lock_tracks_exec(bContext *C, wmOperator *op) track = track->next; } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -3088,7 +3101,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute"); @@ -3121,7 +3134,7 @@ static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) track = track->next; } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); return OPERATOR_FINISHED; } @@ -3138,7 +3151,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** add 2d stabilization tracks operator *********************/ @@ -3155,7 +3168,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB)==0) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB) == 0) { track->flag |= TRACK_USE_2D_STAB; stab->tot_track++; @@ -3169,7 +3182,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3187,7 +3200,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** remove 2d stabilization tracks operator *********************/ @@ -3211,7 +3224,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) stab->act_track--; stab->tot_track--; - if (stab->act_track<0) + if (stab->act_track < 0) stab->act_track = 0; update = 1; @@ -3229,7 +3242,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3247,7 +3260,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** select 2d stabilization tracks operator *********************/ @@ -3273,7 +3286,7 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) } if (update) - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); return OPERATOR_FINISHED; } @@ -3290,7 +3303,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** set 2d stabilization rotation track operator *********************/ @@ -3309,7 +3322,7 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3327,7 +3340,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clean tracks operator *********************/ @@ -3342,30 +3355,30 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) if (del) new_markers = MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); - for (a = 0; a= 0) { - end = a == markersnr-1; - end |= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || - markers[a].flag & MARKER_DISABLED); + end = a == markersnr - 1; + end |= (a < markersnr - 1) && (markers[a].framenr != markers[a + 1].framenr - 1 || + markers[a].flag & MARKER_DISABLED); } if (end) { int segok = 1, len = 0; - if (a != prev && markers[a].framenr != markers[a-1].framenr+1) - len = a-prev; + if (a != prev && markers[a].framenr != markers[a - 1].framenr + 1) + len = a - prev; else if (markers[a].flag & MARKER_DISABLED) - len = a-prev; - else len = a-prev+1; + len = a - prev; + else len = a - prev + 1; if (frames) { if (len < frames) { @@ -3386,7 +3399,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) /* place disabled marker in front of current segment */ if (start_disabled) { - memcpy(new_markers+count, markers+prev, sizeof(MovieTrackingMarker)); + memcpy(new_markers + count, markers + prev, sizeof(MovieTrackingMarker)); new_markers[count].framenr--; new_markers[count].flag |= MARKER_DISABLED; @@ -3394,7 +3407,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) start_disabled = 0; } - memcpy(new_markers+count, markers+prev, t*sizeof(MovieTrackingMarker)); + memcpy(new_markers + count, markers + prev, t * sizeof(MovieTrackingMarker)); count += t; } else if (markers[a].flag & MARKER_DISABLED) { @@ -3443,11 +3456,11 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) while (track) { next = track->next; - if ((track->flag & TRACK_HIDDEN)==0 && (track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { int ok = 1; ok = (is_track_clean(track, frames, action == TRACKING_CLEAN_DELETE_SEGMENT)) && - (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE)==0 || track->error < error); + (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE) == 0 || track->error < error); if (!ok) { if (action == TRACKING_CLEAN_SELECT) { @@ -3476,7 +3489,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) track = next; } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); return OPERATOR_FINISHED; } @@ -3503,7 +3516,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) static EnumPropertyItem actions_items[] = { {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"}, {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete unclean tracks"}, - {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"}, + {TRACKING_CLEAN DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"}, {0, NULL, 0, NULL, NULL} }; @@ -3518,7 +3531,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "frames", 0, 0, INT_MAX, "Tracked Frames", @@ -3538,7 +3551,7 @@ static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_new_object(tracking, "Object"); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3555,7 +3568,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** remove tracking object *********************/ @@ -3576,7 +3589,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) BKE_tracking_remove_object(tracking, object); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3593,7 +3606,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** copy tracks to clipboard operator *********************/ @@ -3647,7 +3660,7 @@ static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_clipboard_paste_tracks(tracking, object); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3664,5 +3677,5 @@ void CLIP_OT_paste_tracks(wmOperatorType *ot) ot->poll = paste_tracks_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } From 2b53595ad64a477a07ebc687d207114155f629bc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 08:55:29 +0000 Subject: [PATCH 122/143] Woops, some unwanted spaces remained in source files. --- source/blender/editors/space_clip/clip_ops.c | 2 +- source/blender/editors/space_clip/tracking_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index fb99bf37a24..e89e85ce591 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -414,7 +414,7 @@ void CLIP_OT_view_pan(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* flags */ - ot->flag = OPTYPE _ BLOCKING; + ot->flag = OPTYPE_BLOCKING; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 8e11269254f..fc93bcc0409 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -3516,7 +3516,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) static EnumPropertyItem actions_items[] = { {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select unclean tracks"}, {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete unclean tracks"}, - {TRACKING_CLEAN DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"}, + {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete unclean segments of tracks"}, {0, NULL, 0, NULL, NULL} }; From f618bada2b27ab9b41ebbdc3be8baff4e798a6c0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 09:01:55 +0000 Subject: [PATCH 123/143] Cleanup of intern/SConstript: CSG is not in source tree anymore, remove option to use it --- intern/SConscript | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/intern/SConscript b/intern/SConscript index b6305f7dbab..a1e7f840800 100644 --- a/intern/SConscript +++ b/intern/SConscript @@ -16,25 +16,16 @@ SConscript(['audaspace/SConscript', 'mikktspace/SConscript', 'smoke/SConscript']) -# NEW_CSG was intended for intern/csg, but -# getting it to compile is difficult -# intern/bsp has been used anyway, so -# perhaps get rid of intern/csg? -NEW_CSG = 'false' - if env ['WITH_BF_REMESH']: SConscript(['dualcon/SConscript']) if env['WITH_BF_FLUID']: SConscript(['elbeem/SConscript']) - + if env['WITH_BF_CYCLES']: SConscript(['cycles/SConscript']) -if NEW_CSG == 'false': - SConscript(['bsp/SConscript']) -else: - SConscript(['csg/SConscript']) +SConscript(['bsp/SConscript']) if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-mingw', 'linuxcross', 'win64-vc'): SConscript(['utfconv/SConscript']) From 69fc654f94cc16176248aeeef89dddd03ffebdc8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 May 2012 09:30:15 +0000 Subject: [PATCH 124/143] Style cleanup: change ffmpeg, avi and frame server api to rna-ish naming style --- source/blender/blenkernel/BKE_writeavi.h | 4 +- source/blender/blenkernel/BKE_writeffmpeg.h | 24 +++--- .../blender/blenkernel/BKE_writeframeserver.h | 10 +-- source/blender/blenkernel/intern/writeavi.c | 22 ++--- .../blender/blenkernel/intern/writeffmpeg.c | 86 +++++++++---------- .../blenkernel/intern/writeframeserver.c | 8 +- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/screen/screendump.c | 2 +- source/blender/makesrna/intern/rna_scene.c | 8 +- .../blender/makesrna/intern/rna_scene_api.c | 2 +- .../blender/render/intern/source/pipeline.c | 2 +- 11 files changed, 85 insertions(+), 85 deletions(-) diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index 03174fb5284..78875951ca4 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -51,8 +51,8 @@ typedef struct bMovieHandle { void (*get_movie_path)(char *string, struct RenderData *rd); /* optional */ } bMovieHandle; -bMovieHandle *BKE_get_movie_handle(const char imtype); -void BKE_makeanimstring(char *string, struct RenderData *rd); +bMovieHandle *BKE_movie_handle_get(const char imtype); +void BKE_movie_filepath_get(char *string, struct RenderData *rd); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index c35105f7b8b..f8382f75c0a 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -66,20 +66,20 @@ struct RenderData; struct ReportList; struct Scene; -extern int start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); -extern void end_ffmpeg(void); -extern int append_ffmpeg(struct RenderData *rd, int start_frame, int frame, int *pixels, - int rectx, int recty, struct ReportList *reports); -void filepath_ffmpeg(char* string, struct RenderData* rd); +int BKE_ffmpeg_start(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); +void BKE_ffmpeg_end(void); +int BKE_ffmpeg_append(struct RenderData *rd, int start_frame, int frame, int *pixels, + int rectx, int recty, struct ReportList *reports); +void BKE_ffmpeg_filepath_get(char* string, struct RenderData* rd); -extern void ffmpeg_set_preset(struct RenderData *rd, int preset); -extern void ffmpeg_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf); -extern void ffmpeg_verify_codec_settings(struct RenderData *rd); -extern int ffmpeg_alpha_channel_supported(struct RenderData *rd); +void BKE_ffmpeg_preset_set(struct RenderData *rd, int preset); +void BKE_ffmpeg_image_type_verify(struct RenderData *rd, struct ImageFormatData *imf); +void BKE_ffmpeg_codec_settings_verify(struct RenderData *rd); +int BKE_ffmpeg_alpha_channel_is_supported(struct RenderData *rd); -extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); -extern int ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); -extern void ffmpeg_property_del(struct RenderData *rd, void *type, void *prop_); +struct IDProperty *BKE_ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); +int BKE_ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); +void BKE_ffmpeg_property_del(struct RenderData *rd, void *type, void *prop_); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h index cb607e1473c..bdce9abe8ad 100644 --- a/source/blender/blenkernel/BKE_writeframeserver.h +++ b/source/blender/blenkernel/BKE_writeframeserver.h @@ -40,11 +40,11 @@ struct RenderData; struct ReportList; struct Scene; -extern int start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); -extern void end_frameserver(void); -extern int append_frameserver(struct RenderData *rd, int start_frame, int frame, int *pixels, - int rectx, int recty, struct ReportList *reports); -extern int frameserver_loop(struct RenderData *rd, struct ReportList *reports); +int BKE_frameserver_start(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); +void BKE_frameserver_end(void); +int BKE_frameserver_append(struct RenderData *rd, int start_frame, int frame, int *pixels, + int rectx, int recty, struct ReportList *reports); +int BKE_frameserver_loop(struct RenderData *rd, struct ReportList *reports); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index ba8a46256c5..841a0f84fed 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -68,7 +68,7 @@ static void filepath_avi(char *string, RenderData *rd); #include "BKE_writeframeserver.h" -bMovieHandle *BKE_get_movie_handle(const char imtype) +bMovieHandle *BKE_movie_handle_get(const char imtype) { static bMovieHandle mh; @@ -97,18 +97,18 @@ bMovieHandle *BKE_get_movie_handle(const char imtype) #endif #ifdef WITH_FFMPEG if (ELEM4(imtype, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_THEORA)) { - mh.start_movie = start_ffmpeg; - mh.append_movie = append_ffmpeg; - mh.end_movie = end_ffmpeg; - mh.get_movie_path = filepath_ffmpeg; + mh.start_movie = BKE_ffmpeg_start; + mh.append_movie = BKE_ffmpeg_append; + mh.end_movie = BKE_ffmpeg_end; + mh.get_movie_path = BKE_ffmpeg_filepath_get; } #endif #ifdef WITH_FRAMESERVER if (imtype == R_IMF_IMTYPE_FRAMESERVER) { - mh.start_movie = start_frameserver; - mh.append_movie = append_frameserver; - mh.end_movie = end_frameserver; - mh.get_next_frame = frameserver_loop; + mh.start_movie = BKE_frameserver_start; + mh.append_movie = BKE_frameserver_append; + mh.end_movie = BKE_frameserver_end; + mh.get_next_frame = BKE_frameserver_loop; } #endif @@ -228,9 +228,9 @@ static void end_avi(void) } /* similar to BKE_makepicstring() */ -void BKE_makeanimstring(char *string, RenderData *rd) +void BKE_movie_filepath_get(char *string, RenderData *rd) { - bMovieHandle *mh= BKE_get_movie_handle(rd->im_format.imtype); + bMovieHandle *mh= BKE_movie_handle_get(rd->im_format.imtype); if (mh->get_movie_path) mh->get_movie_path(string, rd); else diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 7330269c1f4..61f26ede9ea 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -678,7 +678,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report do_init_ffmpeg(); /* Determine the correct filename */ - filepath_ffmpeg(name, rd); + BKE_ffmpeg_filepath_get(name, rd); fprintf(stderr, "Starting output to %s(ffmpeg)...\n" " Using type=%d, codec=%d, audio_codec=%d,\n" " video_bitrate=%d, audio_bitrate=%d,\n" @@ -884,7 +884,7 @@ void flush_ffmpeg(void) * ********************************************************************** */ /* Get the output filename-- similar to the other output formats */ -void filepath_ffmpeg(char* string, RenderData* rd) +void BKE_ffmpeg_filepath_get(char* string, RenderData* rd) { char autosplit[20]; @@ -925,7 +925,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) } } -int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports) +int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports) { int success; @@ -949,7 +949,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo return success; } -void end_ffmpeg(void); +void BKE_ffmpeg_end(void); #ifdef WITH_AUDASPACE static void write_audio_frames(double to_pts) @@ -965,7 +965,7 @@ static void write_audio_frames(double to_pts) } #endif -int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports) +int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports) { AVFrame* avframe; int success = 1; @@ -983,7 +983,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r if (ffmpeg_autosplit) { if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) { - end_ffmpeg(); + BKE_ffmpeg_end(); ffmpeg_autosplit_count++; success &= start_ffmpeg_impl(rd, rectx, recty, reports); } @@ -996,7 +996,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r return success; } -void end_ffmpeg(void) +void BKE_ffmpeg_end(void) { unsigned int i; @@ -1074,7 +1074,7 @@ void end_ffmpeg(void) /* properties */ -void ffmpeg_property_del(RenderData *rd, void *type, void *prop_) +void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_) { struct IDProperty *prop = (struct IDProperty *) prop_; IDProperty * group; @@ -1091,7 +1091,7 @@ void ffmpeg_property_del(RenderData *rd, void *type, void *prop_) } } -IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index) +IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index) { AVCodecContext c; const AVOption * o; @@ -1184,7 +1184,7 @@ static const AVOption *my_av_find_opt(void *v, const char *name, return NULL; } -int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * str) +int BKE_ffmpeg_property_add_string(RenderData *rd, const char * type, const char * str) { AVCodecContext c; const AVOption * o = 0; @@ -1220,12 +1220,12 @@ int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * s } if (param && o->type != FF_OPT_TYPE_CONST && o->unit) { p = my_av_find_opt(&c, param, o->unit, 0, 0); - prop = ffmpeg_property_add(rd, + prop = BKE_ffmpeg_property_add(rd, (char*) type, p - c.av_class->option, o - c.av_class->option); } else { - prop = ffmpeg_property_add(rd, + prop = BKE_ffmpeg_property_add(rd, (char*) type, o - c.av_class->option, 0); } @@ -1268,37 +1268,37 @@ static void ffmpeg_set_expert_options(RenderData *rd) * Use CABAC coder. Using "coder:1", which should be equivalent, * crashes Blender for some reason. Either way - this is no big deal. */ - ffmpeg_property_add_string(rd, "video", "coder:vlc"); + BKE_ffmpeg_property_add_string(rd, "video", "coder:vlc"); /* * The other options were taken from the libx264-default.preset * included in the ffmpeg distribution. */ // ffmpeg_property_add_string(rd, "video", "flags:loop"); // this breaks compatibility for QT - ffmpeg_property_add_string(rd, "video", "cmp:chroma"); - ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); - ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); - ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); - ffmpeg_property_add_string(rd, "video", "me:hex"); - ffmpeg_property_add_string(rd, "video", "subq:6"); - ffmpeg_property_add_string(rd, "video", "me_range:16"); - ffmpeg_property_add_string(rd, "video", "qdiff:4"); - ffmpeg_property_add_string(rd, "video", "keyint_min:25"); - ffmpeg_property_add_string(rd, "video", "sc_threshold:40"); - ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71"); - ffmpeg_property_add_string(rd, "video", "b_strategy:1"); - ffmpeg_property_add_string(rd, "video", "bf:3"); - ffmpeg_property_add_string(rd, "video", "refs:2"); - ffmpeg_property_add_string(rd, "video", "qcomp:0.6"); - ffmpeg_property_add_string(rd, "video", "directpred:3"); - ffmpeg_property_add_string(rd, "video", "trellis:0"); - ffmpeg_property_add_string(rd, "video", "flags2:wpred"); - ffmpeg_property_add_string(rd, "video", "flags2:dct8x8"); - ffmpeg_property_add_string(rd, "video", "flags2:fastpskip"); - ffmpeg_property_add_string(rd, "video", "wpredp:2"); + BKE_ffmpeg_property_add_string(rd, "video", "cmp:chroma"); + BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); + BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); + BKE_ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); + BKE_ffmpeg_property_add_string(rd, "video", "me:hex"); + BKE_ffmpeg_property_add_string(rd, "video", "subq:6"); + BKE_ffmpeg_property_add_string(rd, "video", "me_range:16"); + BKE_ffmpeg_property_add_string(rd, "video", "qdiff:4"); + BKE_ffmpeg_property_add_string(rd, "video", "keyint_min:25"); + BKE_ffmpeg_property_add_string(rd, "video", "sc_threshold:40"); + BKE_ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71"); + BKE_ffmpeg_property_add_string(rd, "video", "b_strategy:1"); + BKE_ffmpeg_property_add_string(rd, "video", "bf:3"); + BKE_ffmpeg_property_add_string(rd, "video", "refs:2"); + BKE_ffmpeg_property_add_string(rd, "video", "qcomp:0.6"); + BKE_ffmpeg_property_add_string(rd, "video", "directpred:3"); + BKE_ffmpeg_property_add_string(rd, "video", "trellis:0"); + BKE_ffmpeg_property_add_string(rd, "video", "flags2:wpred"); + BKE_ffmpeg_property_add_string(rd, "video", "flags2:dct8x8"); + BKE_ffmpeg_property_add_string(rd, "video", "flags2:fastpskip"); + BKE_ffmpeg_property_add_string(rd, "video", "wpredp:2"); if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) - ffmpeg_property_add_string(rd, "video", "cqp:0"); + BKE_ffmpeg_property_add_string(rd, "video", "cqp:0"); } #if 0 /* disabled for after release */ else if (codec_id == CODEC_ID_DNXHD) { @@ -1308,7 +1308,7 @@ static void ffmpeg_set_expert_options(RenderData *rd) #endif } -void ffmpeg_set_preset(RenderData *rd, int preset) +void BKE_ffmpeg_preset_set(RenderData *rd, int preset) { int isntsc = (rd->frs_sec != 25); @@ -1402,7 +1402,7 @@ void ffmpeg_set_preset(RenderData *rd, int preset) ffmpeg_set_expert_options(rd); } -void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) +void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf) { int audio= 0; @@ -1414,7 +1414,7 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) rd->ffcodecdata.codec = CODEC_ID_MPEG2VIDEO; - ffmpeg_set_preset(rd, FFMPEG_PRESET_DVD); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_DVD); } if (rd->ffcodecdata.type == FFMPEG_OGG) { rd->ffcodecdata.type = FFMPEG_MPEG2; @@ -1424,19 +1424,19 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) } else if (imf->imtype == R_IMF_IMTYPE_H264) { if (rd->ffcodecdata.codec != CODEC_ID_H264) { - ffmpeg_set_preset(rd, FFMPEG_PRESET_H264); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264); audio= 1; } } else if (imf->imtype == R_IMF_IMTYPE_XVID) { if (rd->ffcodecdata.codec != CODEC_ID_MPEG4) { - ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_XVID); audio= 1; } } else if (imf->imtype == R_IMF_IMTYPE_THEORA) { if (rd->ffcodecdata.codec != CODEC_ID_THEORA) { - ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_THEORA); audio= 1; } } @@ -1447,12 +1447,12 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) } } -void ffmpeg_verify_codec_settings(RenderData *rd) +void BKE_ffmpeg_codec_settings_verify(RenderData *rd) { ffmpeg_set_expert_options(rd); } -int ffmpeg_alpha_channel_supported(RenderData *rd) +int BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd) { int codec = rd->ffcodecdata.codec; diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 0ff095607e3..b5965838a30 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -110,7 +110,7 @@ static int closesocket(int fd) } #endif -int start_frameserver(struct Scene *scene, RenderData *UNUSED(rd), int rectx, int recty, ReportList *reports) +int BKE_frameserver_start(struct Scene *scene, RenderData *UNUSED(rd), int rectx, int recty, ReportList *reports) { struct sockaddr_in addr; int arg = 1; @@ -258,7 +258,7 @@ static int handle_request(RenderData *rd, char * req) return -1; } -int frameserver_loop(RenderData *rd, ReportList *UNUSED(reports)) +int BKE_frameserver_loop(RenderData *rd, ReportList *UNUSED(reports)) { fd_set readfds; struct timeval tv; @@ -371,7 +371,7 @@ static void serve_ppm(int *pixels, int rectx, int recty) connsock = -1; } -int append_frameserver(RenderData *UNUSED(rd), int UNUSED(start_frame), int frame, int *pixels, +int BKE_frameserver_append(RenderData *UNUSED(rd), int UNUSED(start_frame), int frame, int *pixels, int rectx, int recty, ReportList *UNUSED(reports)) { fprintf(stderr, "Serving frame: %d\n", frame); @@ -386,7 +386,7 @@ int append_frameserver(RenderData *UNUSED(rd), int UNUSED(start_frame), int fram return 0; } -void end_frameserver(void) +void BKE_frameserver_end(void) { if (connsock != -1) { closesocket(connsock); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index b106bd8754a..de3d2d4e871 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -451,7 +451,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) scene = oglrender->scene; oglrender->reports = op->reports; - oglrender->mh = BKE_get_movie_handle(scene->r.im_format.imtype); + oglrender->mh = BKE_movie_handle_get(scene->r.im_format.imtype); if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { if (!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { screen_opengl_render_end(C, oglrender); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index d4078fe7c33..a7161d7f01b 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -315,7 +315,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float { ScreenshotJob *sj= sjv; RenderData rd= sj->scene->r; - bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype); + bMovieHandle *mh= BKE_movie_handle_get(sj->scene->r.im_format.imtype); /* we need this as local variables for renderdata */ rd.frs_sec= U.scrcastfps; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 9a273d90f14..2cb89ec25e9 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -707,7 +707,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) Scene *scene = ptr->id.data; RenderData *rd = &scene->r; #ifdef WITH_FFMPEG - ffmpeg_verify_image_type(rd, imf); + BKE_ffmpeg_image_type_verify(rd, imf); #endif #ifdef WITH_QUICKTIME quicktime_verify_image_type(rd, imf); @@ -750,7 +750,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P Scene *scene = ptr->id.data; RenderData *rd = &scene->r; - if (ffmpeg_alpha_channel_supported(rd)) + if (BKE_ffmpeg_alpha_channel_is_supported(rd)) chan_flag |= IMA_CHAN_FLAG_ALPHA; } #endif @@ -941,7 +941,7 @@ static void rna_FFmpegSettings_lossless_output_set(PointerRNA *ptr, int value) else rd->ffcodecdata.flags &= ~FFMPEG_LOSSLESS_OUTPUT; - ffmpeg_verify_codec_settings(rd); + BKE_ffmpeg_codec_settings_verify(rd); } static void rna_FFmpegSettings_codec_settings_update(Main *UNUSED(bmain), Scene *UNUSED(scene_unused), PointerRNA *ptr) @@ -949,7 +949,7 @@ static void rna_FFmpegSettings_codec_settings_update(Main *UNUSED(bmain), Scene Scene *scene = (Scene *) ptr->id.data; RenderData *rd = &scene->r; - ffmpeg_verify_codec_settings(rd); + BKE_ffmpeg_codec_settings_verify(rd); } #endif diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index a5e807a9622..e3bb6e7b58a 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -75,7 +75,7 @@ static void rna_Scene_update_tagged(Scene *scene) static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) { if (BKE_imtype_is_movie(rd->im_format.imtype)) - BKE_makeanimstring(name, rd); + BKE_movie_filepath_get(name, rd); else BKE_makepicstring(name, rd->pic, G.main->name, (frame == INT_MIN) ? rd->cfra : frame, rd->im_format.imtype, rd->scemode & R_EXTENSION, TRUE); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 63daaaed21a..4cb594b6840 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2131,7 +2131,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* saves images to disk */ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra) { - bMovieHandle *mh= BKE_get_movie_handle(scene->r.im_format.imtype); + bMovieHandle *mh= BKE_movie_handle_get(scene->r.im_format.imtype); int cfrao= scene->r.cfra; int nfra, totrendered= 0, totskipped= 0; From 022d12a721b04799423edf646b2a08bd48edfe6a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 7 May 2012 10:53:09 +0000 Subject: [PATCH 125/143] Fix most of #31307: cycles panorama camera not working correct with speed vectors and window texture coordinates. Only for Fisheye Equisolid it's still not working correct yet. Patch from Dalai with modifications. --- intern/cycles/kernel/kernel_camera.h | 13 -- intern/cycles/kernel/kernel_montecarlo.h | 118 ------------- intern/cycles/kernel/kernel_path.h | 1 + intern/cycles/kernel/kernel_projection.h | 207 +++++++++++++++++++++++ intern/cycles/kernel/kernel_triangle.h | 41 ++++- intern/cycles/kernel/kernel_types.h | 4 +- intern/cycles/kernel/svm/svm_tex_coord.h | 46 ++--- intern/cycles/render/camera.cpp | 26 ++- intern/cycles/render/light.cpp | 2 - intern/cycles/util/util_math.h | 5 + intern/cycles/util/util_transform.h | 4 +- 11 files changed, 300 insertions(+), 167 deletions(-) create mode 100644 intern/cycles/kernel/kernel_projection.h diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 220ebec13ce..e1b474d8537 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -134,19 +134,6 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa /* Panorama Camera */ -__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); - 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); - } -} - __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, Ray *ray) { Transform rastertocamera = kernel_data.cam.rastertocamera; diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index f51ce263ea2..bdd147f83d3 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -185,124 +185,6 @@ __device float2 regular_polygon_sample(float corners, float rotation, float u, f return make_float2(cr*p.x - sr*p.y, sr*p.x + cr*p.y); } -/* Spherical coordinates <-> Cartesian direction */ - -__device float2 direction_to_spherical(float3 dir) -{ - float theta = acosf(dir.z); - float phi = atan2f(dir.x, dir.y); - - return make_float2(theta, phi); -} - -__device float3 spherical_to_direction(float theta, float phi) -{ - return make_float3( - sinf(theta)*cosf(phi), - sinf(theta)*sinf(phi), - cosf(theta)); -} - -/* Equirectangular coordinates <-> Cartesian direction */ - -__device float2 direction_to_equirectangular(float3 dir) -{ - float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; - float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; - - return make_float2(u, v); -} - -__device float3 equirectangular_to_direction(float u, float v) -{ - float phi = M_PI_F*(1.0f - 2.0f*u); - float theta = M_PI_F*(1.0f - v); - - return make_float3( - sin(theta)*cos(phi), - sin(theta)*sin(phi), - cos(theta)); -} - -/* Fisheye <- Cartesian direction */ - -__device float3 fisheye_to_direction(float u, float v, float fov) -{ - u = (u - 0.5f) * 2.0f; - v = (v - 0.5f) * 2.0f; - - float r = sqrt(u*u + v*v); - - if(r > 1.0f) - return make_float3(0.0f, 0.0f, 0.0f); - - float phi = acosf((r != 0.0f)? u/r: 0.0f); - float theta = asinf(r) * (fov / M_PI_F); - - if(v < 0.0f) 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) -{ - u = (u - 0.5f) * width; - v = (v - 0.5f) * height; - - float rmax = 2.0f * lens * sinf(fov * 0.25f); - float r = sqrt(u*u + v*v); - - if(r > rmax) - return make_float3(0.0f, 0.0f, 0.0f); - - float phi = acosf((r != 0.0f)? u/r: 0.0f); - float theta = 2.0f * asinf(r/(2.0f * lens)); - - if(v < 0.0f) 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) -{ - /* point on sphere */ - float3 dir; - - dir.x = 2.0f*u - 1.0f; - dir.z = 2.0f*v - 1.0f; - dir.y = -sqrt(max(1.0f - dir.x*dir.x - dir.z*dir.z, 0.0f)); - - /* reflection */ - float3 I = make_float3(0.0f, -1.0f, 0.0f); - - return 2.0f*dot(dir, I)*dir - I; -} - -__device float2 direction_to_mirrorball(float3 dir) -{ - /* inverse of mirrorball_to_direction */ - dir.y -= 1.0f; - - float div = 2.0f*sqrt(max(-0.5f*dir.y, 0.0f)); - if(div > 0.0f) - dir /= div; - - float u = 0.5f*(dir.x + 1.0f); - float v = 0.5f*(dir.z + 1.0f); - - return make_float2(u, v); -} - CCL_NAMESPACE_END #endif /* __KERNEL_MONTECARLO_CL__ */ diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index d53951a1f34..e0e17ee57dc 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -18,6 +18,7 @@ #include "kernel_differential.h" #include "kernel_montecarlo.h" +#include "kernel_projection.h" #include "kernel_object.h" #include "kernel_triangle.h" #ifdef __QBVH__ diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h new file mode 100644 index 00000000000..43535182d61 --- /dev/null +++ b/intern/cycles/kernel/kernel_projection.h @@ -0,0 +1,207 @@ +/* + * Parts adapted from Open Shading Language with this license: + * + * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. + * All Rights Reserved. + * + * Modifications Copyright 2011, Blender Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sony Pictures Imageworks nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __KERNEL_PROJECTION_CL__ +#define __KERNEL_PROJECTION_CL__ + +CCL_NAMESPACE_BEGIN + +/* Spherical coordinates <-> Cartesian direction */ + +__device float2 direction_to_spherical(float3 dir) +{ + float theta = acosf(dir.z); + float phi = atan2f(dir.x, dir.y); + + return make_float2(theta, phi); +} + +__device float3 spherical_to_direction(float theta, float phi) +{ + return make_float3( + sinf(theta)*cosf(phi), + sinf(theta)*sinf(phi), + cosf(theta)); +} + +/* Equirectangular coordinates <-> Cartesian direction */ + +__device float2 direction_to_equirectangular(float3 dir) +{ + float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; + float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; + + return make_float2(u, v); +} + +__device float3 equirectangular_to_direction(float u, float v) +{ + float phi = M_PI_F*(1.0f - 2.0f*u); + float theta = M_PI_F*(1.0f - v); + + return make_float3( + sin(theta)*cos(phi), + sin(theta)*sin(phi), + cos(theta)); +} + +/* Fisheye <- Cartesian direction */ + +__device float2 direction_to_fisheye(float3 dir, float fov) +{ + float r = atan2f(sqrt(dir.y*dir.y + dir.z*dir.z), dir.x) / fov; + float phi = atan2(dir.z, dir.y); + + float u = r * cos(phi) + 0.5f; + float v = r * sin(phi) + 0.5f; + + return make_float2(u, v); +} + +__device float3 fisheye_to_direction(float u, float v, float fov) +{ + u = (u - 0.5f) * 2.0f; + v = (v - 0.5f) * 2.0f; + + float r = sqrt(u*u + v*v); + + if(r > 1.0f) + return make_float3(0.0f, 0.0f, 0.0f); + + float phi = acosf((r != 0.0f)? u/r: 0.0f); + float theta = asinf(r) * (fov / M_PI_F); + + if(v < 0.0f) phi = -phi; + + return make_float3( + cosf(theta), + -cosf(phi)*sinf(theta), + sinf(phi)*sinf(theta) + ); +} + +__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float fov, float width, float height) +{ + /* XXX not implemented yet */ + float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; + float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; + + return make_float2(u, v); +} + +__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.0f * lens * sinf(fov * 0.25f); + float r = sqrt(u*u + v*v); + + if(r > rmax) + return make_float3(0.0f, 0.0f, 0.0f); + + float phi = acosf((r != 0.0f)? u/r: 0.0f); + float theta = 2.0f * asinf(r/(2.0f * lens)); + + if(v < 0.0f) 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) +{ + /* point on sphere */ + float3 dir; + + dir.x = 2.0f*u - 1.0f; + dir.z = 2.0f*v - 1.0f; + dir.y = -sqrt(max(1.0f - dir.x*dir.x - dir.z*dir.z, 0.0f)); + + /* reflection */ + float3 I = make_float3(0.0f, -1.0f, 0.0f); + + return 2.0f*dot(dir, I)*dir - I; +} + +__device float2 direction_to_mirrorball(float3 dir) +{ + /* inverse of mirrorball_to_direction */ + dir.y -= 1.0f; + + float div = 2.0f*sqrt(max(-0.5f*dir.y, 0.0f)); + if(div > 0.0f) + dir /= div; + + float u = 0.5f*(dir.x + 1.0f); + float v = 0.5f*(dir.z + 1.0f); + + return make_float2(u, v); +} + +__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); + 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); + } +} + +__device float2 direction_to_panorama(KernelGlobals *kg, float3 dir) +{ + switch(kernel_data.cam.panorama_type) { + case PANORAMA_EQUIRECTANGULAR: + return direction_to_equirectangular(dir); + case PANORAMA_FISHEYE_EQUIDISTANT: + return direction_to_fisheye(dir, kernel_data.cam.fisheye_fov); + case PANORAMA_FISHEYE_EQUISOLID: + default: + return direction_to_fisheye_equisolid(dir, kernel_data.cam.fisheye_lens, + kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight); + } +} + +CCL_NAMESPACE_END + +#endif /* __KERNEL_PROJECTION_CL__ */ + diff --git a/intern/cycles/kernel/kernel_triangle.h b/intern/cycles/kernel/kernel_triangle.h index 1b3956c1dd4..674c3b52539 100644 --- a/intern/cycles/kernel/kernel_triangle.h +++ b/intern/cycles/kernel/kernel_triangle.h @@ -217,15 +217,42 @@ __device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd) tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_TRANSFORM_MOTION_POST); motion_post = transform_point(&tfm, motion_post); - /* camera motion */ - tfm = kernel_data.cam.worldtoraster; - float3 P = transform_perspective(&tfm, sd->P); + float3 P; - tfm = kernel_data.cam.motion.pre; - motion_pre = transform_perspective(&tfm, motion_pre) - P; + /* camera motion, for perspective/orthographic motion.pre/post will be a + world-to-raster matrix, for panorama it's world-to-camera */ + if (kernel_data.cam.type != CAMERA_PANORAMA) { + tfm = kernel_data.cam.worldtoraster; + P = transform_perspective(&tfm, sd->P); - tfm = kernel_data.cam.motion.post; - motion_post = P - transform_perspective(&tfm, motion_post); + tfm = kernel_data.cam.motion.pre; + motion_pre = transform_perspective(&tfm, motion_pre); + + tfm = kernel_data.cam.motion.post; + motion_post = transform_perspective(&tfm, motion_post); + } + else { + tfm = kernel_data.cam.worldtocamera; + P = normalize(transform_point(&tfm, sd->P)); + P = float2_to_float3(direction_to_panorama(kg, P)); + P.x *= kernel_data.cam.width; + P.y *= kernel_data.cam.height; + + tfm = kernel_data.cam.motion.pre; + motion_pre = normalize(transform_point(&tfm, motion_pre)); + motion_pre = float2_to_float3(direction_to_panorama(kg, motion_pre)); + motion_pre.x *= kernel_data.cam.width; + motion_pre.y *= kernel_data.cam.height; + + tfm = kernel_data.cam.motion.post; + motion_post = normalize(transform_point(&tfm, motion_post)); + motion_post = float2_to_float3(direction_to_panorama(kg, motion_post)); + motion_post.x *= kernel_data.cam.width; + motion_post.y *= kernel_data.cam.height; + } + + motion_pre = motion_pre - P; + motion_post = P - motion_post; return make_float4(motion_pre.x, motion_pre.y, motion_post.x, motion_post.y); } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 8c4334d61f3..edca9f8d34d 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -491,7 +491,9 @@ typedef struct KernelCamera { /* sensor size */ float sensorwidth; float sensorheight; - int pad1, pad2; + + /* render size */ + float width, height; /* more matrices */ Transform screentoworld; diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h index 3b73cac5430..169307574a2 100644 --- a/intern/cycles/kernel/svm/svm_tex_coord.h +++ b/intern/cycles/kernel/svm/svm_tex_coord.h @@ -20,12 +20,35 @@ CCL_NAMESPACE_BEGIN /* Texture Coordinate Node */ -__device float3 svm_background_offset(KernelGlobals *kg) +__device_inline float3 svm_background_offset(KernelGlobals *kg) { Transform cameratoworld = kernel_data.cam.cameratoworld; return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); } +__device_inline float3 svm_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P) +{ + if(kernel_data.cam.type != CAMERA_PANORAMA) { + if(sd->object != ~0) + P += svm_background_offset(kg); + + Transform tfm = kernel_data.cam.worldtondc; + return transform_perspective(&tfm, P); + } + else { + Transform tfm = kernel_data.cam.worldtocamera; + + if(sd->object != ~0) + P = normalize(transform_point(&tfm, P)); + else + P = normalize(transform_direction(&tfm, P)); + + float2 uv = direction_to_panorama(kg, P);; + + return make_float3(uv.x, uv.y, 0.0f); + } +} + __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { float3 data; @@ -59,12 +82,7 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack break; } case NODE_TEXCO_WINDOW: { - Transform tfm = kernel_data.cam.worldtondc; - - if(sd->object != ~0) - data = transform_perspective(&tfm, sd->P); - else - data = transform_perspective(&tfm, sd->P + svm_background_offset(kg)); + data = svm_world_to_ndc(kg, sd, sd->P); break; } case NODE_TEXCO_REFLECTION: { @@ -113,12 +131,7 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, floa break; } case NODE_TEXCO_WINDOW: { - Transform tfm = kernel_data.cam.worldtondc; - - if(sd->object != ~0) - data = transform_perspective(&tfm, sd->P + sd->dP.dx); - else - data = transform_perspective(&tfm, sd->P + sd->dP.dx + svm_background_offset(kg)); + data = svm_world_to_ndc(kg, sd, sd->P + sd->dP.dx); break; } case NODE_TEXCO_REFLECTION: { @@ -170,12 +183,7 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa break; } case NODE_TEXCO_WINDOW: { - Transform tfm = kernel_data.cam.worldtondc; - - if(sd->object != ~0) - data = transform_perspective(&tfm, sd->P + sd->dP.dy); - else - data = transform_perspective(&tfm, sd->P + sd->dP.dy + svm_background_offset(kg)); + data = svm_world_to_ndc(kg, sd, sd->P + sd->dP.dy); break; } case NODE_TEXCO_REFLECTION: { diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 95405519cc0..3ecffab7cbc 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -158,13 +158,25 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) kcam->have_motion = 0; if(need_motion == Scene::MOTION_PASS) { - if(use_motion) { - kcam->motion.pre = transform_inverse(motion.pre * rastertocamera); - kcam->motion.post = transform_inverse(motion.post * rastertocamera); + if(type == CAMERA_PANORAMA) { + if(use_motion) { + kcam->motion.pre = transform_inverse(motion.pre); + kcam->motion.post = transform_inverse(motion.post); + } + else { + kcam->motion.pre = kcam->worldtocamera; + kcam->motion.post = kcam->worldtocamera; + } } else { - kcam->motion.pre = worldtoraster; - kcam->motion.post = worldtoraster; + if(use_motion) { + kcam->motion.pre = transform_inverse(motion.pre * rastertocamera); + kcam->motion.post = transform_inverse(motion.post * rastertocamera); + } + else { + kcam->motion.pre = worldtoraster; + kcam->motion.post = worldtoraster; + } } } else if(need_motion == Scene::MOTION_BLUR) { @@ -196,6 +208,10 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) kcam->sensorwidth = sensorwidth; kcam->sensorheight = sensorheight; + /* render size */ + kcam->width = width; + kcam->height = height; + /* store differentials */ kcam->dx = float3_to_float4(dx); kcam->dy = float3_to_float4(dy); diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 316e5cec9aa..267cb8e6d3a 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -26,8 +26,6 @@ #include "util_foreach.h" #include "util_progress.h" -#include "kernel_montecarlo.h" - CCL_NAMESPACE_BEGIN static void dump_background_pixels(Device *device, DeviceScene *dscene, int res, vector& pixels) diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 7b527241847..8c0e7105b22 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -507,6 +507,11 @@ __device_inline float3 fabs(float3 a) #endif +__device_inline float3 float2_to_float3(const float2 a) +{ + return make_float3(a.x, a.y, 0.0f); +} + __device_inline float3 float4_to_float3(const float4 a) { return make_float3(a.x, a.y, a.z); diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index 7136c185d04..e4897ee6787 100644 --- a/intern/cycles/util/util_transform.h +++ b/intern/cycles/util/util_transform.h @@ -253,7 +253,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) /* the epsilon here is quite arbitrary, but this function is only used for surface area and bump, where we except it to not be so sensitive */ Transform ttfm = transform_transpose(tfm); - float eps = 1e-7f; + float eps = 1e-6f; float sx = len_squared(float4_to_float3(tfm.x)); float sy = len_squared(float4_to_float3(tfm.y)); @@ -261,7 +261,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) float stx = len_squared(float4_to_float3(ttfm.x)); float sty = len_squared(float4_to_float3(ttfm.y)); float stz = len_squared(float4_to_float3(ttfm.z)); - + if(fabsf(sx - sy) < eps && fabsf(sx - sz) < eps && fabsf(sx - stx) < eps && fabsf(sx - sty) < eps && fabsf(sx - stz) < eps) { From 97df6dab2fa2da856ee4c096ed94a9569a9e5abc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 7 May 2012 10:53:12 +0000 Subject: [PATCH 126/143] GHOST/Cocoa: detect tablet event to disable continuous grab. Don't have tablet to test it though, can someone with Mac + tablet confirm if continuous grab gets automatically disabled when using the tablet? --- intern/ghost/intern/GHOST_SystemCocoa.h | 1 + intern/ghost/intern/GHOST_SystemCocoa.mm | 61 +++++++++--------------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 2220955c270..ce7677aee7a 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -247,6 +247,7 @@ protected: * @return Indication whether the event was handled. */ GHOST_TSuccess handleTabletEvent(void *eventPtr, short eventType); + bool handleTabletEvent(void *eventPtr); /** * Handles a mouse event. diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index d95f7727747..8baf3a12c16 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1421,6 +1421,23 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT return GHOST_kSuccess; } +bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr) +{ + NSEvent *event = (NSEvent *)eventPtr; + + switch ([event subtype]) { + case NX_SUBTYPE_TABLET_POINT: + handleTabletEvent(eventPtr, NSTabletPoint); + return true; + case NX_SUBTYPE_TABLET_PROXIMITY: + handleTabletEvent(eventPtr, NSTabletProximity); + return true; + default: + //No tablet event included : do nothing + return false; + } + +} GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) { @@ -1432,6 +1449,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) //printf("\nW failure for event 0x%x",[event type]); return GHOST_kFailure; } + + bool is_tablet = false; switch ([event type]) { @@ -1440,17 +1459,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSOtherMouseDown: pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - handleTabletEvent(eventPtr, NSTabletPoint); - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - handleTabletEvent(eventPtr, NSTabletProximity); - break; - default: - //No tablet event included : do nothing - break; - } + is_tablet = handleTabletEvent(event); break; case NSLeftMouseUp: @@ -1458,45 +1467,21 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSOtherMouseUp: pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonUp, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - handleTabletEvent(eventPtr, NSTabletPoint); - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - handleTabletEvent(eventPtr, NSTabletProximity); - break; - default: - //No tablet event included : do nothing - break; - } + is_tablet = handleTabletEvent(event); break; case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDragged: //Handle tablet events combined with mouse events - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - handleTabletEvent(eventPtr, NSTabletPoint); - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - handleTabletEvent(eventPtr, NSTabletProximity); - break; - default: - //No tablet event included : do nothing - break; - } + is_tablet = handleTabletEvent(event); case NSMouseMoved: { GHOST_TGrabCursorMode grab_mode = window->getCursorGrabMode(); - /* TODO: CHECK IF THIS IS A TABLET EVENT */ - bool is_tablet = false; - - if (is_tablet && window->getCursorGrabModeIsWarp()) { + if (is_tablet && window->getCursorGrabModeIsWarp()) grab_mode = GHOST_kGrabDisable; - } switch (grab_mode) { case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move From b613879f348e870d3b0fb6a68bbcf91e85579280 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 7 May 2012 13:42:25 +0000 Subject: [PATCH 127/143] GHOST/Cocoa: revert tablet detection commit for continuous grab, apparently it is already doing it and this change breaks something? Still it seems strange that it is doing tablet stuff in this part of the code then. --- intern/ghost/intern/GHOST_SystemCocoa.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 8baf3a12c16..6013f3519ec 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1450,8 +1450,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) return GHOST_kFailure; } - bool is_tablet = false; - switch ([event type]) { case NSLeftMouseDown: @@ -1459,7 +1457,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSOtherMouseDown: pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events - is_tablet = handleTabletEvent(event); + handleTabletEvent(event); break; case NSLeftMouseUp: @@ -1467,21 +1465,25 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSOtherMouseUp: pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonUp, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events - is_tablet = handleTabletEvent(event); + handleTabletEvent(event); break; case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDragged: //Handle tablet events combined with mouse events - is_tablet = handleTabletEvent(event); + handleTabletEvent(event); case NSMouseMoved: { GHOST_TGrabCursorMode grab_mode = window->getCursorGrabMode(); - if (is_tablet && window->getCursorGrabModeIsWarp()) + /* TODO: CHECK IF THIS IS A TABLET EVENT */ + bool is_tablet = false; + + if (is_tablet && window->getCursorGrabModeIsWarp()) { grab_mode = GHOST_kGrabDisable; + } switch (grab_mode) { case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move From 6291b36d4c14949dfe3cd6b02b321f8bde705db0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 May 2012 15:45:41 +0000 Subject: [PATCH 128/143] fix for solidify modifier angle calculation (was incorrectly using normalized angle function) --- source/blender/modifiers/intern/MOD_solidify.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 96c84f5abbe..163c3979bfe 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -474,16 +474,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* just added, calc the normal */ BLI_array_empty(face_angles); + BLI_array_reserve(face_angles, mp->totloop); for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { MLoop *ml_prev = ME_POLY_LOOP_PREV(mloop, mp, j); MLoop *ml_next = ME_POLY_LOOP_NEXT(mloop, mp, j); - float e1[3], e2[3], angle; - + float e1[3], e2[3]; + 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 = (float)M_PI - angle_normalized_v3v3(e1, e2); - BLI_array_append(face_angles, angle); + face_angles[j] = (float)M_PI - angle_v3v3(e1, e2); } for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { From 4bbcb7714ecc212864a0b574136f17baa0191f01 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 7 May 2012 15:50:57 +0000 Subject: [PATCH 129/143] Some misc fixes to UI messages... --- intern/cycles/blender/addon/properties.py | 2 +- source/blender/editors/curve/editcurve.c | 2 +- source/blender/editors/space_clip/clip_ops.c | 2 +- source/blender/editors/space_image/image_ops.c | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 2 +- source/blender/makesrna/intern/rna_lamp.c | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index fb066a3a939..3ade04c4658 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -293,7 +293,7 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): ) cls.fisheye_lens = FloatProperty( name="Fisheye Lens", - description="Lens focal length (mm))", + description="Lens focal length (mm)", min=0.01, soft_max=15.0, max=100.0, default=10.5, ) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 09c01c2bf8c..7b8162bd755 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5233,7 +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"; + ot->description = "Select control points directly linked to already selected ones"; /* api callbacks */ ot->exec = select_more_exec; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index e89e85ce591..117e599cbbb 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -531,7 +531,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"; + ot->description = "Zoom in/out the view"; /* api callbacks */ ot->exec = view_zoom_exec; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 51741b8972a..58fbceb999d 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2173,7 +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"; + ot->description = "Set black point or white point for curves"; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 3e8ac58df8e..d7e7f710dcd 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2315,7 +2315,7 @@ void VIEW3D_OT_view_lock_clear(wmOperatorType *ot) /* identifiers */ ot->name = "View Lock Clear"; - ot->description = "Clears all view locking"; + ot->description = "Clear all view locking"; ot->idname = "VIEW3D_OT_view_lock_clear"; /* api callbacks */ diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index fef362c8f10..e1cb714c68d 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -507,8 +507,8 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) static EnumPropertyItem prop_numbuffer_items[] = { {1, "BUFFERS_1", 0, "1", "Only one buffer rendered"}, - {4, "BUFFERS_4", 0, "4", "Renders 4 buffers for better AA, this quadruples memory usage"}, - {9, "BUFFERS_9", 0, "9", "Renders 9 buffers for better AA, this uses nine times more memory"}, + {4, "BUFFERS_4", 0, "4", "Render 4 buffers for better AA, this quadruples memory usage"}, + {9, "BUFFERS_9", 0, "9", "Render 9 buffers for better AA, this uses nine times more memory"}, {0, NULL, 0, NULL, NULL}}; /* GE only */ From 9a731205e942da12c622dac9804ff308a6f1c4c6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 7 May 2012 16:51:55 +0000 Subject: [PATCH 130/143] direction to equisolid - final fix for [#31307] Cycles panoramic fisheye lens and vector pass problem --- intern/cycles/kernel/kernel_projection.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h index 43535182d61..0ff905b7db8 100644 --- a/intern/cycles/kernel/kernel_projection.h +++ b/intern/cycles/kernel/kernel_projection.h @@ -74,7 +74,7 @@ __device float3 equirectangular_to_direction(float u, float v) cos(theta)); } -/* Fisheye <- Cartesian direction */ +/* Fisheye <-> Cartesian direction */ __device float2 direction_to_fisheye(float3 dir, float fov) { @@ -109,11 +109,14 @@ __device float3 fisheye_to_direction(float u, float v, float fov) ); } -__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float fov, float width, float height) +__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height) { - /* XXX not implemented yet */ - float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; - float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; + float theta = acosf(dir.x); + float r = 2.0f * lens * sinf(theta * 0.25f); + float phi = atan2f(dir.z, dir.y); + + float u = r * cosf(phi) / width + 0.5f; + float v = r * sinf(phi) / height + 0.5f; return make_float2(u, v); } @@ -197,7 +200,7 @@ __device float2 direction_to_panorama(KernelGlobals *kg, float3 dir) case PANORAMA_FISHEYE_EQUISOLID: default: return direction_to_fisheye_equisolid(dir, kernel_data.cam.fisheye_lens, - kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight); + kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight); } } From e11b9df3f1b78c1afdfb977b764813b4f61de1a4 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 7 May 2012 17:22:13 +0000 Subject: [PATCH 131/143] cycles-fisheye: fixed formula for dir to equisolid second time I need a scond commit to get the equisolid formula right, shame on me ;) the formula is: r = 2 x focallength x sin (theta / 2) --- intern/cycles/kernel/kernel_projection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h index 0ff905b7db8..a5735920cd9 100644 --- a/intern/cycles/kernel/kernel_projection.h +++ b/intern/cycles/kernel/kernel_projection.h @@ -112,7 +112,7 @@ __device float3 fisheye_to_direction(float u, float v, float fov) __device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height) { float theta = acosf(dir.x); - float r = 2.0f * lens * sinf(theta * 0.25f); + float r = 2.0f * lens * sinf(theta * 0.5f); float phi = atan2f(dir.z, dir.y); float u = r * cosf(phi) / width + 0.5f; From d5b53420f61b1fd9020465c5c6603d82b93cc97d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 May 2012 17:56:30 +0000 Subject: [PATCH 132/143] style cleanup: outliner --- .../editors/space_outliner/outliner_draw.c | 848 +++++++-------- .../editors/space_outliner/outliner_edit.c | 520 ++++----- .../editors/space_outliner/outliner_intern.h | 114 +- .../editors/space_outliner/outliner_select.c | 328 +++--- .../editors/space_outliner/outliner_tools.c | 438 ++++---- .../editors/space_outliner/outliner_tree.c | 998 +++++++++--------- .../editors/space_outliner/space_outliner.c | 122 +-- 7 files changed, 1684 insertions(+), 1684 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index a32923f17c9..7813bbcd9a6 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -74,20 +74,20 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); if (TSELEM_OPEN(tselem, soops)) outliner_height(soops, &te->subtree, h); (*h) += UI_UNIT_Y; - te= te->next; + te = te->next; } } #if 0 // XXX this is currently disabled until te->xend is set correctly static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { // TreeStoreElem *tselem= TREESTORE(te); @@ -97,16 +97,16 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) *w = te->xend; } outliner_width(soops, &te->subtree, w); - te= te->next; + te = te->next; } } #endif static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int startx) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); // XXX fixme... (currently, we're using a fixed length of 100)! #if 0 if (te->xend) { @@ -114,12 +114,12 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start *w = te->xend; } #endif - if (startx+100 > *w) - *w = startx+100; + if (startx + 100 > *w) + *w = startx + 100; if (TSELEM_OPEN(tselem, soops)) - outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X); - te= te->next; + outliner_rna_width(soops, &te->subtree, w, startx + UI_UNIT_X); + te = te->next; } } @@ -138,7 +138,7 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) * so have to do loop to find it. */ ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -155,18 +155,18 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) * so have to do loop to find it. */ ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin); + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, poin); } static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, poin); } static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) @@ -175,31 +175,31 @@ static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *po DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) { - Bone *bone= (Bone *)poin2; + Bone *bone = (Bone *)poin2; if (bone && (bone->flag & BONE_HIDDEN_P)) bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); } static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) { - EditBone *ebone= (EditBone *)poin2; + EditBone *ebone = (EditBone *)poin2; if (ebone && (ebone->flag & BONE_HIDDEN_A)) ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); } static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->restrictflag & flag) == 0) return 0; } @@ -211,7 +211,7 @@ static int group_select_flag(Group *gr) { GroupObject *gob; - for (gob= gr->gobject.first; gob; gob= gob->next) + for (gob = gr->gobject.first; gob; gob = gob->next) if ((gob->ob->flag & SELECT)) return 1; @@ -225,21 +225,21 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) Group *gr = (Group *)poin2; if (group_restrict_flag(gr, flag)) { - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { gob->ob->restrictflag &= ~flag; - if (flag==OB_RESTRICT_VIEW) + if (flag == OB_RESTRICT_VIEW) if (gob->ob->flag & SELECT) ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT); } } else { - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { /* not in editmode */ - if (scene->obedit!=gob->ob) { + if (scene->obedit != gob->ob) { gob->ob->restrictflag |= flag; - if (flag==OB_RESTRICT_VIEW) + if (flag == OB_RESTRICT_VIEW) if ((gob->ob->flag & SELECT) == 0) ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } @@ -266,17 +266,17 @@ static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poi static void namebutton_cb(bContext *C, void *tsep, char *oldname) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - TreeStore *ts= soops->treestore; - TreeStoreElem *tselem= tsep; + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + TreeStore *ts = soops->treestore; + TreeStoreElem *tselem = tsep; if (ts && tselem) { - TreeElement *te= outliner_find_tse(soops, tselem); + TreeElement *te = outliner_find_tse(soops, tselem); - if (tselem->type==0) { - test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort + if (tselem->type == 0) { + test_idbutton(tselem->id->name + 2); // library.c, unique name and alpha sort switch (GS(tselem->id->name)) { case ID_MA: @@ -288,11 +288,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) case ID_SCE: WM_event_add_notifier(C, NC_SCENE, NULL); break; default: - WM_event_add_notifier(C, NC_ID|NA_RENAME, NULL); break; + WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; } /* Check the library target exists */ if (te->idcode == ID_LI) { - Library *lib= (Library *)tselem->id; + Library *lib = (Library *)tselem->id; char expanded[FILE_MAX]; BKE_library_filepath_set(lib, lib->name); @@ -306,73 +306,73 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } else { switch (tselem->type) { - case TSE_DEFGROUP: - defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object - break; - case TSE_NLA_ACTION: - test_idbutton(tselem->id->name+2); - break; - case TSE_EBONE: - { - bArmature *arm= (bArmature *)tselem->id; - if (arm->edbo) { - EditBone *ebone= te->directdata; - char newname[sizeof(ebone->name)]; - - /* restore bone name */ - BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); - BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); - ED_armature_bone_rename(obedit->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT); + case TSE_DEFGROUP: + defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object + break; + case TSE_NLA_ACTION: + test_idbutton(tselem->id->name + 2); + break; + case TSE_EBONE: + { + bArmature *arm = (bArmature *)tselem->id; + if (arm->edbo) { + EditBone *ebone = te->directdata; + char newname[sizeof(ebone->name)]; + + /* restore bone name */ + BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); + BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); + ED_armature_bone_rename(obedit->data, oldname, newname); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT); + } } - } break; - case TSE_BONE: + case TSE_BONE: { - Bone *bone= te->directdata; + Bone *bone = te->directdata; Object *ob; char newname[sizeof(bone->name)]; // always make current object active tree_element_active(C, scene, soops, te, 1); // was set_active_object() - ob= OBACT; + ob = OBACT; /* restore bone name */ BLI_strncpy(newname, bone->name, sizeof(bone->name)); BLI_strncpy(bone->name, oldname, sizeof(bone->name)); ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_POSE_CHANNEL: + case TSE_POSE_CHANNEL: { - bPoseChannel *pchan= te->directdata; + bPoseChannel *pchan = te->directdata; Object *ob; char newname[sizeof(pchan->name)]; // always make current object active tree_element_active(C, scene, soops, te, 1); // was set_active_object() - ob= OBACT; + ob = OBACT; /* restore bone name */ BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_POSEGRP: + case TSE_POSEGRP: { - Object *ob= (Object *)tselem->id; // id = object - bActionGroup *grp= te->directdata; + Object *ob = (Object *)tselem->id; // id = object + bActionGroup *grp = te->directdata; BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_R_LAYER: - break; + case TSE_R_LAYER: + break; } } tselem->flag &= ~TSE_TEXTBUT; @@ -387,120 +387,120 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar Object *ob = NULL; Group *gr = NULL; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { /* objects have toggle-able restriction flags */ - if (tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type == 0 && te->idcode == ID_OB) { PointerRNA ptr; ob = (Object *)tselem->id; RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); uiBlockSetEmboss(block, UI_EMBOSS); } - if (tselem->type==0 && te->idcode==ID_GR) { + if (tselem->type == 0 && te->idcode == ID_GR) { int restrict_bool; gr = (Group *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); uiBlockSetEmboss(block, UI_EMBOSS); } /* scene render layers and passes have toggle-able flags too! */ - else if (tselem->type==TSE_R_LAYER) { + else if (tselem->type == TSE_R_LAYER) { uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); + bt = uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if (tselem->type==TSE_R_PASS) { - int *layflag= te->directdata; - int passflag= 1<nr; + else if (tselem->type == TSE_R_PASS) { + int *layflag = te->directdata; + int passflag = 1 << tselem->nr; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Render this Pass"); + bt = uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Render this Pass"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); - layflag++; /* is lay_xor */ + layflag++; /* is lay_xor */ if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) - bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); + bt = uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag) ? ICON_DOT : ICON_BLANK1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if (tselem->type==TSE_MODIFIER) { - ModifierData *md= (ModifierData *)te->directdata; + else if (tselem->type == TSE_MODIFIER) { + ModifierData *md = (ModifierData *)te->directdata; ob = (Object *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); + bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); } - else if (tselem->type==TSE_POSE_CHANNEL) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; + else if (tselem->type == TSE_POSE_CHANNEL) { + bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); } - else if (tselem->type==TSE_EBONE) { - EditBone *ebone= (EditBone *)te->directdata; + else if (tselem->type == TSE_EBONE) { + EditBone *ebone = (EditBone *)te->directdata; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); } } @@ -511,23 +511,23 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar static void outliner_draw_rnacols(ARegion *ar, int sizex) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; - float miny = v2d->cur.ymin-V2D_SCROLL_HEIGHT; - if (minytot.ymin) miny = v2d->tot.ymin; + float miny = v2d->cur.ymin - V2D_SCROLL_HEIGHT; + if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* draw column separator lines */ fdrawline((float)sizex, - v2d->cur.ymax, - (float)sizex, - miny); + v2d->cur.ymax, + (float)sizex, + miny); - fdrawline((float)sizex+OL_RNA_COL_SIZEX, - v2d->cur.ymax, - (float)sizex+OL_RNA_COL_SIZEX, - miny); + fdrawline((float)sizex + OL_RNA_COL_SIZEX, + v2d->cur.ymax, + (float)sizex + OL_RNA_COL_SIZEX, + miny); } static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb) @@ -539,21 +539,21 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa uiBlockSetEmboss(block, UI_EMBOSST); - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->type == TSE_RNA_PROPERTY) { - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; if (!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem, soops))) ) - uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } else if (tselem->type == TSE_RNA_ARRAY_ELEM) { - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; - uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } } @@ -563,7 +563,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) { - wmOperatorType *ot= arg2; + wmOperatorType *ot = arg2; wmKeyMapItem *kmi = arg_kmi; if (ot) @@ -572,10 +572,10 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) { - GHashIterator *iter= WM_operatortype_iter(); + GHashIterator *iter = WM_operatortype_iter(); - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(iter); if (BLI_strcasestr(ot->idname, str)) { char name[OP_MAX_TYPENAME]; @@ -583,7 +583,7 @@ static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(ar /* display name for menu */ WM_operator_py_idname(name, ot->idname); - if (0==uiSearchItemAdd(items, name, ot, 0)) + if (0 == uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -595,17 +595,17 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) { static char search[OP_MAX_TYPENAME]; wmEvent event; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); wmKeyMapItem *kmi = arg_kmi; - wmOperatorType *ot= WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); uiBlock *block; uiBut *but; /* clear initial search string, then all items show */ - search[0]= 0; + search[0] = 0; - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); @@ -617,20 +617,20 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; + event = *(win->eventstate); /* XXX huh huh? make api call */ + event.type = EVT_BUT_OPEN; + event.val = KM_PRESS; + event.customdata = but; + event.customdatafree = FALSE; wm_event_add(win, &event); return block; } -#define OL_KM_KEYBOARD 0 -#define OL_KM_MOUSE 1 -#define OL_KM_TWEAK 2 -#define OL_KM_SPECIALS 3 +#define OL_KM_KEYBOARD 0 +#define OL_KM_MOUSE 1 +#define OL_KM_TWEAK 2 +#define OL_KM_SPECIALS 3 static short keymap_menu_type(short type) { @@ -643,11 +643,11 @@ static short keymap_menu_type(short type) static const char *keymap_type_menu(void) { - static const char string[]= - "Event Type%t" - "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) - "|Mouse%x" STRINGIFY(OL_KM_MOUSE) - "|Tweak%x" STRINGIFY(OL_KM_TWEAK) + static const char string[] = + "Event Type%t" + "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) + "|Mouse%x" STRINGIFY(OL_KM_MOUSE) + "|Tweak%x" STRINGIFY(OL_KM_TWEAK) // "|Specials%x" STRINGIFY(OL_KM_SPECIALS) ; @@ -656,25 +656,25 @@ static const char *keymap_type_menu(void) static const char *keymap_mouse_menu(void) { - static const char string[]= - "Mouse Event%t" - "|Left Mouse%x" STRINGIFY(LEFTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) - "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) - "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) - "|Select Mouse%x" STRINGIFY(SELECTMOUSE) - "|Mouse Move%x" STRINGIFY(MOUSEMOVE) - "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) - "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) - "|Wheel In%x" STRINGIFY(WHEELINMOUSE) - "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) - "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) - "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) - "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) + static const char string[] = + "Mouse Event%t" + "|Left Mouse%x" STRINGIFY(LEFTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) + "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) + "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) + "|Select Mouse%x" STRINGIFY(SELECTMOUSE) + "|Mouse Move%x" STRINGIFY(MOUSEMOVE) + "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) + "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) + "|Wheel In%x" STRINGIFY(WHEELINMOUSE) + "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) + "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) + "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) + "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) ; return string; @@ -682,13 +682,13 @@ static const char *keymap_mouse_menu(void) static const char *keymap_tweak_menu(void) { - static const char string[]= - "Tweak Event%t" - "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) - "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) - "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) - "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) - "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) + static const char string[] = + "Tweak Event%t" + "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) + "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) + "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) + "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) + "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) ; return string; @@ -696,17 +696,17 @@ static const char *keymap_tweak_menu(void) static const char *keymap_tweak_dir_menu(void) { - static const char string[]= - "Tweak Direction%t" - "|Any%x" STRINGIFY(KM_ANY) - "|North%x" STRINGIFY(EVT_GESTURE_N) - "|North-East%x" STRINGIFY(EVT_GESTURE_NE) - "|East%x" STRINGIFY(EVT_GESTURE_E) - "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) - "|South%x" STRINGIFY(EVT_GESTURE_S) - "|South-West%x" STRINGIFY(EVT_GESTURE_SW) - "|West%x" STRINGIFY(EVT_GESTURE_W) - "|North-West%x" STRINGIFY(EVT_GESTURE_NW) + static const char string[] = + "Tweak Direction%t" + "|Any%x" STRINGIFY(KM_ANY) + "|North%x" STRINGIFY(EVT_GESTURE_N) + "|North-East%x" STRINGIFY(EVT_GESTURE_NE) + "|East%x" STRINGIFY(EVT_GESTURE_E) + "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) + "|South%x" STRINGIFY(EVT_GESTURE_S) + "|South-West%x" STRINGIFY(EVT_GESTURE_SW) + "|West%x" STRINGIFY(EVT_GESTURE_W) + "|North-West%x" STRINGIFY(EVT_GESTURE_NW) ; return string; @@ -716,25 +716,25 @@ static const char *keymap_tweak_dir_menu(void) static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) { wmKeyMapItem *kmi = kmi_v; - short maptype= keymap_menu_type(kmi->type); + short maptype = keymap_menu_type(kmi->type); - if (maptype!=kmi->maptype) { + if (maptype != kmi->maptype) { switch (kmi->maptype) { case OL_KM_KEYBOARD: - kmi->type= AKEY; - kmi->val= KM_PRESS; + kmi->type = AKEY; + kmi->val = KM_PRESS; break; case OL_KM_MOUSE: - kmi->type= LEFTMOUSE; - kmi->val= KM_PRESS; + kmi->type = LEFTMOUSE; + kmi->val = KM_PRESS; break; case OL_KM_TWEAK: - kmi->type= EVT_TWEAK_L; - kmi->val= KM_ANY; + kmi->type = EVT_TWEAK_L; + kmi->val = KM_ANY; break; case OL_KM_SPECIALS: - kmi->type= AKEY; - kmi->val= KM_PRESS; + kmi->type = AKEY; + kmi->val = KM_PRESS; } ED_region_tag_redraw(CTX_wm_region(C)); } @@ -747,67 +747,67 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo uiBlockSetEmboss(block, UI_EMBOSST); - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { uiBut *but; const char *str; - int xstart= 240; - int butw1= UI_UNIT_X; /* operator */ - int butw2= 90; /* event type, menus */ - int butw3= 43; /* modifiers */ + int xstart = 240; + int butw1 = UI_UNIT_X; /* operator */ + int butw2 = 90; /* event type, menus */ + int butw3 = 43; /* modifiers */ if (tselem->type == TSE_KEYMAP_ITEM) { wmKeyMapItem *kmi = te->directdata; /* modal map? */ - if (kmi->propvalue); + if (kmi->propvalue) ; else { - uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator"); + uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys + 1, butw1, UI_UNIT_Y - 1, "Assign new Operator"); } - xstart+= butw1+10; + xstart += butw1 + 10; /* map type button */ - kmi->maptype= keymap_menu_type(kmi->type); + kmi->maptype = keymap_menu_type(kmi->type); - str= keymap_type_menu(); - but = uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->maptype, 0, 0, 0, 0, "Event type"); + str = keymap_type_menu(); + but = uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype, 0, 0, 0, 0, "Event type"); uiButSetFunc(but, keymap_type_cb, kmi, NULL); - xstart+= butw2+5; + xstart += butw2 + 5; /* edit actual event */ switch (kmi->maptype) { case OL_KM_KEYBOARD: - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code"); - xstart+= butw2+5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, "Key code"); + xstart += butw2 + 5; break; case OL_KM_MOUSE: - str= keymap_mouse_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Mouse button"); - xstart+= butw2+5; + str = keymap_mouse_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, 0, 0, 0, 0, "Mouse button"); + xstart += butw2 + 5; break; case OL_KM_TWEAK: - str= keymap_tweak_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); - xstart+= butw2+5; - str= keymap_tweak_dir_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); - xstart+= butw2+5; + str = keymap_tweak_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); + xstart += butw2 + 5; + str = keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart += butw2 + 5; break; } /* modifiers */ - uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, UI_UNIT_Y-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; - uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - xstart+= 5; - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->keymodifier, "Key Modifier code"); - xstart+= butw3+5; + uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys + 1, butw3 + 5, UI_UNIT_Y - 1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart += butw3 + 5; + uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart += butw3; + uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart += butw3; + uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart += butw3; + xstart += 5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier, "Key Modifier code"); + xstart += butw3 + 5; /* rna property */ if (kmi->ptr && kmi->ptr->data) { - uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; + uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->oskey, 0, 0, 0, 0, ""); xstart += butw2; } (void)xstart; @@ -826,33 +826,33 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa TreeStoreElem *tselem; int spx, dx, len; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->flag & TSE_TEXTBUT) { /* If we add support to rename Sequence. * need change this. */ - if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature + if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature - if (tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); - else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); - else if (tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); - else len= MAX_ID_NAME-2; + if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name); + else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name); + else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name); + else len = MAX_ID_NAME - 2; - dx= (int)UI_GetStringWidth(te->name); - if (dx<100) dx= 100; - spx=te->xs+2*UI_UNIT_X-4; - if (spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; + dx = (int)UI_GetStringWidth(te->name); + if (dx < 100) dx = 100; + spx = te->xs + 2 * UI_UNIT_X - 4; + if (spx + dx + 10 > ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax - spx - 10; - bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); + bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx + 10, UI_UNIT_Y - 1, (void *)te->name, 1.0, (float)len, 0, 0, ""); uiButSetRenameFunc(bt, namebutton_cb, tselem); /* returns false if button got removed */ - if ( 0 == uiButActiveOnly(C, block, bt) ) + if (0 == uiButActiveOnly(C, block, bt) ) tselem->flag &= ~TSE_TEXTBUT; } } @@ -882,8 +882,8 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) } else { /* XXX investigate: button placement of icons is way different than UI_icon_draw? */ - float ufac= UI_UNIT_X/20.0f; - uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); + float ufac = UI_UNIT_X / 20.0f; + uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x - 3.0f * ufac, arg->y, UI_UNIT_X - 4.0f * ufac, UI_UNIT_Y - 4.0f * ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); if (arg->id) uiButSetDragID(but, arg->id); @@ -896,15 +896,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto struct DrawIconArg arg; /* make function calls a bit compacter */ - arg.block= block; - arg.id= tselem->id; + arg.block = block; + arg.id = tselem->id; arg.xmax = xmax; - arg.x= x; - arg.y= y; - arg.alpha= alpha; + arg.x = x; + arg.y = y; + arg.alpha = alpha; if (tselem->type) { - switch ( tselem->type) { + switch (tselem->type) { case TSE_ANIM_DATA: UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx case TSE_NLA: @@ -930,8 +930,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_PARTICLES); break; case TSE_MODIFIER: { - Object *ob= (Object *)tselem->id; - ModifierData *md= BLI_findlink(&ob->modifiers, tselem->nr); + Object *ob = (Object *)tselem->id; + ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); switch (md->type) { case eModifierType_Subsurf: UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; @@ -1033,15 +1033,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if (te->idcode==SEQ_MOVIE) + if (te->idcode == SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); - else if (te->idcode==SEQ_META) + else if (te->idcode == SEQ_META) UI_icon_draw(x, y, ICON_DOT); - else if (te->idcode==SEQ_SCENE) + else if (te->idcode == SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if (te->idcode==SEQ_SOUND) + else if (te->idcode == SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); - else if (te->idcode==SEQ_IMAGE) + else if (te->idcode == SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); else UI_icon_draw(x, y, ICON_PARTICLES); @@ -1054,7 +1054,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto break; case TSE_RNA_STRUCT: if (RNA_struct_is_ID(te->rnaptr.type)) { - arg.id= (ID *)te->rnaptr.data; + arg.id = (ID *)te->rnaptr.data; tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); } else @@ -1065,7 +1065,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } } else if (GS(tselem->id->name) == ID_OB) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; switch (ob->type) { case OB_LAMP: tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; @@ -1093,7 +1093,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } } else { - switch ( GS(tselem->id->name)) { + switch (GS(tselem->id->name)) { case ID_SCE: tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break; case ID_ME: @@ -1106,7 +1106,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LATTICE); break; case ID_LA: { - Lamp *la= (Lamp *)tselem->id; + Lamp *la = (Lamp *)tselem->id; switch (la->type) { case LA_LOCAL: @@ -1161,46 +1161,46 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa TreeStoreElem *tselem; int active; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) break; - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* object hierarchy always, further constrained on level */ - if (level<1 || (tselem->type==0 && te->idcode==ID_OB)) { + if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { /* active blocks get white circle */ - if (tselem->type==0) { - if (te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); - else if (scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? - else active= tree_element_active(C, scene, soops, te, 0); + if (tselem->type == 0) { + if (te->idcode == ID_OB) active = (OBACT == (Object *)tselem->id); + else if (scene->obedit && scene->obedit->data == tselem->id) active = 1; // XXX use context? + else active = tree_element_active(C, scene, soops, te, 0); } - else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0); + else active = tree_element_type_active(NULL, scene, soops, te, tselem, 0); if (active) { - float ufac= UI_UNIT_X/20.0f; + float ufac = UI_UNIT_X / 20.0f; uiSetRoundBox(UI_CNR_ALL); glColor4ub(255, 255, 255, 100); - uiRoundBox((float) * offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); + uiRoundBox((float) *offsx - 0.5f * ufac, (float)ys - 1.0f * ufac, (float)*offsx + UI_UNIT_Y - 3.0f * ufac, (float)ys + UI_UNIT_Y - 3.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac); glEnable(GL_BLEND); /* roundbox disables */ } tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); - te->xs= (float)*offsx; - te->ys= (float)ys; - te->xend= (short)*offsx+UI_UNIT_X; - te->flag |= TE_ICONROW; // for click + te->xs = (float)*offsx; + te->ys = (float)ys; + te->xend = (short)*offsx + UI_UNIT_X; + te->flag |= TE_ICONROW; // for click (*offsx) += UI_UNIT_X; } /* this tree element always has same amount of branches, so don't draw */ - if (tselem->type!=TSE_R_LAYER) - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); + if (tselem->type != TSE_R_LAYER) + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level + 1, xmax, offsx, ys); } } @@ -1211,11 +1211,11 @@ static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, i TreeElement *ten; /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); + te->xs = (float)startx; + te->ys = (float)(*starty); - for (ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) { + outliner_set_coord_tree_element(soops, ten, startx + UI_UNIT_X, starty); } } @@ -1224,17 +1224,17 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene { TreeElement *ten; TreeStoreElem *tselem; - float ufac= UI_UNIT_X/20.0f; - int offsx= 0, active=0; // active=1 active obj, else active data + float ufac = UI_UNIT_X / 20.0f; + int offsx = 0, active = 0; // active=1 active obj, else active data - tselem= TREESTORE(te); + tselem = TREESTORE(te); - if (*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { - int xmax= ar->v2d.cur.xmax; + if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { + int xmax = ar->v2d.cur.xmax; /* icons can be ui buts, we don't want it to overlap with restrict */ - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - xmax-= OL_TOGW+UI_UNIT_X; + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + xmax -= OL_TOGW + UI_UNIT_X; glEnable(GL_BLEND); @@ -1242,149 +1242,149 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene * we don't expand items when searching in the datablocks but we * still want to highlight any filter matches. */ - if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && - (tselem->flag & TSE_SEARCHMATCH)) + if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATABLOCKS && soops->search_string[0] != 0)) && + (tselem->flag & TSE_SEARCHMATCH)) { char col[4]; UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col); - col[3]=100; + col[3] = 100; glColor4ubv((GLubyte *)col); - glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + glRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); } /* colors for active/selected data */ - if (tselem->type==0) { - if (te->idcode==ID_SCE) { + if (tselem->type == 0) { + if (te->idcode == ID_SCE) { if (tselem->id == (ID *)scene) { glColor4ub(255, 255, 255, 100); - active= 2; + active = 2; } } - else if (te->idcode==ID_GR) { + else if (te->idcode == ID_GR) { Group *gr = (Group *)tselem->id; if (group_select_flag(gr)) { char col[4]; UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; glColor4ubv((GLubyte *)col); - active= 2; + active = 2; } } - else if (te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; + else if (te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; - if (ob==OBACT || (ob->flag & SELECT)) { - char col[4]= {0, 0, 0, 0}; + if (ob == OBACT || (ob->flag & SELECT)) { + char col[4] = {0, 0, 0, 0}; /* outliner active ob: always white text, circle color now similar to view3d */ - active= 2; /* means it draws a color circle */ - if (ob==OBACT) { + active = 2; /* means it draws a color circle */ + if (ob == OBACT) { if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; } - active= 1; /* means it draws white text */ + active = 1; /* means it draws white text */ } else if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; } glColor4ubv((GLubyte *)col); } } - else if (scene->obedit && scene->obedit->data==tselem->id) { + else if (scene->obedit && scene->obedit->data == tselem->id) { glColor4ub(255, 255, 255, 100); - active= 2; + active = 2; } else { if (tree_element_active(C, scene, soops, te, 0)) { glColor4ub(220, 220, 255, 100); - active= 2; + active = 2; } } } else { - if ( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; + if (tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active = 2; glColor4ub(220, 220, 255, 100); } /* active circle */ if (active) { uiSetRoundBox(UI_CNR_ALL); - uiRoundBox((float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); - glEnable(GL_BLEND); /* roundbox disables it */ + uiRoundBox((float)startx + UI_UNIT_Y - 1.5f * ufac, (float)*starty + 2.0f * ufac, (float)startx + 2.0f * UI_UNIT_Y - 4.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac); + glEnable(GL_BLEND); /* roundbox disables it */ te->flag |= TE_ACTIVE; // for lookup in display hierarchies } /* open/close icon, only when sublevels, except for scene */ - if (te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { + if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { int icon_x; - if (tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) + if (tselem->type == 0 && ELEM(te->idcode, ID_OB, ID_SCE)) icon_x = startx; else - icon_x = startx+5*ufac; + icon_x = startx + 5 * ufac; - // icons a bit higher + // icons a bit higher if (TSELEM_OPEN(tselem, soops)) - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN); + UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_DOWN); else - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT); + UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_RIGHT); } - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; /* datatype icon */ if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { // icons a bit higher - tselem_draw_icon(block, xmax, (float)startx+offsx - 0.5f*ufac, (float)*starty+2.0f*ufac, tselem, te, 1.0f); + tselem_draw_icon(block, xmax, (float)startx + offsx - 0.5f * ufac, (float)*starty + 2.0f * ufac, tselem, te, 1.0f); - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; } else - offsx+= 2*ufac; + offsx += 2 * ufac; - if (tselem->type==0 && tselem->id->lib) { + if (tselem->type == 0 && tselem->id->lib) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); if (tselem->id->flag & LIB_INDIRECT) - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT); + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_INDIRECT); else - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT); + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; } glDisable(GL_BLEND); /* name */ - if (active==1) UI_ThemeColor(TH_TEXT_HI); + if (active == 1) UI_ThemeColor(TH_TEXT_HI); else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); else UI_ThemeColor(TH_TEXT); - UI_DrawString(startx+offsx, *starty+5*ufac, te->name); + UI_DrawString(startx + offsx, *starty + 5 * ufac, te->name); - offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); + offsx += (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); /* closed item, we draw the icons, not when it's a scene, or master-server list though */ if (!TSELEM_OPEN(tselem, soops)) { if (te->subtree.first) { - if (tselem->type==0 && te->idcode==ID_SCE); - else if (tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ - int tempx= startx+offsx; + if (tselem->type == 0 && te->idcode == ID_SCE) ; + else if (tselem->type != TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ + int tempx = startx + offsx; // divider UI_ThemeColorShade(TH_BACK, -40); - glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4); + glRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4); glEnable(GL_BLEND); glPixelTransferf(GL_ALPHA_SCALE, 0.5); - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty+2); + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty + 2); glPixelTransferf(GL_ALPHA_SCALE, 1.0); glDisable(GL_BLEND); @@ -1393,21 +1393,21 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)*starty; - te->xend= startx+offsx; + te->xs = (float)startx; + te->ys = (float)*starty; + te->xend = startx + offsx; if (TSELEM_OPEN(tselem, soops)) { - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; - for (ten= te->subtree.first; ten; ten= ten->next) - outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) + outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty); } else { - for (ten= te->subtree.first; ten; ten= ten->next) + for (ten = te->subtree.first; ten; ten = ten->next) outliner_set_coord_tree_element(soops, te, startx, starty); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; } } @@ -1417,30 +1417,30 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeStoreElem *tselem; int y1, y2; - if (lb->first==NULL) return; + if (lb->first == NULL) return; - y1=y2= *starty; /* for vertical lines between objects */ - for (te=lb->first; te; te= te->next) { - y2= *starty; - tselem= TREESTORE(te); + y1 = y2 = *starty; /* for vertical lines between objects */ + for (te = lb->first; te; te = te->next) { + y2 = *starty; + tselem = TREESTORE(te); /* horizontal line? */ - if (tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) - glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1); + if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) + glRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) - outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty); + outliner_draw_hierarchy(soops, &te->subtree, startx + UI_UNIT_X, starty); } /* vertical line */ - te= lb->last; - if (te->parent || lb->first!=lb->last) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) { + te = lb->last; + if (te->parent || lb->first != lb->last) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == ID_OB) { - glRecti(startx, y1+UI_UNIT_Y, startx+1, y2); + glRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2); } } } @@ -1450,19 +1450,19 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); /* selection status */ if (TSELEM_OPEN(tselem, soops)) if (tselem->type == TSE_RNA_STRUCT) - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1); + glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, *starty + UI_UNIT_Y - 1); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); if (tselem->type == TSE_RNA_STRUCT) - fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y); + fdrawline(0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (float)*starty + UI_UNIT_Y); } } } @@ -1472,14 +1472,14 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); /* selection status */ if (tselem->flag & TSE_SELECTED) { - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); } - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) outliner_draw_selection(ar, soops, &te->subtree, starty); } } @@ -1497,26 +1497,26 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio /* struct marks */ UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); //UI_ThemeColorShade(TH_BACK, -20); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); } /* always draw selection fill before hierarchy */ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); glColor3fv(col); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); // grey hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y/2-OL_Y_OFFSET; - startx= 6; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; + startx = 6; outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); // items themselves - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; - startx= 0; - for (te= soops->tree.first; te; te= te->next) { + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; + startx = 0; + for (te = soops->tree.first; te; te = te->next) { outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); } } @@ -1527,12 +1527,12 @@ static void outliner_back(ARegion *ar) int ystart; UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + ystart = (int)ar->v2d.tot.ymax; + ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - while (ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti(0, ystart, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, ystart + UI_UNIT_Y); + ystart -= 2 * UI_UNIT_Y; } } @@ -1542,36 +1542,36 @@ static void outliner_draw_restrictcols(ARegion *ar) /* background underneath */ UI_ThemeColor(TH_BACK); - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, (int)ar->v2d.cur.ymin-V2D_SCROLL_HEIGHT-1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); + glRecti((int)ar->v2d.cur.xmax - OL_TOGW, (int)ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT - 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + ystart = (int)ar->v2d.tot.ymax; + ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - while (ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); + ystart -= 2 * UI_UNIT_Y; } UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* view */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); } /* ****************************************************** */ @@ -1579,13 +1579,13 @@ static void outliner_draw_restrictcols(ARegion *ar) void draw_outliner(const bContext *C) { - Main *mainvar= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; - SpaceOops *soops= CTX_wm_space_outliner(C); + Main *mainvar = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; + SpaceOops *soops = CTX_wm_space_outliner(C); uiBlock *block; - int sizey= 0, sizex= 0, sizex_rna= 0; + int sizey = 0, sizex = 0, sizex_rna = 0; outliner_build_tree(mainvar, scene, soops); // always @@ -1594,7 +1594,7 @@ void draw_outliner(const bContext *C) if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { /* RNA has two columns: - * - column 1 is (max_width + OL_RNA_COL_SPACEX) or + * - column 1 is (max_width + OL_RNA_COL_SPACEX) or * (OL_RNA_COL_X), whichever is wider... * - column 2 is fixed at OL_RNA_COL_SIZEX * @@ -1603,13 +1603,13 @@ void draw_outliner(const bContext *C) /* get actual width of column 1 */ outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); - sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); + sizex_rna = MAX2(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ if (soops->outlinevis == SO_KEYMAP) - sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... + sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50; // XXX this is only really a quick hack to make this wide enough... else - sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; + sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ @@ -1618,8 +1618,8 @@ void draw_outliner(const bContext *C) /* constant offset for restriction columns */ // XXX this isn't that great yet... - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - sizex += OL_TOGW*3; + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + sizex += OL_TOGW * 3; } /* tweak to display last line (when list bigger than window) */ @@ -1632,13 +1632,13 @@ void draw_outliner(const bContext *C) UI_view2d_totRect_set(v2d, sizex, sizey); /* force display to pixel coords */ - v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); + v2d->flag |= (V2D_PIXELOFS_X | V2D_PIXELOFS_Y); /* set matrix for 2d-view controls */ UI_view2d_view_ortho(v2d); /* draw outliner stuff (background, hierachy lines and names) */ outliner_back(ar); - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 43f186f4b31..04e9cbf24c2 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -75,13 +75,13 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te) { TreeStoreElem *tselem; - int retval= 0; + int retval = 0; - for (te= te->parent; te; te= te->parent) { - tselem= TREESTORE(te); + for (te = te->parent; te; te = te->parent) { + tselem = TREESTORE(te); if (tselem->flag & TSE_CLOSED) { tselem->flag &= ~TSE_CLOSED; - retval= 1; + retval = 1; } } return retval; @@ -92,17 +92,17 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { /* check if this tree-element was the one we're seeking */ if (te == teFind) { - *found= 1; + *found = 1; return; } /* try to see if sub-tree contains it then */ outliner_open_reveal(soops, &te->subtree, teFind, found); if (*found) { - tselem= TREESTORE(te); + tselem = TREESTORE(te); if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; return; @@ -119,8 +119,8 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) { - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); /* all below close/open? */ if (all) { @@ -135,7 +135,7 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_openclose(C, soops, te, all, mval)) return 1; } @@ -146,15 +146,15 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement /* event can enterkey, then it opens/closes */ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - int all= RNA_boolean_get(op->ptr, "all"); + int all = RNA_boolean_get(op->ptr, "all"); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_openclose(C, soops, te, all, fmval)) break; } @@ -183,12 +183,12 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, { /* can't rename rna datablocks entries */ if (ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - /* do nothing */; + /* do nothing */; } else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, - TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) { - BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); + BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); } else if (ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); @@ -207,27 +207,27 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - ARegion *ar= CTX_wm_region(C); - ReportList *reports= CTX_wm_reports(C); // XXX + ARegion *ar = CTX_wm_region(C); + ReportList *reports = CTX_wm_reports(C); // XXX do_item_rename(ar, te, tselem, reports); } static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) { - ReportList *reports= CTX_wm_reports(C); // XXX + ReportList *reports = CTX_wm_reports(C); // XXX - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); /* name and first icon */ - if (mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { + if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) { do_item_rename(ar, te, tselem, reports); } return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_rename(C, ar, soops, te, mval)) return 1; } return 0; @@ -235,14 +235,14 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_rename(C, ar, soops, te, fmval)) break; } @@ -272,12 +272,12 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) { TreeElement *te; - int level=curlevel, lev; + int level = curlevel, lev; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { - lev= outliner_count_levels(soops, &te->subtree, curlevel+1); - if (lev>level) level= lev; + lev = outliner_count_levels(soops, &te->subtree, curlevel + 1); + if (lev > level) level = lev; } return level; } @@ -288,11 +288,11 @@ int outliner_has_one_flag(SpaceOops *soops, ListBase *lb, short flag, short curl TreeStoreElem *tselem; int level; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & flag) return curlevel; - level= outliner_has_one_flag(soops, &te->subtree, flag, curlevel+1); + level = outliner_has_one_flag(soops, &te->subtree, flag, curlevel + 1); if (level) return level; } return 0; @@ -303,9 +303,9 @@ void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set) TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (set==0) tselem->flag &= ~flag; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (set == 0) tselem->flag &= ~flag; else tselem->flag |= flag; outliner_set_flag(soops, &te->subtree, flag, set); } @@ -321,7 +321,7 @@ int common_restrict_check(bContext *C, Object *ob) /* Don't allow hide an object in edit mode, * check the bug #22153 and #21609, #23977 */ - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit && obedit == ob) { /* found object is hidden, reset */ if (ob->restrictflag & OB_RESTRICT_VIEW) @@ -342,13 +342,13 @@ int common_restrict_check(bContext *C, Object *ob) void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; Object *ob = (Object *)tselem->id; /* add check for edit mode */ if (!common_restrict_check(C, ob)) return; - if (base || (base= BKE_scene_base_find(scene, ob))) { + if (base || (base = BKE_scene_base_find(scene, ob))) { if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); } @@ -357,19 +357,19 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW); } static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -386,36 +386,36 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_visibility_exec; ot->poll = ED_operator_outliner_active_no_editobject; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Toggle Selectability ---------------------------------------- */ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { - base->object->restrictflag^=OB_RESTRICT_SELECT; + base->object->restrictflag ^= OB_RESTRICT_SELECT; } } void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT); } static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -432,35 +432,35 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_selectability_exec; ot->poll = ED_operator_outliner_active_no_editobject; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Toggle Renderability ---------------------------------------- */ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { - base->object->restrictflag^=OB_RESTRICT_RENDER; + base->object->restrictflag ^= OB_RESTRICT_RENDER; } } void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER); } static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); return OPERATOR_FINISHED; } @@ -476,7 +476,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_renderability_exec; ot->poll = ED_operator_outliner_active; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* =============================================== */ @@ -486,8 +486,8 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1)) outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 0); @@ -517,9 +517,9 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); @@ -528,7 +528,7 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) soops->storeflag |= SO_TREESTORE_REDRAW; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -555,10 +555,10 @@ void OUTLINER_OT_selected_toggle(wmOperatorType *ot) static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *so= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; + SpaceOops *so = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; TreeElement *te; int xdelta, ytop; @@ -567,14 +567,14 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) if (OBACT == NULL) return OPERATOR_CANCELLED; - te= outliner_find_id(so, &so->tree, (ID *)OBACT); + te = outliner_find_id(so, &so->tree, (ID *)OBACT); if (te) { /* make te->ys center of view */ - ytop= (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin)/2); - if (ytop>0) ytop= 0; + ytop = (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin) / 2); + if (ytop > 0) ytop = 0; v2d->cur.ymax = (float)ytop; - v2d->cur.ymin = (float)(ytop-(v2d->mask.ymax - v2d->mask.ymin)); + v2d->cur.ymin = (float)(ytop - (v2d->mask.ymax - v2d->mask.ymin)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); @@ -605,16 +605,16 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) static int outliner_scroll_page_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); - int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; - int up= 0; + ARegion *ar = CTX_wm_region(C); + int dy = ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int up = 0; if (RNA_boolean_get(op->ptr, "up")) - up= 1; + up = 1; - if (up == 0) dy= -dy; - ar->v2d.cur.ymin+= dy; - ar->v2d.cur.ymax+= dy; + if (up == 0) dy = -dy; + ar->v2d.cur.ymin += dy; + ar->v2d.cur.ymax += dy; ED_region_tag_redraw(ar); @@ -645,17 +645,17 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot) /* recursive helper for function below */ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); - *starty-= UI_UNIT_Y; + te->xs = (float)startx; + te->ys = (float)(*starty); + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { TreeElement *ten; - for (ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) { + outliner_set_coordinates_element(soops, ten, startx + UI_UNIT_X, starty); } } @@ -665,10 +665,10 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) { TreeElement *te; - int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y; - int startx= 0; + int starty = (int)(ar->v2d.tot.ymax) - UI_UNIT_Y; + int startx = 0; - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { outliner_set_coordinates_element(soops, te, startx, &starty); } } @@ -678,7 +678,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam { TreeElement *te, *tes; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { int found = outliner_filter_has_name(te, name, flags); if (found) { @@ -694,7 +694,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam return te; } - tes= outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); + tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); if (tes) return tes; } @@ -705,32 +705,32 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) { ReportList *reports = NULL; // CTX_wm_reports(C); - TreeElement *te= NULL; + TreeElement *te = NULL; TreeElement *last_find; TreeStoreElem *tselem; - int ytop, xdelta, prevFound=0; + int ytop, xdelta, prevFound = 0; char name[sizeof(soops->search_string)]; /* get last found tree-element based on stored search_tse */ - last_find= outliner_find_tse(soops, &soops->search_tse); + last_find = outliner_find_tse(soops, &soops->search_tse); /* determine which type of search to do */ if (again && last_find) { /* no popup panel - previous + user wanted to search for next after previous */ BLI_strncpy(name, soops->search_string, sizeof(name)); - flags= soops->search_flags; + flags = soops->search_flags; /* try to find matching element */ - te= outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); - if (te==NULL) { + 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_name(soops, &soops->tree, name, flags, last_find, &prevFound); + prevFound = 1; + 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'; + name[0] = '\0'; // XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { // te= outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); // } @@ -739,10 +739,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* do selection and reveal */ if (te) { - tselem= TREESTORE(te); + tselem = TREESTORE(te); if (tselem) { /* expand branches so that it will be visible, we need to get correct coordinates */ - if ( outliner_open_back(soops, te)) + if (outliner_open_back(soops, te)) outliner_set_coordinates(ar, soops); /* deselect all visible, and select found element */ @@ -750,10 +750,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so tselem->flag |= TSE_SELECTED; /* make te->ys center of view */ - ytop= (int)(te->ys + (ar->v2d.mask.ymax-ar->v2d.mask.ymin)/2); - if (ytop>0) ytop= 0; + ytop = (int)(te->ys + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 2); + if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; - ar->v2d.cur.ymin = (float)(ytop-(ar->v2d.mask.ymax-ar->v2d.mask.ymin)); + ar->v2d.cur.ymin = (float)(ytop - (ar->v2d.mask.ymax - ar->v2d.mask.ymin)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); @@ -761,10 +761,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so ar->v2d.cur.xmax += xdelta; /* store selection */ - soops->search_tse= *tselem; + soops->search_tse = *tselem; BLI_strncpy(soops->search_string, name, sizeof(soops->search_string)); - soops->search_flags= flags; + soops->search_flags = flags; /* redraw */ soops->storeflag |= SO_TREESTORE_REDRAW; @@ -785,34 +785,34 @@ static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curleve TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (open) { - if (curlevel<=level) tselem->flag &= ~TSE_CLOSED; + if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; } else { - if (curlevel>=level) tselem->flag |= TSE_CLOSED; + if (curlevel >= level) tselem->flag |= TSE_CLOSED; } - outliner_openclose_level(soops, &te->subtree, curlevel+1, level, open); + outliner_openclose_level(soops, &te->subtree, curlevel + 1, level, open); } } static int outliner_one_level_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - int add= RNA_boolean_get(op->ptr, "open"); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + int add = RNA_boolean_get(op->ptr, "open"); int level; - level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); - if (add==1) { + level = outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); + if (add == 1) { if (level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); } else { - if (level==0) level= outliner_count_levels(soops, &soops->tree, 0); - if (level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); + if (level == 0) level = outliner_count_levels(soops, &soops->tree, 0); + if (level) outliner_openclose_level(soops, &soops->tree, 1, level - 1, 0); } ED_region_tag_redraw(ar); @@ -845,10 +845,10 @@ static int subtree_has_objects(SpaceOops *soops, ListBase *lb) TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) return 1; - if ( subtree_has_objects(soops, &te->subtree)) return 1; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == ID_OB) return 1; + if (subtree_has_objects(soops, &te->subtree)) return 1; } return 0; } @@ -860,15 +860,15 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase TreeStoreElem *tselem; /* open all object elems, close others */ - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); - if (tselem->type==0) { - if (te->idcode==ID_SCE) { - if (tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; - else tselem->flag &= ~TSE_CLOSED; + if (tselem->type == 0) { + if (te->idcode == ID_SCE) { + if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; + else tselem->flag &= ~TSE_CLOSED; } - else if (te->idcode==ID_OB) { + else if (te->idcode == ID_OB) { if (subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } @@ -882,9 +882,9 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase /* show entire object level hierarchy */ static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); /* recursively open/close levels */ tree_element_show_hierarchy(scene, soops, &soops->tree); @@ -915,9 +915,9 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) /* specialized poll callback for these operators to work in Datablocks view only */ static int ed_operator_outliner_datablocks_active(bContext *C) { - ScrArea *sa= CTX_wm_area(C); - if ((sa) && (sa->spacetype==SPACE_OUTLINER)) { - SpaceOops *so= CTX_wm_space_outliner(C); + ScrArea *sa = CTX_wm_area(C); + if ((sa) && (sa->spacetype == SPACE_OUTLINER)) { + SpaceOops *so = CTX_wm_space_outliner(C); return (so->outlinevis == SO_DATABLOCKS); } return 0; @@ -929,7 +929,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C) * this function does not do that yet */ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, - ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) + ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) { ListBase hierarchy = {NULL, NULL}; LinkData *ld; @@ -937,7 +937,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle TreeStoreElem *tse /* , *tsenext */ /* UNUSED */; PointerRNA *ptr, *nextptr; PropertyRNA *prop; - char *newpath=NULL; + char *newpath = NULL; /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed @@ -946,28 +946,28 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle return; /* Overview of Algorithm: - * 1. Go up the chain of parents until we find the 'root', taking note of the + * 1. Go up the chain of parents until we find the 'root', taking note of the * levels encountered in reverse-order (i.e. items are added to the start of the list * for more convenient looping later) - * 2. Walk down the chain, adding from the first ID encountered + * 2. Walk down the chain, adding from the first ID encountered * (which will become the 'ID' for the KeyingSet Path), and build a - * path as we step through the chain + * path as we step through the chain */ /* step 1: flatten out hierarchy of parents into a flat chain */ - for (tem= te->parent; tem; tem= tem->parent) { - ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); - ld->data= tem; + for (tem = te->parent; tem; tem = tem->parent) { + ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); + ld->data = tem; BLI_addhead(&hierarchy, ld); } /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */ - for (ld= hierarchy.first; ld; ld= ld->next) { + for (ld = hierarchy.first; ld; ld = ld->next) { /* get data */ - tem= (TreeElement *)ld->data; - tse= TREESTORE(tem); - ptr= &tem->rnaptr; - prop= tem->directdata; + tem = (TreeElement *)ld->data; + tse = TREESTORE(tem); + ptr = &tem->rnaptr; + prop = tem->directdata; /* check if we're looking for first ID, or appending to path */ if (*id) { @@ -977,43 +977,43 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle if (tse->type == TSE_RNA_PROPERTY) { if (RNA_property_type(prop) == PROP_POINTER) { /* for pointer we just append property name */ - newpath= RNA_path_append(*path, ptr, prop, 0, NULL); + newpath = RNA_path_append(*path, ptr, prop, 0, NULL); } else if (RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - temnext= (TreeElement*)(ld->next->data); + temnext = (TreeElement *)(ld->next->data); /* tsenext= TREESTORE(temnext); */ /* UNUSED */ - nextptr= &temnext->rnaptr; - name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); + nextptr = &temnext->rnaptr; + name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); if (name) { /* if possible, use name as a key in the path */ - newpath= RNA_path_append(*path, NULL, prop, 0, name); + newpath = RNA_path_append(*path, NULL, prop, 0, name); if (name != buf) MEM_freeN(name); } else { /* otherwise use index */ - int index= 0; + int index = 0; - for (temsub=tem->subtree.first; temsub; temsub=temsub->next, index++) + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) if (temsub == temnext) break; - newpath= RNA_path_append(*path, NULL, prop, index, NULL); + newpath = RNA_path_append(*path, NULL, prop, index, NULL); } - ld= ld->next; + ld = ld->next; } } if (newpath) { if (*path) MEM_freeN(*path); - *path= newpath; - newpath= NULL; + *path = newpath; + newpath = NULL; } } else { @@ -1021,12 +1021,12 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle if (tse->type == TSE_RNA_STRUCT) { /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */ if (RNA_struct_is_ID(ptr->type)) { - *id= (ID *)ptr->data; + *id = (ID *)ptr->data; /* clear path */ if (*path) { MEM_freeN(*path); - path= NULL; + path = NULL; } } } @@ -1036,13 +1036,13 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* step 3: if we've got an ID, add the current item to the path */ if (*id) { /* add the active property to the path */ - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; /* array checks */ if (tselem->type == TSE_RNA_ARRAY_ELEM) { /* item is part of an array, so must set the array_index */ - *array_index= te->index; + *array_index = te->index; } else if (RNA_property_array_length(ptr, prop)) { /* entire array was selected, so keyframe all */ @@ -1050,9 +1050,9 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } /* path */ - newpath= RNA_path_append(*path, NULL, prop, 0, NULL); + newpath = RNA_path_append(*path, NULL, prop, 0, NULL); if (*path) MEM_freeN(*path); - *path= newpath; + *path = newpath; } /* free temp data */ @@ -1066,7 +1066,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle * they depend on having RNA paths and/or hierarchies available. */ enum { - DRIVERS_EDITMODE_ADD = 0, + DRIVERS_EDITMODE_ADD = 0, DRIVERS_EDITMODE_REMOVE, } /*eDrivers_EditModes*/; @@ -1078,22 +1078,22 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL TreeElement *te; TreeStoreElem *tselem; - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); + for (te = tree->first; te; te = te->next) { + tselem = TREESTORE(te); /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; + ID *id = NULL; + char *path = NULL; + int array_index = 0; + short flag = 0; + short groupmode = KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); + &id, &path, &array_index, &flag, &groupmode); } /* only if ID and path were set, should we perform any actions */ @@ -1104,10 +1104,10 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { /* entire array was selected, so add drivers for all */ - arraylen= RNA_property_array_length(&te->rnaptr, te->directdata); + arraylen = RNA_property_array_length(&te->rnaptr, te->directdata); } else - arraylen= array_index; + arraylen = array_index; /* we should do at least one step */ if (arraylen == array_index) @@ -1122,13 +1122,13 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL /* add a new driver with the information obtained (only if valid) */ ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON); } - break; + break; case DRIVERS_EDITMODE_REMOVE: { /* remove driver matching the information obtained (only if valid) */ ANIM_remove_driver(reports, id, path, array_index, dflags); } - break; + break; } } @@ -1149,7 +1149,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); + SpaceOops *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ if (soutliner == NULL) @@ -1159,7 +1159,7 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX return OPERATOR_FINISHED; } @@ -1176,7 +1176,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1184,7 +1184,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); + SpaceOops *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ if (soutliner == NULL) @@ -1211,7 +1211,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* =============================================== */ @@ -1221,7 +1221,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) * they depend on having RNA paths and/or hierarchies available. */ enum { - KEYINGSET_EDITMODE_ADD = 0, + KEYINGSET_EDITMODE_ADD = 0, KEYINGSET_EDITMODE_REMOVE, } /*eKeyingSet_EditModes*/; @@ -1231,7 +1231,7 @@ enum { // TODO: should this be an API func? static KeyingSet *verify_active_keyingset(Scene *scene, short add) { - KeyingSet *ks= NULL; + KeyingSet *ks = NULL; /* sanity check */ if (scene == NULL) @@ -1239,13 +1239,13 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* try to find one from scene */ if (scene->active_keyingset > 0) - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* add if none found */ // XXX the default settings have yet to evolve - if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + if ((add) && (ks == NULL)) { + ks = BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); } return ks; @@ -1257,22 +1257,22 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa TreeElement *te; TreeStoreElem *tselem; - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); + for (te = tree->first; te; te = te->next) { + tselem = TREESTORE(te); /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; + ID *id = NULL; + char *path = NULL; + int array_index = 0; + short flag = 0; + short groupmode = KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); + &id, &path, &array_index, &flag, &groupmode); } /* only if ID and path were set, should we perform any actions */ @@ -1284,22 +1284,22 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa /* add a new path with the information obtained (only if valid) */ // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode); - ks->active_path= BLI_countlist(&ks->paths); + ks->active_path = BLI_countlist(&ks->paths); } - break; + break; case KEYINGSET_EDITMODE_REMOVE: { /* find the relevant path, then remove it from the KeyingSet */ - KS_Path *ksp= BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); + KS_Path *ksp = BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); if (ksp) { /* free path's data */ BKE_keyingset_free_path(ks, ksp); - ks->active_path= 0; + ks->active_path = 0; } } - break; + break; } /* free path, since it had to be generated */ @@ -1317,9 +1317,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); + SpaceOops *soutliner = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ if (ks == NULL) { @@ -1333,7 +1333,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -1350,7 +1350,7 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1358,9 +1358,9 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); + SpaceOops *soutliner = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ if (soutliner == NULL) @@ -1370,7 +1370,7 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -1387,7 +1387,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Parent Drop Operator *********************** */ @@ -1395,23 +1395,23 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) static int parent_drop_exec(bContext *C, wmOperator *op) { Object *par = NULL, *ob = NULL; - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); int partype = -1; char parname[MAX_ID_NAME], childname[MAX_ID_NAME]; - partype= RNA_enum_get(op->ptr, "type"); + partype = RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)BKE_libblock_find_name(ID_OB, parname); + par = (Object *)BKE_libblock_find_name(ID_OB, parname); RNA_string_get(op->ptr, "child", childname); - ob= (Object *)BKE_libblock_find_name(ID_OB, childname); + ob = (Object *)BKE_libblock_find_name(ID_OB, childname); ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; } @@ -1419,8 +1419,8 @@ static int parent_drop_exec(bContext *C, wmOperator *op) /* Used for drag and drop parenting */ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement *te, float *fmval) { - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeStoreElem *tselem= TREESTORE(te); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeStoreElem *tselem = TREESTORE(te); if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* name and first icon */ @@ -1436,10 +1436,10 @@ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement * } /* Not it. Let's look at its children. */ - if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { TreeElement *te_valid; - te_valid= outliner_dropzone_parent(C, event, te, fmval); + te_valid = outliner_dropzone_parent(C, event, te, fmval); if (te_valid) return te_valid; } } @@ -1448,24 +1448,24 @@ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement * static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *par= NULL; - Object *ob= NULL; - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - TreeElement *te= NULL; - TreeElement *te_found= NULL; + Object *par = NULL; + Object *ob = NULL; + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + TreeElement *te = NULL; + TreeElement *te_found = NULL; char childname[MAX_ID_NAME]; char parname[MAX_ID_NAME]; - int partype= 0; + int partype = 0; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); /* Find object hovered over */ - for (te= soops->tree.first; te; te= te->next) { - te_found= outliner_dropzone_parent(C, event, te, fmval); + for (te = soops->tree.first; te; te = te->next) { + te_found = outliner_dropzone_parent(C, event, te, fmval); if (te_found) break; } @@ -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(ID_OB, childname); + ob = (Object *)BKE_libblock_find_name(ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)BKE_libblock_find_name(ID_OB, parname); + par = (Object *)BKE_libblock_find_name(ID_OB, parname); if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); @@ -1493,14 +1493,14 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); } } else { /* Menu creation */ - uiPopupMenu *pup= uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); - uiLayout *layout= uiPupMenuLayout(pup); + uiPopupMenu *pup = uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); + uiLayout *layout = uiPupMenuLayout(pup); PointerRNA ptr; @@ -1513,7 +1513,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); /* par becomes parent, make the associated menus */ - if (par->type==OB_ARMATURE) { + if (par->type == OB_ARMATURE) { WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); RNA_string_set(&ptr, "parent", parname); RNA_string_set(&ptr, "child", childname); @@ -1549,7 +1549,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Bone"), 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); } - else if (par->type==OB_CURVE) { + else if (par->type == OB_CURVE) { WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); RNA_string_set(&ptr, "parent", parname); RNA_string_set(&ptr, "child", childname); @@ -1606,7 +1606,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object"); @@ -1616,15 +1616,15 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, float *fmval) { - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeStoreElem *tselem= TREESTORE(te); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeStoreElem *tselem = TREESTORE(te); /* Check for row */ if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* Ignore drop on scene tree elements */ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { if ((te->idcode == ID_SCE) && - !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) + !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) { return 0; } @@ -1639,11 +1639,11 @@ int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, return 1; } - return 0; // ID_OB, but mouse in undefined dropzone. + return 0; // ID_OB, but mouse in undefined dropzone. } /* Not this row. Let's look at its children. */ - if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; @@ -1654,12 +1654,12 @@ int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Scene *scene= CTX_data_scene(C); - Object *ob= NULL; + Scene *scene = CTX_data_scene(C); + Object *ob = NULL; char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); - ob= (Object *)BKE_libblock_find_name(ID_OB, obname); + ob = (Object *)BKE_libblock_find_name(ID_OB, obname); /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) @@ -1683,7 +1683,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object"); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index b1990d3054e..d8d10519bd6 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -48,82 +48,82 @@ struct Object; typedef struct TreeElement { struct TreeElement *next, *prev, *parent; ListBase subtree; - float xs, ys; // do selection - int store_index; // offset in tree store - short flag; // flag for non-saved stuff - short index; // index for data arrays - short idcode; // from TreeStore id - short xend; // width of item display, for select + float xs, ys; // do selection + int store_index; // offset in tree store + short flag; // flag for non-saved stuff + short index; // index for data arrays + short idcode; // from TreeStore id + short xend; // width of item display, for select const char *name; - void *directdata; // Armature Bones, Base, Sequence, Strip... - PointerRNA rnaptr; // RNA Pointer + void *directdata; // Armature Bones, Base, Sequence, Strip... + PointerRNA rnaptr; // RNA Pointer } TreeElement; /* TreeElement->flag */ -#define TE_ACTIVE 1 -#define TE_ICONROW 2 -#define TE_LAZY_CLOSED 4 -#define TE_FREE_NAME 8 +#define TE_ACTIVE 1 +#define TE_ICONROW 2 +#define TE_LAZY_CLOSED 4 +#define TE_FREE_NAME 8 /* TreeStoreElem types */ -#define TSE_NLA 1 -#define TSE_NLA_ACTION 2 -#define TSE_DEFGROUP_BASE 3 -#define TSE_DEFGROUP 4 -#define TSE_BONE 5 -#define TSE_EBONE 6 -#define TSE_CONSTRAINT_BASE 7 -#define TSE_CONSTRAINT 8 -#define TSE_MODIFIER_BASE 9 -#define TSE_MODIFIER 10 -#define TSE_LINKED_OB 11 -#define TSE_SCRIPT_BASE 12 -#define TSE_POSE_BASE 13 -#define TSE_POSE_CHANNEL 14 -#define TSE_ANIM_DATA 15 -#define TSE_DRIVER_BASE 16 -#define TSE_DRIVER 17 +#define TSE_NLA 1 +#define TSE_NLA_ACTION 2 +#define TSE_DEFGROUP_BASE 3 +#define TSE_DEFGROUP 4 +#define TSE_BONE 5 +#define TSE_EBONE 6 +#define TSE_CONSTRAINT_BASE 7 +#define TSE_CONSTRAINT 8 +#define TSE_MODIFIER_BASE 9 +#define TSE_MODIFIER 10 +#define TSE_LINKED_OB 11 +#define TSE_SCRIPT_BASE 12 +#define TSE_POSE_BASE 13 +#define TSE_POSE_CHANNEL 14 +#define TSE_ANIM_DATA 15 +#define TSE_DRIVER_BASE 16 +#define TSE_DRIVER 17 -#define TSE_PROXY 18 -#define TSE_R_LAYER_BASE 19 -#define TSE_R_LAYER 20 -#define TSE_R_PASS 21 -#define TSE_LINKED_MAT 22 +#define TSE_PROXY 18 +#define TSE_R_LAYER_BASE 19 +#define TSE_R_LAYER 20 +#define TSE_R_PASS 21 +#define TSE_LINKED_MAT 22 /* NOTE, is used for light group */ -#define TSE_LINKED_LAMP 23 -#define TSE_POSEGRP_BASE 24 -#define TSE_POSEGRP 25 -#define TSE_SEQUENCE 26 -#define TSE_SEQ_STRIP 27 -#define TSE_SEQUENCE_DUP 28 +#define TSE_LINKED_LAMP 23 +#define TSE_POSEGRP_BASE 24 +#define TSE_POSEGRP 25 +#define TSE_SEQUENCE 26 +#define TSE_SEQ_STRIP 27 +#define TSE_SEQUENCE_DUP 28 #define TSE_LINKED_PSYS 29 -#define TSE_RNA_STRUCT 30 -#define TSE_RNA_PROPERTY 31 -#define TSE_RNA_ARRAY_ELEM 32 -#define TSE_NLA_TRACK 33 -#define TSE_KEYMAP 34 -#define TSE_KEYMAP_ITEM 35 +#define TSE_RNA_STRUCT 30 +#define TSE_RNA_PROPERTY 31 +#define TSE_RNA_ARRAY_ELEM 32 +#define TSE_NLA_TRACK 33 +#define TSE_KEYMAP 34 +#define TSE_KEYMAP_ITEM 35 /* button events */ -#define OL_NAMEBUTTON 1 +#define OL_NAMEBUTTON 1 /* get TreeStoreElem associated with a TreeElement * < a: (TreeElement) tree element to find stored element for */ -#define TREESTORE(a) ((a)?soops->treestore->data+(a)->store_index:NULL) +#define TREESTORE(a) ((a) ? soops->treestore->data + (a)->store_index : NULL) /* size constants */ -#define OL_Y_OFFSET 2 +#define OL_Y_OFFSET 2 -#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X*3) -#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X*2) -#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X +#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 3) +#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 2) +#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X #define OL_TOGW OL_TOG_RESTRICT_VIEWX -#define OL_RNA_COLX (UI_UNIT_X*15) -#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5f) -#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5f) +#define OL_RNA_COLX (UI_UNIT_X * 15) +#define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f) +#define OL_RNA_COL_SPACEX (UI_UNIT_X * 2.5f) /* Outliner Searching -- @@ -145,7 +145,7 @@ typedef struct TreeElement { #define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE) /* is the currrent element open? if so we also show children */ -#define TSELEM_OPEN(telm,sv) ( (telm->flag & TSE_CLOSED)==0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) +#define TSELEM_OPEN(telm, sv) ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) /* outliner_tree.c ----------------------------------------------- */ @@ -170,7 +170,7 @@ int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soop /* outliner_edit.c ---------------------------------------------- */ void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb, - void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); + void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); int common_restrict_check(struct bContext *C, struct Object *ob); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 800953c1a62..45687bf96a5 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -73,21 +73,21 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se { TreeElement *te; TreeStoreElem *tselem; - int change= 0; + int change = 0; - for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) { - tselem= TREESTORE(te); + for (te = lb->first; te && *index >= 0; te = te->next, (*index)--) { + tselem = TREESTORE(te); /* if we've encountered the right item, set its 'Outliner' selection status */ if (*index == 0) { /* this should be the last one, so no need to do anything with index */ - if ((te->flag & TE_ICONROW)==0) { + if ((te->flag & TE_ICONROW) == 0) { /* -1 value means toggle testing for now... */ if (*selecting == -1) { if (tselem->flag & TSE_SELECTED) - *selecting= 0; + *selecting = 0; else - *selecting= 1; + *selecting = 1; } /* set selection */ @@ -103,9 +103,9 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se /* Only try selecting sub-elements if we haven't hit the right element yet * * Hack warning: - * Index must be reduced before supplying it to the sub-tree to try to do - * selection, however, we need to increment it again for the next loop to - * function correctly + * Index must be reduced before supplying it to the sub-tree to try to do + * selection, however, we need to increment it again for the next loop to + * function correctly */ (*index)--; change |= outliner_select(soops, &te->subtree, index, selecting); @@ -124,45 +124,45 @@ static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeSto Scene *sce; /* paranoia check */ - if (te->idcode!=ID_SCE) + if (te->idcode != ID_SCE) return 0; - sce= (Scene *)tselem->id; + sce = (Scene *)tselem->id; if (set) { - sce->r.actlay= tselem->nr; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); + sce->r.actlay = tselem->nr; + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); } else { - return sce->r.actlay==tselem->nr; + return sce->r.actlay == tselem->nr; } return 0; } static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); Scene *sce; Base *base; - Object *ob= NULL; + Object *ob = NULL; /* if id is not object, we search back */ - if (te->idcode==ID_OB) ob= (Object *)tselem->id; + if (te->idcode == ID_OB) ob = (Object *)tselem->id; else { - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if (ob==OBACT) return 0; + ob = (Object *)outliner_search_back(soops, te, ID_OB); + if (ob == OBACT) return 0; } - if (ob==NULL) return 0; + if (ob == NULL) return 0; - sce= (Scene *)outliner_search_back(soops, te, ID_SCE); + sce = (Scene *)outliner_search_back(soops, te, ID_SCE); if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } /* find associated base in current scene */ - base= BKE_scene_base_find(scene, ob); + base = BKE_scene_base_find(scene, ob); if (base) { - if (set==2) { + if (set == 2) { /* swap select */ if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); @@ -176,12 +176,12 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops } if (C) { ED_base_object_activate(C, base); /* adds notifier */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } - if (ob!=scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + if (ob != scene->obedit) + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); return 1; } @@ -192,35 +192,35 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so Object *ob; /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); + ob = (Object *)outliner_search_back(soops, te, ID_OB); // note: ob->matbits can be NULL when a local object points to a library mesh. - if (ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia + if (ob == NULL || ob != OBACT || ob->matbits == NULL) return 0; // just paranoia /* searching in ob mat array? */ - tes= te->parent; - if (tes->idcode==ID_OB) { + tes = te->parent; + if (tes->idcode == ID_OB) { if (set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 1; // make ob material active too + ob->actcol = te->index + 1; + ob->matbits[te->index] = 1; // make ob material active too } else { - if (ob->actcol == te->index+1) + if (ob->actcol == te->index + 1) if (ob->matbits[te->index]) return 1; } } /* or we search for obdata material */ else { if (set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 0; // make obdata material active too + ob->actcol = te->index + 1; + ob->matbits[te->index] = 0; // make obdata material active too } else { - if (ob->actcol == te->index+1) - if (ob->matbits[te->index]==0) return 1; + if (ob->actcol == te->index + 1) + if (ob->matbits[te->index] == 0) return 1; } } if (set) { - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, NULL); } return 0; } @@ -229,10 +229,10 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo { TreeElement *tep; TreeStoreElem /* *tselem,*/ *tselemp; - Object *ob=OBACT; - SpaceButs *sbuts=NULL; + Object *ob = OBACT; + SpaceButs *sbuts = NULL; - if (ob==NULL) return 0; // no active object + if (ob == NULL) return 0; // no active object /*tselem= TREESTORE(te);*/ /*UNUSED*/ @@ -240,11 +240,11 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo /* XXX removed finding sbuts */ /* where is texture linked to? */ - tep= te->parent; - tselemp= TREESTORE(tep); + tep = te->parent; + tselemp = TREESTORE(tep); - if (tep->idcode==ID_WO) { - World *wrld= (World *)tselemp->id; + if (tep->idcode == ID_WO) { + World *wrld = (World *)tselemp->id; if (set) { if (sbuts) { @@ -252,43 +252,43 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo // XXX sbuts->texfrom= 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - wrld->texact= te->index; + wrld->texact = te->index; } else if (tselemp->id == (ID *)(scene->world)) { - if (wrld->texact==te->index) return 1; + if (wrld->texact == te->index) return 1; } } - else if (tep->idcode==ID_LA) { - Lamp *la= (Lamp *)tselemp->id; + else if (tep->idcode == ID_LA) { + Lamp *la = (Lamp *)tselemp->id; if (set) { if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 2; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - la->texact= te->index; + la->texact = te->index; } else { if (tselemp->id == ob->data) { - if (la->texact==te->index) return 1; + if (la->texact == te->index) return 1; } } } - else if (tep->idcode==ID_MA) { - Material *ma= (Material *)tselemp->id; + else if (tep->idcode == ID_MA) { + Material *ma = (Material *)tselemp->id; if (set) { if (sbuts) { //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 0; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - ma->texact= (char)te->index; + ma->texact = (char)te->index; /* also set active material */ - ob->actcol= tep->index+1; + ob->actcol = tep->index + 1; } - else if (tep->flag & TE_ACTIVE) { // this is active material - if (ma->texact==te->index) return 1; + else if (tep->flag & TE_ACTIVE) { // this is active material + if (ma->texact == te->index) return 1; } } @@ -304,8 +304,8 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops Object *ob; /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if (ob==NULL || ob!=OBACT) return 0; // just paranoia + ob = (Object *)outliner_search_back(soops, te, ID_OB); + if (ob == NULL || ob != OBACT) return 0; // just paranoia if (set) { // XXX extern_set_butspace(F5KEY, 0); @@ -317,7 +317,7 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) { - Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); + Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); if (set) return 0; @@ -328,22 +328,22 @@ static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOo static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { TreeElement *tep; - TreeStoreElem *tselem=NULL; - Scene *sce=NULL; + TreeStoreElem *tselem = NULL; + Scene *sce = NULL; - tep= te->parent; + tep = te->parent; if (tep) { - tselem= TREESTORE(tep); - sce= (Scene *)tselem->id; + tselem = TREESTORE(tep); + sce = (Scene *)tselem->id; } - if (set) { // make new scene active + if (set) { // make new scene active if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } } - if (tep==NULL || tselem->id == (ID *)scene) { + if (tep == NULL || tselem->id == (ID *)scene) { if (set) { // XXX extern_set_butspace(F8KEY, 0); } @@ -359,34 +359,34 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * Object *ob; /* id in tselem is object */ - ob= (Object *)tselem->id; + ob = (Object *)tselem->id; if (set) { - BLI_assert(te->index+1 >= 0); - ob->actdef= te->index+1; + BLI_assert(te->index + 1 >= 0); + ob->actdef = te->index + 1; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); } else { - if (ob==OBACT) - if (ob->actdef== te->index+1) return 1; + if (ob == OBACT) + if (ob->actdef == te->index + 1) return 1; } return 0; } static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; if (set) { if (ob->pose) { - ob->pose->active_group= te->index+1; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + ob->pose->active_group = te->index + 1; + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } } else { - if (ob==OBACT && ob->pose) { - if (ob->pose->active_group== te->index+1) return 1; + if (ob == OBACT && ob->pose) { + if (ob->pose->active_group == te->index + 1) return 1; } } return 0; @@ -394,30 +394,30 @@ static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; - bArmature *arm= ob->data; - bPoseChannel *pchan= te->directdata; + Object *ob = (Object *)tselem->id; + bArmature *arm = ob->data; + bPoseChannel *pchan = te->directdata; if (set) { if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - if (set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag - else ED_pose_deselectall(ob, 0); // 0 = deselect + if (set == 2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + else ED_pose_deselectall(ob, 0); // 0 = deselect - if (set==2 && (pchan->bone->flag & BONE_SELECTED)) { + if (set == 2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; } else { pchan->bone->flag |= BONE_SELECTED; - arm->act_bone= pchan->bone; + arm->act_bone = pchan->bone; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob); } } else { - if (ob==OBACT && ob->pose) { + if (ob == OBACT && ob->pose) { if (pchan->bone->flag & BONE_SELECTED) return 1; } } @@ -426,29 +426,29 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - bArmature *arm= (bArmature *)tselem->id; - Bone *bone= te->directdata; + bArmature *arm = (bArmature *)tselem->id; + Bone *bone = te->directdata; if (set) { if (!(bone->flag & BONE_HIDDEN_P)) { - if (set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + if (set == 2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag else ED_pose_deselectall(OBACT, 0); - if (set==2 && (bone->flag & BONE_SELECTED)) { + if (set == 2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; } else { bone->flag |= BONE_SELECTED; - arm->act_bone= bone; + arm->act_bone = bone; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, OBACT); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT); } } else { - Object *ob= OBACT; + Object *ob = OBACT; - if (ob && ob->data==arm) { + if (ob && ob->data == arm) { if (bone->flag & BONE_SELECTED) return 1; } } @@ -460,32 +460,32 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) { if (sel) { - ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; - arm->act_edbone= ebone; + ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL; + arm->act_edbone = ebone; // flush to parent? if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; } else { - ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); // flush to parent? if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, scene->obedit); } static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { - bArmature *arm= scene->obedit->data; - EditBone *ebone= te->directdata; + bArmature *arm = scene->obedit->data; + EditBone *ebone = te->directdata; - if (set==1) { + if (set == 1) { if (!(ebone->flag & BONE_HIDDEN_A)) { - ED_armature_deselect_all(scene->obedit, 0); // deselect + ED_armature_deselect_all(scene->obedit, 0); // deselect tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } } - else if (set==2) { + else if (set == 2) { if (!(ebone->flag & BONE_HIDDEN_A)) { if (!(ebone->flag & BONE_SELECTED)) { tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); @@ -507,9 +507,9 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); // XXX extern_set_butspace(F9KEY, 0); } @@ -520,9 +520,9 @@ static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), Tr static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); // XXX extern_set_butspace(F7KEY, 0); } @@ -533,9 +533,9 @@ static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeEleme static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); // XXX extern_set_butspace(F7KEY, 0); } @@ -550,12 +550,12 @@ 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= BKE_scene_base_find(scene, ob); + Object *ob = (Object *)tselem->id; + Base *base = BKE_scene_base_find(scene, ob); if (set) { if (scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); if (ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); @@ -570,7 +570,7 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { - Sequence *seq= (Sequence*) te->directdata; + Sequence *seq = (Sequence *) te->directdata; if (set) { // XXX select_single_seq(seq, 1); @@ -585,26 +585,26 @@ static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(t static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq, *p; - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = seq_give_editing(scene, FALSE); - seq= (Sequence*)te->directdata; - if (set==0) { + seq = (Sequence *)te->directdata; + if (set == 0) { if (seq->flag & SELECT) return(1); return(0); } // XXX select_single_seq(seq, 1); - p= ed->seqbasep->first; + p = ed->seqbasep->first; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } // if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); - p= p->next; + p = p->next; } return(0); } @@ -613,7 +613,7 @@ static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, { wmKeyMapItem *kmi = te->directdata; - if (set==0) { + if (set == 0) { if (kmi->flag & KMI_INACTIVE) return 0; return 1; } @@ -663,7 +663,7 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl return tree_element_active_modifier(C, te, tselem, set); case TSE_LINKED_OB: if (set) tree_element_set_active_object(C, scene, soops, te, set); - else if (tselem->id==(ID *)OBACT) return 1; + else if (tselem->id == (ID *)OBACT) return 1; break; case TSE_LINKED_PSYS: return tree_element_active_psys(C, scene, te, tselem, set); @@ -693,14 +693,14 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) { - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); - int openclose= 0; + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); + int openclose = 0; /* open close icon */ - if ((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close - if ( mval[0]>te->xs && mval[0]xs+UI_UNIT_X) - openclose= 1; + if ((te->flag & TE_ICONROW) == 0) { // hidden icon, no open/close + if (mval[0] > te->xs && mval[0] < te->xs + UI_UNIT_X) + openclose = 1; } if (openclose) { @@ -718,62 +718,62 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa return 1; } /* name and first icon */ - else if (mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { + else if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) { /* always makes active object */ - if (tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) - tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); + if (tselem->type != TSE_SEQUENCE && tselem->type != TSE_SEQ_STRIP && tselem->type != TSE_SEQUENCE_DUP) + tree_element_set_active_object(C, scene, soops, te, 1 + (extend != 0 && tselem->type == 0)); - if (tselem->type==0) { // the lib blocks + if (tselem->type == 0) { // the lib blocks /* editmode? */ - if (te->idcode==ID_SCE) { - if (scene!=(Scene *)tselem->id) { + if (te->idcode == ID_SCE) { + if (scene != (Scene *)tselem->id) { ED_screen_set_scene(C, CTX_wm_screen(C), (Scene *)tselem->id); } } - else if (te->idcode==ID_GR) { - Group *gr= (Group *)tselem->id; + else if (te->idcode == ID_GR) { + Group *gr = (Group *)tselem->id; GroupObject *gob; if (extend) { - int sel= BA_SELECT; - for (gob= gr->gobject.first; gob; gob= gob->next) { + int sel = BA_SELECT; + for (gob = gr->gobject.first; gob; gob = gob->next) { if (gob->ob->flag & SELECT) { - sel= BA_DESELECT; + sel = BA_DESELECT; break; } } - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { ED_base_object_select(BKE_scene_base_find(scene, gob->ob), sel); } } else { BKE_scene_base_deselect_all(scene); - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->flag & SELECT) == 0) ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } else if (ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); } - else { // rest of types + else { // rest of types tree_element_active(C, scene, soops, te, 1); } } - else tree_element_type_active(C, scene, soops, te, tselem, 1+(extend!=0)); + else tree_element_type_active(C, scene, soops, te, tselem, 1 + (extend != 0)); return 1; } } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; } return 0; @@ -782,23 +782,23 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa /* event can enterkey, then it opens/closes */ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - int extend= RNA_boolean_get(op->ptr, "extend"); + int extend = RNA_boolean_get(op->ptr, "extend"); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - if ( !ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && - !(soops->flag & SO_HIDE_RESTRICTCOLS) && - (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) + if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + !(soops->flag & SO_HIDE_RESTRICTCOLS) && + (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) { return OPERATOR_CANCELLED; } - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } @@ -806,12 +806,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) ED_undo_push(C, "Outliner click event"); } else { - short selecting= -1; + short selecting = -1; int row; /* get row number - 100 here is just a dummy value since we don't need the column */ UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, - fmval[0], fmval[1], NULL, &row); + fmval[0], fmval[1], NULL, &row); /* select relevant row */ if (outliner_select(soops, &soops->tree, &row, &selecting)) { @@ -847,7 +847,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) /* **************** Border Select Tool ****************** */ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *rectf, TreeElement *te, int gesture_mode) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) { if (gesture_mode == GESTURE_MODAL_SELECT) { @@ -869,13 +869,13 @@ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *re static int outliner_border_select_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); TreeElement *te; rcti rect; rctf rectf; - int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); + int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -885,11 +885,11 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { outliner_item_border_select(scene, soops, &rectf, te, gesture_mode); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -911,7 +911,7 @@ void OUTLINER_OT_select_border(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, FALSE); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index c22ed22ff92..a3ed2eac2d5 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -77,31 +77,31 @@ /* ************ SELECTION OPERATIONS ********* */ static void set_operation_types(SpaceOops *soops, ListBase *lb, - int *scenelevel, - int *objectlevel, - int *idlevel, - int *datalevel) + int *scenelevel, + int *objectlevel, + int *idlevel, + int *datalevel) { TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { if (tselem->type) { - if (*datalevel==0) - *datalevel= tselem->type; - else if (*datalevel!=tselem->type) - *datalevel= -1; + if (*datalevel == 0) + *datalevel = tselem->type; + else if (*datalevel != tselem->type) + *datalevel = -1; } else { - int idcode= GS(tselem->id->name); + int idcode = GS(tselem->id->name); switch (idcode) { case ID_SCE: - *scenelevel= 1; + *scenelevel = 1; break; case ID_OB: - *objectlevel= 1; + *objectlevel = 1; break; case ID_ME: case ID_CU: case ID_MB: case ID_LT: @@ -109,9 +109,9 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, case ID_MA: case ID_TE: case ID_IP: case ID_IM: case ID_SO: case ID_KE: case ID_WO: case ID_AC: case ID_NLA: case ID_TXT: case ID_GR: - if (*idlevel==0) *idlevel= idcode; - else if (*idlevel!=idcode) *idlevel= -1; - break; + if (*idlevel == 0) *idlevel = idcode; + else if (*idlevel != idcode) *idlevel = -1; + break; } } } @@ -130,62 +130,62 @@ static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNU static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { - Material **matar=NULL; - int a, totcol=0; + Material **matar = NULL; + int a, totcol = 0; - if ( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - totcol= ob->totcol; - matar= ob->mat; + if (GS(tsep->id->name) == ID_OB) { + Object *ob = (Object *)tsep->id; + totcol = ob->totcol; + matar = ob->mat; } - else if ( GS(tsep->id->name)==ID_ME) { - Mesh *me= (Mesh *)tsep->id; - totcol= me->totcol; - matar= me->mat; + else if (GS(tsep->id->name) == ID_ME) { + Mesh *me = (Mesh *)tsep->id; + totcol = me->totcol; + matar = me->mat; } - else if ( GS(tsep->id->name)==ID_CU) { - Curve *cu= (Curve *)tsep->id; - totcol= cu->totcol; - matar= cu->mat; + else if (GS(tsep->id->name) == ID_CU) { + Curve *cu = (Curve *)tsep->id; + totcol = cu->totcol; + matar = cu->mat; } - else if ( GS(tsep->id->name)==ID_MB) { - MetaBall *mb= (MetaBall *)tsep->id; - totcol= mb->totcol; - matar= mb->mat; + else if (GS(tsep->id->name) == ID_MB) { + MetaBall *mb = (MetaBall *)tsep->id; + totcol = mb->totcol; + matar = mb->mat; } - for (a=0; aindex && matar[a]) { + for (a = 0; a < totcol; a++) { + if (a == te->index && matar[a]) { matar[a]->id.us--; - matar[a]= NULL; + matar[a] = NULL; } } } static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { - MTex **mtex= NULL; + MTex **mtex = NULL; int a; - if ( GS(tsep->id->name)==ID_MA) { - Material *ma= (Material *)tsep->id; - mtex= ma->mtex; + if (GS(tsep->id->name) == ID_MA) { + Material *ma = (Material *)tsep->id; + mtex = ma->mtex; } - else if ( GS(tsep->id->name)==ID_LA) { - Lamp *la= (Lamp *)tsep->id; - mtex= la->mtex; + else if (GS(tsep->id->name) == ID_LA) { + Lamp *la = (Lamp *)tsep->id; + mtex = la->mtex; } - else if ( GS(tsep->id->name)==ID_WO) { - World *wrld= (World *)tsep->id; - mtex= wrld->mtex; + else if (GS(tsep->id->name) == ID_WO) { + World *wrld = (World *)tsep->id; + mtex = wrld->mtex; } else return; - for (a=0; aindex && mtex[a]) { + for (a = 0; a < MAX_MTEX; a++) { + if (a == te->index && mtex[a]) { if (mtex[a]->tex) { mtex[a]->tex->id.us--; - mtex[a]->tex= NULL; + mtex[a]->tex = NULL; } } } @@ -193,12 +193,12 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; if (tsep) { - if ( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - ob->dup_group= NULL; + if (GS(tsep->id->name) == ID_OB) { + Object *ob = (Object *)tsep->id; + ob->dup_group = NULL; } } else { @@ -217,16 +217,16 @@ static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme } static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==0) { - TreeStoreElem *tsep= TREESTORE(te->parent); + if (tselem->type == 0) { + TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(C, scene, te, tsep, tselem); } } @@ -240,10 +240,10 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops * static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); - if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { + 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; } @@ -251,9 +251,9 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= BKE_scene_base_find(scene, (Object *)tselem->id); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->flag &= ~SELECT; base->object->flag &= ~SELECT; @@ -262,18 +262,18 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) - base= BKE_scene_base_find(scene, (Object *)tselem->id); + if (base == NULL) + base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { // check also library later - if (scene->obedit==base->object) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + if (scene->obedit == base->object) + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); - te->directdata= NULL; - tselem->id= NULL; + te->directdata = NULL; + tselem->id = NULL; } } @@ -283,7 +283,7 @@ static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(t /* if the ID type has no special local function, * just clear the lib */ if (id_make_local(tselem->id, FALSE) == FALSE) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); id_clear_lib_data(bmain, tselem->id); } } @@ -344,41 +344,41 @@ static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement * static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; GroupObject *gob; Base *base; - for (gob=group->gobject.first; gob; gob=gob->next) { - base= BKE_scene_base_find(scene, gob->ob); + for (gob = group->gobject.first; gob; gob = gob->next) { + base = BKE_scene_base_find(scene, gob->ob); if (base) { base->object->flag |= SELECT; base->flag |= SELECT; } else { /* link to scene */ - base= MEM_callocN(sizeof(Base), "add_base"); + base = MEM_callocN(sizeof(Base), "add_base"); BLI_addhead(&scene->base, base); - base->lay= (1<<20)-1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ + base->lay = (1 << 20) - 1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ gob->ob->flag |= SELECT; base->flag = gob->ob->flag; - base->object= gob->ob; + base->object = gob->ob; id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */ } } } void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type == 0 && te->idcode == ID_OB) { // when objects selected in other scenes... dunno if that should be allowed - Scene *scene_owner= (Scene *)outliner_search_back(soops, te, ID_SCE); + Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE); if (scene_owner && scene_act != scene_owner) { ED_screen_set_scene(C, CTX_wm_screen(C), scene_owner); } @@ -416,7 +416,7 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te FCurve *fcu; /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */ - for (fcu = iat->adt->drivers.first; fcu; fcu= fcu->next) { + for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; if (fcu->driver) @@ -428,70 +428,70 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; + bPoseChannel *pchan = (bPoseChannel *)te->directdata; - if (event==1) + if (event == 1) pchan->bone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) pchan->bone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { pchan->bone->flag |= BONE_HIDDEN_P; pchan->bone->flag &= ~BONE_SELECTED; } - else if (event==4) + else if (event == 4) pchan->bone->flag &= ~BONE_HIDDEN_P; } static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - Bone *bone= (Bone *)te->directdata; + Bone *bone = (Bone *)te->directdata; - if (event==1) + if (event == 1) bone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) bone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; } - else if (event==4) + else if (event == 4) bone->flag &= ~BONE_HIDDEN_P; } static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - EditBone *ebone= (EditBone *)te->directdata; + EditBone *ebone = (EditBone *)te->directdata; - if (event==1) + if (event == 1) ebone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) ebone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { ebone->flag |= BONE_HIDDEN_A; - ebone->flag &= ~BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } - else if (event==4) + else if (event == 4) ebone->flag &= ~BONE_HIDDEN_A; } static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) { // Sequence *seq= (Sequence*) te->directdata; - if (event==1) { + if (event == 1) { // XXX select_single_seq(seq, 1); } } static void outliner_do_data_operation(SpaceOops *soops, int type, int event, ListBase *lb, - void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) + void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==type) { + if (tselem->type == type) { operation_cb(event, te, tselem); } } @@ -516,34 +516,34 @@ static EnumPropertyItem prop_object_op_types[] = { static int outliner_object_operation_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str= NULL; + const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); - if (event==1) { - Scene *sce= scene; // to be able to delete, scenes are set... + if (event == 1) { + Scene *sce = scene; // to be able to delete, scenes are set... outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb); if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } - str= "Select Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Select Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==2) { + else if (event == 2) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); - str= "Deselect Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Deselect Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==4) { + else if (event == 4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); /* XXX: tree management normally happens from draw_outliner(), but when @@ -554,31 +554,31 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) outliner_cleanup_tree(soops); DAG_scene_sort(bmain, scene); - str= "Delete Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + str = "Delete Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } - else if (event==5) { /* disabled, see above enum (ton) */ + else if (event == 5) { /* disabled, see above enum (ton) */ outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Objects"; + str = "Localized Objects"; } - else if (event==6) { + else if (event == 6) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - str= "Toggle Visibility"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + str = "Toggle Visibility"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); } - else if (event==7) { + else if (event == 7) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - str= "Toggle Selectability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Toggle Selectability"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==8) { + else if (event == 8) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - str= "Toggle Renderability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + str = "Toggle Renderability"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); } - else if (event==9) { + else if (event == 9) { outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb); - str= "Rename Object"; + str = "Rename Object"; } ED_undo_push(C, str); @@ -619,44 +619,44 @@ static EnumPropertyItem prop_group_op_types[] = { static int outliner_group_operation_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str= NULL; + const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); - if (event==1) { + if (event == 1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - str= "Unlink group"; + str = "Unlink group"; } - else if (event==2) { + else if (event == 2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Data"; + str = "Localized Data"; } - else if (event==3) { + else if (event == 3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - str= "Link Group Objects to Scene"; + str = "Link Group Objects to Scene"; } - else if (event==4) { + else if (event == 4) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); - str= "Toggle Visibility"; + str = "Toggle Visibility"; } - else if (event==5) { + else if (event == 5) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); - str= "Toggle Selectability"; + str = "Toggle Selectability"; } - else if (event==6) { + else if (event == 6) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); - str= "Toggle Renderability"; + str = "Toggle Renderability"; } - else if (event==7) { + else if (event == 7) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - str= "Rename"; + str = "Rename"; } @@ -711,9 +711,9 @@ static EnumPropertyItem prop_id_op_types[] = { static int outliner_id_operation_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutlinerIdOpTypes event; /* check for invalid states */ @@ -722,7 +722,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); switch (event) { case OUTLINER_IDOP_UNLINK: @@ -732,25 +732,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case ID_MA: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink material"); break; case ID_TE: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink texture"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_world_cb); - WM_event_add_notifier(C, NC_SCENE|ND_WORLD, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Unlink world"); break; default: @@ -758,7 +758,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } } - break; + break; case OUTLINER_IDOP_LOCAL: { @@ -766,7 +766,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); ED_undo_push(C, "Localized Data"); } - break; + break; case OUTLINER_IDOP_SINGLE: { @@ -775,14 +775,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Single-User Action"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_world_cb); - WM_event_add_notifier(C, NC_SCENE|ND_WORLD, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Single-User World"); break; @@ -791,36 +791,36 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } } - break; + break; case OUTLINER_IDOP_FAKE_ADD: { /* set fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Add Fake User"); } - break; + break; case OUTLINER_IDOP_FAKE_CLEAR: { /* clear fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Clear Fake User"); } - break; + break; case OUTLINER_IDOP_RENAME: { /* rename */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Rename"); } - break; + break; default: // invalid - unhandled @@ -828,10 +828,10 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) } /* wrong notifier still... */ - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); // XXX: this is just so that outliner is always up to date - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; } @@ -857,15 +857,15 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) /* **************************************** */ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *lb, ID *newid, - void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) + void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==type) { + if (tselem->type == type) { TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(te, tselem, tsep, newid); } @@ -898,8 +898,8 @@ static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, Tree static int outliner_action_set_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; bAction *act; @@ -909,7 +909,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); /* get action to use */ - act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); + act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); @@ -918,20 +918,20 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) else if (act->idroot == 0) { /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ BKE_reportf(op->reports, RPT_WARNING, - "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", - act->id.name+2); + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name + 2); } /* perform action if valid channel */ if (datalevel == TSE_ANIM_DATA) - outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID*)act, actionset_id_cb); + outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); else if (idlevel == ID_AC) - outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID*)act, actionset_id_cb); + outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); else return OPERATOR_CANCELLED; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Set action"); /* done */ @@ -956,8 +956,8 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) ot->flag = 0; /* props */ - // TODO: this would be nicer as an ID-pointer... - prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); + // TODO: this would be nicer as an ID-pointer... + prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); RNA_def_enum_funcs(prop, RNA_action_itemf); ot->prop = prop; } @@ -989,8 +989,8 @@ static EnumPropertyItem prop_animdata_op_types[] = { static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_AnimDataOps event; short updateDeps = 0; @@ -998,7 +998,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); if (datalevel != TSE_ANIM_DATA) @@ -1015,14 +1015,14 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) /* clear active action - using standard rules */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case OUTLINER_ANIMOP_REFRESH_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ updateDeps = 1; break; @@ -1030,7 +1030,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) case OUTLINER_ANIMOP_CLEAR_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); ED_undo_push(C, "Clear Drivers"); updateDeps = 1; break; @@ -1084,40 +1084,40 @@ static EnumPropertyItem prop_data_op_types[] = { static int outliner_data_operation_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; int event; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - if (datalevel==TSE_POSE_CHANNEL) { - if (event>0) { + if (datalevel == TSE_POSE_CHANNEL) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "PoseChannel operation"); } } - else if (datalevel==TSE_BONE) { - if (event>0) { + else if (datalevel == TSE_BONE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "Bone operation"); } } - else if (datalevel==TSE_EBONE) { - if (event>0) { + else if (datalevel == TSE_EBONE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "EditBone operation"); } } - else if (datalevel==TSE_SEQUENCE) { - if (event>0) { + else if (datalevel == TSE_SEQUENCE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb); } } @@ -1151,14 +1151,14 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S { ReportList *reports = CTX_wm_reports(C); // XXX... - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; + TreeStoreElem *tselem = TREESTORE(te); /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - if ( outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) + if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; @@ -1177,16 +1177,16 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL); } else if (idlevel) { - if (idlevel==-1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); + if (idlevel == -1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { - if (idlevel==ID_GR) + if (idlevel == ID_GR) WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL); else WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); } } else if (datalevel) { - if (datalevel==-1) BKE_report(reports, RPT_WARNING, "Mixed selection"); + if (datalevel == -1) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { if (datalevel == TSE_ANIM_DATA) WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); @@ -1202,7 +1202,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) return 1; } @@ -1212,15 +1212,15 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 026132e1f16..099e210a658 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -82,50 +82,50 @@ /* ********************************************************* */ /* Defines */ -#define TS_CHUNK 128 +#define TS_CHUNK 128 /* ********************************************************* */ /* Persistent Data */ static void outliner_storage_cleanup(SpaceOops *soops) { - TreeStore *ts= soops->treestore; + TreeStore *ts = soops->treestore; if (ts) { TreeStoreElem *tselem; - int a, unused= 0; + int a, unused = 0; /* each element used once, for ID blocks with more users to have each a treestore */ - for (a=0, tselem= ts->data; ausedelem; a++, tselem++) tselem->used= 0; + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) tselem->used = 0; /* cleanup only after reading file or undo step, and always for * RNA datablocks view in order to save memory */ if (soops->storeflag & SO_TREESTORE_CLEANUP) { - for (a=0, tselem= ts->data; ausedelem; a++, tselem++) { - if (tselem->id==NULL) unused++; + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) { + if (tselem->id == NULL) unused++; } if (unused) { if (ts->usedelem == unused) { MEM_freeN(ts->data); - ts->data= NULL; - ts->usedelem= ts->totelem= 0; + ts->data = NULL; + ts->usedelem = ts->totelem = 0; } else { TreeStoreElem *tsnewar, *tsnew; - tsnew=tsnewar= MEM_mallocN((ts->usedelem-unused)*sizeof(TreeStoreElem), "new tselem"); - for (a=0, tselem= ts->data; ausedelem; a++, tselem++) { + tsnew = tsnewar = MEM_mallocN((ts->usedelem - unused) * sizeof(TreeStoreElem), "new tselem"); + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) { if (tselem->id) { - *tsnew= *tselem; + *tsnew = *tselem; tsnew++; } } MEM_freeN(ts->data); - ts->data= tsnewar; - ts->usedelem-= unused; - ts->totelem= ts->usedelem; + ts->data = tsnewar; + ts->usedelem -= unused; + ts->totelem = ts->usedelem; } } } @@ -139,45 +139,45 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty int a; /* case 1; no TreeStore */ - if (soops->treestore==NULL) { - soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); + if (soops->treestore == NULL) { + soops->treestore = MEM_callocN(sizeof(TreeStore), "treestore"); } - ts= soops->treestore; + ts = soops->treestore; /* check if 'te' is in treestore */ - tselem= ts->data; - for (a=0; ausedelem; a++, tselem++) { - if (tselem->id==id && tselem->used==0) { - if ((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { - te->store_index= a; - tselem->used= 1; + tselem = ts->data; + for (a = 0; a < ts->usedelem; a++, tselem++) { + if (tselem->id == id && tselem->used == 0) { + if ((type == 0 && tselem->type == 0) || (tselem->type == type && tselem->nr == nr)) { + te->store_index = a; + tselem->used = 1; return; } } } /* add 1 element to treestore */ - if (ts->usedelem==ts->totelem) { + if (ts->usedelem == ts->totelem) { TreeStoreElem *tsnew; - tsnew= MEM_mallocN((ts->totelem+TS_CHUNK)*sizeof(TreeStoreElem), "treestore data"); + tsnew = MEM_mallocN((ts->totelem + TS_CHUNK) * sizeof(TreeStoreElem), "treestore data"); if (ts->data) { - memcpy(tsnew, ts->data, ts->totelem*sizeof(TreeStoreElem)); + memcpy(tsnew, ts->data, ts->totelem * sizeof(TreeStoreElem)); MEM_freeN(ts->data); } - ts->data= tsnew; - ts->totelem+= TS_CHUNK; + ts->data = tsnew; + ts->totelem += TS_CHUNK; } - tselem= ts->data+ts->usedelem; + tselem = ts->data + ts->usedelem; - tselem->type= type; - if (type) tselem->nr= nr; // we're picky! :) - else tselem->nr= 0; - tselem->id= id; + tselem->type = type; + if (type) tselem->nr = nr; // we're picky! :) + else tselem->nr = 0; + tselem->id = id; tselem->used = 0; - tselem->flag= TSE_CLOSED; - te->store_index= ts->usedelem; + tselem->flag = TSE_CLOSED; + te->store_index = ts->usedelem; ts->usedelem++; } @@ -188,7 +188,7 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty void outliner_free_tree(ListBase *lb) { while (lb->first) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; outliner_free_tree(&te->subtree); BLI_remlink(lb, te); @@ -207,12 +207,12 @@ void outliner_cleanup_tree(SpaceOops *soops) /* Find ith item from the treestore */ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { - TreeElement *te= lb->first, *tes; + TreeElement *te = lb->first, *tes; while (te) { - if (te->store_index==store_index) return te; - tes= outliner_find_tree_element(&te->subtree, store_index); + if (te->store_index == store_index) return te; + tes = outliner_find_tree_element(&te->subtree, store_index); if (tes) return tes; - te= te->next; + te = te->next; } return NULL; } @@ -220,17 +220,17 @@ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) /* tse is not in the treestore, we use its contents to find a match */ TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) { - TreeStore *ts= soops->treestore; + TreeStore *ts = soops->treestore; TreeStoreElem *tselem; int a; - if (tse->id==NULL) return NULL; + if (tse->id == NULL) return NULL; /* check if 'tse' is in treestore */ - tselem= ts->data; - for (a=0; ausedelem; a++, tselem++) { - if ((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { - if (tselem->id==tse->id) { + tselem = ts->data; + for (a = 0; a < ts->usedelem; a++, tselem++) { + if ((tse->type == 0 && tselem->type == 0) || (tselem->type == tse->type && tselem->nr == tse->nr)) { + if (tselem->id == tse->id) { break; } } @@ -247,13 +247,13 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) TreeElement *te, *tes; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (tselem->type==0) { - if (tselem->id==id) return te; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (tselem->type == 0) { + if (tselem->id == id) return te; /* only deeper on scene or object */ - if ( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { - tes= outliner_find_id(soops, &te->subtree, id); + if (te->idcode == ID_OB || te->idcode == ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode == ID_GR)) { + tes = outliner_find_id(soops, &te->subtree, id); if (tes) return tes; } } @@ -265,12 +265,12 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) { TreeStoreElem *tselem; - te= te->parent; + te = te->parent; while (te) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==idcode) return tselem->id; - te= te->parent; + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == idcode) return tselem->id; + te = te->parent; } return NULL; } @@ -280,28 +280,28 @@ ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) /* Prototype, see functions below */ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index); + TreeElement *parent, short type, short index); /* -------------------------------------------------------- */ /* special handling of hierarchical non-lib data */ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, - TreeElement *parent, int *a) + TreeElement *parent, int *a) { - TreeElement *te= outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); + TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); (*a)++; - te->name= curBone->name; - te->directdata= curBone; + te->name = curBone->name; + te->directdata = curBone; - for (curBone= curBone->childbase.first; curBone; curBone=curBone->next) { + for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } } /* -------------------------------------------------------- */ -#define LOG2I(x) (int)(log(x)/M_LN2) +#define LOG2I(x) (int)(log(x) / M_LN2) static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) { @@ -311,82 +311,82 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc /* log stuff is to convert bitflags (powers of 2) to small integers, * in order to not overflow short tselem->nr */ - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); - te->name= "Combined"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); + te->name = "Combined"; + te->directdata = &srl->passflag; /* save cpu cycles, but we add the first to invoke an open/close triangle */ tselem = TREESTORE(tenla); if (tselem->flag & TSE_CLOSED) return; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); - te->name= "Z"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); - te->name= "Vector"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); - te->name= "Normal"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); - te->name= "UV"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); - te->name= "Mist"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); - te->name= "Index Object"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); - te->name= "Index Material"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); + te->name = "Z"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); - te->name= "Color"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); - te->name= "Diffuse"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); - te->name= "Specular"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); - te->name= "Shadow"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); - te->name= "AO"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); - te->name= "Reflection"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); - te->name= "Refraction"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); - te->name= "Indirect"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); + te->name = "Vector"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); - te->name= "Environment"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); + te->name = "Normal"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); - te->name= "Emit"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); + te->name = "UV"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); + te->name = "Mist"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); + te->name = "Index Object"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); + te->name = "Index Material"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); + te->name = "Color"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); + te->name = "Diffuse"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); + te->name = "Specular"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); + te->name = "Shadow"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); + te->name = "AO"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); + te->name = "Reflection"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); + te->name = "Refraction"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); + te->name = "Indirect"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); + te->name = "Environment"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); + te->name = "Emit"; + te->directdata = &srl->passflag; } #undef LOG2I @@ -394,14 +394,14 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te) { SceneRenderLayer *srl; - TreeElement *tenla= outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); int a; - tenla->name= "RenderLayers"; - for (a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { - TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); - tenlay->name= srl->name; - tenlay->directdata= &srl->passflag; + tenla->name = "RenderLayers"; + for (a = 0, srl = sce->r.layers.first; srl; srl = srl->next, a++) { + TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); + tenlay->name = srl->name; + tenlay->directdata = &srl->passflag; if (srl->light_override) outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); @@ -428,66 +428,66 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - if (ob->proxy && ob->id.lib==NULL) + if (ob->proxy && ob->id.lib == NULL) outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); if (ob->pose) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); - tenla->name= "Pose"; + tenla->name = "Pose"; /* channels undefined in editmode, but we want the 'tenla' pose icon itself */ if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { - int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ + int a = 0, const_index = 1000; /* ensure unique id for bone constraints */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); - ten->name= pchan->name; - ten->directdata= pchan; - pchan->temp= (void *)ten; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); + ten->name = pchan->name; + ten->directdata = pchan; + pchan->temp = (void *)ten; if (pchan->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten1; - TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); + TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); //char *str; - tenla1->name= "Constraints"; - for (con= pchan->constraints.first; con; con= con->next, const_index++) { - ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); + tenla1->name = "Constraints"; + for (con = pchan->constraints.first; con; con = con->next, const_index++) { + ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); #if 0 /* disabled as it needs to be reworked for recoded constraints system */ - target= get_constraint_target(con, &str); - if (str && str[0]) ten1->name= str; - else if (target) ten1->name= target->id.name+2; - else ten1->name= con->name; + target = get_constraint_target(con, &str); + if (str && str[0]) ten1->name = str; + else if (target) ten1->name = target->id.name + 2; + else ten1->name = con->name; #endif - ten1->name= con->name; - ten1->directdata= con; + ten1->name = con->name; + ten1->directdata = con; /* possible add all other types links? */ } } } /* make hierarchy */ - ten= tenla->subtree.first; + ten = tenla->subtree.first; while (ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - if (tselem->type==TSE_POSE_CHANNEL) { - pchan= (bPoseChannel *)ten->directdata; + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + if (tselem->type == TSE_POSE_CHANNEL) { + pchan = (bPoseChannel *)ten->directdata; if (pchan->parent) { BLI_remlink(&tenla->subtree, ten); - par= (TreeElement *)pchan->parent->temp; + par = (TreeElement *)pchan->parent->temp; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } } - ten= nten; + ten = nten; } } @@ -495,39 +495,39 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (ob->pose->agroups.first) { bActionGroup *agrp; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); - int a= 0; + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); + int a = 0; - tenla->name= "Bone Groups"; - for (agrp=ob->pose->agroups.first; agrp; agrp=agrp->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); - ten->name= agrp->name; - ten->directdata= agrp; + tenla->name = "Bone Groups"; + for (agrp = ob->pose->agroups.first; agrp; agrp = agrp->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); + ten->name = agrp->name; + ten->directdata = agrp; } } } - for (a=0; atotcol; a++) + for (a = 0; a < ob->totcol; a++) outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); if (ob->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); //char *str; - tenla->name= "Constraints"; - for (con=ob->constraints.first, a=0; con; con= con->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); + tenla->name = "Constraints"; + for (con = ob->constraints.first, a = 0; con; con = con->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); #if 0 /* disabled due to constraints system targets recode... code here needs review */ - target= get_constraint_target(con, &str); - if (str && str[0]) ten->name= str; - else if (target) ten->name= target->id.name+2; - else ten->name= con->name; + target = get_constraint_target(con, &str); + if (str && str[0]) ten->name = str; + else if (target) ten->name = target->id.name + 2; + else ten->name = con->name; #endif - ten->name= con->name; - ten->directdata= con; + ten->name = con->name; + ten->directdata = con; /* possible add all other types links? */ } } @@ -538,30 +538,30 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree int index; temod->name = "Modifiers"; - for (index=0, md=ob->modifiers.first; md; index++, md=md->next) { + for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) { TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index); - te->name= md->name; + te->name = md->name; te->directdata = md; - if (md->type==eModifierType_Lattice) { - outliner_add_element(soops, &te->subtree, ((LatticeModifierData*) md)->object, te, TSE_LINKED_OB, 0); + if (md->type == eModifierType_Lattice) { + outliner_add_element(soops, &te->subtree, ((LatticeModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Curve) { - outliner_add_element(soops, &te->subtree, ((CurveModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Curve) { + outliner_add_element(soops, &te->subtree, ((CurveModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Armature) { - outliner_add_element(soops, &te->subtree, ((ArmatureModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Armature) { + outliner_add_element(soops, &te->subtree, ((ArmatureModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Hook) { - outliner_add_element(soops, &te->subtree, ((HookModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Hook) { + outliner_add_element(soops, &te->subtree, ((HookModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_ParticleSystem) { + else if (md->type == eModifierType_ParticleSystem) { TreeElement *ten; - ParticleSystem *psys= ((ParticleSystemModifierData*) md)->psys; + ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys; ten = outliner_add_element(soops, &te->subtree, ob, te, TSE_LINKED_PSYS, 0); ten->directdata = psys; - ten->name = psys->part->id.name+2; + ten->name = psys->part->id.name + 2; } } } @@ -570,13 +570,13 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (ob->defbase.first) { bDeformGroup *defgroup; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); - tenla->name= "Vertex Groups"; - for (defgroup=ob->defbase.first, a=0; defgroup; defgroup=defgroup->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); - ten->name= defgroup->name; - ten->directdata= defgroup; + tenla->name = "Vertex Groups"; + for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); + ten->name = defgroup->name; + ten->directdata = defgroup; } } @@ -589,147 +589,147 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) { /* tuck pointer back in object, to construct hierarchy */ - if (GS(id->name)==ID_OB) id->newid= (ID *)te; + if (GS(id->name) == ID_OB) id->newid = (ID *)te; /* expand specific data always */ switch (GS(id->name)) { case ID_LI: { - te->name= ((Library *)id)->name; + te->name = ((Library *)id)->name; } - break; + break; case ID_SCE: { outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te); } - break; + break; case ID_OB: { outliner_add_object_contents(soops, te, tselem, (Object *)id); } - break; + break; case ID_ME: { - Mesh *me= (Mesh *)id; + Mesh *me = (Mesh *)id; int a; if (me->adt) outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); - for (a=0; atotcol; a++) + for (a = 0; a < me->totcol; a++) outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ } - break; + break; case ID_CU: { - Curve *cu= (Curve *)id; + Curve *cu = (Curve *)id; int a; if (cu->adt) outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - for (a=0; atotcol; a++) + for (a = 0; a < cu->totcol; a++) outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); } - break; + break; case ID_MB: { - MetaBall *mb= (MetaBall *)id; + MetaBall *mb = (MetaBall *)id; int a; if (mb->adt) outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); - for (a=0; atotcol; a++) + for (a = 0; a < mb->totcol; a++) outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); } - break; + break; case ID_MA: { - Material *ma= (Material *)id; + Material *ma = (Material *)id; int a; if (ma->adt) outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); - for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_TE: { - Tex *tex= (Tex *)id; + Tex *tex = (Tex *)id; if (tex->adt) outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); } - break; + break; case ID_CA: { - Camera *ca= (Camera *)id; + Camera *ca = (Camera *)id; if (ca->adt) outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); } - break; + break; case ID_LA: { - Lamp *la= (Lamp *)id; + Lamp *la = (Lamp *)id; int a; if (la->adt) outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); - for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_SPK: - { - Speaker *spk= (Speaker *)id; + { + Speaker *spk = (Speaker *)id; - if (spk->adt) - outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); - } - break; + if (spk->adt) + outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); + } + break; case ID_WO: { - World *wrld= (World *)id; + World *wrld = (World *)id; int a; if (wrld->adt) outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); - for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_KE: { - Key *key= (Key *)id; + Key *key = (Key *)id; if (key->adt) outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); } - break; + break; case ID_AC: { // XXX do we want to be exposing the F-Curves here? //bAction *act= (bAction *)id; } - break; + break; case ID_AR: { - bArmature *arm= (bArmature *)id; - int a= 0; + bArmature *arm = (bArmature *)id; + int a = 0; if (arm->adt) outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); @@ -738,115 +738,115 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor EditBone *ebone; TreeElement *ten; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next, a++) { - ten= outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); - ten->directdata= ebone; - ten->name= ebone->name; - ebone->temp= ten; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) { + ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); + ten->directdata = ebone; + ten->name = ebone->name; + ebone->temp = ten; } /* make hierarchy */ - ten= arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; + ten = arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; while (ten) { - TreeElement *nten= ten->next, *par; - ebone= (EditBone *)ten->directdata; + TreeElement *nten = ten->next, *par; + ebone = (EditBone *)ten->directdata; if (ebone->parent) { BLI_remlink(&te->subtree, ten); - par= ebone->parent->temp; + par = ebone->parent->temp; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } - ten= nten; + ten = nten; } } else { /* do not extend Armature when we have posemode */ - tselem= TREESTORE(te->parent); - if ( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); + tselem = TREESTORE(te->parent); + if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) ; else { Bone *curBone; - for (curBone=arm->bonebase.first; curBone; curBone=curBone->next) { + for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, &a); } } } } - break; + break; } } // TODO: this function needs to be split up! It's getting a bit too large... static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index) + TreeElement *parent, short type, short index) { TreeElement *te; TreeStoreElem *tselem; - ID *id= idv; + ID *id = idv; int a = 0; if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - id= ((PointerRNA*)idv)->id.data; - if (!id) id= ((PointerRNA*)idv)->data; + id = ((PointerRNA *)idv)->id.data; + if (!id) id = ((PointerRNA *)idv)->data; } - if (id==NULL) return NULL; + if (id == NULL) return NULL; - te= MEM_callocN(sizeof(TreeElement), "tree elem"); + te = MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ BLI_addtail(lb, te); /* add to the storage */ check_persistent(soops, te, id, type, index); - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* if we are searching for something expand to see child elements */ if (SEARCHING_OUTLINER(soops)) tselem->flag |= TSE_CHILDSEARCH; - te->parent= parent; - te->index= index; // for data arays - if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); - else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); - else if (type==TSE_ANIM_DATA); + te->parent = parent; + te->index = index; // for data arays + if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) ; + else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) ; + else if (type == TSE_ANIM_DATA) ; else { - te->name= id->name+2; // default, can be overridden by Library or non-ID data - te->idcode= GS(id->name); + te->name = id->name + 2; // default, can be overridden by Library or non-ID data + te->idcode = GS(id->name); } - if (type==0) { + if (type == 0) { /* ID datablock */ outliner_add_id_contents(soops, te, tselem, id); } - else if (type==TSE_ANIM_DATA) { + else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; - AnimData *adt= (AnimData *)iat->adt; + AnimData *adt = (AnimData *)iat->adt; /* this element's info */ - te->name= "Animation"; - te->directdata= adt; + te->name = "Animation"; + te->directdata = adt; /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); /* Drivers */ if (adt->drivers.first) { - TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); - ID *lastadded= NULL; + TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); + ID *lastadded = NULL; FCurve *fcu; - ted->name= "Drivers"; + ted->name = "Drivers"; - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { if (fcu->driver && fcu->driver->variables.first) { - ChannelDriver *driver= fcu->driver; + ChannelDriver *driver = fcu->driver; DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* loop over all targets used here */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); - lastadded= dtar->id; + lastadded = dtar->id; } } DRIVER_TARGETS_LOOPER_END @@ -857,29 +857,29 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* NLA Data */ if (adt->nla_tracks.first) { - TreeElement *tenla= outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); NlaTrack *nlt; - int a= 0; + int a = 0; - tenla->name= "NLA Tracks"; + tenla->name = "NLA Tracks"; - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { - TreeElement *tenlt= outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); NlaStrip *strip; TreeElement *ten; - int b= 0; + int b = 0; - tenlt->name= nlt->name; + tenlt->name = nlt->name; - for (strip=nlt->strips.first; strip; strip=strip->next, b++) { - ten= outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); - if (ten) ten->directdata= strip; + for (strip = nlt->strips.first; strip; strip = strip->next, b++) { + ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); + if (ten) ten->directdata = strip; } } } } - else if (type==TSE_SEQUENCE) { - Sequence *seq= (Sequence*) idv; + else if (type == TSE_SEQUENCE) { + Sequence *seq = (Sequence *) idv; Sequence *p; /* @@ -887,56 +887,56 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i * only check te->idcode if te->type is equal to zero, * so this is "safe". */ - te->idcode= seq->type; - te->directdata= seq; + te->idcode = seq->type; + te->directdata = seq; - if (seq->type<7) { + if (seq->type < 7) { /* * This work like the sequence. * If the sequence have a name (not default name) * show it, in other case put the filename. */ if (strcmp(seq->name, "SQ")) - te->name= seq->name; + te->name = seq->name; else { if ((seq->strip) && (seq->strip->stripdata)) - te->name= seq->strip->stripdata->name; + te->name = seq->strip->stripdata->name; else - te->name= "SQ None"; + te->name = "SQ None"; } - if (seq->type==SEQ_META) { - te->name= "Meta Strip"; - p= seq->seqbase.first; + if (seq->type == SEQ_META) { + te->name = "Meta Strip"; + p = seq->seqbase.first; while (p) { - outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; + outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + p = p->next; } } else - outliner_add_element(soops, &te->subtree, (void*)seq->strip, te, TSE_SEQ_STRIP, index); + outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index); } else - te->name= "Effect"; + te->name = "Effect"; } - else if (type==TSE_SEQ_STRIP) { - Strip *strip= (Strip *)idv; + else if (type == TSE_SEQ_STRIP) { + Strip *strip = (Strip *)idv; if (strip->dir) - te->name= strip->dir; + te->name = strip->dir; else - te->name= "Strip None"; - te->directdata= strip; + te->name = "Strip None"; + te->directdata = strip; } - else if (type==TSE_SEQUENCE_DUP) { - Sequence *seq= (Sequence*)idv; + else if (type == TSE_SEQUENCE_DUP) { + Sequence *seq = (Sequence *)idv; - te->idcode= seq->type; - te->directdata= seq; - te->name= seq->strip->stripdata->name; + te->idcode = seq->type; + te->directdata = seq; + te->name = seq->strip->stripdata->name; } else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; + PointerRNA pptr, propptr, *ptr = (PointerRNA *)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; int a, tot; @@ -944,22 +944,22 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* we do lazy build, for speed and to avoid infinite recusion */ if (ptr->data == NULL) { - te->name= "(empty)"; + te->name = "(empty)"; } else if (type == TSE_RNA_STRUCT) { /* struct */ - te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); + te->name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); if (te->name) te->flag |= TE_FREE_NAME; else - te->name= RNA_struct_ui_name(ptr->type); + te->name = RNA_struct_ui_name(ptr->type); /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; - iterprop= RNA_struct_iterator_property(ptr->type); - tot= RNA_property_collection_length(ptr, iterprop); + iterprop = RNA_struct_iterator_property(ptr->type); + tot = RNA_property_collection_length(ptr, iterprop); /* auto open these cases */ if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) @@ -967,57 +967,57 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i tselem->flag &= ~TSE_CLOSED; if (TSELEM_OPEN(tselem, soops)) { - for (a=0; asubtree, (void*)ptr, te, TSE_RNA_PROPERTY, a); + for (a = 0; a < tot; a++) + outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a); } else if (tot) te->flag |= TE_LAZY_CLOSED; - te->rnaptr= *ptr; + te->rnaptr = *ptr; } else if (type == TSE_RNA_PROPERTY) { /* property */ - iterprop= RNA_struct_iterator_property(ptr->type); + iterprop = RNA_struct_iterator_property(ptr->type); RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); - prop= propptr.data; - proptype= RNA_property_type(prop); + prop = propptr.data; + proptype = RNA_property_type(prop); - te->name= RNA_property_ui_name(prop); - te->directdata= prop; - te->rnaptr= *ptr; + te->name = RNA_property_ui_name(prop); + te->directdata = prop; + te->rnaptr = *ptr; /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; if (proptype == PROP_POINTER) { - pptr= RNA_property_pointer_get(ptr, prop); + pptr = RNA_property_pointer_get(ptr, prop); if (pptr.data) { if (TSELEM_OPEN(tselem, soops)) - outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); + outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1); else te->flag |= TE_LAZY_CLOSED; } } else if (proptype == PROP_COLLECTION) { - tot= RNA_property_collection_length(ptr, prop); + tot = RNA_property_collection_length(ptr, prop); if (TSELEM_OPEN(tselem, soops)) { - for (a=0; asubtree, (void*)&pptr, te, TSE_RNA_STRUCT, a); + outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a); } } else if (tot) te->flag |= TE_LAZY_CLOSED; } else if (ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(ptr, prop); + tot = RNA_property_array_length(ptr, prop); if (TSELEM_OPEN(tselem, soops)) { - for (a=0; asubtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a); + for (a = 0; a < tot; a++) + outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a); } else if (tot) te->flag |= TE_LAZY_CLOSED; @@ -1026,51 +1026,51 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else if (type == TSE_RNA_ARRAY_ELEM) { char c; - prop= parent->directdata; + prop = parent->directdata; - te->directdata= prop; - te->rnaptr= *ptr; - te->index= index; + te->directdata = prop; + te->rnaptr = *ptr; + te->index = index; - c= RNA_property_array_item_char(prop, index); + c = RNA_property_array_item_char(prop, index); - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName"); if (c) sprintf((char *)te->name, " %c", c); - else sprintf((char *)te->name, " %d", index+1); + else sprintf((char *)te->name, " %d", index + 1); te->flag |= TE_FREE_NAME; } } else if (type == TSE_KEYMAP) { - wmKeyMap *km= (wmKeyMap *)idv; + wmKeyMap *km = (wmKeyMap *)idv; wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; - te->directdata= idv; - te->name= km->idname; + te->directdata = idv; + te->name = km->idname; if (TSELEM_OPEN(tselem, soops)) { - a= 0; + a = 0; for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { - const char *key= WM_key_event_string(kmi->type); + const char *key = WM_key_event_string(kmi->type); if (key[0]) { - wmOperatorType *ot= NULL; + wmOperatorType *ot = NULL; - if (kmi->propvalue); - else ot= WM_operatortype_find(kmi->idname, 0); + if (kmi->propvalue) ; + else ot = WM_operatortype_find(kmi->idname, 0); if (ot || kmi->propvalue) { - TreeElement *ten= outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); + TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); - ten->directdata= kmi; + ten->directdata = kmi; if (kmi->propvalue) { - ten->name= "Modal map, not yet"; + ten->name = "Modal map, not yet"; } else { WM_operator_py_idname(opname, ot->idname); - ten->name= BLI_strdup(opname); + ten->name = BLI_strdup(opname); ten->flag |= TE_FREE_NAME; } } @@ -1099,28 +1099,28 @@ static int need_add_seq_dup(Sequence *seq) * First check backward, if we found a duplicate * sequence before this, don't need it, just return. */ - p= seq->prev; + p = seq->prev; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->prev; + p = p->prev; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(2); - p= p->prev; + p = p->prev; } - p= seq->next; + p = seq->next; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(0); - p= p->next; + p = p->next; } return(1); } @@ -1130,16 +1130,16 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t /* TreeElement *ch; */ /* UNUSED */ Sequence *p; - p= seq; + p = seq; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; + /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + p = p->next; } } @@ -1156,22 +1156,22 @@ static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) /* build hierarchy */ // XXX also, set extents here... - te= lb->first; + te = lb->first; while (te) { - ten= te->next; - tselem= TREESTORE(te); + ten = te->next; + tselem = TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; + if (tselem->type == 0 && te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); - tep= (TreeElement *)ob->parent->id.newid; + tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); // set correct parent pointers - for (te=tep->subtree.first; te; te= te->next) te->parent= tep; + for (te = tep->subtree.first; te; te = te->next) te->parent = tep; } } - te= ten; + te = ten; } } @@ -1187,20 +1187,20 @@ typedef struct tTreeSort { /* alphabetical comparator */ static int treesort_alpha(const void *v1, const void *v2) { - const tTreeSort *x1= v1, *x2= v2; + const tTreeSort *x1 = v1, *x2 = v2; int comp; /* first put objects last (hierarchy) */ - comp= (x1->idcode==ID_OB); - if (x2->idcode==ID_OB) comp+=2; + comp = (x1->idcode == ID_OB); + if (x2->idcode == ID_OB) comp += 2; - if (comp==1) return 1; - else if (comp==2) return -1; - else if (comp==3) { - comp= strcmp(x1->name, x2->name); + if (comp == 1) return 1; + else if (comp == 2) return -1; + else if (comp == 3) { + comp = strcmp(x1->name, x2->name); - if ( comp>0 ) return 1; - else if ( comp<0) return -1; + if (comp > 0) return 1; + else if (comp < 0) return -1; return 0; } return 0; @@ -1210,23 +1210,23 @@ static int treesort_alpha(const void *v1, const void *v2) #if 0 static int treesort_obtype_alpha(const void *v1, const void *v2) { - const tTreeSort *x1= v1, *x2= v2; + const tTreeSort *x1 = v1, *x2 = v2; /* first put objects last (hierarchy) */ - if (x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; - else if (x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; + if (x1->idcode == ID_OB && x2->idcode != ID_OB) return 1; + else if (x2->idcode == ID_OB && x1->idcode != ID_OB) return -1; else { /* 2nd we check ob type */ - if (x1->idcode==ID_OB && x2->idcode==ID_OB) { + if (x1->idcode == ID_OB && x2->idcode == ID_OB) { if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; else if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; else return 0; } else { - int comp= strcmp(x1->name, x2->name); + int comp = strcmp(x1->name, x2->name); - if ( comp>0 ) return 1; - else if ( comp<0) return -1; + if (comp > 0) return 1; + else if (comp < 0) return -1; return 0; } } @@ -1238,40 +1238,40 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; - int totelem=0; + int totelem = 0; - te= lb->last; - if (te==NULL) return; - tselem= TREESTORE(te); + te = lb->last; + if (te == NULL) return; + tselem = TREESTORE(te); /* sorting rules; only object lists or deformgroups */ - if ( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { + if ( (tselem->type == TSE_DEFGROUP) || (tselem->type == 0 && te->idcode == ID_OB)) { /* count first */ - for (te= lb->first; te; te= te->next) totelem++; + for (te = lb->first; te; te = te->next) totelem++; - if (totelem>1) { - tTreeSort *tear= MEM_mallocN(totelem*sizeof(tTreeSort), "tree sort array"); - tTreeSort *tp=tear; - int skip= 0; - - for (te= lb->first; te; te= te->next, tp++) { - tselem= TREESTORE(te); - tp->te= te; - tp->name= te->name; - tp->idcode= te->idcode; - if (tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // don't sort this - tp->id= tselem->id; + if (totelem > 1) { + tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); + tTreeSort *tp = tear; + int skip = 0; + + for (te = lb->first; te; te = te->next, tp++) { + tselem = TREESTORE(te); + tp->te = te; + tp->name = te->name; + tp->idcode = te->idcode; + if (tselem->type && tselem->type != TSE_DEFGROUP) tp->idcode = 0; // don't sort this + tp->id = tselem->id; } /* keep beginning of list */ - for (tp= tear, skip=0; skipidcode) break; - if (skipfirst=lb->last= NULL; - tp= tear; + lb->first = lb->last = NULL; + tp = tear; while (totelem--) { BLI_addtail(lb, tp->te); tp++; @@ -1280,7 +1280,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) } } - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { outliner_sort(soops, &te->subtree); } } @@ -1290,36 +1290,36 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) static int outliner_filter_has_name(TreeElement *te, const char *name, int flags) { #if 0 - int found= 0; + int found = 0; /* determine if match */ if (flags & SO_FIND_CASE_SENSITIVE) { if (flags & SO_FIND_COMPLETE) - found= strcmp(te->name, name) == 0; + found = strcmp(te->name, name) == 0; else - found= strstr(te->name, name) != NULL; + found = strstr(te->name, name) != NULL; } else { if (flags & SO_FIND_COMPLETE) - found= BLI_strcasecmp(te->name, name) == 0; + found = BLI_strcasecmp(te->name, name) == 0; else - found= BLI_strcasestr(te->name, name) != NULL; + found = BLI_strcasestr(te->name, name) != NULL; } #else - int fn_flag= 0; - int found= 0; + int fn_flag = 0; + int found = 0; if ((flags & SO_FIND_CASE_SENSITIVE) == 0) fn_flag |= FNM_CASEFOLD; if (flags & SO_FIND_COMPLETE) { - found= fnmatch(name, te->name, fn_flag)==0; + found = fnmatch(name, te->name, fn_flag) == 0; } else { char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; BLI_snprintf(fn_name, sizeof(fn_name), "*%s*", name); - found= fnmatch(fn_name, te->name, fn_flag)==0; + found = fnmatch(fn_name, te->name, fn_flag) == 0; } return found; #endif @@ -1333,25 +1333,25 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) /* although we don't have any search string, we return TRUE * since the entire tree is ok then... */ - if (soops->search_string[0]==0) + if (soops->search_string[0] == 0) return 1; - for (te= lb->first; te; te= ten) { - ten= te->next; + for (te = lb->first; te; te = ten) { + ten = te->next; - if (0==outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { + if (0 == outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { /* item isn't something we're looking for, but... - * - if the subtree is expanded, check if there are any matches that can be easily found + * - if the subtree is expanded, check if there are any matches that can be easily found * so that searching for "cu" in the default scene will still match the Cube * - otherwise, we can't see within the subtree and the item doesn't match, * so these can be safely ignored (i.e. the subtree can get freed) */ - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* flag as not a found item */ tselem->flag &= ~TSE_SEARCHMATCH; - if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree)==0) { + if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree) == 0) { outliner_free_tree(&te->subtree); BLI_remlink(lb, te); @@ -1360,7 +1360,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) } } else { - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* flag as a found item - we can then highlight it */ tselem->flag |= TSE_SEARCHMATCH; @@ -1383,14 +1383,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) { Base *base; Object *ob; - TreeElement *te=NULL, *ten; + TreeElement *te = NULL, *ten; TreeStoreElem *tselem; - int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */ + int show_opened = (soops->treestore == NULL); /* on first view, we open scenes */ /* Are we looking for something - we want to tag parents to filter child matches * - NOT in datablocks view - searching all datablocks takes way too long to be useful * - this variable is only set once per tree build */ - if (soops->search_string[0]!=0 && soops->outlinevis!=SO_DATABLOCKS) + if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATABLOCKS) soops->search_flags |= SO_SEARCH_RECURSIVE; else soops->search_flags &= ~SO_SEARCH_RECURSIVE; @@ -1402,64 +1402,64 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) outliner_storage_cleanup(soops); /* clear ob id.new flags */ - for (ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; + for (ob = mainvar->object.first; ob; ob = ob->id.next) ob->id.newid = NULL; /* options */ if (soops->outlinevis == SO_LIBRARIES) { Library *lib; - for (lib= mainvar->library.first; lib; lib= lib->id.next) { - ten= outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); - lib->id.newid= (ID *)ten; + for (lib = mainvar->library.first; lib; lib = lib->id.next) { + ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); + lib->id.newid = (ID *)ten; } /* make hierarchy */ - ten= soops->tree.first; + ten = soops->tree.first; while (ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - lib= (Library *)tselem->id; + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + lib = (Library *)tselem->id; if (lib->parent) { BLI_remlink(&soops->tree, ten); - par= (TreeElement *)lib->parent->id.newid; + par = (TreeElement *)lib->parent->id.newid; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } - ten= nten; + ten = nten; } /* restore newid pointers */ - for (lib= mainvar->library.first; lib; lib= lib->id.next) - lib->id.newid= NULL; + for (lib = mainvar->library.first; lib; lib = lib->id.next) + lib->id.newid = NULL; } else if (soops->outlinevis == SO_ALL_SCENES) { Scene *sce; - for (sce= mainvar->scene.first; sce; sce= sce->id.next) { - te= outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); - tselem= TREESTORE(te); - if (sce==scene && show_opened) + for (sce = mainvar->scene.first; sce; sce = sce->id.next) { + te = outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); + tselem = TREESTORE(te); + if (sce == scene && show_opened) tselem->flag &= ~TSE_CLOSED; - for (base= sce->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); - ten->directdata= base; + for (base = sce->base.first; base; base = base->next) { + ten = outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); + ten->directdata = base; } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for (base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; + for (base = sce->base.first; base; base = base->next) base->object->id.newid = NULL; } } else if (soops->outlinevis == SO_CUR_SCENE) { outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - for (base= scene->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + for (base = scene->base.first; base; base = base->next) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } outliner_make_hierarchy(soops, &soops->tree); } else if (soops->outlinevis == SO_VISIBLE) { - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & scene->lay) outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); } @@ -1469,102 +1469,102 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) Group *group; GroupObject *go; - for (group= mainvar->group.first; group; group= group->id.next) { + for (group = mainvar->group.first; group; group = group->id.next) { if (group->gobject.first) { - te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); + te = outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - for (go= group->gobject.first; go; go= go->next) { - ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); - ten->directdata= NULL; /* eh, why? */ + for (go = group->gobject.first; go; go = go->next) { + ten = outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); + ten->directdata = NULL; /* eh, why? */ } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for (go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; + for (go = group->gobject.first; go; go = go->next) go->ob->id.newid = NULL; } } } else if (soops->outlinevis == SO_SAME_TYPE) { - Object *ob= OBACT; + Object *ob = OBACT; if (ob) { - for (base= scene->base.first; base; base= base->next) { - if (base->object->type==ob->type) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + for (base = scene->base.first; base; base = base->next) { + if (base->object->type == ob->type) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } } outliner_make_hierarchy(soops, &soops->tree); } } else if (soops->outlinevis == SO_SELECTED) { - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & scene->lay) { - if (base==BASACT || (base->flag & SELECT)) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + if (base == BASACT || (base->flag & SELECT)) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } } } outliner_make_hierarchy(soops, &soops->tree); } - else if (soops->outlinevis==SO_SEQUENCE) { + else if (soops->outlinevis == SO_SEQUENCE) { Sequence *seq; - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = seq_give_editing(scene, FALSE); int op; - if (ed==NULL) + if (ed == NULL) return; - seq= ed->seqbasep->first; + seq = ed->seqbasep->first; if (!seq) return; while (seq) { - op= need_add_seq_dup(seq); - if (op==1) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE, 0); + op = need_add_seq_dup(seq); + if (op == 1) { + /* ten= */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0); } - else if (op==0) { - ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE_DUP, 0); + else if (op == 0) { + ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0); outliner_add_seq_dup(soops, seq, ten, 0); } - seq= seq->next; + seq = seq->next; } } - else if (soops->outlinevis==SO_DATABLOCKS) { + else if (soops->outlinevis == SO_DATABLOCKS) { PointerRNA mainptr; RNA_main_pointer_create(mainvar, &mainptr); - ten= outliner_add_element(soops, &soops->tree, (void*)&mainptr, NULL, TSE_RNA_STRUCT, -1); + ten = outliner_add_element(soops, &soops->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1); if (show_opened) { - tselem= TREESTORE(ten); + tselem = TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis==SO_USERDEF) { + else if (soops->outlinevis == SO_USERDEF) { PointerRNA userdefptr; RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &userdefptr); - ten= outliner_add_element(soops, &soops->tree, (void*)&userdefptr, NULL, TSE_RNA_STRUCT, -1); + ten = outliner_add_element(soops, &soops->tree, (void *)&userdefptr, NULL, TSE_RNA_STRUCT, -1); if (show_opened) { - tselem= TREESTORE(ten); + tselem = TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis==SO_KEYMAP) { - wmWindowManager *wm= mainvar->wm.first; + else if (soops->outlinevis == SO_KEYMAP) { + wmWindowManager *wm = mainvar->wm.first; wmKeyMap *km; - for (km= wm->defaultconf->keymaps.first; km; km= km->next) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); + for (km = wm->defaultconf->keymaps.first; km; km = km->next) { + /* ten= */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); } } else { - ten= outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); - if (ten) ten->directdata= BASACT; + ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); + if (ten) ten->directdata = BASACT; } outliner_sort(soops, &soops->tree); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index c2a3affa1b6..3110ff3e29e 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -77,20 +77,20 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te= NULL; + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if ( GS(id->name) == ID_OB ) { + if (GS(id->name) == ID_OB) { /* Ensure item under cursor is valid drop target */ /* Find object hovered over */ - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { TreeElement *te_valid; - te_valid= outliner_dropzone_parent(C, event, te, fmval); + te_valid = outliner_dropzone_parent(C, event, te, fmval); if (te_valid) return 1; } } @@ -102,30 +102,30 @@ static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "child", id->name+2); + RNA_string_set(drop->ptr, "child", id->name + 2); } static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te= NULL; + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if ( GS(id->name) == ID_OB ) { + if (GS(id->name) == ID_OB) { //TODO: Check if no parent? /* Ensure location under cursor is valid dropzone */ - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; } /* Check if mouse cursor is below the tree */ - te= soops->tree.last; - while (((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { - te= te->subtree.last; + te = soops->tree.last; + while (((te->flag & TE_LAZY_CLOSED) == 0) && (te->subtree.last)) { + te = te->subtree.last; } if (fmval[1] < te->ys) return 1; } @@ -136,7 +136,7 @@ static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "dragged_obj", id->name+2); + RNA_string_set(drop->ptr, "dragged_obj", id->name + 2); /* Set to simple parent clear type. Avoid menus for drag and drop if possible. * If desired, user can toggle the different "Clear Parent" types in the operator @@ -155,7 +155,7 @@ static void outliner_dropboxes(void) static void outliner_main_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear */ @@ -168,7 +168,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -234,11 +234,11 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) /* For updating lamp icons, when changing lamp type */ if (wmn->data == ND_LIGHTING_DRAW) ED_region_tag_redraw(ar); - break; + break; case NC_SPACE: if (wmn->data == ND_SPACE_OUTLINER) ED_region_tag_redraw(ar); - break; + break; case NC_ID: if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); @@ -269,7 +269,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case ND_ANIMCHAN: - if (wmn->action==NA_SELECTED) + if (wmn->action == NA_SELECTED) ED_region_tag_redraw(ar); break; } @@ -318,35 +318,35 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) ARegion *ar; SpaceOops *soutliner; - soutliner= MEM_callocN(sizeof(SpaceOops), "initoutliner"); - soutliner->spacetype= SPACE_OUTLINER; + soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner"); + soutliner->spacetype = SPACE_OUTLINER; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for outliner"); + ar = MEM_callocN(sizeof(ARegion), "header for outliner"); BLI_addtail(&soutliner->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for outliner"); + ar = MEM_callocN(sizeof(ARegion), "main area for outliner"); BLI_addtail(&soutliner->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + 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); - ar->v2d.keeptot= V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + 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); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; - return (SpaceLink*)soutliner; + return (SpaceLink *)soutliner; } /* not spacelink itself */ static void outliner_free(SpaceLink *sl) { - SpaceOops *soutliner= (SpaceOops*)sl; + SpaceOops *soutliner = (SpaceOops *)sl; outliner_free_tree(&soutliner->tree); if (soutliner->treestore) { @@ -364,11 +364,11 @@ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *outliner_duplicate(SpaceLink *sl) { - SpaceOops *soutliner= (SpaceOops *)sl; - SpaceOops *soutlinern= MEM_dupallocN(soutliner); + SpaceOops *soutliner = (SpaceOops *)sl; + SpaceOops *soutlinern = MEM_dupallocN(soutliner); - soutlinern->tree.first= soutlinern->tree.last= NULL; - soutlinern->treestore= NULL; + soutlinern->tree.first = soutlinern->tree.last = NULL; + soutlinern->treestore = NULL; return (SpaceLink *)soutlinern; } @@ -376,41 +376,41 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) /* only called once, from space_api/spacetypes.c */ void ED_spacetype_outliner(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - st->spaceid= SPACE_OUTLINER; + st->spaceid = SPACE_OUTLINER; strncpy(st->name, "Outliner", BKE_ST_MAXNAME); - st->new= outliner_new; - st->free= outliner_free; - st->init= outliner_init; - st->duplicate= outliner_duplicate; - st->operatortypes= outliner_operatortypes; - st->keymap= outliner_keymap; - st->dropboxes= outliner_dropboxes; + st->new = outliner_new; + st->free = outliner_free; + st->init = outliner_init; + st->duplicate = outliner_duplicate; + st->operatortypes = outliner_operatortypes; + st->keymap = outliner_keymap; + st->dropboxes = outliner_dropboxes; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= outliner_main_area_init; - art->draw= outliner_main_area_draw; - art->free= outliner_main_area_free; - art->listener= outliner_main_area_listener; + art->init = outliner_main_area_init; + art->draw = outliner_main_area_draw; + art->free = outliner_main_area_free; + art->listener = outliner_main_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= outliner_header_area_init; - art->draw= outliner_header_area_draw; - art->free= outliner_header_area_free; - art->listener= outliner_header_area_listener; + art->init = outliner_header_area_init; + art->draw = outliner_header_area_draw; + art->free = outliner_header_area_free; + art->listener = outliner_header_area_listener; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); From 353ef9541a37faa009e62a2969fc96d160260c6b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 May 2012 18:07:34 +0000 Subject: [PATCH 133/143] fix [#31347] solidify modifier > even thickness parameter weired --- .../blender/modifiers/intern/MOD_solidify.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 163c3979bfe..b45304a315f 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -451,8 +451,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* same as EM_solidify() in editmesh_lib.c */ float *vert_angles = MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */ float *vert_accum = vert_angles + numVerts; - float *face_angles = NULL; - BLI_array_staticdeclare(face_angles, 16); /* BM_NGON_STACK_SIZE */ int j, vidx; face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL); @@ -473,28 +471,28 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mesh_calc_poly_normal(mp, &mloop[mp->loopstart], mvert, face_nors[i]); /* just added, calc the normal */ - BLI_array_empty(face_angles); - BLI_array_reserve(face_angles, mp->totloop); for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { MLoop *ml_prev = ME_POLY_LOOP_PREV(mloop, mp, j); MLoop *ml_next = ME_POLY_LOOP_NEXT(mloop, mp, j); float e1[3], e2[3]; + float angle; + /* TODO - we could speed this up by _not_ normalizing both verts each time + * and always re-usingthe last vector. */ 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); - face_angles[j] = (float)M_PI - angle_v3v3(e1, e2); - } - - for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { + + angle = (float)M_PI - angle_v3v3(e1, e2); + if (angle < FLT_EPSILON) { + angle = FLT_EPSILON; + } + vidx = ml->v; - vert_accum[vidx] += face_angles[j]; - vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * - face_angles[j]; + vert_accum[vidx] += angle; + vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle; } } - - BLI_array_free(face_angles); /* vertex group support */ if (dvert) { From 98ba7dfecf454d8536ef63d8a5bd31c2e687a62e Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 7 May 2012 18:09:59 +0000 Subject: [PATCH 134/143] Collada: patch #31331: Implementation of 'Apply Modifiers' --- source/blender/collada/ExportSettings.h | 1 + source/blender/collada/GeometryExporter.cpp | 46 ++++++++++++++++--- source/blender/collada/GeometryExporter.h | 3 ++ source/blender/collada/collada.cpp | 9 ++-- source/blender/collada/collada.h | 2 +- .../blender/makesrna/intern/rna_scene_api.c | 7 +-- .../windowmanager/intern/wm_operators.c | 15 ++++-- 7 files changed, 63 insertions(+), 20 deletions(-) diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 80e20acbe48..41fa7e1ed38 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -31,6 +31,7 @@ struct ExportSettings { public: bool selected; + bool apply_modifiers; bool second_life; char *filepath; }; diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 8e4fa057daf..8c7bff285eb 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -36,10 +36,18 @@ #include "GeometryExporter.h" #include "DNA_meshdata_types.h" + +extern "C" { + #include "BKE_DerivedMesh.h" + #include "BKE_main.h" + #include "BKE_global.h" + #include "BKE_library.h" +} + + #include "BKE_customdata.h" #include "BKE_material.h" #include "BKE_mesh.h" - #include "collada_internal.h" // TODO: optimize UV sets by making indexed list with duplicates removed @@ -57,6 +65,25 @@ void GeometryExporter::exportGeom(Scene *sce) closeLibrary(); } +Mesh * GeometryExporter::get_mesh(Object *ob, int apply_modifiers) +{ + Mesh *tmpmesh; + if (!apply_modifiers) + { + tmpmesh = (Mesh*)ob->data; + } + else + { + CustomDataMask mask = CD_MASK_MESH; + DerivedMesh *dm = mesh_create_derived_view(mScene, ob, mask); + tmpmesh = BKE_mesh_add("ColladaMesh"); // name is not important here + DM_to_mesh(dm, tmpmesh, ob); + dm->release(dm); + BKE_mesh_tessface_ensure(tmpmesh); + } + return tmpmesh; +} + void GeometryExporter::operator()(Object *ob) { // XXX don't use DerivedMesh, Mesh instead? @@ -64,8 +91,8 @@ void GeometryExporter::operator()(Object *ob) #if 0 DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH); #endif - Mesh *me = (Mesh*)ob->data; - BKE_mesh_tessface_ensure(me); + + Mesh *me = get_mesh(ob, this->export_settings->apply_modifiers); std::string geom_id = get_geometry_id(ob); std::string geom_name = id_name(ob->data); @@ -110,11 +137,11 @@ void GeometryExporter::operator()(Object *ob) // XXX slow if (ob->totcol) { for (int a = 0; a < ob->totcol; a++) { - createPolylist(a, has_uvs, has_color, ob, geom_id, norind); + createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind); } } else { - createPolylist(0, has_uvs, has_color, ob, geom_id, norind); + createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } closeMesh(); @@ -124,7 +151,12 @@ void GeometryExporter::operator()(Object *ob) } closeGeometry(); - + + if (this->export_settings->apply_modifiers) + { + BKE_libblock_free_us(&(G.main->mesh), me); + } + #if 0 dm->release(dm); #endif @@ -135,10 +167,10 @@ void GeometryExporter::createPolylist(short material_index, bool has_uvs, bool has_color, Object *ob, + Mesh *me, std::string& geom_id, std::vector& norind) { - Mesh *me = (Mesh*)ob->data; MFace *mfaces = me->mface; int totfaces = me->totface; diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 5d79fabb713..55dc179e5e2 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -69,6 +69,7 @@ public: bool has_uvs, bool has_color, Object *ob, + Mesh *me, std::string& geom_id, std::vector& norind); @@ -98,6 +99,8 @@ private: std::set exportedGeometry; const ExportSettings *export_settings; + + Mesh * get_mesh(Object *ob, int apply_modifiers); }; struct GeometryFunctor { diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 70bf0556b5b..ae024ec52a7 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -49,13 +49,14 @@ extern "C" return 0; } - int collada_export(Scene *sce, const char *filepath, int selected, int second_life) + int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life) { ExportSettings export_settings; - export_settings.selected = selected != 0; - export_settings.second_life = second_life != 0; - export_settings.filepath = (char *)filepath; + export_settings.selected = selected != 0; + export_settings.apply_modifiers = apply_modifiers != 0; + export_settings.second_life = second_life != 0; + export_settings.filepath = (char *)filepath; /* annoying, collada crashes if file cant be created! [#27162] */ if (!BLI_exists(filepath)) { diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index f8afc797447..f335796f799 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -37,7 +37,7 @@ extern "C" { * both return 1 on success, 0 on error */ int collada_import(bContext *C, const char *filepath); - int collada_export(Scene *sce, const char *filepath, int selected, int second_life); + int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life); #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index e3bb6e7b58a..ca01d61f630 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -85,9 +85,9 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ #include "../../collada/collada.h" -static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int second_life) +static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int apply_modifiers, int second_life) { - collada_export(scene, filepath, selected, second_life); + collada_export(scene, filepath, selected, apply_modifiers, second_life); } #endif @@ -115,7 +115,8 @@ void RNA_api_scene(StructRNA *srna) parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file"); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ - parm = RNA_def_boolean(func, "selected", 0, "Export only selected", "Export only selected elements"); + parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements"); + parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)"); parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); RNA_def_function_ui_description(func, "Export to collada file"); #endif diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 1a9a5ff2cb6..27c4a38c131 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2154,7 +2154,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED static int wm_collada_export_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; - int selected, second_life; + int selected, second_life, apply_modifiers; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -2162,13 +2162,16 @@ 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"); + + /* Options panel */ + selected = RNA_boolean_get(op->ptr, "selected"); + second_life = RNA_boolean_get(op->ptr, "second_life"); + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); /* 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)) { + if (collada_export(CTX_data_scene(C), filename, selected, apply_modifiers, second_life)) { return OPERATOR_FINISHED; } else { @@ -2187,8 +2190,10 @@ static void WM_OT_collada_export(wmOperatorType *ot) ot->poll = WM_operator_winactive; WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "selected", 0, "Export only selected", + RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", "Export only selected elements"); + RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", + "Apply modifiers (Preview Resolution)"); RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); } From a314b70930914c79173856b178ea03aa1cfab1af Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 May 2012 18:12:31 +0000 Subject: [PATCH 135/143] fix [#31354] Segfault with "Extrude Individual Faces and Move" --- source/blender/editors/mesh/editmesh_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index af3d7f16927..2f317ed87c2 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -616,7 +616,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); + EDBM_update_generic(C, em, TRUE); return OPERATOR_FINISHED; } From e5faeab5d677b473ca8dac059ca59b8ebdb03ce4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 May 2012 18:30:04 +0000 Subject: [PATCH 136/143] style cleanup: avi --- source/blender/avi/intern/avi.c | 681 ++++++++++++++-------------- source/blender/avi/intern/avirgb.c | 84 ++-- source/blender/avi/intern/codecs.c | 108 ++--- source/blender/avi/intern/endian.c | 242 +++++----- source/blender/avi/intern/mjpeg.c | 246 +++++----- source/blender/avi/intern/options.c | 132 +++--- source/blender/avi/intern/rgb32.c | 34 +- 7 files changed, 774 insertions(+), 753 deletions(-) diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 17c29e2a834..c4c4e65a7be 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -51,7 +51,7 @@ #include "endian.h" -static int AVI_DEBUG=0; +static int AVI_DEBUG = 0; static char DEBUG_FCC[4]; #define DEBUG_PRINT(x) if (AVI_DEBUG) { printf("AVI DEBUG: " x); } (void)0 @@ -64,7 +64,7 @@ char *tcc_to_char(unsigned int tcc); /* implemetation */ -unsigned int GET_FCC (FILE *fp) +unsigned int GET_FCC(FILE *fp) { unsigned char tmp[4]; @@ -73,10 +73,10 @@ unsigned int GET_FCC (FILE *fp) tmp[2] = getc(fp); tmp[3] = getc(fp); - return FCC (tmp); + return FCC(tmp); } -unsigned int GET_TCC (FILE *fp) +unsigned int GET_TCC(FILE *fp) { char tmp[5]; @@ -85,25 +85,25 @@ unsigned int GET_TCC (FILE *fp) tmp[2] = 0; tmp[3] = 0; - return FCC (tmp); + return FCC(tmp); } char *fcc_to_char(unsigned int fcc) { - DEBUG_FCC[0]= (fcc)&127; - DEBUG_FCC[1]= (fcc>>8)&127; - DEBUG_FCC[2]= (fcc>>16)&127; - DEBUG_FCC[3]= (fcc>>24)&127; + DEBUG_FCC[0] = (fcc) & 127; + DEBUG_FCC[1] = (fcc >> 8) & 127; + DEBUG_FCC[2] = (fcc >> 16) & 127; + DEBUG_FCC[3] = (fcc >> 24) & 127; return DEBUG_FCC; } char *tcc_to_char(unsigned int tcc) { - DEBUG_FCC[0]= (tcc)&127; - DEBUG_FCC[1]= (tcc>>8)&127; - DEBUG_FCC[2]= 0; - DEBUG_FCC[3]= 0; + DEBUG_FCC[0] = (tcc) & 127; + DEBUG_FCC[1] = (tcc >> 8) & 127; + DEBUG_FCC[2] = 0; + DEBUG_FCC[3] = 0; return DEBUG_FCC; } @@ -115,7 +115,7 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num) if (movie == NULL) return -AVI_ERROR_OPTION; - for (cur_stream=0; cur_stream < movie->header->Streams; cur_stream++) { + for (cur_stream = 0; cur_stream < movie->header->Streams; cur_stream++) { if (movie->streams[cur_stream].sh.Type == avist_type) { if (stream_num == 0) return cur_stream; @@ -127,28 +127,28 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num) return -AVI_ERROR_FOUND; } -static int fcc_get_stream (int fcc) +static int fcc_get_stream(int fcc) { char fccs[4]; fccs[0] = fcc; - fccs[1] = fcc>>8; - fccs[2] = fcc>>16; - fccs[3] = fcc>>24; + fccs[1] = fcc >> 8; + fccs[2] = fcc >> 16; + fccs[3] = fcc >> 24; - return 10*(fccs[0]-'0') + (fccs[1]-'0'); + return 10 * (fccs[0] - '0') + (fccs[1] - '0'); } -static int fcc_is_data (int fcc) +static int fcc_is_data(int fcc) { char fccs[4]; fccs[0] = fcc; - fccs[1] = fcc>>8; - fccs[2] = fcc>>16; - fccs[3] = fcc>>24; + fccs[1] = fcc >> 8; + fccs[2] = fcc >> 16; + fccs[3] = fcc >> 24; - if (!isdigit (fccs[0]) || !isdigit (fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) + if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) return 0; if (fccs[3] != 'b' && fccs[3] != 'c') return 0; @@ -166,34 +166,34 @@ AviError AVI_print_error(AviError in_error) error = in_error; switch (error) { - case AVI_ERROR_NONE: - break; - case AVI_ERROR_COMPRESSION: - printf ("AVI ERROR: compressed in an unsupported format\n"); - break; - case AVI_ERROR_OPEN: - printf ("AVI ERROR: could not open file\n"); - break; - case AVI_ERROR_READING: - printf ("AVI ERROR: could not read from file\n"); - break; - case AVI_ERROR_WRITING: - printf ("AVI ERROR: could not write to file\n"); - break; - case AVI_ERROR_FORMAT: - printf ("AVI ERROR: file is in an illegal or unrecognized format\n"); - break; - case AVI_ERROR_ALLOC: - printf ("AVI ERROR: error encountered while allocating memory\n"); - break; - case AVI_ERROR_OPTION: - printf ("AVI ERROR: program made illegal request\n"); - break; - case AVI_ERROR_FOUND: - printf ("AVI ERROR: movie did not contain expected item\n"); - break; - default: - break; + case AVI_ERROR_NONE: + break; + case AVI_ERROR_COMPRESSION: + printf("AVI ERROR: compressed in an unsupported format\n"); + break; + case AVI_ERROR_OPEN: + printf("AVI ERROR: could not open file\n"); + break; + case AVI_ERROR_READING: + printf("AVI ERROR: could not read from file\n"); + break; + case AVI_ERROR_WRITING: + printf("AVI ERROR: could not write to file\n"); + break; + case AVI_ERROR_FORMAT: + printf("AVI ERROR: file is in an illegal or unrecognized format\n"); + break; + case AVI_ERROR_ALLOC: + printf("AVI ERROR: error encountered while allocating memory\n"); + break; + case AVI_ERROR_OPTION: + printf("AVI ERROR: program made illegal request\n"); + break; + case AVI_ERROR_FOUND: + printf("AVI ERROR: movie did not contain expected item\n"); + break; + default: + break; } return in_error; @@ -201,7 +201,7 @@ AviError AVI_print_error(AviError in_error) #if 0 void AVI_set_debug(int mode) { - AVI_DEBUG= mode; + AVI_DEBUG = mode; } int AVI_is_avi(char *name) @@ -209,13 +209,13 @@ int AVI_is_avi(char *name) FILE *fp; int ret; - fp = fopen (name, "rb"); + fp = fopen(name, "rb"); if (fp == NULL) return 0; - if (GET_FCC (fp) != FCC("RIFF") || - !GET_FCC (fp) || - GET_FCC (fp) != FCC("AVI ")) { + if (GET_FCC(fp) != FCC("RIFF") || + !GET_FCC(fp) || + GET_FCC(fp) != FCC("AVI ")) { ret = 0; } else { @@ -230,7 +230,7 @@ int AVI_is_avi(char *name) int AVI_is_avi(const char *name) { int temp, fcca, j; - AviMovie movie= {NULL}; + AviMovie movie = {NULL}; AviMainHeader header; AviBitmapInfoHeader bheader; int movie_tracks = 0; @@ -238,26 +238,26 @@ int AVI_is_avi(const char *name) DEBUG_PRINT("opening movie\n"); movie.type = AVI_MOVIE_READ; - movie.fp = fopen (name, "rb"); + movie.fp = fopen(name, "rb"); movie.offset_table = NULL; if (movie.fp == NULL) return 0; - if (GET_FCC (movie.fp) != FCC("RIFF") || - !(movie.size = GET_FCC (movie.fp))) { + if (GET_FCC(movie.fp) != FCC("RIFF") || + !(movie.size = GET_FCC(movie.fp))) { fclose(movie.fp); return 0; } movie.header = &header; - if (GET_FCC (movie.fp) != FCC("AVI ") || - GET_FCC (movie.fp) != FCC("LIST") || - !GET_FCC (movie.fp) || - GET_FCC (movie.fp) != FCC("hdrl") || - (movie.header->fcc = GET_FCC (movie.fp)) != FCC("avih") || - !(movie.header->size = GET_FCC (movie.fp))) { + if (GET_FCC(movie.fp) != FCC("AVI ") || + GET_FCC(movie.fp) != FCC("LIST") || + !GET_FCC(movie.fp) || + GET_FCC(movie.fp) != FCC("hdrl") || + (movie.header->fcc = GET_FCC(movie.fp)) != FCC("avih") || + !(movie.header->size = GET_FCC(movie.fp))) { DEBUG_PRINT("bad initial header info\n"); fclose(movie.fp); return 0; @@ -278,7 +278,7 @@ int AVI_is_avi(const char *name) movie.header->Reserved[2] = GET_FCC(movie.fp); movie.header->Reserved[3] = GET_FCC(movie.fp); - fseek (movie.fp, movie.header->size-14*4, SEEK_CUR); + fseek(movie.fp, movie.header->size - 14 * 4, SEEK_CUR); if (movie.header->Streams < 1) { DEBUG_PRINT("streams less than 1\n"); @@ -286,15 +286,16 @@ int AVI_is_avi(const char *name) return 0; } - movie.streams = (AviStreamRec *) MEM_callocN (sizeof(AviStreamRec) * movie.header->Streams, "moviestreams"); + movie.streams = (AviStreamRec *) MEM_callocN(sizeof(AviStreamRec) * movie.header->Streams, "moviestreams"); - for (temp=0; temp < movie.header->Streams; temp++) { + for (temp = 0; temp < movie.header->Streams; temp++) { if (GET_FCC(movie.fp) != FCC("LIST") || - !GET_FCC (movie.fp) || - GET_FCC (movie.fp) != FCC ("strl") || - (movie.streams[temp].sh.fcc = GET_FCC (movie.fp)) != FCC ("strh") || - !(movie.streams[temp].sh.size = GET_FCC (movie.fp))) { + !GET_FCC(movie.fp) || + GET_FCC(movie.fp) != FCC("strl") || + (movie.streams[temp].sh.fcc = GET_FCC(movie.fp)) != FCC("strh") || + !(movie.streams[temp].sh.size = GET_FCC(movie.fp))) + { DEBUG_PRINT("bad stream header information\n"); MEM_freeN(movie.streams); @@ -302,20 +303,21 @@ int AVI_is_avi(const char *name) return 0; } - movie.streams[temp].sh.Type = GET_FCC (movie.fp); - movie.streams[temp].sh.Handler = GET_FCC (movie.fp); + movie.streams[temp].sh.Type = GET_FCC(movie.fp); + movie.streams[temp].sh.Handler = GET_FCC(movie.fp); fcca = movie.streams[temp].sh.Handler; if (movie.streams[temp].sh.Type == FCC("vids")) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0) { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { movie.streams[temp].format = AVI_FORMAT_AVI_RGB; } - else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) { + else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { movie.streams[temp].format = AVI_FORMAT_MJPEG; } else { @@ -326,67 +328,70 @@ int AVI_is_avi(const char *name) movie_tracks++; } - movie.streams[temp].sh.Flags = GET_FCC (movie.fp); - movie.streams[temp].sh.Priority = GET_TCC (movie.fp); - movie.streams[temp].sh.Language = GET_TCC (movie.fp); - movie.streams[temp].sh.InitialFrames = GET_FCC (movie.fp); - movie.streams[temp].sh.Scale = GET_FCC (movie.fp); - movie.streams[temp].sh.Rate = GET_FCC (movie.fp); - movie.streams[temp].sh.Start = GET_FCC (movie.fp); - movie.streams[temp].sh.Length = GET_FCC (movie.fp); - movie.streams[temp].sh.SuggestedBufferSize = GET_FCC (movie.fp); - movie.streams[temp].sh.Quality = GET_FCC (movie.fp); - movie.streams[temp].sh.SampleSize = GET_FCC (movie.fp); - movie.streams[temp].sh.left = GET_TCC (movie.fp); - movie.streams[temp].sh.top = GET_TCC (movie.fp); - movie.streams[temp].sh.right = GET_TCC (movie.fp); - movie.streams[temp].sh.bottom = GET_TCC (movie.fp); + movie.streams[temp].sh.Flags = GET_FCC(movie.fp); + movie.streams[temp].sh.Priority = GET_TCC(movie.fp); + movie.streams[temp].sh.Language = GET_TCC(movie.fp); + movie.streams[temp].sh.InitialFrames = GET_FCC(movie.fp); + movie.streams[temp].sh.Scale = GET_FCC(movie.fp); + movie.streams[temp].sh.Rate = GET_FCC(movie.fp); + movie.streams[temp].sh.Start = GET_FCC(movie.fp); + movie.streams[temp].sh.Length = GET_FCC(movie.fp); + movie.streams[temp].sh.SuggestedBufferSize = GET_FCC(movie.fp); + movie.streams[temp].sh.Quality = GET_FCC(movie.fp); + movie.streams[temp].sh.SampleSize = GET_FCC(movie.fp); + movie.streams[temp].sh.left = GET_TCC(movie.fp); + movie.streams[temp].sh.top = GET_TCC(movie.fp); + movie.streams[temp].sh.right = GET_TCC(movie.fp); + movie.streams[temp].sh.bottom = GET_TCC(movie.fp); - fseek (movie.fp, movie.streams[temp].sh.size-14*4, SEEK_CUR); + fseek(movie.fp, movie.streams[temp].sh.size - 14 * 4, SEEK_CUR); - if (GET_FCC (movie.fp) != FCC("strf")) { + if (GET_FCC(movie.fp) != FCC("strf")) { DEBUG_PRINT("no stream format information\n"); MEM_freeN(movie.streams); fclose(movie.fp); return 0; } - movie.streams[temp].sf_size= GET_FCC(movie.fp); + movie.streams[temp].sf_size = GET_FCC(movie.fp); if (movie.streams[temp].sh.Type == FCC("vids")) { j = movie.streams[temp].sf_size - (sizeof(AviBitmapInfoHeader) - 8); if (j >= 0) { AviBitmapInfoHeader *bi; - movie.streams[temp].sf= &bheader; - bi= (AviBitmapInfoHeader *) movie.streams[temp].sf; + movie.streams[temp].sf = &bheader; + bi = (AviBitmapInfoHeader *) movie.streams[temp].sf; - bi->fcc= FCC("strf"); - bi->size= movie.streams[temp].sf_size; - bi->Size= GET_FCC(movie.fp); - bi->Width= GET_FCC(movie.fp); - bi->Height= GET_FCC(movie.fp); - bi->Planes= GET_TCC(movie.fp); - bi->BitCount= GET_TCC(movie.fp); - bi->Compression= GET_FCC(movie.fp); - bi->SizeImage= GET_FCC(movie.fp); - bi->XPelsPerMeter= GET_FCC(movie.fp); - bi->YPelsPerMeter= GET_FCC(movie.fp); - bi->ClrUsed= GET_FCC(movie.fp); - bi->ClrImportant= GET_FCC(movie.fp); + bi->fcc = FCC("strf"); + bi->size = movie.streams[temp].sf_size; + bi->Size = GET_FCC(movie.fp); + bi->Width = GET_FCC(movie.fp); + bi->Height = GET_FCC(movie.fp); + bi->Planes = GET_TCC(movie.fp); + bi->BitCount = GET_TCC(movie.fp); + bi->Compression = GET_FCC(movie.fp); + bi->SizeImage = GET_FCC(movie.fp); + bi->XPelsPerMeter = GET_FCC(movie.fp); + bi->YPelsPerMeter = GET_FCC(movie.fp); + bi->ClrUsed = GET_FCC(movie.fp); + bi->ClrImportant = GET_FCC(movie.fp); fcca = bi->Compression; - if ( movie.streams[temp].format == - AVI_FORMAT_AVI_RGB) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0 ) { + if (movie.streams[temp].format == + AVI_FORMAT_AVI_RGB) { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { + /* pass */ } - else if ( fcca == FCC ("mjpg") || - fcca == FCC ("MJPG")) { - movie.streams[temp].format = AVI_FORMAT_MJPEG; + else if (fcca == FCC("mjpg") || + fcca == FCC("MJPG")) + { + movie.streams[temp].format = AVI_FORMAT_MJPEG; } else { MEM_freeN(movie.streams); @@ -396,14 +401,14 @@ int AVI_is_avi(const char *name) } } - if (j > 0) fseek (movie.fp, j, SEEK_CUR); + if (j > 0) fseek(movie.fp, j, SEEK_CUR); } - else fseek (movie.fp, movie.streams[temp].sf_size, SEEK_CUR); + else fseek(movie.fp, movie.streams[temp].sf_size, SEEK_CUR); /* Walk to the next LIST */ - while (GET_FCC (movie.fp) != FCC("LIST")) { - temp= GET_FCC (movie.fp); - if (temp<0 || ftell(movie.fp) > movie.size) { + while (GET_FCC(movie.fp) != FCC("LIST")) { + temp = GET_FCC(movie.fp); + if (temp < 0 || ftell(movie.fp) > movie.size) { DEBUG_PRINT("incorrect size in header or error in AVI\n"); MEM_freeN(movie.streams); @@ -433,26 +438,27 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) memset(movie, 0, sizeof(AviMovie)); movie->type = AVI_MOVIE_READ; - movie->fp = fopen (name, "rb"); + movie->fp = fopen(name, "rb"); movie->offset_table = NULL; if (movie->fp == NULL) return AVI_ERROR_OPEN; - if (GET_FCC (movie->fp) != FCC("RIFF") || - !(movie->size = GET_FCC (movie->fp))) + if (GET_FCC(movie->fp) != FCC("RIFF") || + !(movie->size = GET_FCC(movie->fp))) { return AVI_ERROR_FORMAT; } - movie->header = (AviMainHeader *) MEM_mallocN (sizeof (AviMainHeader), "movieheader"); + movie->header = (AviMainHeader *) MEM_mallocN(sizeof (AviMainHeader), "movieheader"); - if (GET_FCC (movie->fp) != FCC("AVI ") || - GET_FCC (movie->fp) != FCC("LIST") || - !GET_FCC (movie->fp) || - GET_FCC (movie->fp) != FCC("hdrl") || - (movie->header->fcc = GET_FCC (movie->fp)) != FCC("avih") || - !(movie->header->size = GET_FCC (movie->fp))) { + if (GET_FCC(movie->fp) != FCC("AVI ") || + GET_FCC(movie->fp) != FCC("LIST") || + !GET_FCC(movie->fp) || + GET_FCC(movie->fp) != FCC("hdrl") || + (movie->header->fcc = GET_FCC(movie->fp)) != FCC("avih") || + !(movie->header->size = GET_FCC(movie->fp))) + { DEBUG_PRINT("bad initial header info\n"); return AVI_ERROR_FORMAT; } @@ -472,40 +478,42 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) movie->header->Reserved[2] = GET_FCC(movie->fp); movie->header->Reserved[3] = GET_FCC(movie->fp); - fseek (movie->fp, movie->header->size-14*4, SEEK_CUR); + fseek(movie->fp, movie->header->size - 14 * 4, SEEK_CUR); if (movie->header->Streams < 1) { DEBUG_PRINT("streams less than 1\n"); return AVI_ERROR_FORMAT; } - movie->streams = (AviStreamRec *) MEM_callocN (sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); + movie->streams = (AviStreamRec *) MEM_callocN(sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); - for (temp=0; temp < movie->header->Streams; temp++) { + for (temp = 0; temp < movie->header->Streams; temp++) { if (GET_FCC(movie->fp) != FCC("LIST") || - !GET_FCC (movie->fp) || - GET_FCC (movie->fp) != FCC ("strl") || - (movie->streams[temp].sh.fcc = GET_FCC (movie->fp)) != FCC ("strh") || - !(movie->streams[temp].sh.size = GET_FCC (movie->fp))) { + !GET_FCC(movie->fp) || + GET_FCC(movie->fp) != FCC("strl") || + (movie->streams[temp].sh.fcc = GET_FCC(movie->fp)) != FCC("strh") || + !(movie->streams[temp].sh.size = GET_FCC(movie->fp))) + { DEBUG_PRINT("bad stream header information\n"); - return AVI_ERROR_FORMAT; + return AVI_ERROR_FORMAT; } - movie->streams[temp].sh.Type = GET_FCC (movie->fp); - movie->streams[temp].sh.Handler = GET_FCC (movie->fp); + movie->streams[temp].sh.Type = GET_FCC(movie->fp); + movie->streams[temp].sh.Handler = GET_FCC(movie->fp); fcca = movie->streams[temp].sh.Handler; if (movie->streams[temp].sh.Type == FCC("vids")) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0) { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { movie->streams[temp].format = AVI_FORMAT_AVI_RGB; } - else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) { + else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { movie->streams[temp].format = AVI_FORMAT_MJPEG; } else { @@ -513,66 +521,70 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - movie->streams[temp].sh.Flags = GET_FCC (movie->fp); - movie->streams[temp].sh.Priority = GET_TCC (movie->fp); - movie->streams[temp].sh.Language = GET_TCC (movie->fp); - movie->streams[temp].sh.InitialFrames = GET_FCC (movie->fp); - movie->streams[temp].sh.Scale = GET_FCC (movie->fp); - movie->streams[temp].sh.Rate = GET_FCC (movie->fp); - movie->streams[temp].sh.Start = GET_FCC (movie->fp); - movie->streams[temp].sh.Length = GET_FCC (movie->fp); - movie->streams[temp].sh.SuggestedBufferSize = GET_FCC (movie->fp); - movie->streams[temp].sh.Quality = GET_FCC (movie->fp); - movie->streams[temp].sh.SampleSize = GET_FCC (movie->fp); - movie->streams[temp].sh.left = GET_TCC (movie->fp); - movie->streams[temp].sh.top = GET_TCC (movie->fp); - movie->streams[temp].sh.right = GET_TCC (movie->fp); - movie->streams[temp].sh.bottom = GET_TCC (movie->fp); + movie->streams[temp].sh.Flags = GET_FCC(movie->fp); + movie->streams[temp].sh.Priority = GET_TCC(movie->fp); + movie->streams[temp].sh.Language = GET_TCC(movie->fp); + movie->streams[temp].sh.InitialFrames = GET_FCC(movie->fp); + movie->streams[temp].sh.Scale = GET_FCC(movie->fp); + movie->streams[temp].sh.Rate = GET_FCC(movie->fp); + movie->streams[temp].sh.Start = GET_FCC(movie->fp); + movie->streams[temp].sh.Length = GET_FCC(movie->fp); + movie->streams[temp].sh.SuggestedBufferSize = GET_FCC(movie->fp); + movie->streams[temp].sh.Quality = GET_FCC(movie->fp); + movie->streams[temp].sh.SampleSize = GET_FCC(movie->fp); + movie->streams[temp].sh.left = GET_TCC(movie->fp); + movie->streams[temp].sh.top = GET_TCC(movie->fp); + movie->streams[temp].sh.right = GET_TCC(movie->fp); + movie->streams[temp].sh.bottom = GET_TCC(movie->fp); - fseek (movie->fp, movie->streams[temp].sh.size-14*4, SEEK_CUR); + fseek(movie->fp, movie->streams[temp].sh.size - 14 * 4, SEEK_CUR); - if (GET_FCC (movie->fp) != FCC("strf")) { + if (GET_FCC(movie->fp) != FCC("strf")) { DEBUG_PRINT("no stream format information\n"); return AVI_ERROR_FORMAT; } - movie->streams[temp].sf_size= GET_FCC(movie->fp); + movie->streams[temp].sf_size = GET_FCC(movie->fp); if (movie->streams[temp].sh.Type == FCC("vids")) { j = movie->streams[temp].sf_size - (sizeof(AviBitmapInfoHeader) - 8); if (j >= 0) { AviBitmapInfoHeader *bi; - movie->streams[temp].sf= MEM_mallocN(sizeof(AviBitmapInfoHeader), "streamformat"); + movie->streams[temp].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader), "streamformat"); - bi= (AviBitmapInfoHeader *) movie->streams[temp].sf; + bi = (AviBitmapInfoHeader *) movie->streams[temp].sf; - bi->fcc= FCC("strf"); - bi->size= movie->streams[temp].sf_size; - bi->Size= GET_FCC(movie->fp); - bi->Width= GET_FCC(movie->fp); - bi->Height= GET_FCC(movie->fp); - bi->Planes= GET_TCC(movie->fp); - bi->BitCount= GET_TCC(movie->fp); - bi->Compression= GET_FCC(movie->fp); - bi->SizeImage= GET_FCC(movie->fp); - bi->XPelsPerMeter= GET_FCC(movie->fp); - bi->YPelsPerMeter= GET_FCC(movie->fp); - bi->ClrUsed= GET_FCC(movie->fp); - bi->ClrImportant= GET_FCC(movie->fp); + bi->fcc = FCC("strf"); + bi->size = movie->streams[temp].sf_size; + bi->Size = GET_FCC(movie->fp); + bi->Width = GET_FCC(movie->fp); + bi->Height = GET_FCC(movie->fp); + bi->Planes = GET_TCC(movie->fp); + bi->BitCount = GET_TCC(movie->fp); + bi->Compression = GET_FCC(movie->fp); + bi->SizeImage = GET_FCC(movie->fp); + bi->XPelsPerMeter = GET_FCC(movie->fp); + bi->YPelsPerMeter = GET_FCC(movie->fp); + bi->ClrUsed = GET_FCC(movie->fp); + bi->ClrImportant = GET_FCC(movie->fp); fcca = bi->Compression; - if ( movie->streams[temp].format == - AVI_FORMAT_AVI_RGB) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0 ) { + if (movie->streams[temp].format == + AVI_FORMAT_AVI_RGB) + { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { + /* pass */ } - else if ( fcca == FCC ("mjpg") || - fcca == FCC ("MJPG")) { - movie->streams[temp].format = AVI_FORMAT_MJPEG; + else if (fcca == FCC("mjpg") || + fcca == FCC("MJPG")) + { + movie->streams[temp].format = AVI_FORMAT_MJPEG; } else { return AVI_ERROR_COMPRESSION; @@ -580,38 +592,38 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - if (j > 0) fseek (movie->fp, j, SEEK_CUR); + if (j > 0) fseek(movie->fp, j, SEEK_CUR); } - else fseek (movie->fp, movie->streams[temp].sf_size, SEEK_CUR); + else fseek(movie->fp, movie->streams[temp].sf_size, SEEK_CUR); /* Walk to the next LIST */ - while (GET_FCC (movie->fp) != FCC("LIST")) { - temp= GET_FCC (movie->fp); - if (temp<0 || ftell(movie->fp) > movie->size) { + while (GET_FCC(movie->fp) != FCC("LIST")) { + temp = GET_FCC(movie->fp); + if (temp < 0 || ftell(movie->fp) > movie->size) { DEBUG_PRINT("incorrect size in header or error in AVI\n"); - return AVI_ERROR_FORMAT; + return AVI_ERROR_FORMAT; } - fseek(movie->fp, temp, SEEK_CUR); + fseek(movie->fp, temp, SEEK_CUR); } - fseek(movie->fp, -4L, SEEK_CUR); + fseek(movie->fp, -4L, SEEK_CUR); } while (1) { - temp = GET_FCC (movie->fp); - size = GET_FCC (movie->fp); + temp = GET_FCC(movie->fp); + size = GET_FCC(movie->fp); if (size == 0) break; if (temp == FCC("LIST")) { - if (GET_FCC(movie->fp) == FCC ("movi")) + if (GET_FCC(movie->fp) == FCC("movi")) break; else - fseek (movie->fp, size-4, SEEK_CUR); + fseek(movie->fp, size - 4, SEEK_CUR); } else { - fseek (movie->fp, size, SEEK_CUR); + fseek(movie->fp, size, SEEK_CUR); } if (ftell(movie->fp) > movie->size) { DEBUG_PRINT("incorrect size in header or error in AVI\n"); @@ -619,31 +631,31 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - movie->movi_offset = ftell (movie->fp); + movie->movi_offset = ftell(movie->fp); movie->read_offset = movie->movi_offset; /* Read in the index if the file has one, otherwise create one */ if (movie->header->Flags & AVIF_HASINDEX) { - fseek(movie->fp, size-4, SEEK_CUR); + fseek(movie->fp, size - 4, SEEK_CUR); if (GET_FCC(movie->fp) != FCC("idx1")) { DEBUG_PRINT("bad index informatio\n"); return AVI_ERROR_FORMAT; } - movie->index_entries = GET_FCC (movie->fp)/sizeof(AviIndexEntry); + movie->index_entries = GET_FCC(movie->fp) / sizeof(AviIndexEntry); if (movie->index_entries == 0) { DEBUG_PRINT("no index entries\n"); return AVI_ERROR_FORMAT; } - movie->entries = (AviIndexEntry *) MEM_mallocN (movie->index_entries * sizeof(AviIndexEntry), "movieentries"); + movie->entries = (AviIndexEntry *) MEM_mallocN(movie->index_entries * sizeof(AviIndexEntry), "movieentries"); - for (temp=0; temp < movie->index_entries; temp++) { - movie->entries[temp].ChunkId = GET_FCC (movie->fp); - movie->entries[temp].Flags = GET_FCC (movie->fp); - movie->entries[temp].Offset = GET_FCC (movie->fp); - movie->entries[temp].Size = GET_FCC (movie->fp); + for (temp = 0; temp < movie->index_entries; temp++) { + movie->entries[temp].ChunkId = GET_FCC(movie->fp); + movie->entries[temp].Flags = GET_FCC(movie->fp); + movie->entries[temp].Offset = GET_FCC(movie->fp); + movie->entries[temp].Size = GET_FCC(movie->fp); if (AVI_DEBUG) { printf("Index entry %04d: ChunkId:%s Flags:%d Offset:%d Size:%d\n", @@ -660,31 +672,32 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) * undetermined reason */ if (movie->entries[0].Offset == movie->movi_offset) - movie->read_offset= 4; + movie->read_offset = 4; } DEBUG_PRINT("movie succesfully opened\n"); return AVI_ERROR_NONE; } -void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream) +void *AVI_read_frame(AviMovie *movie, AviFormat format, int frame, int stream) { - int cur_frame=-1, temp, i=0, rewind=1; + int cur_frame = -1, temp, i = 0, rewind = 1; void *buffer; /* Retrieve the record number of the desired frame in the index * If a chunk has Size 0 we need to rewind to previous frame */ while (rewind && frame > -1) { - i=0; - cur_frame=-1; + i = 0; + cur_frame = -1; rewind = 0; while (cur_frame < frame && i < movie->index_entries) { - if (fcc_is_data (movie->entries[i].ChunkId) && - fcc_get_stream (movie->entries[i].ChunkId) == stream) { - if ((cur_frame == frame -1) && (movie->entries[i].Size == 0)) { + if (fcc_is_data(movie->entries[i].ChunkId) && + fcc_get_stream(movie->entries[i].ChunkId) == stream) + { + if ((cur_frame == frame - 1) && (movie->entries[i].Size == 0)) { rewind = 1; - frame = frame -1; + frame = frame - 1; } else { cur_frame++; @@ -697,18 +710,18 @@ void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream) if (cur_frame != frame) return NULL; - fseek (movie->fp, movie->read_offset + movie->entries[i-1].Offset, SEEK_SET); + fseek(movie->fp, movie->read_offset + movie->entries[i - 1].Offset, SEEK_SET); temp = GET_FCC(movie->fp); - buffer = MEM_mallocN (temp, "readbuffer"); + buffer = MEM_mallocN(temp, "readbuffer"); - if (fread (buffer, 1, temp, movie->fp) != temp) { + if (fread(buffer, 1, temp, movie->fp) != temp) { MEM_freeN(buffer); return NULL; } - buffer = avi_format_convert (movie, stream, buffer, movie->streams[stream].format, format, &temp); + buffer = avi_format_convert(movie, stream, buffer, movie->streams[stream].format, format, &temp); return buffer; } @@ -717,21 +730,21 @@ AviError AVI_close(AviMovie *movie) { int i; - fclose (movie->fp); + fclose(movie->fp); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { if (movie->streams[i].sf != NULL) - MEM_freeN (movie->streams[i].sf); + MEM_freeN(movie->streams[i].sf); } if (movie->header != NULL) - MEM_freeN (movie->header); - if (movie->streams!= NULL) - MEM_freeN (movie->streams); + MEM_freeN(movie->header); + if (movie->streams != NULL) + MEM_freeN(movie->streams); if (movie->entries != NULL) - MEM_freeN (movie->entries); + MEM_freeN(movie->entries); if (movie->offset_table != NULL) - MEM_freeN (movie->offset_table); + MEM_freeN(movie->offset_table); return AVI_ERROR_NONE; } @@ -747,21 +760,21 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) int64_t junk_pos; movie->type = AVI_MOVIE_WRITE; - movie->fp = fopen (name, "wb"); + movie->fp = fopen(name, "wb"); movie->index_entries = 0; if (movie->fp == NULL) return AVI_ERROR_OPEN; - movie->offset_table = (int64_t *) MEM_mallocN ((1+streams*2) * sizeof (int64_t), "offsettable"); + movie->offset_table = (int64_t *) MEM_mallocN((1 + streams * 2) * sizeof (int64_t), "offsettable"); - for (i=0; i < 1 + streams*2; i++) + for (i = 0; i < 1 + streams * 2; i++) movie->offset_table[i] = -1L; movie->entries = NULL; - movie->header = (AviMainHeader *) MEM_mallocN (sizeof(AviMainHeader), "movieheader"); + movie->header = (AviMainHeader *) MEM_mallocN(sizeof(AviMainHeader), "movieheader"); movie->header->fcc = FCC("avih"); movie->header->size = 56; @@ -780,20 +793,20 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) movie->header->Reserved[2] = 0; movie->header->Reserved[3] = 0; - movie->streams = (AviStreamRec *) MEM_mallocN (sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); + movie->streams = (AviStreamRec *) MEM_mallocN(sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); - va_start (ap, streams); + va_start(ap, streams); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { movie->streams[i].format = va_arg(ap, AviFormat); - movie->streams[i].sh.fcc = FCC ("strh"); + movie->streams[i].sh.fcc = FCC("strh"); movie->streams[i].sh.size = 56; - movie->streams[i].sh.Type = avi_get_format_type (movie->streams[i].format); + movie->streams[i].sh.Type = avi_get_format_type(movie->streams[i].format); if (movie->streams[i].sh.Type == 0) return AVI_ERROR_FORMAT; - movie->streams[i].sh.Handler = avi_get_format_fcc (movie->streams[i].format); + movie->streams[i].sh.Handler = avi_get_format_fcc(movie->streams[i].format); if (movie->streams[i].sh.Handler == 0) return AVI_ERROR_FORMAT; @@ -816,30 +829,30 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) if (movie->streams[i].sh.Type == FCC("vids")) { #if 0 if (movie->streams[i].format == AVI_FORMAT_MJPEG) { - movie->streams[i].sf = MEM_mallocN (sizeof(AviBitmapInfoHeader) - + sizeof(AviMJPEGUnknown), "moviestreamformatL"); + movie->streams[i].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader) + + sizeof(AviMJPEGUnknown), "moviestreamformatL"); movie->streams[i].sf_size = sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown); } else { #endif - movie->streams[i].sf = MEM_mallocN (sizeof(AviBitmapInfoHeader), "moviestreamformatS"); + movie->streams[i].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader), "moviestreamformatS"); movie->streams[i].sf_size = sizeof(AviBitmapInfoHeader); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->fcc = FCC ("strf"); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->fcc = FCC("strf"); ((AviBitmapInfoHeader *) movie->streams[i].sf)->size = movie->streams[i].sf_size - 8; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Size = movie->streams[i].sf_size - 8; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Planes = 1; ((AviBitmapInfoHeader *) movie->streams[i].sf)->BitCount = 24; - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Compression = avi_get_format_compression (movie->streams[i].format); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Compression = avi_get_format_compression(movie->streams[i].format); ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->XPelsPerMeter = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->YPelsPerMeter = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->ClrUsed = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->ClrImportant = 0; -/* +#if 0 if (movie->streams[i].format == AVI_FORMAT_MJPEG) { AviMJPEGUnknown *tmp; @@ -857,7 +870,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) else if (movie->streams[i].sh.Type == FCC("auds")) { // pass } -*/ +#endif } } @@ -865,53 +878,53 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) list.size = 0; list.ids = FCC("AVI "); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); list.fcc = FCC("LIST"); list.size = 0; list.ids = FCC("hdrl"); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); header_pos1 = ftell(movie->fp); movie->offset_table[0] = ftell(movie->fp); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { list.fcc = FCC("LIST"); list.size = 0; list.ids = FCC("strl"); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); stream_pos1 = ftell(movie->fp); - movie->offset_table[1+i*2] = ftell(movie->fp); - awrite (movie, &movie->streams[i].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); + movie->offset_table[1 + i * 2] = ftell(movie->fp); + awrite(movie, &movie->streams[i].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); - movie->offset_table[1+i*2+1] = ftell(movie->fp); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + movie->offset_table[1 + i * 2 + 1] = ftell(movie->fp); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); stream_pos2 = ftell(movie->fp); - fseek (movie->fp, stream_pos1-8, SEEK_SET); + fseek(movie->fp, stream_pos1 - 8, SEEK_SET); - PUT_FCCN((stream_pos2-stream_pos1+4L), movie->fp); + PUT_FCCN((stream_pos2 - stream_pos1 + 4L), movie->fp); - fseek (movie->fp, stream_pos2, SEEK_SET); + fseek(movie->fp, stream_pos2, SEEK_SET); } - junk_pos= ftell(movie->fp); + junk_pos = ftell(movie->fp); if (junk_pos < 2024 - 8) { chunk.fcc = FCC("JUNK"); chunk.size = 2024 - 8 - (int)junk_pos; - awrite (movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); + awrite(movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); - for (i=0; i < chunk.size; i++) + for (i = 0; i < chunk.size; i++) putc(0, movie->fp); } @@ -921,13 +934,13 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) list.size = 0; list.ids = FCC("movi"); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); - movie->movi_offset = ftell(movie->fp)-8L; + movie->movi_offset = ftell(movie->fp) - 8L; - fseek (movie->fp, AVI_HDRL_SOFF, SEEK_SET); + fseek(movie->fp, AVI_HDRL_SOFF, SEEK_SET); - PUT_FCCN((header_pos2-header_pos1+4L), movie->fp); + PUT_FCCN((header_pos2 - header_pos1 + 4L), movie->fp); return AVI_ERROR_NONE; } @@ -949,93 +962,93 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...) /* Allocate the new memory for the index entry */ - if (frame_num+1 > movie->index_entries) { - temp = (AviIndexEntry *) MEM_mallocN ((frame_num+1) * - (movie->header->Streams+1) * sizeof(AviIndexEntry), "newidxentry"); + if (frame_num + 1 > movie->index_entries) { + temp = (AviIndexEntry *) MEM_mallocN((frame_num + 1) * + (movie->header->Streams + 1) * sizeof(AviIndexEntry), "newidxentry"); if (movie->entries != NULL) { - memcpy (temp, movie->entries, movie->index_entries * (movie->header->Streams+1) - * sizeof(AviIndexEntry)); - MEM_freeN (movie->entries); + memcpy(temp, movie->entries, movie->index_entries * (movie->header->Streams + 1) + * sizeof(AviIndexEntry)); + MEM_freeN(movie->entries); } movie->entries = temp; - movie->index_entries = frame_num+1; + movie->index_entries = frame_num + 1; } /* Slap a new record entry onto the end of the file */ - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); list.fcc = FCC("LIST"); list.size = 0; list.ids = FCC("rec "); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); - rec_off = ftell (movie->fp)-8L; + rec_off = ftell(movie->fp) - 8L; /* Write a frame for every stream */ - va_start (ap, frame_num); + va_start(ap, frame_num); - for (stream=0; stream < movie->header->Streams; stream++) { - unsigned int tbuf=0; + for (stream = 0; stream < movie->header->Streams; stream++) { + unsigned int tbuf = 0; - format = va_arg (ap, AviFormat); - buffer = va_arg (ap, void*); - size = va_arg (ap, int); + format = va_arg(ap, AviFormat); + buffer = va_arg(ap, void *); + size = va_arg(ap, int); /* Convert the buffer into the output format */ - buffer = avi_format_convert (movie, stream, buffer, format, movie->streams[stream].format, &size); + buffer = avi_format_convert(movie, stream, buffer, format, movie->streams[stream].format, &size); /* Write the header info for this data chunk */ - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); - chunk.fcc = avi_get_data_id (format, stream); + chunk.fcc = avi_get_data_id(format, stream); chunk.size = size; - if (size%4) chunk.size += 4 - size%4; + if (size % 4) chunk.size += 4 - size % 4; - awrite (movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); + awrite(movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); /* Write the index entry for this data chunk */ - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].ChunkId = chunk.fcc; - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Flags = AVIIF_KEYFRAME; - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Offset = (int)(ftell(movie->fp) - 12L - movie->movi_offset); - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Size = chunk.size; + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].ChunkId = chunk.fcc; + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].Flags = AVIIF_KEYFRAME; + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].Offset = (int)(ftell(movie->fp) - 12L - movie->movi_offset); + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].Size = chunk.size; /* Write the chunk */ - awrite (movie, buffer, 1, size, movie->fp, AVI_RAW); - MEM_freeN (buffer); + awrite(movie, buffer, 1, size, movie->fp, AVI_RAW); + MEM_freeN(buffer); - if (size%4) awrite (movie, &tbuf, 1, 4-size%4, movie->fp, AVI_RAW); + if (size % 4) awrite(movie, &tbuf, 1, 4 - size % 4, movie->fp, AVI_RAW); /* Update the stream headers length field */ movie->streams[stream].sh.Length++; - fseek (movie->fp, movie->offset_table[1+stream*2], SEEK_SET); - awrite (movie, &movie->streams[stream].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); + fseek(movie->fp, movie->offset_table[1 + stream * 2], SEEK_SET); + awrite(movie, &movie->streams[stream].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); } - va_end (ap); + va_end(ap); /* Record the entry for the new record */ - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); - movie->entries[frame_num * (movie->header->Streams+1)].ChunkId = FCC("rec "); - movie->entries[frame_num * (movie->header->Streams+1)].Flags = AVIIF_LIST; - movie->entries[frame_num * (movie->header->Streams+1)].Offset = (int)(rec_off - 8L - movie->movi_offset); - movie->entries[frame_num * (movie->header->Streams+1)].Size = (int)(ftell(movie->fp) - (rec_off + 4L)); + movie->entries[frame_num * (movie->header->Streams + 1)].ChunkId = FCC("rec "); + movie->entries[frame_num * (movie->header->Streams + 1)].Flags = AVIIF_LIST; + movie->entries[frame_num * (movie->header->Streams + 1)].Offset = (int)(rec_off - 8L - movie->movi_offset); + movie->entries[frame_num * (movie->header->Streams + 1)].Size = (int)(ftell(movie->fp) - (rec_off + 4L)); /* Update the record size */ - fseek (movie->fp, rec_off, SEEK_SET); - PUT_FCCN (movie->entries[frame_num * (movie->header->Streams+1)].Size, movie->fp); + fseek(movie->fp, rec_off, SEEK_SET); + PUT_FCCN(movie->entries[frame_num * (movie->header->Streams + 1)].Size, movie->fp); /* Update the main header information in the file */ movie->header->TotalFrames++; - fseek (movie->fp, movie->offset_table[0], SEEK_SET); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + fseek(movie->fp, movie->offset_table[0], SEEK_SET); + awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); return AVI_ERROR_NONE; } @@ -1044,38 +1057,38 @@ AviError AVI_close_compress(AviMovie *movie) { int temp, movi_size, i; - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); movi_size = (int)ftell(movie->fp); - PUT_FCC ("idx1", movie->fp); - PUT_FCCN ((movie->index_entries*(movie->header->Streams+1)*16), movie->fp); + PUT_FCC("idx1", movie->fp); + PUT_FCCN((movie->index_entries * (movie->header->Streams + 1) * 16), movie->fp); - for (temp=0; temp < movie->index_entries*(movie->header->Streams+1); temp++) - awrite (movie, &movie->entries[temp], 1, sizeof(AviIndexEntry), movie->fp, AVI_INDEXE); + for (temp = 0; temp < movie->index_entries * (movie->header->Streams + 1); temp++) + awrite(movie, &movie->entries[temp], 1, sizeof(AviIndexEntry), movie->fp, AVI_INDEXE); temp = (int)ftell(movie->fp); - fseek (movie->fp, AVI_RIFF_SOFF, SEEK_SET); + fseek(movie->fp, AVI_RIFF_SOFF, SEEK_SET); - PUT_FCCN((temp-8L), movie->fp); + PUT_FCCN((temp - 8L), movie->fp); - fseek (movie->fp, movie->movi_offset, SEEK_SET); + fseek(movie->fp, movie->movi_offset, SEEK_SET); - PUT_FCCN((movi_size-(movie->movi_offset+4L)), movie->fp); + PUT_FCCN((movi_size - (movie->movi_offset + 4L)), movie->fp); - fclose (movie->fp); + fclose(movie->fp); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { if (movie->streams[i].sf != NULL) - MEM_freeN (movie->streams[i].sf); + MEM_freeN(movie->streams[i].sf); } if (movie->header != NULL) - MEM_freeN (movie->header); + MEM_freeN(movie->header); if (movie->entries != NULL) - MEM_freeN (movie->entries); + MEM_freeN(movie->entries); if (movie->streams != NULL) - MEM_freeN (movie->streams); + MEM_freeN(movie->streams); if (movie->offset_table != NULL) - MEM_freeN (movie->offset_table); + MEM_freeN(movie->offset_table); return AVI_ERROR_NONE; } diff --git a/source/blender/avi/intern/avirgb.c b/source/blender/avi/intern/avirgb.c index 36e862708f4..78316990d54 100644 --- a/source/blender/avi/intern/avirgb.c +++ b/source/blender/avi/intern/avirgb.c @@ -42,108 +42,108 @@ /* implementation */ -void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int x, y, i, rowstride; unsigned char *buf; AviBitmapInfoHeader *bi; - short bits= 32; + short bits = 32; (void)size; /* unused */ - bi= (AviBitmapInfoHeader *) movie->streams[stream].sf; - if (bi) bits= bi->BitCount; + bi = (AviBitmapInfoHeader *) movie->streams[stream].sf; + if (bi) bits = bi->BitCount; - if (bits==16) { + if (bits == 16) { unsigned short *pxl; unsigned char *to; #ifdef __BIG_ENDIAN__ unsigned char *pxla; #endif - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); - y= movie->header->Height; - to= buf; + y = movie->header->Height; + to = buf; while (y--) { - pxl= (unsigned short *) (buffer + y * movie->header->Width * 2); + pxl = (unsigned short *) (buffer + y * movie->header->Width * 2); #ifdef __BIG_ENDIAN__ - pxla= (unsigned char *)pxl; + pxla = (unsigned char *)pxl; #endif - x= movie->header->Width; + x = movie->header->Width; while (x--) { #ifdef __BIG_ENDIAN__ - i= pxla[0]; - pxla[0]= pxla[1]; - pxla[1]= i; + i = pxla[0]; + pxla[0] = pxla[1]; + pxla[1] = i; - pxla+=2; + pxla += 2; #endif - *(to++)= ((*pxl>>10)&0x1f)*8; - *(to++)= ((*pxl>>5)&0x1f)*8; - *(to++)= (*pxl&0x1f)*8; + *(to++) = ((*pxl >> 10) & 0x1f) * 8; + *(to++) = ((*pxl >> 5) & 0x1f) * 8; + *(to++) = (*pxl & 0x1f) * 8; pxl++; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } else { - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); - rowstride = movie->header->Width*3; - if (bits!=16) if (movie->header->Width%2) rowstride++; + rowstride = movie->header->Width * 3; + if (bits != 16) if (movie->header->Width % 2) rowstride++; - for (y=0; y < movie->header->Height; y++) { - memcpy (&buf[y*movie->header->Width*3], &buffer[((movie->header->Height-1)-y)*rowstride], movie->header->Width*3); + for (y = 0; y < movie->header->Height; y++) { + memcpy(&buf[y * movie->header->Width * 3], &buffer[((movie->header->Height - 1) - y) * rowstride], movie->header->Width * 3); } - for (y=0; y < movie->header->Height*movie->header->Width*3; y+=3) { + for (y = 0; y < movie->header->Height * movie->header->Width * 3; y += 3) { i = buf[y]; - buf[y] = buf[y+2]; - buf[y+2] = i; + buf[y] = buf[y + 2]; + buf[y + 2] = i; } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } } -void *avi_converter_to_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int y, x, i, rowstride; unsigned char *buf; (void)stream; /* unused */ - *size= movie->header->Height * movie->header->Width * 3; - if (movie->header->Width%2) *size+= movie->header->Height; + *size = movie->header->Height * movie->header->Width * 3; + if (movie->header->Width % 2) *size += movie->header->Height; - buf = MEM_mallocN (*size, "toavirgbbuf"); + buf = MEM_mallocN(*size, "toavirgbbuf"); - rowstride = movie->header->Width*3; - if (movie->header->Width%2) rowstride++; + rowstride = movie->header->Width * 3; + if (movie->header->Width % 2) rowstride++; - for (y=0; y < movie->header->Height; y++) { - memcpy (&buf[y*rowstride], &buffer[((movie->header->Height-1)-y)*movie->header->Width*3], movie->header->Width*3); + for (y = 0; y < movie->header->Height; y++) { + memcpy(&buf[y * rowstride], &buffer[((movie->header->Height - 1) - y) * movie->header->Width * 3], movie->header->Width * 3); } - for (y=0; y < movie->header->Height; y++) { - for (x=0; x < movie->header->Width*3; x+=3) { - i = buf[y*rowstride+x]; - buf[y*rowstride+x] = buf[y*rowstride+x+2]; - buf[y*rowstride+x+2] = i; + for (y = 0; y < movie->header->Height; y++) { + for (x = 0; x < movie->header->Width * 3; x += 3) { + i = buf[y * rowstride + x]; + buf[y * rowstride + x] = buf[y * rowstride + x + 2]; + buf[y * rowstride + x + 2] = i; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } diff --git a/source/blender/avi/intern/codecs.c b/source/blender/avi/intern/codecs.c index c99938e7b9e..01e228d570e 100644 --- a/source/blender/avi/intern/codecs.c +++ b/source/blender/avi/intern/codecs.c @@ -39,7 +39,7 @@ #include "mjpeg.h" #include "rgb32.h" -void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) +void *avi_format_convert(AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) { if (from == to) return buffer; @@ -53,32 +53,32 @@ void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat f } switch (to) { - case AVI_FORMAT_RGB24: - switch (from) { + case AVI_FORMAT_RGB24: + switch (from) { + case AVI_FORMAT_AVI_RGB: + buffer = avi_converter_from_avi_rgb(movie, stream, buffer, size); + break; + case AVI_FORMAT_MJPEG: + buffer = avi_converter_from_mjpeg(movie, stream, buffer, size); + break; + case AVI_FORMAT_RGB32: + buffer = avi_converter_from_rgb32(movie, stream, buffer, size); + break; + default: + break; + } + break; case AVI_FORMAT_AVI_RGB: - buffer = avi_converter_from_avi_rgb (movie, stream, buffer, size); + buffer = avi_converter_to_avi_rgb(movie, stream, buffer, size); break; case AVI_FORMAT_MJPEG: - buffer = avi_converter_from_mjpeg (movie, stream, buffer, size); + buffer = avi_converter_to_mjpeg(movie, stream, buffer, size); break; case AVI_FORMAT_RGB32: - buffer = avi_converter_from_rgb32 (movie, stream, buffer, size); + buffer = avi_converter_to_rgb32(movie, stream, buffer, size); break; default: break; - } - break; - case AVI_FORMAT_AVI_RGB: - buffer = avi_converter_to_avi_rgb (movie, stream, buffer, size); - break; - case AVI_FORMAT_MJPEG: - buffer = avi_converter_to_mjpeg (movie, stream, buffer, size); - break; - case AVI_FORMAT_RGB32: - buffer = avi_converter_to_rgb32 (movie, stream, buffer, size); - break; - default: - break; } return buffer; @@ -88,10 +88,10 @@ int avi_get_data_id(AviFormat format, int stream) { char fcc[5]; - if (avi_get_format_type (format) == FCC("vids")) - sprintf (fcc, "%2.2ddc", stream); - else if (avi_get_format_type (format) == FCC("auds")) - sprintf (fcc, "%2.2ddc", stream); + if (avi_get_format_type(format) == FCC("vids")) + sprintf(fcc, "%2.2ddc", stream); + else if (avi_get_format_type(format) == FCC("auds")) + sprintf(fcc, "%2.2ddc", stream); else return 0; @@ -101,48 +101,48 @@ int avi_get_data_id(AviFormat format, int stream) int avi_get_format_type(AviFormat format) { switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - case AVI_FORMAT_MJPEG: - return FCC("vids"); - break; - default: - return 0; - break; + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + case AVI_FORMAT_MJPEG: + return FCC("vids"); + break; + default: + return 0; + break; } } int avi_get_format_fcc(AviFormat format) { switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - return FCC("DIB "); - break; - case AVI_FORMAT_MJPEG: - return FCC("MJPG"); - break; - default: - return 0; - break; + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + return FCC("DIB "); + break; + case AVI_FORMAT_MJPEG: + return FCC("MJPG"); + break; + default: + return 0; + break; } } int avi_get_format_compression(AviFormat format) { switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - return 0; - break; - case AVI_FORMAT_MJPEG: - return FCC("MJPG"); - break; - default: - return 0; - break; + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + return 0; + break; + case AVI_FORMAT_MJPEG: + return FCC("MJPG"); + break; + default: + return 0; + break; } } diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c index fd8cc56f551..c9b95d25810 100644 --- a/source/blender/avi/intern/endian.c +++ b/source/blender/avi/intern/endian.c @@ -46,125 +46,125 @@ #endif #ifdef __BIG_ENDIAN__ -static void invert (int *num) +static void invert(int *num) { - int new=0, i, j; + int new = 0, i, j; - for (j=0; j < 4; j++) { - for (i=0; i<8; i++) { - new |= ((*num>>(j*8+i))&1)<<((3-j)*8+i); + for (j = 0; j < 4; j++) { + for (i = 0; i < 8; i++) { + new |= ((*num >> (j * 8 + i)) & 1) << ((3 - j) * 8 + i); } } *num = new; } -static void sinvert (short int *num) +static void sinvert(short int *num) { - short int new=0; + short int new = 0; int i, j; - for (j=0; j < 2; j++) { - for (i=0; i<8; i++) { - new |= ((*num>>(j*8+i))&1)<<((1-j)*8+i); + for (j = 0; j < 2; j++) { + for (i = 0; i < 8; i++) { + new |= ((*num >> (j * 8 + i)) & 1) << ((1 - j) * 8 + i); } } *num = new; } -static void Ichunk (AviChunk *chunk) +static void Ichunk(AviChunk *chunk) { - invert (&chunk->fcc); - invert (&chunk->size); + invert(&chunk->fcc); + invert(&chunk->size); } #endif #ifdef __BIG_ENDIAN__ -static void Ilist (AviList *list) +static void Ilist(AviList *list) { - invert (&list->fcc); - invert (&list->size); - invert (&list->ids); + invert(&list->fcc); + invert(&list->size); + invert(&list->ids); } -static void Imainh (AviMainHeader *mainh) +static void Imainh(AviMainHeader *mainh) { - invert (&mainh->fcc); - invert (&mainh->size); - invert (&mainh->MicroSecPerFrame); - invert (&mainh->MaxBytesPerSec); - invert (&mainh->PaddingGranularity); - invert (&mainh->Flags); - invert (&mainh->TotalFrames); - invert (&mainh->InitialFrames); - invert (&mainh->Streams); - invert (&mainh->SuggestedBufferSize); - invert (&mainh->Width); - invert (&mainh->Height); - invert (&mainh->Reserved[0]); - invert (&mainh->Reserved[1]); - invert (&mainh->Reserved[2]); - invert (&mainh->Reserved[3]); + invert(&mainh->fcc); + invert(&mainh->size); + invert(&mainh->MicroSecPerFrame); + invert(&mainh->MaxBytesPerSec); + invert(&mainh->PaddingGranularity); + invert(&mainh->Flags); + invert(&mainh->TotalFrames); + invert(&mainh->InitialFrames); + invert(&mainh->Streams); + invert(&mainh->SuggestedBufferSize); + invert(&mainh->Width); + invert(&mainh->Height); + invert(&mainh->Reserved[0]); + invert(&mainh->Reserved[1]); + invert(&mainh->Reserved[2]); + invert(&mainh->Reserved[3]); } -static void Istreamh (AviStreamHeader *streamh) +static void Istreamh(AviStreamHeader *streamh) { - invert (&streamh->fcc); - invert (&streamh->size); - invert (&streamh->Type); - invert (&streamh->Handler); - invert (&streamh->Flags); - sinvert (&streamh->Priority); - sinvert (&streamh->Language); - invert (&streamh->InitialFrames); - invert (&streamh->Scale); - invert (&streamh->Rate); - invert (&streamh->Start); - invert (&streamh->Length); - invert (&streamh->SuggestedBufferSize); - invert (&streamh->Quality); - invert (&streamh->SampleSize); - sinvert (&streamh->left); - sinvert (&streamh->right); - sinvert (&streamh->top); - sinvert (&streamh->bottom); + invert(&streamh->fcc); + invert(&streamh->size); + invert(&streamh->Type); + invert(&streamh->Handler); + invert(&streamh->Flags); + sinvert(&streamh->Priority); + sinvert(&streamh->Language); + invert(&streamh->InitialFrames); + invert(&streamh->Scale); + invert(&streamh->Rate); + invert(&streamh->Start); + invert(&streamh->Length); + invert(&streamh->SuggestedBufferSize); + invert(&streamh->Quality); + invert(&streamh->SampleSize); + sinvert(&streamh->left); + sinvert(&streamh->right); + sinvert(&streamh->top); + sinvert(&streamh->bottom); } -static void Ibitmaph (AviBitmapInfoHeader *bitmaph) +static void Ibitmaph(AviBitmapInfoHeader *bitmaph) { - invert (&bitmaph->fcc); - invert (&bitmaph->size); - invert (&bitmaph->Size); - invert (&bitmaph->Width); - invert (&bitmaph->Height); - sinvert (&bitmaph->Planes); - sinvert (&bitmaph->BitCount); - invert (&bitmaph->Compression); - invert (&bitmaph->SizeImage); - invert (&bitmaph->XPelsPerMeter); - invert (&bitmaph->YPelsPerMeter); - invert (&bitmaph->ClrUsed); - invert (&bitmaph->ClrImportant); + invert(&bitmaph->fcc); + invert(&bitmaph->size); + invert(&bitmaph->Size); + invert(&bitmaph->Width); + invert(&bitmaph->Height); + sinvert(&bitmaph->Planes); + sinvert(&bitmaph->BitCount); + invert(&bitmaph->Compression); + invert(&bitmaph->SizeImage); + invert(&bitmaph->XPelsPerMeter); + invert(&bitmaph->YPelsPerMeter); + invert(&bitmaph->ClrUsed); + invert(&bitmaph->ClrImportant); } -static void Imjpegu (AviMJPEGUnknown *mjpgu) +static void Imjpegu(AviMJPEGUnknown *mjpgu) { - invert (&mjpgu->a); - invert (&mjpgu->b); - invert (&mjpgu->c); - invert (&mjpgu->d); - invert (&mjpgu->e); - invert (&mjpgu->f); - invert (&mjpgu->g); + invert(&mjpgu->a); + invert(&mjpgu->b); + invert(&mjpgu->c); + invert(&mjpgu->d); + invert(&mjpgu->e); + invert(&mjpgu->f); + invert(&mjpgu->g); } -static void Iindexe (AviIndexEntry *indexe) +static void Iindexe(AviIndexEntry *indexe) { - invert (&indexe->ChunkId); - invert (&indexe->Flags); - invert (&indexe->Offset); - invert (&indexe->Size); + invert(&indexe->ChunkId); + invert(&indexe->Flags); + invert(&indexe->Offset); + invert(&indexe->Size); } #endif /* __BIG_ENDIAN__ */ @@ -173,53 +173,53 @@ void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int ty #ifdef __BIG_ENDIAN__ void *data; - data = MEM_mallocN (size, "avi endian"); + data = MEM_mallocN(size, "avi endian"); - memcpy (data, datain, size); + memcpy(data, datain, size); switch (type) { - case AVI_RAW: - fwrite (data, block, size, fp); - break; - case AVI_CHUNK: - Ichunk ((AviChunk *) data); - fwrite (data, block, size, fp); - break; - case AVI_LIST: - Ilist ((AviList *) data); - fwrite (data, block, size, fp); - break; - case AVI_MAINH: - Imainh ((AviMainHeader *) data); - fwrite (data, block, size, fp); - break; - case AVI_STREAMH: - Istreamh ((AviStreamHeader *) data); - fwrite (data, block, size, fp); - break; - case AVI_BITMAPH: - Ibitmaph ((AviBitmapInfoHeader *) data); - if (size==sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown)) { - Imjpegu((AviMJPEGUnknown*)((char*)data+sizeof(AviBitmapInfoHeader))); - } - fwrite (data, block, size, fp); - break; - case AVI_MJPEGU: - Imjpegu ((AviMJPEGUnknown *) data); - fwrite (data, block, size, fp); - break; - case AVI_INDEXE: - Iindexe ((AviIndexEntry *) data); - fwrite (data, block, size, fp); - break; - default: - break; + case AVI_RAW: + fwrite(data, block, size, fp); + break; + case AVI_CHUNK: + Ichunk((AviChunk *) data); + fwrite(data, block, size, fp); + break; + case AVI_LIST: + Ilist((AviList *) data); + fwrite(data, block, size, fp); + break; + case AVI_MAINH: + Imainh((AviMainHeader *) data); + fwrite(data, block, size, fp); + break; + case AVI_STREAMH: + Istreamh((AviStreamHeader *) data); + fwrite(data, block, size, fp); + break; + case AVI_BITMAPH: + Ibitmaph((AviBitmapInfoHeader *) data); + if (size == sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown)) { + Imjpegu((AviMJPEGUnknown *)((char *)data + sizeof(AviBitmapInfoHeader))); + } + fwrite(data, block, size, fp); + break; + case AVI_MJPEGU: + Imjpegu((AviMJPEGUnknown *) data); + fwrite(data, block, size, fp); + break; + case AVI_INDEXE: + Iindexe((AviIndexEntry *) data); + fwrite(data, block, size, fp); + break; + default: + break; } - MEM_freeN (data); + MEM_freeN(data); #else /* __BIG_ENDIAN__ */ (void)movie; /* unused */ (void)type; /* unused */ - fwrite (datain, block, size, fp); + fwrite(datain, block, size, fp); #endif /* __BIG_ENDIAN__ */ } diff --git a/source/blender/avi/intern/mjpeg.c b/source/blender/avi/intern/mjpeg.c index 29356f8ef28..a700284bf68 100644 --- a/source/blender/avi/intern/mjpeg.c +++ b/source/blender/avi/intern/mjpeg.c @@ -42,14 +42,14 @@ #include "mjpeg.h" -#define PADUP(num, amt) ((num+(amt-1))&~(amt-1)) +#define PADUP(num, amt) ((num + (amt - 1)) & ~(amt - 1)) -static void jpegmemdestmgr_build (j_compress_ptr cinfo, unsigned char *buffer, int bufsize); -static void jpegmemsrcmgr_build (j_decompress_ptr dinfo, unsigned char *buffer, int bufsize); +static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize); +static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize); static int numbytes; -static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) +static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) { if (*htblptr == NULL) *htblptr = jpeg_alloc_huff_table((j_common_ptr) dinfo); @@ -64,25 +64,30 @@ static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const U /* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ /* IMPORTANT: these are only valid for 8-bit data precision! */ -static void std_huff_tables (j_decompress_ptr dinfo) +static void std_huff_tables(j_decompress_ptr dinfo) { static const UINT8 bits_dc_luminance[17] = { /* 0-base */ - 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 + }; static const UINT8 val_dc_luminance[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + }; static const UINT8 bits_dc_chrominance[17] = { /* 0-base */ - 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 + }; static const UINT8 val_dc_chrominance[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + }; static const UINT8 bits_ac_luminance[17] = { /* 0-base */ - 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d + }; static const UINT8 val_ac_luminance[] = { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, @@ -105,10 +110,12 @@ static void std_huff_tables (j_decompress_ptr dinfo) 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; + 0xf9, 0xfa + }; static const UINT8 bits_ac_chrominance[17] = { /* 0-base */ - 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 + }; static const UINT8 val_ac_chrominance[] = { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, @@ -131,16 +138,17 @@ static void std_huff_tables (j_decompress_ptr dinfo) 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; + 0xf9, 0xfa + }; add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); + bits_dc_luminance, val_dc_luminance); add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); + bits_ac_luminance, val_ac_luminance); add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); + bits_dc_chrominance, val_dc_chrominance); add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); + bits_ac_chrominance, val_ac_chrominance); } static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize) @@ -152,7 +160,7 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign (void)width; /* unused */ - numbytes= 0; + numbytes = 0; dinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&dinfo); @@ -166,8 +174,8 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign jpeg_start_decompress(&dinfo); - rowstride= dinfo.output_width*dinfo.output_components; - for (y= 0; y= height) return 0; - inBuffer+= numbytes; - jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize-numbytes); + inBuffer += numbytes; + jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize - numbytes); - numbytes= 0; + numbytes = 0; jpeg_read_header(&dinfo, TRUE); if (dinfo.dc_huff_tbl_ptrs[0] == NULL) { std_huff_tables(&dinfo); } jpeg_start_decompress(&dinfo); - rowstride= dinfo.output_width*dinfo.output_components; - for (y= 0; ysent_table = TRUE; cinfo.dc_huff_tbl_ptrs[1]->sent_table = TRUE; @@ -232,24 +240,24 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char * jpeg_start_compress(&cinfo, FALSE); - i=0; + i = 0; marker[i++] = 'A'; marker[i++] = 'V'; marker[i++] = 'I'; marker[i++] = '1'; marker[i++] = 0; - while (i<60) + while (i < 60) marker[i++] = 32; - jpeg_write_marker (&cinfo, JPEG_APP0, marker, 60); + jpeg_write_marker(&cinfo, JPEG_APP0, marker, 60); - i=0; - while (i<60) + i = 0; + while (i < 60) marker[i++] = 0; - jpeg_write_marker (&cinfo, JPEG_COM, marker, 60); + jpeg_write_marker(&cinfo, JPEG_COM, marker, 60); - rowstride= cinfo.image_width*cinfo.input_components; + rowstride = cinfo.image_width * cinfo.input_components; for (y = 0; y < cinfo.image_height; y++) { jpeg_write_scanlines(&cinfo, (JSAMPARRAY) &inBuffer, 1); inBuffer += rowstride; @@ -260,43 +268,43 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char * static void interlace(unsigned char *to, unsigned char *from, int width, int height) { - int i, rowstride= width*3; + int i, rowstride = width * 3; - for (i=0; iheader->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 1"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 1"); - deint= check_and_decode_jpeg(buffer, buf, movie->header->Width, movie->header->Height, *size); + deint = check_and_decode_jpeg(buffer, buf, movie->header->Width, movie->header->Height, *size); MEM_freeN(buffer); if (deint) { - buffer = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 2"); - interlace (buffer, buf, movie->header->Width, movie->header->Height); - MEM_freeN (buf); + buffer = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 2"); + interlace(buffer, buf, movie->header->Width, movie->header->Height); + MEM_freeN(buf); - buf= buffer; + buf = buffer; } return buf; } -void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size) { unsigned char *buf; - int bufsize= *size; + int bufsize = *size; numbytes = 0; - *size= 0; + *size = 0; - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 1"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 1"); if (!movie->interlace) { - check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf, buffer, movie->header->Width, movie->header->Height, bufsize); + check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf, buffer, movie->header->Width, movie->header->Height, bufsize); } else { - deinterlace (movie->odd_fields, buf, buffer, movie->header->Width, movie->header->Height); - MEM_freeN (buffer); + deinterlace(movie->odd_fields, buf, buffer, movie->header->Width, movie->header->Height); + MEM_freeN(buffer); - buffer= buf; - buf= MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 2"); + buffer = buf; + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 2"); - check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf, buffer, movie->header->Width, movie->header->Height/2, bufsize/2); - *size+= numbytes; - numbytes=0; - check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf+*size, buffer+(movie->header->Height/2)*movie->header->Width*3, movie->header->Width, movie->header->Height/2, bufsize/2); + check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf, buffer, movie->header->Width, movie->header->Height / 2, bufsize / 2); + *size += numbytes; + numbytes = 0; + check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf + *size, buffer + (movie->header->Height / 2) * movie->header->Width * 3, movie->header->Width, movie->header->Height / 2, bufsize / 2); } *size += numbytes; - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } @@ -405,23 +413,23 @@ static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo) static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo) { - numbytes-= cinfo->dest->free_in_buffer; + numbytes -= cinfo->dest->free_in_buffer; MEM_freeN(cinfo->dest); } static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize) { - cinfo->dest= MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build"); + cinfo->dest = MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build"); - cinfo->dest->init_destination= jpegmemdestmgr_init_destination; - cinfo->dest->empty_output_buffer= jpegmemdestmgr_empty_output_buffer; - cinfo->dest->term_destination= jpegmemdestmgr_term_destination; + cinfo->dest->init_destination = jpegmemdestmgr_init_destination; + cinfo->dest->empty_output_buffer = jpegmemdestmgr_empty_output_buffer; + cinfo->dest->term_destination = jpegmemdestmgr_term_destination; - cinfo->dest->next_output_byte= buffer; - cinfo->dest->free_in_buffer= bufsize; + cinfo->dest->next_output_byte = buffer; + cinfo->dest->free_in_buffer = bufsize; - numbytes= bufsize; + numbytes = bufsize; } /* Decompression from memory */ @@ -433,48 +441,48 @@ static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo) static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) { - unsigned char *buf= (unsigned char*) dinfo->src->next_input_byte-2; + unsigned char *buf = (unsigned char *) dinfo->src->next_input_byte - 2; - /* if we get called, must have run out of data */ + /* if we get called, must have run out of data */ WARNMS(dinfo, JWRN_JPEG_EOF); - buf[0]= (JOCTET) 0xFF; - buf[1]= (JOCTET) JPEG_EOI; + buf[0] = (JOCTET) 0xFF; + buf[1] = (JOCTET) JPEG_EOI; - dinfo->src->next_input_byte= buf; - dinfo->src->bytes_in_buffer= 2; + dinfo->src->next_input_byte = buf; + dinfo->src->bytes_in_buffer = 2; return TRUE; } static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt) { - if (dinfo->src->bytes_in_buffersrc->bytes_in_buffer; + if (dinfo->src->bytes_in_buffer < skipcnt) + skipcnt = dinfo->src->bytes_in_buffer; - dinfo->src->next_input_byte+= skipcnt; - dinfo->src->bytes_in_buffer-= skipcnt; + dinfo->src->next_input_byte += skipcnt; + dinfo->src->bytes_in_buffer -= skipcnt; } static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo) { - numbytes-= dinfo->src->bytes_in_buffer; + numbytes -= dinfo->src->bytes_in_buffer; MEM_freeN(dinfo->src); } static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize) { - dinfo->src= MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build"); + dinfo->src = MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build"); - dinfo->src->init_source= jpegmemsrcmgr_init_source; - dinfo->src->fill_input_buffer= jpegmemsrcmgr_fill_input_buffer; - dinfo->src->skip_input_data= jpegmemsrcmgr_skip_input_data; - dinfo->src->resync_to_restart= jpeg_resync_to_restart; - dinfo->src->term_source= jpegmemsrcmgr_term_source; + dinfo->src->init_source = jpegmemsrcmgr_init_source; + dinfo->src->fill_input_buffer = jpegmemsrcmgr_fill_input_buffer; + dinfo->src->skip_input_data = jpegmemsrcmgr_skip_input_data; + dinfo->src->resync_to_restart = jpeg_resync_to_restart; + dinfo->src->term_source = jpegmemsrcmgr_term_source; - dinfo->src->bytes_in_buffer= bufsize; - dinfo->src->next_input_byte= buffer; + dinfo->src->bytes_in_buffer = bufsize; + dinfo->src->next_input_byte = buffer; - numbytes= bufsize; + numbytes = bufsize; } diff --git a/source/blender/avi/intern/options.c b/source/blender/avi/intern/options.c index db9719c171d..7de91318ecf 100644 --- a/source/blender/avi/intern/options.c +++ b/source/blender/avi/intern/options.c @@ -54,78 +54,78 @@ AviError AVI_set_compress_option(AviMovie *movie, int option_type, int stream, A return AVI_ERROR_OPTION; switch (option_type) { - case AVI_OPTION_TYPE_MAIN: - switch (option) { - case AVI_OPTION_WIDTH: - movie->header->Width = *((int *) opt_data); - movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; + case AVI_OPTION_TYPE_MAIN: + switch (option) { + case AVI_OPTION_WIDTH: + movie->header->Width = *((int *) opt_data); + movie->header->SuggestedBufferSize = movie->header->Width * movie->header->Height * 3; + + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); + movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; + movie->streams[i].sh.right = *((int *) opt_data); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } + + break; + + case AVI_OPTION_HEIGHT: + movie->header->Height = *((int *) opt_data); + movie->header->SuggestedBufferSize = movie->header->Width * movie->header->Height * 3; + + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); + movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; + movie->streams[i].sh.bottom = *((int *) opt_data); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } + + break; + + case AVI_OPTION_QUALITY: + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + movie->streams[i].sh.Quality = (*((int *) opt_data)) * 100; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } + break; + + case AVI_OPTION_FRAMERATE: + useconds = (int)(1000000 / (*((double *) opt_data))); + if (useconds) + movie->header->MicroSecPerFrame = useconds; + + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); - movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; - movie->streams[i].sh.right = *((int *) opt_data); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } } + fseek(movie->fp, movie->offset_table[0], SEEK_SET); + awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + break; - - case AVI_OPTION_HEIGHT: - movie->header->Height = *((int *) opt_data); - movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); - movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; - movie->streams[i].sh.bottom = *((int *) opt_data); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } - } - + case AVI_OPTION_TYPE_STRH: break; - - case AVI_OPTION_QUALITY: - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - movie->streams[i].sh.Quality = (*((int *) opt_data))*100; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } - } + case AVI_OPTION_TYPE_STRF: + break; + default: + return AVI_ERROR_OPTION; break; - - case AVI_OPTION_FRAMERATE: - useconds = (int)(1000000/(*((double *) opt_data))); - if (useconds) - movie->header->MicroSecPerFrame = useconds; - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } - } - - } - - fseek (movie->fp, movie->offset_table[0], SEEK_SET); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); - - break; - case AVI_OPTION_TYPE_STRH: - break; - case AVI_OPTION_TYPE_STRF: - break; - default: - return AVI_ERROR_OPTION; - break; } return AVI_ERROR_NONE; diff --git a/source/blender/avi/intern/rgb32.c b/source/blender/avi/intern/rgb32.c index 7b4958ca026..84630f09fe5 100644 --- a/source/blender/avi/intern/rgb32.c +++ b/source/blender/avi/intern/rgb32.c @@ -39,33 +39,33 @@ #include "MEM_guardedalloc.h" #include "rgb32.h" -void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int y, x, rowstridea, rowstrideb; unsigned char *buf; (void)stream; /* unused */ - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromrgb32buf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromrgb32buf"); *size = movie->header->Height * movie->header->Width * 3; - rowstridea = movie->header->Width*3; - rowstrideb = movie->header->Width*4; + rowstridea = movie->header->Width * 3; + rowstrideb = movie->header->Width * 4; - for (y=0; y < movie->header->Height; y++) { - for (x=0; x < movie->header->Width; x++) { - buf[y*rowstridea + x*3 + 0] = buffer[y*rowstrideb + x*4 + 3]; - buf[y*rowstridea + x*3 + 1] = buffer[y*rowstrideb + x*4 + 2]; - buf[y*rowstridea + x*3 + 2] = buffer[y*rowstrideb + x*4 + 1]; + for (y = 0; y < movie->header->Height; y++) { + for (x = 0; x < movie->header->Width; x++) { + buf[y * rowstridea + x * 3 + 0] = buffer[y * rowstrideb + x * 4 + 3]; + buf[y * rowstridea + x * 3 + 1] = buffer[y * rowstrideb + x * 4 + 2]; + buf[y * rowstridea + x * 3 + 2] = buffer[y * rowstrideb + x * 4 + 1]; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } -void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int i; unsigned char *buf; @@ -73,20 +73,20 @@ void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer (void)stream; /* unused */ - buf= MEM_mallocN (movie->header->Height * movie->header->Width * 4, "torgb32buf"); - *size= movie->header->Height * movie->header->Width * 4; + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 4, "torgb32buf"); + *size = movie->header->Height * movie->header->Width * 4; memset(buf, 255, *size); - to= buf; from= buffer; - i=movie->header->Height*movie->header->Width; + to = buf; from = buffer; + i = movie->header->Height * movie->header->Width; while (i--) { memcpy(to, from, 3); - to+=4; from+=3; + to += 4; from += 3; } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } From f44e80e6387601dea6e4e0801d0a387455a02d31 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 7 May 2012 19:08:01 +0000 Subject: [PATCH 137/143] Collada: patch #31331: added missing call to BKE_mesh_tessface_ensure() when 'apply Modifiers' was NOT selected --- source/blender/collada/GeometryExporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 8c7bff285eb..05d4080dcb6 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -79,8 +79,8 @@ Mesh * GeometryExporter::get_mesh(Object *ob, int apply_modifiers) tmpmesh = BKE_mesh_add("ColladaMesh"); // name is not important here DM_to_mesh(dm, tmpmesh, ob); dm->release(dm); - BKE_mesh_tessface_ensure(tmpmesh); } + BKE_mesh_tessface_ensure(tmpmesh); return tmpmesh; } From e6a84eb1b542e7cafe5e760530882bb806f3c433 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 7 May 2012 20:24:38 +0000 Subject: [PATCH 138/143] Cycles: add light falloff node, with quadratic/linear/constant falloff and a smoothing factor to reduce high values near the light. http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Light_Falloff Note that this was already possible to do manually with the Ray Length, but this adds a convenient node for it. This commit also makes the mapping node min/max option work, fixing #31348. --- intern/cycles/blender/blender_shader.cpp | 11 + intern/cycles/kernel/svm/svm.h | 6 + intern/cycles/kernel/svm/svm_light_path.h | 27 + intern/cycles/kernel/svm/svm_mapping.h | 11 + intern/cycles/kernel/svm/svm_types.h | 10 +- intern/cycles/render/nodes.cpp | 61 + intern/cycles/render/nodes.h | 8 + source/blender/blenkernel/BKE_node.h | 5 +- source/blender/blenkernel/intern/node.c | 1 + .../gpu/shaders/gpu_shader_material.glsl | 7 + .../gpu/shaders/gpu_shader_material.glsl.c | 3201 ++++++++--------- .../makesrna/intern/rna_nodetree_types.h | 3 +- source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_shader.h | 1 + .../shader/nodes/node_shader_light_falloff.c | 68 + 15 files changed, 1785 insertions(+), 1636 deletions(-) create mode 100644 source/blender/nodes/shader/nodes/node_shader_light_falloff.c diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 52d97753db3..b33de789631 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -97,6 +97,13 @@ static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_map mapping->translation = get_float3(b_mapping.translation()); mapping->rotation = get_float3(b_mapping.rotation()); mapping->scale = get_float3(b_mapping.scale()); + + mapping->use_minmax = b_mapping.use_min() || b_mapping.use_max(); + + if(b_mapping.use_min()) + mapping->min = get_float3(b_mapping.min()); + if(b_mapping.use_max()) + mapping->max = get_float3(b_mapping.max()); } static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNode b_node) @@ -323,6 +330,10 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Shader node = new LightPathNode(); break; } + case BL::ShaderNode::type_LIGHT_FALLOFF: { + node = new LightFalloffNode(); + break; + } case BL::ShaderNode::type_TEX_IMAGE: { BL::ShaderNodeTexImage b_image_node(b_node); BL::Image b_image(b_image_node.image()); diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 50181c0cf2c..5f4d7bbd0c4 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -326,6 +326,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT case NODE_MAPPING: svm_node_mapping(kg, sd, stack, node.y, node.z, &offset); break; + case NODE_MIN_MAX: + svm_node_min_max(kg, sd, stack, node.y, node.z, &offset); + break; case NODE_TEX_COORD: svm_node_tex_coord(kg, sd, stack, node.y, node.z); break; @@ -344,6 +347,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT case NODE_RGB_CURVES: svm_node_rgb_curves(kg, sd, stack, node, &offset); break; + case NODE_LIGHT_FALLOFF: + svm_node_light_falloff(sd, stack, node); + break; case NODE_END: default: #ifndef __MULTI_CLOSURE__ diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h index ebbcb5be61f..b29dc9cbd45 100644 --- a/intern/cycles/kernel/svm/svm_light_path.h +++ b/intern/cycles/kernel/svm/svm_light_path.h @@ -39,5 +39,32 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint stack_store_float(stack, out_offset, info); } +/* Light Falloff Node */ + +__device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node) +{ + uint strength_offset, out_offset, smooth_offset; + + decode_node_uchar4(node.z, &strength_offset, &smooth_offset, &out_offset, NULL); + + float strength = stack_load_float(stack, strength_offset); + uint type = node.y; + + switch(type) { + case NODE_LIGHT_FALLOFF_QUADRATIC: break; + case NODE_LIGHT_FALLOFF_LINEAR: strength *= sd->ray_length; break; + case NODE_LIGHT_FALLOFF_CONSTANT: strength *= sd->ray_length*sd->ray_length; break; + } + + float smooth = stack_load_float(stack, smooth_offset); + + if(smooth > 0.0f) { + float squared = sd->ray_length*sd->ray_length; + strength *= squared/(smooth + squared); + } + + stack_store_float(stack, out_offset, strength); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h index 6dc74aece08..96645ac97db 100644 --- a/intern/cycles/kernel/svm/svm_mapping.h +++ b/intern/cycles/kernel/svm/svm_mapping.h @@ -34,5 +34,16 @@ __device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, stack_store_float3(stack, out_offset, r); } +__device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset) +{ + float3 v = stack_load_float3(stack, vec_offset); + + float3 mn = float4_to_float3(read_node_float(kg, offset)); + float3 mx = float4_to_float3(read_node_float(kg, offset)); + + float3 r = min(max(mn, v), mx); + stack_store_float3(stack, out_offset, r); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 8037c3964a9..867709f29e0 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -90,7 +90,9 @@ typedef enum NodeType { NODE_TEX_CHECKER = 5700, NODE_BRIGHTCONTRAST = 5800, NODE_RGB_RAMP = 5900, - NODE_RGB_CURVES = 6000 + NODE_RGB_CURVES = 6000, + NODE_MIN_MAX = 6100, + NODE_LIGHT_FALLOFF = 6200 } NodeType; typedef enum NodeAttributeType { @@ -119,6 +121,12 @@ typedef enum NodeLightPath { NODE_LP_ray_length } NodeLightPath; +typedef enum NodeLightFalloff { + NODE_LIGHT_FALLOFF_QUADRATIC, + NODE_LIGHT_FALLOFF_LINEAR, + NODE_LIGHT_FALLOFF_CONSTANT +} NodeLightFalloff; + typedef enum NodeTexCoord { NODE_TEXCO_NORMAL, NODE_TEXCO_OBJECT, diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index fd26c552f21..afc59098432 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -33,6 +33,11 @@ TextureMapping::TextureMapping() rotation = make_float3(0.0f, 0.0f, 0.0f); scale = make_float3(1.0f, 1.0f, 1.0f); + min = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX); + max = make_float3(FLT_MAX, FLT_MAX, FLT_MAX); + + use_minmax = false; + x_mapping = X; y_mapping = Y; z_mapping = Z; @@ -69,6 +74,8 @@ bool TextureMapping::skip() if(x_mapping != X || y_mapping != Y || z_mapping != Z) return false; + if(use_minmax) + return false; return true; } @@ -85,6 +92,12 @@ void TextureMapping::compile(SVMCompiler& compiler, int offset_in, int offset_ou compiler.add_node(tfm.y); compiler.add_node(tfm.z); compiler.add_node(tfm.w); + + if(use_minmax) { + compiler.add_node(NODE_MIN_MAX, offset_out, offset_out); + compiler.add_node(float3_to_float4(min)); + compiler.add_node(float3_to_float4(max)); + } } /* Image Texture */ @@ -1686,6 +1699,54 @@ void LightPathNode::compile(OSLCompiler& compiler) compiler.add(this, "node_light_path"); } +/* Light Path */ + +LightFalloffNode::LightFalloffNode() +: ShaderNode("light_path") +{ + add_input("Strength", SHADER_SOCKET_FLOAT, 100.0f); + add_input("Smooth", SHADER_SOCKET_FLOAT, 0.0f); + add_output("Quadratic", SHADER_SOCKET_FLOAT); + add_output("Linear", SHADER_SOCKET_FLOAT); + add_output("Constant", SHADER_SOCKET_FLOAT); +} + +void LightFalloffNode::compile(SVMCompiler& compiler) +{ + ShaderInput *strength_in = input("Strength"); + ShaderInput *smooth_in = input("Smooth"); + + compiler.stack_assign(strength_in); + compiler.stack_assign(smooth_in); + + ShaderOutput *out = output("Quadratic"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_QUADRATIC, + compiler.encode_uchar4(strength_in->stack_offset, smooth_in->stack_offset, out->stack_offset)); + } + + out = output("Linear"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_LINEAR, + compiler.encode_uchar4(strength_in->stack_offset, smooth_in->stack_offset, out->stack_offset)); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_LINEAR, out->stack_offset); + } + + out = output("Constant"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_CONSTANT, + compiler.encode_uchar4(strength_in->stack_offset, smooth_in->stack_offset, out->stack_offset)); + } +} + +void LightFalloffNode::compile(OSLCompiler& compiler) +{ + compiler.add(this, "node_light_falloff"); +} + /* Value */ ValueNode::ValueNode() diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 364209f8c5e..ff9e3647d01 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -41,6 +41,9 @@ public: float3 rotation; float3 scale; + float3 min, max; + bool use_minmax; + enum Mapping { NONE=0, X=1, Y=2, Z=3 }; Mapping x_mapping, y_mapping, z_mapping; @@ -277,6 +280,11 @@ public: SHADER_NODE_CLASS(LightPathNode) }; +class LightFalloffNode : public ShaderNode { +public: + SHADER_NODE_CLASS(LightFalloffNode) +}; + class ValueNode : public ShaderNode { public: SHADER_NODE_CLASS(ValueNode) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index e7e1577c6b4..fcb56bf8027 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -508,9 +508,10 @@ struct ShadeResult; #define SH_NODE_LAYER_WEIGHT 160 #define SH_NODE_VOLUME_TRANSPARENT 161 #define SH_NODE_VOLUME_ISOTROPIC 162 -#define SH_NODE_GAMMA 163 -#define SH_NODE_TEX_CHECKER 164 +#define SH_NODE_GAMMA 163 +#define SH_NODE_TEX_CHECKER 164 #define SH_NODE_BRIGHTCONTRAST 165 +#define SH_NODE_LIGHT_FALLOFF 166 /* custom defines options for Material node */ #define SH_NODE_MAT_DIFF 1 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7832947be73..07122a1ec4d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1969,6 +1969,7 @@ static void registerShaderNodes(bNodeTreeType *ttype) register_node_type_sh_attribute(ttype); register_node_type_sh_geometry(ttype); register_node_type_sh_light_path(ttype); + register_node_type_sh_light_falloff(ttype); register_node_type_sh_fresnel(ttype); register_node_type_sh_layer_weight(ttype); register_node_type_sh_tex_coord(ttype); diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 5500e6bf171..fdd2a2c95b9 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2188,6 +2188,13 @@ void node_light_path( is_transmission_ray = 0.0; } +void node_light_falloff(float strength, float smooth, out float quadratic, out float linear, out float constant) +{ + quadratic = strength; + linear = strength; + constant = strength; +} + /* output */ void node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 result) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl.c b/source/blender/gpu/shaders/gpu_shader_material.glsl.c index b8086ed9c0a..6dea1ae65c5 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl.c +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl.c @@ -1,1658 +1,1595 @@ /* DataToC output of file */ -int datatoc_gpu_shader_material_glsl_size = 52836; +int datatoc_gpu_shader_material_glsl_size = 50822; char datatoc_gpu_shader_material_glsl[] = { - 13, 10,102,108, -111, 97,116, 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 13, 10,123, 13, 10, 9,114,101, -116,117,114,110, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,102, 41, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,114,103, 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32, -118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109, -105,110, 44, 32,104, 44, 32,115, 44, 32,118, 44, 32, 99,100,101,108,116, 97, 59, 13, 10, 9,118,101, 99, 51, 32, 99, 59, 13, 10, - 13, 10, 9, 99,109, 97,120, 32, 61, 32,109, 97,120, 40,114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, - 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 13, 10, 9, 99,109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, - 32,109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 13, 10, 9, 99,100,101,108,116, 97, 32, - 61, 32, 99,109, 97,120, 45, 99,109,105,110, 59, 13, 10, 13, 10, 9,118, 32, 61, 32, 99,109, 97,120, 59, 13, 10, 9,105,102, 32, - 40, 99,109, 97,120, 33, 61, 48, 46, 48, 41, 13, 10, 9, 9,115, 32, 61, 32, 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 13, - 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, - 13, 10, 9,125, 13, 10, 13, 10, 9,105,102, 32, 40,115, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,104, 32, 61, 32, - 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 99, 32, 61, 32, 40,118,101, 99, 51, 40, 99, -109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,114,103, 98, 46,120,121,122, 41, 47, 99,100,101,108, -116, 97, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,114,103, 98, 46,120, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, 91, - 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,114,103, 98, 46,121, 61, 61, 99,109, - 97,120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32, 45, 32, 32, 99, 91, 50, 93, 59, 13, 10, 9, 9,101, -108,115,101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45, 32, 99, 91, 48, 93, 59, 13, 10, 13, 10, 9, 9, -104, 32, 47, 61, 32, 54, 46, 48, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,104, 60, 48, 46, 48, 41, 13, 10, 9, 9, 9,104, 32, - 43, 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,104, 44, - 32,115, 44, 32,118, 44, 32,114,103, 98, 46,119, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,104,115,118, 95,116,111, - 95,114,103, 98, 40,118,101, 99, 52, 32,104,115,118, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,105, 44, 32,102, 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32, -118, 59, 13, 10, 9,118,101, 99, 51, 32,114,103, 98, 59, 13, 10, 13, 10, 9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 13, 10, - 9,115, 32, 61, 32,104,115,118, 91, 49, 93, 59, 13, 10, 9,118, 32, 61, 32,104,115,118, 91, 50, 93, 59, 13, 10, 13, 10, 9,105, -102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,118, 44, 32, -118, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,105,102, 40,104, 61, 61, 49, 46, 48, 41, 13, 10, - 9, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9, 13, 10, 9, 9,104, 32, 42, 61, 32, 54, 46, 48, 59, 13, 10, 9, 9, -105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 13, 10, 9, 9,102, 32, 61, 32,104, 32, 45, 32,105, 59, 13, 10, 9, 9,114, -103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 13, 10, 9, 9,112, 32, 61, 32,118, 42, 40, 49, 46, - 48, 45,115, 41, 59, 13, 10, 9, 9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42,102, 41, 41, 59, 13, 10, 9, 9,116, - 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41, 41, 59, 13, 10, 9, 9, 13, 10, 9, 9,105, -102, 32, 40,105, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,116, 44, 32,112, 41, - 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, - 99, 51, 40,113, 44, 32,118, 44, 32,112, 41, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 50, 46, - 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 13, 10, 9, 9,101,108,115,101, 32, -105,102, 32, 40,105, 32, 61, 61, 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,113, 44, 32,118, - 41, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118, -101, 99, 51, 40,116, 44, 32,112, 44, 32,118, 41, 59, 13, 10, 9, 9,101,108,115,101, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, - 40,118, 44, 32,112, 44, 32,113, 41, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, - 40,114,103, 98, 44, 32,104,115,118, 46,119, 41, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,115,114,103, 98, 95,116, -111, 95,108,105,110,101, 97,114,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 13, 10,123, 13, 10, 9,105,102, 40, 99, 32, 60, - 32, 48, 46, 48, 52, 48, 52, 53, 41, 13, 10, 9, 9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, - 46, 48, 58, 32, 99, 32, 42, 32, 40, 49, 46, 48, 47, 49, 50, 46, 57, 50, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,114, -101,116,117,114,110, 32,112,111,119, 40, 40, 99, 32, 43, 32, 48, 46, 48, 53, 53, 41, 42, 40, 49, 46, 48, 47, 49, 46, 48, 53, 53, - 41, 44, 32, 50, 46, 52, 41, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,108,105,110,101, 97,114,114,103, 98, 95,116, -111, 95,115,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 13, 10,123, 13, 10, 9,105,102, 40, 99, 32, 60, 32, 48, 46, 48, 48, - 51, 49, 51, 48, 56, 41, 13, 10, 9, 9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, 46, 48, 58, - 32, 99, 32, 42, 32, 49, 50, 46, 57, 50, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,114,101,116,117,114,110, 32, 49, 46, 48, - 53, 53, 32, 42, 32,112,111,119, 40, 99, 44, 32, 49, 46, 48, 47, 50, 46, 52, 41, 32, 45, 32, 48, 46, 48, 53, 53, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40,118,101, 99, 52, 32, - 99,111,108, 95,102,114,111,109, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 13, 10,123, 13, 10, 9, - 99,111,108, 95,116,111, 46,114, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, - 95,102,114,111,109, 46,114, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46,103, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108, -105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,103, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46, 98, - 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, - 59, 13, 10, 9, 99,111,108, 95,116,111, 46, 97, 32, 61, 32, 99,111,108, 95,102,114,111,109, 46, 97, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, - 95,102,114,111,109, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 13, 10,123, 13, 10, 9, 99,111,108, - 95,116,111, 46,114, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114, -111,109, 46,114, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46,103, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, - 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,103, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46, 98, 32, 61, 32, -108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, 59, 13, 10, - 9, 99,111,108, 95,116,111, 46, 97, 32, 61, 32, 99,111,108, 95,102,114,111,109, 46, 97, 59, 13, 10,125, 13, 10, 13, 10, 35,100, -101,102,105,110,101, 32, 77, 95, 80, 73, 32, 51, 46, 49, 52, 49, 53, 57, 50, 54, 53, 51, 53, 56, 57, 55, 57, 51, 50, 51, 56, 52, - 54, 13, 10, 35,100,101,102,105,110,101, 32, 77, 95, 49, 95, 80, 73, 32, 48, 46, 51, 49, 56, 51, 48, 57, 56, 56, 54, 49, 56, 51, - 55, 57, 48, 54, 57, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, - 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,118, 99,111,108, - 95, 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 52, 32, 97,116,116,118, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, - 52, 32,118, 99,111,108, 41, 13, 10,123, 13, 10, 9,118, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 97,116,116,118, 99,111,108, - 46,120, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,121, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99, -111,108, 46,122, 47, 50, 53, 53, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,117,118, 95, - 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 50, 32, 97,116,116,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117, -118, 41, 13, 10,123, 13, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, - 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,103, -101,111,109, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,109, 97,116, 52, 32,118,105,101,119, -105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 97,116,116,111,114, 99,111, 44, 32,118,101, 99, 50, 32, 97,116,116,117,118, - 44, 32,118,101, 99, 52, 32, 97,116,116,118, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 44, - 32,111,117,116, 32,118,101, 99, 51, 32,108,111, 99, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32, -111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117,116, 32, -118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,118, 99,111,108, 95, 97,108,112,104, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102,114,111,110, -116, 98, 97, 99,107, 41, 13, 10,123, 13, 10, 9,108,111, 99, 97,108, 32, 61, 32, 99,111, 59, 13, 10, 9,118,105,101,119, 32, 61, - 32,110,111,114,109, 97,108,105,122,101, 40,108,111, 99, 97,108, 41, 59, 13, 10, 9,103,108,111, 98, 97,108, 32, 61, 32, 40,118, -105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40,108,111, 99, 97,108, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, - 13, 10, 9,111,114, 99,111, 32, 61, 32, 97,116,116,111,114, 99,111, 59, 13, 10, 9,117,118, 95, 97,116,116,114,105, 98,117,116, -101, 40, 97,116,116,117,118, 44, 32,117,118, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108, -105,122,101, 40,110,111,114, 41, 59, 9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, - 97,108, 32,105,115, 32,110,101,103, 97,116,101,100, 32, 42, 47, 13, 10, 9,118, 99,111,108, 95, 97,116,116,114,105, 98,117,116, -101, 40, 97,116,116,118, 99,111,108, 44, 32,118, 99,111,108, 41, 59, 13, 10, 9,118, 99,111,108, 95, 97,108,112,104, 97, 32, 61, - 32, 97,116,116,118, 99,111,108, 46, 97, 59, 13, 10, 9,102,114,111,110,116, 98, 97, 99,107, 32, 61, 32, 49, 46, 48, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,109, 97,116, 52, - 32,109, 97,116, 44, 32,118,101, 99, 51, 32,109,105,110,118,101, 99, 44, 32,118,101, 99, 51, 32,109, 97,120,118,101, 99, 44, 32, -102,108,111, 97,116, 32,100,111,109,105,110, 44, 32,102,108,111, 97,116, 32,100,111,109, 97,120, 44, 32,111,117,116, 32,118,101, - 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32, 40,109, 97,116, 32, 42, 32, -118,101, 99, 52, 40,118,101, 99, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10, 9,105,102, 40,100,111,109,105,110, 32, - 61, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32,109, 97,120, 40,111,117,116,118,101, 99, 44, 32, -109,105,110,118,101, 99, 41, 59, 13, 10, 9,105,102, 40,100,111,109, 97,120, 32, 61, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111, -117,116,118,101, 99, 32, 61, 32,109,105,110, 40,111,117,116,118,101, 99, 44, 32,109, 97,120,118,101, 99, 41, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32, 99, 97,109,101,114, 97, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, - 32,111,117,116,118,105,101,119, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,101,112,116,104, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,111,117,116,100,105,115,116, 41, 13, 10,123, 13, 10, 9,111,117,116,100,101,112,116,104, 32, 61, - 32, 97, 98,115, 40, 99,111, 46,122, 41, 59, 13, 10, 9,111,117,116,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40, 99, -111, 41, 59, 13, 10, 9,111,117,116,118,105,101,119, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 41, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,100,100, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102, -108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, - 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 43, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111, + 10,102,108,111, 97,116, + 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 10,123, 10, 9,114,101,116,117,114,110, 32, +112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,102, 41, 59, 10,125, 10, 10,118,111,105,100, 32,114, +103, 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, + 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109,105,110, 44, 32,104, 44, 32,115, 44, 32, +118, 44, 32, 99,100,101,108,116, 97, 59, 10, 9,118,101, 99, 51, 32, 99, 59, 10, 10, 9, 99,109, 97,120, 32, 61, 32,109, 97,120, + 40,114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10, 9, + 99,109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114, +103, 98, 91, 50, 93, 41, 41, 59, 10, 9, 99,100,101,108,116, 97, 32, 61, 32, 99,109, 97,120, 45, 99,109,105,110, 59, 10, 10, 9, +118, 32, 61, 32, 99,109, 97,120, 59, 10, 9,105,102, 32, 40, 99,109, 97,120, 33, 61, 48, 46, 48, 41, 10, 9, 9,115, 32, 61, 32, + 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 10, 9,101,108,115,101, 32,123, 10, 9, 9,115, 32, 61, 32, 48, 46, 48, 59, 10, + 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 10, 9,105,102, 32, 40,115, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 10, + 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9, 99, 32, 61, 32, 40,118,101, 99, + 51, 40, 99,109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,114,103, 98, 46,120,121,122, 41, 47, 99, +100,101,108,116, 97, 59, 10, 10, 9, 9,105,102, 32, 40,114,103, 98, 46,120, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, + 91, 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,114,103, 98, 46,121, 61, 61, 99,109, + 97,120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32, 45, 32, 32, 99, 91, 50, 93, 59, 10, 9, 9,101,108, +115,101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45, 32, 99, 91, 48, 93, 59, 10, 10, 9, 9,104, 32, 47, + 61, 32, 54, 46, 48, 59, 10, 10, 9, 9,105,102, 32, 40,104, 60, 48, 46, 48, 41, 10, 9, 9, 9,104, 32, 43, 61, 32, 49, 46, 48, + 59, 10, 9,125, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,104, 44, 32,115, 44, 32,118, 44, 32,114,103, + 98, 46,119, 41, 59, 10,125, 10, 10,118,111,105,100, 32,104,115,118, 95,116,111, 95,114,103, 98, 40,118,101, 99, 52, 32,104,115, +118, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,105, 44, 32, +102, 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32,118, 59, 10, 9,118,101, 99, 51, 32,114,103, 98, 59, 10, + 10, 9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 10, 9,115, 32, 61, 32,104,115,118, 91, 49, 93, 59, 10, 9,118, 32, 61, 32, +104,115,118, 91, 50, 93, 59, 10, 10, 9,105,102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 10, 9, 9,114,103, 98, 32, 61, 32,118, +101, 99, 51, 40,118, 44, 32,118, 44, 32,118, 41, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,105,102, 40,104, 61, + 61, 49, 46, 48, 41, 10, 9, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 10, 9, 9,104, 32, 42, 61, 32, 54, 46, 48, 59, + 10, 9, 9,105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 10, 9, 9,102, 32, 61, 32,104, 32, 45, 32,105, 59, 10, 9, 9, +114,103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 10, 9, 9,112, 32, 61, 32,118, 42, 40, 49, 46, + 48, 45,115, 41, 59, 10, 9, 9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42,102, 41, 41, 59, 10, 9, 9,116, 32, 61, + 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41, 41, 59, 10, 9, 9, 10, 9, 9,105,102, 32, 40,105, + 32, 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,116, 44, 32,112, 41, 59, 10, 9, 9, +101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,113, 44, + 32,118, 44, 32,112, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 50, 46, 48, 41, 32,114,103, 98, + 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, + 61, 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,113, 44, 32,118, 41, 59, 10, 9, 9,101,108, +115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,116, 44, 32,112, + 44, 32,118, 41, 59, 10, 9, 9,101,108,115,101, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,112, 44, 32,113, 41, + 59, 10, 9,125, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 44, 32,104,115,118, 46,119, 41, + 59, 10,125, 10, 10,102,108,111, 97,116, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40,102,108,111, + 97,116, 32, 99, 41, 10,123, 10, 9,105,102, 40, 99, 32, 60, 32, 48, 46, 48, 52, 48, 52, 53, 41, 10, 9, 9,114,101,116,117,114, +110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, 46, 48, 58, 32, 99, 32, 42, 32, 40, 49, 46, 48, 47, 49, 50, 46, 57, 50, + 41, 59, 10, 9,101,108,115,101, 10, 9, 9,114,101,116,117,114,110, 32,112,111,119, 40, 40, 99, 32, 43, 32, 48, 46, 48, 53, 53, + 41, 42, 40, 49, 46, 48, 47, 49, 46, 48, 53, 53, 41, 44, 32, 50, 46, 52, 41, 59, 10,125, 10, 10,102,108,111, 97,116, 32,108,105, +110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 10,123, 10, 9,105,102, 40, 99, + 32, 60, 32, 48, 46, 48, 48, 51, 49, 51, 48, 56, 41, 10, 9, 9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, + 63, 32, 48, 46, 48, 58, 32, 99, 32, 42, 32, 49, 50, 46, 57, 50, 59, 10, 9,101,108,115,101, 10, 9, 9,114,101,116,117,114,110, + 32, 49, 46, 48, 53, 53, 32, 42, 32,112,111,119, 40, 99, 44, 32, 49, 46, 48, 47, 50, 46, 52, 41, 32, 45, 32, 48, 46, 48, 53, 53, + 59, 10,125, 10, 10,118,111,105,100, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40,118,101, 99, 52, + 32, 99,111,108, 95,102,114,111,109, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 10,123, 10, 9, 99, +111,108, 95,116,111, 46,114, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95, +102,114,111,109, 46,114, 41, 59, 10, 9, 99,111,108, 95,116,111, 46,103, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110, +101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,103, 41, 59, 10, 9, 99,111,108, 95,116,111, 46, 98, 32, 61, 32, +115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, 59, 10, 9, + 99,111,108, 95,116,111, 46, 97, 32, 61, 32, 99,111,108, 95,102,114,111,109, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,108, +105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, 95,102,114,111,109, 44, 32, +111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 10,123, 10, 9, 99,111,108, 95,116,111, 46,114, 32, 61, 32,108, +105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,114, 41, 59, 10, 9, 99, +111,108, 95,116,111, 46,103, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95, +102,114,111,109, 46,103, 41, 59, 10, 9, 99,111,108, 95,116,111, 46, 98, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116, +111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, 59, 10, 9, 99,111,108, 95,116,111, 46, 97, 32, 61, 32, + 99,111,108, 95,102,114,111,109, 46, 97, 59, 10,125, 10, 10, 35,100,101,102,105,110,101, 32, 77, 95, 80, 73, 32, 51, 46, 49, 52, + 49, 53, 57, 50, 54, 53, 51, 53, 56, 57, 55, 57, 51, 50, 51, 56, 52, 54, 10, 35,100,101,102,105,110,101, 32, 77, 95, 49, 95, 80, + 73, 32, 48, 46, 51, 49, 56, 51, 48, 57, 56, 56, 54, 49, 56, 51, 55, 57, 48, 54, 57, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 47, 10, 10,118,111,105,100, 32,118, 99,111,108, 95, 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 52, 32, 97,116,116,118, + 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 41, 10,123, 10, 9,118, 99,111,108, 32, 61, 32,118,101, + 99, 52, 40, 97,116,116,118, 99,111,108, 46,120, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,121, 47, 50, 53, + 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,122, 47, 50, 53, 53, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118, +111,105,100, 32,117,118, 95, 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 50, 32, 97,116,116,117,118, 44, 32,111,117,116, + 32,118,101, 99, 51, 32,117,118, 41, 10,123, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, + 32, 45, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, + 32,103,101,111,109, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,109, 97,116, 52, 32,118,105, +101,119,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 97,116,116,111,114, 99,111, 44, 32,118,101, 99, 50, 32, 97,116,116, +117,118, 44, 32,118,101, 99, 52, 32, 97,116,116,118, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97, +108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,111, 99, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, + 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117, +116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,118, 99,111,108, 95, 97,108,112,104, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102,114, +111,110,116, 98, 97, 99,107, 41, 10,123, 10, 9,108,111, 99, 97,108, 32, 61, 32, 99,111, 59, 10, 9,118,105,101,119, 32, 61, 32, +110,111,114,109, 97,108,105,122,101, 40,108,111, 99, 97,108, 41, 59, 10, 9,103,108,111, 98, 97,108, 32, 61, 32, 40,118,105,101, +119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40,108,111, 99, 97,108, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 10, 9, +111,114, 99,111, 32, 61, 32, 97,116,116,111,114, 99,111, 59, 10, 9,117,118, 95, 97,116,116,114,105, 98,117,116,101, 40, 97,116, +116,117,118, 44, 32,117,118, 41, 59, 10, 9,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108,105,122,101, 40,110, +111,114, 41, 59, 9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,105,115, + 32,110,101,103, 97,116,101,100, 32, 42, 47, 10, 9,118, 99,111,108, 95, 97,116,116,114,105, 98,117,116,101, 40, 97,116,116,118, + 99,111,108, 44, 32,118, 99,111,108, 41, 59, 10, 9,118, 99,111,108, 95, 97,108,112,104, 97, 32, 61, 32, 97,116,116,118, 99,111, +108, 46, 97, 59, 10, 9,102,114,111,110,116, 98, 97, 99,107, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, + 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,109, 97,116, 52, 32,109, 97,116, 44, 32,118,101, 99, 51, 32, +109,105,110,118,101, 99, 44, 32,118,101, 99, 51, 32,109, 97,120,118,101, 99, 44, 32,102,108,111, 97,116, 32,100,111,109,105,110, + 44, 32,102,108,111, 97,116, 32,100,111,109, 97,120, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10, +123, 10, 9,111,117,116,118,101, 99, 32, 61, 32, 40,109, 97,116, 32, 42, 32,118,101, 99, 52, 40,118,101, 99, 44, 32, 49, 46, 48, + 41, 41, 46,120,121,122, 59, 10, 9,105,102, 40,100,111,109,105,110, 32, 61, 61, 32, 49, 46, 48, 41, 10, 9, 9,111,117,116,118, +101, 99, 32, 61, 32,109, 97,120, 40,111,117,116,118,101, 99, 44, 32,109,105,110,118,101, 99, 41, 59, 10, 9,105,102, 40,100,111, +109, 97,120, 32, 61, 61, 32, 49, 46, 48, 41, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32,109,105,110, 40,111,117,116,118,101, + 99, 44, 32,109, 97,120,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32, 99, 97,109,101,114, 97, 40,118,101, 99, 51, 32, + 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,105,101,119, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, +111,117,116,100,101,112,116,104, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,105,115,116, 41, 10,123, 10, 9, +111,117,116,100,101,112,116,104, 32, 61, 32, 97, 98,115, 40, 99,111, 46,122, 41, 59, 10, 9,111,117,116,100,105,115,116, 32, 61, + 32,108,101,110,103,116,104, 40, 99,111, 41, 59, 10, 9,111,117,116,118,105,101,119, 32, 61, 32,110,111,114,109, 97,108,105,122, +101, 40, 99,111, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,100,100, 40,102,108,111, 97,116, 32,118, 97, +108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, + 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 43, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111, 105,100, 32,109, 97,116,104, 95,115,117, 98,116,114, 97, 99,116, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, - 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9, -111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 45, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,109, 97,116,104, 95,109,117,108,116,105,112,108,121, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, - 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117, -116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 42, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, - 97,116,104, 95,100,105,118,105,100,101, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, - 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, 97, -108, 50, 32, 61, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108, -115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 47, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,109, 97,116,104, 95,115,105,110,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,115,105,110, 40, -118, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 99,111,115,105,110,101, 40,102,108,111, - 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111, -117,116,118, 97,108, 32, 61, 32, 99,111,115, 40,118, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116, -104, 95,116, 97,110,103,101,110,116, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111, -117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,116, 97,110, 40,118, 97,108, 41, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,115,105,110, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111, -117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, 97,108, 32, 60, 61, - 32, 49, 46, 48, 32, 38, 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, - 32, 97,115,105,110, 40,118, 97,108, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, - 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97, 99,111,115, 40,102,108,111, 97,116, 32,118, - 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, - 97,108, 32, 60, 61, 32, 49, 46, 48, 32, 38, 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, -118, 97,108, 32, 61, 32, 97, 99,111,115, 40,118, 97,108, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97, -108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,116, 97,110, 40,102,108, -111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9, -111,117,116,118, 97,108, 32, 61, 32, 97,116, 97,110, 40,118, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, - 97,116,104, 95,112,111,119, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32, -111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, 97,108, 49, 32, - 62, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,112,111,119, 40,118, 97,108, 49, 44, 32,118, 97, -108, 50, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95,108,111,103, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, - 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9, -105,102, 40,118, 97,108, 49, 32, 62, 32, 48, 46, 48, 32, 32, 38, 38, 32,118, 97,108, 50, 32, 62, 32, 48, 46, 48, 41, 13, 10, 9, - 9,111,117,116,118, 97,108, 61, 32,108,111,103, 50, 40,118, 97,108, 49, 41, 32, 47, 32,108,111,103, 50, 40,118, 97,108, 50, 41, - 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109, 97,116,104, 95,109, 97,120, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, - 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, - 97,108, 32, 61, 32,109, 97,120, 40,118, 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,109, 97,116,104, 95,109,105,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, - 61, 32,109,105,110, 40,118, 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97, -116,104, 95,114,111,117,110,100, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117, -116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 61, 32,102,108,111,111,114, 40,118, 97,108, 32, 43, 32, 48, - 46, 53, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95,108,101,115,115, 95,116,104, 97,110, 40,102, + 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117, +116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 45, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, + 95,109,117,108,116,105,112,108,121, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, + 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, +118, 97,108, 49, 32, 42, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,100,105,118,105,100,101, + 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 32, 40,118, 97,108, 50, 32, 61, 61, 32, 48, 46, 48, 41, 10, 9, + 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, +118, 97,108, 49, 32, 47, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,115,105,110,101, 40,102, +108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111, +117,116,118, 97,108, 32, 61, 32,115,105,110, 40,118, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, 99, +111,115,105,110,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97, +108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 99,111,115, 40,118, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, + 32,109, 97,116,104, 95,116, 97,110,103,101,110,116, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,116, 97,110, 40,118, 97,108, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,115,105,110, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 32, 40,118, 97,108, 32, 60, 61, 32, 49, 46, + 48, 32, 38, 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 97,115,105, +110, 40,118, 97,108, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, + 10,118,111,105,100, 32,109, 97,116,104, 95, 97, 99,111,115, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102, +108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 32, 40,118, 97,108, 32, 60, 61, 32, 49, 46, 48, 32, 38, + 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 97, 99,111,115, 40,118, + 97,108, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111, +105,100, 32,109, 97,116,104, 95, 97,116, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 97,116, 97,110, 40,118, 97,108, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,112,111,119, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108, +111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105, +102, 32, 40,118, 97,108, 49, 32, 62, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,112,111,119, 40,118, + 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, + 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,108,111,103, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102, +108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9, +105,102, 40,118, 97,108, 49, 32, 62, 32, 48, 46, 48, 32, 32, 38, 38, 32,118, 97,108, 50, 32, 62, 32, 48, 46, 48, 41, 10, 9, 9, +111,117,116,118, 97,108, 61, 32,108,111,103, 50, 40,118, 97,108, 49, 41, 32, 47, 32,108,111,103, 50, 40,118, 97,108, 50, 41, 59, + 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97, +116,104, 95,109, 97,120, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,109, 97,120, + 40,118, 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,109,105,110, 40,102, 108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, - 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 40,118, 97,108, 49, 32, 60, 32,118, 97,108, 50, 41, 13, 10, 9, - 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, - 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95,103,114,101, 97,116,101,114, 95,116, -104, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 40,118, 97,108, 49, 32, 62, 32,118, 97,108, - 50, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117, -116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,113,117,101,101,122,101, 40,102, -108,111, 97,116, 32,118, 97,108, 44, 32,102,108,111, 97,116, 32,119,105,100,116,104, 44, 32,102,108,111, 97,116, 32, 99,101,110, -116,101,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, - 97,108, 32, 61, 32, 49, 46, 48, 47, 40, 49, 46, 48, 32, 43, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 51, 44, 32, - 45, 40, 40,118, 97,108, 45, 99,101,110,116,101,114, 41, 42,119,105,100,116,104, 41, 41, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 97,100,100, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, - 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117, -116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 13, 10, 9,111, -117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40,111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117, -116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, 41, 47, 51, 46, 48, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,115,117, 98, 40,118,101, 99, 51, 32,118, 49, 44, - 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 45, 32, -118, 50, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40,111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, - 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, - 41, 47, 51, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 97,118,101,114, 97, -103,101, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117, -116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116, -118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,108,101,110,103,116,104, - 40,111,117,116,118,101, 99, 41, 59, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,111, -117,116,118,101, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,100,111,116, 40, -118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, - 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, - 32, 61, 32,118,101, 99, 51, 40, 48, 44, 32, 48, 44, 32, 48, 41, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,100,111,116, - 40,118, 49, 44, 32,118, 50, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 99,114, -111,115,115, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, -117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117, -116,118,101, 99, 32, 61, 32, 99,114,111,115,115, 40,118, 49, 44, 32,118, 50, 41, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, - 32,108,101,110,103,116,104, 40,111,117,116,118,101, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95, -109, 97,116,104, 95,110,111,114,109, 97,108,105,122,101, 40,118,101, 99, 51, 32,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32, -111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111, -117,116,118, 97,108, 32, 61, 32,108,101,110,103,116,104, 40,118, 41, 59, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111, -114,109, 97,108,105,122,101, 40,118, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, -110,101,103, 97,116,101, 40,118,101, 99, 51, 32,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 41, 13, 10,123, - 13, 10, 9,111,117,116,118, 32, 61, 32, 45,118, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,114,109, 97,108, 40, -118,101, 99, 51, 32,100,105,114, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, -110,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,111,116, 41, 13, 10,123, 13, 10, 9,111,117,116,110, -111,114, 32, 61, 32,110,111,114, 59, 13, 10, 9,111,117,116,100,111,116, 32, 61, 32, 45,100,111,116, 40,100,105,114, 44, 32,110, -111,114, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,118,101, 99, 40,102,108,111, 97,116, - 32,102, 97, 99, 44, 32,118,101, 99, 51, 32,118,101, 99, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, - 97,112, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, - 46,120, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, 40,118, -101, 99, 46,120, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 13, 10, 9,111,117,116,118, -101, 99, 46,121, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, - 40,118,101, 99, 46,121, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,121, 59, 13, 10, 9,111,117, -116,118,101, 99, 46,122, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, - 50, 40, 40,118,101, 99, 46,122, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,122, 59, 13, 10, 13, - 10, 9,105,102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32, 40,111, -117,116,118,101, 99, 42,102, 97, 99, 41, 32, 43, 32, 40,118,101, 99, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 13, 10, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, - 32,118,101, 99, 52, 32, 99,111,108, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, 44, 32,111, -117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, -116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, - 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46,114, 44, 32, 48, 46, 48, 41, 41, 46, 97, - 44, 32, 48, 46, 48, 41, 41, 46,114, 59, 13, 10, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,101,120,116,117,114,101, 50, - 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101, -109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46,103, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, -103, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, + 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,109,105,110, 40,118, 97,108, 49, 44, 32,118, + 97,108, 50, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,114,111,117,110,100, 40,102,108,111, 97,116, 32,118, + 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 61, + 32,102,108,111,111,114, 40,118, 97,108, 32, 43, 32, 48, 46, 53, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, +108,101,115,115, 95,116,104, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, + 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 40,118, 97,108, 49, 32, 60, + 32,118, 97,108, 50, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111, +117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,103,114,101, 97,116,101, +114, 95,116,104, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 40,118, 97,108, 49, 32, 62, 32,118, 97, +108, 50, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, + 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,115,113,117,101,101,122,101, 40,102,108,111, 97,116, 32, +118, 97,108, 44, 32,102,108,111, 97,116, 32,119,105,100,116,104, 44, 32,102,108,111, 97,116, 32, 99,101,110,116,101,114, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, + 48, 47, 40, 49, 46, 48, 32, 43, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 51, 44, 32, 45, 40, 40,118, 97,108, 45, + 99,101,110,116,101,114, 41, 42,119,105,100,116,104, 41, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97, +116,104, 95, 97,100,100, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111, +117,116,118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40, +111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98, +115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, 41, 47, 51, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, + 97,116,104, 95,115,117, 98, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, + 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9, +111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 45, 32,118, 50, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, + 40,111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, + 98,115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, 41, 47, 51, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95, +109, 97,116,104, 95, 97,118,101,114, 97,103,101, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111, +117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, + 41, 10,123, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 10, 9,111,117,116,118, 97,108, 32, 61, + 32,108,101,110,103,116,104, 40,111,117,116,118,101, 99, 41, 59, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111,114,109, 97, +108,105,122,101, 40,111,117,116,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,100, +111,116, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117, +116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118,101, + 99, 32, 61, 32,118,101, 99, 51, 40, 48, 44, 32, 48, 44, 32, 48, 41, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32,100,111,116, + 40,118, 49, 44, 32,118, 50, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 99,114,111,115,115, + 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, +101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118,101, 99, 32, + 61, 32, 99,114,111,115,115, 40,118, 49, 44, 32,118, 50, 41, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32,108,101,110,103,116, +104, 40,111,117,116,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,110,111,114,109, + 97,108,105,122,101, 40,118,101, 99, 51, 32,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,108,101,110, +103,116,104, 40,118, 41, 59, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 41, 59, 10, +125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,110,101,103, 97,116,101, 40,118,101, 99, 51, 32,118, 44, 32, +111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 41, 10,123, 10, 9,111,117,116,118, 32, 61, 32, 45,118, 59, 10,125, 10, 10, +118,111,105,100, 32,110,111,114,109, 97,108, 40,118,101, 99, 51, 32,100,105,114, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32, +111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,111, +116, 41, 10,123, 10, 9,111,117,116,110,111,114, 32, 61, 32,110,111,114, 59, 10, 9,111,117,116,100,111,116, 32, 61, 32, 45,100, +111,116, 40,100,105,114, 44, 32,110,111,114, 41, 59, 10,125, 10, 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,118,101, 99, + 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 51, 32,118,101, 99, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, + 99,117,114,118,101,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10, 9,111,117, +116,118,101, 99, 46,120, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, + 50, 40, 40,118,101, 99, 46,120, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 10, 9,111, +117,116,118,101, 99, 46,121, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, + 99, 50, 40, 40,118,101, 99, 46,121, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,121, 59, 10, 9, +111,117,116,118,101, 99, 46,122, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118, +101, 99, 50, 40, 40,118,101, 99, 46,122, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,122, 59, 10, + 10, 9,105,102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, 48, 41, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32, 40,111,117, +116,118,101, 99, 42,102, 97, 99, 41, 32, 43, 32, 40,118,101, 99, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 10, 10,125, 10, + 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, + 32, 99,111,108, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, 44, 32,111,117,116, 32,118,101, + 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32,116,101,120,116,117,114,101, + 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118, +101,109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46,114, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, + 46,114, 59, 10, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, - 50, 40, 99,111,108, 46, 98, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, 98, 59, 13, 10, 13, 10, 9,105, -102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32, 40,111,117,116, 99, -111,108, 42,102, 97, 99, 41, 32, 43, 32, 40, 99,111,108, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 13, 10, 13, 10, 9,111, -117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,101,116, 95, -118, 97,108,117,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97, -108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,101,116, 95,114,103, 98, 40,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99, -111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,115,101,116, 95,114,103, 98, 97, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117, -116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118, + 50, 40, 99,111,108, 46,103, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46,103, 59, 10, 9,111,117,116, 99, +111,108, 46, 98, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, +116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46, 98, 44, 32, + 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, 98, 59, 10, 10, 9,105,102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, + 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32, 40,111,117,116, 99,111,108, 42,102, 97, 99, 41, 32, 43, 32, 40, 99, +111,108, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 10, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 46, + 97, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,118, 97,108,117,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97, +108, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 40,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, + 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 10,125, + 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 97, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, + 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 10,125, 10, 10,118, 111,105,100, 32,115,101,116, 95,118, 97,108,117,101, 95,122,101,114,111, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, -118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111, -105,100, 32,115,101,116, 95,118, 97,108,117,101, 95,111,110,101, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97, -108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,101,116, 95,114,103, 98, 95,122,101,114,111, 40,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 97,108, 41, 13, 10, -123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111, -105,100, 32,115,101,116, 95,114,103, 98, 97, 95,122,101,114,111, 40,111,117,116, 32,118,101, 99, 52, 32,111,117,116,118, 97,108, - 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118,101, 99, 52, 40, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,109,105,120, 95, 98,108,101,110,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, +118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,115,101, +116, 95,118, 97,108,117,101, 95,111,110,101, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, + 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 95,122, +101,114,111, 40,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, + 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 97, 95,122,101,114, +111, 40,111,117,116, 32,118,101, 99, 52, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, +101, 99, 52, 40, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95, 98,108,101,110,100, 40,102,108,111, 97, +116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, + 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, + 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, + 32, 99,111,108, 50, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, + 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95, 97,100,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, + 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111, +108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, + 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, + 50, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10, +118,111,105,100, 32,109,105,120, 95,109,117,108,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111, +108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10, +123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9, +111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 42, 32, 99,111,108, 50, 44, 32, +102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105, +100, 32,109,105,120, 95,115, 99,114,101,101,110, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, + 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, + 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102, +108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, + 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 40,118,101, 99, 52, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99, 42, + 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 50, 41, 41, 42, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, + 32, 99,111,108, 49, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118, +111,105,100, 32,109,105,120, 95,111,118,101,114,108, 97,121, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, - 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, - 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 50, 44, 32,102, 97, - 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109,105,120, 95, 97,100,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, - 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, - 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, - 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, 44, - 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,109,105,120, 95,109,117,108,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, - 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, - 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, - 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 42, 32, 99, -111,108, 50, 44, 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115, 99,114,101,101,110, 40,102,108,111, 97,116, 32,102, 97, 99, 44, - 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, - 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, - 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 40,118,101, 99, - 52, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99, 42, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 50, 41, - 41, 42, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 49, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, - 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,111,118,101,114,108, 97, -121, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, - 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99, -108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99, -109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, - 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, 99, -111,108, 46,114, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 13, 10, - 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, - 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46,114, 41, 41, 42, 40, 49, 46, 48, 32, 45, - 32,111,117,116, 99,111,108, 46,114, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, 32, 60, 32, 48, 46, - 53, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, - 42, 99,111,108, 50, 46,103, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, - 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46, -103, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, - 99,111,108, 46, 98, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 42, 61, 32,102, 97, 99,109, - 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, - 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, - 46, 48, 32, 45, 32, 99,111,108, 50, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, 41, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115,117, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, - 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, - 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, - 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, - 45, 32, 99,111,108, 50, 44, 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, - 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100,105,118, 40,102,108,111, 97,116, 32,102, 97, 99, 44, - 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, - 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, - 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,105,102, 40, 99,111,108, - 50, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,114, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99, -111,108, 46,114, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,114, 47, 99,111,108, 50, 46,114, 59, 13, 10, 9,105,102, - 40, 99,111,108, 50, 46,103, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,103, 32, 61, 32,102, 97, 99,109, 42, -111,117,116, 99,111,108, 46,103, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,103, 47, 99,111,108, 50, 46,103, 59, 13, - 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46, 98, 32, 61, 32,102, - 97, 99,109, 42,111,117,116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46, 98, 47, 99,111,108, 50, - 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100,105,102,102, 40,102,108,111, 97,116, 32,102, 97, - 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, - 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, - 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, - 97, 98,115, 40, 99,111,108, 49, 32, 45, 32, 99,111,108, 50, 41, 44, 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, - 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100, 97,114,107, - 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, - 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, - 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46,114,103, 98, - 32, 61, 32,109,105,110, 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114,103, 98, 42,102, 97, 99, 41, 59, 13, - 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, -109,105,120, 95,108,105,103,104,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32, -118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, - 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111, -117,116, 99,111,108, 46,114,103, 98, 32, 61, 32,109, 97,120, 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114, -103, 98, 42,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100,111,100,103,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, - 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, - 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, - 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,105,102, 40,111,117, -116, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, - 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 13, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, - 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32, -105,102, 40, 40,116,109,112, 32, 61, 32,111,117,116, 99,111,108, 46,114, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 13, 10, - 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,111, -117,116, 99,111,108, 46,114, 32, 61, 32,116,109,112, 59, 13, 10, 9,125, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, - 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32, -102, 97, 99, 42, 99,111,108, 50, 46,103, 59, 13, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, - 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109, -112, 32, 61, 32,111,117,116, 99,111,108, 46,103, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, - 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46, -103, 32, 61, 32,116,109,112, 59, 13, 10, 9,125, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, - 48, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111, -108, 50, 46, 98, 59, 13, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, 99, -111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32,111,117, -116, 99,111,108, 46, 98, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, - 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116,109, -112, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95, 98,117,114,110, 40,102,108,111, 97,116, - 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32, -118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, - 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,116,109,112, 44, 32,102, 97, 99,109, 32, - 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, - 10, 13, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 13, 10, 9,105, -102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 48, 46, 48, 59, - 13, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, 45, 32, -111,117,116, 99,111,108, 46,114, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, - 46,114, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, 13, 10, - 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99, -111,108, 46,114, 32, 61, 32,116,109,112, 59, 13, 10, 13, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, - 42, 99,111,108, 50, 46,103, 59, 13, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, - 99,111,108, 46,103, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, - 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, - 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, -116,109,112, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, -101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,109,112, 59, 13, 10, 13, 10, 9,116,109,112, 32, - 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 13, 10, 9,105,102, 40,116,109,112, 32, 60, 61, - 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32, -105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, - 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 48, 46, 48, - 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, - 46, 98, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116, -109,112, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,104,117,101, 40,102,108,111, 97,116, 32,102, 97, 99, - 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, - 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, - 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, - 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32, -104,115,118, 44, 32,104,115,118, 50, 44, 32,116,109,112, 59, 13, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, - 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, 10, 9,105,102, 40,104,115,118, 50, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, 32, -123, 13, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 13, 10, 9, - 9,104,115,118, 46,120, 32, 61, 32,104,115,118, 50, 46,120, 59, 13, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104, -115,118, 44, 32,116,109,112, 41, 59, 32, 13, 10, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, - 99,111,108, 44, 32,116,109,112, 44, 32,102, 97, 99, 41, 59, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111, -108, 49, 46, 97, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115, 97,116, 40,102,108,111, - 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, -102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, - 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, - 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 13, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117, -116, 99,111,108, 44, 32,104,115,118, 41, 59, 13, 10, 13, 10, 9,105,102, 40,104,115,118, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, - 32,123, 13, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, - 10, 9, 9,104,115,118, 46,121, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46,121, 32, 43, 32,102, 97, 99, 42,104,115,118, 50, - 46,121, 59, 13, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, 13, - 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,118, 97,108, 40,102,108,111, 97,116, 32,102, 97, 99, - 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, - 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, - 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, - 97, 99, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 13, 10, 9,114,103, 98, 95,116,111, - 95,104,115,118, 40, 99,111,108, 49, 44, 32,104,115,118, 41, 59, 13, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111, -108, 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, 10, 9,104,115,118, 46,122, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46, -122, 32, 43, 32,102, 97, 99, 42,104,115,118, 50, 46,122, 59, 13, 10, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, - 44, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95, 99,111,108,111,114, 40, + 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, + 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99, +111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, 53, 41, 10, + 9, 9,111,117,116, 99,111,108, 46,114, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 99,111,108, + 50, 46,114, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, + 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46,114, 41, 41, 42, 40, 49, + 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, 32, 60, 32, + 48, 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, + 99, 42, 99,111,108, 50, 46,103, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, + 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46,103, + 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, + 46, 98, 32, 60, 32, 48, 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, + 46, 48, 42,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, + 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99, +111,108, 50, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, 41, 59, 10,125, 10, 10,118,111,105, +100, 32,109,105,120, 95,115,117, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32, +118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, + 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99, +111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 45, 32, 99,111,108, 50, 44, 32,102, 97, 99, 41, + 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105, +120, 95,100,105,118, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, + 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, + 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, + 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, + 10, 10, 9,105,102, 40, 99,111,108, 50, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,114, 32, 61, 32, +102, 97, 99,109, 42,111,117,116, 99,111,108, 46,114, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,114, 47, 99,111,108, + 50, 46,114, 59, 10, 9,105,102, 40, 99,111,108, 50, 46,103, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,103, + 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,103, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,103, 47, + 99,111,108, 50, 46,103, 59, 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111, +108, 46, 98, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, + 46, 98, 47, 99,111,108, 50, 46, 98, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,100,105,102,102, 40,102,108,111, 97, +116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, + 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, + 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, + 32, 97, 98,115, 40, 99,111,108, 49, 32, 45, 32, 99,111,108, 50, 41, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, + 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,100, 97,114,107, 40,102,108, +111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111, +117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, + 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 46,114,103, 98, 32, 61, 32,109,105,110, + 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114,103, 98, 42,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111, +108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,108,105,103,104,116, 40, 102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, - 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97, -109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, - 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, - 10, 13, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 44, 32,116,109,112, 59, 13, 10, 9,114,103, 98, 95,116, -111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, 10, 9,105,102, 40,104,115,118, 50, 46,121, - 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, - 32,104,115,118, 41, 59, 13, 10, 9, 9,104,115,118, 46,120, 32, 61, 32,104,115,118, 50, 46,120, 59, 13, 10, 9, 9,104,115,118, - 46,121, 32, 61, 32,104,115,118, 50, 46,121, 59, 13, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32, -116,109,112, 41, 59, 32, 13, 10, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, 99,111,108, 44, - 32,116,109,112, 44, 32,102, 97, 99, 41, 59, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, - 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115,111,102,116, 40,102,108,111, 97,116, 32, -102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118, -101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, - 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, - 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32,111,110,101, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, - 10, 9,118,101, 99, 52, 32,115, 99,114, 61, 32,111,110,101, 32, 45, 32, 40,111,110,101, 32, 45, 32, 99,111,108, 50, 41, 42, 40, -111,110,101, 32, 45, 32, 99,111,108, 49, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,102, 97, 99,109, 42, 99,111,108, - 49, 32, 43, 32,102, 97, 99, 42, 40, 40,111,110,101, 32, 45, 32, 99,111,108, 49, 41, 42, 99,111,108, 50, 42, 99,111,108, 49, 32, - 43, 32, 99,111,108, 49, 42,115, 99,114, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,108,105,110,101, - 97,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111, -108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, - 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, - 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,105,102, 40, 99,111,108, 50, 46,114, 32, 62, 32, 48, 46, 53, 41, 13, 10, 9, - 9,111,117,116, 99,111,108, 46,114, 61, 32, 99,111,108, 49, 46,114, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111, -108, 50, 46,114, 32, 45, 32, 48, 46, 53, 41, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,114, - 61, 32, 99,111,108, 49, 46,114, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,114, 41, 32, 45, 32, 49, - 46, 48, 41, 59, 13, 10, 13, 10, 9,105,102, 40, 99,111,108, 50, 46,103, 32, 62, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, - 99,111,108, 46,103, 61, 32, 99,111,108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,103, - 32, 45, 32, 48, 46, 53, 41, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 61, 32, 99,111, -108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,103, 41, 32, 45, 32, 49, 46, 48, 41, 59, - 13, 10, 13, 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 62, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, - 98, 61, 32, 99,111,108, 49, 46, 98, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 32, 45, 32, 48, - 46, 53, 41, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 61, 32, 99,111,108, 49, 46, 98, - 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 41, 32, 45, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,118, 97,108,116,111,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,115, 97,109,112, -108,101,114, 50, 68, 32, 99,111,108,111,114,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, 97,108,112,104, 97, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, - 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,111,108,111,114,109, 97,112, 44, 32,118,101, 99, 50, 40,102, 97, 99, 44, - 32, 48, 46, 48, 41, 41, 59, 13, 10, 9,111,117,116, 97,108,112,104, 97, 32, 61, 32,111,117,116, 99,111,108, 46, 97, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,114,103, 98,116,111, 98,119, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 32, 32, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, - 99,111,108,111,114, 46,114, 42, 48, 46, 51, 53, 32, 43, 32, 99,111,108,111,114, 46,103, 42, 48, 46, 52, 53, 32, 43, 32, 99,111, -108,111,114, 46, 98, 42, 48, 46, 50, 59, 32, 47, 42, 32,107,101,101,112, 32,116,104,101,115,101, 32,102, 97, 99,116,111,114,115, - 32,105,110, 32,115,121,110, 99, 32,119,105,116,104, 32,116,101,120,116,117,114,101, 46,104, 58, 82, 71, 66, 84, 79, 66, 87, 32, - 42, 47, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,105,110,118,101,114,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32, -118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9, -111,117,116, 99,111,108, 46,120,121,122, 32, 61, 32,109,105,120, 40, 99,111,108, 46,120,121,122, 44, 32,118,101, 99, 51, 40, 49, - 46, 48, 44, 32, 49, 46, 48, 44, 32, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 46,120,121,122, 44, 32,102, 97, 99, 41, 59, 13, 10, - 9,111,117,116, 99,111,108, 46,119, 32, 61, 32, 99,111,108, 46,119, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,104,117, -101, 95,115, 97,116, 40,102,108,111, 97,116, 32,104,117,101, 44, 32,102,108,111, 97,116, 32,115, 97,116, 44, 32,102,108,111, 97, -116, 32,118, 97,108,117,101, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32,104,115,118, 59, 13, 10, 13, - 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 44, 32,104,115,118, 41, 59, 13, 10, 13, 10, 9,104,115,118, 91, - 48, 93, 32, 43, 61, 32, 40,104,117,101, 32, 45, 32, 48, 46, 53, 41, 59, 13, 10, 9,105,102, 40,104,115,118, 91, 48, 93, 62, 49, - 46, 48, 41, 32,104,115,118, 91, 48, 93, 45, 61, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, 48, 93, 60, - 48, 46, 48, 41, 32,104,115,118, 91, 48, 93, 43, 61, 32, 49, 46, 48, 59, 13, 10, 9,104,115,118, 91, 49, 93, 32, 42, 61, 32,115, - 97,116, 59, 13, 10, 9,105,102, 40,104,115,118, 91, 49, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 49, 93, 61, 32, 49, 46, 48, - 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, 49, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 49, 93, 61, 32, 48, 46, - 48, 59, 13, 10, 9,104,115,118, 91, 50, 93, 32, 42, 61, 32,118, 97,108,117,101, 59, 13, 10, 9,105,102, 40,104,115,118, 91, 50, - 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, - 50, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 48, 46, 48, 59, 13, 10, 13, 10, 9,104,115,118, 95,116,111, 95, -114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109, -105,120, 40, 99,111,108, 44, 32,111,117,116, 99,111,108, 44, 32,102, 97, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,101,112, 97,114, 97,116,101, 95,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 98, 41, 13, 10, -123, 13, 10, 9,114, 32, 61, 32, 99,111,108, 46,114, 59, 13, 10, 9,103, 32, 61, 32, 99,111,108, 46,103, 59, 13, 10, 9, 98, 32, - 61, 32, 99,111,108, 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, 99,111,109, 98,105,110,101, 95,114,103, 98, 40, -102,108,111, 97,116, 32,114, 44, 32,102,108,111, 97,116, 32,103, 44, 32,102,108,111, 97,116, 32, 98, 44, 32,111,117,116, 32,118, -101, 99, 52, 32, 99,111,108, 41, 13, 10,123, 13, 10, 9, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114, 44, 32,103, 44, 32, 98, - 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,111,117,116,112,117,116, 95,110,111,100,101, 40,118, -101, 99, 52, 32,114,103, 98, 44, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, -117,116,114,103, 98, 41, 13, 10,123, 13, 10, 9,111,117,116,114,103, 98, 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 46,114,103, - 98, 44, 32, 97,108,112,104, 97, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 84, 69, - 88, 84, 85, 82, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10,118,111,105,100, 32, -116,101,120,116,117,114,101, 95,102,108,105,112, 95, 98,108,101,110,100, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118,101, 99, 46, -121,120,122, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, 95,108,105, -110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, - 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, 95,113,117, 97,100, 40,118,101, 99, 51, 32, -118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, - 97,108, 32, 61, 32,109, 97,120, 40, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 44, 32, 48, 46, 48, 41, 59, 13, - 10, 9,111,117,116,118, 97,108, 32, 42, 61, 32,111,117,116,118, 97,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116, -101,120,116,117,114,101, 95,119,111,111,100, 95,115,105,110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108, -111, 97,116, 32,118, 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118, -101, 99, 51, 32,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, 97, 32, 61, 32,115,113,114,116, 40, -118,101, 99, 46,120, 42,118,101, 99, 46,120, 32, 43, 32,118,101, 99, 46,121, 42,118,101, 99, 46,121, 32, 43, 32,118,101, 99, 46, -122, 42,118,101, 99, 46,122, 41, 42, 50, 48, 46, 48, 59, 13, 10, 9,102,108,111, 97,116, 32,119,105, 32, 61, 32, 48, 46, 53, 32, - 43, 32, 48, 46, 53, 42,115,105,110, 40, 97, 41, 59, 13, 10, 13, 10, 9,118, 97,108,117,101, 32, 61, 32,119,105, 59, 13, 10, 9, - 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40,119,105, 44, 32,119,105, 44, 32,119,105, 44, 32, 49, 46, 48, 41, 59, 13, 10, - 9,110,111,114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95,105,109, 97,103,101, 40,118,101, 99, 51, 32,118,101, 99, - 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118, 97,108,117,101, - 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97, -108, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 40, -118,101, 99, 46,120,121, 32, 43, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, 48, 41, 41, 42, 48, 46, 53, 41, 59, 13, 10, - 9,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 59, 13, 10, 13, 10, 9,110,111,114,109, 97,108, 46,120, 32, 61, 32, 50, 46, 48, - 42, 40, 99,111,108,111,114, 46,114, 32, 45, 32, 48, 46, 53, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 46,121, 32, 61, 32, 50, - 46, 48, 42, 40, 48, 46, 53, 32, 45, 32, 99,111,108,111,114, 46,103, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 46,122, 32, 61, - 32, 50, 46, 48, 42, 40, 99,111,108,111,114, 46, 98, 32, 45, 32, 48, 46, 53, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 77, 84, 69, 88, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 47, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111,114, 99,111, 40,118,101, 99, 51, 32, 97,116,116,111,114, - 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 41, 13, 10,123, 13, 10, 9,111,114, 99,111, 32, 61, 32, 97, -116,116,111,114, 99,111, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,117,118, 40,118,101, 99, 50, - 32, 97,116,116,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 41, 13, 10,123, 13, 10, 9, 47, 42, 32,100,105,115, - 97, 98,108,101,100, 32,102,111,114, 32,110,111,119, 44, 32,119,111,114,107,115, 32,116,111,103,101,116,104,101,114, 32,119,105, -116,104, 32,108,101, 97,118,105,110,103, 32,111,117,116, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 13, 10, - 9, 32, 32, 32,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, 99, 50, 40, 49, - 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 32, 42, 47, 13, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97, -116,116,117,118, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,110,111,114, -109, 40,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97, -108, 41, 13, 10,123, 13, 10, 9, 47, 42, 32, 99,111,114,114,101,115,112,111,110,100,115, 32,116,111, 32,115,104,105, 45, 62,111, -114,110, 44, 32,119,104,105, 99,104, 32,105,115, 32,110,101,103, 97,116,101,100, 32,115,111, 32, 99, 97,110, 99,101,108,115, 13, - 10, 9, 32, 32, 32,111,117,116, 32, 98,108,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,110,101,103, 97,116,105,111,110, - 32, 42, 47, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,110,111,114,109, - 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,116, 97,110,103,101,110,116, 40,118,101, - 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116, 97,110,103,101,110,116, 41, - 13, 10,123, 13, 10, 9,111,117,116,116, 97,110,103,101,110,116, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,116, 97,110, -103,101,110,116, 46,120,121,122, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,103,108,111, 98, - 97,108, 40,109, 97,116, 52, 32,118,105,101,119,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 41, 13, 10,123, 13, 10, 9,103,108,111, 98, 97,108, 32, 61, 32, 40,118,105,101, -119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111, 98,106,101, 99,116, 40,109, 97,116, 52, 32,118,105,101,119,105,110,118, -109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 41, 13, 10,123, 13, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, 40,111, 98,105, -110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, 48, 41, 41, - 41, 46,120,121,122, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,114,101,102,108, 40,118,101, 99, - 51, 32,118,110, 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,114,101,102, 41, 13, 10, -123, 13, 10, 9,114,101,102, 32, 61, 32,118,105,101,119, 32, 45, 32, 50, 46, 48, 42,100,111,116, 40,118,110, 44, 32,118,105,101, -119, 41, 42,118,110, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,110,111,114,109, 40,118,101, 99, - 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, - 13, 10, 9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,105,115, 32,110, -101,103, 97,116,101,100, 32, 42, 47, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108,105, -122,101, 40,110,111,114,109, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, - 98,108,101,110,100, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32, -102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, - 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99, -116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 13, 10, 13, - 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, - 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,109,117,108, 40,118,101, 99, - 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10, -123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, - 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, - 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 41, 42,111,117,116, 99,111,108, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 99,114,101,101,110, 40,118,101, 99, 51, 32,111,117, -116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9, -102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9, -102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,118,101, 99, - 51, 40, 49, 46, 48, 41, 32, 45, 32, 40,118,101, 99, 51, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99,116, 42, 40,118,101, 99, - 51, 40, 49, 46, 48, 41, 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,111, -117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,111,118,101,114, -108, 97,121, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108, -111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105, -110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, - 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 13, 10, 13, 10, 9, -105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,105,110, 99,111,108, 46,114, 32, 61, 32, -111,117,116, 99,111,108, 46,114, 42, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, - 46,114, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105,110, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, -102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,114, 41, - 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111, -108, 46,103, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,105,110, 99,111,108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, - 42, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 41, 59, 13, 10, 9,101, -108,115,101, 13, 10, 9, 9,105,110, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, - 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,103, 41, 41, 42, 40, 49, 46, 48, 32, 45, - 32,111,117,116, 99,111,108, 46,103, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, 98, 32, 60, 32, 48, 46, - 53, 41, 13, 10, 9, 9,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 42, 40,102, 97, 99,109, 32, 43, - 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46, 98, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105, -110, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, - 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, - 98, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115,117, 98, 40,118,101, 99, 51, + 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, + 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 46,114,103, 98, 32, 61, 32,109, + 97,120, 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114,103, 98, 42,102, 97, 99, 41, 59, 10, 9,111,117,116, + 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,100,111,100,103, +101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, + 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97, +109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, + 49, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108,111, + 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 10, 9, 9,105,102, 40, +116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 10, 9, + 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32,111,117,116, 99,111,108, 46,114, 47,116,109,112, 41, 32, 62, 32, + 49, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 10, 9, + 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32,116,109,112, 59, 10, 9,125, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, +103, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32, +102, 97, 99, 42, 99,111,108, 50, 46,103, 59, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9, +111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, + 32,111,117,116, 99,111,108, 46,103, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46, +103, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,109, +112, 59, 10, 9,125, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102, +108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 10, 9, 9,105, +102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, + 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 47,116,109,112, 41, 32, + 62, 32, 49, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, + 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116,109,112, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109, +105,120, 95, 98,117,114,110, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, + 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, + 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32, +116,109,112, 44, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, + 61, 32, 99,111,108, 49, 59, 10, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, 46, +114, 59, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, + 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, + 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99, +111,108, 46,114, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, 10, + 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, + 46,114, 32, 61, 32,116,109,112, 59, 10, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, + 50, 46,103, 59, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, + 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, + 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 10, 9, 9,111,117, +116, 99,111,108, 46,103, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, + 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99, +111,108, 46,103, 32, 61, 32,116,109,112, 59, 10, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99, +111,108, 50, 46, 98, 59, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46, + 98, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, + 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 10, 9, 9, +111,117,116, 99,111,108, 46, 98, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, + 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117, +116, 99,111,108, 46, 98, 32, 61, 32,116,109,112, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,104,117,101, 40,102,108, +111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111, +117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, + 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, + 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,118,101, 99, 52, 32, +104,115,118, 44, 32,104,115,118, 50, 44, 32,116,109,112, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, + 44, 32,104,115,118, 50, 41, 59, 10, 10, 9,105,102, 40,104,115,118, 50, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, + 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 10, 9, 9,104,115,118, 46, +120, 32, 61, 32,104,115,118, 50, 46,120, 59, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,116,109, +112, 41, 59, 32, 10, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, 99,111,108, 44, 32,116,109,112, + 44, 32,102, 97, 99, 41, 59, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10, 9,125, 10, +125, 10, 10,118,111,105,100, 32,109,105,120, 95,115, 97,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, + 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, + 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, + 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99, +111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 10, 9,114,103, + 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 10, 10, 9,105,102, 40,104,115,118, 46, +121, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104, +115,118, 50, 41, 59, 10, 10, 9, 9,104,115,118, 46,121, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46,121, 32, 43, 32,102, 97, + 99, 42,104,115,118, 50, 46,121, 59, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99, +111,108, 41, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,118, 97,108, 40,102,108,111, 97,116, 32,102, 97, + 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, + 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, + 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, + 59, 10, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, + 99,111,108, 49, 44, 32,104,115,118, 41, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115, +118, 50, 41, 59, 10, 10, 9,104,115,118, 46,122, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46,122, 32, 43, 32,102, 97, 99, 42, +104,115,118, 50, 46,122, 59, 10, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95, 99,111,108,111,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118, +101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117, +116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, + 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9, +111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 44, + 32,116,109,112, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, 50, 41, 59, 10, 10, + 9,105,102, 40,104,115,118, 50, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115, +118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 10, 9, 9,104,115,118, 46,120, 32, 61, 32,104,115,118, 50, 46,120, + 59, 10, 9, 9,104,115,118, 46,121, 32, 61, 32,104,115,118, 50, 46,121, 59, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, + 40,104,115,118, 44, 32,116,109,112, 41, 59, 32, 10, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, + 99,111,108, 44, 32,116,109,112, 44, 32,102, 97, 99, 41, 59, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, + 49, 46, 97, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,115,111,102,116, 40,102,108,111, 97,116, 32,102, + 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, + 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, + 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, + 99, 59, 10, 10, 9,118,101, 99, 52, 32,111,110,101, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,118,101, 99, 52, 32, +115, 99,114, 61, 32,111,110,101, 32, 45, 32, 40,111,110,101, 32, 45, 32, 99,111,108, 50, 41, 42, 40,111,110,101, 32, 45, 32, 99, +111,108, 49, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,102, 97, 99,109, 42, 99,111,108, 49, 32, 43, 32,102, 97, 99, 42, + 40, 40,111,110,101, 32, 45, 32, 99,111,108, 49, 41, 42, 99,111,108, 50, 42, 99,111,108, 49, 32, 43, 32, 99,111,108, 49, 42,115, + 99,114, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,108,105,110,101, 97,114, 40,102,108,111, 97,116, 32,102, 97, + 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, + 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, + 48, 44, 32, 49, 46, 48, 41, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,105,102, 40, 99, +111,108, 50, 46,114, 32, 62, 32, 48, 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46,114, 61, 32, 99,111,108, 49, 46,114, 32, + 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,114, 32, 45, 32, 48, 46, 53, 41, 41, 59, 10, 9,101,108,115, +101, 10, 9, 9,111,117,116, 99,111,108, 46,114, 61, 32, 99,111,108, 49, 46,114, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, + 40, 99,111,108, 50, 46,114, 41, 32, 45, 32, 49, 46, 48, 41, 59, 10, 10, 9,105,102, 40, 99,111,108, 50, 46,103, 32, 62, 32, 48, + 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 61, 32, 99,111,108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, + 48, 42, 40, 99,111,108, 50, 46,103, 32, 45, 32, 48, 46, 53, 41, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111, +108, 46,103, 61, 32, 99,111,108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,103, 41, 32, + 45, 32, 49, 46, 48, 41, 59, 10, 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 62, 32, 48, 46, 53, 41, 10, 9, 9,111,117,116, + 99,111,108, 46, 98, 61, 32, 99,111,108, 49, 46, 98, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, + 32, 45, 32, 48, 46, 53, 41, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 61, 32, 99,111,108, 49, + 46, 98, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 41, 32, 45, 32, 49, 46, 48, 41, 59, 10,125, + 10, 10,118,111,105,100, 32,118, 97,108,116,111,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,115, 97,109,112,108, +101,114, 50, 68, 32, 99,111,108,111,114,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,111,117,116, 97,108,112,104, 97, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, +116,101,120,116,117,114,101, 50, 68, 40, 99,111,108,111,114,109, 97,112, 44, 32,118,101, 99, 50, 40,102, 97, 99, 44, 32, 48, 46, + 48, 41, 41, 59, 10, 9,111,117,116, 97,108,112,104, 97, 32, 61, 32,111,117,116, 99,111,108, 46, 97, 59, 10,125, 10, 10,118,111, +105,100, 32,114,103, 98,116,111, 98,119, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, + 32,111,117,116,118, 97,108, 41, 32, 32, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 99,111,108,111,114, 46,114, 42, 48, + 46, 51, 53, 32, 43, 32, 99,111,108,111,114, 46,103, 42, 48, 46, 52, 53, 32, 43, 32, 99,111,108,111,114, 46, 98, 42, 48, 46, 50, + 59, 32, 47, 42, 32,107,101,101,112, 32,116,104,101,115,101, 32,102, 97, 99,116,111,114,115, 32,105,110, 32,115,121,110, 99, 32, +119,105,116,104, 32,116,101,120,116,117,114,101, 46,104, 58, 82, 71, 66, 84, 79, 66, 87, 32, 42, 47, 10,125, 10, 10,118,111,105, +100, 32,105,110,118,101,114,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117, +116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 46,120,121,122, 32, 61, 32,109, +105,120, 40, 99,111,108, 46,120,121,122, 44, 32,118,101, 99, 51, 40, 49, 46, 48, 44, 32, 49, 46, 48, 44, 32, 49, 46, 48, 41, 32, + 45, 32, 99,111,108, 46,120,121,122, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46,119, 32, 61, 32, 99,111,108, + 46,119, 59, 10,125, 10, 10,118,111,105,100, 32,104,117,101, 95,115, 97,116, 40,102,108,111, 97,116, 32,104,117,101, 44, 32,102, +108,111, 97,116, 32,115, 97,116, 44, 32,102,108,111, 97,116, 32,118, 97,108,117,101, 44, 32,102,108,111, 97,116, 32,102, 97, 99, + 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9, +118,101, 99, 52, 32,104,115,118, 59, 10, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 44, 32,104,115,118, 41, + 59, 10, 10, 9,104,115,118, 91, 48, 93, 32, 43, 61, 32, 40,104,117,101, 32, 45, 32, 48, 46, 53, 41, 59, 10, 9,105,102, 40,104, +115,118, 91, 48, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 48, 93, 45, 61, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40, +104,115,118, 91, 48, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 48, 93, 43, 61, 32, 49, 46, 48, 59, 10, 9,104,115,118, 91, 49, + 93, 32, 42, 61, 32,115, 97,116, 59, 10, 9,105,102, 40,104,115,118, 91, 49, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 49, 93, + 61, 32, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, 49, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 49, + 93, 61, 32, 48, 46, 48, 59, 10, 9,104,115,118, 91, 50, 93, 32, 42, 61, 32,118, 97,108,117,101, 59, 10, 9,105,102, 40,104,115, +118, 91, 50, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104, +115,118, 91, 50, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 48, 46, 48, 59, 10, 10, 9,104,115,118, 95,116,111, + 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105, +120, 40, 99,111,108, 44, 32,111,117,116, 99,111,108, 44, 32,102, 97, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,112, + 97,114, 97,116,101, 95,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114, 44, + 32,111,117,116, 32,102,108,111, 97,116, 32,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 98, 41, 10,123, 10, 9,114, 32, + 61, 32, 99,111,108, 46,114, 59, 10, 9,103, 32, 61, 32, 99,111,108, 46,103, 59, 10, 9, 98, 32, 61, 32, 99,111,108, 46, 98, 59, + 10,125, 10, 10,118,111,105,100, 32, 99,111,109, 98,105,110,101, 95,114,103, 98, 40,102,108,111, 97,116, 32,114, 44, 32,102,108, +111, 97,116, 32,103, 44, 32,102,108,111, 97,116, 32, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 41, 10,123, 10, + 9, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114, 44, 32,103, 44, 32, 98, 44, 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111, +105,100, 32,111,117,116,112,117,116, 95,110,111,100,101, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,102,108,111, 97,116, 32, 97, +108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 10,123, 10, 9,111,117,116,114,103, 98, + 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 46,114,103, 98, 44, 32, 97,108,112,104, 97, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 32, 84, 69, 88, 84, 85, 82, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 47, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95,102,108,105,112, 95, 98,108,101,110,100, 40,118,101, 99, 51, + 32,118,101, 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10, 9,111,117,116,118,101, 99, + 32, 61, 32,118,101, 99, 46,121,120,122, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110, +100, 95,108,105,110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, + 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 59, 10,125, + 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, 95,113,117, 97,100, 40,118,101, 99, 51, 32,118, +101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, + 61, 32,109, 97,120, 40, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 44, 32, 48, 46, 48, 41, 59, 10, 9,111,117, +116,118, 97,108, 32, 42, 61, 32,111,117,116,118, 97,108, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, +119,111,111,100, 95,115,105,110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118, 97,108, +117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114, +109, 97,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32, 97, 32, 61, 32,115,113,114,116, 40,118,101, 99, 46,120, 42,118,101, 99, + 46,120, 32, 43, 32,118,101, 99, 46,121, 42,118,101, 99, 46,121, 32, 43, 32,118,101, 99, 46,122, 42,118,101, 99, 46,122, 41, 42, + 50, 48, 46, 48, 59, 10, 9,102,108,111, 97,116, 32,119,105, 32, 61, 32, 48, 46, 53, 32, 43, 32, 48, 46, 53, 42,115,105,110, 40, + 97, 41, 59, 10, 10, 9,118, 97,108,117,101, 32, 61, 32,119,105, 59, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, +119,105, 44, 32,119,105, 44, 32,119,105, 44, 32, 49, 46, 48, 41, 59, 10, 9,110,111,114,109, 97,108, 32, 61, 32,118,101, 99, 51, + 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, + 95,105,109, 97,103,101, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,118, 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120, +116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 40,118,101, 99, 46,120,121, 32, 43, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, + 49, 46, 48, 41, 41, 42, 48, 46, 53, 41, 59, 10, 9,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 59, 10, 10, 9,110,111,114,109, + 97,108, 46,120, 32, 61, 32, 50, 46, 48, 42, 40, 99,111,108,111,114, 46,114, 32, 45, 32, 48, 46, 53, 41, 59, 10, 9,110,111,114, +109, 97,108, 46,121, 32, 61, 32, 50, 46, 48, 42, 40, 48, 46, 53, 32, 45, 32, 99,111,108,111,114, 46,103, 41, 59, 10, 9,110,111, +114,109, 97,108, 46,122, 32, 61, 32, 50, 46, 48, 42, 40, 99,111,108,111,114, 46, 98, 32, 45, 32, 48, 46, 53, 41, 59, 10,125, 10, + 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 77, 84, 69, 88, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 47, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111,114, 99,111, 40,118,101, 99, 51, 32, 97,116, +116,111,114, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 41, 10,123, 10, 9,111,114, 99,111, 32, 61, 32, + 97,116,116,111,114, 99,111, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,117,118, 40,118,101, 99, 50, 32, 97, +116,116,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 41, 10,123, 10, 9, 47, 42, 32,100,105,115, 97, 98,108,101, +100, 32,102,111,114, 32,110,111,119, 44, 32,119,111,114,107,115, 32,116,111,103,101,116,104,101,114, 32,119,105,116,104, 32,108, +101, 97,118,105,110,103, 32,111,117,116, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 10, 9, 32, 32, 32,117, +118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, + 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 32, 42, 47, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 44, 32, + 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,110,111,114,109, 40,118,101, 99, 51, 32,110,111, +114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9, 47, 42, 32, + 99,111,114,114,101,115,112,111,110,100,115, 32,116,111, 32,115,104,105, 45, 62,111,114,110, 44, 32,119,104,105, 99,104, 32,105, +115, 32,110,101,103, 97,116,101,100, 32,115,111, 32, 99, 97,110, 99,101,108,115, 10, 9, 32, 32, 32,111,117,116, 32, 98,108,101, +110,100,101,114, 32,110,111,114,109, 97,108, 32,110,101,103, 97,116,105,111,110, 32, 42, 47, 10, 9,111,117,116,110,111,114,109, + 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,110,111,114,109, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32, +116,101,120, 99,111, 95,116, 97,110,103,101,110,116, 40,118,101, 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,111,117,116, 32, +118,101, 99, 51, 32,111,117,116,116, 97,110,103,101,110,116, 41, 10,123, 10, 9,111,117,116,116, 97,110,103,101,110,116, 32, 61, + 32,110,111,114,109, 97,108,105,122,101, 40,116, 97,110,103,101,110,116, 46,120,121,122, 41, 59, 10,125, 10, 10,118,111,105,100, + 32,116,101,120, 99,111, 95,103,108,111, 98, 97,108, 40,109, 97,116, 52, 32,118,105,101,119,105,110,118,109, 97,116, 44, 32,118, +101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 41, 10,123, 10, 9,103,108,111, 98, + 97,108, 32, 61, 32, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, 48, 41, 41, 46, +120,121,122, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111, 98,106,101, 99,116, 40,109, 97,116, 52, 32,118, +105,101,119,105,110,118,109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 99, +111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 41, 10,123, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, + 40,111, 98,105,110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, + 46, 48, 41, 41, 41, 46,120,121,122, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,114,101,102,108, 40,118,101, + 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,114,101,102, 41, 10, +123, 10, 9,114,101,102, 32, 61, 32,118,105,101,119, 32, 45, 32, 50, 46, 48, 42,100,111,116, 40,118,110, 44, 32,118,105,101,119, + 41, 42,118,110, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,110,111,114,109, 40,118,101, 99, 51, 32,110,111, +114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9, 47, 42, 32, + 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,105,115, 32,110,101,103, 97,116,101,100, + 32, 42, 47, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108,105,122,101, 40,110,111,114,109, + 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 98,108,101,110,100, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, - 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, - 13, 10, 9,105,110, 99,111,108, 32, 61, 32, 45,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, 32,111, -117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 97,100,100, 40,118, -101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, - 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, - 13, 10,123, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, - 32,111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100,105,118, - 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, - 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111, -108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32, -102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 13, 10, 13, 10, 9,105,102, 40, -116,101,120, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46,114, 32, 61, 32,102, 97, 99,109, 42, -111,117,116, 99,111,108, 46,114, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46,114, 47,116,101,120, 99,111,108, 46, -114, 59, 13, 10, 9,105,102, 40,116,101,120, 99,111,108, 46,103, 32, 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46,103, - 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,103, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46,103, - 47,116,101,120, 99,111,108, 46,103, 59, 13, 10, 9,105,102, 40,116,101,120, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, - 32,105,110, 99,111,108, 46, 98, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99,116, 42, -111,117,116, 99,111,108, 46, 98, 47,116,101,120, 99,111,108, 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116, -101,120, 95,114,103, 98, 95,100,105,102,102, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101, -120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117, -116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, - 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, - 99,116, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, 32,102, 97, - 99,116, 42, 97, 98,115, 40,116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100, 97,114,107, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118, -101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, - 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, - 97, 99,109, 44, 32, 99,111,108, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, - 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 13, 10, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101, -120, 99,111,108, 46,114, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99, -111,108, 46,114, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111, -108, 46,114, 59, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 13, 10, 9,105,102, - 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32, -101,108,115,101, 32,105,110, 99,111,108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 13, 10, 9, 99,111,108, 32, 61, - 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46, 98, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111, -108, 46, 98, 41, 32,105,110, 99,111,108, 46, 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, - 32, 61, 32,111,117,116, 99,111,108, 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, - 95,108,105,103,104,116, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, - 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, - 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 44, 32, 99,111,108, 59, 13, 10, - 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, - 99,116, 59, 13, 10, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,114, 59, 13, 10, 9,105, -102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99,111,108, 46,114, 32, 61, 32, 99,111,108, 59, - 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46,114, 59, 13, 10, 9, 99,111,108, 32, - 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99, -111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, -103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111, -108, 46, 98, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46, 98, 41, 32,105,110, 99,111,108, 46, - 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,104,117,101, 40,118,101, 99, 51, 32,111, -117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32, -102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, - 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95,104,117,101, 40,102, 97, 99,116, 42,102, 97, 99,103, - 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, - 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46, -114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 97,116, 40,118,101, 99, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, + 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, + 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101, +120, 99,111,108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, + 95,114,103, 98, 95,109,117,108, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111, +108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118, +101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, + 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 10, 10, 9,105,110, + 99,111,108, 32, 61, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 41, 42,111,117,116, 99,111, +108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 99,114,101,101,110, 40,118,101, 99, 51, 32, +111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9, +102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99, +109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 10, 10, 9,105,110, 99,111,108, 32, 61, 32,118,101, 99, 51, 40, 49, 46, 48, + 41, 32, 45, 32, 40,118,101, 99, 51, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99,116, 42, 40,118,101, 99, 51, 40, 49, 46, 48, + 41, 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,111,117,116, 99,111,108, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,111,118,101,114,108, 97,121, 40,118,101, 99, 51, + 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, + 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, + 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, + 46, 53, 41, 10, 9, 9,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46,114, 42, 40,102, 97, 99,109, 32, 43, + 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,114, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,105,110, 99, +111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, 40, 49, + 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,114, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, + 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, 32, 60, 32, 48, 46, 53, 41, 10, 9, 9,105,110, 99,111,108, 46,103, + 32, 61, 32,111,117,116, 99,111,108, 46,103, 42, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, + 99,111,108, 46,103, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,105,110, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 32, 45, 32, + 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,103, + 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, + 46, 98, 32, 60, 32, 48, 46, 53, 41, 10, 9, 9,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 42, 40, +102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46, 98, 41, 59, 10, 9,101,108,115,101, + 10, 9, 9,105,110, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, + 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, + 99,111,108, 46, 98, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115,117, 98, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10, -123, 13, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95,115, 97,116, 40,102, 97, 99,116, 42,102, - 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, - 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99, -111,108, 46,114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,118, 97,108, 40, -118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32, -102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, - 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95,118, 97,108, 40,102, 97, 99, -116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40, -116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, - 61, 32, 99,111,108, 46,114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 99, -111,108,111,114, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32, -105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95, 99,111, -108,111,114, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, - 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99, -111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101, -120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,105,110,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,109, 41, 13, 10,123, 13, 10, 9, -102, 97, 99,116, 32, 42, 61, 32, 97, 98,115, 40,102, 97, 99,103, 41, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45, -102, 97, 99,116, 59, 13, 10, 13, 10, 9,105,102, 40,102, 97, 99,103, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,102,108, -111, 97,116, 32,116,109,112, 32, 61, 32,102, 97, 99,116, 59, 13, 10, 9, 9,102, 97, 99,116, 32, 61, 32,102, 97, 99,109, 59, 13, - 10, 9, 9,102, 97, 99,109, 32, 61, 32,116,109,112, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116, -101,120, 95,118, 97,108,117,101, 95, 98,108,101,110,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, - 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, - 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99, -103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111, -108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, - 95,118, 97,108,117,101, 95,109,117,108, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116, -101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111, -117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, - 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, - 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99,103, 59, 13, 10, 9,105, -110, 99,111,108, 32, 61, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 41, 42,111,117,116, 99, -111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,115, 99,114,101,101,110, - 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, - 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105, -110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97, -108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9, -102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99,103, 59, 13, 10, 9,105,110, 99,111,108, 32, 61, 32, 49, 46, 48, +116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, + 10, 9,105,110, 99,111,108, 32, 61, 32, 45,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, 32,111,117, +116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 97,100,100, 40,118,101, 99, 51, 32, +111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9, +105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, 99,111, +108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100,105,118, 40,118,101, 99, 51, 32,111,117,116, + 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108, +111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, + 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, + 32, 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9,105,102, 40,116,101,120, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, + 32,105,110, 99,111,108, 46,114, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,114, 32, 43, 32,102, 97, 99,116, 42, +111,117,116, 99,111,108, 46,114, 47,116,101,120, 99,111,108, 46,114, 59, 10, 9,105,102, 40,116,101,120, 99,111,108, 46,103, 32, + 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,103, 32, + 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46,103, 47,116,101,120, 99,111,108, 46,103, 59, 10, 9,105,102, 40,116,101, +120, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,102, 97, 99,109, 42,111,117, +116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46, 98, 47,116,101,120, 99,111,108, 46, 98, 59, + 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100,105,102,102, 40,118,101, 99, 51, 32,111,117,116, 99, +111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, + 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97, +116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, 32, + 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, + 43, 32,102, 97, 99,116, 42, 97, 98,115, 40,116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 10,125, 10, 10, +118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100, 97,114,107, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32, +118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, + 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, + 99,109, 44, 32, 99,111,108, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, + 32, 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,114, + 59, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99,111,108, 46,114, 32, 61, 32, + 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46,114, 59, 10, 9, 99, +111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117, +116, 99,111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111, +108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99, +111,108, 46, 98, 59, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46, 98, 41, 32,105,110, 99,111,108, 46, + 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,108,105,103,104,116, 40,118,101, 99, 51, 32,111,117, +116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, +108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108, +111, 97,116, 32,102, 97, 99,109, 44, 32, 99,111,108, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9, +102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101, +120, 99,111,108, 46,114, 59, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99,111, +108, 46,114, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, + 46,114, 59, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 10, 9,105,102, 40, 99,111, +108, 32, 62, 32,111,117,116, 99,111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32,101,108,115, +101, 32,105,110, 99,111,108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99, +116, 42,116,101,120, 99,111,108, 46, 98, 59, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46, 98, 41, 32, +105,110, 99,111,108, 46, 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117, +116, 99,111,108, 46, 98, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,104,117,101, 40,118,101, 99, + 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, +116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, + 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 10, 10, 9,109,105,120, 95,104,117,101, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, + 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, + 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, + 98, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 97,116, 40,118,101, 99, 51, 32,111,117,116, + 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108, +111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,118,101, 99, + 52, 32, 99,111,108, 59, 10, 10, 9,109,105,120, 95,115, 97,116, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, + 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, + 44, 32, 99,111,108, 41, 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 10,125, 10, + 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,118, 97,108, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32, +118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, + 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,118,101, 99, 52, 32, 99,111,108, + 59, 10, 10, 9,109,105,120, 95,118, 97,108, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99, +111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, + 41, 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 10,125, 10, 10,118,111,105,100, + 32,109,116,101,120, 95,114,103, 98, 95, 99,111,108,111,114, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, + 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, + 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 10, 10, + 9,109,105,120, 95, 99,111,108,111,114, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111, +108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, + 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 10,125, 10, 10,118,111,105,100, 32, +109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,105,110,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,116, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,109, 41, 10,123, 10, + 9,102, 97, 99,116, 32, 42, 61, 32, 97, 98,115, 40,102, 97, 99,103, 41, 59, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45, +102, 97, 99,116, 59, 10, 10, 9,105,102, 40,102, 97, 99,103, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108,111, 97,116, + 32,116,109,112, 32, 61, 32,102, 97, 99,116, 59, 10, 9, 9,102, 97, 99,116, 32, 61, 32,102, 97, 99,109, 59, 10, 9, 9,102, 97, + 99,109, 32, 61, 32,116,109,112, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, + 98,108,101,110,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95, +118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9, +105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, 99,111, +108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,109,117,108, 40,102,108,111, 97,116, 32, +111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, + 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, + 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, + 32,102, 97, 99,103, 59, 10, 9,105,110, 99,111,108, 32, 61, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, + 99,111,108, 41, 42,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, +115, 99,114,101,101,110, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111, +108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102, +108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, + 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, + 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99,103, 59, 10, 9,105,110, 99,111,108, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, - 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, -118, 97,108,117,101, 95,115,117, 98, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101, -120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, - 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, - 99,109, 41, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 61, 32, 45,102, 97, 99,116, 59, 13, 10, 9,105,110, 99,111,108, 32, 61, - 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 97,100,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102, -108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, - 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, - 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, - 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 61, 32,102, 97, 99,116, 59, 13, 10, 9,105, -110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, 99,111,108, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,100,105,118, 40,102,108,111, 97,116, 32,111,117,116, - 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, - 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, - 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,105,102, 40,116,101,120, 99,111,108, 32, - 33, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, - 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 47,116,101,120, 99,111,108, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105, -110, 99,111,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117, + 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108, +117,101, 95,115,117, 98, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111, +108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102, +108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, + 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, + 9,102, 97, 99,116, 32, 61, 32, 45,102, 97, 99,116, 59, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, + 99,111,108, 32, 43, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, + 95, 97,100,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, + 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,102, + 97, 99,116, 32, 61, 32,102, 97, 99,116, 59, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, + 32, 43, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,100,105, +118, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108, +111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, +105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, 97,108,117, +101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,105,102, 40,116, +101,120, 99,111,108, 32, 33, 61, 32, 48, 46, 48, 41, 10, 9, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, + 99,111,108, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 47,116,101,120, 99,111,108, 59, 10, 9,101,108,115,101, 10, + 9, 9,105,110, 99,111,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117, 101, 95,100,105,102,102, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111, 108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109, +108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, + 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, + 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, 32,102, 97, 99,116, 42, 97, 98,115, 40, +116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, + 97,108,117,101, 95,100, 97,114,107, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101, +120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109, 116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, - 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, 32,102, 97, 99,116, - 42, 97, 98,115, 40,116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,100, 97,114,107, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32, -102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32, -102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97, -116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32, -102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102,108,111, 97,116, 32, 99,111,108, 32, 61, 32,102, 97, 99, -116, 42,116,101,120, 99,111,108, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 41, 32,105,110, 99, -111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 32, 61, 32,111,117,116, 99,111,108, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,108,105,103,104,116, 40,102,108,111, 97,116, - 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97, -114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102,108,111, 97,116, 32, - 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117, -116, 99,111,108, 41, 32,105,110, 99,111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 32, 61, 32, -111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 99,108, - 97,109,112, 95,112,111,115,105,116,105,118,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,111,117,116,102, 97, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,102, 97, 99, 32, 61, 32,109, 97,120, 40,102, 97, 99, 44, - 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 99,108, 97, -109,112, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 13, - 10,123, 13, 10, 9,111,117,116,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, - 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,104, 97,114, 95,100,105,118,105,100,101, 40,102, -108,111, 97,116, 32,104, 97,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,104, 97,114, 41, 13, 10,123, 13, 10, - 9,111,117,116,104, 97,114, 32, 61, 32,104, 97,114, 47, 49, 50, 56, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, -109,116,101,120, 95,104, 97,114, 95,109,117,108,116,105,112,108,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32,104, 97, -114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,104, 97,114, 41, 13, 10,123, 13, 10, 9,104, 97,114, 32, 42, 61, - 32, 49, 50, 56, 46, 48, 59, 13, 10, 13, 10, 9,105,102, 40,104, 97,114, 32, 60, 32, 49, 46, 48, 41, 32,111,117,116,104, 97,114, - 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,104, 97,114, 32, 62, 32, 53, 49, 49, 46, 48, 41, 32,111, -117,116,104, 97,114, 32, 61, 32, 53, 49, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,111,117,116,104, 97,114, 32, 61, 32,104, - 97,114, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 97,108,112,104, 97, 95,102,114,111,109, 95, 99, -111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 41, 13, 10,123, - 13, 10, 9, 97,108,112,104, 97, 32, 61, 32, 99,111,108, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101, -120, 95, 97,108,112,104, 97, 95,116,111, 95, 99,111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32, 97, -108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99, -111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 97,108,112,104, 97, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98,116,111,105,110,116, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,105,110,116,101,110,115,105,116,121, 41, 13, 10,123, 13, 10, 9,105,110,116,101,110,115,105,116, -121, 32, 61, 32,100,111,116, 40,118,101, 99, 51, 40, 48, 46, 51, 53, 44, 32, 48, 46, 52, 53, 44, 32, 48, 46, 50, 41, 44, 32,114, -103, 98, 46,114,103, 98, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,105, -110,118,101,114,116, 40,102,108,111, 97,116, 32,105,110,118, 97,108,117,101, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111, -117,116,118, 97,108,117,101, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 32, 45, 32,105, -110,118, 97,108,117,101, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,105,110,118,101, -114,116, 40,118,101, 99, 52, 32,105,110,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 13, - 10,123, 13, 10, 9,111,117,116,114,103, 98, 32, 61, 32,118,101, 99, 52, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,105, -110,114,103, 98, 46,114,103, 98, 44, 32,105,110,114,103, 98, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, -116,101,120, 95,118, 97,108,117,101, 95,115,116,101,110, 99,105,108, 40,102,108,111, 97,116, 32,115,116,101,110, 99,105,108, 44, - 32,102,108,111, 97,116, 32,105,110,116,101,110,115,105,116,121, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115, -116,101,110, 99,105,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105,110,116,101,110,115,105,116,121, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,116, 32, 61, 32,105,110,116,101,110,115,105,116,121, 59, 13, 10, 9,111, -117,116,105,110,116,101,110,115,105,116,121, 32, 61, 32,105,110,116,101,110,115,105,116,121, 42,115,116,101,110, 99,105,108, 59, - 13, 10, 9,111,117,116,115,116,101,110, 99,105,108, 32, 61, 32,115,116,101,110, 99,105,108, 42,102, 97, 99,116, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115,116,101,110, 99,105,108, 40,102,108,111, 97,116, 32, -115,116,101,110, 99,105,108, 44, 32,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, -115,116,101,110, 99,105,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 13, 10,123, 13, 10, 9,102, -108,111, 97,116, 32,102, 97, 99,116, 32, 61, 32,114,103, 98, 46, 97, 59, 13, 10, 9,111,117,116,114,103, 98, 32, 61, 32,118,101, - 99, 52, 40,114,103, 98, 46,114,103, 98, 44, 32,114,103, 98, 46, 97, 42,115,116,101,110, 99,105,108, 41, 59, 13, 10, 9,111,117, -116,115,116,101,110, 99,105,108, 32, 61, 32,115,116,101,110, 99,105,108, 42,102, 97, 99,116, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,111,102,115, 40,118,101, 99, 51, 32,116,101,120, 99,111, 44, - 32,118,101, 99, 51, 32,111,102,115, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, 99,111, 41, 13, 10,123, - 13, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,116,101,120, 99,111, 32, 43, 32,111,102,115, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,115,105,122,101, 40,118,101, 99, 51, 32,116,101,120, - 99,111, 44, 32,118,101, 99, 51, 32,115,105,122,101, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, 99,111, - 41, 13, 10,123, 13, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,115,105,122,101, 42,116,101,120, 99,111, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, - 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, - 61, 32,118,101, 99, 51, 40,118,101, 99, 46,120,121, 42, 48, 46, 53, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 32, 48, 46, - 53, 41, 44, 32,118,101, 99, 46,122, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,105,109, 97,103, -101, 40,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, - 32,102,108,111, 97,116, 32,118, 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 13, 10,123, - 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46, -120,121, 41, 59, 13, 10, 9,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, -116,101,120, 95,110,111,114,109, 97,108, 40,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, - 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9, 47, 47, 32, 84, -104,101, 32,105,110,118,101,114,116, 32,111,102, 32,116,104,101, 32,114,101,100, 32, 99,104, 97,110,110,101,108, 32,105,115, 32, -116,111, 32,109, 97,107,101, 13, 10, 9, 47, 47, 32,116,104,101, 32,110,111,114,109, 97,108, 32,109, 97,112, 32, 99,111,109,112, -108,105, 97,110,116, 32,119,105,116,104, 32,116,104,101, 32,111,117,116,115,105,100,101, 32,119,111,114,108,100, 46, 13, 10, 9, - 47, 47, 32, 73,116, 32,110,101,101,100,115, 32,116,111, 32, 98,101, 32,100,111,110,101, 32, 98,101, 99, 97,117,115,101, 32,105, -110, 32, 66,108,101,110,100,101,114, 13, 10, 9, 47, 47, 32,116,104,101, 32,110,111,114,109, 97,108, 32,117,115,101,100, 32,112, -111,105,110,116,115, 32,105,110,119, 97,114,100, 46, 13, 10, 9, 47, 47, 32, 83,104,111,117,108,100, 32,116,104,105,115, 32,101, -118,101,114, 32, 99,104, 97,110,103,101, 32,116,104,105,115, 32,110,101,103, 97,116,101, 32,109,117,115,116, 32, 98,101, 32,114, -101,109,111,118,101,100, 46, 13, 10, 32, 32, 32, 32,118,101, 99, 52, 32, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114, -101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 32, 61, 32, 50, - 46, 48, 42, 40,118,101, 99, 51, 40, 45, 99,111,108,111,114, 46,114, 44, 32, 99,111,108,111,114, 46,103, 44, 32, 99,111,108,111, -114, 46, 98, 41, 32, 45, 32,118,101, 99, 51, 40, 45, 48, 46, 53, 44, 32, 48, 46, 53, 44, 32, 48, 46, 53, 41, 41, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,110,111,114,109, 97,108,115, 95,105,110,105,116, 40, - 32,118,101, 99, 51, 32,118, 78, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78,111,114,103, 44, 32,111,117,116, 32,118,101, - 99, 51, 32,118, 78, 97, 99, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117, -100,101, 32, 41, 13, 10,123, 13, 10, 9,118, 78,111,114,103, 32, 61, 32,118, 78, 59, 13, 10, 9,118, 78, 97, 99, 99, 32, 61, 32, -118, 78, 59, 13, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, - 13, 10, 47, 42, 42, 32,104,101,108,112,101,114, 32,109,101,116,104,111,100, 32,116,111, 32,101,120,116,114, 97, 99,116, 32,116, + 59, 10, 10, 9,102,108,111, 97,116, 32, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 59, 10, 9,105,102, + 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 41, 32,105,110, 99,111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, + 32,105,110, 99,111,108, 32, 61, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97, +108,117,101, 95,108,105,103,104,116, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101, +120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109, +116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, + 59, 10, 10, 9,102,108,111, 97,116, 32, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 59, 10, 9,105,102, + 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 41, 32,105,110, 99,111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, + 32,105,110, 99,111,108, 32, 61, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97, +108,117,101, 95, 99,108, 97,109,112, 95,112,111,115,105,116,105,118,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 10,123, 10, 9,111,117,116,102, 97, 99, 32, 61, 32,109, 97,120, 40, +102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 99,108, + 97,109,112, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, + 10,123, 10, 9,111,117,116,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,104, 97,114, 95,100,105,118,105,100,101, 40,102,108,111, 97,116, + 32,104, 97,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,104, 97,114, 41, 10,123, 10, 9,111,117,116,104, 97, +114, 32, 61, 32,104, 97,114, 47, 49, 50, 56, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,104, 97,114, 95, +109,117,108,116,105,112,108,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32,104, 97,114, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,111,117,116,104, 97,114, 41, 10,123, 10, 9,104, 97,114, 32, 42, 61, 32, 49, 50, 56, 46, 48, 59, 10, 10, 9,105, +102, 40,104, 97,114, 32, 60, 32, 49, 46, 48, 41, 32,111,117,116,104, 97,114, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, + 32,105,102, 40,104, 97,114, 32, 62, 32, 53, 49, 49, 46, 48, 41, 32,111,117,116,104, 97,114, 32, 61, 32, 53, 49, 49, 46, 48, 59, + 10, 9,101,108,115,101, 32,111,117,116,104, 97,114, 32, 61, 32,104, 97,114, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101, +120, 95, 97,108,112,104, 97, 95,102,114,111,109, 95, 99,111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102, +108,111, 97,116, 32, 97,108,112,104, 97, 41, 10,123, 10, 9, 97,108,112,104, 97, 32, 61, 32, 99,111,108, 46, 97, 59, 10,125, 10, + 10,118,111,105,100, 32,109,116,101,120, 95, 97,108,112,104, 97, 95,116,111, 95, 99,111,108, 40,118,101, 99, 52, 32, 99,111,108, + 44, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10, +123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 97,108,112,104, 97, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98,116,111,105,110,116, 40,118,101, 99, 52, 32,114,103, 98, + 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,116,101,110,115,105,116,121, 41, 10,123, 10, 9,105,110,116,101,110,115, +105,116,121, 32, 61, 32,100,111,116, 40,118,101, 99, 51, 40, 48, 46, 51, 53, 44, 32, 48, 46, 52, 53, 44, 32, 48, 46, 50, 41, 44, + 32,114,103, 98, 46,114,103, 98, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,105,110, +118,101,114,116, 40,102,108,111, 97,116, 32,105,110,118, 97,108,117,101, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117, +116,118, 97,108,117,101, 41, 10,123, 10, 9,111,117,116,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 32, 45, 32,105,110,118, 97, +108,117,101, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,105,110,118,101,114,116, 40,118,101, 99, + 52, 32,105,110,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 10,123, 10, 9,111,117,116, +114,103, 98, 32, 61, 32,118,101, 99, 52, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,105,110,114,103, 98, 46,114,103, 98, + 44, 32,105,110,114,103, 98, 46, 97, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,115, +116,101,110, 99,105,108, 40,102,108,111, 97,116, 32,115,116,101,110, 99,105,108, 44, 32,102,108,111, 97,116, 32,105,110,116,101, +110,115,105,116,121, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,116,101,110, 99,105,108, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,111,117,116,105,110,116,101,110,115,105,116,121, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, + 99,116, 32, 61, 32,105,110,116,101,110,115,105,116,121, 59, 10, 9,111,117,116,105,110,116,101,110,115,105,116,121, 32, 61, 32, +105,110,116,101,110,115,105,116,121, 42,115,116,101,110, 99,105,108, 59, 10, 9,111,117,116,115,116,101,110, 99,105,108, 32, 61, + 32,115,116,101,110, 99,105,108, 42,102, 97, 99,116, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, +115,116,101,110, 99,105,108, 40,102,108,111, 97,116, 32,115,116,101,110, 99,105,108, 44, 32,118,101, 99, 52, 32,114,103, 98, 44, + 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,116,101,110, 99,105,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +111,117,116,114,103, 98, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,116, 32, 61, 32,114,103, 98, 46, 97, 59, 10, 9, +111,117,116,114,103, 98, 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 46,114,103, 98, 44, 32,114,103, 98, 46, 97, 42,115,116,101, +110, 99,105,108, 41, 59, 10, 9,111,117,116,115,116,101,110, 99,105,108, 32, 61, 32,115,116,101,110, 99,105,108, 42,102, 97, 99, +116, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,111,102,115, 40,118,101, 99, 51, + 32,116,101,120, 99,111, 44, 32,118,101, 99, 51, 32,111,102,115, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101, +120, 99,111, 41, 10,123, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,116,101,120, 99,111, 32, 43, 32,111,102,115, 59, 10, +125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,115,105,122,101, 40,118,101, 99, 51, 32,116, +101,120, 99,111, 44, 32,118,101, 99, 51, 32,115,105,122,101, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, + 99,111, 41, 10,123, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,115,105,122,101, 42,116,101,120, 99,111, 59, 10,125, 10, + 10,118,111,105,100, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, 99, 44, 32, +111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118,101, 99, + 51, 40,118,101, 99, 46,120,121, 42, 48, 46, 53, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 32, 48, 46, 53, 41, 44, 32,118, +101, 99, 46,122, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,105,109, 97,103,101, 40,118,101, 99, 51, 32,116, +101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118, + 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, + 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118, 97,108,117, +101, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,110,111,114,109, 97,108, 40,118,101, 99, + 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 51, + 32,110,111,114,109, 97,108, 41, 10,123, 10, 9, 47, 47, 32, 84,104,101, 32,105,110,118,101,114,116, 32,111,102, 32,116,104,101, + 32,114,101,100, 32, 99,104, 97,110,110,101,108, 32,105,115, 32,116,111, 32,109, 97,107,101, 10, 9, 47, 47, 32,116,104,101, 32, +110,111,114,109, 97,108, 32,109, 97,112, 32, 99,111,109,112,108,105, 97,110,116, 32,119,105,116,104, 32,116,104,101, 32,111,117, +116,115,105,100,101, 32,119,111,114,108,100, 46, 10, 9, 47, 47, 32, 73,116, 32,110,101,101,100,115, 32,116,111, 32, 98,101, 32, +100,111,110,101, 32, 98,101, 99, 97,117,115,101, 32,105,110, 32, 66,108,101,110,100,101,114, 10, 9, 47, 47, 32,116,104,101, 32, +110,111,114,109, 97,108, 32,117,115,101,100, 32,112,111,105,110,116,115, 32,105,110,119, 97,114,100, 46, 10, 9, 47, 47, 32, 83, +104,111,117,108,100, 32,116,104,105,115, 32,101,118,101,114, 32, 99,104, 97,110,103,101, 32,116,104,105,115, 32,110,101,103, 97, +116,101, 32,109,117,115,116, 32, 98,101, 32,114,101,109,111,118,101,100, 46, 10, 32, 32, 32, 32,118,101, 99, 52, 32, 99,111,108, +111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9, +110,111,114,109, 97,108, 32, 61, 32, 50, 46, 48, 42, 40,118,101, 99, 51, 40, 45, 99,111,108,111,114, 46,114, 44, 32, 99,111,108, +111,114, 46,103, 44, 32, 99,111,108,111,114, 46, 98, 41, 32, 45, 32,118,101, 99, 51, 40, 45, 48, 46, 53, 44, 32, 48, 46, 53, 44, + 32, 48, 46, 53, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,110,111,114,109, 97,108, +115, 95,105,110,105,116, 40, 32,118,101, 99, 51, 32,118, 78, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78,111,114,103, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, + 77, 97,103,110,105,116,117,100,101, 32, 41, 10,123, 10, 9,118, 78,111,114,103, 32, 61, 32,118, 78, 59, 10, 9,118, 78, 97, 99, + 99, 32, 61, 32,118, 78, 59, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 49, 46, 48, 59, 10,125, + 10, 10, 47, 42, 42, 32,104,101,108,112,101,114, 32,109,101,116,104,111,100, 32,116,111, 32,101,120,116,114, 97, 99,116, 32,116, 104,101, 32,117,112,112,101,114, 32,108,101,102,116, 32, 51,120, 51, 32,109, 97,116,114,105,120, 32,102,114,111,109, 32, 97, 32, - 52,120, 52, 32,109, 97,116,114,105,120, 32, 42, 47, 13, 10,109, 97,116, 51, 32,116,111, 95,109, 97,116, 51, 40,109, 97,116, 52, - 32,109, 52, 41, 13, 10,123, 13, 10, 9,109, 97,116, 51, 32,109, 51, 59, 13, 10, 9,109, 51, 91, 48, 93, 32, 61, 32,109, 52, 91, - 48, 93, 46,120,121,122, 59, 13, 10, 9,109, 51, 91, 49, 93, 32, 61, 32,109, 52, 91, 49, 93, 46,120,121,122, 59, 13, 10, 9,109, - 51, 91, 50, 93, 32, 61, 32,109, 52, 91, 50, 93, 46,120,121,122, 59, 13, 10, 9,114,101,116,117,114,110, 32,109, 51, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,111, 98,106,115,112, 97, 99, -101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, - 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,109, 97,116, 52, 32,109, 86,105,101,119, 44, 32,109, 97,116, 52, 32,109, 86,105, -101,119, 73,110,118, 44, 32,109, 97,116, 52, 32,109, 79, 98,106, 44, 32,109, 97,116, 52, 32,109, 79, 98,106, 73,110,118, 44, 32, - 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95, -105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, - 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, 32,118, -101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, - 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, -102, 68,101,116, 32, 41, 32, 13, 10,123, 13, 10, 9,109, 97,116, 51, 32,111, 98,106, 50,118,105,101,119, 32, 61, 32,116,111, 95, -109, 97,116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, 77, 97,116,114,105,120, 41, 59, 13, 10, 9,109, 97,116, 51, - 32,118,105,101,119, 50,111, 98,106, 32, 61, 32,116,111, 95,109, 97,116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, - 77, 97,116,114,105,120, 73,110,118,101,114,115,101, 41, 59, 13, 10, 9, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, - 83, 32, 61, 32,118,105,101,119, 50,111, 98,106, 32, 42, 32,100, 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, - 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, 61, 32,118,105,101,119, 50,111, 98,106, 32, 42, 32,100, 70,100, -121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, 32,110,111,114,109, 97, -108,105,122,101, 40, 32,115,117,114,102, 95,110,111,114,109, 32, 42, 32,111, 98,106, 50,118,105,101,119, 32, 41, 59, 13, 10, 13, - 10, 9,118, 82, 49, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 59, 13, 10, 9, -118, 82, 50, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 59, 13, 10, 9,102, - 68,101,116, 32, 61, 32,100,111,116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, 59, 13, 10, 9, 13, 10, - 9, 47, 42, 32,112,114,101,116,114, 97,110,115,102,111,114,109, 32,118, 78, 97, 99, 99, 32, 40,105,110, 32,109,116,101,120, 95, - 98,117,109,112, 95, 97,112,112,108,121, 41, 32,117,115,105,110,103, 32,116,104,101, 32,105,110,118,101,114,115,101, 32,116,114, - 97,110,115,112,111,115,101,100, 32, 42, 47, 13, 10, 9,118, 82, 49, 32, 61, 32,118, 82, 49, 32, 42, 32,118,105,101,119, 50,111, - 98,106, 59, 13, 10, 9,118, 82, 50, 32, 61, 32,118, 82, 50, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 13, 10, 9,118, 78, - 32, 61, 32,118, 78, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 13, 10, 9, 13, 10, 9,102,108,111, 97,116, 32,102, 77, 97, + 52,120, 52, 32,109, 97,116,114,105,120, 32, 42, 47, 10,109, 97,116, 51, 32,116,111, 95,109, 97,116, 51, 40,109, 97,116, 52, 32, +109, 52, 41, 10,123, 10, 9,109, 97,116, 51, 32,109, 51, 59, 10, 9,109, 51, 91, 48, 93, 32, 61, 32,109, 52, 91, 48, 93, 46,120, +121,122, 59, 10, 9,109, 51, 91, 49, 93, 32, 61, 32,109, 52, 91, 49, 93, 46,120,121,122, 59, 10, 9,109, 51, 91, 50, 93, 32, 61, + 32,109, 52, 91, 50, 93, 46,120,121,122, 59, 10, 9,114,101,116,117,114,110, 32,109, 51, 59, 10,125, 10, 10,118,111,105,100, 32, +109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,111, 98,106,115,112, 97, 99,101, 40, 32,118,101, 99, 51, 32,115,117, +114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, 44, 10, 9, 9, 9, 9, 9, 9, 9, 32, + 32,109, 97,116, 52, 32,109, 86,105,101,119, 44, 32,109, 97,116, 52, 32,109, 86,105,101,119, 73,110,118, 44, 32,109, 97,116, 52, + 32,109, 79, 98,106, 44, 32,109, 97,116, 52, 32,109, 79, 98,106, 73,110,118, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,102, +108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, + 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, + 97,103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, + 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, + 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 68,101,116, 32, 41, 32, 10,123, 10, 9,109, 97,116, + 51, 32,111, 98,106, 50,118,105,101,119, 32, 61, 32,116,111, 95,109, 97,116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101, +119, 77, 97,116,114,105,120, 41, 59, 10, 9,109, 97,116, 51, 32,118,105,101,119, 50,111, 98,106, 32, 61, 32,116,111, 95,109, 97, +116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, 77, 97,116,114,105,120, 73,110,118,101,114,115,101, 41, 59, 10, 9, + 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, 61, 32,118,105,101,119, 50,111, 98,106, 32, 42, 32,100, 70,100,120, + 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, 61, 32,118,105, +101,119, 50,111, 98,106, 32, 42, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, + 32,118, 78, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,115,117,114,102, 95,110,111,114,109, 32, 42, 32,111, 98,106, + 50,118,105,101,119, 32, 41, 59, 10, 10, 9,118, 82, 49, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, + 32,118, 78, 32, 41, 59, 10, 9,118, 82, 50, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, + 32, 41, 32, 59, 10, 9,102, 68,101,116, 32, 61, 32,100,111,116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, + 41, 59, 10, 9, 10, 9, 47, 42, 32,112,114,101,116,114, 97,110,115,102,111,114,109, 32,118, 78, 97, 99, 99, 32, 40,105,110, 32, +109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 41, 32,117,115,105,110,103, 32,116,104,101, 32,105,110,118,101,114, +115,101, 32,116,114, 97,110,115,112,111,115,101,100, 32, 42, 47, 10, 9,118, 82, 49, 32, 61, 32,118, 82, 49, 32, 42, 32,118,105, +101,119, 50,111, 98,106, 59, 10, 9,118, 82, 50, 32, 61, 32,118, 82, 50, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 10, 9, +118, 78, 32, 61, 32,118, 78, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 10, 9, 10, 9,102,108,111, 97,116, 32,102, 77, 97, 103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 32, 42, 32,108,101,110,103,116,104, 40,118, 78, 41, - 59, 13, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103, -110,105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 13, 10, 9,102, - 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,116,101,120,116,117,114, -101,115,112, 97, 99,101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, - 95,110,111,114,109, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97, -103,110,105,116,117,100,101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, - 9, 9, 9, 9, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111, -117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, - 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32, -111,117,116, 32,102,108,111, 97,116, 32,102, 68,101,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103, -109, 97, 83, 32, 61, 32,100, 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, - 83,105,103,109, 97, 84, 32, 61, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, - 51, 32,118, 78, 32, 61, 32,115,117,114,102, 95,110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32, -105,110,116,101,114,112,111,108, 97,116,101,100, 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 13, 10, 9, - 13, 10, 9,118, 82, 49, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, - 97, 84, 44, 32,118, 78, 32, 41, 32, 41, 59, 13, 10, 9,118, 82, 50, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32, 99, -114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 41, 59, 13, 10, 9,102, 68,101,116, 32, 61, 32, -115,105,103,110, 40, 32,100,111,116, 40,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 41, 32, 41, 59, 13, 10, 9, 13, 10, 9, -102,108,111, 97,116, 32,102, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 13, 10, 9, -118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117, -100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 13, 10, 9,102, 80,114,101,118, - 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,118,105,101,119,115,112, 97, 99,101, 40, - 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, 44, 32, - 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, - 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111, + 59, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110, +105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 10, 9,102, 80,114, +101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 10,125, 10, + 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,116,101,120,116,117,114,101,115,112, 97, 99, +101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, + 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100, +101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,111, 117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111,117,116, - 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, - 97,116, 32,102, 68,101,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, 61, 32,100, - 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, - 61, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, 32, -115,117,114,102, 95,110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32,105,110,116,101,114,112,111, -108, 97,116,101,100, 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 13, 10, 9, 13, 10, 9,118, 82, 49, 32, - 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 59, 13, 10, 9,118, 82, 50, 32, 61, 32, - 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 59, 13, 10, 9,102, 68,101,116, 32, 61, 32, -100,111,116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, 59, 13, 10, 9, 13, 10, 9,102,108,111, 97,116, - 32,102, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 13, 10, 9,118, 78, 97, 99, 99, - 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117,100,101, 32, 47, 32, -102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 13, 10, 9,102, 80,114,101,118, 77, 97,103,110,105, -116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,109,116,101,120, 95, 98,117,109,112, 95,116, 97,112, 51, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97, -109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 50, 32, 83, 84,108,108, - 32, 61, 32,116,101,120, 99,111, 46,120,121, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,108,114, 32, 61, 32,116,101,120, 99,111, - 46,120,121, 32, 43, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84, -117,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 32, 59, - 13, 10, 9, 13, 10, 9,102,108,111, 97,116, 32, 72,108,108, 44, 72,108,114, 44, 72,117,108, 59, 13, 10, 9,114,103, 98,116,111, - 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108,108, 41, 44, 32, 72,108,108, 32, 41, 59, - 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108,114, 41, - 44, 32, 72,108,114, 32, 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, - 97, 44, 32, 83, 84,117,108, 41, 44, 32, 72,117,108, 32, 41, 59, 13, 10, 9, 13, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97, -108,101, 32, 42, 32, 40, 72,108,114, 32, 45, 32, 72,108,108, 41, 59, 13, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, - 32, 42, 32, 40, 72,117,108, 32, 45, 32, 72,108,108, 41, 59, 13, 10,125, 13, 10, 13, 10, 35,105,102,100,101,102, 32, 66, 85, 77, - 80, 95, 66, 73, 67, 85, 66, 73, 67, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 98,105, 99,117, - 98,105, 99, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32, -102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66, -116, 32, 41, 32, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, 72,108, 59, 13, 10, 9,102,108,111, 97,116, 32, 72,114, 59, 13, - 10, 9,102,108,111, 97,116, 32, 72,100, 59, 13, 10, 9,102,108,111, 97,116, 32, 72,117, 59, 13, 10, 9, 13, 10, 9,118,101, 99, - 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 13, 10, 9,118,101, 99, 50, - 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 13, 10, 32, 13, 10, 9,118,101, - 99, 50, 32, 83, 84,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, - 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, - 84,101,120, 68,120, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, - 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, 32,116,101,120, 99,111, - 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9, 13, 10, 9,114,103, 98,116,111, 98,119, - 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 41, 59, 13, 10, 9,114,103, 98, -116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, 32, 72,114, 41, 59, 13, 10, - 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,100, 41, 44, 32, 72,100, - 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, - 44, 32, 72,117, 41, 59, 13, 10, 9, 13, 10, 9,118,101, 99, 50, 32,100, 72,100,120,121, 32, 61, 32,118,101, 99, 50, 40, 72,114, - 32, 45, 32, 72,108, 44, 32, 72,117, 32, 45, 32, 72,100, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 66,108,101,110,100, 32, - 61, 32, 99,108, 97,109,112, 40, 49, 46, 48, 45,116,101,120,116,117,114,101, 81,117,101,114,121, 76, 79, 68, 40,105,109, 97, 44, - 32,116,101,120, 99,111, 46,120,121, 41, 46,120, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,105,102, 40,102, 66, -108,101,110,100, 33, 61, 48, 46, 48, 41, 13, 10, 9,123, 13, 10, 9, 9, 47, 47, 32,116,104,101, 32,100,101,114,105,118, 97,116, -105,118,101, 32,111,102, 32,116,104,101, 32, 98,105, 99,117, 98,105, 99, 32,115, 97,109,112,108,105,110,103, 32,111,102, 32,108, -101,118,101,108, 32, 48, 13, 10, 9, 9,105,118,101, 99, 50, 32,118, 68,105,109, 59, 13, 10, 9, 9,118, 68,105,109, 32, 61, 32, -116,101,120,116,117,114,101, 83,105,122,101, 40,105,109, 97, 44, 32, 48, 41, 59, 13, 10, 13, 10, 9, 9, 47, 47, 32,116, 97,107, -105,110,103, 32,116,104,101, 32,102,114, 97, 99,116, 32,112, 97,114,116, 32,111,102, 32,116,104,101, 32,116,101,120,116,117,114, -101, 32, 99,111,111,114,100,105,110, 97,116,101, 32,105,115, 32, 97, 32,104, 97,114,100, 99,111,100,101,100, 32,119,114, 97,112, - 32,109,111,100,101, 46, 13, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32, 97, 99, 99,101,112,116, 97, 98,108,101, 32, - 97,115, 32,116,101,120,116,117,114,101,115, 32,117,115,101, 32,119,114, 97,112, 32,109,111,100,101, 32,101,120, 99,108,117,115, -105,118,101,108,121, 32,105,110, 32, 51, 68, 32,118,105,101,119, 32,101,108,115,101,119,104,101,114,101, 32,105,110, 32, 98,108, -101,110,100,101,114, 46, 32, 13, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32,100,111,110,101, 32,115,111, 32,116,104, - 97,116, 32,119,101, 32, 99, 97,110, 32,115,116,105,108,108, 32,103,101,116, 32, 97, 32,118, 97,108,105,100, 32,116,101,120,101, -108, 32,119,105,116,104, 32,117,118,115, 32,111,117,116,115,105,100,101, 32,116,104,101, 32, 48, 44, 49, 32,114, 97,110,103,101, - 13, 10, 9, 9, 47, 47, 32, 98,121, 32,116,101,120,101,108, 70,101,116, 99,104, 32, 98,101,108,111,119, 44, 32, 97,115, 32, 99, -111,111,114,100,105,110, 97,116,101,115, 32, 97,114,101, 32, 99,108, 97,109,112,101,100, 32,119,104,101,110, 32,117,115,105,110, -103, 32,116,104,105,115, 32,102,117,110, 99,116,105,111,110, 46, 13, 10, 9, 9,118,101, 99, 50, 32,102, 84,101,120, 76,111, 99, - 32, 61, 32,118, 68,105,109, 42,102,114, 97, 99,116, 40,116,101,120, 99,111, 46,120,121, 41, 32, 45, 32,118,101, 99, 50, 40, 48, - 46, 53, 44, 32, 48, 46, 53, 41, 59, 13, 10, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, 99, 32, 61, 32,105,118,101, - 99, 50, 40,102,108,111,111,114, 40,102, 84,101,120, 76,111, 99, 41, 41, 59, 13, 10, 9, 9,118,101, 99, 50, 32,116, 32, 61, 32, - 99,108, 97,109,112, 40,102, 84,101,120, 76,111, 99, 32, 45, 32,105, 84,101,120, 76,111, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, - 48, 41, 59, 9, 9, 47, 47, 32,115, 97,116, 32,106,117,115,116, 32,116,111, 32, 98,101, 32,112,101,100, 97,110,116,105, 99, 13, - 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 13, - 10, 32, 42, 32, 84,104,105,115, 32, 98,108,111, 99,107, 32,119,105,108,108, 32,114,101,112,108, 97, 99,101, 32,116,104,101, 32, -111,110,101, 32, 98,101,108,111,119, 32,119,104,101,110, 32,111,110,101, 32, 99,104, 97,110,110,101,108, 32,116,101,120,116,117, -114,101,115, 32, 97,114,101, 32,112,114,111,112,101,114,108,121, 32,115,117,112,112,111,114,116,101,100, 46, 32, 42, 13, 10, 32, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 13, 10, 9, 9,118, -101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 85, 76, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105, -109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 45, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, - 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 13, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112, -108,101,115, 85, 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, - 76,111, 99, 43,105,118,101, 99, 50, 40, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, - 47,118, 68,105,109, 32, 41, 59, 13, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 76, 76, 32, 61, 32,116,101, -120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, - 45, 49, 44, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 13, 10, - 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 76, 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101, -114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 49, 44, 49, 41, 32, 43, 32,118,101, 99, - 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 13, 10, 13, 10, 9, 9,109, 97,116, 52, 32, 72, 32, - 61, 32,109, 97,116, 52, 40,118, 83, 97,109,112,108,101,115, 85, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46, -120, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,120, 44, 13, 10, - 9, 9, 9, 9, 9,118, 83, 97,109,112,108,101,115, 85, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46,121, 44, - 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,121, 44, 13, 10, 9, 9, - 9, 9, 9,118, 83, 97,109,112,108,101,115, 85, 82, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,120, 44, 32,118, - 83, 97,109,112,108,101,115, 76, 82, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,120, 44, 13, 10, 9, 9, 9, 9, - 9,118, 83, 97,109,112,108,101,115, 85, 82, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,121, 44, 32,118, 83, 97, -109,112,108,101,115, 76, 82, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,121, 41, 59, 13, 10, 42, 47, 9, 13, 10, - 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, 99, 77,111,100, 32, 61, 32,105, 84,101,120, 76,111, 99, 32, 43, 32,105, -118,101, 99, 50, 40, 45, 49, 44, 32, 45, 49, 41, 59, 13, 10, 13, 10, 9, 9,109, 97,116, 52, 32, 72, 59, 13, 10, 9, 9, 13, 10, - 9, 9,102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 52, 59, 32,105, 43, 43, 41,123, 13, 10, 9, - 9, 9,102,111,114, 40,105,110,116, 32,106, 32, 61, 32, 48, 59, 32,106, 32, 60, 32, 52, 59, 32,106, 43, 43, 41,123, 13, 10, 9, - 9, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 84,109,112, 32, 61, 32,105, 84,101,120, 76,111, 99, 77,111,100, 32, 43, 32, -105,118,101, 99, 50, 40,105, 44,106, 41, 59, 13, 10, 9, 9, 9, 9, 13, 10, 9, 9, 9, 9, 47, 47, 32,119,114, 97,112, 32,116, -101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32,109, 97,110,117, 97,108,108,121, 32,102,111,114, 32, -116,101,120,101,108, 70,101,116, 99,104, 32,116,111, 32,119,111,114,107, 32,111,110, 32,117,118,115, 32,111,105,116,115,105,100, -101, 32,116,104,101, 32, 48, 44, 49, 32,114, 97,110,103,101, 46, 13, 10, 9, 9, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, - 32,103,117, 97,114, 97,110,116,101,101,100, 32,116,111, 32,119,111,114,107, 32,115,105,110, 99,101, 32,119,101, 32,116, 97,107, -101, 32,116,104,101, 32,102,114, 97, 99,116,105,111,110, 97,108, 32,112, 97,114,116, 32,111,102, 32,116,104,101, 32,117,118, 32, - 97, 98,111,118,101, 46, 13, 10, 9, 9, 9, 9,105, 84,101,120, 84,109,112, 46,120, 32, 61, 32, 40,105, 84,101,120, 84,109,112, - 46,120, 32, 60, 32, 48, 41, 63, 32,105, 84,101,120, 84,109,112, 46,120, 32, 43, 32,118, 68,105,109, 46,120, 32, 58, 32, 40, 40, -105, 84,101,120, 84,109,112, 46,120, 32, 62, 61, 32,118, 68,105,109, 46,120, 41, 63, 32,105, 84,101,120, 84,109,112, 46,120, 32, - 45, 32,118, 68,105,109, 46,120, 32, 58, 32,105, 84,101,120, 84,109,112, 46,120, 41, 59, 13, 10, 9, 9, 9, 9,105, 84,101,120, - 84,109,112, 46,121, 32, 61, 32, 40,105, 84,101,120, 84,109,112, 46,121, 32, 60, 32, 48, 41, 63, 32,105, 84,101,120, 84,109,112, - 46,121, 32, 43, 32,118, 68,105,109, 46,121, 32, 58, 32, 40, 40,105, 84,101,120, 84,109,112, 46,121, 32, 62, 61, 32,118, 68,105, -109, 46,121, 41, 63, 32,105, 84,101,120, 84,109,112, 46,121, 32, 45, 32,118, 68,105,109, 46,121, 32, 58, 32,105, 84,101,120, 84, -109,112, 46,121, 41, 59, 13, 10, 13, 10, 9, 9, 9, 9,114,103, 98,116,111, 98,119, 40,116,101,120,101,108, 70,101,116, 99,104, - 40,105,109, 97, 44, 32,105, 84,101,120, 84,109,112, 44, 32, 48, 41, 44, 32, 72, 91,105, 93, 91,106, 93, 41, 59, 13, 10, 9, 9, - 9,125, 13, 10, 9, 9,125, 13, 10, 9, 9, 13, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,116, 46,120, 44, 32,121, 32, - 61, 32,116, 46,121, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,120, 50, 32, 61, 32,120, 32, 42, 32,120, 44, 32,120, 51, 32, 61, - 32,120, 50, 32, 42, 32,120, 44, 32,121, 50, 32, 61, 32,121, 32, 42, 32,121, 44, 32,121, 51, 32, 61, 32,121, 50, 32, 42, 32,121, - 59, 13, 10, 13, 10, 9, 9,118,101, 99, 52, 32, 88, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,120, 51, 43,120, 41, - 43,120, 50, 44, 9, 9, 49, 46, 53, 42,120, 51, 45, 50, 46, 53, 42,120, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,120, 51, 43, 50, - 42,120, 50, 43, 48, 46, 53, 42,120, 44, 9, 9, 48, 46, 53, 42, 40,120, 51, 45,120, 50, 41, 41, 59, 13, 10, 9, 9,118,101, 99, - 52, 32, 89, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,121, 51, 43,121, 41, 43,121, 50, 44, 9, 9, 49, 46, 53, 42, -121, 51, 45, 50, 46, 53, 42,121, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,121, 51, 43, 50, 42,121, 50, 43, 48, 46, 53, 42,121, 44, - 9, 9, 48, 46, 53, 42, 40,121, 51, 45,121, 50, 41, 41, 59, 13, 10, 9, 9,118,101, 99, 52, 32,100, 88, 32, 61, 32,118,101, 99, - 52, 40, 45, 49, 46, 53, 42,120, 50, 43, 50, 42,120, 45, 48, 46, 53, 44, 9, 9, 52, 46, 53, 42,120, 50, 45, 53, 42,120, 44, 9, - 9, 9, 45, 52, 46, 53, 42,120, 50, 43, 52, 42,120, 43, 48, 46, 53, 44, 9, 9, 49, 46, 53, 42,120, 50, 45,120, 41, 59, 13, 10, - 9, 9,118,101, 99, 52, 32,100, 89, 32, 61, 32,118,101, 99, 52, 40, 45, 49, 46, 53, 42,121, 50, 43, 50, 42,121, 45, 48, 46, 53, - 44, 9, 9, 52, 46, 53, 42,121, 50, 45, 53, 42,121, 44, 9, 9, 9, 45, 52, 46, 53, 42,121, 50, 43, 52, 42,121, 43, 48, 46, 53, - 44, 9, 9, 49, 46, 53, 42,121, 50, 45,121, 41, 59, 13, 10, 9, 13, 10, 9, 9, 47, 47, 32, 99,111,109,112,108,101,116,101, 32, -100,101,114,105,118, 97,116,105,118,101, 32,105,110, 32,110,111,114,109, 97,108,105,122,101,100, 32, 99,111,111,114,100,105,110, - 97,116,101,115, 32, 40,109,117,108, 32, 98,121, 32,118, 68,105,109, 41, 13, 10, 9, 9,118,101, 99, 50, 32,100, 72,100, 83, 84, - 32, 61, 32,118, 68,105,109, 32, 42, 32,118,101, 99, 50, 40,100,111,116, 40, 89, 44, 32, 72, 32, 42, 32,100, 88, 41, 44, 32,100, -111,116, 40,100, 89, 44, 32, 72, 32, 42, 32, 88, 41, 41, 59, 13, 10, 13, 10, 9, 9, 47, 47, 32,116,114, 97,110,115,102,111,114, -109, 32,100,101,114,105,118, 97,116,105,118,101, 32,116,111, 32,115, 99,114,101,101,110, 45,115,112, 97, 99,101, 13, 10, 9, 9, -118,101, 99, 50, 32,100, 72,100,120,121, 95, 98,105, 99,117, 98,105, 99, 32, 61, 32,118,101, 99, 50, 40, 32,100, 72,100, 83, 84, - 46,120, 32, 42, 32, 84,101,120, 68,120, 46,120, 32, 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, 84,101,120, 68,120, 46,121, - 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,100, 72,100, 83, 84, 46,120, 32, 42, 32, 84,101,120, 68,121, 46,120, 32, - 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, 84,101,120, 68,121, 46,121, 32, 41, 59, 13, 10, 13, 10, 9, 9, 47, 47, 32, 98, -108,101,110,100, 32, 98,101,116,119,101,101,110, 32,116,104,101, 32,116,119,111, 13, 10, 9, 9,100, 72,100,120,121, 32, 61, 32, -100, 72,100,120,121, 42, 40, 49, 45,102, 66,108,101,110,100, 41, 32, 43, 32,100, 72,100,120,121, 95, 98,105, 99,117, 98,105, 99, - 42,102, 66,108,101,110,100, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, -100, 72,100,120,121, 46,120, 59, 13, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32,100, 72,100,120,121, 46, -121, 59, 13, 10,125, 13, 10, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109, -112, 95,116, 97,112, 53, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, - 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32, +118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,102, 68,101,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, 61, 32,100, 70,100,120, + 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, 61, 32,100, 70, +100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, 32,115,117,114,102, 95, +110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32,105,110,116,101,114,112,111,108, 97,116,101,100, + 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 10, 9, 10, 9,118, 82, 49, 32, 61, 32,110,111,114,109, 97, +108,105,122,101, 40, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 32, 41, 59, 10, 9,118, + 82, 50, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32, 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, + 97, 83, 32, 41, 32, 41, 59, 10, 9,102, 68,101,116, 32, 61, 32,115,105,103,110, 40, 32,100,111,116, 40,118, 83,105,103,109, 97, + 83, 44, 32,118, 82, 49, 41, 32, 41, 59, 10, 9, 10, 9,102,108,111, 97,116, 32,102, 77, 97,103,110,105,116,117,100,101, 32, 61, + 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105, +110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, + 95,105,110, 41, 59, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103, +110,105,116,117,100,101, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,118, +105,101,119,115,112, 97, 99,101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117, +114,102, 95,110,111,114,109, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, + 97,103,110,105,116,117,100,101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, + 9, 9, 9, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111, +117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, + 32, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,102, 68,101,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, + 32, 61, 32,100, 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, + 97, 84, 32, 61, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 78, 32, + 61, 32,115,117,114,102, 95,110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32,105,110,116,101,114, +112,111,108, 97,116,101,100, 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 10, 9, 10, 9,118, 82, 49, 32, + 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 59, 10, 9,118, 82, 50, 32, 61, 32, 99, +114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 59, 10, 9,102, 68,101,116, 32, 61, 32,100,111, +116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, 59, 10, 9, 10, 9,102,108,111, 97,116, 32,102, 77, 97, +103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, + 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, + 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111, +117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117, +109,112, 95,116, 97,112, 51, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105, +109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, - 32,100, 66,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116, -101,120, 99,111, 46,120,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101, -120, 99,111, 46,120,121, 41, 59, 13, 10, 13, 10, 9,118,101, 99, 50, 32, 83, 84, 99, 32, 61, 32,116,101,120, 99,111, 46,120,121, - 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, - 84,101,120, 68,120, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, - 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, - 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, - 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9, 13, 10, 9,102, -108,111, 97,116, 32, 72, 99, 44, 72,108, 44, 72,114, 44, 72,100, 44, 72,117, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32, -116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84, 99, 41, 44, 32, 72, 99, 32, 41, 59, 13, 10, 9,114,103, 98, -116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 32, 41, 59, - 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, - 32, 72,114, 32, 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, - 32, 83, 84,100, 41, 44, 32, 72,100, 32, 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, - 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, 44, 32, 72,117, 32, 41, 59, 13, 10, 9, 13, 10, 9,100, 66,115, 32, 61, 32,104, 83, - 99, 97,108,101, 32, 42, 32, 40, 72,114, 32, 45, 32, 72,108, 41, 59, 13, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, - 32, 42, 32, 40, 72,117, 32, 45, 32, 72,100, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117, -109,112, 95,100,101,114,105,118, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, -105,109, 97, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,102, -108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,116, - 32, 41, 32, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,115, 32, 61, 32, 49, 46, 48, 59, 9, 9, 47, 47, 32,110,101,103, 97, -116,101, 32,116,104,105,115, 32,105,102, 32,102,108,105,112,112,101,100, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100, -105,110, 97,116,101, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46, -120,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120, -121, 41, 59, 13, 10, 9, 13, 10, 9, 47, 47, 32,116,104,105,115, 32,118, 97,114,105, 97,110,116, 32,117,115,105,110,103, 32, 97, - 32,100,101,114,105,118, 97,116,105,118,101, 32,109, 97,112, 32,105,115, 32,100,101,115, 99,114,105, 98,101,100, 32,104,101,114, -101, 13, 10, 9, 47, 47, 32,104,116,116,112, 58, 47, 47,109,109,105,107,107,101,108,115,101,110, 51,100, 46, 98,108,111,103,115, -112,111,116, 46, 99,111,109, 47, 50, 48, 49, 49, 47, 48, 55, 47,100,101,114,105,118, 97,116,105,118,101, 45,109, 97,112,115, 46, -104,116,109,108, 13, 10, 9,118,101, 99, 50, 32,100,105,109, 32, 61, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 44, 32,105,109, - 97, 95,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32,100, 66,100,117,118, 32, 61, 32,104, 83, 99, 97,108,101, 42,100,105,109, 42, - 40, 50, 46, 48, 42,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 46,120,121, - 45, 49, 46, 48, 41, 59, 13, 10, 9, 13, 10, 9,100, 66,115, 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84,101,120, 68,120, 46, -120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,120, 46,121, 59, 13, 10, 9,100, 66,116, 32, 61, 32,100, - 66,100,117,118, 46,120, 42, 84,101,120, 68,121, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,121, - 46,121, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 40, 32, -102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, 66,116, - 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, - 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, - 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 41, 32, 13, 10,123, 13, 10, - 9,118,101, 99, 51, 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40,102, 68,101,116, 41, 32, 42, 32, 40, - 32,100, 66,115, 32, 42, 32,118, 82, 49, 32, 43, 32,100, 66,116, 32, 42, 32,118, 82, 50, 32, 41, 59, 13, 10, 9, 13, 10, 9,118, - 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83,117,114,102, 71,114, 97,100, 59, - 13, 10, 9,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,118, - 78, 97, 99, 99, 95,111,117,116, 32, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, - 95, 97,112,112,108,121, 95,116,101,120,115,112, 97, 99,101, 40, 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, - 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, 66,116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, - 51, 32,118, 82, 50, 44, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111, - 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,118,101, 99, 51, - 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, - 78, 97, 99, 99, 95,111,117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114, -109, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99, -111, 46,120,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, - 46,120,121, 41, 59, 13, 10, 13, 10, 9,118,101, 99, 51, 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40, -102, 68,101,116, 41, 32, 42, 32, 40, 32, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,100, 66,115, 32, 47, 32,108, -101,110,103,116,104, 40, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 42, 84,101,120, 68,120, 46,120, 44, 32,105,109, 97, 95,121, - 42, 84,101,120, 68,120, 46,121, 41, 32, 41, 32, 42, 32,118, 82, 49, 32, 43, 32, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32,100, 66,116, 32, 47, 32,108,101,110,103,116,104, 40, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 42, 84,101,120, 68, -121, 46,120, 44, 32,105,109, 97, 95,121, 42, 84,101,120, 68,121, 46,121, 41, 32, 41, 32, 42, 32,118, 82, 50, 32, 41, 59, 13, 10, - 9, 9, 9, 9, 13, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83, -117,114,102, 71,114, 97,100, 59, 13, 10, 9,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, - 97,108,105,122,101, 40, 32,118, 78, 97, 99, 99, 95,111,117,116, 32, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, -116,101,120, 95,110,101,103, 97,116,101, 95,116,101,120,110,111,114,109, 97,108, 40,118,101, 99, 51, 32,110,111,114,109, 97,108, - 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,110,111, -114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, 45,110,111,114,109, 97,108, 46,120, 44, 32, 45,110,111,114,109, 97,108, 46,121, - 44, 32,110,111,114,109, 97,108, 46,122, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,110,115,112, - 97, 99,101, 95,116, 97,110,103,101,110,116, 40,118,101, 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,118,101, 99, 51, 32,110, -111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,116,101,120,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32, -111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 66, 32, 61, 32,116, 97,110,103,101,110,116, - 46,119, 32, 42, 32, 99,114,111,115,115, 40,110,111,114,109, 97,108, 44, 32,116, 97,110,103,101,110,116, 46,120,121,122, 41, 59, - 13, 10, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,116,101,120,110,111,114,109, 97,108, 46,120, 42,116, 97,110, -103,101,110,116, 46,120,121,122, 32, 43, 32,116,101,120,110,111,114,109, 97,108, 46,121, 42, 66, 32, 43, 32,116,101,120,110,111, -114,109, 97,108, 46,122, 42,110,111,114,109, 97,108, 59, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114, -109, 97,108,105,122,101, 40,111,117,116,110,111,114,109, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116, -101,120, 95, 98,108,101,110,100, 95,110,111,114,109, 97,108, 40,102,108,111, 97,116, 32,110,111,114,102, 97, 99, 44, 32,118,101, - 99, 51, 32,110,111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,110,101,119,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118, -101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, - 40, 49, 46, 48, 32, 45, 32,110,111,114,102, 97, 99, 41, 42,110,111,114,109, 97,108, 32, 43, 32,110,111,114,102, 97, 99, 42,110, -101,119,110,111,114,109, 97,108, 59, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122, -101, 40,111,117,116,110,111,114,109, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 32, 77, 65, 84, - 69, 82, 73, 65, 76, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105, -115,105, 98,105,108,105,116,121, 95,115,117,110, 95,104,101,109,105, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32, -111,117,116, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, - 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,108,118, 32, 61, 32,108, 97,109,112,118,101, - 99, 59, 13, 10, 9,100,105,115,116, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, 46, 48, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,111,116,104, -101,114, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,108, 97,109,112, 99,111, 44, 32,111,117,116, 32,118,101, 99, - 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, -118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,108,118, 32, 61, 32, 99,111, 32, 45, 32,108, 97,109,112, 99,111, 59, 13, - 10, 9,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40,108,118, 41, 59, 13, 10, 9,108,118, 32, 61, 32,110,111,114,109, - 97,108,105,122,101, 40,108,118, 41, 59, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,108,105,110,101, 97,114, 40,102,108, -111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108, -111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112, -100,105,115,116, 47, 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111, -105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,115,113,117, 97,114,101, 40,102,108,111, 97,116, 32, -108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, -118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, - 47, 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 42,100,105,115,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,115,108,105,100,101,114,115, 40,102,108,111, 97,116, 32,108, - 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,108,100, 49, 44, 32,102,108,111, 97,116, 32,108,100, 50, 44, 32,102, -108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, - 13, 10, 9,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116,107,119, 32, 61, 32,108, 97,109,112,100,105,115,116, 42,108, - 97,109,112,100,105,115,116, 59, 13, 10, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, 47, - 40,108, 97,109,112,100,105,115,116, 32, 43, 32,108,100, 49, 42,100,105,115,116, 41, 59, 13, 10, 9,118,105,115,105,102, 97, 99, - 32, 42, 61, 32,108, 97,109,112,100,105,115,116,107,119, 47, 40,108, 97,109,112,100,105,115,116,107,119, 32, 43, 32,108,100, 50, - 42,100,105,115,116, 42,100,105,115,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108, -108,111,102,102, 95, 99,117,114,118,101, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,115, 97,109,112,108, -101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,116,101,120, -116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,100,105,115,116, 47,108, 97,109,112,100, -105,115,116, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105, -115,105, 98,105,108,105,116,121, 95,115,112,104,101,114,101, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32, -102,108,111, 97,116, 32,100,105,115,116, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,116, 61, 32,108, - 97,109,112,100,105,115,116, 32, 45, 32,100,105,115,116, 59, 13, 10, 13, 10, 9,111,117,116,118,105,115,105,102, 97, 99, 61, 32, -118,105,115,105,102, 97, 99, 42,109, 97,120, 40,116, 44, 32, 48, 46, 48, 41, 47,108, 97,109,112,100,105,115,116, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,112,111,116, 95,115,113, -117, 97,114,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,109, 97,116, 52, 32,108, 97,109,112,105,109, 97,116, - 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112,114, 41, 13, 10,123, 13, 10, 9, -105,102, 40,100,111,116, 40,108,118, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 62, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, -118,101, 99, 51, 32,108,118,114,111,116, 32, 61, 32, 40,108, 97,109,112,105,109, 97,116, 42,118,101, 99, 52, 40,108,118, 44, 32, - 48, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,109, 97,120, 40, 97, 98,115, 40, -108,118,114,111,116, 46,120, 47,108,118,114,111,116, 46,122, 41, 44, 32, 97, 98,115, 40,108,118,114,111,116, 46,121, 47,108,118, -114,111,116, 46,122, 41, 41, 59, 13, 10, 13, 10, 9, 9,105,110,112,114, 32, 61, 32, 49, 46, 48, 47,115,113,114,116, 40, 49, 46, - 48, 32, 43, 32,120, 42,120, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105,110,112,114, 32, 61, 32, 48, - 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115, -112,111,116, 95, 99,105,114, 99,108,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,108,118, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112,114, 41, 13, 10,123, 13, 10, 9,105,110,112,114, 32, 61, 32,100,111, -116, 40,108,118, 44, 32,108, 97,109,112,118,101, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95, -118,105,115,105, 98,105,108,105,116,121, 95,115,112,111,116, 40,102,108,111, 97,116, 32,115,112,111,116,115,105, 44, 32,102,108, -111, 97,116, 32,115,112,111,116, 98,108, 44, 32,102,108,111, 97,116, 32,105,110,112,114, 44, 32,102,108,111, 97,116, 32,118,105, -115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, - 10, 9,102,108,111, 97,116, 32,116, 32, 61, 32,115,112,111,116,115,105, 59, 13, 10, 13, 10, 9,105,102, 40,105,110,112,114, 32, - 60, 61, 32,116, 41, 32,123, 13, 10, 9, 9,111,117,116,118,105,115,105,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, - 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,116, 32, 61, 32,105,110,112,114, 32, 45, 32,116, 59, 13, 10, 13, 10, 9, 9, - 47, 42, 32,115,111,102,116, 32, 97,114,101, 97, 32, 42, 47, 13, 10, 9, 9,105,102, 40,115,112,111,116, 98,108, 32, 33, 61, 32, - 48, 46, 48, 41, 13, 10, 9, 9, 9,105,110,112,114, 32, 42, 61, 32,115,109,111,111,116,104,115,116,101,112, 40, 48, 46, 48, 44, - 32, 49, 46, 48, 44, 32,116, 47,115,112,111,116, 98,108, 41, 59, 13, 10, 13, 10, 9, 9,111,117,116,118,105,115,105,102, 97, 99, - 32, 61, 32,118,105,115,105,102, 97, 99, 42,105,110,112,114, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, -108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32,118,105,115,105, -102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9, -111,117,116,118,105,115,105,102, 97, 99, 32, 61, 32, 40,118,105,115,105,102, 97, 99, 32, 60, 32, 48, 46, 48, 48, 49, 41, 63, 32, - 48, 46, 48, 58, 32,118,105,115,105,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,118, -105,101,119, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 41, 13, 10,123, 13, 10, - 9, 47, 42, 32,104, 97,110,100,108,101, 32,112,101,114,115,112,101, 99,116,105,118,101, 47,111,114,116,104,111,103,114, 97,112, -104,105, 99, 32, 42, 47, 13, 10, 9,118,105,101,119, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99,116,105,111,110, 77, 97, -116,114,105,120, 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, - 41, 58, 32,118,101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 45, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,115,104, 97,100,101, 95,116, 97,110,103,101,110,116, 95,118, 40,118,101, 99, 51, 32,108,118, 44, 32,118,101, 99, - 51, 32,116, 97,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,110, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 99, - 32, 61, 32, 99,114,111,115,115, 40,108,118, 44, 32,116, 97,110,103, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118,110,111,114, 32, - 61, 32, 99,114,111,115,115, 40, 99, 44, 32,116, 97,110,103, 41, 59, 13, 10, 13, 10, 9,118,110, 32, 61, 32, 45,110,111,114,109, - 97,108,105,122,101, 40,118,110,111,114, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,110, -112, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, -112, 41, 13, 10,123, 13, 10, 9,105,110,112, 32, 61, 32,100,111,116, 40,118,110, 44, 32,108,118, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,115, 95,110,111, 95,100,105,102,102,117,115,101, 40,111,117,116, 32,102,108, -111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,115,104, 97,100,101, 95,105,115, 95,104,101,109,105, 40,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,115, 32, 61, 32, 48, 46, 53, 42,105,110,112, 32, 43, 32, 48, 46, 53, - 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, 40,109, - 97,116, 52, 32, 97,114,101, 97, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,118,110, 41, 13, 10,123, 13, 10, - 9,118,101, 99, 51, 32,118,101, 99, 91, 52, 93, 44, 32, 99, 91, 52, 93, 59, 13, 10, 9,102,108,111, 97,116, 32,114, 97,100, 91, - 52, 93, 44, 32,102, 97, 99, 59, 13, 10, 9, 13, 10, 9,118,101, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, - 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 48, 93, 46,120,121,122, 41, 59, 13, 10, 9,118,101, 99, 91, 49, 93, 32, 61, 32,110, -111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 49, 93, 46,120,121,122, 41, 59, 13, 10, 9,118,101, - 99, 91, 50, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 50, 93, 46,120,121, -122, 41, 59, 13, 10, 9,118,101, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114, -101, 97, 91, 51, 93, 46,120,121,122, 41, 59, 13, 10, 13, 10, 9, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, - 40, 99,114,111,115,115, 40,118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, 59, 13, 10, 9, 99, 91, 49, 93, 32, - 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, 99, 91, 50, 93, - 41, 41, 59, 13, 10, 9, 99, 91, 50, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, - 91, 50, 93, 44, 32,118,101, 99, 91, 51, 93, 41, 41, 59, 13, 10, 9, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122, -101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, 41, 41, 59, 13, 10, 13, 10, 9,114, 97, -100, 91, 48, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, - 59, 13, 10, 9,114, 97,100, 91, 49, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, - 99, 91, 50, 93, 41, 41, 59, 13, 10, 9,114, 97,100, 91, 50, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, - 50, 93, 44, 32,118,101, 99, 91, 51, 93, 41, 41, 59, 13, 10, 9,114, 97,100, 91, 51, 93, 32, 61, 32, 97, 99,111,115, 40,100,111, -116, 40,118,101, 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, 41, 41, 59, 13, 10, 13, 10, 9,102, 97, 99, 61, 32, 32,114, 97, -100, 91, 48, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 48, 93, 41, 59, 13, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, - 49, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 49, 93, 41, 59, 13, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 50, 93, - 42,100,111,116, 40,118,110, 44, 32, 99, 91, 50, 93, 41, 59, 13, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 51, 93, 42,100, -111,116, 40,118,110, 44, 32, 99, 91, 51, 93, 41, 59, 13, 10, 13, 10, 9,114,101,116,117,114,110, 32,109, 97,120, 40,102, 97, 99, - 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,110,112, 95, 97,114,101, - 97, 40,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,118,101, 99, 51, 32,108, 97,109,112, 99,111, 44, 32,118,101, - 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,109, 97,116, 52, 32, 97,114,101, 97, 44, 32, -102,108,111, 97,116, 32, 97,114,101, 97,115,105,122,101, 44, 32,102,108,111, 97,116, 32,107, 44, 32,111,117,116, 32,102,108,111, - 97,116, 32,105,110,112, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 99,111, 32, 61, 32,112,111,115,105,116,105,111,110, 59, - 13, 10, 9,118,101, 99, 51, 32,118,101, 99, 32, 61, 32, 99,111, 32, 45, 32,108, 97,109,112, 99,111, 59, 13, 10, 13, 10, 9,105, -102, 40,100,111,116, 40,118,101, 99, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, -105,110,112, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, - 32,105,110,116,101,110,115, 32, 61, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, 40, 97,114,101, 97, 44, - 32, 99,111, 44, 32,118,110, 41, 59, 13, 10, 13, 10, 9, 9,105,110,112, 32, 61, 32,112,111,119, 40,105,110,116,101,110,115, 42, - 97,114,101, 97,115,105,122,101, 44, 32,107, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97, -100,101, 95,100,105,102,102,117,115,101, 95,111,114,101,110, 95,110, 97,121,101,114, 40,102,108,111, 97,116, 32,110,108, 44, 32, -118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,114,111, -117,103,104, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,104, 32, 61, - 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32, -109, 97,120, 40,100,111,116, 40,110, 44, 32,104, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,110,118, 32, - 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,114, -101, 97,108,110,108, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 13, 10, 13, 10, 9,105,102, 40,114,101, 97,108,110,108, - 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115, -101, 32,105,102, 40,110,108, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, -125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,118,104, 32, 61, 32,109, 97,120, 40,100,111,116, - 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32, 76,105,116, 95, 65, 32, 61, 32, 97, - 99,111,115, 40,114,101, 97,108,110,108, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32, 86,105,101,119, 95, 65, 32, 61, 32, 97, - 99,111,115, 40,110,118, 41, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32, 76,105,116, 95, 66, 32, 61, 32,110,111,114,109, 97, -108,105,122,101, 40,108, 32, 45, 32,114,101, 97,108,110,108, 42,110, 41, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 86,105,101,119, - 95, 66, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 45, 32,110,118, 42,110, 41, 59, 13, 10, 13, 10, 9, 9,102, -108,111, 97,116, 32,116, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 76,105,116, 95, 66, 44, 32, 86,105,101,119, 95, 66, 41, 44, - 32, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9,102,108,111, 97,116, 32, 97, 44, 32, 98, 59, 13, 10, 13, 10, 9, 9,105,102, 40, - 76,105,116, 95, 65, 32, 62, 32, 86,105,101,119, 95, 65, 41, 32,123, 13, 10, 9, 9, 9, 97, 32, 61, 32, 76,105,116, 95, 65, 59, - 13, 10, 9, 9, 9, 98, 32, 61, 32, 86,105,101,119, 95, 65, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, - 10, 9, 9, 9, 97, 32, 61, 32, 86,105,101,119, 95, 65, 59, 13, 10, 9, 9, 9, 98, 32, 61, 32, 76,105,116, 95, 65, 59, 13, 10, - 9, 9,125, 13, 10, 13, 10, 9, 9,102,108,111, 97,116, 32, 65, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 48, 46, 53, 42, 40, 40, -114,111,117,103,104, 42,114,111,117,103,104, 41, 47, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, - 51, 51, 41, 41, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32, 66, 32, 61, 32, 48, 46, 52, 53, 42, 40, 40,114,111,117,103,104, - 42,114,111,117,103,104, 41, 47, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, 48, 57, 41, 41, 59, - 13, 10, 13, 10, 9, 9, 98, 32, 42, 61, 32, 48, 46, 57, 53, 59, 13, 10, 9, 9,105,115, 32, 61, 32,110,108, 42, 40, 65, 32, 43, - 32, 40, 66, 32, 42, 32,116, 32, 42, 32,115,105,110, 40, 97, 41, 32, 42, 32,116, 97,110, 40, 98, 41, 41, 41, 59, 13, 10, 9,125, - 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115,101, 95,116,111,111,110, 40,118, -101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,115,105,122, -101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 13, 10, 9,102, -108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, 41, 59, 13, 10, 13, 10, 9,105,102, 40, 97,110, -103, 32, 60, 32,115,105,122,101, 41, 32,105,115, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, 97,110, -103, 32, 62, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111,116,104, 41, 32,124,124, 32,116,115,109,111,111,116,104, 32, - 61, 61, 32, 48, 46, 48, 41, 32,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,115, 32, 61, 32, 49, 46, - 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115,105,122,101, 41, 47,116,115,109,111,111,116,104, 41, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115,101, 95,109,105,110,110, 97,101,114,116, 40,102,108, -111, 97,116, 32,110,108, 44, 32,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,100, 97, -114,107,110,101,115,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,102, 40,110,108, - 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108, -115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, - 44, 32, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9,105,102, 40,100, 97,114,107,110,101,115,115, 32, 60, 61, 32, 49, 46, 48, 41, - 13, 10, 9, 9, 9,105,115, 32, 61, 32,110,108, 42,112,111,119, 40,109, 97,120, 40,110,118, 42,110,108, 44, 32, 48, 46, 49, 41, - 44, 32,100, 97,114,107,110,101,115,115, 32, 45, 32, 49, 46, 48, 41, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,105, -115, 32, 61, 32,110,108, 42,112,111,119, 40, 49, 46, 48, 48, 48, 49, 32, 45, 32,110,118, 44, 32,100, 97,114,107,110,101,115,115, - 32, 45, 32, 49, 46, 48, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, - 95,102, 97, 99, 40,118,101, 99, 51, 32,118,105,101,119, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,102,108,111, 97,116, 32,103, -114, 97,100, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,116, 49, 44, 32,116, - 50, 59, 13, 10, 9,102,108,111, 97,116, 32,102,102, 97, 99, 59, 13, 10, 13, 10, 9,105,102, 40,102, 97, 99, 61, 61, 48, 46, 48, - 41, 32,123, 13, 10, 9, 9,102,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, - 10, 9, 9,116, 49, 61, 32,100,111,116, 40,118,105,101,119, 44, 32,118,110, 41, 59, 13, 10, 9, 9,105,102, 40,116, 49, 62, 48, - 46, 48, 41, 32, 32,116, 50, 61, 32, 49, 46, 48, 43,116, 49, 59, 13, 10, 9, 9,101,108,115,101, 32,116, 50, 61, 32, 49, 46, 48, - 45,116, 49, 59, 13, 10, 13, 10, 9, 9,116, 50, 61, 32,103,114, 97,100, 32, 43, 32, 40, 49, 46, 48, 45,103,114, 97,100, 41, 42, -112,111,119, 40,116, 50, 44, 32,102, 97, 99, 41, 59, 13, 10, 13, 10, 9, 9,105,102, 40,116, 50, 60, 48, 46, 48, 41, 32,102,102, - 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 40,116, 50, 62, 49, 46, 48, 41, 32,102,102, 97, - 99, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,102,102, 97, 99, 32, 61, 32,116, 50, 59, 13, 10, 9,125, 13, - 10, 13, 10, 9,114,101,116,117,114,110, 32,102,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,100,105,102,102,117,115,101, 95,102,114,101,115,110,101,108, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32, -108,118, 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 95,105, 44, 32,102,108,111, 97, -116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,115, 32, 61, 32,102, -114,101,115,110,101,108, 95,102, 97, 99, 40,108,118, 44, 32,118,110, 44, 32,102, 97, 99, 95,105, 44, 32,102, 97, 99, 41, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 99,117, 98,105, 99, 40,102,108,111, 97,116, 32,105,115, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105,115, 41, 13, 10,123, 13, 10, 9,105,102, 40,105,115, 62, 48, 46, 48, - 32, 38, 38, 32,105,115, 60, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,105,115, 61, 32,115,109,111,111,116,104,115,116,101,112, - 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, 32,105,115, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,105,115, 61, - 32,105,115, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,118,105,115,105,102, 97, 99, 40,102,108, -111, 97,116, 32,105, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,102,108,111, 97,116, 32,114,101,102,108, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105, 41, 13, 10,123, 13, 10, 9, 47, 42,105,102, 40,105, 32, 62, 32, - 48, 46, 48, 41, 42, 47, 13, 10, 9, 9,111,117,116,105, 32, 61, 32,109, 97,120, 40,105, 42,118,105,115,105,102, 97, 99, 42,114, -101,102,108, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 47, 42,101,108,115,101, 13, 10, 9, 9,111,117,116,105, 32, 61, 32,105, 59, - 42, 47, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116, 97,110,103,101,110,116, 95,118, 95,115,112, -101, 99, 40,118,101, 99, 51, 32,116, 97,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,110, 41, 13, 10,123, 13, 10, 9, -118,110, 32, 61, 32,116, 97,110,103, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95, -116,111, 95,100,105,102,102,117,115,101, 40,102,108,111, 97,116, 32,105, 44, 32,118,101, 99, 51, 32,108, 97,109,112, 99,111,108, - 44, 32,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, - 10, 9,105,102, 40,105, 32, 62, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,105, 42,108, 97,109,112, - 99,111,108, 42, 99,111,108, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 51, - 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,104,101,109,105, 95,115,112,101, 99, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,118,101, - 99, 51, 32,118,105,101,119, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, - 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 13, 10,123, 13, - 10, 9,108,118, 32, 43, 61, 32,118,105,101,119, 59, 13, 10, 9,108,118, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, -118, 41, 59, 13, 10, 13, 10, 9,116, 32, 61, 32,100,111,116, 40,118,110, 44, 32,108,118, 41, 59, 13, 10, 9,116, 32, 61, 32, 48, - 46, 53, 42,116, 32, 43, 32, 48, 46, 53, 59, 13, 10, 13, 10, 9,116, 32, 61, 32,118,105,115,105,102, 97, 99, 42,115,112,101, 99, - 42,112,111,119, 40,116, 44, 32,104, 97,114,100, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, -112,104,111,110,103, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32, -118, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, - 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, - 59, 13, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,109, 97,120, 40,100,111,116, 40,104, 44, 32,110, 41, 44, 32, - 48, 46, 48, 41, 59, 13, 10, 13, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,112,111,119, 40,114,115,108,116, 44, 32,104, 97, -114,100, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 99,111,111,107,116,111,114,114, 95,115, -112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97, -116, 32,104, 97,114,100, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9, -118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, 13, 10, 9,102,108,111, - 97,116, 32,110,104, 32, 61, 32,100,111,116, 40,110, 44, 32,104, 41, 59, 13, 10, 13, 10, 9,105,102, 40,110,104, 32, 60, 32, 48, - 46, 48, 41, 32,123, 13, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108, -115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, - 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,105, 32, 61, 32,112,111,119, 40,110,104, 44, 32,104, 97,114, -100, 41, 59, 13, 10, 13, 10, 9, 9,105, 32, 61, 32,105, 47, 40, 48, 46, 49, 43,110,118, 41, 59, 13, 10, 9, 9,115,112,101, 99, -102, 97, 99, 32, 61, 32,105, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 98,108, -105,110,110, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, - 32,102,108,111, 97,116, 32,114,101,102,114, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 95,112,111,119,101,114, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,105,102, 40,114,101,102,114, - 97, 99, 32, 60, 32, 49, 46, 48, 41, 32,123, 13, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, -125, 13, 10, 9,101,108,115,101, 32,105,102, 40,115,112,101, 99, 95,112,111,119,101,114, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, - 13, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, - 10, 9, 9,105,102, 40,115,112,101, 99, 95,112,111,119,101,114, 60, 49, 48, 48, 46, 48, 41, 13, 10, 9, 9, 9,115,112,101, 99, - 95,112,111,119,101,114, 61, 32,115,113,114,116, 40, 49, 46, 48, 47,115,112,101, 99, 95,112,111,119,101,114, 41, 59, 13, 10, 9, - 9,101,108,115,101, 13, 10, 9, 9, 9,115,112,101, 99, 95,112,111,119,101,114, 61, 32, 49, 48, 46, 48, 47,115,112,101, 99, 95, -112,111,119,101,114, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, - 32, 43, 32,108, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,100,111,116, 40,110, 44, 32,104, 41, 59, 13, - 10, 9, 9,105,102, 40,110,104, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, - 48, 46, 48, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,110,118, - 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 49, 41, 59, 13, 10, 9, 9, 9,102,108,111, - 97,116, 32,110,108, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 13, 10, 9, 9, 9,105,102, 40,110,108, 32, 60, 61, 32, - 48, 46, 48, 49, 41, 32,123, 13, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9, 9, -125, 13, 10, 9, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,118,104, 32, 61, 32,109, 97,120, - 40,100,111,116, 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 49, 41, 59, 13, 10, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, - 97, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 98, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42, -110,118, 41, 47,118,104, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 99, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42,110, -108, 41, 47,118,104, 59, 13, 10, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,103, 32, 61, 32, 48, 46, 48, 59, 13, 10, 13, 10, - 9, 9, 9, 9,105,102, 40, 97, 32, 60, 32, 98, 32, 38, 38, 32, 97, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 97, 59, 13, 10, 9, - 9, 9, 9,101,108,115,101, 32,105,102, 40, 98, 32, 60, 32, 97, 32, 38, 38, 32, 98, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 98, - 59, 13, 10, 9, 9, 9, 9,101,108,115,101, 32,105,102, 40, 99, 32, 60, 32, 97, 32, 38, 38, 32, 99, 32, 60, 32, 98, 41, 32,103, - 32, 61, 32, 99, 59, 13, 10, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,112, 32, 61, 32,115,113,114,116, 40, 40, 40,114,101, -102,114, 97, 99, 32, 42, 32,114,101,102,114, 97, 99, 41, 43, 40,118,104, 42,118,104, 41, 45, 49, 46, 48, 41, 41, 59, 13, 10, 9, - 9, 9, 9,102,108,111, 97,116, 32,102, 32, 61, 32, 40, 40, 40,112, 45,118,104, 41, 42, 40,112, 45,118,104, 41, 41, 47, 40, 40, -112, 43,118,104, 41, 42, 40,112, 43,118,104, 41, 41, 41, 42, 40, 49, 46, 48, 43, 40, 40, 40, 40,118,104, 42, 40,112, 43,118,104, - 41, 41, 45, 49, 46, 48, 41, 42, 40, 40,118,104, 42, 40,112, 43,118,104, 41, 41, 45, 49, 46, 48, 41, 41, 47, 40, 40, 40,118,104, - 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 42, 40, 40,118,104, 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 41, - 41, 41, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,110,104, 41, 59, 13, 10, - 13, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,109, 97,120, 40,102, 42,103, 42,101,120,112, 95, 98,108,101,110, -100,101,114, 40, 40, 45, 40, 97,110,103, 42, 97,110,103, 41, 47, 40, 50, 46, 48, 42,115,112,101, 99, 95,112,111,119,101,114, 42, -115,112,101, 99, 95,112,111,119,101,114, 41, 41, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9, 9,125, 13, 10, 9, 9,125, 13, - 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,119, 97,114,100,105,115,111, 95,115,112,101, - 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32, -114,109,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,101, 99, - 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 13, 10, 9,102,108,111, 97,116, 32, -110,104, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,104, 41, 44, 32, 48, 46, 48, 48, 49, 41, 59, 13, 10, 9,102,108, -111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 48, 49, 41, 59, 13, - 10, 9,102,108,111, 97,116, 32,110,108, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,108, 41, 44, 32, 48, 46, 48, 48, - 49, 41, 59, 13, 10, 9,102,108,111, 97,116, 32, 97,110,103,108,101, 32, 61, 32,116, 97,110, 40, 97, 99,111,115, 40,110,104, 41, - 41, 59, 13, 10, 9,102,108,111, 97,116, 32, 97,108,112,104, 97, 32, 61, 32,109, 97,120, 40,114,109,115, 44, 32, 48, 46, 48, 48, - 49, 41, 59, 13, 10, 13, 10, 9,115,112,101, 99,102, 97, 99, 61, 32,110,108, 32, 42, 32, 40, 49, 46, 48, 47, 40, 52, 46, 48, 42, - 77, 95, 80, 73, 42, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 42, 40,101,120,112, 95, 98,108,101,110,100,101,114, 40, - 45, 40, 97,110,103,108,101, 42, 97,110,103,108,101, 41, 47, 40, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 47, 40,115, -113,114,116, 40,110,118, 42,110,108, 41, 41, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116, -111,111,110, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, - 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114, -109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111, -116, 40,104, 44, 32,110, 41, 59, 13, 10, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, - 41, 59, 13, 10, 13, 10, 9,105,102, 40, 97,110,103, 32, 60, 32,115,105,122,101, 41, 32,114,115,108,116, 32, 61, 32, 49, 46, 48, - 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, 97,110,103, 32, 62, 61, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111, -116,104, 41, 32,124,124, 32,116,115,109,111,111,116,104, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,115,108,116, 32, 61, 32, 48, 46, - 48, 59, 13, 10, 9,101,108,115,101, 32,114,115,108,116, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115, -105,122,101, 41, 47,116,115,109,111,111,116,104, 41, 59, 13, 10, 13, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,114,115,108, -116, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,115,112,101, 99, 95, 97,114,101, 97, 95,105,110, -112, 40,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 44, 32,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,111,117,116,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,115,112,101, 99,102, 97, - 99, 32, 61, 32,115,112,101, 99,102, 97, 99, 42,105,110,112, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,115,112,101, 99, 95,116, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112, -101, 99, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 13, 10,123, 13, 10, 9,116, 32, 61, 32,115,104, 97,100,102, 97, 99, 42, -115,112,101, 99, 42,118,105,115,105,102, 97, 99, 42,115,112,101, 99,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,104, 97,100,101, 95, 97,100,100, 95,115,112,101, 99, 40,102,108,111, 97,116, 32,116, 44, 32,118,101, 99, 51, 32,108, 97, -109,112, 99,111,108, 44, 32,118,101, 99, 51, 32,115,112,101, 99, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117, -116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,116, 42,108, 97,109,112, 99,111,108, 42,115,112, -101, 99, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 40,118,101, 99, 52, + 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 50, 32, 83, 84,108,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 59, + 10, 9,118,101, 99, 50, 32, 83, 84,108,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32,100, 70,100,120, 40,116,101, +120, 99,111, 46,120,121, 41, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,117,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, + 43, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 32, 59, 10, 9, 10, 9,102,108,111, 97,116, 32, 72,108,108, 44, + 72,108,114, 44, 72,117,108, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, + 44, 32, 83, 84,108,108, 41, 44, 32, 72,108,108, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114, +101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108,114, 41, 44, 32, 72,108,114, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, + 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117,108, 41, 44, 32, 72,117,108, 32, 41, 59, 10, 9, 10, + 9,100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,108,114, 32, 45, 32, 72,108,108, 41, 59, 10, 9,100, 66, +116, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,117,108, 32, 45, 32, 72,108,108, 41, 59, 10,125, 10, 10, 35,105,102, +100,101,102, 32, 66, 85, 77, 80, 95, 66, 73, 67, 85, 66, 73, 67, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, + 95, 98,105, 99,117, 98,105, 99, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, +105,109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,102,108,111, 97,116, 32, 72,108, 59, 10, 9,102,108,111, 97,116, 32, 72,114, 59, + 10, 9,102,108,111, 97,116, 32, 72,100, 59, 10, 9,102,108,111, 97,116, 32, 72,117, 59, 10, 9, 10, 9,118,101, 99, 50, 32, 84, +101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, + 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 32, 10, 9,118,101, 99, 50, 32, 83, 84,108, + 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 10, 9,118,101, 99, + 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, + 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101, +120, 68,121, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, + 32, 42, 32, 84,101,120, 68,121, 32, 59, 10, 9, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40, +105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, + 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, 32, 72,114, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116, +117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,100, 41, 44, 32, 72,100, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40,116, +101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, 44, 32, 72,117, 41, 59, 10, 9, 10, 9,118,101, 99, 50, + 32,100, 72,100,120,121, 32, 61, 32,118,101, 99, 50, 40, 72,114, 32, 45, 32, 72,108, 44, 32, 72,117, 32, 45, 32, 72,100, 41, 59, + 10, 9,102,108,111, 97,116, 32,102, 66,108,101,110,100, 32, 61, 32, 99,108, 97,109,112, 40, 49, 46, 48, 45,116,101,120,116,117, +114,101, 81,117,101,114,121, 76, 79, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 46,120, 44, 32, 48, 46, 48, + 44, 32, 49, 46, 48, 41, 59, 10, 9,105,102, 40,102, 66,108,101,110,100, 33, 61, 48, 46, 48, 41, 10, 9,123, 10, 9, 9, 47, 47, + 32,116,104,101, 32,100,101,114,105,118, 97,116,105,118,101, 32,111,102, 32,116,104,101, 32, 98,105, 99,117, 98,105, 99, 32,115, + 97,109,112,108,105,110,103, 32,111,102, 32,108,101,118,101,108, 32, 48, 10, 9, 9,105,118,101, 99, 50, 32,118, 68,105,109, 59, + 10, 9, 9,118, 68,105,109, 32, 61, 32,116,101,120,116,117,114,101, 83,105,122,101, 40,105,109, 97, 44, 32, 48, 41, 59, 10, 10, + 9, 9, 47, 47, 32,116, 97,107,105,110,103, 32,116,104,101, 32,102,114, 97, 99,116, 32,112, 97,114,116, 32,111,102, 32,116,104, +101, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101, 32,105,115, 32, 97, 32,104, 97,114,100, 99,111, +100,101,100, 32,119,114, 97,112, 32,109,111,100,101, 46, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32, 97, 99, 99,101, +112,116, 97, 98,108,101, 32, 97,115, 32,116,101,120,116,117,114,101,115, 32,117,115,101, 32,119,114, 97,112, 32,109,111,100,101, + 32,101,120, 99,108,117,115,105,118,101,108,121, 32,105,110, 32, 51, 68, 32,118,105,101,119, 32,101,108,115,101,119,104,101,114, +101, 32,105,110, 32, 98,108,101,110,100,101,114, 46, 32, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32,100,111,110,101, + 32,115,111, 32,116,104, 97,116, 32,119,101, 32, 99, 97,110, 32,115,116,105,108,108, 32,103,101,116, 32, 97, 32,118, 97,108,105, +100, 32,116,101,120,101,108, 32,119,105,116,104, 32,117,118,115, 32,111,117,116,115,105,100,101, 32,116,104,101, 32, 48, 44, 49, + 32,114, 97,110,103,101, 10, 9, 9, 47, 47, 32, 98,121, 32,116,101,120,101,108, 70,101,116, 99,104, 32, 98,101,108,111,119, 44, + 32, 97,115, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32, 97,114,101, 32, 99,108, 97,109,112,101,100, 32,119,104,101,110, + 32,117,115,105,110,103, 32,116,104,105,115, 32,102,117,110, 99,116,105,111,110, 46, 10, 9, 9,118,101, 99, 50, 32,102, 84,101, +120, 76,111, 99, 32, 61, 32,118, 68,105,109, 42,102,114, 97, 99,116, 40,116,101,120, 99,111, 46,120,121, 41, 32, 45, 32,118,101, + 99, 50, 40, 48, 46, 53, 44, 32, 48, 46, 53, 41, 59, 10, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, 99, 32, 61, 32, +105,118,101, 99, 50, 40,102,108,111,111,114, 40,102, 84,101,120, 76,111, 99, 41, 41, 59, 10, 9, 9,118,101, 99, 50, 32,116, 32, + 61, 32, 99,108, 97,109,112, 40,102, 84,101,120, 76,111, 99, 32, 45, 32,105, 84,101,120, 76,111, 99, 44, 32, 48, 46, 48, 44, 32, + 49, 46, 48, 41, 59, 9, 9, 47, 47, 32,115, 97,116, 32,106,117,115,116, 32,116,111, 32, 98,101, 32,112,101,100, 97,110,116,105, + 99, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 10, + 32, 42, 32, 84,104,105,115, 32, 98,108,111, 99,107, 32,119,105,108,108, 32,114,101,112,108, 97, 99,101, 32,116,104,101, 32,111, +110,101, 32, 98,101,108,111,119, 32,119,104,101,110, 32,111,110,101, 32, 99,104, 97,110,110,101,108, 32,116,101,120,116,117,114, +101,115, 32, 97,114,101, 32,112,114,111,112,101,114,108,121, 32,115,117,112,112,111,114,116,101,100, 46, 32, 42, 10, 32, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 10, 9, 9,118,101, 99, 52, + 32,118, 83, 97,109,112,108,101,115, 85, 76, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, + 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 45, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, + 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 85, + 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43, +105,118,101, 99, 50, 40, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105, +109, 32, 41, 59, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 76, 76, 32, 61, 32,116,101,120,116,117,114,101, + 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 45, 49, 44, 49, 41, + 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 10, 9, 9,118,101, 99, 52, + 32,118, 83, 97,109,112,108,101,115, 76, 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, + 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 49, 44, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, + 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 10, 10, 9, 9,109, 97,116, 52, 32, 72, 32, 61, 32,109, 97,116, 52, 40,118, + 83, 97,109,112,108,101,115, 85, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46,120, 44, 32,118, 83, 97,109,112, +108,101,115, 76, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,120, 44, 10, 9, 9, 9, 9, 9,118, 83, 97,109, +112,108,101,115, 85, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46,121, 44, 32,118, 83, 97,109,112,108,101,115, + 76, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,121, 44, 10, 9, 9, 9, 9, 9,118, 83, 97,109,112,108,101, +115, 85, 82, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,120, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46, +119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,120, 44, 10, 9, 9, 9, 9, 9,118, 83, 97,109,112,108,101,115, 85, 82, + 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,121, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,122, 44, 32, +118, 83, 97,109,112,108,101,115, 76, 82, 46,121, 41, 59, 10, 42, 47, 9, 10, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76, +111, 99, 77,111,100, 32, 61, 32,105, 84,101,120, 76,111, 99, 32, 43, 32,105,118,101, 99, 50, 40, 45, 49, 44, 32, 45, 49, 41, 59, + 10, 10, 9, 9,109, 97,116, 52, 32, 72, 59, 10, 9, 9, 10, 9, 9,102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32, +105, 32, 60, 32, 52, 59, 32,105, 43, 43, 41,123, 10, 9, 9, 9,102,111,114, 40,105,110,116, 32,106, 32, 61, 32, 48, 59, 32,106, + 32, 60, 32, 52, 59, 32,106, 43, 43, 41,123, 10, 9, 9, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 84,109,112, 32, 61, 32, +105, 84,101,120, 76,111, 99, 77,111,100, 32, 43, 32,105,118,101, 99, 50, 40,105, 44,106, 41, 59, 10, 9, 9, 9, 9, 10, 9, 9, + 9, 9, 47, 47, 32,119,114, 97,112, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32,109, 97, +110,117, 97,108,108,121, 32,102,111,114, 32,116,101,120,101,108, 70,101,116, 99,104, 32,116,111, 32,119,111,114,107, 32,111,110, + 32,117,118,115, 32,111,105,116,115,105,100,101, 32,116,104,101, 32, 48, 44, 49, 32,114, 97,110,103,101, 46, 10, 9, 9, 9, 9, + 47, 47, 32,116,104,105,115, 32,105,115, 32,103,117, 97,114, 97,110,116,101,101,100, 32,116,111, 32,119,111,114,107, 32,115,105, +110, 99,101, 32,119,101, 32,116, 97,107,101, 32,116,104,101, 32,102,114, 97, 99,116,105,111,110, 97,108, 32,112, 97,114,116, 32, +111,102, 32,116,104,101, 32,117,118, 32, 97, 98,111,118,101, 46, 10, 9, 9, 9, 9,105, 84,101,120, 84,109,112, 46,120, 32, 61, + 32, 40,105, 84,101,120, 84,109,112, 46,120, 32, 60, 32, 48, 41, 63, 32,105, 84,101,120, 84,109,112, 46,120, 32, 43, 32,118, 68, +105,109, 46,120, 32, 58, 32, 40, 40,105, 84,101,120, 84,109,112, 46,120, 32, 62, 61, 32,118, 68,105,109, 46,120, 41, 63, 32,105, + 84,101,120, 84,109,112, 46,120, 32, 45, 32,118, 68,105,109, 46,120, 32, 58, 32,105, 84,101,120, 84,109,112, 46,120, 41, 59, 10, + 9, 9, 9, 9,105, 84,101,120, 84,109,112, 46,121, 32, 61, 32, 40,105, 84,101,120, 84,109,112, 46,121, 32, 60, 32, 48, 41, 63, + 32,105, 84,101,120, 84,109,112, 46,121, 32, 43, 32,118, 68,105,109, 46,121, 32, 58, 32, 40, 40,105, 84,101,120, 84,109,112, 46, +121, 32, 62, 61, 32,118, 68,105,109, 46,121, 41, 63, 32,105, 84,101,120, 84,109,112, 46,121, 32, 45, 32,118, 68,105,109, 46,121, + 32, 58, 32,105, 84,101,120, 84,109,112, 46,121, 41, 59, 10, 10, 9, 9, 9, 9,114,103, 98,116,111, 98,119, 40,116,101,120,101, +108, 70,101,116, 99,104, 40,105,109, 97, 44, 32,105, 84,101,120, 84,109,112, 44, 32, 48, 41, 44, 32, 72, 91,105, 93, 91,106, 93, + 41, 59, 10, 9, 9, 9,125, 10, 9, 9,125, 10, 9, 9, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,116, 46,120, 44, 32, +121, 32, 61, 32,116, 46,121, 59, 10, 9, 9,102,108,111, 97,116, 32,120, 50, 32, 61, 32,120, 32, 42, 32,120, 44, 32,120, 51, 32, + 61, 32,120, 50, 32, 42, 32,120, 44, 32,121, 50, 32, 61, 32,121, 32, 42, 32,121, 44, 32,121, 51, 32, 61, 32,121, 50, 32, 42, 32, +121, 59, 10, 10, 9, 9,118,101, 99, 52, 32, 88, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,120, 51, 43,120, 41, 43, +120, 50, 44, 9, 9, 49, 46, 53, 42,120, 51, 45, 50, 46, 53, 42,120, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,120, 51, 43, 50, 42, +120, 50, 43, 48, 46, 53, 42,120, 44, 9, 9, 48, 46, 53, 42, 40,120, 51, 45,120, 50, 41, 41, 59, 10, 9, 9,118,101, 99, 52, 32, + 89, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,121, 51, 43,121, 41, 43,121, 50, 44, 9, 9, 49, 46, 53, 42,121, 51, + 45, 50, 46, 53, 42,121, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,121, 51, 43, 50, 42,121, 50, 43, 48, 46, 53, 42,121, 44, 9, 9, + 48, 46, 53, 42, 40,121, 51, 45,121, 50, 41, 41, 59, 10, 9, 9,118,101, 99, 52, 32,100, 88, 32, 61, 32,118,101, 99, 52, 40, 45, + 49, 46, 53, 42,120, 50, 43, 50, 42,120, 45, 48, 46, 53, 44, 9, 9, 52, 46, 53, 42,120, 50, 45, 53, 42,120, 44, 9, 9, 9, 45, + 52, 46, 53, 42,120, 50, 43, 52, 42,120, 43, 48, 46, 53, 44, 9, 9, 49, 46, 53, 42,120, 50, 45,120, 41, 59, 10, 9, 9,118,101, + 99, 52, 32,100, 89, 32, 61, 32,118,101, 99, 52, 40, 45, 49, 46, 53, 42,121, 50, 43, 50, 42,121, 45, 48, 46, 53, 44, 9, 9, 52, + 46, 53, 42,121, 50, 45, 53, 42,121, 44, 9, 9, 9, 45, 52, 46, 53, 42,121, 50, 43, 52, 42,121, 43, 48, 46, 53, 44, 9, 9, 49, + 46, 53, 42,121, 50, 45,121, 41, 59, 10, 9, 10, 9, 9, 47, 47, 32, 99,111,109,112,108,101,116,101, 32,100,101,114,105,118, 97, +116,105,118,101, 32,105,110, 32,110,111,114,109, 97,108,105,122,101,100, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32, 40, +109,117,108, 32, 98,121, 32,118, 68,105,109, 41, 10, 9, 9,118,101, 99, 50, 32,100, 72,100, 83, 84, 32, 61, 32,118, 68,105,109, + 32, 42, 32,118,101, 99, 50, 40,100,111,116, 40, 89, 44, 32, 72, 32, 42, 32,100, 88, 41, 44, 32,100,111,116, 40,100, 89, 44, 32, + 72, 32, 42, 32, 88, 41, 41, 59, 10, 10, 9, 9, 47, 47, 32,116,114, 97,110,115,102,111,114,109, 32,100,101,114,105,118, 97,116, +105,118,101, 32,116,111, 32,115, 99,114,101,101,110, 45,115,112, 97, 99,101, 10, 9, 9,118,101, 99, 50, 32,100, 72,100,120,121, + 95, 98,105, 99,117, 98,105, 99, 32, 61, 32,118,101, 99, 50, 40, 32,100, 72,100, 83, 84, 46,120, 32, 42, 32, 84,101,120, 68,120, + 46,120, 32, 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, 84,101,120, 68,120, 46,121, 44, 10, 9, 9, 9, 9, 9, 9, 9, 9, + 32, 32, 32,100, 72,100, 83, 84, 46,120, 32, 42, 32, 84,101,120, 68,121, 46,120, 32, 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, + 32, 84,101,120, 68,121, 46,121, 32, 41, 59, 10, 10, 9, 9, 47, 47, 32, 98,108,101,110,100, 32, 98,101,116,119,101,101,110, 32, +116,104,101, 32,116,119,111, 10, 9, 9,100, 72,100,120,121, 32, 61, 32,100, 72,100,120,121, 42, 40, 49, 45,102, 66,108,101,110, +100, 41, 32, 43, 32,100, 72,100,120,121, 95, 98,105, 99,117, 98,105, 99, 42,102, 66,108,101,110,100, 59, 10, 9,125, 10, 10, 9, +100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32,100, 72,100,120,121, 46,120, 59, 10, 9,100, 66,116, 32, 61, 32,104, + 83, 99, 97,108,101, 32, 42, 32,100, 72,100,120,121, 46,121, 59, 10,125, 10, 10, 35,101,110,100,105,102, 10, 10,118,111,105,100, + 32,109,116,101,120, 95, 98,117,109,112, 95,116, 97,112, 53, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109, +112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32, +100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70, +100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 10, 9,118,101, 99, 50, 32, 83, 84, 99, 32, 61, 32,116,101,120, 99,111, + 46,120,121, 59, 10, 9,118,101, 99, 50, 32, 83, 84,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, + 42, 32, 84,101,120, 68,120, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, + 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, + 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, 32, +116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 10, 9, 10, 9,102,108,111, 97, +116, 32, 72, 99, 44, 72,108, 44, 72,114, 44, 72,100, 44, 72,117, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116, +117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84, 99, 41, 44, 32, 72, 99, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, + 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 32, 41, 59, 10, 9,114,103, 98, +116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, 32, 72,114, 32, 41, 59, + 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,100, 41, 44, 32, + 72,100, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, + 84,117, 41, 44, 32, 72,117, 32, 41, 59, 10, 9, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,114, + 32, 45, 32, 72,108, 41, 59, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,117, 32, 45, 32, 72,100, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,100,101,114,105,118, 40, 32,118,101, 99, 51, + 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,105,109, 97, + 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, + 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,102,108,111, 97,116, 32,115, 32, + 61, 32, 49, 46, 48, 59, 9, 9, 47, 47, 32,110,101,103, 97,116,101, 32,116,104,105,115, 32,105,102, 32,102,108,105,112,112,101, +100, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, + 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, + 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9, 10, 9, 47, 47, 32,116,104,105,115, 32,118, 97,114,105, + 97,110,116, 32,117,115,105,110,103, 32, 97, 32,100,101,114,105,118, 97,116,105,118,101, 32,109, 97,112, 32,105,115, 32,100,101, +115, 99,114,105, 98,101,100, 32,104,101,114,101, 10, 9, 47, 47, 32,104,116,116,112, 58, 47, 47,109,109,105,107,107,101,108,115, +101,110, 51,100, 46, 98,108,111,103,115,112,111,116, 46, 99,111,109, 47, 50, 48, 49, 49, 47, 48, 55, 47,100,101,114,105,118, 97, +116,105,118,101, 45,109, 97,112,115, 46,104,116,109,108, 10, 9,118,101, 99, 50, 32,100,105,109, 32, 61, 32,118,101, 99, 50, 40, +105,109, 97, 95,120, 44, 32,105,109, 97, 95,121, 41, 59, 10, 9,118,101, 99, 50, 32,100, 66,100,117,118, 32, 61, 32,104, 83, 99, + 97,108,101, 42,100,105,109, 42, 40, 50, 46, 48, 42,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99, +111, 46,120,121, 41, 46,120,121, 45, 49, 46, 48, 41, 59, 10, 9, 10, 9,100, 66,115, 32, 61, 32,100, 66,100,117,118, 46,120, 42, + 84,101,120, 68,120, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,120, 46,121, 59, 10, 9,100, 66, +116, 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84,101,120, 68,121, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, + 84,101,120, 68,121, 46,121, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, + 40, 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, + 66,116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,118,101, 99, 51, 32,118, 78, 97, + 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, + 44, 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 41, 32, 10,123, 10, 9, +118,101, 99, 51, 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40,102, 68,101,116, 41, 32, 42, 32, 40, 32, +100, 66,115, 32, 42, 32,118, 82, 49, 32, 43, 32,100, 66,116, 32, 42, 32,118, 82, 50, 32, 41, 59, 10, 9, 10, 9,118, 78, 97, 99, + 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83,117,114,102, 71,114, 97,100, 59, 10, 9,112, +101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,118, 78, 97, 99, 99, + 95,111,117,116, 32, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 95, +116,101,120,115,112, 97, 99,101, 40, 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, + 32,102,108,111, 97,116, 32,100, 66,116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32,118, 82, 50, 44, 10, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115, + 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,102,108,111, 97,116, 32, +105,109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105, +110, 44, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 41, 32, 10,123, 10, 9,118, +101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, + 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 10, 9,118,101, 99, 51, + 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40,102, 68,101,116, 41, 32, 42, 32, 40, 32, 10, 9, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,100, 66,115, 32, 47, 32,108,101,110,103,116,104, 40, 32,118,101, 99, 50, 40,105,109, 97, + 95,120, 42, 84,101,120, 68,120, 46,120, 44, 32,105,109, 97, 95,121, 42, 84,101,120, 68,120, 46,121, 41, 32, 41, 32, 42, 32,118, + 82, 49, 32, 43, 32, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,100, 66,116, 32, 47, 32,108,101,110,103,116,104, 40, + 32,118,101, 99, 50, 40,105,109, 97, 95,120, 42, 84,101,120, 68,121, 46,120, 44, 32,105,109, 97, 95,121, 42, 84,101,120, 68,121, + 46,121, 41, 32, 41, 32, 42, 32,118, 82, 50, 32, 41, 59, 10, 9, 9, 9, 9, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, + 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83,117,114,102, 71,114, 97,100, 59, 10, 9,112,101,114,116,117,114, 98,101, +100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,118, 78, 97, 99, 99, 95,111,117,116, 32, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,110,101,103, 97,116,101, 95,116,101,120,110,111,114,109, 97,108, 40,118, +101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10, +123, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, 45,110,111,114,109, 97,108, 46,120, 44, 32, 45, +110,111,114,109, 97,108, 46,121, 44, 32,110,111,114,109, 97,108, 46,122, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101, +120, 95,110,115,112, 97, 99,101, 95,116, 97,110,103,101,110,116, 40,118,101, 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,118, +101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,116,101,120,110,111,114,109, 97,108, 44, 32,111,117,116, 32, +118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9,118,101, 99, 51, 32, 66, 32, 61, 32,116, 97,110,103, +101,110,116, 46,119, 32, 42, 32, 99,114,111,115,115, 40,110,111,114,109, 97,108, 44, 32,116, 97,110,103,101,110,116, 46,120,121, +122, 41, 59, 10, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,116,101,120,110,111,114,109, 97,108, 46,120, 42,116, 97, +110,103,101,110,116, 46,120,121,122, 32, 43, 32,116,101,120,110,111,114,109, 97,108, 46,121, 42, 66, 32, 43, 32,116,101,120,110, +111,114,109, 97,108, 46,122, 42,110,111,114,109, 97,108, 59, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114, +109, 97,108,105,122,101, 40,111,117,116,110,111,114,109, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, + 98,108,101,110,100, 95,110,111,114,109, 97,108, 40,102,108,111, 97,116, 32,110,111,114,102, 97, 99, 44, 32,118,101, 99, 51, 32, +110,111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,110,101,119,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, + 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, 40, 49, 46, 48, 32, + 45, 32,110,111,114,102, 97, 99, 41, 42,110,111,114,109, 97,108, 32, 43, 32,110,111,114,102, 97, 99, 42,110,101,119,110,111,114, +109, 97,108, 59, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,111,117,116,110, +111,114,109, 97,108, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 32, 77, 65, 84, 69, 82, 73, 65, 76, 32, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 47, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,117, +110, 95,104,101,109,105, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,118, + 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105, +102, 97, 99, 41, 10,123, 10, 9,108,118, 32, 61, 32,108, 97,109,112,118,101, 99, 59, 10, 9,100,105,115,116, 32, 61, 32, 49, 46, + 48, 59, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95, +118,105,115,105, 98,105,108,105,116,121, 95,111,116,104,101,114, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,108, + 97,109,112, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105, +115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,108,118, 32, 61, 32, 99, +111, 32, 45, 32,108, 97,109,112, 99,111, 59, 10, 9,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40,108,118, 41, 59, 10, + 9,108,118, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108,118, 41, 59, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, + 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,108,105,110, +101, 97,114, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, +108, 97,109,112,100,105,115,116, 47, 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 41, 59, 10,125, 10, 10,118, +111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,115,113,117, 97,114,101, 40,102,108,111, 97,116, + 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, + 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, 47, + 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 42,100,105,115,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32, +108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,115,108,105,100,101,114,115, 40,102,108,111, 97,116, 32,108, 97,109,112,100, +105,115,116, 44, 32,102,108,111, 97,116, 32,108,100, 49, 44, 32,102,108,111, 97,116, 32,108,100, 50, 44, 32,102,108,111, 97,116, + 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,102,108,111, + 97,116, 32,108, 97,109,112,100,105,115,116,107,119, 32, 61, 32,108, 97,109,112,100,105,115,116, 42,108, 97,109,112,100,105,115, +116, 59, 10, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, 47, 40,108, 97,109,112,100,105,115, +116, 32, 43, 32,108,100, 49, 42,100,105,115,116, 41, 59, 10, 9,118,105,115,105,102, 97, 99, 32, 42, 61, 32,108, 97,109,112,100, +105,115,116,107,119, 47, 40,108, 97,109,112,100,105,115,116,107,119, 32, 43, 32,108,100, 50, 42,100,105,115,116, 42,100,105,115, +116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95, 99,117,114,118,101, 40,102, +108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, 97, +112, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, + 41, 10,123, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97, +112, 44, 32,118,101, 99, 50, 40,100,105,115,116, 47,108, 97,109,112,100,105,115,116, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 10, +125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,112,104,101,114,101, 40,102, +108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,102,108,111, 97,116, + 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 10, +123, 10, 9,102,108,111, 97,116, 32,116, 61, 32,108, 97,109,112,100,105,115,116, 32, 45, 32,100,105,115,116, 59, 10, 10, 9,111, +117,116,118,105,115,105,102, 97, 99, 61, 32,118,105,115,105,102, 97, 99, 42,109, 97,120, 40,116, 44, 32, 48, 46, 48, 41, 47,108, + 97,109,112,100,105,115,116, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, + 95,115,112,111,116, 95,115,113,117, 97,114,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,109, 97,116, 52, 32, +108, 97,109,112,105,109, 97,116, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112, +114, 41, 10,123, 10, 9,105,102, 40,100,111,116, 40,108,118, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 62, 32, 48, 46, 48, 41, + 32,123, 10, 9, 9,118,101, 99, 51, 32,108,118,114,111,116, 32, 61, 32, 40,108, 97,109,112,105,109, 97,116, 42,118,101, 99, 52, + 40,108,118, 44, 32, 48, 46, 48, 41, 41, 46,120,121,122, 59, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,109, 97,120, 40, + 97, 98,115, 40,108,118,114,111,116, 46,120, 47,108,118,114,111,116, 46,122, 41, 44, 32, 97, 98,115, 40,108,118,114,111,116, 46, +121, 47,108,118,114,111,116, 46,122, 41, 41, 59, 10, 10, 9, 9,105,110,112,114, 32, 61, 32, 49, 46, 48, 47,115,113,114,116, 40, + 49, 46, 48, 32, 43, 32,120, 42,120, 41, 59, 10, 9,125, 10, 9,101,108,115,101, 10, 9, 9,105,110,112,114, 32, 61, 32, 48, 46, + 48, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,112,111,116, 95, + 99,105,114, 99,108,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,105,110,112,114, 41, 10,123, 10, 9,105,110,112,114, 32, 61, 32,100,111,116, 40,108,118, 44, 32, +108, 97,109,112,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116, +121, 95,115,112,111,116, 40,102,108,111, 97,116, 32,115,112,111,116,115,105, 44, 32,102,108,111, 97,116, 32,115,112,111,116, 98, +108, 44, 32,102,108,111, 97,116, 32,105,110,112,114, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,102,108,111, 97,116, 32,116, 32, 61, + 32,115,112,111,116,115,105, 59, 10, 10, 9,105,102, 40,105,110,112,114, 32, 60, 61, 32,116, 41, 32,123, 10, 9, 9,111,117,116, +118,105,115,105,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,116, 32, 61, 32, +105,110,112,114, 32, 45, 32,116, 59, 10, 10, 9, 9, 47, 42, 32,115,111,102,116, 32, 97,114,101, 97, 32, 42, 47, 10, 9, 9,105, +102, 40,115,112,111,116, 98,108, 32, 33, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,105,110,112,114, 32, 42, 61, 32,115,109,111,111, +116,104,115,116,101,112, 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, 32,116, 47,115,112,111,116, 98,108, 41, 59, 10, 10, 9, 9,111, +117,116,118,105,115,105,102, 97, 99, 32, 61, 32,118,105,115,105,102, 97, 99, 42,105,110,112,114, 59, 10, 9,125, 10,125, 10, 10, +118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, + 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 10, +123, 10, 9,111,117,116,118,105,115,105,102, 97, 99, 32, 61, 32, 40,118,105,115,105,102, 97, 99, 32, 60, 32, 48, 46, 48, 48, 49, + 41, 63, 32, 48, 46, 48, 58, 32,118,105,115,105,102, 97, 99, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,118, +105,101,119, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 41, 10,123, 10, 9, 47, + 42, 32,104, 97,110,100,108,101, 32,112,101,114,115,112,101, 99,116,105,118,101, 47,111,114,116,104,111,103,114, 97,112,104,105, + 99, 32, 42, 47, 10, 9,118,105,101,119, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99,116,105,111,110, 77, 97,116,114,105, +120, 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 41, 58, 32, +118,101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 45, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, + 97,100,101, 95,116, 97,110,103,101,110,116, 95,118, 40,118,101, 99, 51, 32,108,118, 44, 32,118,101, 99, 51, 32,116, 97,110,103, + 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,110, 41, 10,123, 10, 9,118,101, 99, 51, 32, 99, 32, 61, 32, 99,114,111,115,115, + 40,108,118, 44, 32,116, 97,110,103, 41, 59, 10, 9,118,101, 99, 51, 32,118,110,111,114, 32, 61, 32, 99,114,111,115,115, 40, 99, + 44, 32,116, 97,110,103, 41, 59, 10, 10, 9,118,110, 32, 61, 32, 45,110,111,114,109, 97,108,105,122,101, 40,118,110,111,114, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,110,112, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, + 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112, 41, 10,123, 10, 9,105,110,112, 32, 61, 32,100,111, +116, 40,118,110, 44, 32,108,118, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,115, 95,110,111, 95,100, +105,102,102,117,115,101, 40,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,115, 32, 61, 32, 48, 46, 48, + 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,115, 95,104,101,109,105, 40,102,108,111, 97,116, 32,105,110, +112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,115, 32, 61, 32, 48, 46, 53, 42,105,110,112, + 32, 43, 32, 48, 46, 53, 59, 10,125, 10, 10,102,108,111, 97,116, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103, +121, 40,109, 97,116, 52, 32, 97,114,101, 97, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,118,110, 41, 10,123, + 10, 9,118,101, 99, 51, 32,118,101, 99, 91, 52, 93, 44, 32, 99, 91, 52, 93, 59, 10, 9,102,108,111, 97,116, 32,114, 97,100, 91, + 52, 93, 44, 32,102, 97, 99, 59, 10, 9, 10, 9,118,101, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99, +111, 32, 45, 32, 97,114,101, 97, 91, 48, 93, 46,120,121,122, 41, 59, 10, 9,118,101, 99, 91, 49, 93, 32, 61, 32,110,111,114,109, + 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 49, 93, 46,120,121,122, 41, 59, 10, 9,118,101, 99, 91, 50, 93, + 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 50, 93, 46,120,121,122, 41, 59, 10, + 9,118,101, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 51, 93, + 46,120,121,122, 41, 59, 10, 10, 9, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40, +118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, 59, 10, 9, 99, 91, 49, 93, 32, 61, 32,110,111,114,109, 97,108, +105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, 99, 91, 50, 93, 41, 41, 59, 10, 9, 99, 91, 50, + 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 50, 93, 44, 32,118,101, 99, 91, + 51, 93, 41, 41, 59, 10, 9, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, + 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, 41, 41, 59, 10, 10, 9,114, 97,100, 91, 48, 93, 32, 61, 32, 97, 99,111,115, 40, +100,111,116, 40,118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, 59, 10, 9,114, 97,100, 91, 49, 93, 32, 61, 32, + 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, 99, 91, 50, 93, 41, 41, 59, 10, 9,114, 97,100, 91, + 50, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 50, 93, 44, 32,118,101, 99, 91, 51, 93, 41, 41, 59, 10, + 9,114, 97,100, 91, 51, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, + 93, 41, 41, 59, 10, 10, 9,102, 97, 99, 61, 32, 32,114, 97,100, 91, 48, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 48, 93, + 41, 59, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 49, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 49, 93, 41, 59, 10, + 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 50, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 50, 93, 41, 59, 10, 9,102, 97, + 99, 43, 61, 32,114, 97,100, 91, 51, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 51, 93, 41, 59, 10, 10, 9,114,101,116,117, +114,110, 32,109, 97,120, 40,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, +105,110,112, 95, 97,114,101, 97, 40,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,118,101, 99, 51, 32,108, 97,109, +112, 99,111, 44, 32,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,109, 97,116, 52, + 32, 97,114,101, 97, 44, 32,102,108,111, 97,116, 32, 97,114,101, 97,115,105,122,101, 44, 32,102,108,111, 97,116, 32,107, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,105,110,112, 41, 10,123, 10, 9,118,101, 99, 51, 32, 99,111, 32, 61, 32,112,111,115,105, +116,105,111,110, 59, 10, 9,118,101, 99, 51, 32,118,101, 99, 32, 61, 32, 99,111, 32, 45, 32,108, 97,109,112, 99,111, 59, 10, 10, + 9,105,102, 40,100,111,116, 40,118,101, 99, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, + 9,105,110,112, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,105, +110,116,101,110,115, 32, 61, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, 40, 97,114,101, 97, 44, 32, 99, +111, 44, 32,118,110, 41, 59, 10, 10, 9, 9,105,110,112, 32, 61, 32,112,111,119, 40,105,110,116,101,110,115, 42, 97,114,101, 97, +115,105,122,101, 44, 32,107, 41, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117, +115,101, 95,111,114,101,110, 95,110, 97,121,101,114, 40,102,108,111, 97,116, 32,110,108, 44, 32,118,101, 99, 51, 32,110, 44, 32, +118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, + 40,118, 32, 43, 32,108, 41, 59, 10, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32, +104, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, + 32,118, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,114,101, 97,108,110,108, 32, 61, 32,100,111,116, 40,110, + 44, 32,108, 41, 59, 10, 10, 9,105,102, 40,114,101, 97,108,110,108, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,105,115, 32, + 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,105,102, 40,110,108, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, + 9,105,115, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,118,104, + 32, 61, 32,109, 97,120, 40,100,111,116, 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9, 9,102,108,111, 97,116, 32, + 76,105,116, 95, 65, 32, 61, 32, 97, 99,111,115, 40,114,101, 97,108,110,108, 41, 59, 10, 9, 9,102,108,111, 97,116, 32, 86,105, +101,119, 95, 65, 32, 61, 32, 97, 99,111,115, 40,110,118, 41, 59, 10, 10, 9, 9,118,101, 99, 51, 32, 76,105,116, 95, 66, 32, 61, + 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 45, 32,114,101, 97,108,110,108, 42,110, 41, 59, 10, 9, 9,118,101, 99, 51, + 32, 86,105,101,119, 95, 66, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 45, 32,110,118, 42,110, 41, 59, 10, 10, + 9, 9,102,108,111, 97,116, 32,116, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 76,105,116, 95, 66, 44, 32, 86,105,101,119, 95, + 66, 41, 44, 32, 48, 46, 48, 41, 59, 10, 10, 9, 9,102,108,111, 97,116, 32, 97, 44, 32, 98, 59, 10, 10, 9, 9,105,102, 40, 76, +105,116, 95, 65, 32, 62, 32, 86,105,101,119, 95, 65, 41, 32,123, 10, 9, 9, 9, 97, 32, 61, 32, 76,105,116, 95, 65, 59, 10, 9, + 9, 9, 98, 32, 61, 32, 86,105,101,119, 95, 65, 59, 10, 9, 9,125, 10, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9, 97, 32, + 61, 32, 86,105,101,119, 95, 65, 59, 10, 9, 9, 9, 98, 32, 61, 32, 76,105,116, 95, 65, 59, 10, 9, 9,125, 10, 10, 9, 9,102, +108,111, 97,116, 32, 65, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 48, 46, 53, 42, 40, 40,114,111,117,103,104, 42,114,111,117,103, +104, 41, 47, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, 51, 51, 41, 41, 41, 59, 10, 9, 9,102, +108,111, 97,116, 32, 66, 32, 61, 32, 48, 46, 52, 53, 42, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 47, 40, 40,114, +111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, 48, 57, 41, 41, 59, 10, 10, 9, 9, 98, 32, 42, 61, 32, 48, 46, + 57, 53, 59, 10, 9, 9,105,115, 32, 61, 32,110,108, 42, 40, 65, 32, 43, 32, 40, 66, 32, 42, 32,116, 32, 42, 32,115,105,110, 40, + 97, 41, 32, 42, 32,116, 97,110, 40, 98, 41, 41, 41, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, +100,105,102,102,117,115,101, 95,116,111,111,110, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, + 51, 32,118, 44, 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111, +116, 40,110, 44, 32,108, 41, 59, 10, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, 41, + 59, 10, 10, 9,105,102, 40, 97,110,103, 32, 60, 32,115,105,122,101, 41, 32,105,115, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108, +115,101, 32,105,102, 40, 97,110,103, 32, 62, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111,116,104, 41, 32,124,124, 32, +116,115,109,111,111,116,104, 32, 61, 61, 32, 48, 46, 48, 41, 32,105,115, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32, +105,115, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115,105,122,101, 41, 47,116,115,109,111,111,116,104, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115,101, 95,109,105,110,110, 97,101,114, +116, 40,102,108,111, 97,116, 32,110,108, 44, 32,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97, +116, 32,100, 97,114,107,110,101,115,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,102, 40, +110,108, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115, +101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, + 48, 46, 48, 41, 59, 10, 10, 9, 9,105,102, 40,100, 97,114,107,110,101,115,115, 32, 60, 61, 32, 49, 46, 48, 41, 10, 9, 9, 9, +105,115, 32, 61, 32,110,108, 42,112,111,119, 40,109, 97,120, 40,110,118, 42,110,108, 44, 32, 48, 46, 49, 41, 44, 32,100, 97,114, +107,110,101,115,115, 32, 45, 32, 49, 46, 48, 41, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,105,115, 32, 61, 32,110,108, 42, +112,111,119, 40, 49, 46, 48, 48, 48, 49, 32, 45, 32,110,118, 44, 32,100, 97,114,107,110,101,115,115, 32, 45, 32, 49, 46, 48, 41, + 59, 10, 9,125, 10,125, 10, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, 95,102, 97, 99, 40,118,101, 99, 51, 32,118, +105,101,119, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,102,108,111, 97,116, 32,103,114, 97,100, 44, 32,102,108,111, 97,116, 32, +102, 97, 99, 41, 10,123, 10, 9,102,108,111, 97,116, 32,116, 49, 44, 32,116, 50, 59, 10, 9,102,108,111, 97,116, 32,102,102, 97, + 99, 59, 10, 10, 9,105,102, 40,102, 97, 99, 61, 61, 48, 46, 48, 41, 32,123, 10, 9, 9,102,102, 97, 99, 32, 61, 32, 49, 46, 48, + 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,116, 49, 61, 32,100,111,116, 40,118,105,101,119, 44, 32,118,110, 41, + 59, 10, 9, 9,105,102, 40,116, 49, 62, 48, 46, 48, 41, 32, 32,116, 50, 61, 32, 49, 46, 48, 43,116, 49, 59, 10, 9, 9,101,108, +115,101, 32,116, 50, 61, 32, 49, 46, 48, 45,116, 49, 59, 10, 10, 9, 9,116, 50, 61, 32,103,114, 97,100, 32, 43, 32, 40, 49, 46, + 48, 45,103,114, 97,100, 41, 42,112,111,119, 40,116, 50, 44, 32,102, 97, 99, 41, 59, 10, 10, 9, 9,105,102, 40,116, 50, 60, 48, + 46, 48, 41, 32,102,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9,101,108,115,101, 32,105,102, 40,116, 50, 62, 49, 46, 48, + 41, 32,102,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 32,102,102, 97, 99, 32, 61, 32,116, 50, 59, 10, + 9,125, 10, 10, 9,114,101,116,117,114,110, 32,102,102, 97, 99, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, +100,105,102,102,117,115,101, 95,102,114,101,115,110,101,108, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, + 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 95,105, 44, 32,102,108,111, 97,116, 32, +102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,115, 32, 61, 32,102,114,101,115,110, +101,108, 95,102, 97, 99, 40,108,118, 44, 32,118,110, 44, 32,102, 97, 99, 95,105, 44, 32,102, 97, 99, 41, 59, 10,125, 10, 10,118, +111,105,100, 32,115,104, 97,100,101, 95, 99,117, 98,105, 99, 40,102,108,111, 97,116, 32,105,115, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,111,117,116,105,115, 41, 10,123, 10, 9,105,102, 40,105,115, 62, 48, 46, 48, 32, 38, 38, 32,105,115, 60, 49, 46, + 48, 41, 10, 9, 9,111,117,116,105,115, 61, 32,115,109,111,111,116,104,115,116,101,112, 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, + 32,105,115, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,105,115, 61, 32,105,115, 59, 10,125, 10, 10,118,111,105,100, + 32,115,104, 97,100,101, 95,118,105,115,105,102, 97, 99, 40,102,108,111, 97,116, 32,105, 44, 32,102,108,111, 97,116, 32,118,105, +115,105,102, 97, 99, 44, 32,102,108,111, 97,116, 32,114,101,102,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, +105, 41, 10,123, 10, 9, 47, 42,105,102, 40,105, 32, 62, 32, 48, 46, 48, 41, 42, 47, 10, 9, 9,111,117,116,105, 32, 61, 32,109, + 97,120, 40,105, 42,118,105,115,105,102, 97, 99, 42,114,101,102,108, 44, 32, 48, 46, 48, 41, 59, 10, 9, 47, 42,101,108,115,101, + 10, 9, 9,111,117,116,105, 32, 61, 32,105, 59, 42, 47, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116, 97,110, +103,101,110,116, 95,118, 95,115,112,101, 99, 40,118,101, 99, 51, 32,116, 97,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32, +118,110, 41, 10,123, 10, 9,118,110, 32, 61, 32,116, 97,110,103, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, + 97,100,100, 95,116,111, 95,100,105,102,102,117,115,101, 40,102,108,111, 97,116, 32,105, 44, 32,118,101, 99, 51, 32,108, 97,109, +112, 99,111,108, 44, 32,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, + 10,123, 10, 9,105,102, 40,105, 32, 62, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,105, 42,108, 97,109, +112, 99,111,108, 42, 99,111,108, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 51, 40, + 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,104,101, +109,105, 95,115,112,101, 99, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,118,101, 99, 51, 32,118, +105,101,119, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,102,108,111, + 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 10,123, 10, 9,108,118, 32, 43, + 61, 32,118,105,101,119, 59, 10, 9,108,118, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108,118, 41, 59, 10, 10, 9,116, + 32, 61, 32,100,111,116, 40,118,110, 44, 32,108,118, 41, 59, 10, 9,116, 32, 61, 32, 48, 46, 53, 42,116, 32, 43, 32, 48, 46, 53, + 59, 10, 10, 9,116, 32, 61, 32,118,105,115,105,102, 97, 99, 42,115,112,101, 99, 42,112,111,119, 40,116, 44, 32,104, 97,114,100, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,112,104,111,110,103, 95,115,112,101, 99, 40,118,101, 99, 51, + 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110, +111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,109, + 97,120, 40,100,111,116, 40,104, 44, 32,110, 41, 44, 32, 48, 46, 48, 41, 59, 10, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, +112,111,119, 40,114,115,108,116, 44, 32,104, 97,114,100, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 99, +111,111,107,116,111,114,114, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, + 51, 32,118, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, + 97, 99, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, + 59, 10, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,100,111,116, 40,110, 44, 32,104, 41, 59, 10, 10, 9,105,102, 40,110,104, + 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101, +108,115,101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, + 44, 32, 48, 46, 48, 41, 59, 10, 9, 9,102,108,111, 97,116, 32,105, 32, 61, 32,112,111,119, 40,110,104, 44, 32,104, 97,114,100, + 41, 59, 10, 10, 9, 9,105, 32, 61, 32,105, 47, 40, 48, 46, 49, 43,110,118, 41, 59, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, + 61, 32,105, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 98,108,105,110,110, 95,115,112,101, 99, + 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,114, +101,102,114, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 95,112,111,119,101,114, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,115,112,101, 99,102, 97, 99, 41, 10,123, 10, 9,105,102, 40,114,101,102,114, 97, 99, 32, 60, 32, 49, 46, 48, 41, 32, +123, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,105,102, 40,115, +112,101, 99, 95,112,111,119,101,114, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, + 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,105,102, 40,115,112,101, 99, 95,112,111,119,101,114, 60, + 49, 48, 48, 46, 48, 41, 10, 9, 9, 9,115,112,101, 99, 95,112,111,119,101,114, 61, 32,115,113,114,116, 40, 49, 46, 48, 47,115, +112,101, 99, 95,112,111,119,101,114, 41, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,115,112,101, 99, 95,112,111,119,101,114, + 61, 32, 49, 48, 46, 48, 47,115,112,101, 99, 95,112,111,119,101,114, 59, 10, 10, 9, 9,118,101, 99, 51, 32,104, 32, 61, 32,110, +111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, 10, 9, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,100,111, +116, 40,110, 44, 32,104, 41, 59, 10, 9, 9,105,102, 40,110,104, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9, 9,115,112,101, + 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9,125, 10, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9,102,108,111, 97, +116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 49, 41, 59, 10, 9, 9, 9, +102,108,111, 97,116, 32,110,108, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 10, 9, 9, 9,105,102, 40,110,108, 32, 60, + 61, 32, 48, 46, 48, 49, 41, 32,123, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 9, +125, 10, 9, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,118,104, 32, 61, 32,109, 97,120, 40,100, +111,116, 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 49, 41, 59, 10, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 97, 32, 61, 32, + 49, 46, 48, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 98, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42,110,118, 41, 47,118, +104, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 99, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42,110,108, 41, 47,118,104, 59, + 10, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,103, 32, 61, 32, 48, 46, 48, 59, 10, 10, 9, 9, 9, 9,105,102, 40, 97, 32, 60, + 32, 98, 32, 38, 38, 32, 97, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 97, 59, 10, 9, 9, 9, 9,101,108,115,101, 32,105,102, 40, + 98, 32, 60, 32, 97, 32, 38, 38, 32, 98, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 98, 59, 10, 9, 9, 9, 9,101,108,115,101, 32, +105,102, 40, 99, 32, 60, 32, 97, 32, 38, 38, 32, 99, 32, 60, 32, 98, 41, 32,103, 32, 61, 32, 99, 59, 10, 10, 9, 9, 9, 9,102, +108,111, 97,116, 32,112, 32, 61, 32,115,113,114,116, 40, 40, 40,114,101,102,114, 97, 99, 32, 42, 32,114,101,102,114, 97, 99, 41, + 43, 40,118,104, 42,118,104, 41, 45, 49, 46, 48, 41, 41, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,102, 32, 61, 32, 40, 40, + 40,112, 45,118,104, 41, 42, 40,112, 45,118,104, 41, 41, 47, 40, 40,112, 43,118,104, 41, 42, 40,112, 43,118,104, 41, 41, 41, 42, + 40, 49, 46, 48, 43, 40, 40, 40, 40,118,104, 42, 40,112, 43,118,104, 41, 41, 45, 49, 46, 48, 41, 42, 40, 40,118,104, 42, 40,112, + 43,118,104, 41, 41, 45, 49, 46, 48, 41, 41, 47, 40, 40, 40,118,104, 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 42, 40, + 40,118,104, 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 41, 41, 41, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 97, +110,103, 32, 61, 32, 97, 99,111,115, 40,110,104, 41, 59, 10, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,109, 97, +120, 40,102, 42,103, 42,101,120,112, 95, 98,108,101,110,100,101,114, 40, 40, 45, 40, 97,110,103, 42, 97,110,103, 41, 47, 40, 50, + 46, 48, 42,115,112,101, 99, 95,112,111,119,101,114, 42,115,112,101, 99, 95,112,111,119,101,114, 41, 41, 41, 44, 32, 48, 46, 48, + 41, 59, 10, 9, 9, 9,125, 10, 9, 9,125, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,119, 97,114, +100,105,115,111, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, + 44, 32,102,108,111, 97,116, 32,114,109,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 10, +123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 10, 9,102, +108,111, 97,116, 32,110,104, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,104, 41, 44, 32, 48, 46, 48, 48, 49, 41, 59, + 10, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 48, + 49, 41, 59, 10, 9,102,108,111, 97,116, 32,110,108, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,108, 41, 44, 32, 48, + 46, 48, 48, 49, 41, 59, 10, 9,102,108,111, 97,116, 32, 97,110,103,108,101, 32, 61, 32,116, 97,110, 40, 97, 99,111,115, 40,110, +104, 41, 41, 59, 10, 9,102,108,111, 97,116, 32, 97,108,112,104, 97, 32, 61, 32,109, 97,120, 40,114,109,115, 44, 32, 48, 46, 48, + 48, 49, 41, 59, 10, 10, 9,115,112,101, 99,102, 97, 99, 61, 32,110,108, 32, 42, 32, 40, 49, 46, 48, 47, 40, 52, 46, 48, 42, 77, + 95, 80, 73, 42, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 42, 40,101,120,112, 95, 98,108,101,110,100,101,114, 40, 45, + 40, 97,110,103,108,101, 42, 97,110,103,108,101, 41, 47, 40, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 47, 40,115,113, +114,116, 40,110,118, 42,110,108, 41, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116,111,111,110, 95, +115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, + 97,116, 32,115,105,122,101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,115,112,101, 99,102, 97, 99, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, + 40,108, 32, 43, 32,118, 41, 59, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111,116, 40,104, 44, 32,110, 41, + 59, 10, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, 41, 59, 10, 10, 9,105,102, 40, + 97,110,103, 32, 60, 32,115,105,122,101, 41, 32,114,115,108,116, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, + 40, 97,110,103, 32, 62, 61, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111,116,104, 41, 32,124,124, 32,116,115,109,111, +111,116,104, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,115,108,116, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,114,115, +108,116, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115,105,122,101, 41, 47,116,115,109,111,111,116,104, + 41, 59, 10, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,114,115,108,116, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97, +100,101, 95,115,112,101, 99, 95, 97,114,101, 97, 95,105,110,112, 40,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 44, 32, +102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,112,101, 99,102, 97, 99, 41, + 10,123, 10, 9,111,117,116,115,112,101, 99,102, 97, 99, 32, 61, 32,115,112,101, 99,102, 97, 99, 42,105,110,112, 59, 10,125, 10, + 10,118,111,105,100, 32,115,104, 97,100,101, 95,115,112,101, 99, 95,116, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, + 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,102,108,111, + 97,116, 32,115,112,101, 99,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 10,123, 10, 9,116, 32, 61, 32, +115,104, 97,100,102, 97, 99, 42,115,112,101, 99, 42,118,105,115,105,102, 97, 99, 42,115,112,101, 99,102, 97, 99, 59, 10,125, 10, + 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95,115,112,101, 99, 40,102,108,111, 97,116, 32,116, 44, 32,118,101, + 99, 51, 32,108, 97,109,112, 99,111,108, 44, 32,118,101, 99, 51, 32,115,112,101, 99, 99,111,108, 44, 32,111,117,116, 32,118,101, + 99, 51, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,116, 42,108, 97,109,112, 99,111,108, + 42,115,112,101, 99, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111, -108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, - 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, - 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32, 99,111,108, 49, 42, 99,111, -108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95, 99,108, 97,109,112,101,100, - 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32,109, 97,120, - 40, 99,111,108, 50, 44, 32,118,101, 99, 52, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100, 95, 99,108, 97,109,112,101,100, 40, -118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32, -111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99, -111,108, 32, 43, 32,109, 97,120, 40, 99,111,108, 49, 42, 99,111,108, 50, 44, 32,118,101, 99, 52, 40, 48, 46, 48, 44, 32, 48, 46, - 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, -109, 97,100,100,102, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 44, 32,118,101, 99, 52, 32, 99,111, -108, 49, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, - 32, 61, 32, 99,111,108, 32, 43, 32,102, 42, 99,111,108, 49, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,109,117,108, 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32, -118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 42, - 99,111,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,117,108, 95,118, 97,108,117,101, - 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, -117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 42,102, 97, 99, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111, 98, 99,111,108,111,114, 40,118,101, 99, 52, 32, 99,111,108, 44, - 32,118,101, 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, - 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 42,111, 98, 99,111,108, 46,114, -103, 98, 44, 32, 99,111,108, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,114, 97,109,112, 95,114,103, 98,116, -111, 98,119, 40,118,101, 99, 51, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, - 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 99,111,108,111,114, 46,114, 42, 48, 46, 51, 32, 43, 32, 99,111, -108,111,114, 46,103, 42, 48, 46, 53, 56, 32, 43, 32, 99,111,108,111,114, 46, 98, 42, 48, 46, 49, 50, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110,108,121, 95,115,104, 97,100,111,119, 40,102,108,111, 97,116, 32,105, 44, - 32,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,102,108,111, 97,116, 32,101,110,101,114,103,121, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,111,117,116,115,104, 97,100,102, 97, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,115,104, 97,100, -102, 97, 99, 32, 61, 32,105, 42,101,110,101,114,103,121, 42, 40, 49, 46, 48, 32, 45, 32,115,104, 97,100,102, 97, 99, 41, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110,108,121, 95,115,104, 97,100,111,119, 95,100,105,102, -102,117,115,101, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,118,101, 99, 51, 32,114,103, 98, 44, 32,118,101, - 99, 52, 32,100,105,102,102, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,100,105,102,102, 41, 13, 10,123, 13, 10, 9, -111,117,116,100,105,102,102, 32, 61, 32,100,105,102,102, 32, 45, 32,118,101, 99, 52, 40,114,103, 98, 42,115,104, 97,100,102, 97, - 99, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110,108,121, 95,115, -104, 97,100,111,119, 95,115,112,101, 99,117,108, 97,114, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,118,101, - 99, 51, 32,115,112,101, 99,114,103, 98, 44, 32,118,101, 99, 52, 32,115,112,101, 99, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116,115,112,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,115,112,101, 99, 32, 61, 32,115,112,101, 99, 32, 45, 32,118, -101, 99, 52, 40,115,112,101, 99,114,103, 98, 42,115,104, 97,100,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111,119, 98,117,102, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, - 97,109,112,108,101,114, 50, 68, 83,104, 97,100,111,119, 32,115,104, 97,100,111,119,109, 97,112, 44, 32,109, 97,116, 52, 32,115, +108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, 59, 10,125, 10, 10,118, +111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32, 99,111, +108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10, +123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32, 99,111,108, 49, 42, 99,111,108, 50, 59, 10,125, 10, 10, +118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95, 99,108, 97,109,112,101,100, 40,118,101, 99, 52, 32, 99,111,108, 49, + 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, + 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32,109, 97,120, 40, 99,111,108, 50, 44, 32,118,101, 99, 52, 40, + 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, + 97,100,101, 95,109, 97,100,100, 95, 99,108, 97,109,112,101,100, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32, + 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, + 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32,109, 97,120, 40, 99,111,108, 49, 42, 99,111,108, + 50, 44, 32,118,101, 99, 52, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, 59, 10,125, 10, + 10,118,111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100,102, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,102,108,111, 97, +116, 32,102, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, + 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32,102, 42, 99,111,108, 49, 59, 10,125, 10, 10,118,111, +105,100, 32,115,104, 97,100,101, 95,109,117,108, 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, + 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, + 99,111,108, 49, 42, 99,111,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,117,108, 95,118, 97,108, +117,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, + 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 42,102, 97, 99, 59, 10,125, 10, + 10,118,111,105,100, 32,115,104, 97,100,101, 95,111, 98, 99,111,108,111,114, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, + 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117, +116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 42,111, 98, 99,111,108, 46,114,103, 98, 44, 32, 99, +111,108, 46, 97, 41, 59, 10,125, 10, 10,118,111,105,100, 32,114, 97,109,112, 95,114,103, 98,116,111, 98,119, 40,118,101, 99, 51, + 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116, +118, 97,108, 32, 61, 32, 99,111,108,111,114, 46,114, 42, 48, 46, 51, 32, 43, 32, 99,111,108,111,114, 46,103, 42, 48, 46, 53, 56, + 32, 43, 32, 99,111,108,111,114, 46, 98, 42, 48, 46, 49, 50, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111, +110,108,121, 95,115,104, 97,100,111,119, 40,102,108,111, 97,116, 32,105, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,102, 97, + 99, 44, 32,102,108,111, 97,116, 32,101,110,101,114,103,121, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,104, + 97,100,102, 97, 99, 41, 10,123, 10, 9,111,117,116,115,104, 97,100,102, 97, 99, 32, 61, 32,105, 42,101,110,101,114,103,121, 42, + 40, 49, 46, 48, 32, 45, 32,115,104, 97,100,102, 97, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111, +110,108,121, 95,115,104, 97,100,111,119, 95,100,105,102,102,117,115,101, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, + 44, 32,118,101, 99, 51, 32,114,103, 98, 44, 32,118,101, 99, 52, 32,100,105,102,102, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +111,117,116,100,105,102,102, 41, 10,123, 10, 9,111,117,116,100,105,102,102, 32, 61, 32,100,105,102,102, 32, 45, 32,118,101, 99, + 52, 40,114,103, 98, 42,115,104, 97,100,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97, +100,101, 95,111,110,108,121, 95,115,104, 97,100,111,119, 95,115,112,101, 99,117,108, 97,114, 40,102,108,111, 97,116, 32,115,104, + 97,100,102, 97, 99, 44, 32,118,101, 99, 51, 32,115,112,101, 99,114,103, 98, 44, 32,118,101, 99, 52, 32,115,112,101, 99, 44, 32, +111,117,116, 32,118,101, 99, 52, 32,111,117,116,115,112,101, 99, 41, 10,123, 10, 9,111,117,116,115,112,101, 99, 32, 61, 32,115, +112,101, 99, 32, 45, 32,118,101, 99, 52, 40,115,112,101, 99,114,103, 98, 42,115,104, 97,100,102, 97, 99, 44, 32, 48, 46, 48, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111,119, 98,117,102, 40,118,101, 99, 51, 32,114, 99, +111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 83,104, 97,100,111,119, 32,115,104, 97,100,111,119,109, 97,112, 44, 32,109, 97, +116, 52, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,111,119, 98,105, + 97,115, 44, 32,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, + 10,123, 10, 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, + 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97,100, +111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 10, 10, 9, 9, 47, 47,102, +108,111, 97,116, 32, 98,105, 97,115, 32, 61, 32, 40, 49, 46, 53, 32, 45, 32,105,110,112, 42,105,110,112, 41, 42,115,104, 97,100, +111,119, 98,105, 97,115, 59, 10, 9, 9, 99,111, 46,122, 32, 45, 61, 32,115,104, 97,100,111,119, 98,105, 97,115, 42, 99,111, 46, +119, 59, 10, 9, 9, 10, 9, 9,105,102, 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 32, 62, + 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 32, + 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, 10, 9, 9, 9,114,101,115, +117,108,116, 32, 61, 32,115,104, 97,100,111,119, 50, 68, 80,114,111,106, 40,115,104, 97,100,111,119,109, 97,112, 44, 32, 99,111, + 41, 46,120, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 10, 9,125, 10, +125, 10, 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111,119, 98,117,102, 95,118,115,109, 40,118,101, 99, 51, 32, +114, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,115,104, 97,100,111,119,109, 97,112, 44, 32,109, 97,116, 52, 32,115, 104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,111,119, 98,105, 97,115, 44, 32, -102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, - 10, 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, - 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, - 97,100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9, - 9, 47, 47,102,108,111, 97,116, 32, 98,105, 97,115, 32, 61, 32, 40, 49, 46, 53, 32, 45, 32,105,110,112, 42,105,110,112, 41, 42, -115,104, 97,100,111,119, 98,105, 97,115, 59, 13, 10, 9, 9, 99,111, 46,122, 32, 45, 61, 32,115,104, 97,100,111,119, 98,105, 97, -115, 42, 99,111, 46,119, 59, 13, 10, 9, 9, 13, 10, 9, 9,105,102, 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, - 32, 99,111, 46,120, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, - 38, 32, 99,111, 46,121, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, - 13, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, 32,115,104, 97,100,111,119, 50, 68, 80,114,111,106, 40,115,104, 97,100,111, -119,109, 97,112, 44, 32, 99,111, 41, 46,120, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,114,101,115,117,108,116, 32, - 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111, -119, 98,117,102, 95,118,115,109, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,115,104, 97, -100,111,119,109, 97,112, 44, 32,109, 97,116, 52, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97, -116, 32,115,104, 97,100,111,119, 98,105, 97,115, 44, 32,102,108,111, 97,116, 32, 98,108,101,101,100, 98,105, 97,115, 44, 32,102, -108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, - 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, 46, - 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97, -100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9, 9,105,102, - 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, - 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99, -111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, 32,123, 13, 10, 9, 9, 9,118,101, 99, 50, 32,109,111,109,101,110, -116,115, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40,115,104, 97,100,111,119,109, 97,112, 44, 32, 99,111, - 41, 46,114,103, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32, 99,111, 46,122, 47, 99,111, 46,119, - 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9, 9, 13, 10, 9, 9, 9,105,102, - 40,100,105,115,116, 32, 60, 61, 32,109,111,109,101,110,116,115, 46,120, 41, 13, 10, 9, 9, 9, 9,112, 32, 61, 32, 49, 46, 48, - 59, 13, 10, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109,111,109,101,110,116,115, - 46,121, 32, 45, 32, 40,109,111,109,101,110,116,115, 46,120, 42,109,111,109,101,110,116,115, 46,120, 41, 59, 13, 10, 9, 9, 9, -118, 97,114,105, 97,110, 99,101, 32, 61, 32,109, 97,120, 40,118, 97,114,105, 97,110, 99,101, 44, 32,115,104, 97,100,111,119, 98, -105, 97,115, 47, 49, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,100, 32, 61, 32,109,111,109,101,110, -116,115, 46,120, 32, 45, 32,100,105,115,116, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 95,109, 97,120, 32, 61, 32,118, - 97,114,105, 97,110, 99,101, 32, 47, 32, 40,118, 97,114,105, 97,110, 99,101, 32, 43, 32,100, 42,100, 41, 59, 13, 10, 13, 10, 9, - 9, 9, 47, 47, 32, 78,111,119, 32,114,101,100,117, 99,101, 32,108,105,103,104,116, 45, 98,108,101,101,100,105,110,103, 32, 98, -121, 32,114,101,109,111,118,105,110,103, 32,116,104,101, 32, 91, 48, 44, 32,120, 93, 32,116, 97,105,108, 32, 97,110,100, 32,108, -105,110,101, 97,114,108,121, 32,114,101,115, 99, 97,108,105,110,103, 32, 40,120, 44, 32, 49, 93, 13, 10, 9, 9, 9,112, 95,109, - 97,120, 32, 61, 32, 99,108, 97,109,112, 40, 40,112, 95,109, 97,120, 45, 98,108,101,101,100, 98,105, 97,115, 41, 47, 40, 49, 46, - 48, 45, 98,108,101,101,100, 98,105, 97,115, 41, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9, 9,114, -101,115,117,108,116, 32, 61, 32,109, 97,120, 40,112, 44, 32,112, 95,109, 97,120, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101, -108,115,101, 32,123, 13, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,125, 9, 9, 9, 13, - 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,108,105,103,104,116, 95,116,101,120,116,117, -114,101, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,111,111,107,105,101, 44, 32,109, - 97,116, 52, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117, -108,116, 41, 13, 10,123, 13, 10, 13, 10, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97,100,111,119,112,101,114,115,109, - 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32, -116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40, 99,111,111,107,105,101, 44, 32, 99,111, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95,101,120,112,111,115,117,114,101, 95, 99,111,114,114,101, 99,116, 40,118,101, 99, - 51, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32,108,105,110,102, 97, 99, 44, 32,102,108,111, 97,116, 32,108,111,103,102, 97, - 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, - 61, 32,108,105,110,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32,101,120,112, 40, 99,111,108, 42,108,111,103,102, 97, 99, 41, 41, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,105,115,116, 95,102, 97, 99,116,111,114, 40,118, -101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,109,105,115,116,115,116, 97, 44, 32,102,108,111, 97,116, 32,109,105,115, -116,100,105,115,116, 44, 32,102,108,111, 97,116, 32,109,105,115,116,116,121,112,101, 44, 32,102,108,111, 97,116, 32,109,105,115, -105, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, -102, 97, 99, 44, 32,122, 99,111,114, 59, 13, 10, 13, 10, 9,122, 99,111,114, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99, -116,105,111,110, 77, 97,116,114,105,120, 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,108,101,110,103,116,104, - 40, 99,111, 41, 58, 32, 45, 99,111, 91, 50, 93, 59, 13, 10, 9, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 40, -122, 99,111,114, 45,109,105,115,116,115,116, 97, 41, 47,109,105,115,116,100,105,115,116, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, - 41, 59, 13, 10, 9,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 48, 46, 48, 41, 32,102, 97, 99, 32, 42, 61, 32, -102, 97, 99, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 49, 46, 48, 41, 59, - 13, 10, 9,101,108,115,101, 32,102, 97, 99, 32, 61, 32,115,113,114,116, 40,102, 97, 99, 41, 59, 13, 10, 13, 10, 9,111,117,116, -102, 97, 99, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 45,102, 97, 99, 41, 42, 40, 49, 46, 48, 45,109,105,115,105, 41, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,119,111,114,108,100, 95,109,105,120, 40,118,101, 99, - 51, 32,104,111,114, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, - 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 99,111,108, 46, 97, 44, 32, - 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,109,105,120, 40,104, -111,114, 44, 32, 99,111,108, 46,114,103, 98, 44, 32,102, 97, 99, 41, 44, 32, 99,111,108, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,108,112,104, 97, 95,111,112, 97,113,117,101, 40,118,101, 99, 52, 32, 99,111, -108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, - 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,104, 97,100,101, 95, 97,108,112,104, 97, 95,111, 98, 99,111,108,111,114, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118, -101, 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, - 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 99,111,108, 46, 97, 42,111, 98, - 99,111,108, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 78, 69, 87, 32, 83, - 72, 65, 68, 69, 82, 32, 85, 84, 73, 76, 73, 84, 73, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, - 10, 13, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, 95,100,105,101,108,101, 99,116,114,105, 99, 40,118,101, 99, 51, - 32, 73,110, 99,111,109,105,110,103, 44, 32,118,101, 99, 51, 32, 78,111,114,109, 97,108, 44, 32,102,108,111, 97,116, 32,101,116, - 97, 41, 13, 10,123, 13, 10, 32, 32, 32, 32, 47, 42, 32, 99,111,109,112,117,116,101, 32,102,114,101,115,110,101,108, 32,114,101, -102,108,101, 99,116, 97,110, 99,101, 32,119,105,116,104,111,117,116, 32,101,120,112,108,105, 99,105,116,108,121, 32, 99,111,109, -112,117,116,105,110,103, 13, 10, 32, 32, 32, 32, 32, 32, 32,116,104,101, 32,114,101,102,114, 97, 99,116,101,100, 32,100,105,114, -101, 99,116,105,111,110, 32, 42, 47, 13, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, 99, 32, 61, 32, 97, 98,115, 40,100,111,116, - 40, 73,110, 99,111,109,105,110,103, 44, 32, 78,111,114,109, 97,108, 41, 41, 59, 13, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, -103, 32, 61, 32,101,116, 97, 32, 42, 32,101,116, 97, 32, 45, 32, 49, 46, 48, 32, 43, 32, 99, 32, 42, 32, 99, 59, 13, 10, 32, 32, - 32, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 59, 13, 10, 13, 10, 32, 32, 32, 32,105,102, 40,103, 32, 62, 32, 48, 46, - 48, 41, 32,123, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32,103, 32, 61, 32,115,113,114,116, 40,103, 41, 59, 13, 10, 32, 32, 32, 32, - 32, 32, 32, 32,102,108,111, 97,116, 32, 65, 32, 61, 40,103, 32, 45, 32, 99, 41, 47, 40,103, 32, 43, 32, 99, 41, 59, 13, 10, 32, - 32, 32, 32, 32, 32, 32, 32,102,108,111, 97,116, 32, 66, 32, 61, 40, 99, 32, 42, 40,103, 32, 43, 32, 99, 41, 45, 32, 49, 46, 48, - 41, 47, 40, 99, 32, 42, 40,103, 32, 45, 32, 99, 41, 43, 32, 49, 46, 48, 41, 59, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101, -115,117,108,116, 32, 61, 32, 48, 46, 53, 32, 42, 32, 65, 32, 42, 32, 65, 32, 42, 40, 49, 46, 48, 32, 43, 32, 66, 32, 42, 32, 66, - 41, 59, 13, 10, 32, 32, 32, 32,125, 13, 10, 32, 32, 32, 32,101,108,115,101, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,115, -117,108,116, 32, 61, 32, 49, 46, 48, 59, 32, 32, 47, 42, 32, 84, 73, 82, 32, 40,110,111, 32,114,101,102,114, 97, 99,116,101,100, - 32, 99,111,109,112,111,110,101,110,116, 41, 32, 42, 47, 13, 10, 13, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,114,101,115, -117,108,116, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,104,121,112,111,116, 40,102,108,111, 97,116, 32,120, 44, 32, -102,108,111, 97,116, 32,121, 41, 13, 10,123, 13, 10, 9,114,101,116,117,114,110, 32,115,113,114,116, 40,120, 42,120, 32, 43, 32, -121, 42,121, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 78, 69, 87, 32, 83, 72, 65, - 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10, 35,100, -101,102,105,110,101, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 32, 51, 13, 10, 13, 10, 47, 42, 32, 98,115,100,102,115, 32, 42, - 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40,118,101, 99, 52, - 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,118,101, 99, 51, 32, 78, 44, - 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9, 47, 42, 32, 97,109, 98,105,101,110, -116, 32,108,105,103,104,116, 32, 42, 47, 13, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 50, 41, 59, - 13, 10, 13, 10, 9, 47, 42, 32,100,105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, 32, 42, 47, 13, 10, 9, +102,108,111, 97,116, 32, 98,108,101,101,100, 98,105, 97,115, 44, 32,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32, +102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32, +123, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,118, +101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, + 32, 49, 46, 48, 41, 59, 10, 9, 9,105,102, 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 32, + 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32, 99,111, 46,121, + 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, 32,123, 10, 9, 9, 9, +118,101, 99, 50, 32,109,111,109,101,110,116,115, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40,115,104, 97, +100,111,119,109, 97,112, 44, 32, 99,111, 41, 46,114,103, 59, 10, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32, + 99,111, 46,122, 47, 99,111, 46,119, 59, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 9, + 10, 9, 9, 9,105,102, 40,100,105,115,116, 32, 60, 61, 32,109,111,109,101,110,116,115, 46,120, 41, 10, 9, 9, 9, 9,112, 32, + 61, 32, 49, 46, 48, 59, 10, 10, 9, 9, 9,102,108,111, 97,116, 32,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109,111,109,101, +110,116,115, 46,121, 32, 45, 32, 40,109,111,109,101,110,116,115, 46,120, 42,109,111,109,101,110,116,115, 46,120, 41, 59, 10, 9, + 9, 9,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109, 97,120, 40,118, 97,114,105, 97,110, 99,101, 44, 32,115,104, 97,100,111, +119, 98,105, 97,115, 47, 49, 48, 46, 48, 41, 59, 10, 10, 9, 9, 9,102,108,111, 97,116, 32,100, 32, 61, 32,109,111,109,101,110, +116,115, 46,120, 32, 45, 32,100,105,115,116, 59, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 95,109, 97,120, 32, 61, 32,118, 97, +114,105, 97,110, 99,101, 32, 47, 32, 40,118, 97,114,105, 97,110, 99,101, 32, 43, 32,100, 42,100, 41, 59, 10, 10, 9, 9, 9, 47, + 47, 32, 78,111,119, 32,114,101,100,117, 99,101, 32,108,105,103,104,116, 45, 98,108,101,101,100,105,110,103, 32, 98,121, 32,114, +101,109,111,118,105,110,103, 32,116,104,101, 32, 91, 48, 44, 32,120, 93, 32,116, 97,105,108, 32, 97,110,100, 32,108,105,110,101, + 97,114,108,121, 32,114,101,115, 99, 97,108,105,110,103, 32, 40,120, 44, 32, 49, 93, 10, 9, 9, 9,112, 95,109, 97,120, 32, 61, + 32, 99,108, 97,109,112, 40, 40,112, 95,109, 97,120, 45, 98,108,101,101,100, 98,105, 97,115, 41, 47, 40, 49, 46, 48, 45, 98,108, +101,101,100, 98,105, 97,115, 41, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 10, 9, 9, 9,114,101,115,117,108,116, 32, + 61, 32,109, 97,120, 40,112, 44, 32,112, 95,109, 97,120, 41, 59, 10, 9, 9,125, 10, 9, 9,101,108,115,101, 32,123, 10, 9, 9, + 9,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,125, 9, 9, 9, 10, 9,125, 10,125, 10, 10,118,111,105,100, + 32,115,104, 97,100,101, 95,108,105,103,104,116, 95,116,101,120,116,117,114,101, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, + 97,109,112,108,101,114, 50, 68, 32, 99,111,111,107,105,101, 44, 32,109, 97,116, 52, 32,115,104, 97,100,111,119,112,101,114,115, +109, 97,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 10, 9,118,101, 99, 52, 32, 99, +111, 32, 61, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, + 59, 10, 10, 9,114,101,115,117,108,116, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40, 99,111,111,107,105, +101, 44, 32, 99,111, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,101,120,112,111,115,117,114,101, 95, 99, +111,114,114,101, 99,116, 40,118,101, 99, 51, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32,108,105,110,102, 97, 99, 44, 32,102, +108,111, 97,116, 32,108,111,103,102, 97, 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 10,123, 10, + 9,111,117,116, 99,111,108, 32, 61, 32,108,105,110,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32,101,120,112, 40, 99,111,108, 42, +108,111,103,102, 97, 99, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,105,115,116, 95,102, 97, 99, +116,111,114, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,109,105,115,116,115,116, 97, 44, 32,102,108,111, 97, +116, 32,109,105,115,116,100,105,115,116, 44, 32,102,108,111, 97,116, 32,109,105,115,116,116,121,112,101, 44, 32,102,108,111, 97, +116, 32,109,105,115,105, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 10,123, 10, 9,102,108,111, + 97,116, 32,102, 97, 99, 44, 32,122, 99,111,114, 59, 10, 10, 9,122, 99,111,114, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, + 99,116,105,111,110, 77, 97,116,114,105,120, 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,108,101,110,103,116, +104, 40, 99,111, 41, 58, 32, 45, 99,111, 91, 50, 93, 59, 10, 9, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 40,122, + 99,111,114, 45,109,105,115,116,115,116, 97, 41, 47,109,105,115,116,100,105,115,116, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, + 59, 10, 9,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 48, 46, 48, 41, 32,102, 97, 99, 32, 42, 61, 32,102, 97, + 99, 59, 10, 9,101,108,115,101, 32,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 49, 46, 48, 41, 59, 10, 9,101, +108,115,101, 32,102, 97, 99, 32, 61, 32,115,113,114,116, 40,102, 97, 99, 41, 59, 10, 10, 9,111,117,116,102, 97, 99, 32, 61, 32, + 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 45,102, 97, 99, 41, 42, 40, 49, 46, 48, 45,109,105,115,105, 41, 59, 10,125, 10, 10,118, +111,105,100, 32,115,104, 97,100,101, 95,119,111,114,108,100, 95,109,105,120, 40,118,101, 99, 51, 32,104,111,114, 44, 32,118,101, + 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97, +116, 32,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 99,111,108, 46, 97, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, + 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,109,105,120, 40,104,111,114, 44, 32, 99,111,108, 46,114,103, 98, 44, + 32,102, 97, 99, 41, 44, 32, 99,111,108, 46, 97, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,108,112, +104, 97, 95,111,112, 97,113,117,101, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, + 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 49, + 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,108,112,104, 97, 95,111, 98, 99,111,108,111,114, + 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, + 44, 32, 99,111,108, 46, 97, 42,111, 98, 99,111,108, 46, 97, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 32, 78, 69, 87, 32, 83, 72, 65, 68, 69, 82, 32, 85, 84, 73, 76, 73, 84, 73, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 47, 10, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, 95,100,105,101,108,101, 99,116,114,105, 99, + 40,118,101, 99, 51, 32, 73,110, 99,111,109,105,110,103, 44, 32,118,101, 99, 51, 32, 78,111,114,109, 97,108, 44, 32,102,108,111, + 97,116, 32,101,116, 97, 41, 10,123, 10, 32, 32, 32, 32, 47, 42, 32, 99,111,109,112,117,116,101, 32,102,114,101,115,110,101,108, + 32,114,101,102,108,101, 99,116, 97,110, 99,101, 32,119,105,116,104,111,117,116, 32,101,120,112,108,105, 99,105,116,108,121, 32, + 99,111,109,112,117,116,105,110,103, 10, 32, 32, 32, 32, 32, 32, 32,116,104,101, 32,114,101,102,114, 97, 99,116,101,100, 32,100, +105,114,101, 99,116,105,111,110, 32, 42, 47, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, 99, 32, 61, 32, 97, 98,115, 40,100,111, +116, 40, 73,110, 99,111,109,105,110,103, 44, 32, 78,111,114,109, 97,108, 41, 41, 59, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, +103, 32, 61, 32,101,116, 97, 32, 42, 32,101,116, 97, 32, 45, 32, 49, 46, 48, 32, 43, 32, 99, 32, 42, 32, 99, 59, 10, 32, 32, 32, + 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 59, 10, 10, 32, 32, 32, 32,105,102, 40,103, 32, 62, 32, 48, 46, 48, 41, 32, +123, 10, 32, 32, 32, 32, 32, 32, 32, 32,103, 32, 61, 32,115,113,114,116, 40,103, 41, 59, 10, 32, 32, 32, 32, 32, 32, 32, 32,102, +108,111, 97,116, 32, 65, 32, 61, 40,103, 32, 45, 32, 99, 41, 47, 40,103, 32, 43, 32, 99, 41, 59, 10, 32, 32, 32, 32, 32, 32, 32, + 32,102,108,111, 97,116, 32, 66, 32, 61, 40, 99, 32, 42, 40,103, 32, 43, 32, 99, 41, 45, 32, 49, 46, 48, 41, 47, 40, 99, 32, 42, + 40,103, 32, 45, 32, 99, 41, 43, 32, 49, 46, 48, 41, 59, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,115,117,108,116, 32, 61, 32, + 48, 46, 53, 32, 42, 32, 65, 32, 42, 32, 65, 32, 42, 40, 49, 46, 48, 32, 43, 32, 66, 32, 42, 32, 66, 41, 59, 10, 32, 32, 32, 32, +125, 10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, + 32, 32, 47, 42, 32, 84, 73, 82, 32, 40,110,111, 32,114,101,102,114, 97, 99,116,101,100, 32, 99,111,109,112,111,110,101,110,116, + 41, 32, 42, 47, 10, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,114,101,115,117,108,116, 59, 10,125, 10, 10,102,108,111, 97, +116, 32,104,121,112,111,116, 40,102,108,111, 97,116, 32,120, 44, 32,102,108,111, 97,116, 32,121, 41, 10,123, 10, 9,114,101,116, +117,114,110, 32,115,113,114,116, 40,120, 42,120, 32, 43, 32,121, 42,121, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 32, 78, 69, 87, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 47, 10, 10, 35,100,101,102,105,110,101, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 32, 51, 10, 10, 47, 42, + 32, 98,115,100,102,115, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115, +101, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,118, +101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9, 47, 42, 32, 97,109, + 98,105,101,110,116, 32,108,105,103,104,116, 32, 42, 47, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, 99, 51, 40, 48, 46, + 50, 41, 59, 10, 10, 9, 47, 42, 32,100,105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, 32, 42, 47, 10, 9, 102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 59, 32,105, - 43, 43, 41, 32,123, 13, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 32, 61, 32,103, -108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 13, 10, - 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83, -111,117,114, 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, 46,114,103, 98, 59, 13, 10, 13, 10, 9, 9,102,108,111, 97,116, - 32, 98,115,100,102, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111, -110, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 42, - 98,115,100,102, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111, -108,111,114, 46,114,103, 98, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98, -115,100,102, 95,103,108,111,115,115,121, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117, -103,104,110,101,115,115, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, - 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9, 47, 42, 32, 97,109, 98,105,101,110,116, 32,108,105,103,104,116, 32, 42, - 47, 13, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 50, 41, 59, 13, 10, 13, 10, 9, 47, 42, 32,100, -105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, 32, 42, 47, 13, 10, 9,102,111,114, 40,105,110,116, 32,105, - 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 59, 32,105, 43, 43, 41, 32,123, 13, 10, 9, 9, -118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111, -117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 72, 32, - 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,104, 97,108,102, 86,101, 99,116,111,114, 46,120, -121,122, 59, 13, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 32, 61, 32,103,108, 95, 76, -105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, 46,114,103, 98, 59, 13, 10, 9, 9,118,101, - 99, 51, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, - 99,101, 91,105, 93, 46,115,112,101, 99,117,108, 97,114, 46,114,103, 98, 59, 13, 10, 13, 10, 9, 9, 47, 42, 32,119,101, 32,109, -105,120, 32,105,110, 32,115,111,109,101, 32,100,105,102,102,117,115,101, 32,115,111, 32,108,111,119, 32,114,111,117,103,104,110, -101,115,115, 32,115,116,105,108,108, 32,115,104,111,119,115, 32,117,112, 32, 42, 47, 13, 10, 9, 9,102,108,111, 97,116, 32, 98, -115,100,102, 32, 61, 32, 48, 46, 53, 42,112,111,119, 40,109, 97,120, 40,100,111,116, 40, 78, 44, 32, 72, 41, 44, 32, 48, 46, 48, - 41, 44, 32, 49, 46, 48, 47,114,111,117,103,104,110,101,115,115, 41, 59, 13, 10, 9, 9, 98,115,100,102, 32, 43, 61, 32, 48, 46, - 53, 42,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 41, 44, 32, 48, 46, - 48, 41, 59, 13, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 42, 98,115,100,102, 59, - 13, 10, 9,125, 13, 10, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111,108,111,114, 46,114, -103, 98, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95, 97, + 43, 43, 41, 32,123, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 32, 61, 32,103,108, + 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 10, 9, 9, +118,101, 99, 51, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117, +114, 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, 46,114,103, 98, 59, 10, 10, 9, 9,102,108,111, 97,116, 32, 98,115,100, +102, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 41, 44, 32, + 48, 46, 48, 41, 59, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 42, 98,115,100,102, 59, + 10, 9,125, 10, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111,108,111,114, 46,114,103, 98, 44, + 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,103,108,111,115,115,121, 40, +118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,118,101, 99, + 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, + 9, 47, 42, 32, 97,109, 98,105,101,110,116, 32,108,105,103,104,116, 32, 42, 47, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118, +101, 99, 51, 40, 48, 46, 50, 41, 59, 10, 10, 9, 47, 42, 32,100,105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116, +115, 32, 42, 47, 10, 9,102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, + 72, 84, 83, 59, 32,105, 43, 43, 41, 32,123, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111, +110, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120, +121,122, 59, 10, 9, 9,118,101, 99, 51, 32, 72, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, + 46,104, 97,108,102, 86,101, 99,116,111,114, 46,120,121,122, 59, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,100,105, +102,102,117,115,101, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,100,105,102,102,117,115, +101, 46,114,103, 98, 59, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 32, 61, 32,103, +108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,115,112,101, 99,117,108, 97,114, 46,114,103, 98, 59, 10, 10, + 9, 9, 47, 42, 32,119,101, 32,109,105,120, 32,105,110, 32,115,111,109,101, 32,100,105,102,102,117,115,101, 32,115,111, 32,108, +111,119, 32,114,111,117,103,104,110,101,115,115, 32,115,116,105,108,108, 32,115,104,111,119,115, 32,117,112, 32, 42, 47, 10, 9, + 9,102,108,111, 97,116, 32, 98,115,100,102, 32, 61, 32, 48, 46, 53, 42,112,111,119, 40,109, 97,120, 40,100,111,116, 40, 78, 44, + 32, 72, 41, 44, 32, 48, 46, 48, 41, 44, 32, 49, 46, 48, 47,114,111,117,103,104,110,101,115,115, 41, 59, 10, 9, 9, 98,115,100, +102, 32, 43, 61, 32, 48, 46, 53, 42,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105, +111,110, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, + 42, 98,115,100,102, 59, 10, 9,125, 10, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111,108,111, +114, 46,114,103, 98, 44, 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95, 97, 110,105,115,111,116,114,111,112,105, 99, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117, 103,104,110,101,115,115, 85, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 86, 44, 32,118,101, 99, 51, 32, - 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, - 9,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, - 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95, -103,108, 97,115,115, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115, -115, 44, 32,102,108,111, 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105, -102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,108,117, 99,101,110,116, 40,118, -101, 99, 52, 32, 99,111,108,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117, -108,116, 41, 13, 10,123, 13, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, - 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111, -100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,112, 97,114,101,110,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32, -111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9, 47, 42, 32,116,104,105,115, 32,105,115, -110, 39,116, 32,114,105,103,104,116, 32, 42, 47, 13, 10, 9,114,101,115,117,108,116, 46,114, 32, 61, 32, 99,111,108,111,114, 46, -114, 59, 13, 10, 9,114,101,115,117,108,116, 46,103, 32, 61, 32, 99,111,108,111,114, 46,103, 59, 13, 10, 9,114,101,115,117,108, -116, 46, 98, 32, 61, 32, 99,111,108,111,114, 46, 98, 59, 13, 10, 9,114,101,115,117,108,116, 46, 97, 32, 61, 32, 48, 46, 48, 59, - 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,118,101,108,118,101,116, 40,118,101, 99, - 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,105,103,109, 97, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105, -102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, - 13, 10, 13, 10, 47, 42, 32,101,109,105,115,115,105,111,110, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, -101,109,105,115,115,105,111,110, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,116,114,101,110, -103,116,104, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, - 13, 10, 9,114,101,115,117,108,116, 32, 61, 32, 99,111,108,111,114, 42,115,116,114,101,110,103,116,104, 59, 13, 10,125, 13, 10, - 13, 10, 47, 42, 32, 99,108,111,115,117,114,101,115, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,109,105, -120, 95,115,104, 97,100,101,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 49, - 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 41, - 13, 10,123, 13, 10, 9,115,104, 97,100,101,114, 32, 61, 32,109,105,120, 40,115,104, 97,100,101,114, 49, 44, 32,115,104, 97,100, -101,114, 50, 44, 32,102, 97, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 97,100,100, 95,115, -104, 97,100,101,114, 40,118,101, 99, 52, 32,115,104, 97,100,101,114, 49, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 50, - 44, 32,111,117,116, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 41, 13, 10,123, 13, 10, 9,115,104, 97,100,101,114, 32, 61, - 32,115,104, 97,100,101,114, 49, 32, 43, 32,115,104, 97,100,101,114, 50, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32,102,114,101, -115,110,101,108, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,102,114,101,115,110,101,108, 40,102,108,111, - 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,101,116, 97, 32, 61, 32,109, 97,120, 40,105, -111,114, 44, 32, 48, 46, 48, 48, 48, 48, 49, 41, 59, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,102,114,101,115,110,101,108, - 95,100,105,101,108,101, 99,116,114,105, 99, 40, 73, 44, 32, 78, 44, 32,101,116, 97, 41, 59, 32, 47, 47, 98, 97, 99,107,102, 97, - 99,105,110,103, 40, 41, 63, 32, 49, 46, 48, 47,101,116, 97, 58, 32,101,116, 97, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32, -103,101,111,109,101,116,114,121, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,103,101,111,109,101,116,114, -121, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, 32,116,111,119,111,114,108,100, 44, 13, - 10, 9,111,117,116, 32,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111, -114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,116, 97,110,103,101,110,116, 44, 13, 10, 9,111,117,116, 32,118,101, - 99, 51, 32,116,114,117,101, 95,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,109,105,110, -103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,112, 97,114, 97,109,101,116,114,105, 99, 44, 13, 10, 9,111,117,116, 32,102,108, -111, 97,116, 32, 98, 97, 99,107,102, 97, 99,105,110,103, 41, 13, 10,123, 13, 10, 9,112,111,115,105,116,105,111,110, 32, 61, 32, - 40,116,111,119,111,114,108,100, 42,118,101, 99, 52, 40, 73, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10, 9,110,111, -114,109, 97,108, 32, 61, 32, 78, 59, 13, 10, 9,116, 97,110,103,101,110,116, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, - 13, 10, 9,116,114,117,101, 95,110,111,114,109, 97,108, 32, 61, 32, 78, 59, 13, 10, 9,105,110, 99,111,109,105,110,103, 32, 61, - 32, 73, 59, 13, 10, 9,112, 97,114, 97,109,101,116,114,105, 99, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10, 9, - 98, 97, 99,107,102, 97, 99,105,110,103, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100, -101, 95,116,101,120, 95, 99,111,111,114,100, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, - 32,118,105,101,119,105,110,118,109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 13, 10, 9,118,101, - 99, 51, 32, 97,116,116,114, 95,111,114, 99,111, 44, 32,118,101, 99, 51, 32, 97,116,116,114, 95,117,118, 44, 13, 10, 9,111,117, -116, 32,118,101, 99, 51, 32,103,101,110,101,114, 97,116,101,100, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97, -108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 44, - 13, 10, 9,111,117,116, 32,118,101, 99, 51, 32, 99, 97,109,101,114, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32,119,105,110, -100,111,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,114,101,102,108,101, 99,116,105,111,110, 41, 13, 10,123, 13, 10, 9,103, -101,110,101,114, 97,116,101,100, 32, 61, 32, 97,116,116,114, 95,111,114, 99,111, 59, 13, 10, 9,110,111,114,109, 97,108, 32, 61, - 32,110,111,114,109, 97,108,105,122,101, 40, 40,111, 98,105,110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, - 42,118,101, 99, 52, 40, 78, 44, 32, 48, 46, 48, 41, 41, 41, 46,120,121,122, 41, 59, 13, 10, 9,117,118, 32, 61, 32, 97,116,116, -114, 95,117,118, 59, 13, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, 73, 59, 13, 10, 9, 99, 97,109,101,114, 97, 32, 61, 32, 73, - 59, 13, 10, 9,119,105,110,100,111,119, 32, 61, 32,103,108, 95, 70,114, 97,103, 67,111,111,114,100, 46,120,121,122, 59, 13, 10, - 9,114,101,102,108,101, 99,116,105,111,110, 32, 61, 32,114,101,102,108,101, 99,116, 40, 78, 44, 32, 73, 41, 59, 13, 10, 13, 10, -125, 13, 10, 13, 10, 47, 42, 32,116,101,120,116,117,114,101,115, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, - 95,116,101,120, 95,103,114, 97,100,105,101,110,116, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 52, 32, - 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, - 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,104,101, 99,107,101,114, 40,118,101, 99, 51, 32, 99,111, 44, 32, -118,101, 99, 52, 32, 99,111,108,111,114, 49, 44, 32,118,101, 99, 52, 32, 99,111,108,111,114, 50, 44, 32,102,108,111, 97,116, 32, -115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, - 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9, -102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99, -108,111,117,100,115, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,111,117,116, 32,118, -101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99, -111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,101,110,118,105,114,111,110,109,101,110,116, 40,118, -101, 99, 51, 32, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32, - 99,111,108,111,114, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,117, 32, 61, 32, 40, 97,116, 97,110, 40, 99,111, 46,121, - 44, 32, 99,111, 46,120, 41, 32, 43, 32, 77, 95, 80, 73, 41, 47, 40, 50, 46, 48, 42, 77, 95, 80, 73, 41, 59, 13, 10, 9,102,108, -111, 97,116, 32,118, 32, 61, 32, 97,116, 97,110, 40, 99,111, 46,122, 44, 32,104,121,112,111,116, 40, 99,111, 46,120, 44, 32, 99, -111, 46,121, 41, 41, 47, 77, 95, 80, 73, 32, 43, 32, 48, 46, 53, 59, 13, 10, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101, -120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,118,101, 99, 50, 40,117, 44, 32,118, 41, 41, 59, 13, 10,125, 13, 10, 13, 10, -118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,105,109, 97,103,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,115, 97,109, -112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32, 97,108,112,104, 97, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114, -101, 50, 68, 40,105,109, 97, 44, 32, 99,111, 46,120,121, 41, 59, 13, 10, 32, 32, 32, 32, 97,108,112,104, 97, 32, 61, 32, 99,111, -108,111,114, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,109, 97,103,105, 99, - 40,118,101, 99, 51, 32,112, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100,105,115,116, -111,114,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, - 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, -109,117,115,103,114, 97,118,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102, -108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,109,101,110,115,105,111,110, 44, 32,102,108, -111, 97,116, 32,108, 97, 99,117,110, 97,114,105,116,121, 44, 32,102,108,111, 97,116, 32,111,102,102,115,101,116, 44, 32,102,108, -111, 97,116, 32,103, 97,105,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108, -111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, - 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101, -120, 95,110,111,105,115,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108, -111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,115,116,111,114,116,105,111,110, 44, 32,111,117, -116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, - 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,115,107,121, 40,118,101, 99, 51, 32, 99, -111, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32, -118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,118, -111,114,111,110,111,105, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,111,117,116, - 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, - 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, - 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,119, 97,118,101, 40,118,101, 99, 51, 32, 99, -111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100,105,115,116,111,114,116,105,111,110, - 44, 32,102,108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,101,116, 97,105,108, 95,115, 99, 97, -108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, - 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, - 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32,108,105,103,104,116, 32,112, 97,116,104, 32, 42, 47, 13, 10, - 13, 10,118,111,105,100, 32,110,111,100,101, 95,108,105,103,104,116, 95,112, 97,116,104, 40, 13, 10, 9,111,117,116, 32,102,108, -111, 97,116, 32,105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105, -115, 95,115,104, 97,100,111,119, 95,114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,100,105,102, -102,117,115,101, 95,114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,103,108,111,115,115,121, 95, -114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,115,105,110,103,117,108, 97,114, 95,114, 97,121, - 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,114,101,102,108,101, 99,116,105,111,110, 95,114, 97,121, 44, - 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,116,114, 97,110,115,109,105,115,115,105,111,110, 95,114, 97,121, - 41, 13, 10,123, 13, 10, 9,105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,105,115, - 95,115,104, 97,100,111,119, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95,100,105,102,102,117,115,101, 95, -114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95,103,108,111,115,115,121, 95,114, 97,121, 32, 61, 32, 48, 46, 48, - 59, 13, 10, 9,105,115, 95,115,105,110,103,117,108, 97,114, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95, -114,101,102,108,101, 99,116,105,111,110, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95,116,114, 97,110,115, -109,105,115,115,105,111,110, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32,111,117,116,112, -117,116, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,111,117,116,112,117,116, 95,109, 97,116,101,114,105, - 97,108, 40,118,101, 99, 52, 32,115,117,114,102, 97, 99,101, 44, 32,118,101, 99, 52, 32,118,111,108,117,109,101, 44, 32,102,108, -111, 97,116, 32,100,105,115,112,108, 97, 99,101,109,101,110,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108, -116, 41, 13, 10,123, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,115,117,114,102, 97, 99,101, 59, 13, 10,125, 13, 10, 13, 10, + 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110, +111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32, +114,101,115,117,108,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,103,108, 97,115,115, + 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,102,108, +111, 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, + 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99, +111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110, +111,100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,108,117, 99,101,110,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, + 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111,100, +101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101, +115,117,108,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,112, 97, +114,101,110,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, + 41, 10,123, 10, 9, 47, 42, 32,116,104,105,115, 32,105,115,110, 39,116, 32,114,105,103,104,116, 32, 42, 47, 10, 9,114,101,115, +117,108,116, 46,114, 32, 61, 32, 99,111,108,111,114, 46,114, 59, 10, 9,114,101,115,117,108,116, 46,103, 32, 61, 32, 99,111,108, +111,114, 46,103, 59, 10, 9,114,101,115,117,108,116, 46, 98, 32, 61, 32, 99,111,108,111,114, 46, 98, 59, 10, 9,114,101,115,117, +108,116, 46, 97, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,118,101, +108,118,101,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,105,103,109, 97, 44, 32,118,101, + 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111,100,101, 95, 98, +115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108, +116, 41, 59, 10,125, 10, 10, 47, 42, 32,101,109,105,115,115,105,111,110, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, + 95,101,109,105,115,115,105,111,110, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,116,114,101, +110,103,116,104, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, + 10, 9,114,101,115,117,108,116, 32, 61, 32, 99,111,108,111,114, 42,115,116,114,101,110,103,116,104, 59, 10,125, 10, 10, 47, 42, + 32, 99,108,111,115,117,114,101,115, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,109,105,120, 95,115,104, 97,100, +101,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 49, 44, 32,118,101, 99, 52, + 32,115,104, 97,100,101,114, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 41, 10,123, 10, 9,115,104, + 97,100,101,114, 32, 61, 32,109,105,120, 40,115,104, 97,100,101,114, 49, 44, 32,115,104, 97,100,101,114, 50, 44, 32,102, 97, 99, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 97,100,100, 95,115,104, 97,100,101,114, 40,118,101, 99, 52, 32, +115,104, 97,100,101,114, 49, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +115,104, 97,100,101,114, 41, 10,123, 10, 9,115,104, 97,100,101,114, 32, 61, 32,115,104, 97,100,101,114, 49, 32, 43, 32,115,104, + 97,100,101,114, 50, 59, 10,125, 10, 10, 47, 42, 32,102,114,101,115,110,101,108, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111, +100,101, 95,102,114,101,115,110,101,108, 40,102,108,111, 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, + 99, 51, 32, 73, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,102,108,111, 97,116, + 32,101,116, 97, 32, 61, 32,109, 97,120, 40,105,111,114, 44, 32, 48, 46, 48, 48, 48, 48, 49, 41, 59, 10, 9,114,101,115,117,108, +116, 32, 61, 32,102,114,101,115,110,101,108, 95,100,105,101,108,101, 99,116,114,105, 99, 40, 73, 44, 32, 78, 44, 32,101,116, 97, + 41, 59, 32, 47, 47, 98, 97, 99,107,102, 97, 99,105,110,103, 40, 41, 63, 32, 49, 46, 48, 47,101,116, 97, 58, 32,101,116, 97, 41, + 59, 10,125, 10, 10, 47, 42, 32,103,101,111,109,101,116,114,121, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,103, +101,111,109,101,116,114,121, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, 32,116,111,119, +111,114,108,100, 44, 10, 9,111,117,116, 32,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,111,117,116, 32,118,101, + 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,116, 97,110,103,101,110,116, 44, 10, 9,111,117, +116, 32,118,101, 99, 51, 32,116,114,117,101, 95,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99, +111,109,105,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,112, 97,114, 97,109,101,116,114,105, 99, 44, 10, 9,111,117,116, + 32,102,108,111, 97,116, 32, 98, 97, 99,107,102, 97, 99,105,110,103, 41, 10,123, 10, 9,112,111,115,105,116,105,111,110, 32, 61, + 32, 40,116,111,119,111,114,108,100, 42,118,101, 99, 52, 40, 73, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 10, 9,110,111, +114,109, 97,108, 32, 61, 32, 78, 59, 10, 9,116, 97,110,103,101,110,116, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 10, + 9,116,114,117,101, 95,110,111,114,109, 97,108, 32, 61, 32, 78, 59, 10, 9,105,110, 99,111,109,105,110,103, 32, 61, 32, 73, 59, + 10, 9,112, 97,114, 97,109,101,116,114,105, 99, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 10, 9, 98, 97, 99,107,102, + 97, 99,105,110,103, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,111, +111,114,100, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, 32,118,105,101,119,105,110,118, +109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 10, 9,118,101, 99, 51, 32, 97,116,116,114, 95,111, +114, 99,111, 44, 32,118,101, 99, 51, 32, 97,116,116,114, 95,117,118, 44, 10, 9,111,117,116, 32,118,101, 99, 51, 32,103,101,110, +101,114, 97,116,101,100, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 44, 10, 9,111,117,116, 32,118,101, 99, 51, + 32, 99, 97,109,101,114, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32,119,105,110,100,111,119, 44, 32,111,117,116, 32,118,101, + 99, 51, 32,114,101,102,108,101, 99,116,105,111,110, 41, 10,123, 10, 9,103,101,110,101,114, 97,116,101,100, 32, 61, 32, 97,116, +116,114, 95,111,114, 99,111, 59, 10, 9,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 40,111, 98, +105,110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 78, 44, 32, 48, 46, 48, 41, 41, + 41, 46,120,121,122, 41, 59, 10, 9,117,118, 32, 61, 32, 97,116,116,114, 95,117,118, 59, 10, 9,111, 98,106,101, 99,116, 32, 61, + 32, 73, 59, 10, 9, 99, 97,109,101,114, 97, 32, 61, 32, 73, 59, 10, 9,119,105,110,100,111,119, 32, 61, 32,103,108, 95, 70,114, + 97,103, 67,111,111,114,100, 46,120,121,122, 59, 10, 9,114,101,102,108,101, 99,116,105,111,110, 32, 61, 32,114,101,102,108,101, + 99,116, 40, 78, 44, 32, 73, 41, 59, 10, 10,125, 10, 10, 47, 42, 32,116,101,120,116,117,114,101,115, 32, 42, 47, 10, 10,118,111, +105,100, 32,110,111,100,101, 95,116,101,120, 95,103,114, 97,100,105,101,110,116, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117, +116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, + 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, + 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,104,101, 99,107,101,114, 40,118,101, 99, 51, 32, 99,111, 44, + 32,118,101, 99, 52, 32, 99,111,108,111,114, 49, 44, 32,118,101, 99, 52, 32, 99,111,108,111,114, 50, 44, 32,102,108,111, 97,116, + 32,115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, + 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,108,111,117,100,115, + 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99, +111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32, +118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110, +111,100,101, 95,116,101,120, 95,101,110,118,105,114,111,110,109,101,110,116, 40,118,101, 99, 51, 32, 99,111, 44, 32,115, 97,109, +112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 10,123, 10, 9,102, +108,111, 97,116, 32,117, 32, 61, 32, 40, 97,116, 97,110, 40, 99,111, 46,121, 44, 32, 99,111, 46,120, 41, 32, 43, 32, 77, 95, 80, + 73, 41, 47, 40, 50, 46, 48, 42, 77, 95, 80, 73, 41, 59, 10, 9,102,108,111, 97,116, 32,118, 32, 61, 32, 97,116, 97,110, 40, 99, +111, 46,122, 44, 32,104,121,112,111,116, 40, 99,111, 46,120, 44, 32, 99,111, 46,121, 41, 41, 47, 77, 95, 80, 73, 32, 43, 32, 48, + 46, 53, 59, 10, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,118,101, 99, + 50, 40,117, 44, 32,118, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,105,109, 97,103,101, + 40,118,101, 99, 51, 32, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, + 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 41, 10,123, 10, 9, 99,111,108, +111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 99,111, 46,120,121, 41, 59, 10, 32, 32, 32, 32, + 97,108,112,104, 97, 32, 61, 32, 99,111,108,111,114, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101, +120, 95,109, 97,103,105, 99, 40,118,101, 99, 51, 32,112, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, + 97,116, 32,100,105,115,116,111,114,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, + 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, + 95,109,117,115,103,114, 97,118,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32, +102,108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,109,101,110,115,105,111,110, 44, 32,102, +108,111, 97,116, 32,108, 97, 99,117,110, 97,114,105,116,121, 44, 32,102,108,111, 97,116, 32,111,102,102,115,101,116, 44, 32,102, +108,111, 97,116, 32,103, 97,105,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102, +108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, + 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,110,111,105, +115,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100, +101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,115,116,111,114,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, + 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, + 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105, +100, 32,110,111,100,101, 95,116,101,120, 95,115,107,121, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 52, + 32, 99,111,108,111,114, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10,125, 10, + 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,118,111,114,111,110,111,105, 40,118,101, 99, 51, 32, 99,111, 44, 32, +102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, + 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,119, + 97,118,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32, +100,105,115,116,111,114,116,105,111,110, 44, 32,102,108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32, +100,101,116, 97,105,108, 95,115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, + 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10, 47, 42, 32,108,105,103,104,116, 32,112, 97,116,104, 32, + 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,108,105,103,104,116, 95,112, 97,116,104, 40, 10, 9,111,117,116, 32,102, +108,111, 97,116, 32,105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105, +115, 95,115,104, 97,100,111,119, 95,114, 97,121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,100,105,102,102, +117,115,101, 95,114, 97,121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,103,108,111,115,115,121, 95,114, 97, +121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,115,105,110,103,117,108, 97,114, 95,114, 97,121, 44, 10, 9, +111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,114,101,102,108,101, 99,116,105,111,110, 95,114, 97,121, 44, 10, 9,111,117, +116, 32,102,108,111, 97,116, 32,105,115, 95,116,114, 97,110,115,109,105,115,115,105,111,110, 95,114, 97,121, 41, 10,123, 10, 9, +105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 32, 61, 32, 49, 46, 48, 59, 10, 9,105,115, 95,115,104, 97,100,111,119, 95, +114, 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,100,105,102,102,117,115,101, 95,114, 97,121, 32, 61, 32, 48, 46, 48, + 59, 10, 9,105,115, 95,103,108,111,115,115,121, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,115,105,110,103, +117,108, 97,114, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,114,101,102,108,101, 99,116,105,111,110, 95,114, + 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,116,114, 97,110,115,109,105,115,115,105,111,110, 95,114, 97,121, 32, 61, + 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,108,105,103,104,116, 95,102, 97,108,108,111,102,102, + 40,102,108,111, 97,116, 32,115,116,114,101,110,103,116,104, 44, 32,102,108,111, 97,116, 32,115,109,111,111,116,104, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,113,117, 97,100,114, 97,116,105, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,108,105, +110,101, 97,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 99,111,110,115,116, 97,110,116, 41, 10,123, 10, 9,113,117, 97, +100,114, 97,116,105, 99, 32, 61, 32,115,116,114,101,110,103,116,104, 59, 10, 9,108,105,110,101, 97,114, 32, 61, 32,115,116,114, +101,110,103,116,104, 59, 10, 9, 99,111,110,115,116, 97,110,116, 32, 61, 32,115,116,114,101,110,103,116,104, 59, 10,125, 10, 10, + 47, 42, 32,111,117,116,112,117,116, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,111,117,116,112,117,116, 95,109, + 97,116,101,114,105, 97,108, 40,118,101, 99, 52, 32,115,117,114,102, 97, 99,101, 44, 32,118,101, 99, 52, 32,118,111,108,117,109, +101, 44, 32,102,108,111, 97,116, 32,100,105,115,112,108, 97, 99,101,109,101,110,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +114,101,115,117,108,116, 41, 10,123, 10, 9,114,101,115,117,108,116, 32, 61, 32,115,117,114,102, 97, 99,101, 59, 10,125, 10, 10, 0}; diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 5352bbd0e0f..d7e55ae27df 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -77,7 +77,8 @@ DefNode( ShaderNode, SH_NODE_VOLUME_TRANSPARENT, 0, "VO DefNode( ShaderNode, SH_NODE_VOLUME_ISOTROPIC, 0, "VOLUME_ISOTROPIC", VolumeIsotropic, "Isotropic Volume", "" ) DefNode( ShaderNode, SH_NODE_EMISSION, 0, "EMISSION", Emission, "Emission", "" ) DefNode( ShaderNode, SH_NODE_NEW_GEOMETRY, 0, "NEW_GEOMETRY", NewGeometry, "Geometry", "" ) -DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", Light_path, "Light Path", "" ) +DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", LightPath, "Light Path", "" ) +DefNode( ShaderNode, SH_NODE_LIGHT_FALLOFF, 0, "LIGHT_FALLOFF", LightFalloff, "Light Falloff", "" ) DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture","" ) DefNode( ShaderNode, SH_NODE_TEX_SKY, def_sh_tex_sky, "TEX_SKY", TexSky, "Sky Texture", "" ) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 9bcbc91265c..be9dd10b71d 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -149,6 +149,7 @@ set(SRC shader/nodes/node_shader_volume_transparent.c shader/nodes/node_shader_volume_isotropic.c shader/nodes/node_shader_light_path.c + shader/nodes/node_shader_light_falloff.c shader/nodes/node_shader_mix_shader.c shader/nodes/node_shader_add_shader.c shader/nodes/node_shader_output_lamp.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index d2b3a61971b..3d93f41cfe5 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -73,6 +73,7 @@ void register_node_type_sh_hue_sat(struct bNodeTreeType *ttype); void register_node_type_sh_attribute(struct bNodeTreeType *ttype); void register_node_type_sh_geometry(struct bNodeTreeType *ttype); void register_node_type_sh_light_path(struct bNodeTreeType *ttype); +void register_node_type_sh_light_falloff(struct bNodeTreeType *ttype); void register_node_type_sh_fresnel(struct bNodeTreeType *ttype); void register_node_type_sh_layer_weight(struct bNodeTreeType *ttype); void register_node_type_sh_tex_coord(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c new file mode 100644 index 00000000000..8ee0f0adef6 --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c @@ -0,0 +1,68 @@ +/* + * ***** 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) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../node_shader_util.h" + +/* **************** INPUT ********************* */ + +static bNodeSocketTemplate sh_node_light_falloff_in[]= { + { SOCK_FLOAT, 0, "Strength", 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Smooth", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +/* **************** OUTPUT ******************** */ + +static bNodeSocketTemplate sh_node_light_falloff_out[]= { + { SOCK_FLOAT, 0, "Quadratic", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Linear", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Constant", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static int node_shader_gpu_light_falloff(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) +{ + return GPU_stack_link(mat, "node_light_falloff", in, out); +} + +/* node type definition */ +void register_node_type_sh_light_falloff(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_light_falloff_in, sh_node_light_falloff_out); + node_type_size(&ntype, 150, 60, 200); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_exec(&ntype, NULL); + node_type_gpu(&ntype, node_shader_gpu_light_falloff); + + nodeRegisterType(ttype, &ntype); +} + From 5797edfcf23060fa2b506292e0af970276554c0b Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 7 May 2012 20:37:48 +0000 Subject: [PATCH 139/143] adding kernel_projection.h in CMakelists --- intern/cycles/kernel/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index e9820010b63..d165716aaca 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -33,6 +33,7 @@ set(SRC_HEADERS kernel_object.h kernel_passes.h kernel_path.h + kernel_projection.h kernel_qbvh.h kernel_random.h kernel_shader.h From 243304a6231cf86da9d21097c6dd3bfe05acf1f4 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Tue, 8 May 2012 05:04:29 +0000 Subject: [PATCH 140/143] ndof: restored support for older serial port 3D mice on Linux (R45951 broke it, oops) --- intern/ghost/intern/GHOST_NDOFManagerX11.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp index 1e78cafd4f6..565324ae211 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp @@ -37,6 +37,8 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys) setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */ if (spnav_open() != -1) { + m_available = true; + /* determine exactly which device (if any) is plugged in */ #define MAX_LINE_LENGTH 100 @@ -49,7 +51,6 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys) unsigned short vendor_id = 0, product_id = 0; if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) if (setDevice(vendor_id, product_id)) { - m_available = true; break; /* stop looking once the first 3D mouse is found */ } } From 673e26196f3076dd0d04cf4e619e259195e587f1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 8 May 2012 07:31:02 +0000 Subject: [PATCH 141/143] Fix #31344: MovieClip python custom properties are reset when reopen the file --- source/blender/blenloader/intern/writefile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index dcae11ff2e1..91ce94ae6ed 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2696,6 +2696,9 @@ static void write_movieclips(WriteData *wd, ListBase *idbase) MovieTrackingObject *object; writestruct(wd, ID_MC, "MovieClip", 1, clip); + if (clip->id.properties) + IDP_WriteProperty(clip->id.properties, wd); + if (clip->adt) write_animdata(wd, clip->adt); From 670916dbffc617a3ee6d9d637ae39a162510e6c0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 8 May 2012 09:10:58 +0000 Subject: [PATCH 142/143] Fix #31332: VSE drag and drop onto timeline buggy --- source/blender/editors/space_sequencer/sequencer_add.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 4bc08242020..6aa8d28bce2 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -412,7 +412,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) deselect_all_seq(scene); - tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + if (RNA_struct_property_is_set(op->ptr, "files")) + tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + else + tot_files = 0; if (tot_files) { /* multiple files */ From 7a4ad3aaaeee044c0768ce1206230a0dd723bb9e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 May 2012 09:31:25 +0000 Subject: [PATCH 143/143] style cleanup: seqeffects --- source/blender/blenkernel/intern/seqeffects.c | 2461 ++++++++--------- 1 file changed, 1225 insertions(+), 1236 deletions(-) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 5983beac4ef..f3a68d36384 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -58,27 +58,27 @@ #include "RNA_access.h" /* **** XXX **** */ -static void error(const char *UNUSED(error), ...) {} +static void error(const char *UNUSED(error), ...) { +} -#define INT 96 -#define FLO 128 +#define INT 96 +#define FLO 128 /* **** XXX **** */ /* Glow effect */ enum { - GlowR=0, - GlowG=1, - GlowB=2, - GlowA=3 + GlowR = 0, + GlowG = 1, + GlowB = 2, + GlowA = 3 }; -static struct ImBuf * prepare_effect_imbufs( - SeqRenderData context, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out; +static struct ImBuf *prepare_effect_imbufs( + SeqRenderData context, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out; int x = context.rectx; int y = context.recty; @@ -87,8 +87,9 @@ static struct ImBuf * prepare_effect_imbufs( out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect); } else if ((ibuf1 && ibuf1->rect_float) || - (ibuf2 && ibuf2->rect_float) || - (ibuf3 && ibuf3->rect_float)) { + (ibuf2 && ibuf2->rect_float) || + (ibuf3 && ibuf3->rect_float)) + { /* if any inputs are rectfloat, output is float too */ out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat); @@ -127,15 +128,15 @@ static struct ImBuf * prepare_effect_imbufs( static void open_plugin_seq(PluginSeq *pis, const char *seqname) { int (*version)(void); - void* (*alloc_private)(void); + void * (*alloc_private)(void); char *cp; /* to be sure: (is tested for) */ - pis->doit= NULL; - pis->pname= NULL; - pis->varstr= NULL; - pis->cfra= NULL; - pis->version= 0; + pis->doit = NULL; + pis->pname = NULL; + pis->varstr = NULL; + pis->cfra = NULL; + pis->version = 0; pis->instance_private_data = NULL; /* clear the error list */ @@ -145,55 +146,54 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) /* pis->handle= 0; */ /* open the needed object */ - pis->handle= BLI_dynlib_open(pis->name); + pis->handle = BLI_dynlib_open(pis->name); if (test_dlerr(pis->name, pis->name)) return; if (pis->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); + version = (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); if (test_dlerr(pis->name, "plugin_seq_getversion")) return; if (version != NULL) { - pis->version= version(); + pis->version = version(); if (pis->version >= 2 && pis->version <= 6) { int (*info_func)(PluginInfo *); - PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); + PluginInfo *info = (PluginInfo *) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo"); + info_func = (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo"); if (info_func == NULL) error("No info func"); else { info_func(info); - pis->pname= info->name; - pis->vars= info->nvars; - pis->cfra= info->cfra; + pis->pname = info->name; + pis->vars = info->nvars; + pis->cfra = info->cfra; - pis->varstr= info->varstr; + pis->varstr = info->varstr; - pis->doit= (void(*)(void))info->seq_doit; + pis->doit = (void (*)(void))info->seq_doit; if (info->init) info->init(); } MEM_freeN(info); - cp= BLI_dynlib_find_symbol(pis->handle, "seqname"); + cp = BLI_dynlib_find_symbol(pis->handle, "seqname"); if (cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR); } else { - printf ("Plugin returned unrecognized version number\n"); + printf("Plugin returned unrecognized version number\n"); return; } } - alloc_private = (void* (*)(void))BLI_dynlib_find_symbol( - pis->handle, "plugin_seq_alloc_private_data"); + alloc_private = (void * (*)(void))BLI_dynlib_find_symbol( + pis->handle, "plugin_seq_alloc_private_data"); if (alloc_private) { pis->instance_private_data = alloc_private(); } - pis->current_private_data = (void**) - BLI_dynlib_find_symbol( - pis->handle, "plugin_private_data"); + pis->current_private_data = (void **) + BLI_dynlib_find_symbol(pis->handle, "plugin_private_data"); } } @@ -203,25 +203,25 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname) VarStruct *varstr; int a; - pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq"); + pis = MEM_callocN(sizeof(PluginSeq), "PluginSeq"); BLI_strncpy(pis->name, str, FILE_MAX); open_plugin_seq(pis, seqname); - if (pis->doit==NULL) { - if (pis->handle==NULL) error("no plugin: %s", str); + if (pis->doit == NULL) { + if (pis->handle == NULL) error("no plugin: %s", str); else error("in plugin: %s", str); MEM_freeN(pis); return NULL; } /* default values */ - varstr= pis->varstr; - for (a=0; avars; a++, varstr++) { - if ( (varstr->type & FLO)==FLO) - pis->data[a]= varstr->def; - else if ( (varstr->type & INT)==INT) - *((int *)(pis->data+a))= (int) varstr->def; + varstr = pis->varstr; + for (a = 0; a < pis->vars; a++, varstr++) { + if ( (varstr->type & FLO) == FLO) + pis->data[a] = varstr->def; + else if ( (varstr->type & INT) == INT) + *((int *)(pis->data + a)) = (int) varstr->def; } return pis; @@ -229,7 +229,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname) static void free_plugin_seq(PluginSeq *pis) { - if (pis==NULL) return; + if (pis == NULL) return; /* no BLI_dynlib_close: same plugin can be opened multiple times with 1 handle */ @@ -237,7 +237,7 @@ static void free_plugin_seq(PluginSeq *pis) void (*free_private)(void *); free_private = (void (*)(void *))BLI_dynlib_find_symbol( - pis->handle, "plugin_seq_free_private_data"); + pis->handle, "plugin_seq_free_private_data"); if (free_private) { free_private(pis->instance_private_data); } @@ -246,9 +246,9 @@ static void free_plugin_seq(PluginSeq *pis) MEM_freeN(pis); } -static void init_plugin(Sequence * seq, const char * fname) +static void init_plugin(Sequence *seq, const char *fname) { - seq->plugin= (PluginSeq *)add_plugin_seq(fname, seq->name+2); + seq->plugin = (PluginSeq *)add_plugin_seq(fname, seq->name + 2); } /* @@ -259,34 +259,34 @@ static int num_inputs_plugin(void) return 1; } -static void load_plugin(Sequence * seq) +static void load_plugin(Sequence *seq) { if (seq) { - open_plugin_seq(seq->plugin, seq->name+2); + open_plugin_seq(seq->plugin, seq->name + 2); } } -static void copy_plugin(Sequence * dst, Sequence * src) +static void copy_plugin(Sequence *dst, Sequence *src) { if (src->plugin) { - dst->plugin= MEM_dupallocN(src->plugin); - open_plugin_seq(dst->plugin, dst->name+2); + dst->plugin = MEM_dupallocN(src->plugin); + open_plugin_seq(dst->plugin, dst->name + 2); } } -static ImBuf * IMB_cast_away_list(ImBuf * i) +static ImBuf *IMB_cast_away_list(ImBuf *i) { if (!i) { return NULL; } - return (ImBuf*) (((void**) i) + 2); + return (ImBuf *) (((void **) i) + 2); } -static struct ImBuf * do_plugin_effect( - SeqRenderData context, Sequence *seq, float cfra, - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_plugin_effect( + SeqRenderData context, Sequence *seq, float cfra, + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { char *cp; int float_rendering; @@ -294,31 +294,31 @@ static struct ImBuf * do_plugin_effect( * old plugins) do very bad stuff * with imbuf-internals */ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; if (seq->plugin && seq->plugin->doit) { if (seq->plugin->cfra) - *(seq->plugin->cfra)= cfra; + *(seq->plugin->cfra) = cfra; cp = BLI_dynlib_find_symbol( - seq->plugin->handle, "seqname"); + seq->plugin->handle, "seqname"); /* XXX: it's crappy to limit copying buffer by it's lemgth, * but assuming plugin stuff is using correct buffer size * it should be fine */ - if (cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2); + if (cp) strncpy(cp, seq->name + 2, sizeof(seq->name) - 2); if (seq->plugin->current_private_data) { *seq->plugin->current_private_data - = seq->plugin->instance_private_data; + = seq->plugin->instance_private_data; } float_rendering = (out->rect_float != NULL); - if (seq->plugin->version<=3 && float_rendering) { + if (seq->plugin->version <= 3 && float_rendering) { use_temp_bufs = 1; if (ibuf1) { @@ -344,27 +344,27 @@ static struct ImBuf * do_plugin_effect( out->flags &= ~IB_rectfloat; } - if (seq->plugin->version<=2) { + if (seq->plugin->version <= 2) { if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1); if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2); if (ibuf3) IMB_convert_rgba_to_abgr(ibuf3); } - if (seq->plugin->version<=4) { + if (seq->plugin->version <= 4) { ((SeqDoit)seq->plugin->doit)( - seq->plugin->data, facf0, facf1, x, y, - IMB_cast_away_list(ibuf1), - IMB_cast_away_list(ibuf2), - IMB_cast_away_list(out), - IMB_cast_away_list(ibuf3)); + seq->plugin->data, facf0, facf1, x, y, + IMB_cast_away_list(ibuf1), + IMB_cast_away_list(ibuf2), + IMB_cast_away_list(out), + IMB_cast_away_list(ibuf3)); } else { ((SeqDoit)seq->plugin->doit)( - seq->plugin->data, facf0, facf1, x, y, - ibuf1, ibuf2, out, ibuf3); + seq->plugin->data, facf0, facf1, x, y, + ibuf1, ibuf2, out, ibuf3); } - if (seq->plugin->version<=2) { + if (seq->plugin->version <= 2) { if (!use_temp_bufs) { if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1); if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2); @@ -372,7 +372,7 @@ static struct ImBuf * do_plugin_effect( } IMB_convert_rgba_to_abgr(out); } - if (seq->plugin->version<=3 && float_rendering) { + if (seq->plugin->version <= 3 && float_rendering) { IMB_float_from_rect_simple(out); } @@ -386,12 +386,12 @@ static struct ImBuf * do_plugin_effect( } static int do_plugin_early_out(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return 0; } -static void free_plugin(struct Sequence * seq) +static void free_plugin(struct Sequence *seq) { free_plugin_seq(seq->plugin); seq->plugin = NULL; @@ -401,129 +401,129 @@ static void free_plugin(struct Sequence * seq) * ALPHA OVER * ********************************************************************** */ -static void init_alpha_over_or_under(Sequence * seq) +static void init_alpha_over_or_under(Sequence *seq) { - Sequence * seq1 = seq->seq1; - Sequence * seq2 = seq->seq2; + Sequence *seq1 = seq->seq1; + Sequence *seq2 = seq->seq2; - seq->seq2= seq1; - seq->seq1= seq2; + seq->seq2 = seq1; + seq->seq1 = seq2; } static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, - char * rect1, char *rect2, char *out) + char *rect1, char *rect2, char *out) { int fac2, mfac, fac, fac4; int xo, tempc; char *rt1, *rt2, *rt; - xo= x; - rt1= (char *)rect1; - rt2= (char *)rect2; - rt= (char *)out; + xo = x; + rt1 = (char *)rect1; + rt2 = (char *)rect2; + rt = (char *)out; - fac2= (int)(256.0f*facf0); - fac4= (int)(256.0f*facf1); + fac2 = (int)(256.0f * facf0); + fac4 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 over rt2 (alpha from rt1) */ - fac= fac2; - mfac= 256 - ( (fac2*rt1[3])>>8 ); + fac = fac2; + mfac = 256 - ( (fac2 * rt1[3]) >> 8); - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); - else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + else if (mfac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); else { - tempc= ( fac*rt1[0] + mfac*rt2[0])>>8; - if (tempc>255) rt[0]= 255; else rt[0]= tempc; - tempc= ( fac*rt1[1] + mfac*rt2[1])>>8; - if (tempc>255) rt[1]= 255; else rt[1]= tempc; - tempc= ( fac*rt1[2] + mfac*rt2[2])>>8; - if (tempc>255) rt[2]= 255; else rt[2]= tempc; - tempc= ( fac*rt1[3] + mfac*rt2[3])>>8; - if (tempc>255) rt[3]= 255; else rt[3]= tempc; + tempc = (fac * rt1[0] + mfac * rt2[0]) >> 8; + if (tempc > 255) rt[0] = 255; else rt[0] = tempc; + tempc = (fac * rt1[1] + mfac * rt2[1]) >> 8; + if (tempc > 255) rt[1] = 255; else rt[1] = tempc; + tempc = (fac * rt1[2] + mfac * rt2[2]) >> 8; + if (tempc > 255) rt[2] = 255; else rt[2] = tempc; + tempc = (fac * rt1[3] + mfac * rt2[3]) >> 8; + if (tempc > 255) rt[3] = 255; else rt[3] = tempc; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - fac= fac4; - mfac= 256 - ( (fac4*rt1[3])>>8 ); + fac = fac4; + mfac = 256 - ( (fac4 * rt1[3]) >> 8); - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); - else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + else if (mfac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); else { - tempc= ( fac*rt1[0] + mfac*rt2[0])>>8; - if (tempc>255) rt[0]= 255; else rt[0]= tempc; - tempc= ( fac*rt1[1] + mfac*rt2[1])>>8; - if (tempc>255) rt[1]= 255; else rt[1]= tempc; - tempc= ( fac*rt1[2] + mfac*rt2[2])>>8; - if (tempc>255) rt[2]= 255; else rt[2]= tempc; - tempc= ( fac*rt1[3] + mfac*rt2[3])>>8; - if (tempc>255) rt[3]= 255; else rt[3]= tempc; + tempc = (fac * rt1[0] + mfac * rt2[0]) >> 8; + if (tempc > 255) rt[0] = 255; else rt[0] = tempc; + tempc = (fac * rt1[1] + mfac * rt2[1]) >> 8; + if (tempc > 255) rt[1] = 255; else rt[1] = tempc; + tempc = (fac * rt1[2] + mfac * rt2[2]) >> 8; + if (tempc > 255) rt[2] = 255; else rt[2] = tempc; + tempc = (fac * rt1[3] + mfac * rt2[3]) >> 8; + if (tempc > 255) rt[3] = 255; else rt[3] = tempc; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, - float * rect1, float *rect2, float *out) + float *rect1, float *rect2, float *out) { float fac2, mfac, fac, fac4; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac4= facf1; + fac2 = facf0; + fac4 = facf1; while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 over rt2 (alpha from rt1) */ - fac= fac2; - mfac= 1.0f - (fac2 * rt1[3]); + fac = fac2; + mfac = 1.0f - (fac2 * rt1[3]); if (fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } - else if (mfac <=0) { + else if (mfac <= 0) { memcpy(rt, rt1, 4 * sizeof(float)); } else { - rt[0] = fac*rt1[0] + mfac*rt2[0]; - rt[1] = fac*rt1[1] + mfac*rt2[1]; - rt[2] = fac*rt1[2] + mfac*rt2[2]; - rt[3] = fac*rt1[3] + mfac*rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - fac= fac4; - mfac= 1.0f - (fac4*rt1[3]); + fac = fac4; + mfac = 1.0f - (fac4 * rt1[3]); if (fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); @@ -532,35 +532,35 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, memcpy(rt, rt1, 4 * sizeof(float)); } else { - rt[0] = fac*rt1[0] + mfac*rt2[0]; - rt[1] = fac*rt1[1] + mfac*rt2[1]; - rt[2] = fac*rt1[2] + mfac*rt2[2]; - rt[3] = fac*rt1[3] + mfac*rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } -static struct ImBuf * do_alphaover_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_alphaover_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaover_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_alphaover_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -571,24 +571,24 @@ static struct ImBuf * do_alphaover_effect( * ********************************************************************** */ static void do_alphaunder_effect_byte( - float facf0, float facf1, int x, int y, char *rect1, - char *rect2, char *out) + float facf0, float facf1, int x, int y, char *rect1, + char *rect2, char *out) { int fac2, mfac, fac, fac4; int xo; char *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= (int)(256.0f*facf0); - fac4= (int)(256.0f*facf1); + fac2 = (int)(256.0f * facf0); + fac4 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 under rt2 (alpha from rt2) */ @@ -596,68 +596,68 @@ static void do_alphaunder_effect_byte( /* this complex optimalisation is because the * 'skybuf' can be crossed in */ - if (rt2[3]==0 && fac2==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); - else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (rt2[3] == 0 && fac2 == 256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + else if (rt2[3] == 255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - mfac= rt2[3]; - fac= (fac2*(256-mfac))>>8; + mfac = rt2[3]; + fac = (fac2 * (256 - mfac)) >> 8; - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8; - rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8; - rt[2]= ( fac*rt1[2] + mfac*rt2[2])>>8; - rt[3]= ( fac*rt1[3] + mfac*rt2[3])>>8; + rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8; + rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8; + rt[2] = (fac * rt1[2] + mfac * rt2[2]) >> 8; + rt[3] = (fac * rt1[3] + mfac * rt2[3]) >> 8; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - if (rt2[3]==0 && fac4==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); - else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (rt2[3] == 0 && fac4 == 256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + else if (rt2[3] == 255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - mfac= rt2[3]; - fac= (fac4*(256-mfac))>>8; + mfac = rt2[3]; + fac = (fac4 * (256 - mfac)) >> 8; - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8; - rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8; - rt[2]= ( fac*rt1[2] + mfac*rt2[2])>>8; - rt[3]= ( fac*rt1[3] + mfac*rt2[3])>>8; + rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8; + rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8; + rt[2] = (fac * rt1[2] + mfac * rt2[2]) >> 8; + rt[3] = (fac * rt1[3] + mfac * rt2[3]) >> 8; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { float fac2, mfac, fac, fac4; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac4= facf1; + fac2 = facf0; + fac4 = facf1; while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 under rt2 (alpha from rt2) */ @@ -665,7 +665,7 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, /* this complex optimalisation is because the * 'skybuf' can be crossed in */ - if ( rt2[3]<=0 && fac2 >= 1.0f) { + if (rt2[3] <= 0 && fac2 >= 1.0f) { memcpy(rt, rt1, 4 * sizeof(float)); } else if (rt2[3] >= 1.0f) { @@ -679,67 +679,67 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, memcpy(rt, rt2, 4 * sizeof(float)); } else { - rt[0]= fac*rt1[0] + mfac*rt2[0]; - rt[1]= fac*rt1[1] + mfac*rt2[1]; - rt[2]= fac*rt1[2] + mfac*rt2[2]; - rt[3]= fac*rt1[3] + mfac*rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - if (rt2[3]<=0 && fac4 >= 1.0f) { + if (rt2[3] <= 0 && fac4 >= 1.0f) { memcpy(rt, rt1, 4 * sizeof(float)); } - else if (rt2[3]>=1.0f) { + else if (rt2[3] >= 1.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } else { - mfac= rt2[3]; - fac= fac4*(1.0f-mfac); + mfac = rt2[3]; + fac = fac4 * (1.0f - mfac); if (fac == 0) { memcpy(rt, rt2, 4 * sizeof(float)); } else { - rt[0]= fac * rt1[0] + mfac * rt2[0]; - rt[1]= fac * rt1[1] + mfac * rt2[1]; - rt[2]= fac * rt1[2] + mfac * rt2[2]; - rt[3]= fac * rt1[3] + mfac * rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } -static struct ImBuf* do_alphaunder_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_alphaunder_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs( - context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaunder_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_alphaunder_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -750,95 +750,95 @@ static struct ImBuf* do_alphaunder_effect( * ********************************************************************** */ static void do_cross_effect_byte(float facf0, float facf1, int x, int y, - char *rect1, char *rect2, - char *out) + char *rect1, char *rect2, + char *out) { int fac1, fac2, fac3, fac4; int xo; char *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= (int)(256.0f*facf0); - fac1= 256-fac2; - fac4= (int)(256.0f*facf1); - fac3= 256-fac4; + fac2 = (int)(256.0f * facf0); + fac1 = 256 - fac2; + fac4 = (int)(256.0f * facf1); + fac3 = 256 - fac4; while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= (fac1*rt1[0] + fac2*rt2[0])>>8; - rt[1]= (fac1*rt1[1] + fac2*rt2[1])>>8; - rt[2]= (fac1*rt1[2] + fac2*rt2[2])>>8; - rt[3]= (fac1*rt1[3] + fac2*rt2[3])>>8; + rt[0] = (fac1 * rt1[0] + fac2 * rt2[0]) >> 8; + rt[1] = (fac1 * rt1[1] + fac2 * rt2[1]) >> 8; + rt[2] = (fac1 * rt1[2] + fac2 * rt2[2]) >> 8; + rt[3] = (fac1 * rt1[3] + fac2 * rt2[3]) >> 8; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= (fac3*rt1[0] + fac4*rt2[0])>>8; - rt[1]= (fac3*rt1[1] + fac4*rt2[1])>>8; - rt[2]= (fac3*rt1[2] + fac4*rt2[2])>>8; - rt[3]= (fac3*rt1[3] + fac4*rt2[3])>>8; + rt[0] = (fac3 * rt1[0] + fac4 * rt2[0]) >> 8; + rt[1] = (fac3 * rt1[1] + fac4 * rt2[1]) >> 8; + rt[2] = (fac3 * rt1[2] + fac4 * rt2[2]) >> 8; + rt[3] = (fac3 * rt1[3] + fac4 * rt2[3]) >> 8; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_cross_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, float *out) + float *rect1, float *rect2, float *out) { float fac1, fac2, fac3, fac4; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac1= 1.0f - fac2; - fac4= facf1; - fac3= 1.0f - fac4; + fac2 = facf0; + fac1 = 1.0f - fac2; + fac4 = facf1; + fac3 = 1.0f - fac4; while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= fac1*rt1[0] + fac2*rt2[0]; - rt[1]= fac1*rt1[1] + fac2*rt2[1]; - rt[2]= fac1*rt1[2] + fac2*rt2[2]; - rt[3]= fac1*rt1[3] + fac2*rt2[3]; + rt[0] = fac1 * rt1[0] + fac2 * rt2[0]; + rt[1] = fac1 * rt1[1] + fac2 * rt2[1]; + rt[2] = fac1 * rt1[2] + fac2 * rt2[2]; + rt[3] = fac1 * rt1[3] + fac2 * rt2[3]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= fac3*rt1[0] + fac4*rt2[0]; - rt[1]= fac3*rt1[1] + fac4*rt2[1]; - rt[2]= fac3*rt1[2] + fac4*rt2[2]; - rt[3]= fac3*rt1[3] + fac4*rt2[3]; + rt[0] = fac3 * rt1[0] + fac4 * rt2[0]; + rt[1] = fac3 * rt1[1] + fac4 * rt2[1]; + rt[2] = fac3 * rt1[2] + fac4 * rt2[2]; + rt[3] = fac3 * rt1[3] + fac4 * rt2[3]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } @@ -846,26 +846,26 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y, /* careful: also used by speed effect! */ -static struct ImBuf* do_cross_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_cross_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs( - context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_cross_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_cross_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -906,9 +906,9 @@ static void makeGammaTables(float gamma) for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { color_domain_table[i] = i * color_step; gamma_range_table[i] = pow(color_domain_table[i], - valid_gamma); + valid_gamma); inv_gamma_range_table[i] = pow(color_domain_table[i], - valid_inv_gamma); + valid_inv_gamma); } /* The end of the table should match 1.0 carefully. In order to avoid */ @@ -921,11 +921,11 @@ static void makeGammaTables(float gamma) /* To speed up calculations, we make these calc factor tables. They are */ /* multiplication factors used in scaling the interpolation. */ - for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++ ) { - gamfactor_table[i] = inv_color_step - * (gamma_range_table[i + 1] - gamma_range_table[i]); - inv_gamfactor_table[i] = inv_color_step - * (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); + for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { + gamfactor_table[i] = inv_color_step * + (gamma_range_table[i + 1] - gamma_range_table[i]); + inv_gamfactor_table[i] = inv_color_step * + (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); } } /* end of void makeGammaTables(float gamma) */ @@ -942,9 +942,9 @@ static float gammaCorrect(float c) /* may help solve that, by exchanging LUT size for the interpolation. */ /* Negative colors are explicitly handled. */ if (i < 0) res = -pow(abs(c), valid_gamma); - else if (i >= RE_GAMMA_TABLE_SIZE ) res = pow(c, valid_gamma); + else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(c, valid_gamma); else res = gamma_range_table[i] + - ( (c - color_domain_table[i]) * gamfactor_table[i]); + ( (c - color_domain_table[i]) * gamfactor_table[i]); return res; } /* end of float gammaCorrect(float col) */ @@ -956,12 +956,12 @@ static float invGammaCorrect(float col) int i; float res = 0.0; - i = floor(col*inv_color_step); + i = floor(col * inv_color_step); /* Negative colors are explicitly handled. */ if (i < 0) res = -pow(abs(col), valid_inv_gamma); else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(col, valid_inv_gamma); else res = inv_gamma_range_table[i] + - ( (col - color_domain_table[i]) * inv_gamfactor_table[i]); + ( (col - color_domain_table[i]) * inv_gamfactor_table[i]); return res; } /* end of float invGammaCorrect(float col) */ @@ -969,26 +969,26 @@ static float invGammaCorrect(float col) static void gamtabs(float gamma) { - float val, igamma= 1.0f/gamma; + float val, igamma = 1.0f / gamma; int a; /* gamtab: in short, out short */ - for (a=0; a<65536; a++) { - val= a; - val/= 65535.0f; + for (a = 0; a < 65536; a++) { + val = a; + val /= 65535.0f; - if (gamma==2.0f) val= sqrt(val); - else if (gamma!=1.0f) val= pow(val, igamma); + if (gamma == 2.0f) val = sqrt(val); + else if (gamma != 1.0f) val = pow(val, igamma); - gamtab[a]= (65535.99f*val); + gamtab[a] = (65535.99f * val); } /* inverse gamtab1 : in byte, out short */ - for (a=1; a<=256; a++) { - if (gamma==2.0f) igamtab1[a-1]= a*a-1; - else if (gamma==1.0f) igamtab1[a-1]= 256*a-1; + for (a = 1; a <= 256; a++) { + if (gamma == 2.0f) igamtab1[a - 1] = a * a - 1; + else if (gamma == 1.0f) igamtab1[a - 1] = 256 * a - 1; else { - val= a/256.0f; - igamtab1[a - 1]= (65535.0 * pow(val, gamma)) - 1; + val = a / 256.0f; + igamtab1[a - 1] = (65535.0 * pow(val, gamma)) - 1; } } @@ -1003,139 +1003,139 @@ static void build_gammatabs(void) } } -static void init_gammacross(Sequence * UNUSED(seq)) +static void init_gammacross(Sequence *UNUSED(seq)) { } -static void load_gammacross(Sequence * UNUSED(seq)) +static void load_gammacross(Sequence *UNUSED(seq)) { } -static void free_gammacross(Sequence * UNUSED(seq)) +static void free_gammacross(Sequence *UNUSED(seq)) { } static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1), - int x, int y, - unsigned char *rect1, - unsigned char *rect2, - unsigned char *out) + int x, int y, + unsigned char *rect1, + unsigned char *rect2, + unsigned char *out) { int fac1, fac2, col; int xo; unsigned char *rt1, *rt2, *rt; - xo= x; - rt1= (unsigned char *)rect1; - rt2= (unsigned char *)rect2; - rt= (unsigned char *)out; + xo = x; + rt1 = (unsigned char *)rect1; + rt2 = (unsigned char *)rect2; + rt = (unsigned char *)out; - fac2= (int)(256.0f*facf0); - fac1= 256-fac2; + fac2 = (int)(256.0f * facf0); + fac1 = 256 - fac2; while (y--) { - x= xo; + x = xo; while (x--) { - col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8; - if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col=(fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8; - if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8; - if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8; - if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[0]] + fac2 * igamtab1[rt2[0]]) >> 8; + if (col > 65535) rt[0] = 255; else rt[0] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[1]] + fac2 * igamtab1[rt2[1]]) >> 8; + if (col > 65535) rt[1] = 255; else rt[1] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[2]] + fac2 * igamtab1[rt2[2]]) >> 8; + if (col > 65535) rt[2] = 255; else rt[2] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[3]] + fac2 * igamtab1[rt2[3]]) >> 8; + if (col > 65535) rt[3] = 255; else rt[3] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8; - if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8; - if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8; - if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8; - if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[0]] + fac2 * igamtab1[rt2[0]]) >> 8; + if (col > 65535) rt[0] = 255; else rt[0] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[1]] + fac2 * igamtab1[rt2[1]]) >> 8; + if (col > 65535) rt[1] = 255; else rt[1] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[2]] + fac2 * igamtab1[rt2[2]]) >> 8; + if (col > 65535) rt[2] = 255; else rt[2] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[3]] + fac2 * igamtab1[rt2[3]]) >> 8; + if (col > 65535) rt[3] = 255; else rt[3] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), - int x, int y, - float *rect1, float *rect2, - float *out) + int x, int y, + float *rect1, float *rect2, + float *out) { float fac1, fac2; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac1= 1.0f - fac2; + fac2 = facf0; + fac1 = 1.0f - fac2; while (y--) { - x= xo * 4; + x = xo * 4; while (x--) { - *rt= gammaCorrect( - fac1 * invGammaCorrect(*rt1) - + fac2 * invGammaCorrect(*rt2)); + *rt = gammaCorrect( + fac1 * invGammaCorrect(*rt1) + + fac2 * invGammaCorrect(*rt2)); rt1++; rt2++; rt++; } - if (y==0) break; + if (y == 0) break; y--; - x= xo * 4; + x = xo * 4; while (x--) { - *rt= gammaCorrect( - fac1*invGammaCorrect(*rt1) - + fac2*invGammaCorrect(*rt2)); + *rt = gammaCorrect( + fac1 * invGammaCorrect(*rt1) + + fac2 * invGammaCorrect(*rt2)); rt1++; rt2++; rt++; } } } -static struct ImBuf * do_gammacross_effect( - SeqRenderData context, - Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_gammacross_effect( + SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); build_gammatabs(); if (out->rect_float) { do_gammacross_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_gammacross_effect_byte( - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; } @@ -1146,86 +1146,86 @@ static struct ImBuf * do_gammacross_effect( * ********************************************************************** */ static void do_add_effect_byte(float facf0, float facf1, int x, int y, - unsigned char *rect1, unsigned char *rect2, - unsigned char *out) + unsigned char *rect1, unsigned char *rect2, + unsigned char *out) { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; - xo= x; - rt1= (char *)rect1; - rt2= (char *)rect2; - rt= (char *)out; + xo = x; + rt1 = (char *)rect1; + rt2 = (char *)rect2; + rt = (char *)out; - fac1= (int)(256.0f*facf0); - fac3= (int)(256.0f*facf1); + fac1 = (int)(256.0f * facf0); + fac3 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { - col= rt1[0]+ ((fac1*rt2[0])>>8); - if (col>255) rt[0]= 255; else rt[0]= col; - col= rt1[1]+ ((fac1*rt2[1])>>8); - if (col>255) rt[1]= 255; else rt[1]= col; - col= rt1[2]+ ((fac1*rt2[2])>>8); - if (col>255) rt[2]= 255; else rt[2]= col; - col= rt1[3]+ ((fac1*rt2[3])>>8); - if (col>255) rt[3]= 255; else rt[3]= col; + col = rt1[0] + ((fac1 * rt2[0]) >> 8); + if (col > 255) rt[0] = 255; else rt[0] = col; + col = rt1[1] + ((fac1 * rt2[1]) >> 8); + if (col > 255) rt[1] = 255; else rt[1] = col; + col = rt1[2] + ((fac1 * rt2[2]) >> 8); + if (col > 255) rt[2] = 255; else rt[2] = col; + col = rt1[3] + ((fac1 * rt2[3]) >> 8); + if (col > 255) rt[3] = 255; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - col= rt1[0]+ ((fac3*rt2[0])>>8); - if (col>255) rt[0]= 255; else rt[0]= col; - col= rt1[1]+ ((fac3*rt2[1])>>8); - if (col>255) rt[1]= 255; else rt[1]= col; - col= rt1[2]+ ((fac3*rt2[2])>>8); - if (col>255) rt[2]= 255; else rt[2]= col; - col= rt1[3]+ ((fac3*rt2[3])>>8); - if (col>255) rt[3]= 255; else rt[3]= col; + col = rt1[0] + ((fac3 * rt2[0]) >> 8); + if (col > 255) rt[0] = 255; else rt[0] = col; + col = rt1[1] + ((fac3 * rt2[1]) >> 8); + if (col > 255) rt[1] = 255; else rt[1] = col; + col = rt1[2] + ((fac3 * rt2[2]) >> 8); + if (col > 255) rt[2] = 255; else rt[2] = col; + col = rt1[3] + ((fac3 * rt2[3]) >> 8); + if (col > 255) rt[3] = 255; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_add_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac1= facf0; - fac3= facf1; + fac1 = facf0; + fac3 = facf1; while (y--) { - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 + fac1 * (*rt2); rt1++; rt2++; rt++; } - if (y==0) break; + if (y == 0) break; y--; - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 + fac3 * (*rt2); @@ -1234,25 +1234,24 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_add_effect(SeqRenderData context, - Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_add_effect(SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_add_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_add_effect_byte( - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; } @@ -1263,86 +1262,86 @@ static struct ImBuf * do_add_effect(SeqRenderData context, * ********************************************************************** */ static void do_sub_effect_byte(float facf0, float facf1, - int x, int y, - char *rect1, char *rect2, char *out) + int x, int y, + char *rect1, char *rect2, char *out) { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; - xo= x; - rt1= (char *)rect1; - rt2= (char *)rect2; - rt= (char *)out; + xo = x; + rt1 = (char *)rect1; + rt2 = (char *)rect2; + rt = (char *)out; - fac1= (int)(256.0f*facf0); - fac3= (int)(256.0f*facf1); + fac1 = (int)(256.0f * facf0); + fac3 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { - col= rt1[0]- ((fac1*rt2[0])>>8); - if (col<0) rt[0]= 0; else rt[0]= col; - col= rt1[1]- ((fac1*rt2[1])>>8); - if (col<0) rt[1]= 0; else rt[1]= col; - col= rt1[2]- ((fac1*rt2[2])>>8); - if (col<0) rt[2]= 0; else rt[2]= col; - col= rt1[3]- ((fac1*rt2[3])>>8); - if (col<0) rt[3]= 0; else rt[3]= col; + col = rt1[0] - ((fac1 * rt2[0]) >> 8); + if (col < 0) rt[0] = 0; else rt[0] = col; + col = rt1[1] - ((fac1 * rt2[1]) >> 8); + if (col < 0) rt[1] = 0; else rt[1] = col; + col = rt1[2] - ((fac1 * rt2[2]) >> 8); + if (col < 0) rt[2] = 0; else rt[2] = col; + col = rt1[3] - ((fac1 * rt2[3]) >> 8); + if (col < 0) rt[3] = 0; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - col= rt1[0]- ((fac3*rt2[0])>>8); - if (col<0) rt[0]= 0; else rt[0]= col; - col= rt1[1]- ((fac3*rt2[1])>>8); - if (col<0) rt[1]= 0; else rt[1]= col; - col= rt1[2]- ((fac3*rt2[2])>>8); - if (col<0) rt[2]= 0; else rt[2]= col; - col= rt1[3]- ((fac3*rt2[3])>>8); - if (col<0) rt[3]= 0; else rt[3]= col; + col = rt1[0] - ((fac3 * rt2[0]) >> 8); + if (col < 0) rt[0] = 0; else rt[0] = col; + col = rt1[1] - ((fac3 * rt2[1]) >> 8); + if (col < 0) rt[1] = 0; else rt[1] = col; + col = rt1[2] - ((fac3 * rt2[2]) >> 8); + if (col < 0) rt[2] = 0; else rt[2] = col; + col = rt1[3] - ((fac3 * rt2[3]) >> 8); + if (col < 0) rt[3] = 0; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_sub_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac1= facf0; - fac3= facf1; + fac1 = facf0; + fac3 = facf1; while (y--) { - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 - fac1 * (*rt2); rt1++; rt2++; rt++; } - if (y==0) break; + if (y == 0) break; y--; - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 - fac3 * (*rt2); @@ -1351,25 +1350,24 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_sub_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_sub_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_sub_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_sub_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -1379,88 +1377,88 @@ static struct ImBuf * do_sub_effect( * ********************************************************************** */ /* Must be > 0 or add precopy, etc to the function */ -#define XOFF 8 -#define YOFF 8 +#define XOFF 8 +#define YOFF 8 static void do_drop_effect_byte(float facf0, float facf1, int x, int y, - char *rect2i, char *rect1i, - char *outi) + char *rect2i, char *rect1i, + char *outi) { int height, width, temp, fac, fac1, fac2; char *rt1, *rt2, *out; - int field= 1; + int field = 1; - width= x; - height= y; + width = x; + height = y; - fac1= (int)(70.0f*facf0); - fac2= (int)(70.0f*facf1); + fac1 = (int)(70.0f * facf0); + fac2 = (int)(70.0f * facf1); - rt2= (char*) (rect2i + YOFF*width); - rt1= (char*) rect1i; - out= (char*) outi; - for (y=0; y>8); + for (x = XOFF; x < width; x++) { + temp = ((fac * rt2[3]) >> 8); - *(out++)= MAX2(0, *rt1 - temp); rt1++; - *(out++)= MAX2(0, *rt1 - temp); rt1++; - *(out++)= MAX2(0, *rt1 - temp); rt1++; - *(out++)= MAX2(0, *rt1 - temp); rt1++; - rt2+=4; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + rt2 += 4; } - rt2+=XOFF*4; + rt2 += XOFF * 4; } - memcpy(out, rt1, sizeof(int)*YOFF*width); + memcpy(out, rt1, sizeof(int) * YOFF * width); } static void do_drop_effect_float(float facf0, float facf1, int x, int y, - float *rect2i, float *rect1i, - float *outi) + float *rect2i, float *rect1i, + float *outi) { int height, width; float temp, fac, fac1, fac2; float *rt1, *rt2, *out; - int field= 1; + int field = 1; - width= x; - height= y; + width = x; + height = y; - fac1= 70.0f*facf0; - fac2= 70.0f*facf1; + fac1 = 70.0f * facf0; + fac2 = 70.0f * facf1; - rt2= (rect2i + YOFF*width); - rt1= rect1i; - out= outi; - for (y=0; y fac*a*(b-1)+axaux= c*px + py*s ;//+centx @@ -1489,48 +1487,48 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y, while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + ((fac1*rt1[0]*(rt2[0]-256))>>16); - rt[1]= rt1[1] + ((fac1*rt1[1]*(rt2[1]-256))>>16); - rt[2]= rt1[2] + ((fac1*rt1[2]*(rt2[2]-256))>>16); - rt[3]= rt1[3] + ((fac1*rt1[3]*(rt2[3]-256))>>16); + rt[0] = rt1[0] + ((fac1 * rt1[0] * (rt2[0] - 256)) >> 16); + rt[1] = rt1[1] + ((fac1 * rt1[1] * (rt2[1] - 256)) >> 16); + rt[2] = rt1[2] + ((fac1 * rt1[2] * (rt2[2] - 256)) >> 16); + rt[3] = rt1[3] + ((fac1 * rt1[3] * (rt2[3] - 256)) >> 16); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + ((fac3*rt1[0]*(rt2[0]-256))>>16); - rt[1]= rt1[1] + ((fac3*rt1[1]*(rt2[1]-256))>>16); - rt[2]= rt1[2] + ((fac3*rt1[2]*(rt2[2]-256))>>16); - rt[3]= rt1[3] + ((fac3*rt1[3]*(rt2[3]-256))>>16); + rt[0] = rt1[0] + ((fac3 * rt1[0] * (rt2[0] - 256)) >> 16); + rt[1] = rt1[1] + ((fac3 * rt1[1] * (rt2[1] - 256)) >> 16); + rt[2] = rt1[2] + ((fac3 * rt1[2] * (rt2[2] - 256)) >> 16); + rt[3] = rt1[3] + ((fac3 * rt1[3] * (rt2[3] - 256)) >> 16); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_mul_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac1= facf0; - fac3= facf1; + fac1 = facf0; + fac3 = facf1; /* formula: * fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a @@ -1538,52 +1536,52 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + fac1*rt1[0]*(rt2[0]-1.0f); - rt[1]= rt1[1] + fac1*rt1[1]*(rt2[1]-1.0f); - rt[2]= rt1[2] + fac1*rt1[2]*(rt2[2]-1.0f); - rt[3]= rt1[3] + fac1*rt1[3]*(rt2[3]-1.0f); + rt[0] = rt1[0] + fac1 * rt1[0] * (rt2[0] - 1.0f); + rt[1] = rt1[1] + fac1 * rt1[1] * (rt2[1] - 1.0f); + rt[2] = rt1[2] + fac1 * rt1[2] * (rt2[2] - 1.0f); + rt[3] = rt1[3] + fac1 * rt1[3] * (rt2[3] - 1.0f); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + fac3*rt1[0]*(rt2[0]-1.0f); - rt[1]= rt1[1] + fac3*rt1[1]*(rt2[1]-1.0f); - rt[2]= rt1[2] + fac3*rt1[2]*(rt2[2]-1.0f); - rt[3]= rt1[3] + fac3*rt1[3]*(rt2[3]-1.0f); + rt[0] = rt1[0] + fac3 * rt1[0] * (rt2[0] - 1.0f); + rt[1] = rt1[1] + fac3 * rt1[1] * (rt2[1] - 1.0f); + rt[2] = rt1[2] + fac3 * rt1[2] * (rt2[2] - 1.0f); + rt[3] = rt1[3] + fac3 * rt1[3] * (rt2[3] - 1.0f); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } -static struct ImBuf * do_mul_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_mul_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_mul_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_mul_effect_byte( - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; @@ -1607,8 +1605,8 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo wipezone->angle = tanf(DEG2RADF(fabsf(wipe->angle))); wipezone->xo = xo; wipezone->yo = yo; - wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f)); - wipezone->pythangle = 1.0f/sqrtf(wipezone->angle*wipezone->angle + 1.0f); + wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f)); + wipezone->pythangle = 1.0f / sqrtf(wipezone->angle * wipezone->angle + 1.0f); } // This function calculates the blur band for the wipe effects @@ -1623,18 +1621,18 @@ static float in_band(float width, float dist, int side, int dir) return (float)side; if (side == 1) - alpha = (dist+0.5f*width) / (width); + alpha = (dist + 0.5f * width) / (width); else - alpha = (0.5f*width-dist) / (width); + alpha = (0.5f * width - dist) / (width); if (dir == 0) - alpha = 1-alpha; + alpha = 1 - alpha; return alpha; } static float check_zone(WipeZone *wipezone, int x, int y, - Sequence *seq, float facf0) + Sequence *seq, float facf0) { float posx, posy, hyp, hyp2, angle, hwidth, b1, b2, b3, pointdist; /* some future stuff */ @@ -1642,9 +1640,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, float temp1, temp2, temp3, temp4; //some placeholder variables int xo = wipezone->xo; int yo = wipezone->yo; - float halfx = xo*0.5f; - float halfy = yo*0.5f; - float widthf, output=0; + float halfx = xo * 0.5f; + float halfy = yo * 0.5f; + float widthf, output = 0; WipeVars *wipe = (WipeVars *)seq->effectdata; int width; @@ -1670,9 +1668,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, hyp = fabs(y - posy); } else { - b1 = posy - (-angle)*posx; - b2 = y - (-angle)*x; - hyp = fabsf(angle*x+y+(-posy-angle*posx))*wipezone->pythangle; + b1 = posy - (-angle) * posx; + b2 = y - (-angle) * x; + hyp = fabsf(angle * x + y + (-posy - angle * posx)) * wipezone->pythangle; } if (angle < 0) { @@ -1693,49 +1691,49 @@ static float check_zone(WipeZone *wipezone, int x, int y, else output = in_band(width, hyp, 1, 1); } - break; + break; case DO_DOUBLE_WIPE: if (!wipe->forward) - facf0 = 1.0f-facf0; // Go the other direction + facf0 = 1.0f - facf0; // Go the other direction width = wipezone->width; // calculate the blur width - hwidth = width*0.5f; + hwidth = width * 0.5f; if (angle == 0) { - b1 = posy*0.5f; - b3 = yo-posy*0.5f; + b1 = posy * 0.5f; + b3 = yo - posy * 0.5f; b2 = y; - hyp = abs(y - posy*0.5f); - hyp2 = abs(y - (yo-posy*0.5f)); + hyp = abs(y - posy * 0.5f); + hyp2 = abs(y - (yo - posy * 0.5f)); } else { - b1 = posy*0.5f - (-angle)*posx*0.5f; - b3 = (yo-posy*0.5f) - (-angle)*(xo-posx*0.5f); - b2 = y - (-angle)*x; + b1 = posy * 0.5f - (-angle) * posx * 0.5f; + b3 = (yo - posy * 0.5f) - (-angle) * (xo - posx * 0.5f); + b2 = y - (-angle) * x; - hyp = fabsf(angle*x+y+(-posy*0.5f-angle*posx*0.5f))*wipezone->pythangle; - hyp2 = fabsf(angle*x+y+(-(yo-posy*0.5f)-angle*(xo-posx*0.5f)))*wipezone->pythangle; + hyp = fabsf(angle * x + y + (-posy * 0.5f - angle * posx * 0.5f)) * wipezone->pythangle; + hyp2 = fabsf(angle * x + y + (-(yo - posy * 0.5f) - angle * (xo - posx * 0.5f))) * wipezone->pythangle; } - hwidth = minf(hwidth, fabsf(b3-b1)/2.0f); + hwidth = minf(hwidth, fabsf(b3 - b1) / 2.0f); - if (b2 < b1 && b2 < b3 ) { + if (b2 < b1 && b2 < b3) { output = in_band(hwidth, hyp, 0, 1); } - else if (b2 > b1 && b2 > b3 ) { + else if (b2 > b1 && b2 > b3) { output = in_band(hwidth, hyp2, 0, 1); } else { - if ( hyp < hwidth && hyp2 > hwidth ) + if (hyp < hwidth && hyp2 > hwidth) output = in_band(hwidth, hyp, 1, 1); - else if ( hyp > hwidth && hyp2 < hwidth ) - output = in_band(hwidth, hyp2, 1, 1); + else if (hyp > hwidth && hyp2 < hwidth) + output = in_band(hwidth, hyp2, 1, 1); else - output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1); + output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1); } - if (!wipe->forward)output = 1-output; - break; + if (!wipe->forward) output = 1 - output; + break; case DO_CLOCK_WIPE: /* * temp1: angle of effect center in rads @@ -1744,125 +1742,125 @@ static float check_zone(WipeZone *wipezone, int x, int y, * temp4: angle of high side of blur */ output = 1.0f - facf0; - widthf = wipe->edgeWidth*2.0f*(float)M_PI; + widthf = wipe->edgeWidth * 2.0f * (float)M_PI; temp1 = 2.0f * (float)M_PI * facf0; if (wipe->forward) { - temp1 = 2.0f*(float)M_PI - temp1; + temp1 = 2.0f * (float)M_PI - temp1; } x = x - halfx; y = y - halfy; - temp2 = asin(abs(y)/sqrt(x*x + y*y)); + temp2 = asin(abs(y) / sqrt(x * x + y * y)); if (x <= 0 && y >= 0) temp2 = (float)M_PI - temp2; - else if (x<=0 && y <= 0) temp2 += (float)M_PI; - else if (x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; + else if (x <= 0 && y <= 0) temp2 += (float)M_PI; + else if (x >= 0 && y <= 0) temp2 = 2.0f * (float)M_PI - temp2; if (wipe->forward) { - temp3 = temp1-(widthf*0.5f)*facf0; - temp4 = temp1+(widthf*0.5f)*(1-facf0); + temp3 = temp1 - (widthf * 0.5f) * facf0; + temp4 = temp1 + (widthf * 0.5f) * (1 - facf0); } else { - temp3 = temp1-(widthf*0.5f)*(1-facf0); - temp4 = temp1+(widthf*0.5f)*facf0; + temp3 = temp1 - (widthf * 0.5f) * (1 - facf0); + temp4 = temp1 + (widthf * 0.5f) * facf0; } if (temp3 < 0) temp3 = 0; - if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI; + if (temp4 > 2.0f * (float)M_PI) temp4 = 2.0f * (float)M_PI; if (temp2 < temp3) output = 0; else if (temp2 > temp4) output = 1; - else output = (temp2-temp3)/(temp4-temp3); + else output = (temp2 - temp3) / (temp4 - temp3); if (x == 0 && y == 0) output = 1; if (output != output) output = 1; if (wipe->forward) output = 1 - output; - break; - /* BOX WIPE IS NOT WORKING YET */ - /* case DO_CROSS_WIPE: */ - /* BOX WIPE IS NOT WORKING YET */ + break; + /* BOX WIPE IS NOT WORKING YET */ + /* case DO_CROSS_WIPE: */ + /* BOX WIPE IS NOT WORKING YET */ #if 0 case DO_BOX_WIPE: - if (invert)facf0 = 1-facf0; + if (invert) facf0 = 1 - facf0; - width = (int)(wipe->edgeWidth*((xo+yo)/2.0)); - hwidth = (float)width/2.0; - if (angle == 0)angle = 0.000001; - b1 = posy/2 - (-angle)*posx/2; - b3 = (yo-posy/2) - (-angle)*(xo-posx/2); - b2 = y - (-angle)*x; + width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0)); + hwidth = (float)width / 2.0; + if (angle == 0) angle = 0.000001; + b1 = posy / 2 - (-angle) * posx / 2; + b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2); + b2 = y - (-angle) * x; - hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle; - hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle; + hyp = abs(angle * x + y + (-posy / 2 - angle * posx / 2)) * wipezone->pythangle; + hyp2 = abs(angle * x + y + (-(yo - posy / 2) - angle * (xo - posx / 2))) * wipezone->pythangle; - temp1 = xo*(1-facf0/2)-xo*facf0/2; - temp2 = yo*(1-facf0/2)-yo*facf0/2; - pointdist = sqrt(temp1*temp1 + temp2*temp2); + temp1 = xo * (1 - facf0 / 2) - xo * facf0 / 2; + temp2 = yo * (1 - facf0 / 2) - yo * facf0 / 2; + pointdist = sqrt(temp1 * temp1 + temp2 * temp2); - if (b2 < b1 && b2 < b3 ) { + if (b2 < b1 && b2 < b3) { if (hwidth < pointdist) output = in_band(wipezone, hwidth, hyp, facf0, 0, 1); - } - else if (b2 > b1 && b2 > b3 ) { + } + else if (b2 > b1 && b2 > b3) { if (hwidth < pointdist) output = in_band(wipezone, hwidth, hyp2, facf0, 0, 1); - } - else { - if ( hyp < hwidth && hyp2 > hwidth ) + } + else { + if (hyp < hwidth && hyp2 > hwidth) output = in_band(wipezone, hwidth, hyp, facf0, 1, 1); - else if ( hyp > hwidth && hyp2 < hwidth ) - output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1); + else if (hyp > hwidth && hyp2 < hwidth) + output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1); else - output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); + output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); } - if (invert)facf0 = 1-facf0; - angle = -1/angle; - b1 = posy/2 - (-angle)*posx/2; - b3 = (yo-posy/2) - (-angle)*(xo-posx/2); - b2 = y - (-angle)*x; + if (invert) facf0 = 1 - facf0; + angle = -1 / angle; + b1 = posy / 2 - (-angle) * posx / 2; + b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2); + b2 = y - (-angle) * x; - hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle; - hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle; + hyp = abs(angle * x + y + (-posy / 2 - angle * posx / 2)) * wipezone->pythangle; + hyp2 = abs(angle * x + y + (-(yo - posy / 2) - angle * (xo - posx / 2))) * wipezone->pythangle; - if (b2 < b1 && b2 < b3 ) { + if (b2 < b1 && b2 < b3) { if (hwidth < pointdist) output *= in_band(wipezone, hwidth, hyp, facf0, 0, 1); - } - else if (b2 > b1 && b2 > b3 ) { + } + else if (b2 > b1 && b2 > b3) { if (hwidth < pointdist) output *= in_band(wipezone, hwidth, hyp2, facf0, 0, 1); - } - else { - if ( hyp < hwidth && hyp2 > hwidth ) + } + else { + if (hyp < hwidth && hyp2 > hwidth) output *= in_band(wipezone, hwidth, hyp, facf0, 1, 1); - else if ( hyp > hwidth && hyp2 < hwidth ) + else if (hyp > hwidth && hyp2 < hwidth) output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1); else output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); } - break; + break; #endif case DO_IRIS_WIPE: if (xo > yo) yo = xo; else xo = yo; - if (!wipe->forward) facf0 = 1-facf0; + if (!wipe->forward) facf0 = 1 - facf0; width = wipezone->width; - hwidth = width*0.5f; + hwidth = width * 0.5f; - temp1 = (halfx-(halfx)*facf0); - pointdist = sqrt(temp1*temp1 + temp1*temp1); + temp1 = (halfx - (halfx) * facf0); + pointdist = sqrt(temp1 * temp1 + temp1 * temp1); - temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); - if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2-pointdist), 0, 1); - else output = in_band(hwidth, fabs(temp2-pointdist), 1, 1); + temp2 = sqrt((halfx - x) * (halfx - x) + (halfy - y) * (halfy - y)); + if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2 - pointdist), 0, 1); + else output = in_band(hwidth, fabs(temp2 - pointdist), 1, 1); - if (!wipe->forward) output = 1-output; + if (!wipe->forward) output = 1 - output; - break; + break; } if (output < 0) output = 0; else if (output > 1) output = 1; @@ -1871,7 +1869,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, static void init_wipe_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct WipeVars), "wipevars"); } @@ -1882,7 +1880,7 @@ static int num_inputs_wipe(void) static void free_wipe_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -1892,9 +1890,9 @@ static void copy_wipe_effect(Sequence *dst, Sequence *src) } static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), - int x, int y, - unsigned char *rect1, - unsigned char *rect2, unsigned char *out) + int x, int y, + unsigned char *rect1, + unsigned char *rect2, unsigned char *out) { WipeZone wipezone; WipeVars *wipe = (WipeVars *)seq->effectdata; @@ -1909,15 +1907,15 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), xo = x; yo = y; - for (y=0;yeffectdata; @@ -1970,15 +1968,15 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) xo = x; yo = y; - for (y=0;yrect_float) { do_wipe_effect_float(seq, - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_wipe_effect_byte(seq, - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; @@ -2043,7 +2040,7 @@ static void init_transform_effect(Sequence *seq) { TransformVars *transform; - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct TransformVars), "transformvars"); transform = (TransformVars *)seq->effectdata; @@ -2051,14 +2048,14 @@ static void init_transform_effect(Sequence *seq) transform->ScalexIni = 1.0f; transform->ScaleyIni = 1.0f; - transform->xIni=0.0f; - transform->yIni=0.0f; + transform->xIni = 0.0f; + transform->yIni = 0.0f; - transform->rotIni=0.0f; + transform->rotIni = 0.0f; - transform->interpolation=1; - transform->percent=1; - transform->uniform_scale=0; + transform->interpolation = 1; + transform->percent = 1; + transform->uniform_scale = 0; } static int num_inputs_transform(void) @@ -2068,7 +2065,7 @@ static int num_inputs_transform(void) static void free_transform_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -2078,8 +2075,8 @@ static void copy_transform_effect(Sequence *dst, Sequence *src) } static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out, - float scale_x, float scale_y, float translate_x, float translate_y, - float rotate, int interpolation) + float scale_x, float scale_y, float translate_x, float translate_y, + float rotate, int interpolation) { int xo, yo, xi, yi; float xt, yt, xr, yr; @@ -2089,19 +2086,19 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out yo = y; // Rotate - s= sin(rotate); - c= cos(rotate); + s = sin(rotate); + c = cos(rotate); for (yi = 0; yi < yo; yi++) { for (xi = 0; xi < xo; xi++) { //translate point - xt = xi-translate_x; - yt = yi-translate_y; + xt = xi - translate_x; + yt = yi - translate_y; //rotate point with center ref - xr = c*xt + s*yt; - yr = -s*xt + c*yt; + xr = c * xt + s * yt; + yr = -s * xt + c * yt; //scale point with center ref xt = xr / scale_x; @@ -2113,22 +2110,22 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out //interpolate switch (interpolation) { - case 0: - neareast_interpolation(ibuf1, out, xt, yt, xi, yi); - break; - case 1: - bilinear_interpolation(ibuf1, out, xt, yt, xi, yi); - break; - case 2: - bicubic_interpolation(ibuf1, out, xt, yt, xi, yi); - break; + case 0: + neareast_interpolation(ibuf1, out, xt, yt, xi, yi); + break; + case 1: + bilinear_interpolation(ibuf1, out, xt, yt, xi, yi); + break; + case 2: + bicubic_interpolation(ibuf1, out, xt, yt, xi, yi); + break; } } } } static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x, int y, - struct ImBuf *ibuf1, struct ImBuf *out) + struct ImBuf *ibuf1, struct ImBuf *out) { TransformVars *transform = (TransformVars *)seq->effectdata; float scale_x, scale_y, translate_x, translate_y, rotate_radians; @@ -2144,14 +2141,14 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x // Translate if (!transform->percent) { - float rd_s = (scene->r.size/100.0f); + float rd_s = (scene->r.size / 100.0f); - translate_x = transform->xIni*rd_s+(x/2.0f); - translate_y = transform->yIni*rd_s+(y/2.0f); + translate_x = transform->xIni * rd_s + (x / 2.0f); + translate_y = transform->yIni * rd_s + (y / 2.0f); } else { - translate_x = x*(transform->xIni/100.0f)+(x/2.0f); - translate_y = y*(transform->yIni/100.0f)+(y/2.0f); + translate_x = x * (transform->xIni / 100.0f) + (x / 2.0f); + translate_y = y * (transform->yIni / 100.0f) + (y / 2.0f); } // Rotate @@ -2161,13 +2158,12 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } -static struct ImBuf * do_transform_effect( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float UNUSED(facf1), - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_transform_effect( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float UNUSED(facf1), + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); do_transform(context.scene, seq, facf0, context.rectx, context.recty, ibuf1, out); @@ -2180,7 +2176,7 @@ static struct ImBuf * do_transform_effect( * GLOW * ********************************************************************** */ -static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, +static void RVBlurBitmap2_byte(unsigned char *map, int width, int height, float blur, int quality) /* MUUUCCH better than the previous blur. */ @@ -2192,26 +2188,26 @@ static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, /* a small bitmap. Avoid avoid avoid. */ /*=============================== */ { - unsigned char* temp=NULL, *swap; - float *filter=NULL; - int x, y, i, fx, fy; - int index, ix, halfWidth; - float fval, k, curColor[3], curColor2[3], weight=0; + unsigned char *temp = NULL, *swap; + float *filter = NULL; + int x, y, i, fx, fy; + int index, ix, halfWidth; + float fval, k, curColor[3], curColor2[3], weight = 0; /* If we're not really blurring, bail out */ - if (blur<=0) + if (blur <= 0) return; /* Allocate memory for the tempmap and the blur filter matrix */ - temp= MEM_mallocN((width*height*4), "blurbitmaptemp"); + temp = MEM_mallocN((width * height * 4), "blurbitmaptemp"); if (!temp) return; /* Allocate memory for the filter elements */ - halfWidth = ((quality+1)*blur); - filter = (float *)MEM_mallocN(sizeof(float)*halfWidth*2, "blurbitmapfilter"); + halfWidth = ((quality + 1) * blur); + filter = (float *)MEM_mallocN(sizeof(float) * halfWidth * 2, "blurbitmapfilter"); if (!filter) { - MEM_freeN (temp); + MEM_freeN(temp); return; } @@ -2221,137 +2217,137 @@ static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, /* posted to comp.graphics.algorithms by */ /* Blancmange (bmange@airdmhor.gen.nz) */ - k = -1.0f/(2.0f*(float)M_PI*blur*blur); - for (ix = 0;ix< halfWidth;ix++) { - weight = (float)exp(k*(ix*ix)); + k = -1.0f / (2.0f * (float)M_PI * blur * blur); + for (ix = 0; ix < halfWidth; ix++) { + weight = (float)exp(k * (ix * ix)); filter[halfWidth - ix] = weight; filter[halfWidth + ix] = weight; } filter[0] = weight; /* Normalize the array */ - fval=0; - for (ix = 0;ix< halfWidth*2;ix++) - fval+=filter[ix]; + fval = 0; + for (ix = 0; ix < halfWidth * 2; ix++) + fval += filter[ix]; - for (ix = 0;ix< halfWidth*2;ix++) - filter[ix]/=fval; + for (ix = 0; ix < halfWidth * 2; ix++) + filter[ix] /= fval; /* Blur the rows */ - for (y=0;y=0)&&(i= 0) && (i < width)) { + curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx]; + curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx]; + curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx]; - curColor2[0]+=map[(width-1-i+y*width)*4+GlowR] * - filter[fx]; - curColor2[1]+=map[(width-1-i+y*width)*4+GlowG] * - filter[fx]; - curColor2[2]+=map[(width-1-i+y*width)*4+GlowB] * - filter[fx]; + curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] * + filter[fx]; + curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] * + filter[fx]; + curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] * + filter[fx]; } fx++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; - temp[((width-1-x+y*width)*4)+GlowR]=curColor2[0]; - temp[((width-1-x+y*width)*4)+GlowG]=curColor2[1]; - temp[((width-1-x+y*width)*4)+GlowB]=curColor2[2]; + temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0]; + temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1]; + temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (x=halfWidth;x=0)&&(i= 0) && (i < height)) { /* Bottom */ - curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; - curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; - curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy]; + curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy]; + curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy]; + curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy]; /* Top */ - curColor2[0]+=map[(x+(height-1-i)*width) * - 4+GlowR]*filter[fy]; - curColor2[1]+=map[(x+(height-1-i)*width) * - 4+GlowG]*filter[fy]; - curColor2[2]+=map[(x+(height-1-i)*width) * - 4+GlowB]*filter[fy]; + curColor2[0] += map[(x + (height - 1 - i) * width) * + 4 + GlowR] * filter[fy]; + curColor2[1] += map[(x + (height - 1 - i) * width) * + 4 + GlowG] * filter[fy]; + curColor2[2] += map[(x + (height - 1 - i) * width) * + 4 + GlowB] * filter[fy]; } fy++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; - temp[((x+(height-1-y)*width)*4)+GlowR]=curColor2[0]; - temp[((x+(height-1-y)*width)*4)+GlowG]=curColor2[1]; - temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; + temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0]; + temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1]; + temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (y=halfWidth;y=0)&&(i= 0) && (i < width)) { + curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx]; + curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx]; + curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx]; - curColor2[0]+=map[(width-1-i+y*width)*4+GlowR] * - filter[fx]; - curColor2[1]+=map[(width-1-i+y*width)*4+GlowG] * - filter[fx]; - curColor2[2]+=map[(width-1-i+y*width)*4+GlowB] * - filter[fx]; + curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] * + filter[fx]; + curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] * + filter[fx]; + curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] * + filter[fx]; } fx++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; - temp[((width-1-x+y*width)*4)+GlowR]=curColor2[0]; - temp[((width-1-x+y*width)*4)+GlowG]=curColor2[1]; - temp[((width-1-x+y*width)*4)+GlowB]=curColor2[2]; + temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0]; + temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1]; + temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (x=halfWidth;x=0)&&(i= 0) && (i < height)) { /* Bottom */ - curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; - curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; - curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy]; + curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy]; + curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy]; + curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy]; /* Top */ - curColor2[0]+=map[(x+(height-1-i)*width) * - 4+GlowR]*filter[fy]; - curColor2[1]+=map[(x+(height-1-i)*width) * - 4+GlowG]*filter[fy]; - curColor2[2]+=map[(x+(height-1-i)*width) * - 4+GlowB]*filter[fy]; + curColor2[0] += map[(x + (height - 1 - i) * width) * + 4 + GlowR] * filter[fy]; + curColor2[1] += map[(x + (height - 1 - i) * width) * + 4 + GlowG] * filter[fy]; + curColor2[2] += map[(x + (height - 1 - i) * width) * + 4 + GlowB] * filter[fy]; } fy++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; - temp[((x+(height-1-y)*width)*4)+GlowR]=curColor2[0]; - temp[((x+(height-1-y)*width)*4)+GlowG]=curColor2[1]; - temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; + temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0]; + temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1]; + temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (y=halfWidth;y0) { - out[index+GlowR]=MIN2(255*clamp, (in[index+GlowR]*boost*intensity)/255); - out[index+GlowG]=MIN2(255*clamp, (in[index+GlowG]*boost*intensity)/255); - out[index+GlowB]=MIN2(255*clamp, (in[index+GlowB]*boost*intensity)/255); - out[index+GlowA]=MIN2(255*clamp, (in[index+GlowA]*boost*intensity)/255); + intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold); + if (intensity > 0) { + out[index + GlowR] = MIN2(255 * clamp, (in[index + GlowR] * boost * intensity) / 255); + out[index + GlowG] = MIN2(255 * clamp, (in[index + GlowG] * boost * intensity) / 255); + out[index + GlowB] = MIN2(255 * clamp, (in[index + GlowB] * boost * intensity) / 255); + out[index + GlowA] = MIN2(255 * clamp, (in[index + GlowA] * boost * intensity) / 255); } else { - out[index+GlowR]=0; - out[index+GlowG]=0; - out[index+GlowB]=0; - out[index+GlowA]=0; + out[index + GlowR] = 0; + out[index + GlowG] = 0; + out[index + GlowB] = 0; + out[index + GlowA] = 0; } } } } -static void RVIsolateHighlights_float (float* in, float* out, - int width, int height, float threshold, - float boost, float clamp) +static void RVIsolateHighlights_float(float *in, float *out, + int width, int height, float threshold, + float boost, float clamp) { int x, y, index; - float intensity; + float intensity; - for (y=0;y< height;y++) { - for (x=0;x< width;x++) { - index= (x+y*width)*4; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + index = (x + y * width) * 4; /* Isolate the intensity */ - intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold); - if (intensity>0) { - out[index+GlowR]=MIN2(clamp, (in[index+GlowR]*boost*intensity)); - out[index+GlowG]=MIN2(clamp, (in[index+GlowG]*boost*intensity)); - out[index+GlowB]=MIN2(clamp, (in[index+GlowB]*boost*intensity)); - out[index+GlowA]=MIN2(clamp, (in[index+GlowA]*boost*intensity)); + intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold); + if (intensity > 0) { + out[index + GlowR] = MIN2(clamp, (in[index + GlowR] * boost * intensity)); + out[index + GlowG] = MIN2(clamp, (in[index + GlowG] * boost * intensity)); + out[index + GlowB] = MIN2(clamp, (in[index + GlowB] * boost * intensity)); + out[index + GlowA] = MIN2(clamp, (in[index + GlowA] * boost * intensity)); } else { - out[index+GlowR]=0; - out[index+GlowG]=0; - out[index+GlowB]=0; - out[index+GlowA]=0; + out[index + GlowR] = 0; + out[index + GlowG] = 0; + out[index + GlowB] = 0; + out[index + GlowA] = 0; } } } @@ -2621,7 +2617,7 @@ static void init_glow_effect(Sequence *seq) { GlowVars *glow; - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct GlowVars), "glowvars"); glow = (GlowVars *)seq->effectdata; @@ -2640,7 +2636,7 @@ static int num_inputs_glow(void) static void free_glow_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -2651,56 +2647,56 @@ static void copy_glow_effect(Sequence *dst, Sequence *src) //void do_glow_effect(Cast *cast, float facf0, float facf1, int xo, int yo, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use) static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), - int x, int y, char *rect1, - char *UNUSED(rect2), char *out) + int x, int y, char *rect1, + char *UNUSED(rect2), char *out) { - unsigned char *outbuf=(unsigned char *)out; - unsigned char *inbuf=(unsigned char *)rect1; + unsigned char *outbuf = (unsigned char *)out; + unsigned char *inbuf = (unsigned char *)rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini*765, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); + RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini * 765, glow->fBoost * facf0, glow->fClamp); + RVBlurBitmap2_byte(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); if (!glow->bNoComp) - RVAddBitmaps_byte (inbuf, outbuf, outbuf, x, y); + RVAddBitmaps_byte(inbuf, outbuf, outbuf, x, y); } static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), - int x, int y, - float *rect1, float *UNUSED(rect2), float *out) + int x, int y, + float *rect1, float *UNUSED(rect2), float *out) { float *outbuf = out; float *inbuf = rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini*3.0f, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); + RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini * 3.0f, glow->fBoost * facf0, glow->fClamp); + RVBlurBitmap2_float(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); if (!glow->bNoComp) - RVAddBitmaps_float (inbuf, outbuf, outbuf, x, y); + RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y); } -static struct ImBuf * do_glow_effect( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_glow_effect( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); - int render_size = 100*context.rectx/context.scene->r.xsch; + int render_size = 100 * context.rectx / context.scene->r.xsch; if (out->rect_float) { do_glow_effect_float(seq, render_size, - facf0, facf1, - context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, + context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_glow_effect_byte(seq, render_size, - facf0, facf1, - context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, + context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; @@ -2714,7 +2710,7 @@ static void init_solid_color(Sequence *seq) { SolidColorVars *cv; - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct SolidColorVars), "solidcolor"); cv = (SolidColorVars *)seq->effectdata; @@ -2728,7 +2724,7 @@ static int num_inputs_color(void) static void free_solid_color(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -2738,18 +2734,17 @@ static void copy_solid_color(Sequence *dst, Sequence *src) } static int early_out_color(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return -1; } -static struct ImBuf * do_solid_color( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_solid_color( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); SolidColorVars *cv = (SolidColorVars *)seq->effectdata; @@ -2772,20 +2767,20 @@ static struct ImBuf * do_solid_color( rect = (unsigned char *)out->rect; - for (y=0; yy; y++) { - for (x=0; xx; x++, rect+=4) { - rect[0]= col0[0]; - rect[1]= col0[1]; - rect[2]= col0[2]; - rect[3]= 255; + for (y = 0; y < out->y; y++) { + for (x = 0; x < out->x; x++, rect += 4) { + rect[0] = col0[0]; + rect[1] = col0[1]; + rect[2] = col0[2]; + rect[3] = 255; } y++; - if (yy) { - for (x=0; xx; x++, rect+=4) { - rect[0]= col1[0]; - rect[1]= col1[1]; - rect[2]= col1[2]; - rect[3]= 255; + if (y < out->y) { + for (x = 0; x < out->x; x++, rect += 4) { + rect[0] = col1[0]; + rect[1] = col1[1]; + rect[2] = col1[2]; + rect[3] = 255; } } } @@ -2805,20 +2800,20 @@ static struct ImBuf * do_solid_color( rect_float = out->rect_float; - for (y=0; yy; y++) { - for (x=0; xx; x++, rect_float+=4) { - rect_float[0]= col0[0]; - rect_float[1]= col0[1]; - rect_float[2]= col0[2]; - rect_float[3]= 1.0; + for (y = 0; y < out->y; y++) { + for (x = 0; x < out->x; x++, rect_float += 4) { + rect_float[0] = col0[0]; + rect_float[1] = col0[1]; + rect_float[2] = col0[2]; + rect_float[3] = 1.0; } y++; - if (yy) { - for (x=0; xx; x++, rect_float+=4) { - rect_float[0]= col1[0]; - rect_float[1]= col1[1]; - rect_float[2]= col1[2]; - rect_float[3]= 1.0; + if (y < out->y) { + for (x = 0; x < out->x; x++, rect_float += 4) { + rect_float[0] = col1[0]; + rect_float[1] = col1[1]; + rect_float[2] = col1[2]; + rect_float[3] = 1.0; } } } @@ -2841,16 +2836,15 @@ static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0), return -1; } -static struct ImBuf * do_multicam( - SeqRenderData context, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), - struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), - struct ImBuf *UNUSED(ibuf3)) -{ - struct ImBuf * i; - struct ImBuf * out; - Editing * ed; - ListBase * seqbasep; +static struct ImBuf *do_multicam( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)){ + struct ImBuf *i; + struct ImBuf *out; + Editing *ed; + ListBase *seqbasep; if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) { return NULL; @@ -2896,12 +2890,11 @@ static int early_out_adjustment(struct Sequence *UNUSED(seq), float UNUSED(facf0 return -1; } -static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, - float cfra) -{ - Editing * ed; - ListBase * seqbasep; - struct ImBuf * i= NULL; +static struct ImBuf *do_adjustment_impl(SeqRenderData context, Sequence *seq, + float cfra){ + Editing *ed; + ListBase *seqbasep; + struct ImBuf *i = NULL; ed = context.scene->ed; @@ -2909,7 +2902,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, if (seq->machine > 0) { i = give_ibuf_seqbase(context, cfra, - seq->machine - 1, seqbasep); + seq->machine - 1, seqbasep); } /* found nothing? so let's work the way up the metastrip stack, so @@ -2918,7 +2911,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, */ if (!i) { - Sequence * meta; + Sequence *meta; meta = seq_metastrip(&ed->seqbase, NULL, seq); @@ -2930,15 +2923,14 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, return i; } -static struct ImBuf * do_adjustment( - SeqRenderData context, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), - struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), - struct ImBuf *UNUSED(ibuf3)) -{ - struct ImBuf * i = NULL; - struct ImBuf * out; - Editing * ed; +static struct ImBuf *do_adjustment( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)){ + struct ImBuf *i = NULL; + struct ImBuf *out; + Editing *ed; ed = context.scene->ed; @@ -2964,11 +2956,11 @@ static struct ImBuf * do_adjustment( * ********************************************************************** */ static void init_speed_effect(Sequence *seq) { - SpeedControlVars * v; + SpeedControlVars *v; if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct SpeedControlVars), - "speedcontrolvars"); + "speedcontrolvars"); v = (SpeedControlVars *)seq->effectdata; v->globalSpeed = 1.0; @@ -2977,9 +2969,9 @@ static void init_speed_effect(Sequence *seq) v->length = 0; } -static void load_speed_effect(Sequence * seq) +static void load_speed_effect(Sequence *seq) { - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; v->frameMap = NULL; v->length = 0; @@ -2992,7 +2984,7 @@ static int num_inputs_speed(void) static void free_speed_effect(Sequence *seq) { - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; if (v->frameMap) MEM_freeN(v->frameMap); if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; @@ -3000,7 +2992,7 @@ static void free_speed_effect(Sequence *seq) static void copy_speed_effect(Sequence *dst, Sequence *src) { - SpeedControlVars * v; + SpeedControlVars *v; dst->effectdata = MEM_dupallocN(src->effectdata); v = (SpeedControlVars *)dst->effectdata; v->frameMap = NULL; @@ -3008,15 +3000,15 @@ static void copy_speed_effect(Sequence *dst, Sequence *src) } static int early_out_speed(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return 1; } -static void store_icu_yrange_speed(struct Sequence * seq, - short UNUSED(adrcode), float * ymin, float * ymax) +static void store_icu_yrange_speed(struct Sequence *seq, + short UNUSED(adrcode), float *ymin, float *ymax) { - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; /* if not already done, load / initialize data */ get_sequence_effect(seq); @@ -3036,32 +3028,31 @@ static void store_icu_yrange_speed(struct Sequence * seq, } } } -void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) +void sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, int force) { int cfra; float fallback_fac = 1.0f; - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; - FCurve *fcu= NULL; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; + FCurve *fcu = NULL; int flags = v->flags; /* if not already done, load / initialize data */ get_sequence_effect(seq); - if ( (force == FALSE) && - (seq->len == v->length) && - (v->frameMap != NULL) - ) { + if ((force == FALSE) && + (seq->len == v->length) && + (v->frameMap != NULL)) + { return; } - if ( (seq->seq1 == NULL) || - (seq->len < 1) - ) { /* make coverity happy and check for (CID 598) input strip ... */ + if ((seq->seq1 == NULL) || (seq->len < 1)) { + /* make coverity happy and check for (CID 598) input strip ... */ return; } /* XXX - new in 2.5x. should we use the animation system this way? * The fcurve is needed because many frames need evaluating at once - campbell */ - fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL); + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL); if (!v->frameMap || v->length != seq->len) { @@ -3070,7 +3061,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) v->length = seq->len; v->frameMap = MEM_callocN(sizeof(float) * v->length, - "speedcontrol frameMap"); + "speedcontrol frameMap"); } fallback_fac = 1.0; @@ -3080,7 +3071,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) (seq->seq1->len != 0)) { fallback_fac = (float) seq->seq1->len / - (float) (seq->seq1->enddisp - seq->seq1->start); + (float) (seq->seq1->enddisp - seq->seq1->start); flags = SEQ_SPEED_INTEGRATE; fcu = NULL; } @@ -3179,13 +3170,13 @@ static int num_inputs_default(void) } static int early_out_noop(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return 0; } static int early_out_fade(struct Sequence *UNUSED(seq), - float facf0, float facf1) + float facf0, float facf1) { if (facf0 == 0.0f && facf1 == 0.0f) { return 1; @@ -3197,7 +3188,7 @@ static int early_out_fade(struct Sequence *UNUSED(seq), } static int early_out_mul_input2(struct Sequence *UNUSED(seq), - float facf0, float facf1) + float facf0, float facf1) { if (facf0 == 0.0f && facf1 == 0.0f) { return 1; @@ -3205,20 +3196,20 @@ static int early_out_mul_input2(struct Sequence *UNUSED(seq), return 0; } -static void store_icu_yrange_noop(struct Sequence * UNUSED(seq), - short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax)) +static void store_icu_yrange_noop(struct Sequence *UNUSED(seq), + short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax)) { /* defaults are fine */ } static void get_default_fac_noop(struct Sequence *UNUSED(seq), float UNUSED(cfra), - float * facf0, float * facf1) + float *facf0, float *facf1) { *facf0 = *facf1 = 1.0; } static void get_default_fac_fade(struct Sequence *seq, float cfra, - float * facf0, float * facf1) + float *facf0, float *facf1) { *facf0 = (float)(cfra - seq->startdisp); *facf1 = (float)(*facf0 + 0.5f); @@ -3226,45 +3217,43 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf * do_overdrop_effect(SeqRenderData context, - Sequence *UNUSED(seq), - float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf * ibuf1, - struct ImBuf * ibuf2, - struct ImBuf * ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_overdrop_effect(SeqRenderData context, + Sequence *UNUSED(seq), + float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, + struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; if (out->rect_float) { do_drop_effect_float( - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); do_alphaover_effect_float( - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_drop_effect_byte( - facf0, facf1, x, y, - (char*) ibuf1->rect, - (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, x, y, + (char *) ibuf1->rect, + (char *) ibuf2->rect, + (char *) out->rect); do_alphaover_effect_byte( - facf0, facf1, x, y, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, x, y, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } -static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) -{ +static struct SeqEffectHandle get_sequence_effect_impl(int seq_type){ struct SeqEffectHandle rval; int sequence_type = seq_type; @@ -3280,112 +3269,112 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) rval.copy = NULL; switch (sequence_type) { - case SEQ_CROSS: - rval.execute = do_cross_effect; - rval.early_out = early_out_fade; - rval.get_default_fac = get_default_fac_fade; - break; - case SEQ_GAMCROSS: - rval.init = init_gammacross; - rval.load = load_gammacross; - rval.free = free_gammacross; - rval.early_out = early_out_fade; - rval.get_default_fac = get_default_fac_fade; - rval.execute = do_gammacross_effect; - break; - case SEQ_ADD: - rval.execute = do_add_effect; - rval.early_out = early_out_mul_input2; - break; - case SEQ_SUB: - rval.execute = do_sub_effect; - rval.early_out = early_out_mul_input2; - break; - case SEQ_MUL: - rval.execute = do_mul_effect; - rval.early_out = early_out_mul_input2; - break; - case SEQ_ALPHAOVER: - rval.init = init_alpha_over_or_under; - rval.execute = do_alphaover_effect; - break; - case SEQ_OVERDROP: - rval.execute = do_overdrop_effect; - break; - case SEQ_ALPHAUNDER: - rval.init = init_alpha_over_or_under; - rval.execute = do_alphaunder_effect; - break; - case SEQ_WIPE: - rval.init = init_wipe_effect; - rval.num_inputs = num_inputs_wipe; - rval.free = free_wipe_effect; - rval.copy = copy_wipe_effect; - rval.early_out = early_out_fade; - rval.get_default_fac = get_default_fac_fade; - rval.execute = do_wipe_effect; - break; - case SEQ_GLOW: - rval.init = init_glow_effect; - rval.num_inputs = num_inputs_glow; - rval.free = free_glow_effect; - rval.copy = copy_glow_effect; - rval.execute = do_glow_effect; - break; - case SEQ_TRANSFORM: - rval.init = init_transform_effect; - rval.num_inputs = num_inputs_transform; - rval.free = free_transform_effect; - rval.copy = copy_transform_effect; - rval.execute = do_transform_effect; - break; - case SEQ_SPEED: - rval.init = init_speed_effect; - rval.num_inputs = num_inputs_speed; - rval.load = load_speed_effect; - rval.free = free_speed_effect; - rval.copy = copy_speed_effect; - rval.execute = do_cross_effect; - rval.early_out = early_out_speed; - rval.store_icu_yrange = store_icu_yrange_speed; - break; - case SEQ_COLOR: - rval.init = init_solid_color; - rval.num_inputs = num_inputs_color; - rval.early_out = early_out_color; - rval.free = free_solid_color; - rval.copy = copy_solid_color; - rval.execute = do_solid_color; - break; - case SEQ_PLUGIN: - rval.init_plugin = init_plugin; - rval.num_inputs = num_inputs_plugin; - rval.load = load_plugin; - rval.free = free_plugin; - rval.copy = copy_plugin; - rval.execute = do_plugin_effect; - rval.early_out = do_plugin_early_out; - rval.get_default_fac = get_default_fac_fade; - break; - case SEQ_MULTICAM: - rval.num_inputs = num_inputs_multicam; - rval.early_out = early_out_multicam; - rval.execute = do_multicam; - break; - case SEQ_ADJUSTMENT: - rval.num_inputs = num_inputs_adjustment; - rval.early_out = early_out_adjustment; - rval.execute = do_adjustment; - break; + case SEQ_CROSS: + rval.execute = do_cross_effect; + rval.early_out = early_out_fade; + rval.get_default_fac = get_default_fac_fade; + break; + case SEQ_GAMCROSS: + rval.init = init_gammacross; + rval.load = load_gammacross; + rval.free = free_gammacross; + rval.early_out = early_out_fade; + rval.get_default_fac = get_default_fac_fade; + rval.execute = do_gammacross_effect; + break; + case SEQ_ADD: + rval.execute = do_add_effect; + rval.early_out = early_out_mul_input2; + break; + case SEQ_SUB: + rval.execute = do_sub_effect; + rval.early_out = early_out_mul_input2; + break; + case SEQ_MUL: + rval.execute = do_mul_effect; + rval.early_out = early_out_mul_input2; + break; + case SEQ_ALPHAOVER: + rval.init = init_alpha_over_or_under; + rval.execute = do_alphaover_effect; + break; + case SEQ_OVERDROP: + rval.execute = do_overdrop_effect; + break; + case SEQ_ALPHAUNDER: + rval.init = init_alpha_over_or_under; + rval.execute = do_alphaunder_effect; + break; + case SEQ_WIPE: + rval.init = init_wipe_effect; + rval.num_inputs = num_inputs_wipe; + rval.free = free_wipe_effect; + rval.copy = copy_wipe_effect; + rval.early_out = early_out_fade; + rval.get_default_fac = get_default_fac_fade; + rval.execute = do_wipe_effect; + break; + case SEQ_GLOW: + rval.init = init_glow_effect; + rval.num_inputs = num_inputs_glow; + rval.free = free_glow_effect; + rval.copy = copy_glow_effect; + rval.execute = do_glow_effect; + break; + case SEQ_TRANSFORM: + rval.init = init_transform_effect; + rval.num_inputs = num_inputs_transform; + rval.free = free_transform_effect; + rval.copy = copy_transform_effect; + rval.execute = do_transform_effect; + break; + case SEQ_SPEED: + rval.init = init_speed_effect; + rval.num_inputs = num_inputs_speed; + rval.load = load_speed_effect; + rval.free = free_speed_effect; + rval.copy = copy_speed_effect; + rval.execute = do_cross_effect; + rval.early_out = early_out_speed; + rval.store_icu_yrange = store_icu_yrange_speed; + break; + case SEQ_COLOR: + rval.init = init_solid_color; + rval.num_inputs = num_inputs_color; + rval.early_out = early_out_color; + rval.free = free_solid_color; + rval.copy = copy_solid_color; + rval.execute = do_solid_color; + break; + case SEQ_PLUGIN: + rval.init_plugin = init_plugin; + rval.num_inputs = num_inputs_plugin; + rval.load = load_plugin; + rval.free = free_plugin; + rval.copy = copy_plugin; + rval.execute = do_plugin_effect; + rval.early_out = do_plugin_early_out; + rval.get_default_fac = get_default_fac_fade; + break; + case SEQ_MULTICAM: + rval.num_inputs = num_inputs_multicam; + rval.early_out = early_out_multicam; + rval.execute = do_multicam; + break; + case SEQ_ADJUSTMENT: + rval.num_inputs = num_inputs_adjustment; + rval.early_out = early_out_adjustment; + rval.execute = do_adjustment; + break; } return rval; } -struct SeqEffectHandle get_sequence_effect(Sequence * seq) +struct SeqEffectHandle get_sequence_effect(Sequence *seq) { - struct SeqEffectHandle rval= {NULL}; + struct SeqEffectHandle rval = {NULL}; if (seq->type & SEQ_EFFECT) { rval = get_sequence_effect_impl(seq->type); @@ -3398,9 +3387,9 @@ struct SeqEffectHandle get_sequence_effect(Sequence * seq) return rval; } -struct SeqEffectHandle get_sequence_blend(Sequence * seq) +struct SeqEffectHandle get_sequence_blend(Sequence *seq) { - struct SeqEffectHandle rval= {NULL}; + struct SeqEffectHandle rval = {NULL}; if (seq->blend_mode != 0) { rval = get_sequence_effect_impl(seq->blend_mode);