From 00ce0c9aae04a461d96dc626bc6651a3ba0211cf Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 5 Oct 2012 12:59:09 +0000 Subject: Clean up in "add object" code: * Get rid of ED_object_add_generic_invoke() and all invoke callbacks using it, it was doing nothing exec() callbacks would not do. In fact, its only action (setting part of common add ops properties, like loc, layers, etc.) was needed too by direct exec call, so it was done twice in case of using invoke()! * Replace custom invoke code for metaballs by WM_menu_invoke helper (as already used by lamps). * Add a new OBJECT_OT_empty_add op, to allow direct addition of empties of a given drawtype. * And some general code cleanup (like trailing spaces, empty lines, ...). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Did quite a bunch of tests/verifications, but obviously could not tackle all possible scenarios... Anyway, if any, bugs should arize quite quickly (but I don’t expect any! :p ). --- release/scripts/startup/bl_ui/space_info.py | 51 ++--- source/blender/editors/curve/editcurve.c | 68 +++--- source/blender/editors/include/ED_object.h | 1 - source/blender/editors/mesh/editmesh_add.c | 109 +++++----- source/blender/editors/object/object_add.c | 295 +++++++++++++------------- source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 7 files changed, 255 insertions(+), 271 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_info.py b/release/scripts/startup/bl_ui/space_info.py index de58b5d1aaf..9ab2a772df0 100644 --- a/release/scripts/startup/bl_ui/space_info.py +++ b/release/scripts/startup/bl_ui/space_info.py @@ -192,7 +192,7 @@ class INFO_MT_mesh_add(Menu): def draw(self, context): layout = self.layout - layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator_context = 'EXEC_REGION_WIN' layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane") layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube") layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle") @@ -203,7 +203,7 @@ class INFO_MT_mesh_add(Menu): layout.separator() layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid") layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey") - layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS') + layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus") class INFO_MT_curve_add(Menu): @@ -213,7 +213,7 @@ class INFO_MT_curve_add(Menu): def draw(self, context): layout = self.layout - layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator_context = 'EXEC_REGION_WIN' layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier") layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle") layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve") @@ -221,22 +221,6 @@ class INFO_MT_curve_add(Menu): layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path") -class INFO_MT_edit_curve_add(Menu): - bl_idname = "INFO_MT_edit_curve_add" - bl_label = "Add" - - def draw(self, context): - is_surf = context.active_object.type == 'SURFACE' - - layout = self.layout - layout.operator_context = 'INVOKE_REGION_WIN' - - if is_surf: - INFO_MT_surface_add.draw(self, context) - else: - INFO_MT_curve_add.draw(self, context) - - class INFO_MT_surface_add(Menu): bl_idname = "INFO_MT_surface_add" bl_label = "Surface" @@ -244,7 +228,7 @@ class INFO_MT_surface_add(Menu): def draw(self, context): layout = self.layout - layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator_context = 'EXEC_REGION_WIN' layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve") layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle") layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface") @@ -253,6 +237,22 @@ class INFO_MT_surface_add(Menu): layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus") +class INFO_MT_edit_curve_add(Menu): + bl_idname = "INFO_MT_edit_curve_add" + bl_label = "Add" + + def draw(self, context): + is_surf = context.active_object.type == 'SURFACE' + + layout = self.layout + layout.operator_context = 'EXEC_REGION_WIN' + + if is_surf: + INFO_MT_surface_add.draw(self, context) + else: + INFO_MT_curve_add.draw(self, context) + + class INFO_MT_armature_add(Menu): bl_idname = "INFO_MT_armature_add" bl_label = "Armature" @@ -260,7 +260,7 @@ class INFO_MT_armature_add(Menu): def draw(self, context): layout = self.layout - layout.operator_context = 'INVOKE_REGION_WIN' + layout.operator_context = 'EXEC_REGION_WIN' layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA') @@ -284,23 +284,18 @@ class INFO_MT_add(Menu): #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE') layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE') layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META') -# layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT') layout.separator() layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE') - # XXX Quick fix for [#32764]. - layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE' - layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY' - layout.operator_context = 'EXEC_REGION_WIN' + layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY') layout.separator() layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER') layout.separator() layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA') -# layout.operator_context = 'EXEC_AREA' layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP') layout.separator() @@ -308,7 +303,7 @@ class INFO_MT_add(Menu): layout.separator() if(len(bpy.data.groups) > 10): - layout.operator_context = 'INVOKE_DEFAULT' + layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY') else: layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY') diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 9c13f4be6a9..afd6bc4c4b5 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -6567,18 +6567,18 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) if (!isSurf) { /* adding curve */ if (obedit == NULL || obedit->type != OB_CURVE) { Curve *cu; - + obedit = ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); newob = 1; cu = (Curve *)obedit->data; cu->flag |= CU_DEFORM_FILL; - + if (type & CU_PRIM_PATH) cu->flag |= CU_PATH | CU_3D; - } + } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); - } + } else { /* adding surface */ if (obedit == NULL || obedit->type != OB_SURF) { obedit = ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); @@ -6589,7 +6589,6 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) /* rename here, the undo stack checks name for valid undo pushes */ if (newob) { - if (obedit->type == OB_CURVE) { rename_id((ID *)obedit, get_curve_defname(type)); rename_id((ID *)obedit->data, get_curve_defname(type)); @@ -6599,11 +6598,11 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) rename_id((ID *)obedit->data, get_surf_defname(type)); } } - + /* ED_object_add_type doesnt do an undo, is needed for redo operator on primitive */ if (newob && enter_editmode) ED_undo_push(C, "Enter Editmode"); - + ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); nu = add_nurbs_primitive(C, obedit, mat, type, newob); @@ -6643,12 +6642,11 @@ void CURVE_OT_primitive_bezier_curve_add(wmOperatorType *ot) ot->name = "Add Bezier"; ot->description = "Construct a Bezier Curve"; ot->idname = "CURVE_OT_primitive_bezier_curve_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_bezier_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6666,12 +6664,11 @@ void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) ot->name = "Add Bezier Circle"; ot->description = "Construct a Bezier Circle"; ot->idname = "CURVE_OT_primitive_bezier_circle_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_bezier_circle_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6689,12 +6686,11 @@ void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot) ot->name = "Add Nurbs Curve"; ot->description = "Construct a Nurbs Curve"; ot->idname = "CURVE_OT_primitive_nurbs_curve_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_curve_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6712,12 +6708,11 @@ void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot) ot->name = "Add Nurbs Circle"; ot->description = "Construct a Nurbs Circle"; ot->idname = "CURVE_OT_primitive_nurbs_circle_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_circle_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6735,12 +6730,11 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) ot->name = "Add Path"; ot->description = "Construct a Path"; ot->idname = "CURVE_OT_primitive_nurbs_path_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_curve_path_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6759,12 +6753,11 @@ void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) ot->name = "Add Surface Curve"; ot->description = "Construct a Nurbs surface Curve"; ot->idname = "SURFACE_OT_primitive_nurbs_surface_curve_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_surface_curve_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6782,12 +6775,11 @@ void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) ot->name = "Add Surface Circle"; ot->description = "Construct a Nurbs surface Circle"; ot->idname = "SURFACE_OT_primitive_nurbs_surface_circle_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_surface_circle_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6805,12 +6797,11 @@ void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) ot->name = "Add Surface Patch"; ot->description = "Construct a Nurbs surface Patch"; ot->idname = "SURFACE_OT_primitive_nurbs_surface_surface_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_surface_surface_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6828,12 +6819,11 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(wmOperatorType *ot) ot->name = "Add Surface Cylinder"; ot->description = "Construct a Nurbs surface Cylinder"; ot->idname = "SURFACE_OT_primitive_nurbs_surface_cylinder_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_surface_cylinder_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6851,12 +6841,11 @@ void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) ot->name = "Add Surface Sphere"; ot->description = "Construct a Nurbs surface Sphere"; ot->idname = "SURFACE_OT_primitive_nurbs_surface_sphere_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_surface_sphere_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -6874,12 +6863,11 @@ void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) ot->name = "Add Surface Torus"; ot->description = "Construct a Nurbs surface Torus"; ot->idname = "SURFACE_OT_primitive_nurbs_surface_torus_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_nurbs_surface_torus_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 26c8b865377..9836d690e53 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -126,7 +126,6 @@ float ED_object_new_primitive_matrix(struct bContext *C, struct Object *editob, const float loc[3], const float rot[3], float primmat[][4]); void ED_object_add_generic_props(struct wmOperatorType *ot, int do_editmode); -int ED_object_add_generic_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float loc[3], float rot[3], int *enter_editmode, unsigned int *layer, int *is_view_aligned); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index fdaddec5246..0cf4ac48bf7 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -64,7 +64,7 @@ static Object *make_prim_init(bContext *C, const char *idname, *state = 0; if (obedit == NULL || obedit->type != OB_MESH) { obedit = ED_object_add_type(C, OB_MESH, loc, rot, FALSE, layer); - + rename_id((ID *)obedit, idname); rename_id((ID *)obedit->data, idname); @@ -103,7 +103,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -125,12 +125,11 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) ot->name = "Add Plane"; ot->description = "Construct a filled planar mesh with 4 vertices"; ot->idname = "MESH_OT_primitive_plane_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_plane_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -145,7 +144,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -153,7 +152,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_cube mat=%m4 size=%f", mat, dia * 2.0f)) { return OPERATOR_CANCELLED; } - + /* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */ make_prim_finish(C, obedit, &state, enter_editmode); @@ -166,12 +165,11 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) ot->name = "Add Cube"; ot->description = "Construct a cube mesh"; ot->idname = "MESH_OT_primitive_cube_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_cube_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -192,10 +190,10 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) int enter_editmode; int state, cap_end, cap_tri; unsigned int layer; - + cap_end = RNA_enum_get(op->ptr, "fill_type"); cap_tri = (cap_end == 2); - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -207,9 +205,9 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - + return OPERATOR_FINISHED; } @@ -221,15 +219,14 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) ot->name = "Add Circle"; ot->description = "Construct a circle mesh"; ot->idname = "MESH_OT_primitive_circle_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_circle_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); @@ -247,10 +244,10 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) int enter_editmode; int state, cap_end, cap_tri; unsigned int layer; - + cap_end = RNA_enum_get(op->ptr, "end_fill_type"); cap_tri = (cap_end == 2); - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -266,9 +263,9 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - + return OPERATOR_FINISHED; } @@ -280,15 +277,14 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) ot->name = "Add Cylinder"; ot->description = "Construct a cylinder mesh"; ot->idname = "MESH_OT_primitive_cylinder_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_cylinder_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); @@ -308,10 +304,10 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) int enter_editmode; int state, cap_end, cap_tri; unsigned int layer; - + cap_end = RNA_enum_get(op->ptr, "end_fill_type"); cap_tri = (cap_end == 2); - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -324,7 +320,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; @@ -338,15 +334,14 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) ot->name = "Add Cone"; ot->description = "Construct a conic mesh"; ot->idname = "MESH_OT_primitive_cone_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_cone_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); prop = RNA_def_float(ot->srna, "radius1", 1.0f, 0.0, FLT_MAX, "Radius 1", "", 0.001, 100.00); @@ -368,7 +363,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -381,8 +376,9 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); + return OPERATOR_FINISHED; } @@ -394,15 +390,14 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) ot->name = "Add Grid"; ot->description = "Construct a grid mesh"; ot->idname = "MESH_OT_primitive_grid_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_grid_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "x_subdivisions", 10, 3, INT_MAX, "X Subdivisions", "", 3, 1000); RNA_def_int(ot->srna, "y_subdivisions", 10, 3, INT_MAX, "Y Subdivisions", "", 3, 1000); @@ -420,19 +415,20 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) int enter_editmode; int state, view_aligned; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &view_aligned); if (!view_aligned) rot[0] += (float)M_PI / 2.0f; - + obedit = make_prim_init(C, "Monkey", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "vertout", "create_monkey mat=%m4", mat)) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); + return OPERATOR_FINISHED; } @@ -442,12 +438,11 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) ot->name = "Add Monkey"; ot->description = "Construct a Suzanne mesh"; ot->idname = "MESH_OT_primitive_monkey_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_monkey_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -462,7 +457,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -474,7 +469,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); return OPERATOR_FINISHED; @@ -488,15 +483,14 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) ot->name = "Add UV Sphere"; ot->description = "Construct a UV sphere mesh"; ot->idname = "MESH_OT_primitive_uv_sphere_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_uvsphere_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "segments", 32, 3, INT_MAX, "Segments", "", 3, 500); RNA_def_int(ot->srna, "ring_count", 16, 3, INT_MAX, "Rings", "", 3, 500); @@ -514,7 +508,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) int enter_editmode; int state; unsigned int layer; - + ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); obedit = make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); @@ -527,10 +521,10 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) { return OPERATOR_CANCELLED; } - + make_prim_finish(C, obedit, &state, enter_editmode); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) @@ -541,15 +535,14 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) ot->name = "Add Ico Sphere"; ot->description = "Construct an Icosphere mesh"; ot->idname = "MESH_OT_primitive_ico_sphere_add"; - + /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = add_primitive_icosphere_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_int(ot->srna, "subdivisions", 2, 1, INT_MAX, "Subdivisions", "", 1, 8); prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0f, FLT_MAX, "Size", "", 0.001f, 100.00); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 102353ce1d1..f6a7a6d6f17 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -43,6 +43,7 @@ #include "DNA_meta_types.h" #include "DNA_object_fluidsim.h" #include "DNA_object_force.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_speaker_types.h" #include "DNA_vfont_types.h" @@ -138,6 +139,19 @@ static EnumPropertyItem field_type_items[] = { {0, NULL, 0, NULL, NULL} }; +/* Copy from rna_object.c */ +static EnumPropertyItem empty_drawtype_items[] = { + {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, + {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, + {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, + {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {OB_CUBE, "CUBE", 0, "Cube", ""}, + {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, + {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, + {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, + {0, NULL, 0, NULL, NULL} +}; + /************************** Exported *****************************/ void ED_object_location_from_view(bContext *C, float loc[3]) @@ -245,100 +259,100 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } -static void object_add_generic_invoke_options(bContext *C, wmOperator *op) +int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float loc[3], float rot[3], + int *enter_editmode, unsigned int *layer, int *is_view_aligned) { - if (RNA_struct_find_property(op->ptr, "enter_editmode")) /* optional */ - if (!RNA_struct_property_is_set(op->ptr, "enter_editmode")) - RNA_boolean_set(op->ptr, "enter_editmode", U.flag & USER_ADD_EDITMODE); + View3D *v3d = CTX_wm_view3d(C); - if (!RNA_struct_property_is_set(op->ptr, "location")) { - float loc[3]; + /* Switch to Edit mode? */ + if (RNA_struct_find_property(op->ptr, "enter_editmode")) { /* optional */ + int _enter_editmode; + if (!enter_editmode) + enter_editmode = &_enter_editmode; - ED_object_location_from_view(C, loc); - RNA_float_set_array(op->ptr, "location", loc); + if (RNA_struct_property_is_set(op->ptr, "enter_editmode") && enter_editmode) + *enter_editmode = RNA_boolean_get(op->ptr, "enter_editmode"); + else { + *enter_editmode = U.flag & USER_ADD_EDITMODE; + RNA_boolean_set(op->ptr, "enter_editmode", *enter_editmode); + } } - if (!RNA_struct_property_is_set(op->ptr, "layers")) { - View3D *v3d = CTX_wm_view3d(C); - Scene *scene = CTX_data_scene(C); - int a, values[20], layer; - - if (v3d) { - layer = (v3d->scenelock && !v3d->localvd) ? scene->layact : v3d->layact; + /* Get layers! */ + { + int a, layer_values[20]; + unsigned int _layer; + if (!layer) + layer = &_layer; + + if (RNA_struct_property_is_set(op->ptr, "layers")) { + RNA_boolean_get_array(op->ptr, "layers", layer_values); + *layer = 0; + for (a = 0; a < 20; a++) { + if (layer_values[a]) + *layer |= (1 << a); + } } else { - layer = scene->layact; - } - - for (a = 0; a < 20; a++) { - values[a] = (layer & (1 << a)); + Scene *scene = CTX_data_scene(C); + if (v3d) + *layer = (v3d->scenelock && !v3d->localvd) ? scene->layact : v3d->layact; + else + *layer = scene->layact; + for (a = 0; a < 20; a++) { + layer_values[a] = *layer & (1 << a); + } + RNA_boolean_set_array(op->ptr, "layers", layer_values); } - RNA_boolean_set_array(op->ptr, "layers", values); + /* in local view we additionally add local view layers, + * not part of operator properties */ + if (v3d && v3d->localvd) + *layer |= v3d->lay; } -} - -int ED_object_add_generic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - object_add_generic_invoke_options(C, op); - return op->type->exec(C, op); -} -int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float loc[3], float rot[3], - int *enter_editmode, unsigned int *layer, int *is_view_aligned) -{ - View3D *v3d = CTX_wm_view3d(C); - int a, layer_values[20]; - int view_align; - - *enter_editmode = FALSE; - if (RNA_struct_find_property(op->ptr, "enter_editmode") && RNA_boolean_get(op->ptr, "enter_editmode")) { - *enter_editmode = TRUE; - } + /* Location! */ + { + float _loc[3]; + if (!loc) + loc = _loc; - if (RNA_struct_property_is_set(op->ptr, "layers")) { - RNA_boolean_get_array(op->ptr, "layers", layer_values); - *layer = 0; - for (a = 0; a < 20; a++) { - if (layer_values[a]) - *layer |= (1 << a); - else - *layer &= ~(1 << a); + if (RNA_struct_property_is_set(op->ptr, "location")) { + RNA_float_get_array(op->ptr, "location", loc); + } + else { + ED_object_location_from_view(C, loc); + RNA_float_set_array(op->ptr, "location", loc); } - } - else { - /* not set, use the scenes layers */ - Scene *scene = CTX_data_scene(C); - *layer = scene->layact; } - /* in local view we additionally add local view layers, - * not part of operator properties */ - if (v3d && v3d->localvd) - *layer |= v3d->lay; - - if (RNA_struct_property_is_set(op->ptr, "rotation")) - view_align = FALSE; - else if (RNA_struct_property_is_set(op->ptr, "view_align")) - view_align = RNA_boolean_get(op->ptr, "view_align"); - else { - view_align = U.flag & USER_ADD_VIEWALIGNED; - RNA_boolean_set(op->ptr, "view_align", view_align); - } + /* Rotation! */ + { + int _is_view_aligned; + float _rot[3]; + if (!is_view_aligned) + is_view_aligned = &_is_view_aligned; + if (!rot) + rot = _rot; + + if (RNA_struct_property_is_set(op->ptr, "rotation")) + *is_view_aligned = FALSE; + else if (RNA_struct_property_is_set(op->ptr, "view_align")) + *is_view_aligned = RNA_boolean_get(op->ptr, "view_align"); + else { + *is_view_aligned = U.flag & USER_ADD_VIEWALIGNED; + RNA_boolean_set(op->ptr, "view_align", *is_view_aligned); + } - if (view_align) { - ED_object_rotation_from_view(C, rot); - RNA_float_set_array(op->ptr, "rotation", rot); + if (*is_view_aligned) { + ED_object_rotation_from_view(C, rot); + RNA_float_set_array(op->ptr, "rotation", rot); + } + else + RNA_float_get_array(op->ptr, "rotation", rot); } - else - RNA_float_get_array(op->ptr, "rotation", rot); - if (is_view_aligned) - *is_view_aligned = view_align; - - RNA_float_get_array(op->ptr, "location", loc); - - if (*layer == 0) { + if (layer && *layer == 0) { BKE_report(op->reports, RPT_ERROR, "Property 'layer' has no values set"); return 0; } @@ -405,9 +419,7 @@ void OBJECT_OT_add(wmOperatorType *ot) ot->idname = "OBJECT_OT_add"; /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = object_add_exec; - ot->poll = ED_operator_objectmode; /* flags */ @@ -420,57 +432,47 @@ void OBJECT_OT_add(wmOperatorType *ot) /********************* Add Effector Operator ********************/ -/* for effector add primitive operators */ -static Object *effector_add_type(bContext *C, wmOperator *op, int type) +/* for object add operator */ +static int effector_add_exec(bContext *C, wmOperator *op) { Object *ob; - int enter_editmode; + int type, enter_editmode; unsigned int layer; float loc[3], rot[3]; float mat[4][4]; - object_add_generic_invoke_options(C, op); - if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) - return NULL; + return OPERATOR_CANCELLED; + + type = RNA_enum_get(op->ptr, "type"); if (type == PFIELD_GUIDE) { ob = ED_object_add_type(C, OB_CURVE, loc, rot, FALSE, layer); - rename_id(&ob->id, "CurveGuide"); + if (!ob) + return OPERATOR_CANCELLED; + rename_id(&ob->id, "CurveGuide"); ((Curve *)ob->data)->flag |= CU_PATH | CU_3D; ED_object_enter_editmode(C, 0); ED_object_new_primitive_matrix(C, ob, loc, rot, mat); BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, 1)); - if (!enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA); } else { ob = ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); - rename_id(&ob->id, "Field"); + if (!ob) + return OPERATOR_CANCELLED; - switch (type) { - case PFIELD_WIND: - case PFIELD_VORTEX: - ob->empty_drawtype = OB_SINGLE_ARROW; - break; - } + rename_id(&ob->id, "Field"); + if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) + ob->empty_drawtype = OB_SINGLE_ARROW; } ob->pd = object_add_collision_fields(type); DAG_scene_sort(CTX_data_main(C), CTX_data_scene(C)); - return ob; -} - -/* for object add operator */ -static int effector_add_exec(bContext *C, wmOperator *op) -{ - if (effector_add_type(C, op, RNA_enum_get(op->ptr, "type")) == NULL) - return OPERATOR_CANCELLED; - return OPERATOR_FINISHED; } @@ -482,9 +484,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) ot->idname = "OBJECT_OT_effector_add"; /* api callbacks */ - ot->invoke = WM_menu_invoke; ot->exec = effector_add_exec; - ot->poll = ED_operator_objectmode; /* flags */ @@ -509,8 +509,6 @@ static int object_camera_add_exec(bContext *C, wmOperator *op) /* force view align for cameras */ RNA_boolean_set(op->ptr, "view_align", TRUE); - object_add_generic_invoke_options(C, op); - if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -562,8 +560,6 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; float mat[4][4]; - object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ - if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -571,7 +567,8 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) obedit = ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer); newob = 1; } - else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + else + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); @@ -587,25 +584,6 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - Object *obedit = CTX_data_edit_object(C); - uiPopupMenu *pup; - uiLayout *layout; - - object_add_generic_invoke_options(C, op); - - pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout = uiPupMenuLayout(pup); - if (!obedit || obedit->type == OB_MBALL) - uiItemsEnumO(layout, op->type->idname, "type"); - else - uiItemsEnumO(layout, "OBJECT_OT_metaball_add", "type"); - uiPupMenuEnd(C, pup); - - return OPERATOR_CANCELLED; -} - void OBJECT_OT_metaball_add(wmOperatorType *ot) { /* identifiers */ @@ -614,14 +592,15 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) ot->idname = "OBJECT_OT_metaball_add"; /* api callbacks */ - ot->invoke = object_metaball_add_invoke; + ot->invoke = WM_menu_invoke;/* object_metaball_add_invoke; */ ot->exec = object_metaball_add_exec; ot->poll = ED_operator_scene_editable; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", ""); + ot->prop = RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", ""); + ED_object_add_generic_props(ot, TRUE); } @@ -634,7 +613,6 @@ static int object_add_text_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; - object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -656,7 +634,6 @@ void OBJECT_OT_text_add(wmOperatorType *ot) ot->idname = "OBJECT_OT_text_add"; /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = object_add_text_exec; ot->poll = ED_operator_objectmode; @@ -677,7 +654,6 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; - object_add_generic_invoke_options(C, op); /* XXX these props don't get set right when only exec() is called */ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; @@ -713,7 +689,6 @@ void OBJECT_OT_armature_add(wmOperatorType *ot) ot->idname = "OBJECT_OT_armature_add"; /* api callbacks */ - ot->invoke = ED_object_add_generic_invoke; ot->exec = object_armature_add_exec; ot->poll = ED_operator_objectmode; @@ -722,6 +697,45 @@ void OBJECT_OT_armature_add(wmOperatorType *ot) ED_object_add_generic_props(ot, TRUE); } +/********************* Add Empty Operator ********************/ + +static int object_empty_add_exec(bContext *C, wmOperator *op) +{ + Object *ob; + int type = RNA_enum_get(op->ptr, "type"); + unsigned int layer; + float loc[3], rot[3]; + + if (!ED_object_add_generic_get_opts(C, op, loc, rot, NULL, &layer, NULL)) + return OPERATOR_CANCELLED; + + ob = ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); + ob->empty_drawtype = type; + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_empty_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Empty"; + ot->description = "Add an empty object to the scene"; + ot->idname = "OBJECT_OT_empty_add"; + + /* api callbacks */ + ot->invoke = WM_menu_invoke; + ot->exec = object_empty_add_exec; + ot->poll = ED_operator_objectmode; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + ot->prop = RNA_def_enum(ot->srna, "type", empty_drawtype_items, 0, "Type", ""); + + ED_object_add_generic_props(ot, FALSE); +} + /********************* Add Lamp Operator ********************/ static const char *get_lamp_defname(int type) @@ -743,12 +757,10 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) Object *ob; Lamp *la; int type = RNA_enum_get(op->ptr, "type"); - int enter_editmode; unsigned int layer; float loc[3], rot[3]; - object_add_generic_invoke_options(C, op); - if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, NULL, &layer, NULL)) return OPERATOR_CANCELLED; ob = ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer); @@ -793,12 +805,10 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) { Group *group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); - int enter_editmode; unsigned int layer; float loc[3], rot[3]; - object_add_generic_invoke_options(C, op); - if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, NULL, &layer, NULL)) return OPERATOR_CANCELLED; if (group) { @@ -834,7 +844,6 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_enum_search_invoke; ot->exec = group_instance_add_exec; - ot->poll = ED_operator_objectmode; /* flags */ @@ -852,13 +861,11 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) static int object_speaker_add_exec(bContext *C, wmOperator *op) { Object *ob; - int enter_editmode; unsigned int layer; float loc[3], rot[3]; Scene *scene = CTX_data_scene(C); - object_add_generic_invoke_options(C, op); - if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, NULL, &layer, NULL)) return OPERATOR_CANCELLED; ob = ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index b62ff676066..bb288462f0f 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -112,6 +112,7 @@ void OBJECT_OT_add_named(struct wmOperatorType *ot); void OBJECT_OT_metaball_add(struct wmOperatorType *ot); void OBJECT_OT_text_add(struct wmOperatorType *ot); void OBJECT_OT_armature_add(struct wmOperatorType *ot); +void OBJECT_OT_empty_add(struct wmOperatorType *ot); void OBJECT_OT_lamp_add(struct wmOperatorType *ot); void OBJECT_OT_effector_add(struct wmOperatorType *ot); void OBJECT_OT_camera_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index cec849efca7..181a98a8896 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -113,6 +113,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_delete); WM_operatortype_append(OBJECT_OT_text_add); WM_operatortype_append(OBJECT_OT_armature_add); + WM_operatortype_append(OBJECT_OT_empty_add); WM_operatortype_append(OBJECT_OT_lamp_add); WM_operatortype_append(OBJECT_OT_camera_add); WM_operatortype_append(OBJECT_OT_speaker_add); -- cgit v1.2.3 From 7e0d1cf65263f1906252fce3a9cd2618e9130920 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Oct 2012 13:06:36 +0000 Subject: Typo fix: Tooltip for "Offset Factor" for FollowPath constraint referred to "bone" instead of "curve" --- source/blender/makesrna/intern/rna_constraint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 770bdb68e38..f2454a2dcfb 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1243,7 +1243,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) prop = RNA_def_property(srna, "offset_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "offset_fac"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Offset Factor", "Percentage value defining target position along length of bone"); + RNA_def_property_ui_text(prop, "Offset Factor", "Percentage value defining target position along length of curve"); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE); -- cgit v1.2.3 From 72da7722dd25a8b4d2697cd4c6c3489a872c36a0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 5 Oct 2012 13:11:16 +0000 Subject: Fix #32770: iTaSC IK solver not working correct with bones that have stretch with have all rotation axes disabled. --- source/blender/ikplugin/intern/itasc_plugin.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index d88f954345f..c929c97a040 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -1172,10 +1172,8 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) switch (ikchan->jointType & ~IK_TRANSY) { case 0: // fixed bone - if (!(ikchan->jointType & IK_TRANSY)) { - joint += ":F"; - ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip); - } + joint += ":F"; + ret = arm->addSegment(joint, parent, KDL::Joint::None, 0.0, tip); break; case IK_XDOF: // RX only, get the X rotation -- cgit v1.2.3 From 5baa587a12d7f726b5ec3d937a3196fdb687b976 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Oct 2012 13:22:09 +0000 Subject: Warning indicators for animators when Auto Keying is enabled during transform Recently on the bf-funboard list, there have been some requests for clearer indications for animators that autokeying has been enabled when transforming so that corrective action can be taken sooner if this wasn't expected. This is especially important in distributed+collaborative environments where multiple artists may work on a single shot file: someone working on a shot from another animator may not be aware that autokeying was enabled, thus accidentally setting a whole bunch of extra keyframes. In this current incarnation, we display using red (not hardcoded, but using an existing theme color) a solid 1px border around the 3D view while transforming with autokeying enabled. In addition to the border, a blinking indicator (record icon + "Auto Keying On" text) appear in the top right corner, as inspired by the traditional recording indicator icons on camcorders. --- source/blender/editors/transform/transform.c | 78 ++++++++++++++++++++++++---- source/blender/editors/transform/transform.h | 2 + 2 files changed, 69 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 631418598e5..2bcbbc3a8a2 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -57,6 +57,8 @@ #include "BIF_gl.h" #include "BIF_glutil.h" +#include "BLF_api.h" + #include "BKE_nla.h" #include "BKE_bmesh.h" #include "BKE_context.h" @@ -88,12 +90,14 @@ #include "BLI_linklist.h" #include "BLI_smallhash.h" #include "BLI_array.h" +#include "PIL_time.h" +#include "UI_interface_icons.h" #include "UI_resources.h" #include "transform.h" -#include +#include // XXX: duplicated??? static void drawTransformApply(const struct bContext *C, ARegion *ar, void *arg); static int doEdgeSlide(TransInfo *t, float perc); @@ -827,7 +831,7 @@ int transformEvent(TransInfo *t, wmEvent *event) float mati[3][3] = MAT3_UNITY; char cmode = constraintModeToChar(t); int handled = 1; - + t->redraw |= handleMouseInput(t, &t->mouse, event); if (event->type == MOUSEMOVE) { @@ -1271,10 +1275,13 @@ int transformEvent(TransInfo *t, wmEvent *event) if (t->handleEvent) t->redraw |= t->handleEvent(t, event); - if (handled || t->redraw) + if (handled || t->redraw) { + t->last_update = PIL_check_seconds_timer(); return 0; - else + } + else { return OPERATOR_PASS_THROUGH; + } } int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int cent2d[2]) @@ -1557,14 +1564,63 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi drawNonPropEdge(C, t); } -#if 0 -static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), void *UNUSED(arg)) +/* just draw a little warning message in the top-right corner of the viewport to warn that autokeying is enabled */ +static void drawAutoKeyWarning(const struct bContext *C, TransInfo *t, ARegion *ar) { -// TransInfo *t = arg; -// -// drawHelpline(C, t->mval[0], t->mval[1], t); + int show_warning; + + /* red border around the viewport */ + UI_ThemeColor(TH_REDALERT); + + glBegin(GL_LINE_LOOP); + glVertex2f(1, 1); + glVertex2f(1, ar->winy-1); + glVertex2f(ar->winx-1, ar->winy-1); + glVertex2f(ar->winx-1, 1); + glEnd(); + + /* Entire warning should "blink" to catch periphery attention without being overly distracting + * much like how a traditional recording sign in the corner of a camcorder works + * + * - Blink frequency here is 0.5 secs (i.e. a compromise between epilepsy-inducing flicker + too slow to notice). + * We multiply by two to speed up the odd/even time-in-seconds = on/off toggle. + * - Always start with warning shown so that animators are more likely to notice when starting to transform + */ + show_warning = (int)(t->last_update * 2.0) & 1; + + if ((show_warning) || (t->state == TRANS_STARTING)) { + const char printable[] = "Auto Keying On"; + int xco, yco; + + xco = ar->winx - BLF_width_default(printable) - 10; + yco = ar->winy - BLF_height_default(printable) - 10; + + /* red warning text */ + UI_ThemeColor(TH_REDALERT); + BLF_draw_default_ascii(xco, ar->winy - 17, 0.0f, printable, sizeof(printable)); + + /* autokey recording icon... */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + xco -= (ICON_DEFAULT_WIDTH + 2); + UI_icon_draw(xco, yco, ICON_REC); + + glDisable(GL_BLEND); + } +} + +static void drawTransformPixel(const struct bContext *C, ARegion *ar, void *arg) +{ + TransInfo *t = arg; + Scene *scene = t->scene; + Object *ob = OBACT; + + /* draw autokeyframing hint in the corner */ + if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { + drawAutoKeyWarning(C, t, ar); + } } -#endif void saveTransform(bContext *C, TransInfo *t, wmOperator *op) { @@ -1734,7 +1790,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); - //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); + t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } else if (t->spacetype == SPACE_IMAGE) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index e645cb2fed6..40f53423d37 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -322,6 +322,8 @@ typedef struct TransInfo { float auto_values[4]; float axis[3]; float axis_orig[3]; /* TransCon can change 'axis', store the original value here */ + + double last_update; /* Time of last update (in seconds) */ void *view; struct bContext *context; /* Only valid (non null) during an operator called function. */ -- cgit v1.2.3 From b7bb1ef9b95068599d2db9f6b04222ebab788cdf Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Oct 2012 14:05:49 +0000 Subject: Whitespace edits --- source/blender/editors/animation/keyframing.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index fc2647a51f4..0454e88e320 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1587,7 +1587,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; char *path; - float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + float cfra = (float)CFRA; short success = 0; int a, index, length, all = RNA_boolean_get(op->ptr, "all"); short flag = 0; @@ -1758,20 +1758,20 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) if (ptr.id.data && ptr.data && prop) { path = RNA_path_from_ID_to_property(&ptr, prop); - + if (path) { if (all) { length = RNA_property_array_length(&ptr, prop); - + if (length) index = 0; else length = 1; } else length = 1; - + for (a = 0; a < length; a++) success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, 0); - + MEM_freeN(path); } else if (G.debug & G_DEBUG) @@ -1785,9 +1785,9 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) if (success) { /* send updates */ uiContextAnimUpdate(C); - + DAG_ids_flush_update(bmain, 0); - + /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } -- cgit v1.2.3 From b2a5f28421b73949b3267f2779bdcc72cd39d639 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Oct 2012 14:51:35 +0000 Subject: Follow Path Constraint - "Animate Path" Operator Added a convenience operator to the Follow Path constraint which adds a F-Curve for the path (or the operator's "fixed position" value if no path is assigned), with options for setting the start frame and length of motion. This makes it easier for common users to just set up a quick follow-path animation where the camera (e.g. flying around a set over certain number of frames). A key advantage of this is that it takes care of the underlying math required for setting up the generator curve accordingly (I've got some plans for making this a bit friendlier to use later). Now, animating the paths is a one-click operation, with the start and length properties able to be controlled using the operator properties. --- .../startup/bl_ui/properties_object_constraint.py | 1 + source/blender/editors/object/object_constraint.c | 127 +++++++++++++++++++++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 4 files changed, 130 insertions(+) diff --git a/release/scripts/startup/bl_ui/properties_object_constraint.py b/release/scripts/startup/bl_ui/properties_object_constraint.py index 3d671a0d1b7..fba7bd8712a 100644 --- a/release/scripts/startup/bl_ui/properties_object_constraint.py +++ b/release/scripts/startup/bl_ui/properties_object_constraint.py @@ -212,6 +212,7 @@ class ConstraintButtonsPanel(): def FOLLOW_PATH(self, context, layout, con): self.target_template(layout, con) + layout.operator("constraint.followpath_path_animate", text="Animate Path", icon='ANIM_DATA') split = layout.split() diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 1ef7c12b409..b7aadd3cc74 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -40,6 +40,7 @@ #include "BLI_dynstr.h" #include "BLI_utildefines.h" +#include "DNA_anim_types.h" #include "DNA_constraint_types.h" #include "DNA_curve_types.h" #include "DNA_scene_types.h" @@ -51,6 +52,7 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_depsgraph.h" +#include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_main.h" #include "BKE_object.h" @@ -71,6 +73,7 @@ #include "ED_object.h" #include "ED_armature.h" +#include "ED_keyframing.h" #include "ED_screen.h" #include "UI_interface.h" @@ -877,6 +880,130 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot) edit_constraint_properties(ot); } +/* --------------- Follow Path Constraint ------------------ */ + +static int followpath_path_animate_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_active_context(C); + bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_FOLLOWPATH); + bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL; + + bAction *act = NULL; + FCurve *fcu = NULL; + int sfra = RNA_int_get(op->ptr, "frame_start"); + int len = RNA_int_get(op->ptr, "length"); + float standardRange = 1.0; + + /* nearly impossible sanity check */ + if (data == NULL) { + BKE_report(op->reports, RPT_ERROR, "Follow Path constraint not found"); + return OPERATOR_CANCELLED; + } + + /* add F-Curve as appropriate */ + if (data->tar) { + Curve *cu = (Curve *)data->tar->data; + + if ( ELEM(NULL, cu->adt, cu->adt->action) || + (list_find_fcurve(&cu->adt->action->curves, "eval_time", 0) == NULL)) + { + /* create F-Curve for path animation */ + act = verify_adt_action(&cu->id, 1); + fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1); + + /* standard vertical range - 1:1 = 100 frames */ + standardRange = 100.0f; + } + else { + /* path anim exists already - abort for now as this may well be what was intended */ + BKE_report(op->reports, RPT_WARNING, "Path is already animated"); + return OPERATOR_CANCELLED; + } + } + else { + /* animate constraint's "fixed offset" */ + PointerRNA ptr; + PropertyRNA *prop; + char *path; + + /* get RNA pointer to constraint's "offset_factor" property - to build RNA path */ + RNA_pointer_create(&ob->id, &RNA_FollowPathConstraint, con, &ptr); + prop = RNA_struct_find_property(&ptr, "offset_factor"); + + path = RNA_path_from_ID_to_property(&ptr, prop); + + /* create F-Curve for constraint */ + act = verify_adt_action(&ob->id, 1); + fcu = verify_fcurve(act, NULL, NULL, path, 0, 1); + + /* standard vertical range - 0.0 to 1.0 */ + standardRange = 1.0f; + + /* enable "Use Fixed Position" so that animating this has effect */ + data->followflag |= FOLLOWPATH_STATIC; + + /* path needs to be freed */ + if (path) + MEM_freeN(path); + } + + /* setup dummy 'generator' modifier here to get 1-1 correspondence still working + * and define basic slope of this curve based on the properties + */ + if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { + FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); + FMod_Generator *gen = fcm->data; + + /* Assume that we have the following equation: + * y = Ax + B + * 1 0 <-- coefficients array indices + */ + float A = standardRange / (float)(len); + float B = (float)(-sfra) * A; + + gen->coefficients[1] = A; + gen->coefficients[0] = B; + } + + /* updates... */ + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); + return OPERATOR_FINISHED; +} + +static int followpath_path_animate_invoke(bContext *C, wmOperator *op, wmEvent *evt) +{ + /* hook up invoke properties for figuring out which constraint we're dealing with */ + if (edit_constraint_invoke_properties(C, op)) { + return followpath_path_animate_exec(C, op); + } + else { + return OPERATOR_CANCELLED; + } +} + +void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Auto Animate Path"; + ot->idname = "CONSTRAINT_OT_followpath_path_animate"; + ot->description = "Add default animation for path used by constraint if it isn't animated already"; + + /* callbacks */ + ot->invoke = followpath_path_animate_invoke; + ot->exec = followpath_path_animate_exec; + ot->poll = edit_constraint_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + edit_constraint_properties(ot); + RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame", + "First frame of path animation", MINAFRAME, MAXFRAME); + RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length", + "Number of frames that path animation should take", 0, MAXFRAME); +} + /* ------------- Object Solver Constraint ------------------ */ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index bb288462f0f..4c83f6ef2ce 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -194,6 +194,7 @@ void CONSTRAINT_OT_childof_set_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_objectsolver_set_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_objectsolver_clear_inverse(struct wmOperatorType *ot); +void CONSTRAINT_OT_followpath_path_animate(struct wmOperatorType *ot); /* object_vgroup.c */ void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 181a98a8896..fa40d579e2b 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -169,6 +169,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse); WM_operatortype_append(CONSTRAINT_OT_objectsolver_set_inverse); WM_operatortype_append(CONSTRAINT_OT_objectsolver_clear_inverse); + WM_operatortype_append(CONSTRAINT_OT_followpath_path_animate); WM_operatortype_append(OBJECT_OT_vertex_group_add); WM_operatortype_append(OBJECT_OT_vertex_group_remove); -- cgit v1.2.3 From b67d75fad29ce2dfa4ef0aee271b6e86518a3d6b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 5 Oct 2012 14:54:32 +0000 Subject: Fix generated texture coordinate issue after "from dupli" option was added. --- intern/cycles/render/nodes.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index b878bdee3c7..8173f5d0af2 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1644,6 +1644,8 @@ TextureCoordinateNode::TextureCoordinateNode() add_output("Camera", SHADER_SOCKET_POINT); add_output("Window", SHADER_SOCKET_POINT); add_output("Reflection", SHADER_SOCKET_NORMAL); + + from_dupli = false; } void TextureCoordinateNode::attributes(AttributeRequestSet *attributes) -- cgit v1.2.3 From d3cdaca648740ec6e11aebecc243442aa5ae7142 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Oct 2012 14:56:04 +0000 Subject: Code cleanup * Added/fixed some comments * Swapped order that invoke/exec calls are defined in the operator definitions to reflect flow better --- source/blender/editors/object/object_constraint.c | 52 ++++++++++++++++------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index b7aadd3cc74..6acb5c63365 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -658,12 +658,15 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot) ot->idname = "CONSTRAINT_OT_stretchto_reset"; ot->description = "Reset original length of bone for Stretch To Constraint"; - ot->exec = stretchto_reset_exec; + /* callbacks */ ot->invoke = stretchto_reset_invoke; + ot->exec = stretchto_reset_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } @@ -701,12 +704,15 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) ot->idname = "CONSTRAINT_OT_limitdistance_reset"; ot->description = "Reset limiting distance for Limit Distance Constraint"; - ot->exec = limitdistance_reset_exec; + /* callbacks */ ot->invoke = limitdistance_reset_invoke; + ot->exec = limitdistance_reset_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } @@ -827,12 +833,15 @@ void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot) ot->idname = "CONSTRAINT_OT_childof_set_inverse"; ot->description = "Set inverse correction for ChildOf constraint"; - ot->exec = childof_set_inverse_exec; + /* callbacks */ ot->invoke = childof_set_inverse_invoke; + ot->exec = childof_set_inverse_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } @@ -871,12 +880,15 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot) ot->idname = "CONSTRAINT_OT_childof_clear_inverse"; ot->description = "Clear inverse correction for ChildOf constraint"; - ot->exec = childof_clear_inverse_exec; + /* callbacks */ ot->invoke = childof_clear_inverse_invoke; + ot->exec = childof_clear_inverse_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } @@ -1041,13 +1053,16 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) ot->name = "Set Inverse"; ot->idname = "CONSTRAINT_OT_objectsolver_set_inverse"; ot->description = "Set inverse correction for ObjectSolver constraint"; - - ot->exec = objectsolver_set_inverse_exec; + + /* callbacks */ ot->invoke = objectsolver_set_inverse_invoke; + ot->exec = objectsolver_set_inverse_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } @@ -1084,13 +1099,16 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) ot->name = "Clear Inverse"; ot->idname = "CONSTRAINT_OT_objectsolver_clear_inverse"; ot->description = "Clear inverse correction for ObjectSolver constraint"; - - ot->exec = objectsolver_clear_inverse_exec; + + /* callbacks */ ot->invoke = objectsolver_clear_inverse_invoke; + ot->exec = objectsolver_clear_inverse_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } @@ -1110,13 +1128,14 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) void ED_object_constraint_update(Object *ob) { - if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); object_test_constraints(ob); - 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); + 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); } void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *ob) @@ -1133,6 +1152,7 @@ static int constraint_poll(bContext *C) return (ptr.id.data && ptr.data); } + static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); @@ -1147,12 +1167,12 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) constraints_set_active(lb, NULL); ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */ - + /* ITASC needs to be rebuilt once a constraint is removed [#26920] */ if (is_ik) { BIK_clear_data(ob->pose); } - + /* notifiers */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); @@ -1179,6 +1199,7 @@ void CONSTRAINT_OT_delete(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + static int constraint_move_down_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); @@ -1208,7 +1229,6 @@ static int constraint_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNU return OPERATOR_CANCELLED; } - void CONSTRAINT_OT_move_down(wmOperatorType *ot) { /* identifiers */ @@ -1217,12 +1237,14 @@ void CONSTRAINT_OT_move_down(wmOperatorType *ot) ot->description = "Move constraint down in constraint stack"; /* callbacks */ - ot->exec = constraint_move_down_exec; ot->invoke = constraint_move_down_invoke; + ot->exec = constraint_move_down_exec; ot->poll = edit_constraint_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ edit_constraint_properties(ot); } -- cgit v1.2.3 From db70bfc206538a9582e17a3eedcd1923e3f8d2c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Oct 2012 15:44:11 +0000 Subject: code cleanup: use functions to initialize selection user data structs, use radius-squared for circle select comparisons. edge_fully_inside_rect() & edge_inside_rect() args were shorts when all callers were passing ints. --- source/blender/blenlib/BLI_lasso.h | 6 +- source/blender/blenlib/intern/lasso.c | 8 +- source/blender/editors/include/ED_mesh.h | 2 +- source/blender/editors/include/ED_particle.h | 2 +- source/blender/editors/include/ED_view3d.h | 3 + source/blender/editors/mask/mask_select.c | 4 +- source/blender/editors/mesh/editmesh_select.c | 4 +- source/blender/editors/object/object_constraint.c | 2 +- source/blender/editors/physics/particle_edit.c | 2 +- .../blender/editors/space_clip/tracking_select.c | 4 +- source/blender/editors/space_node/node_select.c | 4 +- .../blender/editors/space_view3d/view3d_select.c | 228 +++++++++++---------- source/blender/editors/transform/transform.c | 6 +- source/blender/editors/uvedit/uvedit_ops.c | 4 +- source/blender/windowmanager/WM_api.h | 2 +- source/blender/windowmanager/intern/wm_operators.c | 5 +- 16 files changed, 156 insertions(+), 130 deletions(-) diff --git a/source/blender/blenlib/BLI_lasso.h b/source/blender/blenlib/BLI_lasso.h index 85a000b000c..a7e90a51e86 100644 --- a/source/blender/blenlib/BLI_lasso.h +++ b/source/blender/blenlib/BLI_lasso.h @@ -34,8 +34,8 @@ struct rcti; -void BLI_lasso_boundbox(struct rcti *rect, int mcords[][2], short moves); -int BLI_lasso_is_point_inside(int mcords[][2], short moves, const int sx, const int sy, const int error_value); -int BLI_lasso_is_edge_inside(int mcords[][2], short moves, int x0, int y0, int x1, int y1, const int error_value); +void BLI_lasso_boundbox(struct rcti *rect, const int mcords[][2], const short moves); +int BLI_lasso_is_point_inside(const int mcords[][2], const short moves, const int sx, const int sy, const int error_value); +int BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, int x0, int y0, int x1, int y1, const int error_value); #endif diff --git a/source/blender/blenlib/intern/lasso.c b/source/blender/blenlib/intern/lasso.c index 7df4da80e16..5cd8bb813a1 100644 --- a/source/blender/blenlib/intern/lasso.c +++ b/source/blender/blenlib/intern/lasso.c @@ -37,7 +37,7 @@ #include "BLI_lasso.h" /* own include */ -void BLI_lasso_boundbox(rcti *rect, int mcords[][2], short moves) +void BLI_lasso_boundbox(rcti *rect, const int mcords[][2], const short moves) { short a; @@ -53,14 +53,14 @@ void BLI_lasso_boundbox(rcti *rect, int mcords[][2], short moves) } -int BLI_lasso_is_point_inside(int mcords[][2], short moves, +int BLI_lasso_is_point_inside(const int mcords[][2], const short moves, const int sx, const int sy, const int error_value) { /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */ float angletot = 0.0, dot, ang, cross, fp1[2], fp2[2]; int a; - int *p1, *p2; + const int *p1, *p2; if (sx == error_value) { return 0; @@ -100,7 +100,7 @@ int BLI_lasso_is_point_inside(int mcords[][2], short moves, } /* edge version for lasso select. we assume boundbox check was done */ -int BLI_lasso_is_edge_inside(int mcords[][2], short moves, +int BLI_lasso_is_edge_inside(const int mcords[][2], const short moves, int x0, int y0, int x1, int y1, const int error_value) { diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 62818612509..028b5db6beb 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -138,7 +138,7 @@ int EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, sh int EDBM_backbuf_check(unsigned int index); void EDBM_backbuf_free(void); -int EDBM_backbuf_border_mask_init(struct ViewContext *vc, int mcords[][2], short tot, +int EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); int EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index 0076b08da99..dee97c7882a 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -61,7 +61,7 @@ void PE_update_object(struct Scene *scene, struct Object *ob, int useflag); int PE_mouse_particles(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); int PE_border_select(struct bContext *C, struct rcti *rect, int select, int extend); int PE_circle_select(struct bContext *C, int selecting, const int mval[2], float rad); -int PE_lasso_select(struct bContext *C, int mcords[][2], short moves, short extend, short select); +int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, short extend, short select); void PE_deselect_all_visible(struct PTCacheEdit *edit); /* undo */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index acc53861e95..8161dd23b8e 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -40,6 +40,7 @@ struct BPoint; struct BezTriple; struct BezTriple; struct BoundBox; +struct EditBone; struct ImBuf; struct MVert; struct Main; @@ -170,6 +171,8 @@ void mesh_foreachScreenEdge(struct ViewContext *vc, void (*func)(void *userData, void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, struct BMFace *efa, int x, int y, int index), void *userData); void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData); void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); +void armature_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1), void *userData); + void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 55bad39f4f2..69cfdf4e51b 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -485,7 +485,7 @@ void MASK_OT_select_border(wmOperatorType *ot) WM_operator_properties_gesture_border(ot, TRUE); } -static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short select) +static int do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, short select) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -549,7 +549,7 @@ static int do_lasso_select_mask(bContext *C, int mcords[][2], short moves, short static int clip_lasso_select_exec(bContext *C, wmOperator *op) { int mcords_tot; - int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { short select; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index abc8cb6b327..801c9382c26 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -131,7 +131,7 @@ unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0; /* set in dr static char *selbuf = NULL; /* opengl doesn't support concave... */ -static void draw_triangulated(int mcords[][2], short tot) +static void draw_triangulated(const int mcords[][2], const short tot) { ListBase lb = {NULL, NULL}; DispList *dl; @@ -227,7 +227,7 @@ void EDBM_backbuf_free(void) * - grab again and compare * returns 'OK' */ -int EDBM_backbuf_border_mask_init(ViewContext *vc, int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) +int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) { unsigned int *dr, *drm; struct ImBuf *buf, *bufmask; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 6acb5c63365..56f2426b1b0 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -982,7 +982,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int followpath_path_animate_invoke(bContext *C, wmOperator *op, wmEvent *evt) +static int followpath_path_animate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { /* hook up invoke properties for figuring out which constraint we're dealing with */ if (edit_constraint_invoke_properties(C, op)) { diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index b03c637e67c..ee2b5e08520 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1633,7 +1633,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) /************************ lasso select operator ************************/ -int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, short select) +int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short extend, short select) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 507e492497d..4f62d3fdc2f 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -413,7 +413,7 @@ void CLIP_OT_select_border(wmOperatorType *ot) /********************** lasso select operator *********************/ -static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select) +static int do_lasso_select_marker(bContext *C, const int mcords[][2], const short moves, short select) { SpaceClip *sc = CTX_wm_space_clip(C); ARegion *ar = CTX_wm_region(C); @@ -469,7 +469,7 @@ static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, sho static int clip_lasso_select_exec(bContext *C, wmOperator *op) { int mcords_tot; - int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { short select; diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index f7757ce49b4..b0916a50c37 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -539,7 +539,7 @@ void NODE_OT_select_border(wmOperatorType *ot) /* ****** Lasso Select ****** */ -static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short select) +static int do_lasso_select_node(bContext *C, const int mcords[][2], short moves, short select) { SpaceNode *snode = CTX_wm_space_node(C); bNode *node; @@ -585,7 +585,7 @@ static int do_lasso_select_node(bContext *C, int mcords[][2], short moves, short static int node_lasso_select_exec(bContext *C, wmOperator *op) { int mcords_tot; - int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { short select; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 926c19df95a..a9eee92c442 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -256,10 +256,33 @@ static void edbm_backbuf_check_and_select_tfaces(Mesh *me, int select) typedef struct LassoSelectUserData { ViewContext *vc; - rcti *rect; - int (*mcords)[2], moves, select, pass, done; + const rcti *rect; + const int (*mcords)[2]; + int moves; + int select; + + /* runtime */ + int pass; + int is_done; + int is_change; } LassoSelectUserData; +static void view3d_userdata_lassoselect_init(LassoSelectUserData *r_data, + ViewContext *vc, const rcti *rect, const int (*mcords)[2], + const int moves, const int select) +{ + r_data->vc = vc; + r_data->rect = rect; + r_data->mcords = mcords; + r_data->moves = moves; + r_data->select = select; + + /* runtime */ + r_data->pass = 0; + r_data->is_done = FALSE; + r_data->is_change = FALSE; +} + static int view3d_selectable_data(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -290,12 +313,12 @@ static int view3d_selectable_data(bContext *C) /* helper also for borderselect */ -static int edge_fully_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) +static int edge_fully_inside_rect(const rcti *rect, int x1, int y1, int x2, int y2) { return BLI_rcti_isect_pt(rect, x1, y1) && BLI_rcti_isect_pt(rect, x2, y2); } -static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) +static int edge_inside_rect(const rcti *rect, int x1, int y1, int x2, int y2) { int d1, d2, d3, d4; @@ -323,7 +346,7 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) /* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) * and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK */ -static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], short moves, short select) +static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves, short select) { bPoseChannel *pchan; bArmature *arm = ob->data; @@ -390,7 +413,7 @@ static void object_deselect_all_visible(Scene *scene, View3D *v3d) } } -static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], const short moves, short extend, short select) { Base *base; @@ -434,7 +457,7 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, IS_CLIPPED)) { BM_edge_select_set(data->vc->em->bm, eed, data->select); - data->done = TRUE; + data->is_done = TRUE; } } else { @@ -455,7 +478,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int } } -static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { LassoSelectUserData data; ToolSettings *ts = vc->scene->toolsettings; @@ -467,13 +490,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, /* set editmesh */ vc->em = BMEdit_FromObject(vc->obedit); - data.vc = vc; - data.rect = ▭ - data.mcords = mcords; - data.moves = moves; - data.select = select; - data.done = FALSE; - data.pass = 0; + view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); if (extend == 0 && select) EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT); @@ -497,7 +514,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, data.pass = 0; mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF); - if (data.done == 0) { + if (data.is_done == 0) { data.pass = 1; mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_CLIP_TEST_OFF); } @@ -549,15 +566,11 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP } } -static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { LassoSelectUserData data; - /* set vc->editnurb */ - data.vc = vc; - data.mcords = mcords; - data.moves = moves; - data.select = select; + view3d_userdata_lassoselect_init(&data, vc, NULL, mcords, moves, select); if (extend == 0 && select) CU_deselect_all(vc->obedit); @@ -574,14 +587,11 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } -static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { LassoSelectUserData data; - /* set editdata in vc */ - data.mcords = mcords; - data.moves = moves; - data.select = select; + view3d_userdata_lassoselect_init(&data, vc, NULL, mcords, moves, select); if (extend == 0 && select) ED_setflagsLatt(vc->obedit, 0); @@ -590,7 +600,7 @@ static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short move lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data); } -static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { bArmature *arm = vc->obedit->data; EditBone *ebone; @@ -656,7 +666,7 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov } -static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { MetaBall *mb = (MetaBall *)vc->obedit->data; MetaElem *ml; @@ -742,7 +752,7 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int return OPERATOR_FINISHED; } -static void do_lasso_select_paintvert(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { Object *ob = vc->obact; Mesh *me = ob ? ob->data : NULL; @@ -764,7 +774,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, int mcords[][2], short mo paintvert_flush_flags(ob); } -static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { Object *ob = vc->obact; Mesh *me = ob ? ob->data : NULL; @@ -819,7 +829,9 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) } #endif -static void view3d_lasso_select(bContext *C, ViewContext *vc, int mcords[][2], short moves, short extend, short select) +static void view3d_lasso_select(bContext *C, ViewContext *vc, + const int mcords[][2], short moves, + short extend, short select) { Object *ob = CTX_data_active_object(C); @@ -870,7 +882,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) { ViewContext vc; int mcords_tot; - int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { short extend, select; @@ -1553,19 +1565,37 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese typedef struct BoxSelectUserData { ViewContext *vc; - rcti *rect; - int select, pass, done; + const rcti *rect; + int select; + + /* runtime */ + int pass; + int is_done; + int is_change; } BoxSelectUserData; -int edge_inside_circle(int centx, int centy, int rad, int x1, int y1, int x2, int y2) +static void view3d_userdata_boxselect_init(BoxSelectUserData *r_data, + ViewContext *vc, const rcti *rect, const int select) +{ + r_data->vc = vc; + r_data->rect = rect; + r_data->select = select; + + /* runtime */ + r_data->pass = 0; + r_data->is_done = FALSE; + r_data->is_change = FALSE; +} + +int edge_inside_circle(int centx, int centy, int radius, int x1, int y1, int x2, int y2) { - int radsq = rad * rad; + int radius_squared = radius * radius; /* check points in circle itself */ - if ((x1 - centx) * (x1 - centx) + (y1 - centy) * (y1 - centy) <= radsq) { + if ((x1 - centx) * (x1 - centx) + (y1 - centy) * (y1 - centy) <= radius_squared) { return TRUE; } - else if ((x2 - centx) * (x2 - centx) + (y2 - centy) * (y2 - centy) <= radsq) { + else if ((x2 - centx) * (x2 - centx) + (y2 - centy) * (y2 - centy) <= radius_squared) { return TRUE; } else { @@ -1573,7 +1603,7 @@ int edge_inside_circle(int centx, int centy, int rad, int x1, int y1, int x2, in const float v1[2] = {x1, y1}; const float v2[2] = {x2, y2}; /* pointdistline */ - if (dist_squared_to_line_segment_v2(cent, v1, v2) < (float)radsq) { + if (dist_squared_to_line_segment_v2(cent, v1, v2) < (float)radius_squared) { return TRUE; } } @@ -1617,9 +1647,7 @@ static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int exte { BoxSelectUserData data; - data.vc = vc; - data.rect = rect; - data.select = select; + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == 0 && select) CU_deselect_all(vc->obedit); @@ -1642,9 +1670,7 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int ex { BoxSelectUserData data; - data.vc = vc; - data.rect = rect; - data.select = select; + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == 0 && select) ED_setflagsLatt(vc->obedit, 0); @@ -1671,7 +1697,7 @@ static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0 if (data->pass == 0) { if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) { BM_edge_select_set(data->vc->em->bm, eed, data->select); - data->done = TRUE; + data->is_done = TRUE; } } else { @@ -1695,11 +1721,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten ToolSettings *ts = vc->scene->toolsettings; int bbsel; - data.vc = vc; - data.rect = rect; - data.select = select; - data.pass = 0; - data.done = FALSE; + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == 0 && select) EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT); @@ -1724,7 +1746,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten data.pass = 0; mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_CLIP_TEST_OFF); - if (data.done == 0) { + if (data.is_done == 0) { data.pass = 1; mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_CLIP_TEST_OFF); } @@ -2182,15 +2204,32 @@ typedef struct CircleSelectUserData { short select; int mval[2]; float radius; + float radius_squared; + + /* runtime */ + int is_change; } CircleSelectUserData; +static void view3d_userdata_circleselect_init(CircleSelectUserData *r_data, + ViewContext *vc, const int select, const int mval[2], const float rad) +{ + r_data->vc = vc; + r_data->select = select; + copy_v2_v2_int(r_data->mval, mval); + r_data->radius = rad; + r_data->radius_squared = rad * rad; + + /* runtime */ + r_data->is_change = FALSE; +} + static void mesh_circle_doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index)) { CircleSelectUserData *data = userData; - int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx * mx + my * my); + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; - if (r <= data->radius) { + if (len_squared_v2(delta) <= data->radius_squared) { BM_vert_select_set(data->vc->em->bm, eve, data->select); } } @@ -2205,10 +2244,10 @@ static void mesh_circle_doSelectEdge(void *userData, BMEdge *eed, int x0, int y0 static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index)) { CircleSelectUserData *data = userData; - int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx * mx + my * my); - - if (r <= data->radius) { + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; + + if (len_squared_v2(delta) <= data->radius_squared) { BM_face_select_set(data->vc->em->bm, efa, data->select); } } @@ -2224,11 +2263,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f vc->em = BMEdit_FromObject(vc->obedit); - data.vc = vc; - data.select = select; - data.mval[0] = mval[0]; - data.mval[1] = mval[1]; - data.radius = rad; + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); if (ts->selectmode & SCE_SELECT_VERTEX) { if (bbsel) { @@ -2299,12 +2334,13 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { CircleSelectUserData *data = userData; - int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx * mx + my * my); Object *obedit = data->vc->obedit; Curve *cu = (Curve *)obedit->data; - if (r <= data->radius) { + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; + + if (len_squared_v2(delta) <= data->radius_squared) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); @@ -2342,6 +2378,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval data.mval[1] = mval[1]; data.radius = rad; data.vc = vc; + data.is_change = FALSE; ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ nurbs_foreachScreenVert(vc, nurbscurve_circle_doSelect, &data); @@ -2351,10 +2388,10 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y) { CircleSelectUserData *data = userData; - int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx * mx + my * my); + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; - if (r <= data->radius) { + if (len_squared_v2(delta) <= data->radius_squared) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } @@ -2362,12 +2399,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2] { CircleSelectUserData data; - /* set vc-> edit data */ - - data.select = select; - data.mval[0] = mval[0]; - data.mval[1] = mval[1]; - data.radius = rad; + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ lattice_foreachScreenVert(vc, latticecurve_circle_doSelect, &data); @@ -2378,10 +2410,10 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2] static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { CircleSelectUserData *data = userData; - int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx * mx + my * my); - - if (r <= data->radius) { + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; + + if (len_squared_v2(delta) <= data->radius_squared) { if (data->select) pchan->bone->flag |= BONE_SELECTED; else @@ -2396,13 +2428,8 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f bArmature *arm = vc->obact->data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; - int change = FALSE; - /* set vc->edit data */ - data.select = select; - data.mval[0] = mval[0]; - data.mval[1] = mval[1]; - data.radius = rad; + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ @@ -2446,14 +2473,14 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f pchan->bone->flag |= BONE_SELECTED; else pchan->bone->flag &= ~BONE_SELECTED; - change = TRUE; + data.is_change = TRUE; } - change |= is_point_done; + data.is_change |= is_point_done; } } - if (change) { + if (data.is_change) { WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obact); } } @@ -2461,10 +2488,10 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head) { CircleSelectUserData *data = userData; - int mx = x - data->mval[0], my = y - data->mval[1]; - float r = sqrt(mx * mx + my * my); + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; - if (r <= data->radius) { + if (len_squared_v2(delta) <= data->radius_squared) { if (head) { if (data->select) ebone->flag |= BONE_ROOTSEL; @@ -2486,13 +2513,8 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 CircleSelectUserData data; bArmature *arm = vc->obedit->data; EditBone *ebone; - int change = FALSE; - - /* set vc->edit data */ - data.select = select; - data.mval[0] = mval[0]; - data.mval[1] = mval[1]; - data.radius = rad; + + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -2539,14 +2561,14 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - change = TRUE; + data.is_change = TRUE; } - change |= is_point_done; + data.is_change |= is_point_done; } } - if (change) { + if (data.is_change) { ED_armature_sync_selection(arm->edbo); ED_armature_validate_active(arm); WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 2bcbbc3a8a2..be568fcb9d8 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1565,7 +1565,7 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi } /* just draw a little warning message in the top-right corner of the viewport to warn that autokeying is enabled */ -static void drawAutoKeyWarning(const struct bContext *C, TransInfo *t, ARegion *ar) +static void drawAutoKeyWarning(TransInfo *t, ARegion *ar) { int show_warning; @@ -1610,7 +1610,7 @@ static void drawAutoKeyWarning(const struct bContext *C, TransInfo *t, ARegion * } } -static void drawTransformPixel(const struct bContext *C, ARegion *ar, void *arg) +static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, void *arg) { TransInfo *t = arg; Scene *scene = t->scene; @@ -1618,7 +1618,7 @@ static void drawTransformPixel(const struct bContext *C, ARegion *ar, void *arg) /* draw autokeyframing hint in the corner */ if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { - drawAutoKeyWarning(C, t, ar); + drawAutoKeyWarning(t, ar); } } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 70f2bf70ec8..f732808fa59 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2745,7 +2745,7 @@ static void UV_OT_circle_select(wmOperatorType *ot) /* ******************** lasso select operator **************** */ -static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, short select) +static int do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short moves, short select) { Image *ima = CTX_data_edit_image(C); ARegion *ar = CTX_wm_region(C); @@ -2819,7 +2819,7 @@ static int do_lasso_select_mesh_uv(bContext *C, int mcords[][2], short moves, sh static int uv_lasso_select_exec(bContext *C, wmOperator *op) { int mcords_tot; - int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); + const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { short select; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index ac05331095b..e7b7f679ce3 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -273,7 +273,7 @@ int WM_gesture_lines_cancel(struct bContext *C, struct wmOperator *op); int WM_gesture_lasso_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_lasso_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_lasso_cancel(struct bContext *C, struct wmOperator *op); -int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2]; +const int (*WM_gesture_lasso_path_to_array(struct bContext *C, struct wmOperator *op, int *mcords_tot))[2]; int WM_gesture_straightline_invoke(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_straightline_modal(struct bContext *C, struct wmOperator *op, struct wmEvent *event); int WM_gesture_straightline_cancel(struct bContext *C, struct wmOperator *op); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 313fc0a819e..9de3c15d70f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2727,7 +2727,7 @@ int WM_gesture_lines_cancel(bContext *C, wmOperator *op) * * caller must free. */ -int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *mcords_tot))[2] +const int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *mcords_tot))[2] { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "path"); int (*mcords)[2] = NULL; @@ -2757,7 +2757,8 @@ int (*WM_gesture_lasso_path_to_array(bContext *UNUSED(C), wmOperator *op, int *m *mcords_tot = 0; } - return mcords; + /* cast for 'const' */ + return (const int (*)[2])mcords; } #if 0 -- cgit v1.2.3 From 657fc4f4742bf7b01d613ac8a5989eddadc151a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Oct 2012 15:48:39 +0000 Subject: code cleanup: de-duplicate enum. --- source/blender/editors/object/object_add.c | 15 +-------------- source/blender/makesrna/RNA_enum_types.h | 1 + source/blender/makesrna/intern/rna_object.c | 29 +++++++++++++++-------------- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f6a7a6d6f17..43a32cd662e 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -139,19 +139,6 @@ static EnumPropertyItem field_type_items[] = { {0, NULL, 0, NULL, NULL} }; -/* Copy from rna_object.c */ -static EnumPropertyItem empty_drawtype_items[] = { - {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, - {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, - {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, - {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, - {OB_CUBE, "CUBE", 0, "Cube", ""}, - {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, - {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, - {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, - {0, NULL, 0, NULL, NULL} -}; - /************************** Exported *****************************/ void ED_object_location_from_view(bContext *C, float loc[3]) @@ -731,7 +718,7 @@ void OBJECT_OT_empty_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", empty_drawtype_items, 0, "Type", ""); + ot->prop = RNA_def_enum(ot->srna, "type", object_empty_drawtype_items, 0, "Type", ""); ED_object_add_generic_props(ot, FALSE); } diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index b651d4d5e5c..0f9a00de7b6 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -38,6 +38,7 @@ extern EnumPropertyItem DummyRNA_NULL_items[]; extern EnumPropertyItem DummyRNA_DEFAULT_items[]; extern EnumPropertyItem object_mode_items[]; +extern EnumPropertyItem object_empty_drawtype_items[]; extern EnumPropertyItem metaelem_type_items[]; extern EnumPropertyItem proportional_falloff_items[]; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 758b433b1cb..0b8afef0364 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -69,6 +69,19 @@ EnumPropertyItem object_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem object_empty_drawtype_items[] = { + {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, + {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, + {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, + {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {OB_CUBE, "CUBE", 0, "Cube", ""}, + {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, + {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, + {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, + {0, NULL, 0, NULL, NULL} +}; + + static EnumPropertyItem parent_type_items[] = { {PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"}, {PARCURVE, "CURVE", 0, "Curve", "The object is parented to a curve"}, @@ -80,7 +93,7 @@ static EnumPropertyItem parent_type_items[] = { {PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"}, {0, NULL, 0, NULL, NULL} }; - + static EnumPropertyItem collision_bounds_items[] = { {OB_BOUND_BOX, "BOX", 0, "Box", ""}, {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, @@ -1874,18 +1887,6 @@ static void rna_def_object(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - - static EnumPropertyItem empty_drawtype_items[] = { - {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, - {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, - {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, - {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, - {OB_CUBE, "CUBE", 0, "Cube", ""}, - {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, - {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, - {OB_EMPTY_IMAGE, "IMAGE", 0, "Image", ""}, - {0, NULL, 0, NULL, NULL} - }; static EnumPropertyItem track_items[] = { {OB_POSX, "POS_X", 0, "+X", ""}, @@ -2267,7 +2268,7 @@ static void rna_def_object(BlenderRNA *brna) /* empty */ prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype"); - RNA_def_property_enum_items(prop, empty_drawtype_items); + RNA_def_property_enum_items(prop, object_empty_drawtype_items); RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); -- cgit v1.2.3 From 292e8e7e00af8c3efb9498d45c275ce9b90dca69 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Oct 2012 17:07:02 +0000 Subject: add armature_foreachScreenBone(), use for lasso and circle select. also add boundbox checking for lasso select. --- source/blender/editors/space_view3d/drawobject.c | 46 +++++ .../blender/editors/space_view3d/view3d_select.c | 193 ++++++++++----------- 2 files changed, 142 insertions(+), 97 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 1d773f5db9e..5ea0413ef71 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -101,6 +101,7 @@ #include "ED_sculpt.h" #include "ED_types.h" #include "ED_curve.h" /* for curve_editnurbs */ +#include "ED_armature.h" #include "UI_resources.h" @@ -2219,6 +2220,51 @@ void nurbs_foreachScreenVert( } } +/* ED_view3d_init_mats_rv3d must be called first */ +void armature_foreachScreenBone( + struct ViewContext *vc, + void (*func)(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1), + void *userData) +{ + bArmature *arm = vc->obedit->data; + EditBone *ebone; + + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (EBONE_VISIBLE(arm, ebone)) { + int screen_co_a[2], screen_co_b[2]; + int points_proj_tot = 0; + + /* project head location to screenspace */ + if (ED_view3d_project_int_object(vc->ar, ebone->head, screen_co_a, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + points_proj_tot++; + } + else { + screen_co_a[0] = IS_CLIPPED; /* weak */ + /* screen_co_a[1]: intentionally dont set this so we get errors on misuse */ + } + + /* project tail location to screenspace */ + if (ED_view3d_project_int_object(vc->ar, ebone->tail, screen_co_b, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + points_proj_tot++; + } + else { + screen_co_b[0] = IS_CLIPPED; /* weak */ + /* screen_co_b[1]: intentionally dont set this so we get errors on misuse */ + } + + if (points_proj_tot) { /* at least one point's projection worked */ + func(userData, ebone, + screen_co_a[0], screen_co_a[1], + screen_co_b[0], screen_co_b[1]); + } + } + } +} + /* ************** DRAW MESH ****************** */ /* First section is all the "simple" draw routines, diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index a9eee92c442..ab0c6a2edc8 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -600,65 +600,70 @@ static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], shor lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data); } -static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1) { - bArmature *arm = vc->obedit->data; - EditBone *ebone; - int change = FALSE; - - if (extend == 0 && select) - ED_armature_deselect_all_visible(vc->obedit); - - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - - /* set editdata in vc */ - - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - if (EBONE_SELECTABLE(arm, ebone)) { - int screen_co_a[2], screen_co_b[2]; - int is_point_done = FALSE; - int points_proj_tot = 0; + LassoSelectUserData *data = userData; + bArmature *arm = data->vc->obedit->data; - /* project head location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, ebone->head, screen_co_a, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - points_proj_tot++; - if (BLI_lasso_is_point_inside(mcords, moves, screen_co_a[0], screen_co_a[1], INT_MAX)) { - is_point_done = TRUE; - if (select) ebone->flag |= BONE_ROOTSEL; - else ebone->flag &= ~BONE_ROOTSEL; - } - } + if (EBONE_SELECTABLE(arm, ebone)) { + int is_point_done = FALSE; + int points_proj_tot = 0; - /* project tail location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, ebone->tail, screen_co_b, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + /* project head location to screenspace */ + if (x0 != IS_CLIPPED) { + points_proj_tot++; + if (BLI_rcti_isect_pt(data->rect, x0, y0) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, INT_MAX)) { - points_proj_tot++; - if (BLI_lasso_is_point_inside(mcords, moves, screen_co_b[0], screen_co_b[1], INT_MAX)) { - is_point_done = TRUE; - if (select) ebone->flag |= BONE_TIPSEL; - else ebone->flag &= ~BONE_TIPSEL; - } + is_point_done = TRUE; + if (data->select) ebone->flag |= BONE_ROOTSEL; + else ebone->flag &= ~BONE_ROOTSEL; } + } - /* if one of points selected, we skip the bone itself */ - if ((is_point_done == FALSE) && (points_proj_tot == 2) && - BLI_lasso_is_edge_inside(mcords, moves, - screen_co_a[0], screen_co_a[1], - screen_co_b[0], screen_co_b[1], INT_MAX)) + /* project tail location to screenspace */ + if (x1 != IS_CLIPPED) { + points_proj_tot++; + if (BLI_rcti_isect_pt(data->rect, x1, y1) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, INT_MAX)) { - if (select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - change = TRUE; + is_point_done = TRUE; + if (data->select) ebone->flag |= BONE_TIPSEL; + else ebone->flag &= ~BONE_TIPSEL; } + } - change |= is_point_done; + /* if one of points selected, we skip the bone itself */ + if ((is_point_done == FALSE) && (points_proj_tot == 2) && + BLI_lasso_is_edge_inside(data->mcords, data->moves, x0, y0, x1, y1, INT_MAX)) + { + if (data->select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + data->is_change = TRUE; } + + data->is_change |= is_point_done; } - - if (change) { +} + +static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +{ + LassoSelectUserData data; + rcti rect; + + view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); + + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + + BLI_lasso_boundbox(&rect, mcords, moves); + + if (extend == 0 && select) + ED_armature_deselect_all_visible(vc->obedit); + + armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data); + + if (data.is_change) { + bArmature *arm = vc->obedit->data; ED_armature_sync_selection(arm->edbo); ED_armature_validate_active(arm); WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obedit); @@ -2508,65 +2513,59 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int } return 0; } -static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +static void do_circle_select_armature__doSelectBone(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1) { - CircleSelectUserData data; - bArmature *arm = vc->obedit->data; - EditBone *ebone; - - view3d_userdata_circleselect_init(&data, vc, select, mval, rad); + CircleSelectUserData *data = userData; + bArmature *arm = data->vc->obedit->data; - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ - - /* check each EditBone... */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - if (EBONE_SELECTABLE(arm, ebone)) { - int screen_co_a[2], screen_co_b[2]; - int is_point_done = FALSE; - int points_proj_tot = 0; + if (EBONE_SELECTABLE(arm, ebone)) { + int is_point_done = FALSE; + int points_proj_tot = 0; - /* project head location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, ebone->head, screen_co_a, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - points_proj_tot++; - if (armature_circle_doSelectJoint(&data, ebone, screen_co_a[0], screen_co_a[1], TRUE)) { - is_point_done = TRUE; - } + /* project head location to screenspace */ + if (x0 != IS_CLIPPED) { + points_proj_tot++; + if (armature_circle_doSelectJoint(data, ebone, x0, y0, TRUE)) { + is_point_done = TRUE; } + } - /* project tail location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, ebone->tail, screen_co_b, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - points_proj_tot++; - if (armature_circle_doSelectJoint(&data, ebone, screen_co_b[0], screen_co_b[1], FALSE)) { - is_point_done = TRUE; - } + /* project tail location to screenspace */ + if (x1 != IS_CLIPPED) { + points_proj_tot++; + if (armature_circle_doSelectJoint(data, ebone, x1, y1, FALSE)) { + is_point_done = TRUE; } + } - /* check if the head and/or tail is in the circle - * - the call to check also does the selection already - */ - - /* only if the endpoints didn't get selected, deal with the middle of the bone too - * It works nicer to only do this if the head or tail are not in the circle, - * otherwise there is no way to circle select joints alone */ - if ((is_point_done == FALSE) && (points_proj_tot == 2) && - edge_inside_circle(mval[0], mval[1], rad, - screen_co_a[0], screen_co_a[1], - screen_co_b[0], screen_co_b[1])) - { - if (select) - ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; - else - ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - data.is_change = TRUE; - } + /* check if the head and/or tail is in the circle + * - the call to check also does the selection already + */ - data.is_change |= is_point_done; + /* only if the endpoints didn't get selected, deal with the middle of the bone too + * It works nicer to only do this if the head or tail are not in the circle, + * otherwise there is no way to circle select joints alone */ + if ((is_point_done == FALSE) && (points_proj_tot == 2) && + edge_inside_circle(data->mval[0], data->mval[1], data->radius, x0, y0, x1, y1)) + { + if (data->select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + data->is_change = TRUE; } + + data->is_change |= is_point_done; } +} +static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +{ + CircleSelectUserData data; + bArmature *arm = vc->obedit->data; + + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); + + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + + armature_foreachScreenBone(vc, do_circle_select_armature__doSelectBone, &data); if (data.is_change) { ED_armature_sync_selection(arm->edbo); -- cgit v1.2.3 From e23b202693bcd64341b04a3bd3d9f0654dc25dff Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 5 Oct 2012 17:17:19 +0000 Subject: Fix part of cycles/osl light pass rendering, transmission still not correct. --- intern/cycles/kernel/osl/osl_shader.cpp | 20 ++++++++++++++++---- intern/cycles/kernel/svm/svm_types.h | 8 +++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index 98ede0e4f60..ea508dcb660 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -139,15 +139,27 @@ static void flatten_surface_closure_tree(ShaderData *sd, bool no_glossy, float sample_weight = fabsf(average(weight)) * albedo; sc.sample_weight = sample_weight; - sc.type = CLOSURE_BSDF_ID; /* scattering flags */ - if (scattering == OSL::Labels::DIFFUSE) + if (scattering == OSL::Labels::DIFFUSE) { sd->flag |= SD_BSDF | SD_BSDF_HAS_EVAL; - else if (scattering == OSL::Labels::GLOSSY) + sc.type = CLOSURE_BSDF_DIFFUSE_ID; + } + else if (scattering == OSL::Labels::GLOSSY) { sd->flag |= SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY; - else + sc.type = CLOSURE_BSDF_GLOSSY_ID; + } + else if (scattering == OSL::Labels::STRAIGHT) { sd->flag |= SD_BSDF; + sc.type = CLOSURE_BSDF_TRANSPARENT_ID; + } + else { + /* todo: we don't actually have a way to determine if + * this closure will reflect/transmit. could add our own + * own scattering flag that do give this info */ + sd->flag |= SD_BSDF; + sc.type = CLOSURE_BSDF_GLOSSY_ID; + } /* add */ sd->closure[sd->num_closure++] = sc; diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 3cf44a3409a..ee423573cdf 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -287,16 +287,18 @@ typedef enum ClosureType { CLOSURE_BSDF_DIFFUSE_ID, CLOSURE_BSDF_OREN_NAYAR_ID, + CLOSURE_BSDF_GLOSSY_ID, CLOSURE_BSDF_REFLECTION_ID, CLOSURE_BSDF_MICROFACET_GGX_ID, CLOSURE_BSDF_MICROFACET_BECKMANN_ID, CLOSURE_BSDF_WARD_ID, + CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, CLOSURE_BSDF_WESTIN_SHEEN_ID, + CLOSURE_BSDF_TRANSMISSION_ID, CLOSURE_BSDF_TRANSLUCENT_ID, CLOSURE_BSDF_REFRACTION_ID, CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, - CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, CLOSURE_BSDF_GLASS_ID, @@ -320,8 +322,8 @@ typedef enum ClosureType { /* watch this, being lazy with memory usage */ #define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID) #define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID) -#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID) -#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_GLASS_ID) +#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_GLOSSY_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID) +#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSMISSION_ID && type <= CLOSURE_BSDF_GLASS_ID) #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID) #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID) #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID) -- cgit v1.2.3 From db5682ac8c53377e819fd50357de580c02405fca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Oct 2012 17:51:44 +0000 Subject: use pose_foreachScreenBone for pose lasso and circle select --- source/blender/editors/include/ED_view3d.h | 1 + source/blender/editors/space_view3d/drawobject.c | 47 +++++ .../blender/editors/space_view3d/view3d_select.c | 194 +++++++++++---------- 3 files changed, 150 insertions(+), 92 deletions(-) diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 8161dd23b8e..ebf93baeabc 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -172,6 +172,7 @@ void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData); void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); void armature_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1), void *userData); +void pose_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1), void *userData); void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 5ea0413ef71..40207ce806c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2265,6 +2265,53 @@ void armature_foreachScreenBone( } } +/* ED_view3d_init_mats_rv3d must be called first */ +/* almost _exact_ copy of #armature_foreachScreenBone */ +void pose_foreachScreenBone( + struct ViewContext *vc, + void (*func)(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1), + void *userData) +{ + bArmature *arm = vc->obact->data; + bPose *pose = vc->obact->pose; + bPoseChannel *pchan; + + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + if (PBONE_VISIBLE(arm, pchan->bone)) { + int screen_co_a[2], screen_co_b[2]; + int points_proj_tot = 0; + + /* project head location to screenspace */ + if (ED_view3d_project_int_object(vc->ar, pchan->pose_head, screen_co_a, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + points_proj_tot++; + } + else { + screen_co_a[0] = IS_CLIPPED; /* weak */ + /* screen_co_a[1]: intentionally dont set this so we get errors on misuse */ + } + + /* project tail location to screenspace */ + if (ED_view3d_project_int_object(vc->ar, pchan->pose_tail, screen_co_b, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + points_proj_tot++; + } + else { + screen_co_b[0] = IS_CLIPPED; /* weak */ + /* screen_co_b[1]: intentionally dont set this so we get errors on misuse */ + } + + if (points_proj_tot) { /* at least one point's projection worked */ + func(userData, pchan, + screen_co_a[0], screen_co_a[1], + screen_co_b[0], screen_co_b[1]); + } + } + } +} + /* ************** DRAW MESH ****************** */ /* First section is all the "simple" draw routines, diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index ab0c6a2edc8..36a2927cb44 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -343,62 +343,70 @@ static int edge_inside_rect(const rcti *rect, int x1, int y1, int x2, int y2) return 1; } -/* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) - * and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK - */ -static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves, short select) +static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1) { - bPoseChannel *pchan; - bArmature *arm = ob->data; - - if ((ob->type != OB_ARMATURE) || (ob->pose == NULL)) { - return; - } - - ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); + LassoSelectUserData *data = userData; + bArmature *arm = data->vc->obact->data; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - if (PBONE_SELECTABLE(arm, pchan->bone)) { - int screen_co_a[2], screen_co_b[2]; - int is_point_done = FALSE; - int points_proj_tot = 0; + if (PBONE_SELECTABLE(arm, pchan->bone)) { + int is_point_done = FALSE; + int points_proj_tot = 0; - /* project head location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, pchan->pose_head, screen_co_a, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + /* project head location to screenspace */ + if (x0 != IS_CLIPPED) { + points_proj_tot++; + if (BLI_rcti_isect_pt(data->rect, x0, y0) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, INT_MAX)) { - points_proj_tot++; - if (BLI_lasso_is_point_inside(mcords, moves, screen_co_a[0], screen_co_a[1], INT_MAX)) { - is_point_done = TRUE; - } + is_point_done = TRUE; } + } - /* project tail location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, pchan->pose_tail, screen_co_b, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + /* project tail location to screenspace */ + if (x1 != IS_CLIPPED) { + points_proj_tot++; + if (BLI_rcti_isect_pt(data->rect, x1, y1) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, INT_MAX)) { - points_proj_tot++; - if (BLI_lasso_is_point_inside(mcords, moves, screen_co_b[0], screen_co_b[1], INT_MAX)) { - is_point_done = TRUE; - } + is_point_done = TRUE; } + } - /* if one of points selected, we skip the bone itself */ - if ((is_point_done == TRUE) || - ((is_point_done == FALSE) && (points_proj_tot == 2) && - BLI_lasso_is_edge_inside(mcords, moves, - screen_co_a[0], screen_co_a[1], - screen_co_b[0], screen_co_b[1], INT_MAX))) - { - if (select) pchan->bone->flag |= BONE_SELECTED; - else pchan->bone->flag &= ~BONE_SELECTED; - } + /* if one of points selected, we skip the bone itself */ + if ((is_point_done == TRUE) || + ((is_point_done == FALSE) && (points_proj_tot == 2) && + BLI_lasso_is_edge_inside(data->mcords, data->moves, x0, y0, x1, y1, INT_MAX))) + { + if (data->select) pchan->bone->flag |= BONE_SELECTED; + else pchan->bone->flag &= ~BONE_SELECTED; + data->is_change = TRUE; } + data->is_change |= is_point_done; } +} +static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves, short select) +{ + LassoSelectUserData data; + rcti rect; - if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* mask modifier ('armature' mode), etc. */ - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + if ((ob->type != OB_ARMATURE) || (ob->pose == NULL)) { + return; + } + + view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); + + ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); + + BLI_lasso_boundbox(&rect, mcords, moves); + + pose_foreachScreenBone(vc, do_lasso_select_pose__doSelectBone, &data); + + if (data.is_change) { + bArmature *arm = ob->data; + if (arm->flag & ARM_HAS_VIZ_DEPS) { + /* mask modifier ('armature' mode), etc. */ + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } } } @@ -2427,66 +2435,68 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int } return 0; } -static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1) { - CircleSelectUserData data; - bArmature *arm = vc->obact->data; - bPose *pose = vc->obact->pose; - bPoseChannel *pchan; - - view3d_userdata_circleselect_init(&data, vc, select, mval, rad); + CircleSelectUserData *data = userData; + bArmature *arm = data->vc->obact->data; - ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ - - /* check each PoseChannel... */ - /* TODO: could be optimized at some point */ - for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - if (PBONE_SELECTABLE(arm, pchan->bone)) { - int screen_co_a[2], screen_co_b[2]; - int is_point_done = FALSE; - int points_proj_tot = 0; - - /* project head location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, pchan->pose_head, screen_co_a, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - points_proj_tot++; - if (pchan_circle_doSelectJoint(&data, pchan, screen_co_a[0], screen_co_a[1])) { - is_point_done = TRUE; - } - } + if (PBONE_SELECTABLE(arm, pchan->bone)) { + int is_point_done = FALSE; + int points_proj_tot = 0; - /* project tail location to screenspace */ - if (ED_view3d_project_int_object(vc->ar, pchan->pose_tail, screen_co_b, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - points_proj_tot++; - if (pchan_circle_doSelectJoint(&data, pchan, screen_co_b[0], screen_co_b[1])) { - is_point_done = TRUE; - } + /* project head location to screenspace */ + if (x0 != IS_CLIPPED) { + points_proj_tot++; + if (pchan_circle_doSelectJoint(data, pchan, x0, y0)) { + is_point_done = TRUE; } + } - /* only if the endpoints didn't get selected, deal with the middle of the bone too - * It works nicer to only do this if the head or tail are not in the circle, - * otherwise there is no way to circle select joints alone */ - if ((is_point_done == FALSE) && (points_proj_tot == 2) && - edge_inside_circle(mval[0], mval[1], rad, - screen_co_a[0], screen_co_a[1], - screen_co_b[0], screen_co_b[1])) - { - if (select) - pchan->bone->flag |= BONE_SELECTED; - else - pchan->bone->flag &= ~BONE_SELECTED; - data.is_change = TRUE; + /* project tail location to screenspace */ + if (x1 != IS_CLIPPED) { + points_proj_tot++; + if (pchan_circle_doSelectJoint(data, pchan, x1, y1)) { + is_point_done = TRUE; } + } - data.is_change |= is_point_done; + /* check if the head and/or tail is in the circle + * - the call to check also does the selection already + */ + + /* only if the endpoints didn't get selected, deal with the middle of the bone too + * It works nicer to only do this if the head or tail are not in the circle, + * otherwise there is no way to circle select joints alone */ + if ((is_point_done == FALSE) && (points_proj_tot == 2) && + edge_inside_circle(data->mval[0], data->mval[1], data->radius, x0, y0, x1, y1)) + { + if (data->select) pchan->bone->flag |= BONE_SELECTED; + else pchan->bone->flag &= ~BONE_SELECTED; + data->is_change = TRUE; } + + data->is_change |= is_point_done; } +} +static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +{ + CircleSelectUserData data; + + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); + + ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ + + pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data); if (data.is_change) { + bArmature *arm = vc->obact->data; + WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, vc->obact); + + if (arm->flag & ARM_HAS_VIZ_DEPS) { + /* mask modifier ('armature' mode), etc. */ + DAG_id_tag_update(&vc->obact->id, OB_RECALC_DATA); + } } } -- cgit v1.2.3 From ba470956274cc4086ee153e4f9bdda9d2ff714f5 Mon Sep 17 00:00:00 2001 From: Dan Eicher Date: Fri, 5 Oct 2012 19:51:11 +0000 Subject: Grease Pencil notifier/listener cleanup As suggested by Campbell on the IRC gave grease pencil its own notifier type (NC_GPENCIL) and made the makesrna notifier functions actually update properly. Also got the #ifdef'd GreasePencil.layers.[new/remove] functions working. --- source/blender/blenkernel/BKE_gpencil.h | 4 +- source/blender/blenkernel/intern/gpencil.c | 11 ++- source/blender/editors/gpencil/gpencil_buttons.c | 8 +- source/blender/editors/gpencil/gpencil_edit.c | 10 +-- source/blender/editors/gpencil/gpencil_paint.c | 10 +-- source/blender/editors/gpencil/gpencil_undo.c | 2 +- source/blender/editors/space_action/space_action.c | 4 +- source/blender/editors/space_clip/space_clip.c | 20 +++-- source/blender/editors/space_image/space_image.c | 8 +- source/blender/editors/space_node/space_node.c | 7 +- .../editors/space_sequencer/space_sequencer.c | 8 +- source/blender/editors/space_view3d/space_view3d.c | 9 ++- source/blender/makesrna/intern/rna_gpencil.c | 92 ++++++++++++++++------ source/blender/windowmanager/WM_types.h | 1 + 14 files changed, 120 insertions(+), 74 deletions(-) diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index f3223fb4af1..3cb20ead39e 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -44,7 +44,7 @@ void free_gpencil_layers(struct ListBase *list); 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); +struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd, const char *name, int setactive); struct bGPdata *gpencil_data_addnew(const char name[]); struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src); @@ -62,6 +62,6 @@ struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, shor void gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf); struct bGPDlayer *gpencil_layer_getactive(struct bGPdata *gpd); void gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active); -void gpencil_layer_delactive(struct bGPdata *gpd); +void gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl); #endif /* __BKE_GPENCIL_H__ */ diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 2ec5801746c..84871375788 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -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, const char *name, int setactive) { bGPDlayer *gpl; @@ -182,11 +182,12 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd) gpl->thickness = 3; /* auto-name */ - strcpy(gpl->info, "GP_Layer"); + strcpy(gpl->info, name); BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); /* make this one the active one */ - gpencil_layer_setactive(gpd, gpl); + if (setactive) + gpencil_layer_setactive(gpd, gpl); /* return layer */ return gpl; @@ -509,10 +510,8 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active) } /* delete the active gp-layer */ -void gpencil_layer_delactive(bGPdata *gpd) +void gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl) { - bGPDlayer *gpl = gpencil_layer_getactive(gpd); - /* error checking */ if (ELEM(NULL, gpd, gpl)) return; diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index d90ec02b0c1..8a3c996a481 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -75,17 +75,15 @@ static void gp_ui_activelayer_cb(bContext *C, void *gpd, void *gpl) /* make sure the layer we want to remove is the active one */ gpencil_layer_setactive(gpd, gpl); - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } /* delete 'active' layer */ static void gp_ui_dellayer_cb(bContext *C, void *gpd, void *gpl) { - /* make sure the layer we want to remove is the active one */ - gpencil_layer_setactive(gpd, gpl); - gpencil_layer_delactive(gpd); + gpencil_layer_delete((bGPdata *)gpd, (bGPDlayer *)gpl); - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 659e99607f0..46df8ba5fac 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -224,7 +224,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -272,7 +272,7 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op) } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -306,10 +306,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) *gpd_ptr = gpencil_data_addnew("GPencil"); /* add new layer now */ - gpencil_layer_addnew(*gpd_ptr); + gpencil_layer_addnew(*gpd_ptr, "GP_Layer", 1); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -360,7 +360,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op) gpencil_layer_delframe(gpl, gpf); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 0595f4e18bd..de7c2c41a6d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1143,7 +1143,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode) /* get active layer (or add a new one if non-existent) */ p->gpl = gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { - p->gpl = gpencil_layer_addnew(p->gpd); + p->gpl = gpencil_layer_addnew(p->gpd, "GP_Layer", 1); if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); @@ -1616,7 +1616,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op) gpencil_draw_exit(C, op); /* refreshes */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1677,7 +1677,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) //printf("\tGP - hotkey invoked... waiting for click-drag\n"); } - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL, NULL); + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -1790,7 +1790,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) estate = OPERATOR_RUNNING_MODAL; /* stroke could be smoothed, send notifier to refresh screen */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); } else { //printf("\t\tGP - end of stroke + op\n"); @@ -1880,7 +1880,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_FINISHED: /* one last flush before we're done */ gpencil_draw_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); break; case OPERATOR_CANCELLED: diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index fa9f5196866..3d2cd260fb9 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -111,7 +111,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) } } - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 92b6517cbd9..2e92b1eea6f 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -357,8 +357,8 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { /* only handle this event in GPencil mode for performance considerations */ if (saction->mode == SACTCONT_GPENCIL) ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 3f925df30c7..ffe4762ad15 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -407,8 +407,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: - case ND_GPENCIL: - clip_scopes_check_gpencil_change(sa); ED_area_tag_redraw(sa); break; } @@ -420,6 +418,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); } break; + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { + clip_scopes_check_gpencil_change(sa); + ED_area_tag_redraw(sa); + } + break; } } @@ -1159,8 +1163,8 @@ static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1373,8 +1377,8 @@ static void clip_props_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->data == ND_SPACE_CLIP) ED_region_tag_redraw(ar); break; - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1406,8 +1410,8 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->data == ND_DATA) ED_region_tag_redraw(ar); break; case NC_BRUSH: diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index dbad6e8bb24..31cb6d91889 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -708,8 +708,8 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -737,8 +737,8 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->data == ND_DATA) ED_region_tag_redraw(ar); break; case NC_BRUSH: diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 0601d7c105f..b70d66f60b4 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -440,9 +440,6 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCREEN: switch (wmn->data) { - case ND_GPENCIL: - ED_region_tag_redraw(ar); - break; case ND_SCREENCAST: case ND_ANIMPLAY: ED_region_tag_redraw(ar); @@ -463,6 +460,10 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; + case NC_GPENCIL: + if (wmn->action == NA_EDITED) + ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 21c70a5b4a9..7bfe58cb50a 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -556,8 +556,8 @@ static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); } break; @@ -610,8 +610,8 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->data == ND_DATA) { ED_region_tag_redraw(ar); } break; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 1e371cb074d..236cbb86724 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -776,7 +776,6 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCREEN: switch (wmn->data) { - case ND_GPENCIL: case ND_ANIMPLAY: case ND_SKETCH: ED_region_tag_redraw(ar); @@ -793,6 +792,10 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) } break; + case NC_GPENCIL: + if (wmn->action == NA_EDITED) + ED_region_tag_redraw(ar); + break; } } @@ -941,8 +944,8 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->data == ND_DATA) ED_region_tag_redraw(ar); break; } diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 131611d3002..bf7f4984ea1 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -40,6 +40,15 @@ #ifdef RNA_RUNTIME +#include "WM_api.h" + +#include "BKE_gpencil.h" + +static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) { bGPDlayer *gpl = (bGPDlayer *)ptr->data; @@ -53,6 +62,7 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr) static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr) { + bGPdata *gpd = ptr->id.data; if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */ @@ -101,6 +111,34 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); } +static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int setactive) +{ + bGPDlayer *gl = gpencil_layer_addnew(gpd, name, setactive); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + + return gl; +} + +static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlayer *layer) +{ + bGPDlayer *gl; + + for (gl = gpd->layers.first; gl; gl = gl->next) { + if (gl == layer) + break; + } + + if (gl == NULL) { + BKE_reportf(reports, RPT_ERROR, "Layer not found in grease pencil data"); + return; + } + + gpencil_layer_delete(gpd, layer); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + #else static void rna_def_gpencil_stroke_point(BlenderRNA *brna) @@ -116,13 +154,13 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Coordinates", ""); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pressure"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); } static void rna_def_gpencil_stroke(BlenderRNA *brna) @@ -189,7 +227,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Info", "Layer name"); RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_info_set"); RNA_def_struct_name_property(srna, prop); - + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + /* Frames */ prop = RNA_def_property(srna, "frames", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "frames", NULL); @@ -201,32 +240,33 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "actframe"); RNA_def_property_ui_text(prop, "Active Frame", "Frame currently being displayed for this layer"); RNA_def_property_editable_func(prop, "rna_GPencilLayer_active_frame_editable"); - + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + /* Drawing Color */ prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_array(prop, 3); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Color", "Color for all strokes in this layer"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "color[3]"); RNA_def_property_range(prop, 0.3, 1.0f); RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Line Thickness */ prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "thickness"); RNA_def_property_range(prop, 1, 10); RNA_def_property_ui_text(prop, "Thickness", "Thickness of strokes (in pixels)"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Onion-Skinning */ prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ONIONSKIN); RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "ghost_range_max", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gstep"); @@ -234,23 +274,23 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Max Ghost Range", "Maximum number of frames on either side of the active frame to show " "(0 = show the 'first' available sketch on either side)"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); /* Flags */ prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE); RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_LOCKED); RNA_def_property_ui_text(prop, "Locked", "Protect layer from further editing and/or frame changes"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); prop = RNA_def_property(srna, "lock_frame", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK); RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* expose as layers.active */ #if 0 @@ -258,25 +298,25 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE); RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencilLayer_active_set"); RNA_def_property_ui_text(prop, "Active", "Set active layer for editing"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); #endif prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT); RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the DopeSheet"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); /* XXX keep this option? */ prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG); RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update_runtime(prop, "rna_GPencil_update"); /* X-Ray */ prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY); RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects"); - RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); } static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) @@ -284,28 +324,27 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) StructRNA *srna; PropertyRNA *prop; -/* FunctionRNA *func; */ -/* PropertyRNA *parm; */ + FunctionRNA *func; + PropertyRNA *parm; RNA_def_property_srna(cprop, "GreasePencilLayers"); srna = RNA_def_struct(brna, "GreasePencilLayers", NULL); RNA_def_struct_sdna(srna, "bGPdata"); RNA_def_struct_ui_text(srna, "Grease Pencil Layers", "Collection of grease pencil layers"); -#if 0 func = RNA_def_function(srna, "new", "rna_GPencil_layer_new"); - RNA_def_function_ui_description(func, "Add a new spline to the curve"); - parm = RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline"); + RNA_def_function_ui_description(func, "Add a new grease pencil layer"); + parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm = RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline"); + RNA_def_boolean(func, "set_active", 0, "Set Active", "Set the newly created layer to the active layer"); + parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The newly created layer"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "remove", "rna_GPencil_layer_remove"); - RNA_def_function_ui_description(func, "Remove a spline from a curve"); + RNA_def_function_ui_description(func, "Remove a grease pencil layer"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); + parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to remove"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); -#endif prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "GreasePencil"); @@ -344,11 +383,12 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, draw_mode_items); RNA_def_property_ui_text(prop, "Draw Mode", ""); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); prop = RNA_def_property(srna, "use_stroke_endpoints", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_DEPTH_STROKE_ENDPOINTS); RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping"); - + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); } diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index f9b22331f37..2aa0d83f234 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -238,6 +238,7 @@ typedef struct wmNotifier { #define NC_LOGIC (19<<24) #define NC_MOVIECLIP (20<<24) #define NC_MASK (21<<24) +#define NC_GPENCIL (22<<24) /* data type, 256 entries is enough, it can overlap */ #define NOTE_DATA 0x00FF0000 -- cgit v1.2.3 From 39a96e9e3fab5347497da004e71227c651e8604e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 00:42:30 +0000 Subject: disable padding warning for DNA, gave problems with struct bounds padding which DNA ignores. tag operator callbacks as needing their return values used. These are not directly called in many places so the inconvenience is minimal. --- source/blender/editors/sculpt_paint/paint_vertex.c | 14 ++++++++---- source/blender/editors/sculpt_paint/sculpt.c | 5 ++++- source/blender/makesdna/intern/makesdna.c | 5 +++++ source/blender/windowmanager/WM_types.h | 18 +++++++++++++--- source/blender/windowmanager/intern/wm_operators.c | 25 ++++++++++++++++------ 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index f1ee8f522d9..5a79368ac49 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2372,7 +2372,8 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) { - + int retval; + op->customdata = paint_stroke_new(C, NULL, wpaint_stroke_test_start, wpaint_stroke_update_step, wpaint_stroke_done, event->type); @@ -2380,7 +2381,9 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) /* add modal handler */ WM_event_add_modal_handler(C, op); - op->type->modal(C, op, event); + retval = op->type->modal(C, op, event); + OPERATOR_RETVAL_CHECK(retval); + BLI_assert(retval == OPERATOR_RUNNING_MODAL); return OPERATOR_RUNNING_MODAL; } @@ -2816,7 +2819,8 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) { - + int retval; + op->customdata = paint_stroke_new(C, NULL, vpaint_stroke_test_start, vpaint_stroke_update_step, vpaint_stroke_done, event->type); @@ -2824,7 +2828,9 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event) /* add modal handler */ WM_event_add_modal_handler(C, op); - op->type->modal(C, op, event); + retval = op->type->modal(C, op, event); + OPERATOR_RETVAL_CHECK(retval); + BLI_assert(retval == OPERATOR_RUNNING_MODAL); return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index ec0478d128f..3d3e86d2acb 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3998,6 +3998,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even { struct PaintStroke *stroke; int ignore_background_click; + int retval; if (!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; @@ -4021,7 +4022,9 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even /* add modal handler */ WM_event_add_modal_handler(C, op); - op->type->modal(C, op, event); + retval = op->type->modal(C, op, event); + OPERATOR_RETVAL_CHECK(retval); + BLI_assert(retval == OPERATOR_RUNNING_MODAL); return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 88c5ea3e910..494cb875169 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -1186,6 +1186,9 @@ int main(int argc, char **argv) return(return_status); } +/* handy but fails on struct bounds which makesdna doesnt care about + * unless structs are nested */ +#if 0 /* include files for automatic dependencies */ /* extra safety check that we are aligned, @@ -1194,6 +1197,8 @@ int main(int argc, char **argv) # pragma GCC diagnostic error "-Wpadded" #endif +#endif /* if 0 */ + #include "DNA_listBase.h" #include "DNA_vec_types.h" #include "DNA_ID.h" diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 2aa0d83f234..ad828cef6d5 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -509,7 +509,11 @@ typedef struct wmOperatorType { * parameters may be provided through operator properties. cannot use * any interface code or input device state. * - see defines below for return values */ - int (*exec)(struct bContext *, struct wmOperator *); + int (*exec)(struct bContext *, struct wmOperator *) +#ifdef __GNUC__ + __attribute__((warn_unused_result)) +#endif + ; /* this callback executes on a running operator whenever as property * is changed. It can correct its own properties or report errors for @@ -521,9 +525,17 @@ typedef struct wmOperatorType { * any further events are handled in modal. if the operation is * canceled due to some external reason, cancel is called * - see defines below for return values */ - int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *); + int (*invoke)(struct bContext *, struct wmOperator *, struct wmEvent *) +#ifdef __GNUC__ + __attribute__((warn_unused_result)) +#endif + ; int (*cancel)(struct bContext *, struct wmOperator *); - int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *); + int (*modal)(struct bContext *, struct wmOperator *, struct wmEvent *) +#ifdef __GNUC__ + __attribute__((warn_unused_result)) +#endif + ; /* verify if the operator can be executed in the current context, note * that the operator might still fail to execute even if this return true */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 9de3c15d70f..e4d6b3dd465 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2289,6 +2289,8 @@ static int border_apply_rect(wmOperator *op) static int border_apply(bContext *C, wmOperator *op, int gesture_mode) { + int retval; + if (!border_apply_rect(op)) return 0; @@ -2296,7 +2298,9 @@ static int border_apply(bContext *C, wmOperator *op, int gesture_mode) if (RNA_struct_find_property(op->ptr, "gesture_mode") ) RNA_int_set(op->ptr, "gesture_mode", gesture_mode); - op->type->exec(C, op); + retval = op->type->exec(C, op); + OPERATOR_RETVAL_CHECK(retval); + return 1; } @@ -2422,8 +2426,11 @@ static void gesture_circle_apply(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "y", rect->ymin); RNA_int_set(op->ptr, "radius", rect->xmax); - if (op->type->exec) - op->type->exec(C, op); + if (op->type->exec) { + int retval; + retval = op->type->exec(C, op); + OPERATOR_RETVAL_CHECK(retval); + } #ifdef GESTURE_MEMORY circle_select_size = rect->xmax; #endif @@ -2643,8 +2650,10 @@ static void gesture_lasso_apply(bContext *C, wmOperator *op) wm_gesture_end(C, op); - if (op->type->exec) - op->type->exec(C, op); + if (op->type->exec) { + int retval = op->type->exec(C, op); + OPERATOR_RETVAL_CHECK(retval); + } } int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event) @@ -2813,8 +2822,10 @@ static int straightline_apply(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "xend", rect->xmax); RNA_int_set(op->ptr, "yend", rect->ymax); - if (op->type->exec) - op->type->exec(C, op); + if (op->type->exec) { + int retval = op->type->exec(C, op); + OPERATOR_RETVAL_CHECK(retval); + } return 1; } -- cgit v1.2.3 From f84f2c703378284cb72de3bb07b7a8f4b5de31c9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 01:30:49 +0000 Subject: add circle select for metaballs --- .../blender/editors/space_view3d/view3d_select.c | 102 +++++++++++++-------- 1 file changed, 66 insertions(+), 36 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 36a2927cb44..c4639fc2c56 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -550,7 +550,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP if (BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); - if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; + if (bp == cu->lastsel && !(bp->f1 & SELECT)) cu->lastsel = NULL; } else { if (cu->drawflag & CU_HIDE_HANDLES) { @@ -569,7 +569,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP } } - if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel = NULL; + if (bezt == cu->lastsel && !(bezt->f2 & SELECT)) cu->lastsel = NULL; } } } @@ -1633,7 +1633,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi if (BLI_rcti_isect_pt(data->rect, x, y)) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); - if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; + if (bp == cu->lastsel && !(bp->f1 & SELECT)) cu->lastsel = NULL; } else { if (cu->drawflag & CU_HIDE_HANDLES) { @@ -1652,7 +1652,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi } } - if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel = NULL; + if (bezt == cu->lastsel && !(bezt->f2 & SELECT)) cu->lastsel = NULL; } } } @@ -2357,7 +2357,7 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); - if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; + if (bp == cu->lastsel && !(bp->f1 & SELECT)) cu->lastsel = NULL; } else { if (cu->drawflag & CU_HIDE_HANDLES) { @@ -2376,7 +2376,7 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint } } - if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel = NULL; + if (bezt == cu->lastsel && !(bezt->f2 & SELECT)) cu->lastsel = NULL; } } } @@ -2384,14 +2384,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval { CircleSelectUserData data; - /* set vc-> edit data */ - - data.select = select; - data.mval[0] = mval[0]; - data.mval[1] = mval[1]; - data.radius = rad; - data.vc = vc; - data.is_change = FALSE; + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ nurbs_foreachScreenVert(vc, nurbscurve_circle_doSelect, &data); @@ -2584,6 +2577,29 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 } } +static void mball_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +{ + const float radius_squared = rad * rad; + const float mval_fl[2] = {mval[0], mval[1]}; + + MetaBall *mb = (MetaBall *)vc->obedit->data; + MetaElem *ml; + + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + + for (ml = mb->editelems->first; ml; ml = ml->next) { + float screen_co[2]; + if (ED_view3d_project_float_object(vc->ar, &ml->x, screen_co, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { + if (select) ml->flag |= SELECT; + else ml->flag &= ~SELECT; + } + } + } +} + /** Callbacks for circle selection in Editmode */ static void obedit_circle_select(ViewContext *vc, short select, const int mval[2], float rad) @@ -2602,24 +2618,50 @@ static void obedit_circle_select(ViewContext *vc, short select, const int mval[2 case OB_ARMATURE: armature_circle_select(vc, select, mval, rad); break; + case OB_MBALL: + mball_circle_select(vc, select, mval, rad); + break; default: return; } } +static int object_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +{ + Scene *scene = vc->scene; + const float radius_squared = rad * rad; + const float mval_fl[2] = {mval[0], mval[1]}; + int is_change = FALSE; + + Base *base; + select = select ? BA_SELECT : BA_DESELECT; + for (base = FIRSTBASE; base; base = base->next) { + if (((base->flag & SELECT) == 0) && BASE_SELECTABLE(vc->v3d, base)) { + float screen_co[2]; + if (ED_view3d_project_float_global(vc->ar, base->object->obmat[3], screen_co, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { + ED_base_object_select(base, select); + is_change = TRUE; + } + } + } + } + + return is_change; +} + /* not a real operator, only for circle test */ static int view3d_circle_select_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); - View3D *v3d = sa->spacedata.first; - int x = RNA_int_get(op->ptr, "x"); - int y = RNA_int_get(op->ptr, "y"); int radius = RNA_int_get(op->ptr, "radius"); int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); int select; + const int mval[2] = {RNA_int_get(op->ptr, "x"), + RNA_int_get(op->ptr, "y")}; select = (gesture_mode == GESTURE_MODAL_SELECT); @@ -2627,13 +2669,10 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT | OB_MODE_POSE))) ) { ViewContext vc; - int mval[2]; view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - mval[0] = x; - mval[1] = y; if (CTX_data_edit_object(C)) { obedit_circle_select(&vc, select, mval, (float)radius); @@ -2656,21 +2695,12 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - Base *base; - select = select ? BA_SELECT : BA_DESELECT; - for (base = FIRSTBASE; base; base = base->next) { - if (BASE_SELECTABLE(v3d, base)) { - ED_view3d_project_base(ar, base); - if (base->sx != IS_CLIPPED) { - int dx = base->sx - x; - int dy = base->sy - y; - if (dx * dx + dy * dy < radius * radius) - ED_base_object_select(base, select); - } - } + ViewContext vc; + view3d_set_viewcontext(C, &vc); + + if (object_circle_select(&vc, select, mval, (float)radius)) { + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); } return OPERATOR_FINISHED; -- cgit v1.2.3 From c4472bbab678cfc826fc40fe9272db38cbb6a1cd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 03:02:14 +0000 Subject: add mball_foreachScreenElem() and use for lasso & circle selection, also utility metaball functions to (de)select all. --- source/blender/blenkernel/BKE_mball.h | 4 ++ source/blender/blenkernel/intern/mball.c | 29 ++++++++ source/blender/editors/include/ED_view3d.h | 2 + source/blender/editors/metaball/mball_edit.c | 79 ++++++++++----------- source/blender/editors/space_view3d/drawobject.c | 19 +++++ .../blender/editors/space_view3d/view3d_select.c | 82 +++++++++++----------- 6 files changed, 131 insertions(+), 84 deletions(-) diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 913e8653b9b..d591b44e489 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -63,4 +63,8 @@ void BKE_mball_translate(struct MetaBall *mb, float offset[3]); struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type); +void BKE_mball_select_all(struct MetaBall *mb); +void BKE_mball_deselect_all(struct MetaBall *mb); +void BKE_mball_select_swap(struct MetaBall *mb); + #endif diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 2030ab0f552..de7fdece7dd 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -2396,3 +2396,32 @@ void BKE_mball_translate(MetaBall *mb, float offset[3]) add_v3_v3(&ml->x, offset); } } + +/* *** select funcs *** */ +void BKE_mball_select_all(struct MetaBall *mb) +{ + MetaElem *ml; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + ml->flag |= SELECT; + } +} + +void BKE_mball_deselect_all(MetaBall *mb) +{ + MetaElem *ml; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + ml->flag &= ~SELECT; + } +} + +void BKE_mball_select_swap(struct MetaBall *mb) +{ + MetaElem *ml; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + ml->flag ^= SELECT; + } +} + diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index ebf93baeabc..b81e08ed7ef 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -44,6 +44,7 @@ struct EditBone; struct ImBuf; struct MVert; struct Main; +struct MetaElem; struct Nurb; struct Nurb; struct Object; @@ -170,6 +171,7 @@ void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, void mesh_foreachScreenEdge(struct ViewContext *vc, void (*func)(void *userData, struct BMEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, eV3DClipTest clipVerts); void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, struct BMFace *efa, int x, int y, int index), void *userData); void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData); +void mball_foreachScreenElem(struct ViewContext *vc, void (*func)(void *userData, struct MetaElem *ml, int x, int y), void *userData); void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); void armature_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct EditBone *ebone, int x0, int y0, int x1, int y1), void *userData); void pose_foreachScreenBone(struct ViewContext *vc, void (*func)(void *userData, struct bPoseChannel *pchan, int x0, int y0, int x1, int y1), void *userData); diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 22ccd7bbed8..e9063687506 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -129,37 +129,33 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) MetaElem *ml; int action = RNA_enum_get(op->ptr, "action"); - ml = mb->editelems->first; - if (ml) { - if (action == SEL_TOGGLE) { - action = SEL_SELECT; - while (ml) { - if (ml->flag & SELECT) { - action = SEL_DESELECT; - break; - } - ml = ml->next; - } - } + if (mb->editelems->first == NULL) + return OPERATOR_CANCELLED; - ml = mb->editelems->first; - while (ml) { - switch (action) { - case SEL_SELECT: - ml->flag |= SELECT; - break; - case SEL_DESELECT: - ml->flag &= ~SELECT; - break; - case SEL_INVERT: - ml->flag ^= SELECT; - break; + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + for (ml = mb->editelems->first; ml; ml = ml->next) { + if (ml->flag & SELECT) { + action = SEL_DESELECT; + break; } - ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); } + switch (action) { + case SEL_SELECT: + BKE_mball_select_all(mb); + break; + case SEL_DESELECT: + BKE_mball_deselect_all(mb); + break; + case SEL_INVERT: + BKE_mball_select_swap(mb); + break; + } + + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); + return OPERATOR_FINISHED; } @@ -421,7 +417,7 @@ int mouse_mball(bContext *C, const int mval[2], int extend, int deselect, int to Object *obedit = CTX_data_edit_object(C); ViewContext vc; MetaBall *mb = (MetaBall *)obedit->data; - MetaElem *ml, *act = NULL; + MetaElem *ml, *ml_act = NULL; int a, hits; unsigned int buffer[4 * MAXPICKBUF]; rcti rect; @@ -451,14 +447,14 @@ int mouse_mball(bContext *C, const int mval[2], int extend, int deselect, int to /* index converted for gl stuff */ if (ml->selcol1 == buffer[4 * a + 3]) { ml->flag |= MB_SCALE_RAD; - act = ml; + ml_act = ml; } if (ml->selcol2 == buffer[4 * a + 3]) { ml->flag &= ~MB_SCALE_RAD; - act = ml; + ml_act = ml; } } - if (act) break; + if (ml_act) break; ml = ml->next; if (ml == NULL) ml = mb->editelems->first; if (ml == startelem) break; @@ -466,31 +462,28 @@ int mouse_mball(bContext *C, const int mval[2], int extend, int deselect, int to /* When some metaelem was found, then it is necessary to select or * deselect it. */ - if (act) { + if (ml_act) { if (extend) { - act->flag |= SELECT; + ml_act->flag |= SELECT; } else if (deselect) { - act->flag &= ~SELECT; + ml_act->flag &= ~SELECT; } else if (toggle) { - if (act->flag & SELECT) - act->flag &= ~SELECT; + if (ml_act->flag & SELECT) + ml_act->flag &= ~SELECT; else - act->flag |= SELECT; + ml_act->flag |= SELECT; } else { /* Deselect all existing metaelems */ - ml = mb->editelems->first; - while (ml) { - ml->flag &= ~SELECT; - ml = ml->next; - } + BKE_mball_deselect_all(mb); + /* Select only metaelem clicked on */ - act->flag |= SELECT; + ml_act->flag |= SELECT; } - mb->lastelem = act; + mb->lastelem = ml_act; WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 40207ce806c..a6f4527cf98 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2220,6 +2220,25 @@ void nurbs_foreachScreenVert( } } +/* ED_view3d_init_mats_rv3d must be called first */ +void mball_foreachScreenElem( + struct ViewContext *vc, + void (*func)(void *userData, struct MetaElem *ml, int x, int y), + void *userData) +{ + MetaBall *mb = (MetaBall *)vc->obedit->data; + MetaElem *ml; + + for (ml = mb->editelems->first; ml; ml = ml->next) { + int screen_co[2]; + if (ED_view3d_project_int_object(vc->ar, &ml->x, screen_co, + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + { + func(userData, ml, screen_co[0], screen_co[1]); + } + } +} + /* ED_view3d_init_mats_rv3d must be called first */ void armature_foreachScreenBone( struct ViewContext *vc, diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c4639fc2c56..53f2c2e9f5e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -61,13 +61,14 @@ #include "IMB_imbuf.h" #include "BKE_global.h" -#include "BKE_context.h" -#include "BKE_paint.h" #include "BKE_armature.h" +#include "BKE_context.h" #include "BKE_depsgraph.h" -#include "BKE_tessmesh.h" +#include "BKE_mball.h" #include "BKE_movieclip.h" #include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_tessmesh.h" #include "BKE_tracking.h" @@ -678,32 +679,34 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho } } +static void do_lasso_select_mball__doSelectElem(void *userData, struct MetaElem *ml, int x, int y) +{ + LassoSelectUserData *data = userData; + if (BLI_rcti_isect_pt(data->rect, x, y) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, INT_MAX)) { + if (data->select) ml->flag |= SELECT; + else ml->flag &= ~SELECT; + data->is_change = TRUE; + } +} static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) { + LassoSelectUserData data; + rcti rect; + MetaBall *mb = (MetaBall *)vc->obedit->data; - MetaElem *ml; - if (extend == 0 && select) { - /* XXX, make an editor function as is done elsewhere */ - for (ml = mb->editelems->first; ml; ml = ml->next) { - ml->flag &= ~SELECT; - } - } + if (extend == 0 && select) + BKE_mball_deselect_all(mb); + + view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - for (ml = mb->editelems->first; ml; ml = ml->next) { - int screen_co[2]; - if (ED_view3d_project_int_object(vc->ar, &ml->x, screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - if (BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], INT_MAX)) { - if (select) ml->flag |= SELECT; - else ml->flag &= ~SELECT; - } - } - } + BLI_lasso_boundbox(&rect, mcords, moves); + + mball_foreachScreenElem(vc, do_lasso_select_mball__doSelectElem, &data); } static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) @@ -1792,11 +1795,8 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int exten hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect); - if (extend == 0 && select) { - for (ml = mb->editelems->first; ml; ml = ml->next) { - ml->flag &= ~SELECT; - } - } + if (extend == 0 && select) + BKE_mball_deselect_all(mb); for (ml = mb->editelems->first; ml; ml = ml->next) { for (a = 0; a < hits; a++) { @@ -2577,27 +2577,27 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 } } +static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem *ml, int x, int y) +{ + CircleSelectUserData *data = userData; + const float delta[2] = {(float)(x - data->mval[0]), + (float)(y - data->mval[1])}; + + if (len_squared_v2(delta) <= data->radius_squared) { + if (data->select) ml->flag |= SELECT; + else ml->flag &= ~SELECT; + data->is_change = TRUE; + } +} static void mball_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - const float radius_squared = rad * rad; - const float mval_fl[2] = {mval[0], mval[1]}; + CircleSelectUserData data; - MetaBall *mb = (MetaBall *)vc->obedit->data; - MetaElem *ml; + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - for (ml = mb->editelems->first; ml; ml = ml->next) { - float screen_co[2]; - if (ED_view3d_project_float_object(vc->ar, &ml->x, screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) - { - if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { - if (select) ml->flag |= SELECT; - else ml->flag &= ~SELECT; - } - } - } + mball_foreachScreenElem(vc, do_circle_select_mball__doSelectElem, &data); } /** Callbacks for circle selection in Editmode */ -- cgit v1.2.3 From 6a164c7f72e679985e78f92b635426db73a93022 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 03:33:11 +0000 Subject: fix [#32779] Bmesh module: assigning to bm.select_mode crashes Blender if bmesh is empty was missing set typecheck --- source/blender/python/generic/py_capi_utils.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index a2521484c88..2b4dcf93b66 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -760,7 +760,6 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int *valu return 0; } -/* 'value' _must_ be a set type, error check before calling */ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix) { /* set of enum items, concatenate all values with OR */ @@ -771,6 +770,15 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co Py_ssize_t hash = 0; PyObject *key; + PyC_ObSpit("", value); + + if (!PySet_Check(value)) { + PyErr_Format(PyExc_TypeError, + "%.200s expected a set, not %.200s", + error_prefix, Py_TYPE(value)->tp_name); + return -1; + } + *r_value = 0; while (_PySet_NextEntry(value, &pos, &key, &hash)) { @@ -778,7 +786,7 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co if (param == NULL) { PyErr_Format(PyExc_TypeError, - "%.200s expected a string, not %.200s", + "%.200s set must contain strings, not %.200s", error_prefix, Py_TYPE(key)->tp_name); return -1; } -- cgit v1.2.3 From b26ccf0aff3ab8871923ade7993b8f8d3a3f75f5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 03:34:52 +0000 Subject: toggle cut through in the knife tool now refreshes (before you had to wave the mouse about to see the result). also remove print from last commit. --- source/blender/blenkernel/BKE_mball.h | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/editors/mesh/editmesh_knife.c | 1 + source/blender/python/generic/py_capi_utils.c | 2 -- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index d591b44e489..7a0eea1b009 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -59,7 +59,7 @@ void BKE_mball_properties_copy(struct Scene *scene, struct Object *active_object int BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]); int BKE_mball_center_median(struct MetaBall *mb, float r_cent[3]); int BKE_mball_center_bounds(struct MetaBall *mb, float r_cent[3]); -void BKE_mball_translate(struct MetaBall *mb, float offset[3]); +void BKE_mball_translate(struct MetaBall *mb, const float offset[3]); struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index de7fdece7dd..592101fbd31 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -2388,7 +2388,7 @@ int BKE_mball_center_bounds(MetaBall *mb, float r_cent[3]) return 0; } -void BKE_mball_translate(MetaBall *mb, float offset[3]) +void BKE_mball_translate(MetaBall *mb, const float offset[3]) { MetaElem *ml; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 969f185810e..4f4fc27582c 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -3130,6 +3130,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, wmEvent *event) break; case KNF_MODAL_CUT_THROUGH_TOGGLE: kcd->cut_through = !kcd->cut_through; + knifetool_update_mval(kcd, event->mval); /* refresh knife path */ knife_update_header(C, kcd); break; case KNF_MODAL_NEW_CUT: diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 2b4dcf93b66..9492c8384dc 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -770,8 +770,6 @@ int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, co Py_ssize_t hash = 0; PyObject *key; - PyC_ObSpit("", value); - if (!PySet_Check(value)) { PyErr_Format(PyExc_TypeError, "%.200s expected a set, not %.200s", -- cgit v1.2.3 From 950ac472507432339ac0d4b126ac48137bf39e9c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 6 Oct 2012 03:56:09 +0000 Subject: Bugfix [#32789] (Minor) Different types used between func declaration and definition (EDBM_selectmode_convert()) Cheers to Sebastian Nell (codemanx) for catching this. --- source/blender/editors/include/ED_mesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 028b5db6beb..093872c79f6 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -149,7 +149,7 @@ struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, int *dist); int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle); void EDBM_selectmode_set(struct BMEditMesh *em); -void EDBM_selectmode_convert(struct BMEditMesh *em, short selectmode_old, const short selectmode_new); +void EDBM_selectmode_convert(struct BMEditMesh *em, const short selectmode_old, const short selectmode_new); void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select); -- cgit v1.2.3 From c001bd81a75b60a491ae30947736eea78260827a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 6 Oct 2012 07:03:03 +0000 Subject: Color Management: fixed loading configuration from non-ascii paths Used the same hack as BLI gzip is using -- calculate short path and send it to OCIO library. --- source/blender/blenlib/BLI_fileops.h | 2 ++ source/blender/blenlib/intern/fileops.c | 28 ++++++++++++++++----------- source/blender/imbuf/intern/colormanagement.c | 13 ++++++++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index e8d6336a994..c278370d211 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -96,6 +96,8 @@ void BLI_file_free_lines(struct LinkNode *lines); # ifndef O_BINARY # define O_BINARY 0 # endif +#else +void BLI_get_short_name(char short_name[256], const char *filename); #endif #ifdef __cplusplus diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 453463beaa8..1df904f617a 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -210,6 +210,22 @@ FILE *BLI_fopen(const char *filename, const char *mode) return ufopen(filename, mode); } +void BLI_get_short_name(char short_name[256], const char *filename) +{ + wchar_t short_name_16[256]; + int i = 0; + + UTF16_ENCODE(filename); + + GetShortPathNameW(filename_16, short_name_16, 256); + + for (i = 0; i < 256; i++) { + short_name[i] = (char)short_name_16[i]; + } + + UTF16_UN_ENCODE(filename); +} + void *BLI_gzopen(const char *filename, const char *mode) { gzFile gzfile; @@ -218,25 +234,15 @@ void *BLI_gzopen(const char *filename, const char *mode) return 0; } else { - wchar_t short_name_16[256]; char short_name[256]; - int i = 0; /* xxx Creates file before transcribing the path */ if (mode[0] == 'w') fclose(ufopen(filename, "a")); - UTF16_ENCODE(filename); - - GetShortPathNameW(filename_16, short_name_16, 256); - - for (i = 0; i < 256; i++) { - short_name[i] = (char)short_name_16[i]; - } + BLI_get_short_name(short_name, filename); gzfile = gzopen(short_name, mode); - - UTF16_UN_ENCODE(filename); } return gzfile; diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index c7bdd532bb9..37510c10e9a 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -51,6 +51,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_fileops.h" #include "BLI_math.h" #include "BLI_math_color.h" #include "BLI_path_util.h" @@ -574,10 +575,20 @@ void colormanagement_init(void) if (config == NULL) { configdir = BLI_get_folder(BLENDER_DATAFILES, "colormanagement"); - if (configdir) { + if (configdir) { BLI_join_dirfile(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE); +#ifdef WIN32 + { + /* quite a hack to support loading configuration from path with non-acii symbols */ + + char short_name[256]; + BLI_get_short_name(short_name, configfile); + config = OCIO_configCreateFromFile(short_name); + } +#else config = OCIO_configCreateFromFile(configfile); +#endif } } -- cgit v1.2.3 From a2d8cf333fb61de97270c1dce732a72915f20dd4 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sat, 6 Oct 2012 11:00:45 +0000 Subject: Better support for LLVM linking, needed for static OSL library. This adds cmake code for LLVM on linux and updates the cmake code used for OSX. LLVM is linked like other external libraries now, by using the setup_liblinks and setup_libdirs macros instead of the PLATFORM_LINKFLAGS variable. The use of llvm-config for getting a list of libraries can also be simplified quite a bit. Caching the LLVM_DIRECTORY and LLVM_VERSION strings could be nicer though. --- CMakeLists.txt | 174 +++++++++++++++++++++++++++-------------- build_files/cmake/macros.cmake | 6 ++ 2 files changed, 120 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a91b5a3bdac..9e031d0358e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,6 +254,9 @@ set(CYCLES_CUDA_BINARIES_ARCH sm_13 sm_20 sm_21 sm_30 CACHE STRING "CUDA archite mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH) unset(PLATFORM_DEFAULT) +# LLVM +option(WITH_LLVM "Use LLVM" OFF) + # disable for now, but plan to support on all platforms eventually option(WITH_MEM_JEMALLOC "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF) mark_as_advanced(WITH_MEM_JEMALLOC) @@ -371,6 +374,11 @@ if(WITH_CYCLES OR WITH_MOD_BOOLEAN) set(WITH_BOOST ON) endif() +# auto enable llvm for cycles_osl +if(WITH_CYCLES_OSL) + set(WITH_LLVM ON) +endif() + # don't store paths to libs for portable distribution if(WITH_INSTALL_PORTABLE) set(CMAKE_SKIP_BUILD_RPATH TRUE) @@ -704,6 +712,56 @@ if(UNIX AND NOT APPLE) endif() endif() + if(WITH_LLVM) + set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + set(LLVM_VERSION "3.0" CACHE STRING "Version of LLVM to use" "") + set(LLVM_STATIC YES) + if(LLVM_DIRECTORY) + set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config") + else() + set(LLVM_CONFIG llvm-config) + endif() + execute_process(COMMAND ${LLVM_CONFIG} --version + OUTPUT_VARIABLE LLVM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --prefix + OUTPUT_VARIABLE LLVM_DIRECTORY + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --libdir + OUTPUT_VARIABLE LLVM_LIB_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --includedir + OUTPUT_VARIABLE LLVM_INCLUDES + OUTPUT_STRIP_TRAILING_WHITESPACE) + find_library(LLVM_LIBRARY + NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get + PATHS ${LLVM_LIB_DIR}) + message(STATUS "LLVM version = ${LLVM_VERSION}") + message(STATUS "LLVM dir = ${LLVM_DIRECTORY}") + message(STATUS "LLVM includes = ${LLVM_INCLUDES}") + message(STATUS "LLVM lib dir = ${LLVM_LIB_DIR}") + + if(LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR) + # ensure include directory is added (in case of non-standard locations + include_directories(BEFORE "${LLVM_INCLUDES}") + string(REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION}) + message(STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}") + add_definitions("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}") + if(LLVM_STATIC) + # if static LLVM libraries were requested, use llvm-config to generate + # the list of what libraries we need, and substitute that in the right + # way for LLVM_LIBRARY. + execute_process(COMMAND ${LLVM_CONFIG} --libfiles + OUTPUT_VARIABLE LLVM_LIBRARY + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY}) + endif() + message(STATUS "LLVM library = ${LLVM_LIBRARY}") + else() + message(FATAL_ERROR "LLVM not found.") + endif() + endif() + if(WITH_CYCLES_OSL) set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") @@ -1559,6 +1617,56 @@ elseif(APPLE) set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD") endif() + if(WITH_LLVM) + set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation") + set(LLVM_VERSION "3.1" CACHE STRING "Version of LLVM to use" "") + set(LLVM_STATIC YES) + if(LLVM_DIRECTORY) + set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config") + else() + set(LLVM_CONFIG llvm-config) + endif() + execute_process(COMMAND ${LLVM_CONFIG} --version + OUTPUT_VARIABLE LLVM_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --prefix + OUTPUT_VARIABLE LLVM_DIRECTORY + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --libdir + OUTPUT_VARIABLE LLVM_LIB_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LLVM_CONFIG} --includedir + OUTPUT_VARIABLE LLVM_INCLUDES + OUTPUT_STRIP_TRAILING_WHITESPACE) + find_library(LLVM_LIBRARY + NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get + PATHS ${LLVM_LIB_DIR}) + message(STATUS "LLVM version = ${LLVM_VERSION}") + message(STATUS "LLVM dir = ${LLVM_DIRECTORY}") + message(STATUS "LLVM includes = ${LLVM_INCLUDES}") + message(STATUS "LLVM lib dir = ${LLVM_LIB_DIR}") + + if(LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR) + # ensure include directory is added (in case of non-standard locations + include_directories(BEFORE "${LLVM_INCLUDES}") + string(REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION}) + message(STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}") + add_definitions("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}") + if(LLVM_STATIC) + # if static LLVM libraries were requested, use llvm-config to generate + # the list of what libraries we need, and substitute that in the right + # way for LLVM_LIBRARY. + execute_process(COMMAND ${LLVM_CONFIG} --libfiles + OUTPUT_VARIABLE LLVM_LIBRARY + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY}) + endif() + message(STATUS "LLVM library = ${LLVM_LIBRARY}") + else() + message(FATAL_ERROR "LLVM not found.") + endif() + endif() + if(WITH_CYCLES_OSL) set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation") @@ -1582,66 +1690,6 @@ elseif(APPLE) endif() include_directories(${OSL_INCLUDES}) - - - # LLVM library setup, needed for osl - - set(LLVM_DIRECTORY "${LIBDIR}/llvm") - set(LLVM_STATIC YES) - if (LLVM_DIRECTORY) - set (LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config") - else () - set (LLVM_CONFIG llvm-config) - endif () - execute_process (COMMAND ${LLVM_CONFIG} --version - OUTPUT_VARIABLE LLVM_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND ${LLVM_CONFIG} --prefix - OUTPUT_VARIABLE LLVM_DIRECTORY - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND ${LLVM_CONFIG} --libdir - OUTPUT_VARIABLE LLVM_LIB_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND ${LLVM_CONFIG} --includedir - OUTPUT_VARIABLE LLVM_INCLUDES - OUTPUT_STRIP_TRAILING_WHITESPACE) - find_library ( LLVM_LIBRARY - NAMES libLLVMAnalysis.a # first of a whole bunch of libs to get - PATHS ${LLVM_LIB_DIR}) - message (STATUS "LLVM version = ${LLVM_VERSION}") - message (STATUS "LLVM dir = ${LLVM_DIRECTORY}") - message (STATUS "LLVM includes = ${LLVM_INCLUDES}") - message (STATUS "LLVM lib dir = ${LLVM_LIB_DIR}") - - if (LLVM_LIBRARY AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR) - # ensure include directory is added (in case of non-standard locations - include_directories (BEFORE "${LLVM_INCLUDES}") - string (REGEX REPLACE "\\." "" OSL_LLVM_VERSION ${LLVM_VERSION}) - message (STATUS "LLVM OSL_LLVM_VERSION = ${OSL_LLVM_VERSION}") - add_definitions ("-DOSL_LLVM_VERSION=${OSL_LLVM_VERSION}") - if (LLVM_STATIC) - # if static LLVM libraries were requested, use llvm-config to generate - # the list of what libraries we need, and substitute that in the right - # way for LLVM_LIBRARY. - set (LLVM_LIBRARY "") - execute_process (COMMAND ${LLVM_CONFIG} --libs - OUTPUT_VARIABLE llvm_library_list - OUTPUT_STRIP_TRAILING_WHITESPACE) - string (REPLACE "-l" "" llvm_library_list ${llvm_library_list}) - string (REPLACE " " ";" llvm_library_list ${llvm_library_list}) - foreach (f ${llvm_library_list}) - list (APPEND LLVM_LIBRARY "${LLVM_LIB_DIR}/lib${f}.a") - endforeach () - endif () - string (REPLACE ";" " " LLVM_LIBRARY "${LLVM_LIBRARY}") - message (STATUS "LLVM library = ${LLVM_LIBRARY}") - else () - message (FATAL_ERROR "LLVM not found.") - endif () - set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${LLVM_LIBRARY}") - - # end LLVM library setup - endif() set(EXETYPE MACOSX_BUNDLE) @@ -1677,6 +1725,12 @@ if(WITH_CYCLES) if(NOT WITH_BOOST) message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES") endif() + + if(WITH_CYCLES_OSL) + if(NOT WITH_LLVM) + message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL") + endif() + endif() endif() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 43cfb31c03c..750903b12d7 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -244,6 +244,9 @@ macro(SETUP_LIBDIRS) link_directories(${PCRE_LIBPATH}) link_directories(${EXPAT_LIBPATH}) endif() + if(WITH_LLVM) + link_directories(${LLVM_LIB_DIR}) + endif() if(WITH_MEM_JEMALLOC) link_directories(${JEMALLOC_LIBPATH}) endif() @@ -382,6 +385,9 @@ macro(setup_liblinks if(WITH_CYCLES_OSL) target_link_libraries(${target} ${OSL_LIBRARIES}) endif() + if(WITH_LLVM) + target_link_libraries(${target} ${LLVM_LIBRARY}) + endif() if(WIN32 AND NOT UNIX) target_link_libraries(${target} ${PTHREADS_LIBRARIES}) endif() -- cgit v1.2.3 From 098d611c7b8dc5178c5dd89fc02148ab2ed5b983 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 6 Oct 2012 11:52:54 +0000 Subject: Fix for UV texture coordinate problem in cycles, after recent fix. --- intern/cycles/render/nodes.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 8173f5d0af2..4e16eea2774 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1650,10 +1650,12 @@ TextureCoordinateNode::TextureCoordinateNode() void TextureCoordinateNode::attributes(AttributeRequestSet *attributes) { - if(!output("Generated")->links.empty()) - attributes->add(ATTR_STD_GENERATED); - if(!output("UV")->links.empty()) - attributes->add(ATTR_STD_UV); + if(!from_dupli) { + if(!output("Generated")->links.empty()) + attributes->add(ATTR_STD_GENERATED); + if(!output("UV")->links.empty()) + attributes->add(ATTR_STD_UV); + } ShaderNode::attributes(attributes); } @@ -1704,13 +1706,13 @@ void TextureCoordinateNode::compile(SVMCompiler& compiler) out = output("UV"); if(!out->links.empty()) { if(from_dupli) { - int attr = compiler.attribute(ATTR_STD_UV); compiler.stack_assign(out); - compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3); + compiler.add_node(texco_node, NODE_TEXCO_DUPLI_UV, out->stack_offset); } else { + int attr = compiler.attribute(ATTR_STD_UV); compiler.stack_assign(out); - compiler.add_node(texco_node, NODE_TEXCO_DUPLI_UV, out->stack_offset); + compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3); } } -- cgit v1.2.3 From b6a803fb368953bca1a7480694a7ab6d97439fad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 12:00:54 +0000 Subject: fix reading past array bounds for nearest_uv_between() and draw_tracking_tracks(). --- source/blender/editors/space_clip/clip_draw.c | 2 +- source/blender/editors/uvedit/uvedit_ops.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index b22c9a60bdc..5e940df2a30 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1126,7 +1126,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); + copy_v3_v3(vec, track->bundle_pos); vec[3] = 1; mul_v4_m4v4(pos, mat, vec); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index f732808fa59..6e655faf35f 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -759,14 +759,13 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i BMLoop *l; MLoopUV *luv; BMIter iter; - float m[3], v1[3], v2[3], c1, c2, *uv1 = NULL, /* *uv2, */ /* UNUSED */ *uv3 = NULL; + float m[2], v1[2], v2[2], c1, c2, *uv1 = NULL, /* *uv2, */ /* UNUSED */ *uv3 = NULL; int id1, id2, i; id1 = (id + efa->len - 1) % efa->len; id2 = (id + efa->len + 1) % efa->len; - m[0] = co[0] - uv[0]; - m[1] = co[1] - uv[1]; + sub_v2_v2v2(m, co, uv); i = 0; BM_ITER_ELEM (l, &iter, efa, BM_LOOPS_OF_FACE) { @@ -782,8 +781,8 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i i++; } - sub_v3_v3v3(v1, uv1, uv); - sub_v3_v3v3(v2, uv3, uv); + sub_v2_v2v2(v1, uv1, uv); + sub_v2_v2v2(v2, uv3, uv); /* m and v2 on same side of v-v1? */ c1 = v1[0] * m[1] - v1[1] * m[0]; -- cgit v1.2.3 From 4cc29110aa8c2f351f357859752342af28dc8fd5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 12:04:09 +0000 Subject: fix writing past array bounds in imagewraposa(). also correct array sizes in othere areas. --- source/blender/blenlib/intern/math_vector_inline.c | 2 +- source/blender/editors/mesh/editmesh_rip.c | 2 +- source/blender/editors/mesh/editmesh_select.c | 2 +- source/blender/editors/sculpt_paint/paint_utils.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 4 ++-- source/blender/render/intern/include/texture.h | 2 +- source/blender/render/intern/source/imagetexture.c | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index c409e536b45..2cfe999e032 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -689,7 +689,7 @@ MINLINE void normal_float_to_short_v3(short out[3], const float in[3]) /********************************* Comparison ********************************/ -MINLINE int is_zero_v2(const float v[3]) +MINLINE int is_zero_v2(const float v[2]) { return (v[0] == 0 && v[1] == 0); } diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 53b877f2a6e..001d584416f 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -57,7 +57,7 @@ /* helper to find edge for edge_rip */ static float edbm_rip_rip_edgedist(ARegion *ar, float mat[][4], - const float co1[3], const float co2[2], const float mvalf[2]) + const float co1[3], const float co2[3], const float mvalf[2]) { float vec1[3], vec2[3]; diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 801c9382c26..da87767e492 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -448,7 +448,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, int *dist, short sel, short stri } /* returns labda for closest distance v1 to line-piece v2 - v3 */ -float labda_PdistVL2Dfl(const float v1[3], const float v2[3], const float v3[3]) +float labda_PdistVL2Dfl(const float v1[2], const float v2[2], const float v3[2]) { float rc[2], len; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 29a59651cf7..b3679516fff 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -201,7 +201,7 @@ static void imapaint_project(Object *ob, float model[][4], float proj[][4], cons static void imapaint_tri_weights(Object *ob, const float v1[3], const float v2[3], const float v3[3], - const float co[3], float w[3]) + const float co[2], float w[3]) { float pv1[4], pv2[4], pv3[4], h[3], divw; float model[4][4], proj[4][4], wmat[3][3], invwmat[3][3]; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index a6f4527cf98..84a69b811ca 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5945,8 +5945,8 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, if (mb->editelems) { if ((G.f & G_PICKSEL) == 0) { - unsigned char wire_col[3]; - UI_GetThemeColor3ubv(TH_WIRE, wire_col); + unsigned char wire_col[4]; + UI_GetThemeColor4ubv(TH_WIRE, wire_col); glColor3ubv(wire_col); drawDispList(scene, v3d, rv3d, base, dt, dflag, wire_col); diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index e8f171fe383..4b9fa2d2042 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -76,7 +76,7 @@ void render_realtime_texture(struct ShadeInput *shi, struct Image *ima); /* imagetexture.h */ -int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[3], const float dyt[3], struct TexResult *texres); +int imagewraposa(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], const float dxt[2], const float dyt[2], struct TexResult *texres); int imagewrap(struct Tex *tex, struct Image *ima, struct ImBuf *ibuf, const float texvec[3], struct TexResult *texres); void image_sample(struct Image *ima, float fx, float fy, float dx, float dy, float result[4]); diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index f62ed909094..6c86f2a2999 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -1018,7 +1018,7 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf) } -static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], float dxt[3], float dyt[3], TexResult *texres) +static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], float dxt[2], float dyt[2], TexResult *texres) { TexResult texr; float fx, fy, minx, maxx, miny, maxy; @@ -1412,17 +1412,17 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } -int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const float DXT[3], const float DYT[3], TexResult *texres) +int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const float DXT[2], const float DYT[2], TexResult *texres) { TexResult texr; - float fx, fy, minx, maxx, miny, maxy, dx, dy, dxt[3], dyt[3]; + float fx, fy, minx, maxx, miny, maxy, dx, dy, dxt[2], dyt[2]; float maxd, pixsize, val1, val2, val3; int curmap, retval, imaprepeat, imapextend; /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, * make a local copy here so that original vecs remain untouched */ - copy_v3_v3(dxt, DXT); - copy_v3_v3(dyt, DYT); + copy_v2_v2(dxt, DXT); + copy_v2_v2(dyt, DYT); /* anisotropic filtering */ if (tex->texfilter != TXF_BOX) -- cgit v1.2.3 From 1e2f475512e5d5614078a6154cfd38a0e05fa6ea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Oct 2012 12:36:21 +0000 Subject: added simple checker for array sizes, uses clang to parse C/C++, Warns if an array is passed to a function where the array is declared larger, eg float[2] argument is passed function defined as float[3], (or a greater size). Existing free static checkers dont do this from what I can tell. --- GNUmakefile | 5 + build_files/cmake/clang_array_check.py | 337 +++++++++++++++++++++ .../cmake/cmake_static_check_clang_array.py | 76 +++++ 3 files changed, 418 insertions(+) create mode 100644 build_files/cmake/clang_array_check.py create mode 100644 build_files/cmake/cmake_static_check_clang_array.py diff --git a/GNUmakefile b/GNUmakefile index 7b333a5fc77..90d76dfe432 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -171,6 +171,7 @@ help: @echo "" @echo "Static Source Code Checking (not associated with building blender)" @echo " * check_cppcheck - run blender source through cppcheck (C & C++)" + @echo " * check_clang_array - run blender source through clang array checking script (C & C++)" @echo " * check_splint - run blenders source through splint (C only)" @echo " * check_sparse - run blenders source through sparse (C only)" @echo " * check_smatch - run blenders source through smatch (C only)" @@ -244,6 +245,10 @@ check_cppcheck: $(CMAKE_CONFIG) cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py +check_clang_array: + $(CMAKE_CONFIG) + cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py + check_splint: $(CMAKE_CONFIG) cd $(BUILD_DIR) ; python3.2 $(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py diff --git a/build_files/cmake/clang_array_check.py b/build_files/cmake/clang_array_check.py new file mode 100644 index 00000000000..df45648f975 --- /dev/null +++ b/build_files/cmake/clang_array_check.py @@ -0,0 +1,337 @@ +# --- +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# --- +# by Campbell Barton + +""" +Invocation: + + export CLANG_BIND_DIR="/dsk/src/llvm/tools/clang/bindings/python" + export CLANG_LIB_DIR="/opt/llvm/lib" + + python2 clang_array_check.py somefile.c -DSOME_DEFINE -I/some/include + +... defines and includes are optional + +""" + +# ----------------------------------------------------------------------------- +# predefined function/arg sizes, handy sometimes, but not complete... + +defs_precalc = { + "glColor3bv": {0: 3}, + "glColor4bv": {0: 4}, + + "glColor3ubv": {0: 3}, + "glColor4ubv": {0: 4}, + + "glColor4usv": {0: 3}, + "glColor4usv": {0: 4}, + + "glColor3fv": {0: 3}, + "glColor4fv": {0: 4}, + + "glColor3dv": {0: 3}, + "glColor4dv": {0: 4}, + + "glVertex2fv": {0: 2}, + "glVertex3fv": {0: 3}, + "glVertex4fv": {0: 4}, + + "glEvalCoord1fv": {0: 1}, + "glEvalCoord1dv": {0: 1}, + "glEvalCoord2fv": {0: 2}, + "glEvalCoord2dv": {0: 2}, + + "glRasterPos2dv": {0: 2}, + "glRasterPos3dv": {0: 3}, + "glRasterPos4dv": {0: 4}, + + "glRasterPos2fv": {0: 2}, + "glRasterPos3fv": {0: 3}, + "glRasterPos4fv": {0: 4}, + + "glRasterPos2sv": {0: 2}, + "glRasterPos3sv": {0: 3}, + "glRasterPos4sv": {0: 4}, + + "glTexCoord2fv": {0: 2}, + "glTexCoord3fv": {0: 3}, + "glTexCoord4fv": {0: 4}, + + "glTexCoord2dv": {0: 2}, + "glTexCoord3dv": {0: 3}, + "glTexCoord4dv": {0: 4}, + + "glNormal3fv": {0: 3}, + "glNormal3dv": {0: 3}, + "glNormal3bv": {0: 3}, + "glNormal3iv": {0: 3}, + "glNormal3sv": {0: 3}, +} + +# ----------------------------------------------------------------------------- + +import sys + +if 0: + # Examples with LLVM as the root dir: '/dsk/src/llvm' + + # path containing 'clang/__init__.py' + CLANG_BIND_DIR = "/dsk/src/llvm/tools/clang/bindings/python" + + # path containing libclang.so + CLANG_LIB_DIR = "/opt/llvm/lib" +else: + import os + CLANG_BIND_DIR = os.environ.get("CLANG_BIND_DIR") + CLANG_LIB_DIR = os.environ.get("CLANG_LIB_DIR") + + if CLANG_BIND_DIR is None: + print("$CLANG_BIND_DIR python binding dir not set") + if CLANG_LIB_DIR is None: + print("$CLANG_LIB_DIR clang lib dir not set") + +sys.path.append(CLANG_BIND_DIR) + +import clang +import clang.cindex +from clang.cindex import (CursorKind, + TypeKind, + TokenKind) + +clang.cindex.Config.set_library_path(CLANG_LIB_DIR) + +index = clang.cindex.Index.create() + +args = sys.argv[2:] +# print(args) + +tu = index.parse(sys.argv[1], args) +print 'Translation unit:', tu.spelling + +# ----------------------------------------------------------------------------- + +def function_parm_wash_tokens(parm): + # print(parm.kind) + assert parm.kind in (CursorKind.PARM_DECL, + CursorKind.VAR_DECL, # XXX, double check this + CursorKind.FIELD_DECL, + ) + + """ + Return tolens without trailing commads and 'const' + """ + + tokens = [t for t in parm.get_tokens()] + if not tokens: + return tokens + + #if tokens[-1].kind == To + # remove trailing char + if tokens[-1].kind == TokenKind.PUNCTUATION: + if tokens[-1].spelling in (",", ")", ";"): + tokens.pop() + #else: + # print(tokens[-1].spelling) + + t_new = [] + for t in tokens: + t_kind = t.kind + t_spelling = t.spelling + ok = True + if t_kind == TokenKind.KEYWORD: + if t_spelling in ("const", "restrict", "volatile"): + ok = False + elif t_spelling.startswith("__"): + ok = False # __restrict + elif t_kind in (TokenKind.COMMENT, ): + ok = False + + # Use these + elif t_kind in (TokenKind.LITERAL, + TokenKind.PUNCTUATION, + TokenKind.IDENTIFIER): + # use but ignore + pass + + else: + print("Unknown!", t_kind, t_spelling) + + # if its OK we will add + if ok: + t_new.append(t) + return t_new + + +def parm_size(node_child): + tokens = function_parm_wash_tokens(node_child) + + # print(" ".join([t.spelling for t in tokens])) + + # NOT PERFECT CODE, EXTRACT SIZE FROM TOKENS + if len(tokens) >= 3: # foo [ 1 ] + if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and + (tokens[-2].kind == TokenKind.LITERAL and tokens[-2].spelling.isdigit()) and + (tokens[-1].kind == TokenKind.PUNCTUATION and tokens[-1].spelling == "]")): + # --- + return int(tokens[-2].spelling) + return -1 + + + +def function_get_arg_sizes(node): + # Return a dict if (index: size) items + # {arg_indx: arg_array_size, ... ] + arg_sizes = {} + + if node.spelling == "BM_vert_create" or 1: + node_parms = [node_child for node_child in node.get_children() + if node_child.kind == CursorKind.PARM_DECL] + + for i, node_child in enumerate(node_parms): + + # print(node_child.kind, node_child.spelling) + #print(node_child.type.kind, node_child.spelling) # TypeKind.POINTER + + if node_child.type.kind == TypeKind.POINTER: + pointee = node_child.type.get_pointee() + if pointee.is_pod(): + size = parm_size(node_child) + if size != -1: + arg_sizes[i] = size + + return arg_sizes + + +# ----------------------------------------------------------------------------- +_defs = {} + +def lookup_function_size_def(func_id): + return _defs.get(func_id, ()) + +# ----------------------------------------------------------------------------- + +def file_check_arg_sizes(tu): + + # main checking function + def validate_arg_size(node): + """ + Loop over args and validate sizes for args we KNOW the size of. + """ + assert node.kind == CursorKind.CALL_EXPR + # print("---", " <~> ".join([" ".join([t.spelling for t in C.get_tokens()]) for C in node.get_children()])) + # print(node.location) + + # first child is the function call, skip that. + children = list(node.get_children()) + + if not children: + return # XXX, look into this, happens on C++ + + func = children[0] + + # get the func declaration! + # works but we can better scan for functions ahead of time. + if 0: + func_dec = func.get_definition() + if func_dec: + print("FD", " ".join([t.spelling for t in func_dec.get_tokens()])) + else: + # HRMP'f - why does this fail? + print("AA", " ".join([t.spelling for t in node.get_tokens()])) + else: + args_size_definition = () # dummy + + # get the key + tok = list(func.get_tokens()) + if tok: + func_id = tok[0].spelling + args_size_definition = lookup_function_size_def(func_id) + + if not args_size_definition: + return + + children = children[1:] + for i, node_child in enumerate(children): + children = list(node_child.get_children()) + + # skip if we dont have an index... + size_def = args_size_definition.get(i, -1) + + if size_def == -1: + continue + + #print([c.kind for c in children]) + # print(" ".join([t.spelling for t in node_child.get_tokens()])) + + if len(children) == 1: + arg = children[0] + if arg.kind in (CursorKind.DECL_REF_EXPR, + CursorKind.UNEXPOSED_EXPR): + + if arg.type.kind == TypeKind.POINTER: + dec = arg.get_definition() + if dec: + size = parm_size(dec) + + # size == 0 is for 'float *a' + if size != -1 and size != 0: + + # nice print! + ''' + print("".join([t.spelling for t in func.get_tokens()]), + i, + " ".join([t.spelling for t in dec.get_tokens()])) + ''' + + # testing + # size_def = 100 + + if size < size_def: + location = node.location + print("%s:%d:%d: argument %d is size %d, should be %d" % + (location.file, + location.line, + location.column, + i + 1, size, size_def + )) + + + # we dont really care what we are looking at, just scan entire file for + # function calls. + + def recursive_func_call_check(node): + + if node.kind == CursorKind.CALL_EXPR: + validate_arg_size(node) + + for c in node.get_children(): + recursive_func_call_check(c) + + recursive_func_call_check(tu.cursor) + + +# -- first pass, cache function definitions sizes + +# PRINT FUNC DEFINES +def recursive_arg_sizes(node, ): + # print(node.kind, node.spelling) + if node.kind == CursorKind.FUNCTION_DECL: + args_sizes = function_get_arg_sizes(node) + #if args_sizes: + # print(node.spelling, args_sizes) + _defs[node.spelling] = args_sizes + # print("adding", node.spelling) + for c in node.get_children(): + recursive_arg_sizes(c) +# cache function sizes +recursive_arg_sizes(tu.cursor) +_defs.update(defs_precalc) + +# --- second pass, check against def's +file_check_arg_sizes(tu) diff --git a/build_files/cmake/cmake_static_check_clang_array.py b/build_files/cmake/cmake_static_check_clang_array.py new file mode 100644 index 00000000000..ff15a130ee0 --- /dev/null +++ b/build_files/cmake/cmake_static_check_clang_array.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3.2 + +# ***** 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. +# +# Contributor(s): Campbell Barton +# +# ***** END GPL LICENSE BLOCK ***** + +# + +import project_source_info +import subprocess +import sys +import os + +CHECKER_IGNORE_PREFIX = [ + "extern", + "intern/moto", + ] + +CHECKER_BIN = "python2" + +CHECKER_ARGS = [ + os.path.join(os.path.dirname(__file__), "clang_array_check.py"), + # not sure why this is needed, but it is. + "-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"), + ] + + +def main(): + source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX) + + check_commands = [] + for c, inc_dirs, defs in source_info: + cmd = ([CHECKER_BIN] + + CHECKER_ARGS + + [c] + + [("-I%s" % i) for i in inc_dirs] + + [("-D%s" % d) for d in defs] + ) + + check_commands.append((c, cmd)) + + process_functions = [] + + def my_process(i, c, cmd): + percent = 100.0 * (i / (len(check_commands) - 1)) + percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:" + + sys.stdout.flush() + sys.stdout.write("%s " % percent_str) + + return subprocess.Popen(cmd) + + for i, (c, cmd) in enumerate(check_commands): + process_functions.append((my_process, (i, c, cmd))) + + project_source_info.queue_processes(process_functions) + + +if __name__ == "__main__": + main() -- cgit v1.2.3 From 2ecb4781a7634b7e95c7426c0f15e98abafee4a5 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sat, 6 Oct 2012 14:35:48 +0000 Subject: Fix for incomplete loading of liboslexec static library. This is needed in order to provide the osl_allocate_closure_component function for LLVM. --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e031d0358e..dc90f962968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -770,8 +770,9 @@ if(UNIX AND NOT APPLE) find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib) find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib) find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib) - # WARNING! depends on correct order of OSL libs linking - list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY}) + # Note: --whole-archive is needed to force loading of all symbols in liboslexec, + # otherwise LLVM is missing the osl_allocate_closure_component function + list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY}) find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include) find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin) -- cgit v1.2.3 From 78978dcd805af2db50478fcba7fdf56d3fbca2ec Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sat, 6 Oct 2012 16:28:02 +0000 Subject: Fix for a case of 'static initialization fiasco' with OSL closure variables. The parameter lists are using OIIO::TypeDesc static standards, which are also static variables. With static OSL libraries these are not initialized when the closure parameter lists are initialized, so OSL rejects the closure types. Putting static initialization into functions works just as well, but ensures the OIIO::TypeDesc access is delayed until initialization is complete. --- intern/cycles/kernel/osl/background.cpp | 23 +++++-- intern/cycles/kernel/osl/bsdf_ashikhmin_velvet.cpp | 16 +++-- intern/cycles/kernel/osl/bsdf_diffuse.cpp | 30 +++++---- intern/cycles/kernel/osl/bsdf_microfacet.cpp | 74 +++++++++++++--------- intern/cycles/kernel/osl/bsdf_oren_nayar.cpp | 16 +++-- intern/cycles/kernel/osl/bsdf_phong.cpp | 34 ++++++---- intern/cycles/kernel/osl/bsdf_reflection.cpp | 14 ++-- intern/cycles/kernel/osl/bsdf_refraction.cpp | 16 +++-- intern/cycles/kernel/osl/bsdf_transparent.cpp | 12 ++-- intern/cycles/kernel/osl/bsdf_ward.cpp | 20 +++--- intern/cycles/kernel/osl/bsdf_westin.cpp | 34 ++++++---- intern/cycles/kernel/osl/bssrdf.cpp | 14 ++-- intern/cycles/kernel/osl/debug.cpp | 14 ++-- intern/cycles/kernel/osl/emissive.cpp | 12 ++-- intern/cycles/kernel/osl/osl_closures.cpp | 44 ++++++------- intern/cycles/kernel/osl/osl_closures.h | 44 ++++++------- intern/cycles/kernel/osl/vol_subsurface.cpp | 20 +++--- 17 files changed, 264 insertions(+), 173 deletions(-) diff --git a/intern/cycles/kernel/osl/background.cpp b/intern/cycles/kernel/osl/background.cpp index 81812a46b6c..6290eed0af8 100644 --- a/intern/cycles/kernel/osl/background.cpp +++ b/intern/cycles/kernel/osl/background.cpp @@ -85,16 +85,25 @@ public: } }; -ClosureParam closure_background_params[] = { - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(GenericBackgroundClosure) -}; + +ClosureParam *closure_background_params() +{ + static ClosureParam params[] = { + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(GenericBackgroundClosure) + }; + return params; +} CLOSURE_PREPARE(closure_background_prepare, GenericBackgroundClosure) -ClosureParam closure_holdout_params[] = { - CLOSURE_FINISH_PARAM(HoldoutClosure) -}; +ClosureParam *closure_holdout_params() +{ + static ClosureParam params[] = { + CLOSURE_FINISH_PARAM(HoldoutClosure) + }; + return params; +} CLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure) diff --git a/intern/cycles/kernel/osl/bsdf_ashikhmin_velvet.cpp b/intern/cycles/kernel/osl/bsdf_ashikhmin_velvet.cpp index 2c545ca55e7..a1904d7f5d7 100644 --- a/intern/cycles/kernel/osl/bsdf_ashikhmin_velvet.cpp +++ b/intern/cycles/kernel/osl/bsdf_ashikhmin_velvet.cpp @@ -173,12 +173,16 @@ public: -ClosureParam bsdf_ashikhmin_velvet_params[] = { - CLOSURE_VECTOR_PARAM(AshikhminVelvetClosure, m_N), - CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, m_sigma), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(AshikhminVelvetClosure) -}; +ClosureParam *bsdf_ashikhmin_velvet_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(AshikhminVelvetClosure, m_N), + CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, m_sigma), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(AshikhminVelvetClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_ashikhmin_velvet_prepare, AshikhminVelvetClosure) diff --git a/intern/cycles/kernel/osl/bsdf_diffuse.cpp b/intern/cycles/kernel/osl/bsdf_diffuse.cpp index 582ac01d959..1e06d3b583f 100644 --- a/intern/cycles/kernel/osl/bsdf_diffuse.cpp +++ b/intern/cycles/kernel/osl/bsdf_diffuse.cpp @@ -168,17 +168,25 @@ public: } }; -ClosureParam bsdf_diffuse_params[] = { - CLOSURE_VECTOR_PARAM(DiffuseClosure, m_N), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(DiffuseClosure) -}; - -ClosureParam bsdf_translucent_params[] = { - CLOSURE_VECTOR_PARAM(TranslucentClosure, m_N), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(TranslucentClosure) -}; +ClosureParam *bsdf_diffuse_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(DiffuseClosure, m_N), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(DiffuseClosure) + }; + return params; +} + +ClosureParam *bsdf_translucent_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(TranslucentClosure, m_N), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(TranslucentClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_diffuse_prepare, DiffuseClosure) CLOSURE_PREPARE(bsdf_translucent_prepare, TranslucentClosure) diff --git a/intern/cycles/kernel/osl/bsdf_microfacet.cpp b/intern/cycles/kernel/osl/bsdf_microfacet.cpp index 09730d8c3e1..8446dbbe982 100644 --- a/intern/cycles/kernel/osl/bsdf_microfacet.cpp +++ b/intern/cycles/kernel/osl/bsdf_microfacet.cpp @@ -503,35 +503,51 @@ public: -ClosureParam bsdf_microfacet_ggx_params[] = { - CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<0>, m_N), - CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<0>, m_ag), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>) -}; - -ClosureParam bsdf_microfacet_ggx_refraction_params[] = { - CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<1>, m_N), - CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_ag), - CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_eta), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>) -}; - -ClosureParam bsdf_microfacet_beckmann_params[] = { - CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<0>, m_N), - CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<0>, m_ab), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>) -}; - -ClosureParam bsdf_microfacet_beckmann_refraction_params[] = { - CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<1>, m_N), - CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_ab), - CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_eta), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>) -}; +ClosureParam *bsdf_microfacet_ggx_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<0>, m_N), + CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<0>, m_ag), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>) + }; + return params; +} + +ClosureParam *bsdf_microfacet_ggx_refraction_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<1>, m_N), + CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_ag), + CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_eta), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>) + }; + return params; +} + +ClosureParam *bsdf_microfacet_beckmann_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<0>, m_N), + CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<0>, m_ab), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>) + }; + return params; +} + +ClosureParam *bsdf_microfacet_beckmann_refraction_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<1>, m_N), + CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_ab), + CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_eta), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>) + }; + return params; +} CLOSURE_PREPARE(bsdf_microfacet_ggx_prepare, MicrofacetGGXClosure<0>) CLOSURE_PREPARE(bsdf_microfacet_ggx_refraction_prepare, MicrofacetGGXClosure<1>) diff --git a/intern/cycles/kernel/osl/bsdf_oren_nayar.cpp b/intern/cycles/kernel/osl/bsdf_oren_nayar.cpp index 83d0e583695..2a00100c256 100644 --- a/intern/cycles/kernel/osl/bsdf_oren_nayar.cpp +++ b/intern/cycles/kernel/osl/bsdf_oren_nayar.cpp @@ -125,12 +125,16 @@ private: } }; -ClosureParam bsdf_oren_nayar_params[] = { - CLOSURE_VECTOR_PARAM(OrenNayarClosure, m_N), - CLOSURE_FLOAT_PARAM(OrenNayarClosure, m_sigma), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(OrenNayarClosure) -}; +ClosureParam *bsdf_oren_nayar_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(OrenNayarClosure, m_N), + CLOSURE_FLOAT_PARAM(OrenNayarClosure, m_sigma), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(OrenNayarClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_oren_nayar_prepare, OrenNayarClosure) diff --git a/intern/cycles/kernel/osl/bsdf_phong.cpp b/intern/cycles/kernel/osl/bsdf_phong.cpp index 57745079d33..1f430cc6f5d 100644 --- a/intern/cycles/kernel/osl/bsdf_phong.cpp +++ b/intern/cycles/kernel/osl/bsdf_phong.cpp @@ -258,18 +258,28 @@ public: -ClosureParam bsdf_phong_params[] = { - CLOSURE_VECTOR_PARAM(PhongClosure, m_N), - CLOSURE_FLOAT_PARAM (PhongClosure, m_exponent), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(PhongClosure) }; - -ClosureParam bsdf_phong_ramp_params[] = { - CLOSURE_VECTOR_PARAM (PhongRampClosure, m_N), - CLOSURE_FLOAT_PARAM (PhongRampClosure, m_exponent), - CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, m_colors, PhongRampClosure::MAXCOLORS), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM (PhongRampClosure) }; +ClosureParam *bsdf_phong_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(PhongClosure, m_N), + CLOSURE_FLOAT_PARAM (PhongClosure, m_exponent), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(PhongClosure) + }; + return params; +} + +ClosureParam *bsdf_phong_ramp_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM (PhongRampClosure, m_N), + CLOSURE_FLOAT_PARAM (PhongRampClosure, m_exponent), + CLOSURE_COLOR_ARRAY_PARAM(PhongRampClosure, m_colors, PhongRampClosure::MAXCOLORS), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM (PhongRampClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_phong_prepare, PhongClosure) CLOSURE_PREPARE(bsdf_phong_ramp_prepare, PhongRampClosure) diff --git a/intern/cycles/kernel/osl/bsdf_reflection.cpp b/intern/cycles/kernel/osl/bsdf_reflection.cpp index 7041b4ced6f..1b85ec146d3 100644 --- a/intern/cycles/kernel/osl/bsdf_reflection.cpp +++ b/intern/cycles/kernel/osl/bsdf_reflection.cpp @@ -97,11 +97,15 @@ public: } }; -ClosureParam bsdf_reflection_params[] = { - CLOSURE_VECTOR_PARAM(ReflectionClosure, m_N), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(ReflectionClosure) -}; +ClosureParam *bsdf_reflection_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(ReflectionClosure, m_N), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(ReflectionClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_reflection_prepare, ReflectionClosure) diff --git a/intern/cycles/kernel/osl/bsdf_refraction.cpp b/intern/cycles/kernel/osl/bsdf_refraction.cpp index f56ad7b127c..76ee53f7929 100644 --- a/intern/cycles/kernel/osl/bsdf_refraction.cpp +++ b/intern/cycles/kernel/osl/bsdf_refraction.cpp @@ -108,12 +108,16 @@ public: } }; -ClosureParam bsdf_refraction_params[] = { - CLOSURE_VECTOR_PARAM(RefractionClosure, m_N), - CLOSURE_FLOAT_PARAM(RefractionClosure, m_eta), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(RefractionClosure) -}; +ClosureParam *bsdf_refraction_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(RefractionClosure, m_N), + CLOSURE_FLOAT_PARAM(RefractionClosure, m_eta), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(RefractionClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_refraction_prepare, RefractionClosure) diff --git a/intern/cycles/kernel/osl/bsdf_transparent.cpp b/intern/cycles/kernel/osl/bsdf_transparent.cpp index acde92530a2..29cef8e192f 100644 --- a/intern/cycles/kernel/osl/bsdf_transparent.cpp +++ b/intern/cycles/kernel/osl/bsdf_transparent.cpp @@ -87,10 +87,14 @@ public: -ClosureParam bsdf_transparent_params[] = { - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(TransparentClosure) -}; +ClosureParam *bsdf_transparent_params() +{ + static ClosureParam params[] = { + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(TransparentClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_transparent_prepare, TransparentClosure) diff --git a/intern/cycles/kernel/osl/bsdf_ward.cpp b/intern/cycles/kernel/osl/bsdf_ward.cpp index 4aacbc4ffc3..9d8d2fc4b76 100644 --- a/intern/cycles/kernel/osl/bsdf_ward.cpp +++ b/intern/cycles/kernel/osl/bsdf_ward.cpp @@ -211,14 +211,18 @@ public: -ClosureParam bsdf_ward_params[] = { - CLOSURE_VECTOR_PARAM(WardClosure, m_N), - CLOSURE_VECTOR_PARAM(WardClosure, m_T), - CLOSURE_FLOAT_PARAM(WardClosure, m_ax), - CLOSURE_FLOAT_PARAM(WardClosure, m_ay), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(WardClosure) -}; +ClosureParam *bsdf_ward_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(WardClosure, m_N), + CLOSURE_VECTOR_PARAM(WardClosure, m_T), + CLOSURE_FLOAT_PARAM(WardClosure, m_ax), + CLOSURE_FLOAT_PARAM(WardClosure, m_ay), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(WardClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_ward_prepare, WardClosure) diff --git a/intern/cycles/kernel/osl/bsdf_westin.cpp b/intern/cycles/kernel/osl/bsdf_westin.cpp index a476e8045f7..6716376ad3e 100644 --- a/intern/cycles/kernel/osl/bsdf_westin.cpp +++ b/intern/cycles/kernel/osl/bsdf_westin.cpp @@ -222,19 +222,27 @@ public: -ClosureParam bsdf_westin_backscatter_params[] = { - CLOSURE_VECTOR_PARAM(WestinBackscatterClosure, m_N), - CLOSURE_FLOAT_PARAM(WestinBackscatterClosure, m_roughness), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(WestinBackscatterClosure) -}; - -ClosureParam bsdf_westin_sheen_params[] = { - CLOSURE_VECTOR_PARAM(WestinSheenClosure, m_N), - CLOSURE_FLOAT_PARAM(WestinSheenClosure, m_edginess), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(WestinSheenClosure) -}; +ClosureParam *bsdf_westin_backscatter_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(WestinBackscatterClosure, m_N), + CLOSURE_FLOAT_PARAM(WestinBackscatterClosure, m_roughness), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(WestinBackscatterClosure) + }; + return params; +} + +ClosureParam *bsdf_westin_sheen_params() +{ + static ClosureParam params[] = { + CLOSURE_VECTOR_PARAM(WestinSheenClosure, m_N), + CLOSURE_FLOAT_PARAM(WestinSheenClosure, m_edginess), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(WestinSheenClosure) + }; + return params; +} CLOSURE_PREPARE(bsdf_westin_backscatter_prepare, WestinBackscatterClosure) CLOSURE_PREPARE(bsdf_westin_sheen_prepare, WestinSheenClosure) diff --git a/intern/cycles/kernel/osl/bssrdf.cpp b/intern/cycles/kernel/osl/bssrdf.cpp index b195cf513cd..889e8a54796 100644 --- a/intern/cycles/kernel/osl/bssrdf.cpp +++ b/intern/cycles/kernel/osl/bssrdf.cpp @@ -94,11 +94,15 @@ public: -ClosureParam closure_bssrdf_cubic_params[] = { - CLOSURE_COLOR_PARAM(BSSRDFCubicClosure, m_radius), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(BSSRDFCubicClosure) -}; +ClosureParam *closure_bssrdf_cubic_params() +{ + static ClosureParam params[] = { + CLOSURE_COLOR_PARAM(BSSRDFCubicClosure, m_radius), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(BSSRDFCubicClosure) + }; + return params; +} CLOSURE_PREPARE(closure_bssrdf_cubic_prepare, BSSRDFCubicClosure) diff --git a/intern/cycles/kernel/osl/debug.cpp b/intern/cycles/kernel/osl/debug.cpp index 768a9100e8a..ee5fb30371a 100644 --- a/intern/cycles/kernel/osl/debug.cpp +++ b/intern/cycles/kernel/osl/debug.cpp @@ -69,11 +69,15 @@ public: }; -ClosureParam closure_debug_params[] = { - CLOSURE_STRING_PARAM(DebugClosure, m_tag), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(DebugClosure) -}; +ClosureParam *closure_debug_params() +{ + static ClosureParam params[] = { + CLOSURE_STRING_PARAM(DebugClosure, m_tag), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(DebugClosure) + }; + return params; +} CLOSURE_PREPARE(closure_debug_prepare, DebugClosure) diff --git a/intern/cycles/kernel/osl/emissive.cpp b/intern/cycles/kernel/osl/emissive.cpp index 0a582c3f558..3ee57cbe6b6 100644 --- a/intern/cycles/kernel/osl/emissive.cpp +++ b/intern/cycles/kernel/osl/emissive.cpp @@ -97,10 +97,14 @@ public: -ClosureParam closure_emission_params[] = { - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(GenericEmissiveClosure) -}; +ClosureParam *closure_emission_params() +{ + static ClosureParam params[] = { + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(GenericEmissiveClosure) + }; + return params; +} CLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure) diff --git a/intern/cycles/kernel/osl/osl_closures.cpp b/intern/cycles/kernel/osl/osl_closures.cpp index a1a108a1b1d..9e99d4d2480 100644 --- a/intern/cycles/kernel/osl/osl_closures.cpp +++ b/intern/cycles/kernel/osl/osl_closures.cpp @@ -64,28 +64,28 @@ static void register_closure(OSL::ShadingSystem *ss, const char *name, int id, O void OSLShader::register_closures(OSL::ShadingSystem *ss) { - register_closure(ss, "diffuse", OSL_CLOSURE_BSDF_DIFFUSE_ID, bsdf_diffuse_params, bsdf_diffuse_prepare); - register_closure(ss, "oren_nayar", OSL_CLOSURE_BSDF_OREN_NAYAR_ID, bsdf_oren_nayar_params, bsdf_oren_nayar_prepare); - register_closure(ss, "translucent", OSL_CLOSURE_BSDF_TRANSLUCENT_ID, bsdf_translucent_params, bsdf_translucent_prepare); - register_closure(ss, "reflection", OSL_CLOSURE_BSDF_REFLECTION_ID, bsdf_reflection_params, bsdf_reflection_prepare); - register_closure(ss, "refraction", OSL_CLOSURE_BSDF_REFRACTION_ID, bsdf_refraction_params, bsdf_refraction_prepare); - register_closure(ss, "transparent", OSL_CLOSURE_BSDF_TRANSPARENT_ID, bsdf_transparent_params, bsdf_transparent_prepare); - register_closure(ss, "microfacet_ggx", OSL_CLOSURE_BSDF_MICROFACET_GGX_ID, bsdf_microfacet_ggx_params, bsdf_microfacet_ggx_prepare); - register_closure(ss, "microfacet_ggx_refraction", OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, bsdf_microfacet_ggx_refraction_params, bsdf_microfacet_ggx_refraction_prepare); - register_closure(ss, "microfacet_beckmann", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID, bsdf_microfacet_beckmann_params, bsdf_microfacet_beckmann_prepare); - register_closure(ss, "microfacet_beckmann_refraction", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, bsdf_microfacet_beckmann_refraction_params, bsdf_microfacet_beckmann_refraction_prepare); - register_closure(ss, "ward", OSL_CLOSURE_BSDF_WARD_ID, bsdf_ward_params, bsdf_ward_prepare); - register_closure(ss, "phong", OSL_CLOSURE_BSDF_PHONG_ID, bsdf_phong_params, bsdf_phong_prepare); - register_closure(ss, "phong_ramp", OSL_CLOSURE_BSDF_PHONG_RAMP_ID, bsdf_phong_ramp_params, bsdf_phong_ramp_prepare); - register_closure(ss, "ashikhmin_velvet", OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, bsdf_ashikhmin_velvet_params, bsdf_ashikhmin_velvet_prepare); - register_closure(ss, "westin_backscatter", OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, bsdf_westin_backscatter_params, bsdf_westin_backscatter_prepare); - register_closure(ss, "westin_sheen", OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID, bsdf_westin_sheen_params, bsdf_westin_sheen_prepare); - register_closure(ss, "bssrdf_cubic", OSL_CLOSURE_BSSRDF_CUBIC_ID, closure_bssrdf_cubic_params, closure_bssrdf_cubic_prepare); - register_closure(ss, "emission", OSL_CLOSURE_EMISSION_ID, closure_emission_params, closure_emission_prepare); - register_closure(ss, "debug", OSL_CLOSURE_DEBUG_ID, closure_debug_params, closure_debug_prepare); - register_closure(ss, "background", OSL_CLOSURE_BACKGROUND_ID, closure_background_params, closure_background_prepare); - register_closure(ss, "holdout", OSL_CLOSURE_HOLDOUT_ID, closure_holdout_params, closure_holdout_prepare); - register_closure(ss, "subsurface", OSL_CLOSURE_SUBSURFACE_ID, closure_subsurface_params, closure_subsurface_prepare); + register_closure(ss, "diffuse", OSL_CLOSURE_BSDF_DIFFUSE_ID, bsdf_diffuse_params(), bsdf_diffuse_prepare); + register_closure(ss, "oren_nayar", OSL_CLOSURE_BSDF_OREN_NAYAR_ID, bsdf_oren_nayar_params(), bsdf_oren_nayar_prepare); + register_closure(ss, "translucent", OSL_CLOSURE_BSDF_TRANSLUCENT_ID, bsdf_translucent_params(), bsdf_translucent_prepare); + register_closure(ss, "reflection", OSL_CLOSURE_BSDF_REFLECTION_ID, bsdf_reflection_params(), bsdf_reflection_prepare); + register_closure(ss, "refraction", OSL_CLOSURE_BSDF_REFRACTION_ID, bsdf_refraction_params(), bsdf_refraction_prepare); + register_closure(ss, "transparent", OSL_CLOSURE_BSDF_TRANSPARENT_ID, bsdf_transparent_params(), bsdf_transparent_prepare); + register_closure(ss, "microfacet_ggx", OSL_CLOSURE_BSDF_MICROFACET_GGX_ID, bsdf_microfacet_ggx_params(), bsdf_microfacet_ggx_prepare); + register_closure(ss, "microfacet_ggx_refraction", OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, bsdf_microfacet_ggx_refraction_params(), bsdf_microfacet_ggx_refraction_prepare); + register_closure(ss, "microfacet_beckmann", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID, bsdf_microfacet_beckmann_params(), bsdf_microfacet_beckmann_prepare); + register_closure(ss, "microfacet_beckmann_refraction", OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, bsdf_microfacet_beckmann_refraction_params(), bsdf_microfacet_beckmann_refraction_prepare); + register_closure(ss, "ward", OSL_CLOSURE_BSDF_WARD_ID, bsdf_ward_params(), bsdf_ward_prepare); + register_closure(ss, "phong", OSL_CLOSURE_BSDF_PHONG_ID, bsdf_phong_params(), bsdf_phong_prepare); + register_closure(ss, "phong_ramp", OSL_CLOSURE_BSDF_PHONG_RAMP_ID, bsdf_phong_ramp_params(), bsdf_phong_ramp_prepare); + register_closure(ss, "ashikhmin_velvet", OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, bsdf_ashikhmin_velvet_params(), bsdf_ashikhmin_velvet_prepare); + register_closure(ss, "westin_backscatter", OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, bsdf_westin_backscatter_params(), bsdf_westin_backscatter_prepare); + register_closure(ss, "westin_sheen", OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID, bsdf_westin_sheen_params(), bsdf_westin_sheen_prepare); + register_closure(ss, "bssrdf_cubic", OSL_CLOSURE_BSSRDF_CUBIC_ID, closure_bssrdf_cubic_params(), closure_bssrdf_cubic_prepare); + register_closure(ss, "emission", OSL_CLOSURE_EMISSION_ID, closure_emission_params(), closure_emission_prepare); + register_closure(ss, "debug", OSL_CLOSURE_DEBUG_ID, closure_debug_params(), closure_debug_prepare); + register_closure(ss, "background", OSL_CLOSURE_BACKGROUND_ID, closure_background_params(), closure_background_prepare); + register_closure(ss, "holdout", OSL_CLOSURE_HOLDOUT_ID, closure_holdout_params(), closure_holdout_prepare); + register_closure(ss, "subsurface", OSL_CLOSURE_SUBSURFACE_ID, closure_subsurface_params(), closure_subsurface_prepare); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/osl/osl_closures.h b/intern/cycles/kernel/osl/osl_closures.h index 00794183ca5..a69af45672d 100644 --- a/intern/cycles/kernel/osl/osl_closures.h +++ b/intern/cycles/kernel/osl/osl_closures.h @@ -64,28 +64,28 @@ enum { OSL_CLOSURE_SUBSURFACE_ID }; -extern OSL::ClosureParam bsdf_diffuse_params[]; -extern OSL::ClosureParam bsdf_oren_nayar_params[]; -extern OSL::ClosureParam bsdf_translucent_params[]; -extern OSL::ClosureParam bsdf_reflection_params[]; -extern OSL::ClosureParam bsdf_refraction_params[]; -extern OSL::ClosureParam bsdf_transparent_params[]; -extern OSL::ClosureParam bsdf_microfacet_ggx_params[]; -extern OSL::ClosureParam bsdf_microfacet_ggx_refraction_params[]; -extern OSL::ClosureParam bsdf_microfacet_beckmann_params[]; -extern OSL::ClosureParam bsdf_microfacet_beckmann_refraction_params[]; -extern OSL::ClosureParam bsdf_ward_params[]; -extern OSL::ClosureParam bsdf_phong_params[]; -extern OSL::ClosureParam bsdf_phong_ramp_params[]; -extern OSL::ClosureParam bsdf_ashikhmin_velvet_params[]; -extern OSL::ClosureParam bsdf_westin_backscatter_params[]; -extern OSL::ClosureParam bsdf_westin_sheen_params[]; -extern OSL::ClosureParam closure_bssrdf_cubic_params[]; -extern OSL::ClosureParam closure_emission_params[]; -extern OSL::ClosureParam closure_debug_params[]; -extern OSL::ClosureParam closure_background_params[]; -extern OSL::ClosureParam closure_holdout_params[]; -extern OSL::ClosureParam closure_subsurface_params[]; +OSL::ClosureParam *bsdf_diffuse_params(); +OSL::ClosureParam *bsdf_oren_nayar_params(); +OSL::ClosureParam *bsdf_translucent_params(); +OSL::ClosureParam *bsdf_reflection_params(); +OSL::ClosureParam *bsdf_refraction_params(); +OSL::ClosureParam *bsdf_transparent_params(); +OSL::ClosureParam *bsdf_microfacet_ggx_params(); +OSL::ClosureParam *bsdf_microfacet_ggx_refraction_params(); +OSL::ClosureParam *bsdf_microfacet_beckmann_params(); +OSL::ClosureParam *bsdf_microfacet_beckmann_refraction_params(); +OSL::ClosureParam *bsdf_ward_params(); +OSL::ClosureParam *bsdf_phong_params(); +OSL::ClosureParam *bsdf_phong_ramp_params(); +OSL::ClosureParam *bsdf_ashikhmin_velvet_params(); +OSL::ClosureParam *bsdf_westin_backscatter_params(); +OSL::ClosureParam *bsdf_westin_sheen_params(); +OSL::ClosureParam *closure_bssrdf_cubic_params(); +OSL::ClosureParam *closure_emission_params(); +OSL::ClosureParam *closure_debug_params(); +OSL::ClosureParam *closure_background_params(); +OSL::ClosureParam *closure_holdout_params(); +OSL::ClosureParam *closure_subsurface_params(); void bsdf_diffuse_prepare(OSL::RendererServices *, int id, void *data); void bsdf_oren_nayar_prepare(OSL::RendererServices *, int id, void *data); diff --git a/intern/cycles/kernel/osl/vol_subsurface.cpp b/intern/cycles/kernel/osl/vol_subsurface.cpp index 818a057b6cc..5845428ed43 100644 --- a/intern/cycles/kernel/osl/vol_subsurface.cpp +++ b/intern/cycles/kernel/osl/vol_subsurface.cpp @@ -122,14 +122,18 @@ public: -ClosureParam closure_subsurface_params[] = { - CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_eta), - CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_g), - CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_mfp), - CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_albedo), - CLOSURE_STRING_KEYPARAM("label"), - CLOSURE_FINISH_PARAM(SubsurfaceClosure) -}; +ClosureParam *closure_subsurface_params() +{ + static ClosureParam params[] = { + CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_eta), + CLOSURE_FLOAT_PARAM(SubsurfaceClosure, m_g), + CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_mfp), + CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_albedo), + CLOSURE_STRING_KEYPARAM("label"), + CLOSURE_FINISH_PARAM(SubsurfaceClosure) + }; + return params; +} CLOSURE_PREPARE(closure_subsurface_prepare, SubsurfaceClosure) -- cgit v1.2.3 From 1df170bb96158abebc123256df04cebe6a5f8f08 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 6 Oct 2012 16:42:11 +0000 Subject: Code cleanups for PBVH GPU buffers * De-duplicate GPU code to check if VBO should be used. * Add a flag to indicate if the buffer should be drawn smooth or not, rather than checking each time the node is drawn. --- source/blender/gpu/intern/gpu_buffers.c | 41 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 3e5a14774c2..a0a379c3cee 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1269,6 +1269,14 @@ void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, /* XXX: the rest of the code in this file is used for optimized PBVH * drawing and doesn't interact at all with the buffer code above */ +/* Return false if VBO is either unavailable or disabled by the user, + true otherwise */ +static int gpu_vbo_enabled(void) +{ + return (GLEW_ARB_vertex_buffer_object && + !(U.gameflags & USER_DISABLE_VBO)); +} + /* Convenience struct for building the VBO. */ typedef struct { float co[3]; @@ -1304,6 +1312,10 @@ struct GPU_Buffers { int has_hidden; unsigned int tot_tri, tot_quad; + + /* The PBVH ensures that either all faces in the node are + smooth-shaded or all faces are flat-shaded */ + int smooth; }; typedef enum { VBO_ENABLED, @@ -1434,6 +1446,7 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], buffers = MEM_callocN(sizeof(GPU_Buffers), "GPU_Buffers"); buffers->index_type = GL_UNSIGNED_SHORT; + buffers->smooth = mface[face_indices[0]].flag & ME_SMOOTH; /* Count the number of visible triangles */ for (i = 0, tottri = 0; i < totface; ++i) { @@ -1442,7 +1455,7 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], tottri += f->v4 ? 2 : 1; } - if (GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) + if (gpu_vbo_enabled()) glGenBuffersARB(1, &buffers->index_buf); if (buffers->index_buf) { @@ -1591,6 +1604,8 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, buffers->grid_flag_mats = grid_flag_mats; buffers->gridkey = *key; + buffers->smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; + //printf("node updated %p\n", buffers); } @@ -1685,7 +1700,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to /* VBO is disabled; delete the previous buffer (if it exists) and * return an invalid handle */ - if (!GLEW_ARB_vertex_buffer_object || (U.gameflags & USER_DISABLE_VBO)) { + if (gpu_vbo_enabled()) { if (buffer) glDeleteBuffersARB(1, &buffer); return 0; @@ -1773,7 +1788,7 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, #undef FILL_QUAD_BUFFER -static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) +static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers) { const MVert *mvert = buffers->mvert; int i, j; @@ -1793,7 +1808,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) glBegin((f->v4) ? GL_QUADS : GL_TRIANGLES); - if (smooth) { + if (buffers->smooth) { for (j = 0; j < S; j++) { if (has_mask) { gpu_color_from_mask_set(buffers->vmask[fv[j]]); @@ -1840,7 +1855,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) } } -static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) +static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) { const CCGKey *key = &buffers->gridkey; int i, j, x, y, gridsize = buffers->gridkey.grid_size; @@ -1873,7 +1888,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) if (paint_is_grid_face_hidden(gh, gridsize, x, y)) continue; - if (smooth) { + if (buffers->smooth) { for (j = 0; j < 4; j++) { if (has_mask) { gpu_color_from_mask_set(*CCG_elem_mask(key, e[j])); @@ -1903,7 +1918,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) glEnd(); } - else if (smooth) { + else if (buffers->smooth) { for (y = 0; y < gridsize - 1; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridsize; x++) { @@ -1970,19 +1985,15 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) const MFace *f = &buffers->mface[buffers->face_indices[0]]; if (!setMaterial(f->mat_nr + 1, NULL)) return; - - smooth = f->flag & ME_SMOOTH; - glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); } else if (buffers->totgrid) { const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; if (!setMaterial(f->mat_nr + 1, NULL)) return; - - smooth = f->flag & ME_SMOOTH; - glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); } + glShadeModel(buffers->smooth ? GL_SMOOTH : GL_FLAT); + if (buffers->vert_buf && buffers->index_buf) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); @@ -2042,10 +2053,10 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) } /* fallbacks if we are out of memory or VBO is disabled */ else if (buffers->totface) { - gpu_draw_buffers_legacy_mesh(buffers, smooth); + gpu_draw_buffers_legacy_mesh(buffers); } else if (buffers->totgrid) { - gpu_draw_buffers_legacy_grids(buffers, smooth); + gpu_draw_buffers_legacy_grids(buffers); } } -- cgit v1.2.3 From 0c0fa7dde66269f451d5b6ebe95860dd9e913d5f Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 6 Oct 2012 16:52:52 +0000 Subject: Improve flat-shaded VBO drawing for sculpt meshes Separate vertex copies are now made for flat-shading, such that the normal is correctly flat-shaded. The element index buffer is not created in this case. --- source/blender/gpu/intern/gpu_buffers.c | 112 ++++++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 21 deletions(-) diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index a0a379c3cee..201162262b2 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -1397,28 +1397,88 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, int *vert_indices, int totvert, const float *vmask) { VertexBufferFormat *vert_data; - int i; + int i, j, k; buffers->vmask = vmask; if (buffers->vert_buf) { + int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3)); + /* Build VBO */ glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, - sizeof(VertexBufferFormat) * totvert, - NULL, GL_STATIC_DRAW_ARB); + sizeof(VertexBufferFormat) * totelem, + NULL, GL_STATIC_DRAW_ARB); + vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); if (vert_data) { - for (i = 0; i < totvert; ++i) { - MVert *v = mvert + vert_indices[i]; - VertexBufferFormat *out = vert_data + i; - - copy_v3_v3(out->co, v->co); - memcpy(out->no, v->no, sizeof(short) * 3); - if (vmask) { - gpu_color_from_mask_copy(vmask[vert_indices[i]], - out->color); + /* Vertex data is shared if smooth-shaded, but seperate + copies are made for flat shading because normals + shouldn't be shared. */ + if (buffers->smooth) { + for (i = 0; i < totvert; ++i) { + MVert *v = mvert + vert_indices[i]; + VertexBufferFormat *out = vert_data + i; + + copy_v3_v3(out->co, v->co); + memcpy(out->no, v->no, sizeof(short) * 3); + if (vmask) { + gpu_color_from_mask_copy(vmask[vert_indices[i]], + out->color); + } + } + } + else { + for (i = 0; i < buffers->totface; ++i) { + const MFace *f = &buffers->mface[buffers->face_indices[i]]; + const unsigned int *fv = &f->v1; + const int vi[2][3] = {{0, 1, 2}, {3, 0, 2}}; + float fno[3]; + short no[3]; + + float fmask; + + /* Face normal and mask */ + if (f->v4) { + normal_quad_v3(fno, + mvert[fv[0]].co, + mvert[fv[1]].co, + mvert[fv[2]].co, + mvert[fv[3]].co); + if (vmask) { + fmask = (vmask[fv[0]] + + vmask[fv[1]] + + vmask[fv[2]] + + vmask[fv[3]]) * 0.25; + } + } + else { + normal_tri_v3(fno, + mvert[fv[0]].co, + mvert[fv[1]].co, + mvert[fv[2]].co); + if (vmask) { + fmask = (vmask[fv[0]] + + vmask[fv[1]] + + vmask[fv[2]]) / 3.0f; + } + } + normal_float_to_short_v3(no, fno); + + for (j = 0; j < (f->v4 ? 2 : 1); j++) { + for (k = 0; k < 3; k++) { + const MVert *v = &mvert[fv[vi[j][k]]]; + VertexBufferFormat *out = vert_data; + + copy_v3_v3(out->co, v->co); + memcpy(out->no, no, sizeof(short) * 3); + if (vmask) + gpu_color_from_mask_copy(fmask, out->color); + + vert_data++; + } + } } } @@ -1454,8 +1514,11 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], if (!paint_is_face_hidden(f, mvert)) tottri += f->v4 ? 2 : 1; } - - if (gpu_vbo_enabled()) + + /* An element index buffer is used for smooth shading, but flat + shading requires separate vertex normals so an index buffer is + can't be used there. */ + if (gpu_vbo_enabled() && buffers->smooth) glGenBuffersARB(1, &buffers->index_buf); if (buffers->index_buf) { @@ -1499,7 +1562,7 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } - if (buffers->index_buf) + if (buffers->index_buf || !buffers->smooth) glGenBuffersARB(1, &buffers->vert_buf); buffers->tot_tri = tottri; @@ -1979,7 +2042,6 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) { const int has_mask = (buffers->vmask || buffers->gridkey.has_mask); - int smooth = 0; if (buffers->totface) { const MFace *f = &buffers->mface[buffers->face_indices[0]]; @@ -1992,9 +2054,9 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) return; } - glShadeModel(buffers->smooth ? GL_SMOOTH : GL_FLAT); + glShadeModel((buffers->smooth || buffers->totface) ? GL_SMOOTH : GL_FLAT); - if (buffers->vert_buf && buffers->index_buf) { + if (buffers->vert_buf) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); if (has_mask) { @@ -2006,7 +2068,9 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) } glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); + + if (buffers->index_buf) + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); if (buffers->tot_quad) { char *offset = 0; @@ -2027,6 +2091,8 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) } } else { + int totelem = buffers->tot_tri * 3; + glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), (void *)offsetof(VertexBufferFormat, co)); glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), @@ -2036,11 +2102,15 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) (void *)offsetof(VertexBufferFormat, color)); } - glDrawElements(GL_TRIANGLES, buffers->tot_tri * 3, buffers->index_type, 0); + if (buffers->index_buf) + glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, 0); + else + glDrawArrays(GL_TRIANGLES, 0, totelem); } glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + if (buffers->index_buf) + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); -- cgit v1.2.3 From f7d61831e175ffc506dc0e0d3362b0f40cdce5ae Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 6 Oct 2012 17:11:53 +0000 Subject: Cycles / OSL: * OSL UI message did not show up when device type was GPU, but User Preferences were None. Also remove experimental check, more convenient for testing. --- intern/cycles/blender/addon/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 8d39b09ab0e..4f4b0371839 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -955,7 +955,7 @@ def draw_device(self, context): elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL': layout.prop(cscene, "device") - if cscene.feature_set == 'EXPERIMENTAL' and cscene.device == 'CPU' and engine.with_osl(): + if engine.with_osl() and (cscene.device == 'CPU' or device_type == 'None'): layout.prop(cscene, "shading_system") -- cgit v1.2.3 From 1e433e81ad032c522eddb50a7020c62d54c53f3f Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 6 Oct 2012 17:51:52 +0000 Subject: Increase maximum octree depth to 12 Note that this is just an RNA change, underlying dualcon octree already supports even higher values. --- source/blender/makesrna/intern/rna_modifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index eb4660c18e8..1b26c0447ff 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -3007,7 +3007,7 @@ static void rna_def_modifier_remesh(BlenderRNA *brna) prop = RNA_def_property(srna, "octree_depth", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "depth"); - RNA_def_property_range(prop, 1, 10); + RNA_def_property_range(prop, 1, 12); RNA_def_property_ui_text(prop, "Octree Depth", "Resolution of the octree; higher values give finer details"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); -- cgit v1.2.3 From 8b4baa347fbaf05c8ee84cd18d5f8f66e7d0e480 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 6 Oct 2012 18:28:34 +0000 Subject: Code cleanups for dualcon octree * Move InternalNode operators from Octree class into InternalNode struct * Constify various member functions --- intern/dualcon/intern/octree.cpp | 91 ++++++------ intern/dualcon/intern/octree.h | 299 ++++++++++++++++++++++----------------- 2 files changed, 217 insertions(+), 173 deletions(-) diff --git a/intern/dualcon/intern/octree.cpp b/intern/dualcon/intern/octree.cpp index c74f8bf2f46..f17148799a1 100644 --- a/intern/dualcon/intern/octree.cpp +++ b/intern/dualcon/intern/octree.cpp @@ -384,22 +384,22 @@ InternalNode *Octree::addTriangle(InternalNode *node, CubeTriangleIsect *p, int /* Pruning using intersection test */ if (subp->isIntersecting()) { - if (!hasChild(node, i)) { + if (!node->has_child(i)) { if (height == 1) node = addLeafChild(node, i, count, createLeaf(0)); else node = addInternalChild(node, i, count, createInternal(0)); } - Node *chd = getChild(node, count); + Node *chd = node->get_child(count); if (node->is_child_leaf(i)) - setChild(node, count, (Node *)updateCell(&chd->leaf, subp)); + node->set_child(count, (Node *)updateCell(&chd->leaf, subp)); else - setChild(node, count, (Node *)addTriangle(&chd->internal, subp, height - 1)); + node->set_child(count, (Node *)addTriangle(&chd->internal, subp, height - 1)); } } - if (hasChild(node, i)) + if (node->has_child(i)) count++; } @@ -450,11 +450,11 @@ void Octree::preparePrimalEdgesMask(InternalNode *node) { int count = 0; for (int i = 0; i < 8; i++) { - if (hasChild(node, i)) { + if (node->has_child(i)) { if (node->is_child_leaf(i)) - createPrimalEdgesMask(&getChild(node, count)->leaf); + createPrimalEdgesMask(&node->get_child(count)->leaf); else - preparePrimalEdgesMask(&getChild(node, count)->internal); + preparePrimalEdgesMask(&node->get_child(count)->internal); count++; } @@ -487,7 +487,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *& path // Get children paths int chdleaf[8]; - fillChildren(&newnode->internal, chd, chdleaf); + newnode->internal.fill_children(chd, chdleaf); // int count = 0; for (i = 0; i < 8; i++) { @@ -510,7 +510,7 @@ Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *& path int df[2] = {depth - 1, depth - 1}; int *nstf[2]; - fillChildren(&newnode->internal, chd, chdleaf); + newnode->internal.fill_children(chd, chdleaf); for (i = 0; i < 12; i++) { int c[2] = {cellProcFaceMask[i][0], cellProcFaceMask[i][1]}; @@ -590,7 +590,7 @@ void Octree::findPaths(Node *node[2], int leaf[2], int depth[2], int *st[2], int for (j = 0; j < 2; j++) { if (!leaf[j]) { - fillChildren(&node[j]->internal, chd[j], chdleaf[j]); + node[j]->internal.fill_children(chd[j], chdleaf[j]); int len = (dimen >> (maxDepth - depth[j] + 1)); for (i = 0; i < 8; i++) { @@ -966,10 +966,10 @@ Node *Octree::patch(Node *newnode, int st[3], int len, PathList *rings) st[1] + len * vertmap[i][1], st[2] + len * vertmap[i][2] }; - patch(getChild(&newnode->internal, count), nori, len, zlists[i]); + patch(newnode->internal.get_child(count), nori, len, zlists[i]); } - if (hasChild(&newnode->internal, i)) { + if (newnode->internal.has_child(i)) { count++; } } @@ -1408,16 +1408,16 @@ Node *Octree::locateCell(InternalNode *node, int st[3], int len, int ori[3], int rst[1] = st[1] + vertmap[ind][1] * len; rst[2] = st[2] + vertmap[ind][2] * len; - if (hasChild(node, ind)) { - int count = getChildCount(node, ind); - Node *chd = getChild(node, count); + if (node->has_child(ind)) { + int count = node->get_child_count(ind); + Node *chd = node->get_child(count); if (node->is_child_leaf(ind)) { rleaf = chd; rlen = len; } else { // Recur - setChild(node, count, locateCell(&chd->internal, rst, len, ori, dir, side, rleaf, rst, rlen)); + node->set_child(count, locateCell(&chd->internal, rst, len, ori, dir, side, rleaf, rst, rlen)); } } else { @@ -1724,7 +1724,7 @@ void Octree::buildSigns(unsigned char table[], Node *node, int isLeaf, int sg, i // Internal node Node *chd[8]; int leaf[8]; - fillChildren(&node->internal, chd, leaf); + node->internal.fill_children(chd, leaf); // Get the signs at the corners of the first cube rvalue[0] = sg; @@ -1784,8 +1784,8 @@ void Octree::clearProcessBits(Node *node, int height) // Internal cell, recur int count = 0; for (i = 0; i < 8; i++) { - if (hasChild(&node->internal, i)) { - clearProcessBits(getChild(&node->internal, count), height - 1); + if (node->internal.has_child(i)) { + clearProcessBits(node->internal.get_child(count), height - 1); count++; } } @@ -2016,13 +2016,13 @@ int Octree::floodFill(Node *node, int st[3], int len, int height, int threshold) int count = 0; len >>= 1; for (i = 0; i < 8; i++) { - if (hasChild((InternalNode *)node, i)) { + if (node->internal.has_child(i)) { int nst[3]; nst[0] = st[0] + vertmap[i][0] * len; nst[1] = st[1] + vertmap[i][1] * len; nst[2] = st[2] + vertmap[i][2] * len; - int d = floodFill(getChild((InternalNode *)node, count), nst, len, height - 1, threshold); + int d = floodFill(node->internal.get_child(count), nst, len, height - 1, threshold); if (d > maxtotal) { maxtotal = d; } @@ -2062,9 +2062,9 @@ void Octree::writeOut() void Octree::countIntersection(Node *node, int height, int& nedge, int& ncell, int& nface) { if (height > 0) { - int total = getNumChildren(&node->internal); + int total = node->internal.get_num_children(); for (int i = 0; i < total; i++) { - countIntersection(getChild(&node->internal, i), height - 1, nedge, ncell, nface); + countIntersection(node->internal.get_child(i), height - 1, nedge, ncell, nface); } } else { @@ -2175,7 +2175,8 @@ static void minimize(float rvalue[3], float mp[3], const float pts[12][3], solve_least_squares(ata, atb, mp, rvalue); } -void Octree::computeMinimizer(LeafNode *leaf, int st[3], int len, float rvalue[3]) +void Octree::computeMinimizer(const LeafNode *leaf, int st[3], int len, + float rvalue[3]) const { // First, gather all edge intersections float pts[12][3], norms[12][3]; @@ -2253,13 +2254,13 @@ void Octree::generateMinimizer(Node *node, int st[3], int len, int height, int& int count = 0; len >>= 1; for (i = 0; i < 8; i++) { - if (hasChild(&node->internal, i)) { + if (node->internal.has_child(i)) { int nst[3]; nst[0] = st[0] + vertmap[i][0] * len; nst[1] = st[1] + vertmap[i][1] * len; nst[2] = st[2] + vertmap[i][2] * len; - generateMinimizer(getChild(&node->internal, count), + generateMinimizer(node->internal.get_child(count), nst, len, height - 1, offset); count++; } @@ -2344,9 +2345,9 @@ void Octree::edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxde Node *chd[4][8]; for (j = 0; j < 4; j++) { for (i = 0; i < 8; i++) { - chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, - getChildCount(&node[j]->internal, i)) : NULL; + chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ? + node[j]->internal.get_child( + node[j]->internal.get_child_count(i)) : NULL; } } @@ -2391,9 +2392,9 @@ void Octree::faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxde Node *chd[2][8]; for (j = 0; j < 2; j++) { for (i = 0; i < 8; i++) { - chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, - getChildCount(&node[j]->internal, i)) : NULL; + chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ? + node[j]->internal.get_child( + node[j]->internal.get_child_count(i)) : NULL; } } @@ -2460,9 +2461,8 @@ void Octree::cellProcContour(Node *node, int leaf, int depth) // Fill children nodes Node *chd[8]; for (i = 0; i < 8; i++) { - chd[i] = ((!leaf) && hasChild(&node->internal, i)) ? - getChild(&node->internal, - getChildCount(&node->internal, i)) : NULL; + chd[i] = ((!leaf) && node->internal.has_child(i)) ? + node->internal.get_child(node->internal.get_child_count(i)) : NULL; } // 8 Cell calls @@ -2539,8 +2539,8 @@ void Octree::edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep Node *chd[4][8]; for (j = 0; j < 4; j++) { for (i = 0; i < 8; i++) { - chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, getChildCount(&node[j]->internal, i)) : NULL; + chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ? + node[j]->internal.get_child( node[j]->internal.get_child_count(i)) : NULL; } } @@ -2589,9 +2589,9 @@ void Octree::faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep Node *chd[2][8]; for (j = 0; j < 2; j++) { for (i = 0; i < 8; i++) { - chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, - getChildCount(&node[j]->internal, i)) : NULL; + chd[j][i] = ((!leaf[j]) && node[j]->internal.has_child(i)) ? + node[j]->internal.get_child( + node[j]->internal.get_child_count(i)) : NULL; } } @@ -2658,9 +2658,8 @@ void Octree::cellProcParity(Node *node, int leaf, int depth) // Fill children nodes Node *chd[8]; for (i = 0; i < 8; i++) { - chd[i] = ((!leaf) && hasChild((InternalNode *)node, i)) ? - getChild((InternalNode *)node, - getChildCount((InternalNode *)node, i)) : NULL; + chd[i] = ((!leaf) && node->internal.has_child(i)) ? + node->internal.get_child(node->internal.get_child_count(i)) : NULL; } // 8 Cell calls @@ -2803,3 +2802,7 @@ const int dirEdge[3][4] = { {7, 6, 5, 4}, {11, 10, 9, 8} }; + +int InternalNode::numChildrenTable[256]; +int InternalNode::childrenCountTable[256][8]; +int InternalNode::childrenIndexTable[256][8]; diff --git a/intern/dualcon/intern/octree.h b/intern/dualcon/intern/octree.h index 550d584baa7..6cbdc9fb3d8 100644 --- a/intern/dualcon/intern/octree.h +++ b/intern/dualcon/intern/octree.h @@ -56,12 +56,18 @@ #define EDGE_FLOATS 4 union Node; +struct LeafNode; struct InternalNode { - /* Treat as bitfield, bit N indicates whether child N exists or not */ - unsigned char has_child; - /* Treat as bitfield, bit N indicates whether child N is a leaf or not */ - unsigned char child_is_leaf; + /* Initialized in Octree::BuildTable */ + static int numChildrenTable[256]; + static int childrenCountTable[256][8]; + static int childrenIndexTable[256][8]; + + /* Bit N indicates whether child N exists or not */ + unsigned char has_child_bitfield; + /* Bit N indicates whether child N is a leaf or not */ + unsigned char child_is_leaf_bitfield; /* Can have up to eight children */ Node *children[0]; @@ -69,7 +75,78 @@ struct InternalNode { /// Test if child is leaf int is_child_leaf(int index) const { - return (child_is_leaf >> index) & 1; + return (child_is_leaf_bitfield >> index) & 1; + } + + /// If child index exists + int has_child(int index) const + { + return (has_child_bitfield >> index) & 1; + } + + /// Get the pointer to child index + Node *get_child(int count) + { + return children[count]; + } + + const Node *get_child(int count) const + { + return children[count]; + } + + /// Get total number of children + int get_num_children() const + { + return numChildrenTable[has_child_bitfield]; + } + + /// Get the count of children + int get_child_count(int index) const + { + return childrenCountTable[has_child_bitfield][index]; + } + int get_child_index(int count) + { + return childrenIndexTable[has_child_bitfield][count]; + } + const int *get_child_counts() const + { + return childrenCountTable[has_child_bitfield]; + } + + /// Get all children + void fill_children(Node *children[8], int leaf[8]) + { + int count = 0; + for (int i = 0; i < 8; i++) { + leaf[i] = is_child_leaf(i); + if (has_child(i)) { + children[i] = get_child(count); + count++; + } + else { + children[i] = NULL; + leaf[i] = 0; + } + } + } + + /// Sets the child pointer + void set_child(int count, Node *chd) + { + children[count] = chd; + } + void set_internal_child(int index, int count, InternalNode *chd) + { + set_child(count, (Node *)chd); + has_child_bitfield |= (1 << index); + } + void set_leaf_child(int index, int count, LeafNode *chd) + { + set_child(count, (Node *)chd); + has_child_bitfield |= (1 << index); + child_is_leaf_bitfield |= (1 << index); } }; @@ -345,7 +422,8 @@ class Octree void countIntersection(Node *node, int height, int& nedge, int& ncell, int& nface); void generateMinimizer(Node * node, int st[3], int len, int height, int& offset); - void computeMinimizer(LeafNode * leaf, int st[3], int len, float rvalue[3]); + void computeMinimizer(const LeafNode * leaf, int st[3], int len, + float rvalue[3]) const; /** * Traversal functions to generate polygon model * op: 0 for counting, 1 for writing OBJ, 2 for writing OFF, 3 for writing PLY @@ -365,9 +443,6 @@ class Octree /************ Operators for all nodes ************/ /// Lookup table - int numChildrenTable[256]; - int childrenCountTable[256][8]; - int childrenIndexTable[256][8]; int numEdgeTable[8]; int edgeCountTable[8][3]; @@ -375,12 +450,12 @@ class Octree void buildTable() { for (int i = 0; i < 256; i++) { - numChildrenTable[i] = 0; + InternalNode::numChildrenTable[i] = 0; int count = 0; for (int j = 0; j < 8; j++) { - numChildrenTable[i] += ((i >> j) & 1); - childrenCountTable[i][j] = count; - childrenIndexTable[i][count] = j; + InternalNode::numChildrenTable[i] += ((i >> j) & 1); + InternalNode::childrenCountTable[i][j] = count; + InternalNode::childrenIndexTable[i][count] = j; count += ((i >> j) & 1); } } @@ -402,15 +477,15 @@ class Octree return getSign(&node->leaf, index); } else { - if (hasChild(&node->internal, index)) { - return getSign(getChild(&node->internal, getChildCount(&node->internal, index)), + if (node->internal.has_child(index)) { + return getSign(node->internal.get_child(node->internal.get_child_count(index)), height - 1, index); } else { - return getSign(getChild(&node->internal, 0), + return getSign(node->internal.get_child(0), height - 1, - 7 - getChildIndex(&node->internal, 0)); + 7 - node->internal.get_child_index(0)); } } } @@ -469,7 +544,7 @@ class Octree leaf->signs |= ((sign & 1) << index); } - int getSignMask(const LeafNode *leaf) + int getSignMask(const LeafNode *leaf) const { return leaf->signs; } @@ -536,7 +611,7 @@ class Octree } /// Get edge parity - int getEdgeParity(LeafNode *leaf, int index) + int getEdgeParity(const LeafNode *leaf, int index) const { assert(index >= 0 && index <= 11); @@ -597,7 +672,8 @@ class Octree leaf->primary_edge_intersections |= (1 << pindex); } - int getStoredEdgesParity(LeafNode *leaf, int pindex) + + int getStoredEdgesParity(const LeafNode *leaf, int pindex) const { assert(pindex <= 2 && pindex >= 0); @@ -652,7 +728,7 @@ class Octree InternalNode *parent = locateParent(node, len, st, count); // Update - setChild(parent, count, (Node *)leaf); + parent->set_child(count, (Node *)leaf); } void updateParent(InternalNode *node, int len, int st[3]) @@ -667,14 +743,14 @@ class Octree InternalNode *parent = locateParent(len, st, count); // UPdate - setChild(parent, count, (Node *)node); + parent->set_child(count, (Node *)node); } /// Find edge intersection on a given edge - int getEdgeIntersectionByIndex(int st[3], int index, float pt[3], int check) + int getEdgeIntersectionByIndex(int st[3], int index, float pt[3], int check) const { // First, locat the leaf - LeafNode *leaf; + const LeafNode *leaf; if (check) { leaf = locateLeafCheck(st); } @@ -697,7 +773,7 @@ class Octree } /// Retrieve number of edges intersected - int getPrimalEdgesMask(LeafNode *leaf) + int getPrimalEdgesMask(const LeafNode *leaf) const { return leaf->primary_edge_intersections; } @@ -710,7 +786,7 @@ class Octree } /// Get the count for a primary edge - int getEdgeCount(LeafNode *leaf, int index) + int getEdgeCount(const LeafNode *leaf, int index) const { return edgeCountTable[getPrimalEdgesMask(leaf)][index]; } @@ -744,7 +820,7 @@ class Octree } /// Retrieve edge intersection - float getEdgeOffset(LeafNode *leaf, int count) + float getEdgeOffset(const LeafNode *leaf, int count) const { return leaf->edge_intersections[4 * count]; } @@ -834,10 +910,11 @@ class Octree } /// Retrieve complete edge intersection - void getEdgeIntersectionByIndex(LeafNode *leaf, int index, int st[3], int len, float pt[3], float nm[3]) + void getEdgeIntersectionByIndex(const LeafNode *leaf, int index, int st[3], + int len, float pt[3], float nm[3]) const { int count = getEdgeCount(leaf, index); - float *pts = leaf->edge_intersections; + const float *pts = leaf->edge_intersections; float off = pts[4 * count]; @@ -865,7 +942,8 @@ class Octree return off; } - void fillEdgeIntersections(LeafNode *leaf, int st[3], int len, float pts[12][3], float norms[12][3]) + void fillEdgeIntersections(const LeafNode *leaf, int st[3], int len, + float pts[12][3], float norms[12][3]) const { int i; // int stt[3] = {0, 0, 0}; @@ -890,7 +968,7 @@ class Octree nst[i] += len; // int nstt[3] = {0, 0, 0}; // nstt[i] += 1; - LeafNode *node = locateLeaf(nst); + const LeafNode *node = locateLeaf(nst); if (e1) { // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]], norms[fmask[i][0]]); @@ -912,7 +990,7 @@ class Octree nst[i] -= len; // int nstt[3] = {1, 1, 1}; // nstt[i] -= 1; - LeafNode *node = locateLeaf(nst); + const LeafNode *node = locateLeaf(nst); // getEdgeIntersectionByIndex(node, eemask[i], nstt, 1, pts[emask[i]], norms[emask[i]]); getEdgeIntersectionByIndex(node, eemask[i], nst, len, pts[emask[i]], norms[emask[i]]); @@ -921,7 +999,9 @@ class Octree } - void fillEdgeIntersections(LeafNode *leaf, int st[3], int len, float pts[12][3], float norms[12][3], int parity[12]) + void fillEdgeIntersections(const LeafNode *leaf, int st[3], int len, + float pts[12][3], float norms[12][3], + int parity[12]) const { int i; for (i = 0; i < 12; i++) { @@ -948,7 +1028,7 @@ class Octree nst[i] += len; // int nstt[3] = {0, 0, 0}; // nstt[i] += 1; - LeafNode *node = locateLeafCheck(nst); + const LeafNode *node = locateLeafCheck(nst); if (node == NULL) { continue; } @@ -979,7 +1059,7 @@ class Octree nst[i] -= len; // int nstt[3] = {1, 1, 1}; // nstt[i] -= 1; - LeafNode *node = locateLeafCheck(nst); + const LeafNode *node = locateLeafCheck(nst); if (node == NULL) { continue; } @@ -1088,7 +1168,20 @@ class Octree int index = (((st[0] >> i) & 1) << 2) | (((st[1] >> i) & 1) << 1) | (((st[2] >> i) & 1)); - node = getChild(&node->internal, getChildCount(&node->internal, index)); + node = node->internal.get_child(node->internal.get_child_count(index)); + } + + return &node->leaf; + } + + const LeafNode *locateLeaf(int st[3]) const + { + const Node *node = root; + for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) { + int index = (((st[0] >> i) & 1) << 2) | + (((st[1] >> i) & 1) << 1) | + (((st[2] >> i) & 1)); + node = node->internal.get_child(node->internal.get_child_count(index)); } return &node->leaf; @@ -1102,8 +1195,7 @@ class Octree index = (((st[0] & i) ? 4 : 0) | ((st[1] & i) ? 2 : 0) | ((st[2] & i) ? 1 : 0)); - node = getChild(&node->internal, - getChildCount(&node->internal, index)); + node = node->internal.get_child(node->internal.get_child_count(index)); } return &node->leaf; @@ -1116,10 +1208,26 @@ class Octree int index = (((st[0] >> i) & 1) << 2) | (((st[1] >> i) & 1) << 1) | (((st[2] >> i) & 1)); - if (!hasChild(&node->internal, index)) { + if (!node->internal.has_child(index)) { + return NULL; + } + node = node->internal.get_child(node->internal.get_child_count(index)); + } + + return &node->leaf; + } + + const LeafNode *locateLeafCheck(int st[3]) const + { + const Node *node = root; + for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) { + int index = (((st[0] >> i) & 1) << 2) | + (((st[1] >> i) & 1) << 1) | + (((st[2] >> i) & 1)); + if (!node->internal.has_child(index)) { return NULL; } - node = getChild(&node->internal, getChildCount(&node->internal, index)); + node = node->internal.get_child(node->internal.get_child_count(index)); } return &node->leaf; @@ -1135,10 +1243,10 @@ class Octree ((st[1] & i) ? 2 : 0) | ((st[2] & i) ? 1 : 0)); pre = node; - node = &getChild(node, getChildCount(node, index))->internal; + node = &node->get_child(node->get_child_count(index))->internal; } - count = getChildCount(pre, index); + count = pre->get_child_count(index); return pre; } @@ -1152,88 +1260,21 @@ class Octree ((st[1] & i) ? 2 : 0) | ((st[2] & i) ? 1 : 0)); pre = node; - node = (InternalNode *)getChild(node, getChildCount(node, index)); + node = &node->get_child(node->get_child_count(index))->internal; } - count = getChildCount(pre, index); + count = pre->get_child_count(index); return pre; } /************ Operators for internal nodes ************/ - /// If child index exists - int hasChild(InternalNode *node, int index) - { - return (node->has_child >> index) & 1; - } - - /// Get the pointer to child index - Node *getChild(InternalNode *node, int count) - { - return node->children[count]; - }; - - /// Get total number of children - int getNumChildren(InternalNode *node) - { - return numChildrenTable[node->has_child]; - } - - /// Get the count of children - int getChildCount(InternalNode *node, int index) - { - return childrenCountTable[node->has_child][index]; - } - int getChildIndex(InternalNode *node, int count) - { - return childrenIndexTable[node->has_child][count]; - } - int *getChildCounts(InternalNode *node) - { - return childrenCountTable[node->has_child]; - } - - /// Get all children - void fillChildren(InternalNode *node, Node *children[8], int leaf[8]) - { - int count = 0; - for (int i = 0; i < 8; i++) { - leaf[i] = node->is_child_leaf(i); - if (hasChild(node, i)) { - children[i] = getChild(node, count); - count++; - } - else { - children[i] = NULL; - leaf[i] = 0; - } - } - } - - /// Sets the child pointer - void setChild(InternalNode *node, int count, Node *chd) - { - node->children[count] = chd; - } - void setInternalChild(InternalNode *node, int index, int count, InternalNode *chd) - { - setChild(node, count, (Node *)chd); - node->has_child |= (1 << index); - } - void setLeafChild(InternalNode *node, int index, int count, LeafNode *chd) - { - setChild(node, count, (Node *)chd); - node->has_child |= (1 << index); - node->child_is_leaf |= (1 << index); - } /// Add a kid to an existing internal node - /// Fix me: can we do this without wasting memory ? - /// Fixed: using variable memory InternalNode *addChild(InternalNode *node, int index, Node *child, int aLeaf) { // Create new internal node - int num = getNumChildren(node); + int num = node->get_num_children(); InternalNode *rnode = createInternal(num + 1); // Establish children @@ -1242,19 +1283,19 @@ class Octree for (i = 0; i < 8; i++) { if (i == index) { if (aLeaf) { - setLeafChild(rnode, i, count2, &child->leaf); + rnode->set_leaf_child(i, count2, &child->leaf); } else { - setInternalChild(rnode, i, count2, &child->internal); + rnode->set_internal_child(i, count2, &child->internal); } count2++; } - else if (hasChild(node, i)) { + else if (node->has_child(i)) { if (node->is_child_leaf(i)) { - setLeafChild(rnode, i, count2, &getChild(node, count1)->leaf); + rnode->set_leaf_child(i, count2, &node->get_child(count1)->leaf); } else { - setInternalChild(rnode, i, count2, &getChild(node, count1)->internal); + rnode->set_internal_child(i, count2, &node->get_child(count1)->internal); } count1++; count2++; @@ -1269,8 +1310,8 @@ class Octree InternalNode *createInternal(int length) { InternalNode *inode = (InternalNode *)alloc[length]->allocate(); - inode->has_child = 0; - inode->child_is_leaf = 0; + inode->has_child_bitfield = 0; + inode->child_is_leaf_bitfield = 0; return inode; } @@ -1301,21 +1342,21 @@ class Octree InternalNode *addLeafChild(InternalNode *par, int index, int count, LeafNode *leaf) { - int num = getNumChildren(par) + 1; + int num = par->get_num_children() + 1; InternalNode *npar = createInternal(num); *npar = *par; if (num == 1) { - setLeafChild(npar, index, 0, leaf); + npar->set_leaf_child(index, 0, leaf); } else { int i; for (i = 0; i < count; i++) { - setChild(npar, i, getChild(par, i)); + npar->set_child(i, par->get_child(i)); } - setLeafChild(npar, index, count, leaf); + npar->set_leaf_child(index, count, leaf); for (i = count + 1; i < num; i++) { - setChild(npar, i, getChild(par, i - 1)); + npar->set_child(i, par->get_child(i - 1)); } } @@ -1326,21 +1367,21 @@ class Octree InternalNode *addInternalChild(InternalNode *par, int index, int count, InternalNode *node) { - int num = getNumChildren(par) + 1; + int num = par->get_num_children() + 1; InternalNode *npar = createInternal(num); *npar = *par; if (num == 1) { - setInternalChild(npar, index, 0, node); + npar->set_internal_child(index, 0, node); } else { int i; for (i = 0; i < count; i++) { - setChild(npar, i, getChild(par, i)); + npar->set_child(i, par->get_child(i)); } - setInternalChild(npar, index, count, node); + npar->set_internal_child(index, count, node); for (i = count + 1; i < num; i++) { - setChild(npar, i, getChild(par, i - 1)); + npar->set_child(i, par->get_child(i - 1)); } } -- cgit v1.2.3 From e8bc62e16232aff442d2f0f6d52ff37e0c79be92 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 6 Oct 2012 18:28:38 +0000 Subject: Avoid unecessary minimizer calculations in dualcon * The minimize() function, which solves a least-squares problem, is only needed for sharp remesh mode, but was being calculated for smooth and blocks modes as well. Disabling this calculation when it's not needed gives a big performance boost. --- intern/dualcon/intern/octree.cpp | 78 ++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 19 deletions(-) diff --git a/intern/dualcon/intern/octree.cpp b/intern/dualcon/intern/octree.cpp index f17148799a1..49c50c8240d 100644 --- a/intern/dualcon/intern/octree.cpp +++ b/intern/dualcon/intern/octree.cpp @@ -2128,8 +2128,32 @@ static void solve_least_squares(const float halfA[], const float b[], rvalue[i] = result(i); } +static void mass_point(float mp[3], const float pts[12][3], const int parity[12]) +{ + int ec = 0; + + for (int i = 0; i < 12; i++) { + if (parity[i]) { + const float *p = pts[i]; + + mp[0] += p[0]; + mp[1] += p[1]; + mp[2] += p[2]; + + ec++; + } + } + + if (ec == 0) { + return; + } + mp[0] /= ec; + mp[1] /= ec; + mp[2] /= ec; +} + static void minimize(float rvalue[3], float mp[3], const float pts[12][3], - const float norms[12][3], const int parity[12]) + const float norms[12][3], const int parity[12]) { float ata[6] = {0, 0, 0, 0, 0, 0}; float atb[3] = {0, 0, 0}; @@ -2183,27 +2207,43 @@ void Octree::computeMinimizer(const LeafNode *leaf, int st[3], int len, int parity[12]; fillEdgeIntersections(leaf, st, len, pts, norms, parity); - // Next, construct QEF and minimizer - float mp[3] = {0, 0, 0}; - minimize(rvalue, mp, pts, norms, parity); - - /* Restraining the location of the minimizer */ - float nh1 = hermite_num * len; - float nh2 = (1 + hermite_num) * len; - if ((mode == DUALCON_MASS_POINT || mode == DUALCON_CENTROID) || - (rvalue[0] < st[0] - nh1 || rvalue[1] < st[1] - nh1 || rvalue[2] < st[2] - nh1 || - rvalue[0] > st[0] + nh2 || rvalue[1] > st[1] + nh2 || rvalue[2] > st[2] + nh2)) { - if (mode == DUALCON_CENTROID) { - // Use centroids + switch (mode) { + case DUALCON_CENTROID: rvalue[0] = (float) st[0] + len / 2; rvalue[1] = (float) st[1] + len / 2; rvalue[2] = (float) st[2] + len / 2; - } - else { - // Use mass point instead - rvalue[0] = mp[0]; - rvalue[1] = mp[1]; - rvalue[2] = mp[2]; + break; + + case DUALCON_MASS_POINT: + rvalue[0] = rvalue[1] = rvalue[2] = 0; + mass_point(rvalue, pts, parity); + break; + + default: { + // Sharp features */ + + // construct QEF and minimizer + float mp[3] = {0, 0, 0}; + minimize(rvalue, mp, pts, norms, parity); + + /* Restraining the location of the minimizer */ + float nh1 = hermite_num * len; + float nh2 = (1 + hermite_num) * len; + + if (rvalue[0] < st[0] - nh1 || + rvalue[1] < st[1] - nh1 || + rvalue[2] < st[2] - nh1 || + + rvalue[0] > st[0] + nh2 || + rvalue[1] > st[1] + nh2 || + rvalue[2] > st[2] + nh2) + { + // Use mass point instead + rvalue[0] = mp[0]; + rvalue[1] = mp[1]; + rvalue[2] = mp[2]; + } + break; } } } -- cgit v1.2.3 From 868df3525e79ff6c4f5eb6a2801bb70553877fcb Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sat, 6 Oct 2012 18:40:05 +0000 Subject: Fix for WITH_LLVM cmake option: When using WITH_CYCLES_OSL this option is forced ON, but this change was not cached yet. Thanks to Jens Verwiebe for providing this fix. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc90f962968..47a53d0edb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -376,7 +376,7 @@ endif() # auto enable llvm for cycles_osl if(WITH_CYCLES_OSL) - set(WITH_LLVM ON) + set(WITH_LLVM ON CACHE BOOL "ON" FORCE) endif() # don't store paths to libs for portable distribution -- cgit v1.2.3 From e7db06ad9db5a1a05b00fc835038d4366d637851 Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sat, 6 Oct 2012 18:53:57 +0000 Subject: Force USE_QTKIT for osx 64bit --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47a53d0edb1..1f0ef41fe59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,6 +319,9 @@ if(APPLE) option(WITH_COCOA "Use Cocoa framework instead of deprecated Carbon" ON) option(USE_QTKIT "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF) option(WITH_LIBS10.5 "Use 10.5 libs (needed for 64bit builds)" OFF) + if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64) + set(USE_QTKIT ON CACHE BOOL "ON" FORCE) # no Quicktime in 64bit + endif() endif() -- cgit v1.2.3 From 7beff06950a9811a9689ab2d04f8ca4d573d1436 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 7 Oct 2012 00:09:02 +0000 Subject: BGE: Committing patch [#31442] "API improvements: Group references python api, for better control over groups and instances" by Martin Sell (moerdn). This patch adds a member and a group property to KX_GameObject: * KX_GameObject.member returns the list of group members if the object is a group object, otherwise None is returned * KX_GameObject.group returns the group object that the object belongs to or None if the object is not part of a group --- doc/python_api/rst/bge.types.rst | 12 +++++ source/gameengine/Ketsji/KX_GameObject.cpp | 76 +++++++++++++++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 32 +++++++++++++ source/gameengine/Ketsji/KX_Scene.cpp | 21 +++++++++ 4 files changed, 140 insertions(+), 1 deletion(-) diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index f4374f7f355..6599cfeb2b2 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -986,6 +986,18 @@ Types The object's parent object. (read-only). :type: :class:`KX_GameObject` or None + + .. attribute:: members + + Returns the list of group members if the object is a group object, otherwise None is returned. + + :type: :class:`CListValue` of :class:`KX_GameObject` or None + + .. attribute:: group + + Returns the group object that the object belongs to or None if the object is not part of a group. + + :type: :class:`KX_GameObject` or None .. attribute:: visible diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index fe8419d5343..80634c3d8fc 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -110,7 +110,9 @@ KX_GameObject::KX_GameObject( m_pHitObject(NULL), m_pObstacleSimulation(NULL), m_actionManager(NULL), - m_isDeformable(false) + m_isDeformable(false), + m_pDupliGroupObject(NULL), + m_pInstanceObjects(NULL) #ifdef WITH_PYTHON , m_attr_dict(NULL) #endif @@ -168,6 +170,16 @@ KX_GameObject::~KX_GameObject() KX_GetActiveScene()->RemoveAnimatedObject(this); delete m_actionManager; } + + if (m_pDupliGroupObject) + { + m_pDupliGroupObject->Release(); + } + + if (m_pInstanceObjects) + { + m_pInstanceObjects->Release(); + } #ifdef WITH_PYTHON if (m_attr_dict) { PyDict_Clear(m_attr_dict); /* in case of circular refs or other weird cases */ @@ -229,6 +241,46 @@ KX_IPhysicsController* KX_GameObject::GetPhysicsController() return m_pPhysicsController1; } +KX_GameObject* KX_GameObject::GetDupliGroupObject() +{ + return m_pDupliGroupObject; +} + +CListValue* KX_GameObject::GetInstanceObjects() +{ + return m_pInstanceObjects; +} + +void KX_GameObject::AddInstanceObjects(KX_GameObject* obj) +{ + if(!m_pInstanceObjects) + m_pInstanceObjects = new CListValue(); + + obj->AddRef(); + m_pInstanceObjects->Add(obj); +} + +void KX_GameObject::RemoveInstanceObject(KX_GameObject* obj) +{ + assert(m_pInstanceObjects); + m_pInstanceObjects->RemoveValue(obj); + obj->Release(); +} + +void KX_GameObject::RemoveDupliGroupObject() +{ + if(m_pDupliGroupObject) { + m_pDupliGroupObject->Release(); + m_pDupliGroupObject = NULL; + } +} + +void KX_GameObject::SetDupliGroupObject(KX_GameObject* obj) +{ + obj->AddRef(); + m_pDupliGroupObject = obj; +} + KX_GameObject* KX_GameObject::GetParent() { KX_GameObject* result = NULL; @@ -1629,6 +1681,8 @@ PyMethodDef KX_GameObject::Methods[] = { PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("name", KX_GameObject, pyattr_get_name), KX_PYATTRIBUTE_RO_FUNCTION("parent", KX_GameObject, pyattr_get_parent), + KX_PYATTRIBUTE_RO_FUNCTION("members", KX_GameObject, pyattr_get_instance_objects), + KX_PYATTRIBUTE_RO_FUNCTION("group", KX_GameObject, pyattr_get_dupli_group_object), KX_PYATTRIBUTE_RO_FUNCTION("life", KX_GameObject, pyattr_get_life), KX_PYATTRIBUTE_RW_FUNCTION("mass", KX_GameObject, pyattr_get_mass, pyattr_set_mass), KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min), @@ -1924,6 +1978,26 @@ PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE Py_RETURN_NONE; } +PyObject *KX_GameObject::pyattr_get_instance_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject* self= static_cast(self_v); + CListValue* instances = self->GetInstanceObjects(); + if (instances) { + return instances->GetProxy(); + } + Py_RETURN_NONE; +} + +PyObject *KX_GameObject::pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject* self= static_cast(self_v); + KX_GameObject* pivot = self->GetDupliGroupObject(); + if (pivot) { + return pivot->GetProxy(); + } + Py_RETURN_NONE; +} + PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast(self_v); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index ea75ca4a917..4fde0752a13 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -116,6 +116,8 @@ protected: KX_ObstacleSimulation* m_pObstacleSimulation; + CListValue* m_pInstanceObjects; + KX_GameObject* m_pDupliGroupObject; // The action manager is used to play/stop/update actions BL_ActionManager* m_actionManager; @@ -207,6 +209,33 @@ public: */ void RemoveParent(KX_Scene *scene); + /********************************* + * group reference API + *********************************/ + + KX_GameObject* + GetDupliGroupObject( + ); + + CListValue* + GetInstanceObjects( + ); + + void + SetDupliGroupObject(KX_GameObject* + ); + + void + AddInstanceObjects(KX_GameObject* + ); + + void + RemoveDupliGroupObject( + ); + + void + RemoveInstanceObject(KX_GameObject* + ); /********************************* * Animation API *********************************/ @@ -949,6 +978,9 @@ public: static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_instance_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 652ed2ab2dd..a4237f9fabe 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -769,6 +769,13 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // we can now add the graphic controller to the physic engine replica->ActivateGraphicController(true); + // set references for dupli-group + // groupobj holds a list of all objects, that belongs to this group + groupobj->AddInstanceObjects(replica); + + // every object gets the reference to its dupli-group object + replica->SetDupliGroupObject(groupobj); + // done with replica replica->Release(); } @@ -1017,6 +1024,20 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) m_timemgr->RemoveTimeProperty(propval); } } + + // if the object is the dupligroup proxy, you have to cleanup all m_pDupliGroupObject's in all + // instances refering to this group + if(newobj->GetInstanceObjects()) { + for (int i = 0; i < newobj->GetInstanceObjects()->GetCount(); i++) { + KX_GameObject* instance = (KX_GameObject*)newobj->GetInstanceObjects()->GetValue(i); + instance->RemoveDupliGroupObject(); + } + } + + // if this object was part of a group, make sure to remove it from that group's instance list + KX_GameObject* group = newobj->GetDupliGroupObject(); + if (group) + group->RemoveInstanceObject(newobj); newobj->RemoveMeshes(); ret = 1; -- cgit v1.2.3 From 397d316ab1cb2ef5ee42eae6ce18d154479aa6b8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 7 Oct 2012 00:30:31 +0000 Subject: Fix render engine API compatibility breakage in end_result, this parameter should have been optional. --- source/blender/makesrna/intern/rna_render.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index d2e4e8edbfb..039d50e4ee8 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -329,7 +329,6 @@ static void rna_def_render_engine(BlenderRNA *brna) prop = RNA_def_pointer(func, "result", "RenderResult", "Result", ""); RNA_def_property_flag(prop, PROP_REQUIRED); prop = RNA_def_boolean(func, "cancel", 0, "Cancel", "Don't merge back results"); - RNA_def_property_flag(prop, PROP_REQUIRED); func = RNA_def_function(srna, "test_break", "RE_engine_test_break"); prop = RNA_def_boolean(func, "do_break", 0, "Break", ""); -- cgit v1.2.3 From d5de816a150501c0041c6315a3dd8dc572c5887e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 03:26:30 +0000 Subject: patch [#32791] Spelling mistakes corrected. from Sunny Gogoi (darkowlzz) --- doc/guides/interface_API.txt | 16 ++++++++-------- source/blender/editors/interface/interface_layout.c | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/guides/interface_API.txt b/doc/guides/interface_API.txt index 5f601dd3ebc..5f0fbc85ff8 100644 --- a/doc/guides/interface_API.txt +++ b/doc/guides/interface_API.txt @@ -50,7 +50,7 @@ Contents - It works with only OpenGL calls, for the full 100%. This means that it has some quirks built-in to work with all OS's and OpenGL versions. Especially frontbuffer drawing is a continuous point of attention. Buttons can be drawn with any window matrix. However, - errors can still occor when buttons are created in windows with non-standard glViewports. + errors can still occur when buttons are created in windows with non-standard glViewports. - The code was written to replace the old 1.8 button system, but under high pressure. Quite some button methods from the old system were copied for that reason. @@ -95,7 +95,7 @@ blender/source/blender/src/toolbox.c (extra GUI elements built on top of this AP All GUI elements are collected in uiBlocks, which in turn are linked together in a list that's part of a Blender Area-window. - uiBlock *block= uiNewBlock(&curarea->uiblocks, "stuff", UI_EMBOSSX, UI_HELV, curarea->win); + uiBlock *block = uiNewBlock(&curarea->uiblocks, "stuff", UI_EMBOSSX, UI_HELV, curarea->win); The next code example makes a new block, and puts it in the list of blocks of the current active Area: @@ -221,7 +221,7 @@ void uiBlockSetButmFunc(uiBlock *block, void (*menufunc)(void *arg, int event), void uiAutoBlock(uiBlock *block, float minx, float miny, float sizex, float sizey, UI_BLOCK_ROWS) Sets the buttons in this block to automatically align, and fit within boundaries. - Internally it allows multiple collums or rows as well. Only 'row order' has been implemented. + Internally it allows multiple colums or rows as well. Only 'row order' has been implemented. The uiDefBut definitions don't need coordinates as input here, but instead: - first value (x1) to indicate row number - width and height values (if filled in) will be used to define a relative width/height. @@ -346,7 +346,7 @@ type: without returnvalues, the first item gets value 0 (incl. title!) Example: "Do something %t| turn left %2| turn right %1| nothing %0" -11. COL +11. COLOR A special button that only visualizes a RGB value In 'retval' you can put a code, which is used to identify for sliders if it needs redraws while using the sliders. Check button '5'. @@ -363,7 +363,7 @@ uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, float min, float max, float a1, float a2, char *tip) Same syntax and types available as previous uiDefBut, but now with an icon code - instead of a name. THe icons are numbered in resources.c + instead of a name. The icons are numbered in resources.c uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, float *poin, @@ -397,9 +397,9 @@ void uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, static uiBlock *info_file_importmenu(void *arg_unused) { uiBlock *block; - short yco= 0, xco = 20; + short yco = 0, xco = 20; - block= uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSW, UI_HELV, G.curscreen->mainwin); + block = uiNewBlock(&curarea->uiblocks, "importmenu", UI_EMBOSSW, UI_HELV, G.curscreen->mainwin); uiBlockSetXOfs(block, -40); // offset to parent button /* flags are defines */ @@ -409,7 +409,7 @@ void uiDefBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, char *str, uiDefButS(block, TOG|BIT|2, 0, "Two Sided", xco, yco-=20, 75, 19, &U.vrmlflag, 0.0, 0.0, 0, 0, ""); uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 50); // checks for fontsize + uiTextBoundsBlock(block, 50); /* checks for fontsize */ return block; } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 7a369019ac4..d692bf8e492 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -835,8 +835,9 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname bt = block->buttons.last; bt->flag = UI_TEXT_LEFT; } - else /* XXX bug here, collums draw bottom item badly */ + else { /* XXX bug here, colums draw bottom item badly */ uiItemS(column); + } } } -- cgit v1.2.3 From a17e39476cf3d7bc7724e5d259d0c3572cdb08dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 04:21:37 +0000 Subject: Optimization for endian switching, but shifting is a lot faster then using a temp char (approx 18x speedup on my system). --- source/blender/blenlib/BLI_endian_switch_inline.h | 80 ++++++++--------------- 1 file changed, 29 insertions(+), 51 deletions(-) diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h index b747da3b738..6694276a995 100644 --- a/source/blender/blenlib/BLI_endian_switch_inline.h +++ b/source/blender/blenlib/BLI_endian_switch_inline.h @@ -32,85 +32,63 @@ * \ingroup bli */ +/* note: using a temp char to switch endian is a lot slower, + * use bit shifting instead. */ +/* *** 16 *** */ BLI_INLINE void BLI_endian_switch_int16(short *val) { - char *p_i = (char *)val; - char s_i; + short tval = *val; + *val = (tval >> 8) | + (tval << 8); - s_i = p_i[0]; - p_i[0] = p_i[1]; - p_i[1] = s_i; } - BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) { - char *p_i = (char *)val; - char s_i; - - s_i = p_i[0]; - p_i[0] = p_i[1]; - p_i[1] = s_i; + BLI_endian_switch_int16((short *)val); } + +/* *** 32 *** */ BLI_INLINE void BLI_endian_switch_int32(int *val) { - char *p_i = (char *)val; - char s_i; + int tval = *val; + *val = ((tval >> 24)) | + ((tval << 8) & 0x00ff0000) | + ((tval >> 8) & 0x0000ff00) | + ((tval << 24)); - s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; - s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; } - BLI_INLINE void BLI_endian_switch_uint32(unsigned int *val) { - char *p_i = (char *)val; - char s_i; - - s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; - s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; + BLI_endian_switch_int32((int *)val); } - BLI_INLINE void BLI_endian_switch_float(float *val) { - char *p_i = (char *)val; - char s_i; - - s_i = p_i[0]; p_i[0] = p_i[3]; p_i[3] = s_i; - s_i = p_i[1]; p_i[1] = p_i[2]; p_i[2] = s_i; + BLI_endian_switch_int32((int *)val); } + +/* *** 64 *** */ BLI_INLINE void BLI_endian_switch_int64(int64_t *val) { - char *p_i = (char *)val; - char s_i; - - 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; + int64_t tval = *val; + *val = ((tval >> 56)) | + ((tval << 40) & 0x00ff000000000000) | + ((tval << 24) & 0x0000ff0000000000) | + ((tval << 8) & 0x000000ff00000000) | + ((tval >> 8) & 0x00000000ff000000) | + ((tval >> 24) & 0x0000000000ff0000) | + ((tval >> 40) & 0x000000000000ff00) | + ((tval << 56)); } - BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) { - char *p_i = (char *)val; - char s_i; - - 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; + BLI_endian_switch_int64((int64_t *)val); } - BLI_INLINE void BLI_endian_switch_double(double *val) { - char *p_i = (char *)val; - char s_i; - - 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; + BLI_endian_switch_int64((int64_t *)val); } #endif /* __BLI_ENDIAN_SWITCH_INLINE_H__ */ -- cgit v1.2.3 From c530661db21ce882d4b5ef16d64ed5fc8f469761 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 06:06:28 +0000 Subject: patch [#32556] Stupid endian conversion in avi format from Andreas Schwab (schwab) modified to use code from BLI_endian_switch. --- source/blender/avi/intern/endian.c | 31 ++++++++--------------- source/blender/blenlib/BLI_endian_switch_inline.h | 2 +- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c index c9b95d25810..8e5ed80f5a0 100644 --- a/source/blender/avi/intern/endian.c +++ b/source/blender/avi/intern/endian.c @@ -46,31 +46,22 @@ #endif #ifdef __BIG_ENDIAN__ + +/* copied from BLI_endian_switch_inline.h */ static void invert(int *num) { - 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); - } - } - - *num = new; + int tval = *val; + *val = ((tval >> 24)) | + ((tval << 8) & 0x00ff0000) | + ((tval >> 8) & 0x0000ff00) | + ((tval << 24)); } -static void sinvert(short int *num) +static void sinvert(short int *val) { - 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); - } - } - - *num = new; + short tval = *val; + *val = (tval >> 8) | + (tval << 8); } static void Ichunk(AviChunk *chunk) diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h index 6694276a995..948d462fde4 100644 --- a/source/blender/blenlib/BLI_endian_switch_inline.h +++ b/source/blender/blenlib/BLI_endian_switch_inline.h @@ -40,7 +40,7 @@ BLI_INLINE void BLI_endian_switch_int16(short *val) { short tval = *val; *val = (tval >> 8) | - (tval << 8); + (tval << 8); } BLI_INLINE void BLI_endian_switch_uint16(unsigned short *val) -- cgit v1.2.3 From 89a415a49d0e96bd6bf63b5e6e9d5bfe2f87bc49 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 06:27:31 +0000 Subject: rename avi files (endian.h is common linux include). --- source/blender/avi/AVI_avi.h | 2 +- source/blender/avi/CMakeLists.txt | 20 +- source/blender/avi/intern/avi.c | 3 +- source/blender/avi/intern/avi_codecs.c | 148 ++++++++++ source/blender/avi/intern/avi_endian.c | 217 ++++++++++++++ source/blender/avi/intern/avi_endian.h | 48 ++++ source/blender/avi/intern/avi_mjpeg.c | 490 ++++++++++++++++++++++++++++++++ source/blender/avi/intern/avi_mjpeg.h | 38 +++ source/blender/avi/intern/avi_options.c | 133 +++++++++ source/blender/avi/intern/avi_rgb.c | 149 ++++++++++ source/blender/avi/intern/avi_rgb.h | 38 +++ source/blender/avi/intern/avi_rgb32.c | 93 ++++++ source/blender/avi/intern/avi_rgb32.h | 38 +++ source/blender/avi/intern/avirgb.c | 149 ---------- source/blender/avi/intern/avirgb.h | 35 --- source/blender/avi/intern/codecs.c | 148 ---------- source/blender/avi/intern/endian.c | 216 -------------- source/blender/avi/intern/endian.h | 52 ---- source/blender/avi/intern/mjpeg.c | 488 ------------------------------- source/blender/avi/intern/mjpeg.h | 35 --- source/blender/avi/intern/options.c | 133 --------- source/blender/avi/intern/rgb32.c | 92 ------ source/blender/avi/intern/rgb32.h | 35 --- 23 files changed, 1404 insertions(+), 1396 deletions(-) create mode 100644 source/blender/avi/intern/avi_codecs.c create mode 100644 source/blender/avi/intern/avi_endian.c create mode 100644 source/blender/avi/intern/avi_endian.h create mode 100644 source/blender/avi/intern/avi_mjpeg.c create mode 100644 source/blender/avi/intern/avi_mjpeg.h create mode 100644 source/blender/avi/intern/avi_options.c create mode 100644 source/blender/avi/intern/avi_rgb.c create mode 100644 source/blender/avi/intern/avi_rgb.h create mode 100644 source/blender/avi/intern/avi_rgb32.c create mode 100644 source/blender/avi/intern/avi_rgb32.h delete mode 100644 source/blender/avi/intern/avirgb.c delete mode 100644 source/blender/avi/intern/avirgb.h delete mode 100644 source/blender/avi/intern/codecs.c delete mode 100644 source/blender/avi/intern/endian.c delete mode 100644 source/blender/avi/intern/endian.h delete mode 100644 source/blender/avi/intern/mjpeg.c delete mode 100644 source/blender/avi/intern/mjpeg.h delete mode 100644 source/blender/avi/intern/options.c delete mode 100644 source/blender/avi/intern/rgb32.c delete mode 100644 source/blender/avi/intern/rgb32.h diff --git a/source/blender/avi/AVI_avi.h b/source/blender/avi/AVI_avi.h index bdfdbc117ed..4dc52970119 100644 --- a/source/blender/avi/AVI_avi.h +++ b/source/blender/avi/AVI_avi.h @@ -178,7 +178,7 @@ typedef struct _AviStreamRec { } AviStreamRec; typedef struct _AviMovie { - FILE *fp; + FILE *fp; int type; #define AVI_MOVIE_READ 0 diff --git a/source/blender/avi/CMakeLists.txt b/source/blender/avi/CMakeLists.txt index 79422dff917..292206d8cb9 100644 --- a/source/blender/avi/CMakeLists.txt +++ b/source/blender/avi/CMakeLists.txt @@ -35,19 +35,19 @@ set(INC_SYS set(SRC intern/avi.c - intern/avirgb.c - intern/codecs.c - intern/endian.c - intern/mjpeg.c - intern/options.c - intern/rgb32.c + intern/avi_rgb.c + intern/avi_codecs.c + intern/avi_endian.c + intern/avi_mjpeg.c + intern/avi_options.c + intern/avi_rgb32.c AVI_avi.h intern/avi_intern.h - intern/avirgb.h - intern/endian.h - intern/mjpeg.h - intern/rgb32.h + intern/avi_rgb.h + intern/avi_endian.h + intern/avi_mjpeg.h + intern/avi_rgb32.h ) blender_add_lib(bf_avi "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 2845b2f95c9..15d8702a5ec 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -32,7 +32,6 @@ * This is external code. */ - #include #include #include @@ -49,7 +48,7 @@ #include "AVI_avi.h" #include "avi_intern.h" -#include "endian.h" +#include "avi_endian.h" static int AVI_DEBUG = 0; static char DEBUG_FCC[4]; diff --git a/source/blender/avi/intern/avi_codecs.c b/source/blender/avi/intern/avi_codecs.c new file mode 100644 index 00000000000..e43826064a6 --- /dev/null +++ b/source/blender/avi/intern/avi_codecs.c @@ -0,0 +1,148 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/avi/intern/avi_codecs.c + * \ingroup avi + * + * This is external code. Identify and convert different avi-files. + */ + + +#include "AVI_avi.h" +#include "avi_intern.h" + +#include "avi_rgb.h" +#include "avi_mjpeg.h" +#include "avi_rgb32.h" + +void *avi_format_convert(AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) +{ + if (from == to) + return buffer; + + if (from != AVI_FORMAT_RGB24 && + to != AVI_FORMAT_RGB24) + { + return avi_format_convert(movie, stream, + avi_format_convert(movie, stream, buffer, from, AVI_FORMAT_RGB24, size), + AVI_FORMAT_RGB24, to, size); + } + + switch (to) { + 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_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; +} + +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); + else + return 0; + + return FCC(fcc); +} + +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; + } +} + +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; + } +} + +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; + } +} diff --git a/source/blender/avi/intern/avi_endian.c b/source/blender/avi/intern/avi_endian.c new file mode 100644 index 00000000000..70add8bd90f --- /dev/null +++ b/source/blender/avi/intern/avi_endian.c @@ -0,0 +1,217 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/avi/intern/avi_endian.c + * \ingroup avi + * + * This is external code. Streams bytes to output depending on the + * endianness of the system. + */ + + +#include +#include +#include + +#include "AVI_avi.h" +#include "avi_endian.h" +#include "avi_intern.h" + +#ifdef __BIG_ENDIAN__ +#include "MEM_guardedalloc.h" +#endif + +#ifdef __BIG_ENDIAN__ + +/* copied from BLI_endian_switch_inline.h */ +static void invert(int *num) +{ + int tval = *val; + *val = ((tval >> 24)) | + ((tval << 8) & 0x00ff0000) | + ((tval >> 8) & 0x0000ff00) | + ((tval << 24)); +} + +static void sinvert(short int *val) +{ + short tval = *val; + *val = (tval >> 8) | + (tval << 8); +} + +static void Ichunk(AviChunk *chunk) +{ + invert(&chunk->fcc); + invert(&chunk->size); +} +#endif + +#ifdef __BIG_ENDIAN__ +static void Ilist(AviList *list) +{ + invert(&list->fcc); + invert(&list->size); + invert(&list->ids); +} + +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]); +} + +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); +} + +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); +} + +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); +} + +static void Iindexe(AviIndexEntry *indexe) +{ + invert(&indexe->ChunkId); + invert(&indexe->Flags); + invert(&indexe->Offset); + invert(&indexe->Size); +} +#endif /* __BIG_ENDIAN__ */ + +void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int type) +{ +#ifdef __BIG_ENDIAN__ + void *data; + + data = MEM_mallocN(size, "avi endian"); + + 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; + } + + MEM_freeN(data); +#else /* __BIG_ENDIAN__ */ + (void)movie; /* unused */ + (void)type; /* unused */ + fwrite(datain, block, size, fp); +#endif /* __BIG_ENDIAN__ */ +} diff --git a/source/blender/avi/intern/avi_endian.h b/source/blender/avi/intern/avi_endian.h new file mode 100644 index 00000000000..8cea283a553 --- /dev/null +++ b/source/blender/avi/intern/avi_endian.h @@ -0,0 +1,48 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/avi/intern/avi_endian.h + * \ingroup avi + * + * This is external code. + */ + +#ifndef __AVI_ENDIAN_H__ +#define __AVI_ENDIAN_H__ + +#define AVI_RAW 0 +#define AVI_CHUNK 1 +#define AVI_LIST 2 +#define AVI_MAINH 3 +#define AVI_STREAMH 4 +#define AVI_BITMAPH 5 +#define AVI_INDEXE 6 +#define AVI_MJPEGU 7 + +void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int type); + +#endif /* __AVI_ENDIAN_H__ */ diff --git a/source/blender/avi/intern/avi_mjpeg.c b/source/blender/avi/intern/avi_mjpeg.c new file mode 100644 index 00000000000..b98e03d6a19 --- /dev/null +++ b/source/blender/avi/intern/avi_mjpeg.c @@ -0,0 +1,490 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/avi/intern/avi_mjpeg.c + * \ingroup avi + * + * This is external code. Converts between avi and mpeg/jpeg. + */ + +#include +#include + +#include "AVI_avi.h" + +#include "MEM_guardedalloc.h" + +#include "jpeglib.h" +#include "jerror.h" + +#include "avi_mjpeg.h" + +#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 int numbytes; + +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); + + memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); + memcpy((*htblptr)->huffval, val, sizeof((*htblptr)->huffval)); + + /* Initialize sent_table FALSE so table will be written to JPEG file. */ + (*htblptr)->sent_table = FALSE; +} + +/* 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 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 + }; + static const UINT8 val_dc_luminance[] = + { + 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 + }; + static const UINT8 val_dc_chrominance[] = + { + 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 + }; + static const UINT8 val_ac_luminance[] = + { + 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, + 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, + 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, + 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, + 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, + 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, + 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, + 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, + 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, + 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, + 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, + 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, + 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 + }; + 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 + }; + static const UINT8 val_ac_chrominance[] = + { + 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, + 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, + 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, + 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, + 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, + 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, + 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, + 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, + 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, + 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, + 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 + }; + + add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[0], + bits_dc_luminance, val_dc_luminance); + add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[0], + bits_ac_luminance, val_ac_luminance); + add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[1], + bits_dc_chrominance, val_dc_chrominance); + add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[1], + bits_ac_chrominance, val_ac_chrominance); +} + +static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize) +{ + int rowstride; + unsigned int y; + struct jpeg_decompress_struct dinfo; + struct jpeg_error_mgr jerr; + + (void)width; /* unused */ + + numbytes = 0; + + dinfo.err = jpeg_std_error(&jerr); + jpeg_create_decompress(&dinfo); + jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize); + jpeg_read_header(&dinfo, TRUE); + if (dinfo.dc_huff_tbl_ptrs[0] == NULL) { + std_huff_tables(&dinfo); + } + dinfo.out_color_space = JCS_RGB; + dinfo.dct_method = JDCT_IFAST; + + jpeg_start_decompress(&dinfo); + + rowstride = dinfo.output_width * dinfo.output_components; + for (y = 0; y < dinfo.output_height; y++) { + jpeg_read_scanlines(&dinfo, (JSAMPARRAY) &outBuffer, 1); + outBuffer += rowstride; + } + jpeg_finish_decompress(&dinfo); + + if (dinfo.output_height >= height) return 0; + + inBuffer += numbytes; + jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize - numbytes); + + 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; y < dinfo.output_height; y++) { + jpeg_read_scanlines(&dinfo, (JSAMPARRAY) &outBuffer, 1); + outBuffer += rowstride; + } + jpeg_finish_decompress(&dinfo); + jpeg_destroy_decompress(&dinfo); + + return 1; +} + +static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *inBuffer, int width, int height, int bufsize) +{ + int i, rowstride; + unsigned int y; + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + unsigned char marker[60]; + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpegmemdestmgr_build(&cinfo, outbuffer, bufsize); + + cinfo.image_width = width; + cinfo.image_height = height; + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&cinfo); + jpeg_set_colorspace(&cinfo, JCS_YCbCr); + + jpeg_set_quality(&cinfo, quality, TRUE); + + cinfo.dc_huff_tbl_ptrs[0]->sent_table = TRUE; + cinfo.dc_huff_tbl_ptrs[1]->sent_table = TRUE; + cinfo.ac_huff_tbl_ptrs[0]->sent_table = TRUE; + cinfo.ac_huff_tbl_ptrs[1]->sent_table = TRUE; + + cinfo.comp_info[0].component_id = 0; + cinfo.comp_info[0].v_samp_factor = 1; + cinfo.comp_info[1].component_id = 1; + cinfo.comp_info[2].component_id = 2; + + cinfo.write_JFIF_header = FALSE; + + jpeg_start_compress(&cinfo, FALSE); + + i = 0; + marker[i++] = 'A'; + marker[i++] = 'V'; + marker[i++] = 'I'; + marker[i++] = '1'; + marker[i++] = 0; + while (i < 60) + marker[i++] = 32; + + jpeg_write_marker(&cinfo, JPEG_APP0, marker, 60); + + i = 0; + while (i < 60) + marker[i++] = 0; + + jpeg_write_marker(&cinfo, JPEG_COM, marker, 60); + + rowstride = cinfo.image_width * cinfo.input_components; + for (y = 0; y < cinfo.image_height; y++) { + jpeg_write_scanlines(&cinfo, (JSAMPARRAY) &inBuffer, 1); + inBuffer += rowstride; + } + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); +} + +static void interlace(unsigned char *to, unsigned char *from, int width, int height) +{ + int i, rowstride = width * 3; + + for (i = 0; i < height; i++) { + if (i & 1) + memcpy(&to[i * rowstride], &from[(i / 2 + height / 2) * rowstride], rowstride); + else + memcpy(&to[i * rowstride], &from[(i / 2) * rowstride], rowstride); + } +} + +static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height) +{ + int i, rowstride = width * 3; + + for (i = 0; i < height; i++) { + if ((i & 1) == odd) + memcpy(&to[(i / 2 + height / 2) * rowstride], &from[i * rowstride], rowstride); + else + memcpy(&to[(i / 2) * rowstride], &from[i * rowstride], rowstride); + } +} + +static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, int width, int height, int bufsize) +{ + /* JPEG's are always multiples of 16, extra is cropped out AVI's */ + if ((width & 0xF) || (height & 0xF)) { + int i, rrowstride, jrowstride; + int jwidth = PADUP(width, 16); + int jheight = PADUP(height, 16); + unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_decode_jpeg"); + int ret = Decode_JPEG(inbuf, tmpbuf, jwidth, jheight, bufsize); + + /* crop the tmpbuf into the real buffer */ + rrowstride = width * 3; + jrowstride = jwidth * 3; + for (i = 0; i < height; i++) + memcpy(&outbuf[i * rrowstride], &tmpbuf[i * jrowstride], rrowstride); + MEM_freeN(tmpbuf); + + return ret; + } + else { + return Decode_JPEG(inbuf, outbuf, width, height, bufsize); + } +} + +static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned char *inbuf, int width, int height, int bufsize) +{ + /* JPEG's are always multiples of 16, extra is ignored in AVI's */ + if ((width & 0xF) || (height & 0xF)) { + int i, rrowstride, jrowstride; + int jwidth = PADUP(width, 16); + int jheight = PADUP(height, 16); + unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_compress_jpeg"); + + /* resize the realbuf into the tmpbuf */ + rrowstride = width * 3; + jrowstride = jwidth * 3; + for (i = 0; i < jheight; i++) { + if (i < height) + memcpy(&tmpbuf[i * jrowstride], &inbuf[i * rrowstride], rrowstride); + else + memset(&tmpbuf[i * jrowstride], 0, rrowstride); + memset(&tmpbuf[i * jrowstride + rrowstride], 0, jrowstride - rrowstride); + } + + Compress_JPEG(quality, outbuf, tmpbuf, jwidth, jheight, bufsize); + + MEM_freeN(tmpbuf); + } + else { + Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize); + } +} + +void *avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size) +{ + int deint; + unsigned char *buf; + + (void)stream; /* unused */ + + 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); + + 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); + + buf = buffer; + } + + return buf; +} + +void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size) +{ + unsigned char *buf; + int bufsize = *size; + + numbytes = 0; + *size = 0; + + 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); + } + else { + 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"); + + 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); + return buf; +} + + +/* Compression from memory */ + +static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo) +{ + (void)cinfo; /* unused */ +} + +static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo) +{ + (void)cinfo; /* unused */ + return TRUE; +} + +static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo) +{ + 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->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; + + numbytes = bufsize; +} + +/* Decompression from memory */ + +static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo) +{ + (void)dinfo; +} + +static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) +{ + unsigned char *buf = (unsigned char *) dinfo->src->next_input_byte - 2; + + /* if we get called, must have run out of data */ + WARNMS(dinfo, JWRN_JPEG_EOF); + + buf[0] = (JOCTET) 0xFF; + buf[1] = (JOCTET) JPEG_EOI; + + 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_buffer < skipcnt) + skipcnt = dinfo->src->bytes_in_buffer; + + 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; + + 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->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; + + numbytes = bufsize; +} diff --git a/source/blender/avi/intern/avi_mjpeg.h b/source/blender/avi/intern/avi_mjpeg.h new file mode 100644 index 00000000000..6ae0e56ffa4 --- /dev/null +++ b/source/blender/avi/intern/avi_mjpeg.h @@ -0,0 +1,38 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/avi/intern/avi_mjpeg.h + * \ingroup avi + */ + +#ifndef __AVI_MJPEG_H__ +#define __AVI_MJPEG_H__ + +void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size); +void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size); + +#endif /* __AVI_MJPEG_H__ */ diff --git a/source/blender/avi/intern/avi_options.c b/source/blender/avi/intern/avi_options.c new file mode 100644 index 00000000000..f7759a1099f --- /dev/null +++ b/source/blender/avi/intern/avi_options.c @@ -0,0 +1,133 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/avi/intern/avi_options.c + * \ingroup avi + * + * This is external code. Sets some compression related options + * (width, height quality, framerate). + */ + +#include "AVI_avi.h" +#include "avi_intern.h" +#include "avi_endian.h" + +#ifdef WIN32 +# include "BLI_winstuff.h" +#endif + +/* avi_set_compress_options gets its own file... now don't WE feel important? */ + +AviError AVI_set_compress_option(AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data) +{ + int i; + int useconds; + + (void)stream; /* unused */ + + if (movie->header->TotalFrames != 0) /* Can't change params after we have already started writing frames */ + 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; + + 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); + } + } + + } + + 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/avi_rgb.c b/source/blender/avi/intern/avi_rgb.c new file mode 100644 index 00000000000..61587e15e61 --- /dev/null +++ b/source/blender/avi/intern/avi_rgb.c @@ -0,0 +1,149 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/avi/intern/avi_rgb.c + * \ingroup avi + * + * This is external code. Converts rgb-type avi-s. + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "AVI_avi.h" +#include "avi_rgb.h" + +/* implementation */ + +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; + + (void)size; /* unused */ + + bi = (AviBitmapInfoHeader *) movie->streams[stream].sf; + if (bi) bits = bi->BitCount; + + 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"); + + y = movie->header->Height; + to = buf; + + while (y--) { + pxl = (unsigned short *) (buffer + y * movie->header->Width * 2); + +#ifdef __BIG_ENDIAN__ + pxla = (unsigned char *)pxl; +#endif + + x = movie->header->Width; + while (x--) { +#ifdef __BIG_ENDIAN__ + i = pxla[0]; + pxla[0] = pxla[1]; + pxla[1] = i; + + pxla += 2; +#endif + + *(to++) = ((*pxl >> 10) & 0x1f) * 8; + *(to++) = ((*pxl >> 5) & 0x1f) * 8; + *(to++) = (*pxl & 0x1f) * 8; + pxl++; + } + } + + MEM_freeN(buffer); + + return buf; + } + else { + 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++; + + 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) { + i = buf[y]; + buf[y] = buf[y + 2]; + buf[y + 2] = i; + } + + MEM_freeN(buffer); + + return buf; + } +} + +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; + + buf = MEM_mallocN(*size, "toavirgbbuf"); + + 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++) { + 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); + + return buf; +} diff --git a/source/blender/avi/intern/avi_rgb.h b/source/blender/avi/intern/avi_rgb.h new file mode 100644 index 00000000000..773166e9fab --- /dev/null +++ b/source/blender/avi/intern/avi_rgb.h @@ -0,0 +1,38 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/avi/intern/avi_rgb.h + * \ingroup avi + */ + +#ifndef __AVI_RGB_H__ +#define __AVI_RGB_H__ + +void *avi_converter_from_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); + +#endif /* __AVI_RGB_H__ */ diff --git a/source/blender/avi/intern/avi_rgb32.c b/source/blender/avi/intern/avi_rgb32.c new file mode 100644 index 00000000000..5c7a4889d97 --- /dev/null +++ b/source/blender/avi/intern/avi_rgb32.c @@ -0,0 +1,93 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/avi/intern/avi_rgb32.c + * \ingroup avi + * + * This is external code. Converts between rgb32 and avi. + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "AVI_avi.h" +#include "avi_rgb32.h" + +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"); + *size = movie->header->Height * movie->header->Width * 3; + + 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]; + } + } + + MEM_freeN(buffer); + + return buf; +} + +void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size) +{ + int i; + unsigned char *buf; + unsigned char *to, *from; + + (void)stream; /* unused */ + + 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; + + while (i--) { + memcpy(to, from, 3); + to += 4; from += 3; + } + + MEM_freeN(buffer); + + return buf; +} diff --git a/source/blender/avi/intern/avi_rgb32.h b/source/blender/avi/intern/avi_rgb32.h new file mode 100644 index 00000000000..523f9e795fd --- /dev/null +++ b/source/blender/avi/intern/avi_rgb32.h @@ -0,0 +1,38 @@ +/* + * ***** 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. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/avi/intern/avi_rgb32.h + * \ingroup avi + */ + +#ifndef __AVI_RGB32_H__ +#define __AVI_RGB32_H__ + +void *avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size); +void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size); + +#endif /* __AVI_RGB32_H__ */ diff --git a/source/blender/avi/intern/avirgb.c b/source/blender/avi/intern/avirgb.c deleted file mode 100644 index 7a95972845a..00000000000 --- a/source/blender/avi/intern/avirgb.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file blender/avi/intern/avirgb.c - * \ingroup avi - * - * This is external code. Converts rgb-type avi-s. - */ - - -#include "AVI_avi.h" -#include -#include - -#include "MEM_guardedalloc.h" -#include "avirgb.h" - -/* implementation */ - -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; - - (void)size; /* unused */ - - bi = (AviBitmapInfoHeader *) movie->streams[stream].sf; - if (bi) bits = bi->BitCount; - - 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"); - - y = movie->header->Height; - to = buf; - - while (y--) { - pxl = (unsigned short *) (buffer + y * movie->header->Width * 2); - -#ifdef __BIG_ENDIAN__ - pxla = (unsigned char *)pxl; -#endif - - x = movie->header->Width; - while (x--) { -#ifdef __BIG_ENDIAN__ - i = pxla[0]; - pxla[0] = pxla[1]; - pxla[1] = i; - - pxla += 2; -#endif - - *(to++) = ((*pxl >> 10) & 0x1f) * 8; - *(to++) = ((*pxl >> 5) & 0x1f) * 8; - *(to++) = (*pxl & 0x1f) * 8; - pxl++; - } - } - - MEM_freeN(buffer); - - return buf; - } - else { - 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++; - - 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) { - i = buf[y]; - buf[y] = buf[y + 2]; - buf[y + 2] = i; - } - - MEM_freeN(buffer); - - return buf; - } -} - -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; - - buf = MEM_mallocN(*size, "toavirgbbuf"); - - 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++) { - 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); - - return buf; -} diff --git a/source/blender/avi/intern/avirgb.h b/source/blender/avi/intern/avirgb.h deleted file mode 100644 index 20211d6ab2d..00000000000 --- a/source/blender/avi/intern/avirgb.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/avi/intern/avirgb.h - * \ingroup avi - */ - - -void *avi_converter_from_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); - diff --git a/source/blender/avi/intern/codecs.c b/source/blender/avi/intern/codecs.c deleted file mode 100644 index 01e228d570e..00000000000 --- a/source/blender/avi/intern/codecs.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/avi/intern/codecs.c - * \ingroup avi - * - * This is external code. Identify and convert different avi-files. - */ - - -#include "AVI_avi.h" -#include "avi_intern.h" - -#include "avirgb.h" -#include "mjpeg.h" -#include "rgb32.h" - -void *avi_format_convert(AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) -{ - if (from == to) - return buffer; - - if (from != AVI_FORMAT_RGB24 && - to != AVI_FORMAT_RGB24) - { - return avi_format_convert(movie, stream, - avi_format_convert(movie, stream, buffer, from, AVI_FORMAT_RGB24, size), - AVI_FORMAT_RGB24, to, size); - } - - switch (to) { - 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_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; -} - -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); - else - return 0; - - return FCC(fcc); -} - -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; - } -} - -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; - } -} - -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; - } -} diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c deleted file mode 100644 index 8e5ed80f5a0..00000000000 --- a/source/blender/avi/intern/endian.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file blender/avi/intern/endian.c - * \ingroup avi - * - * This is external code. Streams bytes to output depending on the - * endianness of the system. - */ - - -#include -#include -#include -#include "AVI_avi.h" -#include "endian.h" -#include "avi_intern.h" - -#ifdef __BIG_ENDIAN__ -#include "MEM_guardedalloc.h" -#endif - -#ifdef __BIG_ENDIAN__ - -/* copied from BLI_endian_switch_inline.h */ -static void invert(int *num) -{ - int tval = *val; - *val = ((tval >> 24)) | - ((tval << 8) & 0x00ff0000) | - ((tval >> 8) & 0x0000ff00) | - ((tval << 24)); -} - -static void sinvert(short int *val) -{ - short tval = *val; - *val = (tval >> 8) | - (tval << 8); -} - -static void Ichunk(AviChunk *chunk) -{ - invert(&chunk->fcc); - invert(&chunk->size); -} -#endif - -#ifdef __BIG_ENDIAN__ -static void Ilist(AviList *list) -{ - invert(&list->fcc); - invert(&list->size); - invert(&list->ids); -} - -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]); -} - -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); -} - -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); -} - -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); -} - -static void Iindexe(AviIndexEntry *indexe) -{ - invert(&indexe->ChunkId); - invert(&indexe->Flags); - invert(&indexe->Offset); - invert(&indexe->Size); -} -#endif /* __BIG_ENDIAN__ */ - -void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int type) -{ -#ifdef __BIG_ENDIAN__ - void *data; - - data = MEM_mallocN(size, "avi endian"); - - 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; - } - - MEM_freeN(data); -#else /* __BIG_ENDIAN__ */ - (void)movie; /* unused */ - (void)type; /* unused */ - fwrite(datain, block, size, fp); -#endif /* __BIG_ENDIAN__ */ -} diff --git a/source/blender/avi/intern/endian.h b/source/blender/avi/intern/endian.h deleted file mode 100644 index 7ef49cb1699..00000000000 --- a/source/blender/avi/intern/endian.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/avi/intern/endian.h - * \ingroup avi - * - * This is external code. - */ - -#ifndef __ENDIAN_H__ -#define __ENDIAN_H__ - -#include -#include "AVI_avi.h" - -#define AVI_RAW 0 -#define AVI_CHUNK 1 -#define AVI_LIST 2 -#define AVI_MAINH 3 -#define AVI_STREAMH 4 -#define AVI_BITMAPH 5 -#define AVI_INDEXE 6 -#define AVI_MJPEGU 7 - -void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int type); - -#endif - diff --git a/source/blender/avi/intern/mjpeg.c b/source/blender/avi/intern/mjpeg.c deleted file mode 100644 index a700284bf68..00000000000 --- a/source/blender/avi/intern/mjpeg.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file blender/avi/intern/mjpeg.c - * \ingroup avi - * - * This is external code. Converts between avi and mpeg/jpeg. - */ - - -#include "AVI_avi.h" -#include -#include -#include "jpeglib.h" -#include "jerror.h" -#include "MEM_guardedalloc.h" - -#include "mjpeg.h" - -#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 int numbytes; - -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); - - memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); - memcpy((*htblptr)->huffval, val, sizeof((*htblptr)->huffval)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - -/* 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 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 - }; - static const UINT8 val_dc_luminance[] = - { - 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 - }; - static const UINT8 val_dc_chrominance[] = - { - 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 - }; - static const UINT8 val_ac_luminance[] = - { - 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 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 - }; - 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 - }; - static const UINT8 val_ac_chrominance[] = - { - 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 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 - }; - - add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - -static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize) -{ - int rowstride; - unsigned int y; - struct jpeg_decompress_struct dinfo; - struct jpeg_error_mgr jerr; - - (void)width; /* unused */ - - numbytes = 0; - - dinfo.err = jpeg_std_error(&jerr); - jpeg_create_decompress(&dinfo); - jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize); - jpeg_read_header(&dinfo, TRUE); - if (dinfo.dc_huff_tbl_ptrs[0] == NULL) { - std_huff_tables(&dinfo); - } - dinfo.out_color_space = JCS_RGB; - dinfo.dct_method = JDCT_IFAST; - - jpeg_start_decompress(&dinfo); - - rowstride = dinfo.output_width * dinfo.output_components; - for (y = 0; y < dinfo.output_height; y++) { - jpeg_read_scanlines(&dinfo, (JSAMPARRAY) &outBuffer, 1); - outBuffer += rowstride; - } - jpeg_finish_decompress(&dinfo); - - if (dinfo.output_height >= height) return 0; - - inBuffer += numbytes; - jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize - numbytes); - - 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; y < dinfo.output_height; y++) { - jpeg_read_scanlines(&dinfo, (JSAMPARRAY) &outBuffer, 1); - outBuffer += rowstride; - } - jpeg_finish_decompress(&dinfo); - jpeg_destroy_decompress(&dinfo); - - return 1; -} - -static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *inBuffer, int width, int height, int bufsize) -{ - int i, rowstride; - unsigned int y; - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; - unsigned char marker[60]; - - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - jpegmemdestmgr_build(&cinfo, outbuffer, bufsize); - - cinfo.image_width = width; - cinfo.image_height = height; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - - jpeg_set_defaults(&cinfo); - jpeg_set_colorspace(&cinfo, JCS_YCbCr); - - jpeg_set_quality(&cinfo, quality, TRUE); - - cinfo.dc_huff_tbl_ptrs[0]->sent_table = TRUE; - cinfo.dc_huff_tbl_ptrs[1]->sent_table = TRUE; - cinfo.ac_huff_tbl_ptrs[0]->sent_table = TRUE; - cinfo.ac_huff_tbl_ptrs[1]->sent_table = TRUE; - - cinfo.comp_info[0].component_id = 0; - cinfo.comp_info[0].v_samp_factor = 1; - cinfo.comp_info[1].component_id = 1; - cinfo.comp_info[2].component_id = 2; - - cinfo.write_JFIF_header = FALSE; - - jpeg_start_compress(&cinfo, FALSE); - - i = 0; - marker[i++] = 'A'; - marker[i++] = 'V'; - marker[i++] = 'I'; - marker[i++] = '1'; - marker[i++] = 0; - while (i < 60) - marker[i++] = 32; - - jpeg_write_marker(&cinfo, JPEG_APP0, marker, 60); - - i = 0; - while (i < 60) - marker[i++] = 0; - - jpeg_write_marker(&cinfo, JPEG_COM, marker, 60); - - rowstride = cinfo.image_width * cinfo.input_components; - for (y = 0; y < cinfo.image_height; y++) { - jpeg_write_scanlines(&cinfo, (JSAMPARRAY) &inBuffer, 1); - inBuffer += rowstride; - } - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); -} - -static void interlace(unsigned char *to, unsigned char *from, int width, int height) -{ - int i, rowstride = width * 3; - - for (i = 0; i < height; i++) { - if (i & 1) - memcpy(&to[i * rowstride], &from[(i / 2 + height / 2) * rowstride], rowstride); - else - memcpy(&to[i * rowstride], &from[(i / 2) * rowstride], rowstride); - } -} - -static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height) -{ - int i, rowstride = width * 3; - - for (i = 0; i < height; i++) { - if ((i & 1) == odd) - memcpy(&to[(i / 2 + height / 2) * rowstride], &from[i * rowstride], rowstride); - else - memcpy(&to[(i / 2) * rowstride], &from[i * rowstride], rowstride); - } -} - -static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, int width, int height, int bufsize) -{ - /* JPEG's are always multiples of 16, extra is cropped out AVI's */ - if ((width & 0xF) || (height & 0xF)) { - int i, rrowstride, jrowstride; - int jwidth = PADUP(width, 16); - int jheight = PADUP(height, 16); - unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_decode_jpeg"); - int ret = Decode_JPEG(inbuf, tmpbuf, jwidth, jheight, bufsize); - - /* crop the tmpbuf into the real buffer */ - rrowstride = width * 3; - jrowstride = jwidth * 3; - for (i = 0; i < height; i++) - memcpy(&outbuf[i * rrowstride], &tmpbuf[i * jrowstride], rrowstride); - MEM_freeN(tmpbuf); - - return ret; - } - else { - return Decode_JPEG(inbuf, outbuf, width, height, bufsize); - } -} - -static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned char *inbuf, int width, int height, int bufsize) -{ - /* JPEG's are always multiples of 16, extra is ignored in AVI's */ - if ((width & 0xF) || (height & 0xF)) { - int i, rrowstride, jrowstride; - int jwidth = PADUP(width, 16); - int jheight = PADUP(height, 16); - unsigned char *tmpbuf = MEM_mallocN(jwidth * jheight * 3, "avi.check_and_compress_jpeg"); - - /* resize the realbuf into the tmpbuf */ - rrowstride = width * 3; - jrowstride = jwidth * 3; - for (i = 0; i < jheight; i++) { - if (i < height) - memcpy(&tmpbuf[i * jrowstride], &inbuf[i * rrowstride], rrowstride); - else - memset(&tmpbuf[i * jrowstride], 0, rrowstride); - memset(&tmpbuf[i * jrowstride + rrowstride], 0, jrowstride - rrowstride); - } - - Compress_JPEG(quality, outbuf, tmpbuf, jwidth, jheight, bufsize); - - MEM_freeN(tmpbuf); - } - else { - Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize); - } -} - -void *avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size) -{ - int deint; - unsigned char *buf; - - (void)stream; /* unused */ - - 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); - - 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); - - buf = buffer; - } - - return buf; -} - -void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size) -{ - unsigned char *buf; - int bufsize = *size; - - numbytes = 0; - *size = 0; - - 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); - } - else { - 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"); - - 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); - return buf; -} - - -/* Compression from memory */ - -static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo) -{ - (void)cinfo; /* unused */ -} - -static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo) -{ - (void)cinfo; /* unused */ - return TRUE; -} - -static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo) -{ - 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->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; - - numbytes = bufsize; -} - -/* Decompression from memory */ - -static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo) -{ - (void)dinfo; -} - -static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) -{ - unsigned char *buf = (unsigned char *) dinfo->src->next_input_byte - 2; - - /* if we get called, must have run out of data */ - WARNMS(dinfo, JWRN_JPEG_EOF); - - buf[0] = (JOCTET) 0xFF; - buf[1] = (JOCTET) JPEG_EOI; - - 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_buffer < skipcnt) - skipcnt = dinfo->src->bytes_in_buffer; - - 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; - - 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->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; - - numbytes = bufsize; -} diff --git a/source/blender/avi/intern/mjpeg.h b/source/blender/avi/intern/mjpeg.h deleted file mode 100644 index 75649891f2b..00000000000 --- a/source/blender/avi/intern/mjpeg.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/avi/intern/mjpeg.h - * \ingroup avi - */ - - -void *avi_converter_from_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size); -void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size); - diff --git a/source/blender/avi/intern/options.c b/source/blender/avi/intern/options.c deleted file mode 100644 index 7de91318ecf..00000000000 --- a/source/blender/avi/intern/options.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file blender/avi/intern/options.c - * \ingroup avi - * - * This is external code. Sets some compression related options - * (width, height quality, framerate). - */ - -#include "AVI_avi.h" -#include "avi_intern.h" -#include "endian.h" - -#ifdef WIN32 -# include "BLI_winstuff.h" -#endif - -/* avi_set_compress_options gets its own file... now don't WE feel important? */ - -AviError AVI_set_compress_option(AviMovie *movie, int option_type, int stream, AviOption option, void *opt_data) -{ - int i; - int useconds; - - (void)stream; /* unused */ - - if (movie->header->TotalFrames != 0) /* Can't change params after we have already started writing frames */ - 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; - - 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); - } - } - - } - - 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 deleted file mode 100644 index 84630f09fe5..00000000000 --- a/source/blender/avi/intern/rgb32.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * - */ - -/** \file blender/avi/intern/rgb32.c - * \ingroup avi - * - * This is external code. Converts between rgb32 and avi. - */ - - -#include "AVI_avi.h" -#include -#include -#include "MEM_guardedalloc.h" -#include "rgb32.h" - -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"); - *size = movie->header->Height * movie->header->Width * 3; - - 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]; - } - } - - MEM_freeN(buffer); - - return buf; -} - -void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size) -{ - int i; - unsigned char *buf; - unsigned char *to, *from; - - (void)stream; /* unused */ - - 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; - - while (i--) { - memcpy(to, from, 3); - to += 4; from += 3; - } - - MEM_freeN(buffer); - - return buf; -} diff --git a/source/blender/avi/intern/rgb32.h b/source/blender/avi/intern/rgb32.h deleted file mode 100644 index 55f9771a4df..00000000000 --- a/source/blender/avi/intern/rgb32.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ***** 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. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/avi/intern/rgb32.h - * \ingroup avi - */ - - -void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size); -void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size); - -- cgit v1.2.3 From 1a9f930514719eee65609d7499bd184147580b55 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 07:27:09 +0000 Subject: add type checking for more error prone macros. --- source/blender/blenkernel/BKE_armature.h | 10 ++++++-- source/blender/blenkernel/BKE_sequencer.h | 8 ++++--- source/blender/blenlib/BLI_utildefines.h | 4 ++++ source/blender/editors/include/ED_anim_api.h | 36 ++++++++++++++-------------- source/blender/editors/include/ED_armature.h | 13 ++++++++-- 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index a3f3beefbaf..6b9de47836e 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -131,8 +131,14 @@ typedef struct Mat4 { Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan, int rest); /* like EBONE_VISIBLE */ -#define PBONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P)) -#define PBONE_SELECTABLE(arm, bone) (PBONE_VISIBLE(arm, bone) && !((bone)->flag & BONE_UNSELECTABLE)) +#define PBONE_VISIBLE(arm, bone) ( \ + CHECK_TYPE_INLINE(arm, bArmature), \ + CHECK_TYPE_INLINE(bone, Bone), \ + (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P)) \ + ) + +#define PBONE_SELECTABLE(arm, bone) \ + (PBONE_VISIBLE(arm, bone) && !((bone)->flag & BONE_UNSELECTABLE)) #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index cecff2d9516..80431682d6f 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -73,15 +73,17 @@ void BKE_sequence_iterator_end(SeqIterator *iter); SeqIterator iter; \ for (BKE_sequence_iterator_begin(ed, &iter, 1); \ iter.valid; \ - BKE_sequence_iterator_next(&iter)) { \ + BKE_sequence_iterator_next(&iter)) \ + { \ _seq = iter.seq; - + #define SEQ_BEGIN(ed, _seq) \ { \ SeqIterator iter; \ for (BKE_sequence_iterator_begin(ed, &iter, 0); \ iter.valid; \ - BKE_sequence_iterator_next(&iter)) { \ + BKE_sequence_iterator_next(&iter)) \ + { \ _seq = iter.seq; #define SEQ_END \ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 29097a4c6c3..ebb40c18c21 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -128,6 +128,10 @@ #endif #endif +/* can be used in simple macros */ +#define CHECK_TYPE_INLINE(val, type) \ + ((void)(((type *)0) == (val))) + #ifndef SWAP # define SWAP(type, a, b) { \ type sw_ap; \ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index e1401a8ff88..8d7ae3aad6a 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -232,28 +232,28 @@ typedef enum eAnimFilter_Flags { /* Dopesheet only */ /* 'Scene' channels */ -#define SEL_SCEC(sce) ((sce->flag & SCE_DS_SELECTED)) -#define EXPANDED_SCEC(sce) ((sce->flag & SCE_DS_COLLAPSED) == 0) +#define SEL_SCEC(sce) (CHECK_TYPE_INLINE(sce, Scene), ((sce->flag & SCE_DS_SELECTED))) +#define EXPANDED_SCEC(sce) (CHECK_TYPE_INLINE(sce, Scene), ((sce->flag & SCE_DS_COLLAPSED) == 0)) /* 'Sub-Scene' channels (flags stored in Data block) */ -#define FILTER_WOR_SCED(wo) ((wo->flag & WO_DS_EXPAND)) +#define FILTER_WOR_SCED(wo) (CHECK_TYPE_INLINE(wo, World), (wo->flag & WO_DS_EXPAND)) /* 'Object' channels */ -#define SEL_OBJC(base) ((base->flag & SELECT)) -#define EXPANDED_OBJC(ob) ((ob->nlaflag & OB_ADS_COLLAPSED) == 0) +#define SEL_OBJC(base) (CHECK_TYPE_INLINE(base, Base), ((base->flag & SELECT))) +#define EXPANDED_OBJC(ob) (CHECK_TYPE_INLINE(ob, Object), ((ob->nlaflag & OB_ADS_COLLAPSED) == 0)) /* 'Sub-object' channels (flags stored in Data block) */ -#define FILTER_SKE_OBJD(key) ((key->flag & KEY_DS_EXPAND)) -#define FILTER_MAT_OBJD(ma) ((ma->flag & MA_DS_EXPAND)) -#define FILTER_LAM_OBJD(la) ((la->flag & LA_DS_EXPAND)) -#define FILTER_CAM_OBJD(ca) ((ca->flag & CAM_DS_EXPAND)) -#define FILTER_CUR_OBJD(cu) ((cu->flag & CU_DS_EXPAND)) -#define FILTER_PART_OBJD(part) ((part->flag & PART_DS_EXPAND)) -#define FILTER_MBALL_OBJD(mb) ((mb->flag2 & MB_DS_EXPAND)) -#define FILTER_ARM_OBJD(arm) ((arm->flag & ARM_DS_EXPAND)) -#define FILTER_MESH_OBJD(me) ((me->flag & ME_DS_EXPAND)) -#define FILTER_LATTICE_OBJD(lt) ((lt->flag & LT_DS_EXPAND)) -#define FILTER_SPK_OBJD(spk) ((spk->flag & SPK_DS_EXPAND)) +#define FILTER_SKE_OBJD(key) (CHECK_TYPE_INLINE(key, Key), ((key->flag & KEY_DS_EXPAND))) +#define FILTER_MAT_OBJD(ma) (CHECK_TYPE_INLINE(ma, Material), ((ma->flag & MA_DS_EXPAND))) +#define FILTER_LAM_OBJD(la) (CHECK_TYPE_INLINE(la, Lamp), ((la->flag & LA_DS_EXPAND))) +#define FILTER_CAM_OBJD(ca) (CHECK_TYPE_INLINE(ca, Camera), ((ca->flag & CAM_DS_EXPAND))) +#define FILTER_CUR_OBJD(cu) (CHECK_TYPE_INLINE(cu, Curve), ((cu->flag & CU_DS_EXPAND))) +#define FILTER_PART_OBJD(part) (CHECK_TYPE_INLINE(part, ParticleSettings), ((part->flag & PART_DS_EXPAND))) +#define FILTER_MBALL_OBJD(mb) (CHECK_TYPE_INLINE(mb, MetaBall), ((mb->flag2 & MB_DS_EXPAND))) +#define FILTER_ARM_OBJD(arm) (CHECK_TYPE_INLINE(arm, bArmature), ((arm->flag & ARM_DS_EXPAND))) +#define FILTER_MESH_OBJD(me) (CHECK_TYPE_INLINE(me, Mesh), ((me->flag & ME_DS_EXPAND))) +#define FILTER_LATTICE_OBJD(lt) (CHECK_TYPE_INLINE(lt, Lattice), ((lt->flag & LT_DS_EXPAND))) +#define FILTER_SPK_OBJD(spk) (CHECK_TYPE_INLINE(spk, Speaker), ((spk->flag & SPK_DS_EXPAND))) /* Variable use expanders */ -#define FILTER_NTREE_DATA(ntree) ((ntree->flag & NTREE_DS_EXPAND)) -#define FILTER_TEX_DATA(tex) ((tex->flag & TEX_DS_EXPAND)) +#define FILTER_NTREE_DATA(ntree) (CHECK_TYPE_INLINE(ntree, bNodeTree), ((ntree->flag & NTREE_DS_EXPAND))) +#define FILTER_TEX_DATA(tex) (CHECK_TYPE_INLINE(tex, Tex), ((tex->flag & TEX_DS_EXPAND))) /* 'Sub-object/Action' channels (flags stored in Action) */ #define SEL_ACTC(actc) ((actc->flag & ACT_SELECTED)) diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index b9996c87194..efd10f3cb6b 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -93,9 +93,18 @@ typedef struct EditBone { #define BONESEL_NOSEL (1 << 31) /* Indicates a negative number */ /* useful macros */ -#define EBONE_VISIBLE(arm, ebone) (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A)) +#define EBONE_VISIBLE(arm, ebone) ( \ + CHECK_TYPE_INLINE(arm, bArmature), \ + CHECK_TYPE_INLINE(ebone, EditBone), \ + (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A)) \ + ) + #define EBONE_SELECTABLE(arm, ebone) (EBONE_VISIBLE(arm, ebone) && !(ebone->flag & BONE_UNSELECTABLE)) -#define EBONE_EDITABLE(ebone) (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) + +#define EBONE_EDITABLE(ebone) ( \ + CHECK_TYPE_INLINE(ebone, EditBone), \ + (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) \ + ) /* used in bone_select_hierachy() */ #define BONE_SELECT_PARENT 0 -- cgit v1.2.3 From 7748133bf2d0a99f37b2a0b0ce438b6726db36fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 07:38:22 +0000 Subject: code cleanup: glare stream operation was setting alpha array twice. --- .../blender/compositor/operations/COM_GlareStreaksOperation.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp index 9125783c222..60d37fb8145 100644 --- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp @@ -81,11 +81,9 @@ void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile, float *sourcebuffer = tsrc->getBuffer(); float factor = 1.f / (float)(6 - settings->iter); - for (int i = 0; i < size4; i++) { - data[i] += sourcebuffer[i] * factor; - } - for (int i = 0; i < size; i++) { - data[i * 4 + 3] = 1.0f; + for (int i = 0; i < size4; i += 4) { + madd_v3_v3fl(&data[i], &sourcebuffer[i], factor); + data[i + 3] = 1.0f; } tdst->clear(); -- cgit v1.2.3 From e8872a8ea259c856aab188cda8eb4502d6a02cfc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 09:48:59 +0000 Subject: style cleanup: if(); --- .../cmake/cmake_static_check_clang_array.py | 1 + build_files/cmake/cmake_static_check_cppcheck.py | 1 + build_files/cmake/cmake_static_check_smatch.py | 1 + build_files/cmake/cmake_static_check_sparse.py | 1 + build_files/cmake/cmake_static_check_splint.py | 1 + source/blender/blenkernel/intern/blender.c | 8 +- source/blender/blenkernel/intern/customdata.c | 49 +++++++--- source/blender/blenkernel/intern/displist.c | 4 +- source/blender/blenkernel/intern/font.c | 8 +- source/blender/blenkernel/intern/lattice.c | 5 +- source/blender/blenkernel/intern/modifier.c | 8 +- source/blender/blenkernel/intern/particle.c | 8 +- source/blender/blenlib/BLI_endian_switch_inline.h | 12 +-- source/blender/editors/armature/editarmature.c | 11 ++- source/blender/editors/curve/editcurve.c | 101 +++++++++++++++------ source/blender/editors/interface/interface.c | 12 ++- .../blender/editors/interface/interface_handlers.c | 20 +++- .../blender/editors/interface/interface_layout.c | 8 +- .../blender/editors/interface/interface_widgets.c | 4 +- source/blender/editors/mesh/editface.c | 8 +- source/blender/editors/physics/particle_edit.c | 8 +- source/blender/editors/render/render_update.c | 44 ++++++--- source/blender/editors/screen/area.c | 29 ++++-- source/blender/editors/sculpt_paint/paint_undo.c | 12 ++- source/blender/editors/space_file/filelist.c | 4 +- source/blender/editors/space_image/space_image.c | 5 +- .../blender/editors/space_outliner/outliner_draw.c | 14 ++- .../blender/editors/space_outliner/outliner_tree.c | 24 +++-- .../editors/space_sequencer/sequencer_edit.c | 4 +- source/blender/editors/space_view3d/drawarmature.c | 13 ++- source/blender/editors/space_view3d/view3d_draw.c | 4 +- .../editors/transform/transform_conversions.c | 8 +- source/blender/makesdna/intern/makesdna.c | 18 ++-- .../nodes/texture/nodes/node_texture_output.c | 2 +- .../blender/render/intern/source/convertblender.c | 8 +- source/blender/render/intern/source/imagetexture.c | 33 +++++-- source/blender/render/intern/source/occlusion.c | 7 +- source/blender/render/intern/source/pipeline.c | 12 ++- source/blender/render/intern/source/pointdensity.c | 6 +- .../blender/render/intern/source/render_texture.c | 41 ++++++--- source/blender/render/intern/source/rendercore.c | 49 +++++++--- .../blender/render/intern/source/renderdatabase.c | 9 +- source/blender/render/intern/source/shadeoutput.c | 47 +++++++--- source/blender/render/intern/source/sss.c | 4 +- source/blender/render/intern/source/zbuf.c | 4 +- .../blender/windowmanager/intern/wm_event_system.c | 8 +- source/blender/windowmanager/intern/wm_files.c | 7 +- 47 files changed, 495 insertions(+), 200 deletions(-) diff --git a/build_files/cmake/cmake_static_check_clang_array.py b/build_files/cmake/cmake_static_check_clang_array.py index ff15a130ee0..8afaf0805f2 100644 --- a/build_files/cmake/cmake_static_check_clang_array.py +++ b/build_files/cmake/cmake_static_check_clang_array.py @@ -30,6 +30,7 @@ import os CHECKER_IGNORE_PREFIX = [ "extern", "intern/moto", + "blender/intern/opennl", ] CHECKER_BIN = "python2" diff --git a/build_files/cmake/cmake_static_check_cppcheck.py b/build_files/cmake/cmake_static_check_cppcheck.py index c340ca5c458..4ea357162ca 100644 --- a/build_files/cmake/cmake_static_check_cppcheck.py +++ b/build_files/cmake/cmake_static_check_cppcheck.py @@ -30,6 +30,7 @@ import os CHECKER_IGNORE_PREFIX = [ "extern", "intern/moto", + "blender/intern/opennl", ] CHECKER_BIN = "cppcheck" diff --git a/build_files/cmake/cmake_static_check_smatch.py b/build_files/cmake/cmake_static_check_smatch.py index 779945b030a..eebb2e94f93 100644 --- a/build_files/cmake/cmake_static_check_smatch.py +++ b/build_files/cmake/cmake_static_check_smatch.py @@ -25,6 +25,7 @@ CHECKER_IGNORE_PREFIX = [ "extern", "intern/moto", + "blender/intern/opennl", ] CHECKER_BIN = "smatch" diff --git a/build_files/cmake/cmake_static_check_sparse.py b/build_files/cmake/cmake_static_check_sparse.py index db1b14e7acb..8862fc78bb5 100644 --- a/build_files/cmake/cmake_static_check_sparse.py +++ b/build_files/cmake/cmake_static_check_sparse.py @@ -25,6 +25,7 @@ CHECKER_IGNORE_PREFIX = [ "extern", "intern/moto", + "blender/intern/opennl", ] CHECKER_BIN = "sparse" diff --git a/build_files/cmake/cmake_static_check_splint.py b/build_files/cmake/cmake_static_check_splint.py index f538fa612d0..b753a6122cd 100644 --- a/build_files/cmake/cmake_static_check_splint.py +++ b/build_files/cmake/cmake_static_check_splint.py @@ -25,6 +25,7 @@ CHECKER_IGNORE_PREFIX = [ "extern", "intern/moto", + "blender/intern/opennl", ] CHECKER_BIN = "splint" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 99b788e80ce..197e38ac778 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -621,7 +621,9 @@ void BKE_undo_step(bContext *C, int step) } 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; @@ -631,7 +633,9 @@ void BKE_undo_step(bContext *C, int step) 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; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index de55751f2ec..efcc00c401d 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2866,7 +2866,9 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if (!(mask & CD_TYPE_AS_MASK(layer->type))) ; + if (!(mask & CD_TYPE_AS_MASK(layer->type))) { + /* pass */ + } else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) { if (typeInfo->free) typeInfo->free(layer->data, totelem, typeInfo->size); @@ -2892,10 +2894,15 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if (!(mask & CD_TYPE_AS_MASK(layer->type))) ; - else if (layer->flag & CD_FLAG_IN_MEMORY) ; - else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) + if (!(mask & CD_TYPE_AS_MASK(layer->type))) { + /* pass */ + } + else if (layer->flag & CD_FLAG_IN_MEMORY) { + /* pass */ + } + else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) { update = 1; + } } if (!update) @@ -2913,15 +2920,23 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if (!(mask & CD_TYPE_AS_MASK(layer->type))) ; - else if (layer->flag & CD_FLAG_IN_MEMORY) ; + if (!(mask & CD_TYPE_AS_MASK(layer->type))) { + /* pass */ + } + else if (layer->flag & CD_FLAG_IN_MEMORY) { + /* pass */ + } else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) { blay = cdf_layer_find(cdf, layer->type, layer->name); if (blay) { if (cdf_read_layer(cdf, blay)) { - if (typeInfo->read(cdf, layer->data, totelem)) ; - else break; + if (typeInfo->read(cdf, layer->data, totelem)) { + /* pass */ + } + else { + break; + } layer->flag |= CD_FLAG_IN_MEMORY; } else @@ -2952,9 +2967,12 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in layer = &data->layers[i]; typeInfo = layerType_getInfo(layer->type); - if (!(mask & CD_TYPE_AS_MASK(layer->type))) ; - else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) + if (!(mask & CD_TYPE_AS_MASK(layer->type))) { + /* pass */ + } + else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) { update = 1; + } } if (!update) @@ -2995,11 +3013,16 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in blay = cdf_layer_find(cdf, layer->type, layer->name); if (cdf_write_layer(cdf, blay)) { - if (typeInfo->write(cdf, layer->data, totelem)) ; - else break; + if (typeInfo->write(cdf, layer->data, totelem)) { + /* pass */ + } + else { + break; + } } - else + else { break; + } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 64959fd3aa1..10c9f30f5ee 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -299,7 +299,9 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i else resolu = nu->resolu; - if (!BKE_nurb_check_valid_u(nu)) ; + if (!BKE_nurb_check_valid_u(nu)) { + /* pass */ + } else if (nu->type == CU_BEZIER) { /* count */ len = 0; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 8b35974ea62..06b21fbbd29 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -928,8 +928,12 @@ makebreak: * 3: curs down */ 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) { + /* pass */ + } + else if ((mode == FO_CURSDOWN || mode == FO_PAGEDOWN) && ct->linenr == lnr) { + /* pass */ + } else { switch (mode) { case FO_CURSUP: lnr = ct->linenr - 1; break; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 17e4103c7d3..bb871f0cfd4 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -879,9 +879,10 @@ void outside_lattice(Lattice *lt) for (v = 0; v < lt->pntsv; v++) { 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) ; + if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) { + /* pass */ + } else { - bp->hide = 1; bp->f1 &= ~SELECT; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 28de80a7157..f072ed4009e 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -574,10 +574,12 @@ 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) ; - else - if (modifier_isCorrectableDeformed(md)) + if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) { + /* pass */ + } + else if (modifier_isCorrectableDeformed(md)) { return 1; + } } return 0; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e8af794eaea..89dadcd8dd5 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -97,8 +97,8 @@ int count_particles(ParticleSystem *psys) 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; @@ -110,8 +110,8 @@ int count_particles_mod(ParticleSystem *psys, int totgr, int cur) 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 if (p % totgr == cur) tot++; } return tot; diff --git a/source/blender/blenlib/BLI_endian_switch_inline.h b/source/blender/blenlib/BLI_endian_switch_inline.h index 948d462fde4..6aa0405861e 100644 --- a/source/blender/blenlib/BLI_endian_switch_inline.h +++ b/source/blender/blenlib/BLI_endian_switch_inline.h @@ -74,12 +74,12 @@ BLI_INLINE void BLI_endian_switch_int64(int64_t *val) { int64_t tval = *val; *val = ((tval >> 56)) | - ((tval << 40) & 0x00ff000000000000) | - ((tval << 24) & 0x0000ff0000000000) | - ((tval << 8) & 0x000000ff00000000) | - ((tval >> 8) & 0x00000000ff000000) | - ((tval >> 24) & 0x0000000000ff0000) | - ((tval >> 40) & 0x000000000000ff00) | + ((tval << 40) & 0x00ff000000000000l) | + ((tval << 24) & 0x0000ff0000000000l) | + ((tval << 8) & 0x000000ff00000000l) | + ((tval >> 8) & 0x00000000ff000000l) | + ((tval >> 24) & 0x0000000000ff0000l) | + ((tval >> 40) & 0x000000000000ff00l) | ((tval << 56)); } BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 707594ff590..46bbf6f0683 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -3357,12 +3357,17 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) if (EBONE_VISIBLE(arm, ebone)) { /* we extrude per definition the tip */ do_extrude = FALSE; - if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED)) + if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED)) { do_extrude = TRUE; + } else if (ebone->flag & BONE_ROOTSEL) { /* but, a bone with parent deselected we do the root... */ - if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) ; - else do_extrude = 2; + if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) { + /* pass */ + } + else { + do_extrude = 2; + } } if (do_extrude) { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index afd6bc4c4b5..d22b9f2abfb 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1579,8 +1579,9 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) BPoint *bp, *bpn, *newbp; int a, b, newu, newv, sel; - if (obedit->type == OB_SURF) ; - else return OPERATOR_CANCELLED; + if (obedit->type != OB_SURF) { + return OPERATOR_CANCELLED; + } cu->lastsel = NULL; @@ -1593,8 +1594,12 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) a = nu->pntsu * nu->pntsv; while (a) { a--; - if (bp->f1 & flag) ; - else break; + if (bp->f1 & flag) { + /* pass */ + } + else { + break; + } bp++; } if (a == 0) { @@ -1715,8 +1720,12 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) bp = nu->bp; a = nu->pntsu; while (a) { - if (bp->f1 & flag) ; - else break; + if (bp->f1 & flag) { + /* pass */ + } + else { + break; + } bp++; a--; } @@ -3762,20 +3771,28 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu /* first nurbs: u = resolu-1 selected */ - if (is_u_selected(nu1, nu1->pntsu - 1) ) ; + if (is_u_selected(nu1, nu1->pntsu - 1) ) { + /* pass */ + } else { /* For 2D curves blender uses (orderv = 0). It doesn't make any sense mathematically. */ /* but after rotating (orderu = 0) will be confusing. */ if (nu1->orderv == 0) nu1->orderv = 1; rotate_direction_nurb(nu1); - if (is_u_selected(nu1, nu1->pntsu - 1)) ; + if (is_u_selected(nu1, nu1->pntsu - 1)) { + /* pass */ + } else { rotate_direction_nurb(nu1); - if (is_u_selected(nu1, nu1->pntsu - 1)) ; + if (is_u_selected(nu1, nu1->pntsu - 1)) { + /* pass */ + } else { rotate_direction_nurb(nu1); - if (is_u_selected(nu1, nu1->pntsu - 1)) ; + if (is_u_selected(nu1, nu1->pntsu - 1)) { + /* pass */ + } else { /* rotate again, now its OK! */ if (nu1->pntsv != 1) rotate_direction_nurb(nu1); @@ -3786,17 +3803,25 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu } /* 2nd nurbs: u = 0 selected */ - if (is_u_selected(nu2, 0) ) ; + if (is_u_selected(nu2, 0) ) { + /* pass */ + } else { if (nu2->orderv == 0) nu2->orderv = 1; rotate_direction_nurb(nu2); - if (is_u_selected(nu2, 0)) ; + if (is_u_selected(nu2, 0)) { + /* pass */ + } else { rotate_direction_nurb(nu2); - if (is_u_selected(nu2, 0)) ; + if (is_u_selected(nu2, 0)) { + /* pass */ + } else { rotate_direction_nurb(nu2); - if (is_u_selected(nu2, 0)) ; + if (is_u_selected(nu2, 0)) { + /* pass */ + } else { /* rotate again, now its OK! */ if (nu1->pntsu == 1) rotate_direction_nurb(nu1); @@ -3892,15 +3917,27 @@ static int merge_nurb(bContext *C, wmOperator *op) /* resolution match, to avoid uv rotations */ if (nus1->nu->pntsv == 1) { - if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) ; - else ok = 0; + if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) { + /* pass */ + } + else { + ok = 0; + } } else if (nus2->nu->pntsv == 1) { - if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) ; - else ok = 0; + if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) { + /* pass */ + } + else { + ok = 0; + } + } + else if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsv == nus2->nu->pntsv) { + /* pass */ + } + else if (nus1->nu->pntsu == nus2->nu->pntsv || nus1->nu->pntsv == nus2->nu->pntsu) { + /* pass */ } - else if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsv == nus2->nu->pntsv) ; - else if (nus1->nu->pntsu == nus2->nu->pntsv || nus1->nu->pntsv == nus2->nu->pntsu) ; else { ok = 0; } @@ -3949,8 +3986,12 @@ static int make_segment_exec(bContext *C, wmOperator *op) if (isNurbsel_count(cu, nu) == 1) { /* only 1 selected, not first or last, a little complex, but intuitive */ if (nu->pntsv == 1) { - if ( (nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) ; - else break; + if ( (nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) { + /* pass */ + } + else { + break; + } } } } @@ -5684,8 +5725,12 @@ static int delete_exec(bContext *C, wmOperator *op) a = nu->pntsu; if (a) { while (a) { - if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) ; - else break; + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + /* pass */ + } + else { + break; + } a--; bezt++; } @@ -5704,8 +5749,12 @@ static int delete_exec(bContext *C, wmOperator *op) a = nu->pntsu * nu->pntsv; if (a) { while (a) { - if (bp->f1 & SELECT) ; - else break; + if (bp->f1 & SELECT) { + /* pass */ + } + else { + break; + } a--; bp++; } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2c00e39766c..df18498559e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1152,9 +1152,15 @@ static void ui_is_but_sel(uiBut *but, double *value) } } - if (is_push == 2) ; - else if (is_push == 1) but->flag |= UI_SELECT; - else but->flag &= ~UI_SELECT; + if (is_push == 2) { + /* pass */ + } + else if (is_push == 1) { + but->flag |= UI_SELECT; + } + else { + but->flag &= ~UI_SELECT; + } } static uiBut *ui_find_inlink(uiBlock *block, void *poin) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 60e4c2aa90f..f798f0b399b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -704,7 +704,9 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) BLI_rcti_rctf_copy(&rect, &but->rect); - if (but->imb) ; /* use button size itself */ + if (but->imb) { + /* use button size itself */ + } else if (but->flag & UI_ICON_LEFT) { rect.xmax = rect.xmin + (BLI_rcti_size_y(&rect)); } @@ -1184,7 +1186,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* numeric value */ if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { - if (but->poin == NULL && but->rnapoin.data == NULL) ; + if (but->poin == NULL && but->rnapoin.data == NULL) { + /* pass */ + } else if (mode == 'c') { ui_get_but_string(but, buf, sizeof(buf)); WM_clipboard_text_set(buf, 0); @@ -1205,7 +1209,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else if (but->type == COLOR) { float rgb[3]; - if (but->poin == NULL && but->rnapoin.data == NULL) ; + if (but->poin == NULL && but->rnapoin.data == NULL) { + /* pass */ + } else if (mode == 'c') { ui_get_but_vectorf(but, rgb); @@ -1234,7 +1240,9 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { uiHandleButtonData *active_data = but->active; - if (but->poin == NULL && but->rnapoin.data == NULL) ; + if (but->poin == NULL && but->rnapoin.data == NULL) { + /* pass */ + } else if (mode == 'c') { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR); @@ -2297,7 +2305,9 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton { if (data->state == BUTTON_STATE_HIGHLIGHT) { if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) { - if (but->dt == UI_EMBOSSN && !event->ctrl) ; + if (but->dt == UI_EMBOSSN && !event->ctrl) { + /* pass */ + } else { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); return WM_UI_HANDLER_BREAK; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index d692bf8e492..8e30b31f3fe 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2516,8 +2516,12 @@ static void ui_item_align(uiLayout *litem, short nr) if (!bitem->but->alignnr) bitem->but->alignnr = nr; } - else if (item->type == ITEM_LAYOUT_ABSOLUTE) ; - else if (item->type == ITEM_LAYOUT_OVERLAP) ; + else if (item->type == ITEM_LAYOUT_ABSOLUTE) { + /* pass */ + } + else if (item->type == ITEM_LAYOUT_OVERLAP) { + /* pass */ + } else if (item->type == ITEM_LAYOUT_BOX) { box = (uiLayoutItemBx *)item; box->roundbox->alignnr = nr; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 3fc20309264..0e1fd87c985 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -891,8 +891,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect /* calculate blend color */ if (ELEM4(but->type, TOG, ROW, TOGN, LISTROW)) { - if (but->flag & UI_SELECT) ; - else if (but->flag & UI_ACTIVE) ; + if (but->flag & UI_SELECT) {} + else if (but->flag & UI_ACTIVE) {} else alpha = 0.5f; } diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 5fd848ccb13..429b2148894 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -214,7 +214,9 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind /* fill array by selection */ mp = me->mpoly; for (a = 0; a < me->totpoly; a++, mp++) { - if (mp->flag & ME_HIDE) ; + if (mp->flag & ME_HIDE) { + /* pass */ + } else if (mp->flag & ME_FACE_SEL) { hash_add_face(ehash, mp, me->mloop + mp->loopstart); linkflag[a] = 1; @@ -572,7 +574,9 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) mpoly = me->mpoly; for (a = 1; a <= me->totpoly; a++, mpoly++) { if (selar[a]) { - if (mpoly->flag & ME_HIDE) ; + if (mpoly->flag & ME_HIDE) { + /* pass */ + } else { if (select) mpoly->flag |= ME_FACE_SEL; else mpoly->flag &= ~ME_FACE_SEL; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index ee2b5e08520..dc490c94b38 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3989,7 +3989,9 @@ void PE_undo_step(Scene *scene, int step) } else if (step==1) { - if (edit->curundo==NULL || edit->curundo->prev==NULL); + if (edit->curundo==NULL || edit->curundo->prev==NULL) { + /* pass */ + } else { if (G.debug & G_DEBUG) printf("undo %s\n", edit->curundo->name); edit->curundo= edit->curundo->prev; @@ -3999,7 +4001,9 @@ void PE_undo_step(Scene *scene, int step) else { /* curundo has to remain current situation! */ - if (edit->curundo==NULL || edit->curundo->next==NULL); + if (edit->curundo==NULL || edit->curundo->next==NULL) { + /* pass */ + } else { get_PTCacheUndo(edit, edit->curundo->next); edit->curundo= edit->curundo->next; diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 08ccf37265b..cd55b91cb6b 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -224,8 +224,12 @@ static void material_changed(Main *bmain, Material *ma) /* find node materials using this */ for (parent = bmain->mat.first; parent; parent = parent->id.next) { - if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) ; - else continue; + if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) { + /* pass */ + } + else { + continue; + } BKE_icon_changed(BKE_icon_getid(&parent->id)); @@ -247,9 +251,15 @@ static void texture_changed(Main *bmain, Tex *tex) /* find materials */ for (ma = bmain->mat.first; ma; ma = ma->id.next) { - if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) ; - else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) ; - else continue; + if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) { + /* pass */ + } + else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) { + /* pass */ + } + else { + continue; + } BKE_icon_changed(BKE_icon_getid(&ma->id)); @@ -259,18 +269,30 @@ static void texture_changed(Main *bmain, Tex *tex) /* find lamps */ for (la = bmain->lamp.first; la; la = la->id.next) { - if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) ; - else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) ; - else continue; + if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) { + /* pass */ + } + else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) { + /* pass */ + } + else { + continue; + } BKE_icon_changed(BKE_icon_getid(&la->id)); } /* find worlds */ for (wo = bmain->world.first; wo; wo = wo->id.next) { - if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) ; - else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) ; - else continue; + if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) { + /* pass */ + } + else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) { + /* pass */ + } + else { + continue; + } BKE_icon_changed(BKE_icon_getid(&wo->id)); } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 01a5304451a..7c377a041e7 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -407,8 +407,12 @@ void region_scissor_winrct(ARegion *ar, rcti *winrct) ar = ar->prev; if (BLI_rcti_isect(winrct, &ar->winrct, NULL)) { - if (ar->flag & RGN_FLAG_HIDDEN) ; - else if (ar->alignment & RGN_SPLIT_PREV) ; + if (ar->flag & RGN_FLAG_HIDDEN) { + /* pass */ + } + else if (ar->alignment & RGN_SPLIT_PREV) { + /* pass */ + } else if (ar->alignment == RGN_OVERLAP_LEFT) { winrct->xmin = ar->winrct.xmax + 1; } @@ -935,20 +939,25 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int /* prefsize, for header we stick to exception */ prefsizex = ar->sizex ? ar->sizex : ar->type->prefsizex; - if (ar->regiontype == RGN_TYPE_HEADER) + if (ar->regiontype == RGN_TYPE_HEADER) { prefsizey = ar->type->prefsizey; + } else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2); } - else + else { prefsizey = ar->sizey ? ar->sizey : ar->type->prefsizey; - - /* hidden is user flag */ - if (ar->flag & RGN_FLAG_HIDDEN) ; - /* XXX floating area region, not handled yet here */ - else if (alignment == RGN_ALIGN_FLOAT) ; - /* remainder is too small for any usage */ + } + + + if (ar->flag & RGN_FLAG_HIDDEN) { + /* hidden is user flag */ + } + else if (alignment == RGN_ALIGN_FLOAT) { + /* XXX floating area region, not handled yet here */ + } else if (rct_fits(remainder, 'v', 1) < 0 || rct_fits(remainder, 'h', 1) < 0) { + /* remainder is too small for any usage */ ar->flag |= RGN_FLAG_TOO_SMALL; } else if (alignment == RGN_ALIGN_NONE) { diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index f5b9aa742c6..e406d4f5c3b 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -152,7 +152,9 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * UndoElem *undo; if (step == 1) { - if (stack->current == NULL) ; + if (stack->current == NULL) { + /* pass */ + } else { if (!name || strcmp(stack->current->name, name) == 0) { if (G.debug & G_DEBUG_WM) { @@ -165,7 +167,9 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * } } else if (step == -1) { - if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) ; + if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) { + /* pass */ + } else { if (!name || strcmp(stack->current->name, name) == 0) { undo = (stack->current && stack->current->next) ? stack->current->next : stack->elems.first; @@ -254,7 +258,9 @@ int ED_undo_paint_valid(int type, const char *name) else return 0; - if (stack->current == NULL) ; + if (stack->current == NULL) { + /* pass */ + } else { if (name && strcmp(stack->current->name, name) == 0) return 1; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index d3b4df05aa9..ce522ec7e3f 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -748,7 +748,9 @@ static int file_is_blend_backup(const char *str) a = strlen(str); b = 7; - if (a == 0 || b >= a) ; + if (a == 0 || b >= a) { + /* pass */ + } else { char *loc; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 31cb6d91889..7f53f378042 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -414,8 +414,9 @@ static void image_refresh(const bContext *C, ScrArea *sa) /* don't need to check for pin here, see above */ sima->image = tf->tpage; - if (sima->flag & SI_EDITTILE) ; - else sima->curtile = tf->tile; + if ((sima->flag & SI_EDITTILE) == 0) { + sima->curtile = tf->tile; + } } } } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index a05588495e9..e8aa01af6b2 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -783,7 +783,9 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo wmKeyMapItem *kmi = te->directdata; /* modal map? */ - if (kmi->propvalue) ; + if (kmi->propvalue) { + /* pass */ + } else { uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys + 1, butw1, UI_UNIT_Y - 1, "Assign new Operator"); } @@ -1409,11 +1411,15 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene /* 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 */ + if (tselem->type == 0 && te->idcode == ID_SCE) { + /* pass */ + } + 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 + /* divider */ UI_ThemeColorShade(TH_BACK, -40); glRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4); diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 3e1ce1fea6e..ef0542130ea 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -769,7 +769,9 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor 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) ; + if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) { + /* pass */ + } else { Bone *curBone; for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) { @@ -811,9 +813,15 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i 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) ; + if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { + /* pass */ + } + else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + /* pass */ + } + else if (type == TSE_ANIM_DATA) { + /* pass */ + } else { te->name = id->name + 2; // default, can be overridden by Library or non-ID data te->idcode = GS(id->name); @@ -1055,8 +1063,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i if (key[0]) { wmOperatorType *ot = NULL; - if (kmi->propvalue) ; - else ot = WM_operatortype_find(kmi->idname, 0); + if (kmi->propvalue) { + /* pass */ + } + 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); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 204930e82a6..459a8d54d12 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -579,7 +579,9 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) seq2 = del_seq_find_replace_recurs(scene, seq->seq2); seq3 = del_seq_find_replace_recurs(scene, seq->seq3); - if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) ; + if (seq1 == seq->seq1 && seq2 == seq->seq2 && seq3 == seq->seq3) { + /* pass */ + } else if (seq1 || seq2 || seq3) { seq->seq1 = (seq1) ? seq1 : (seq2) ? seq2 : seq3; seq->seq2 = (seq2) ? seq2 : (seq1) ? seq1 : seq3; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index ecce12b8cba..31df13343ce 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2226,9 +2226,16 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) } /* restore */ - if (index != -1) glLoadName(-1); - if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) ; - else if (dt > OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f); + if (index != -1) { + glLoadName(-1); + } + + if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { + /* pass */ + } + else if (dt > OB_WIRE) { + bglPolygonOffset(rv3d->dist, 0.0f); + } /* finally names and axes */ if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ca768f2ef17..00d35a5d2e1 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -355,7 +355,9 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** if (dx < GRID_MIN_PX_D) { rv3d->gridview *= sublines; dx *= sublines; - if (dx < GRID_MIN_PX_D) ; + if (dx < GRID_MIN_PX_D) { + /* pass */ + } else { UI_ThemeColor(TH_GRID); drawgrid_draw(ar, wx, wy, x, y, dx); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 39a5da94798..2e9d1ee670f 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3986,13 +3986,13 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL); if (t->frame_side == 'R') { - if (right <= cfra) *count = *flag = 0; /* ignore */ - else if (left > cfra) ; /* keep the selection */ + if (right <= cfra) { *count = *flag = 0; } /* ignore */ + else if (left > cfra) { } /* keep the selection */ else *flag |= SEQ_RIGHTSEL; } else { - if (left >= cfra) *count = *flag = 0; /* ignore */ - else if (right < cfra) ; /* keep the selection */ + if (left >= cfra) { *count = *flag = 0; } /* ignore */ + else if (right < cfra) { } /* keep the selection */ else *flag |= SEQ_LEFTSEL; } } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 494cb875169..079f2768352 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -485,11 +485,15 @@ static int preprocess_include(char *maindata, int len) } /* do not copy when: */ - if (comment) ; - else if (cp[0] == ' ' && cp[1] == ' ') ; - else if (cp[-1] == '*' && cp[0] == ' ') ; /* pointers with a space */ - - /* skip special keywords */ + if (comment) { + /* pass */ + } + else if (cp[0] == ' ' && cp[1] == ' ') { + /* pass */ + } + else if (cp[-1] == '*' && cp[0] == ' ') { + /* pointers with a space */ + } /* skip special keywords */ else if (strncmp("DNA_DEPRECATED", cp, 14) == 0) { /* single values are skipped already, so decrement 1 less */ a -= 13; @@ -1028,7 +1032,9 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (debugSDNA > -1) printf("Writing file ... "); - if (nr_names == 0 || nr_structs == 0) ; + if (nr_names == 0 || nr_structs == 0) { + /* pass */ + } else { strcpy(str, "SDNA"); dna_write(file, str, 4); diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index ce22bc00a55..fdd3b97ad59 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -65,7 +65,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); target->tin = (target->tr + target->tg + target->tb) / 3.0f; - target->talpha = 1; + target->talpha = TRUE; if (target->nor) { if (in[1] && in[1]->hasinput) diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index b3948563a87..46ab3aeb21f 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -4106,8 +4106,12 @@ static void set_fullsample_trace_flag(Render *re, ObjectRen *obr) vlr->flag |= R_FULL_OSA; } else if (trace) { - if (mode & MA_SHLESS); - else if (vlr->mat->material_type == MA_TYPE_VOLUME); + if (mode & MA_SHLESS) { + /* pass */ + } + else if (vlr->mat->material_type == MA_TYPE_VOLUME) { + /* pass */ + } else if ((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) { /* for blurry reflect/refract, better to take more samples * inside the raytrace than as OSA samples */ diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 6c86f2a2999..154292a3065 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -150,8 +150,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul fx-= xs; fy-= ys; - if ( (tex->flag & TEX_CHECKER_ODD)==0) { - if ((xs+ys) & 1);else return retval; + if ( (tex->flag & TEX_CHECKER_ODD) == 0) { + if ((xs + ys) & 1) { + /* pass */ + } + else { + return retval; + } } if ( (tex->flag & TEX_CHECKER_EVEN)==0) { if ((xs+ys) & 1) return retval; @@ -474,7 +479,9 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) muly= 1.0; - if (starty==endy); + if (starty==endy) { + /* pass */ + } else { if (y==starty) muly= 1.0f-(rf->ymin - y); if (y==endy) muly= (rf->ymax - y); @@ -1453,8 +1460,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const image_mipmap_test(tex, ibuf); if (tex->imaflag & TEX_USEALPHA) { - if (tex->imaflag & TEX_CALCALPHA); - else texres->talpha= 1; + if (tex->imaflag & TEX_CALCALPHA) { + /* pass */ + } + else { + texres->talpha = TRUE; + } } texr.talpha= texres->talpha; @@ -1550,11 +1561,17 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const if (boundary==0) { if ( (tex->flag & TEX_CHECKER_ODD)==0) { - if ((xs+ys) & 1); - else return retval; + if ((xs + ys) & 1) { + /* pass */ + } + else { + return retval; + } } if ( (tex->flag & TEX_CHECKER_EVEN)==0) { - if ((xs+ys) & 1) return retval; + if ((xs + ys) & 1) { + return retval; + } } fx-= xs; fy-= ys; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index af774c5be73..895c5d6c8fb 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -625,9 +625,12 @@ static void occ_build_sh_normalize(OccNode *node) sh_mul(node->sh, 1.0f / node->area); for (b = 0; b < TOTCHILD; b++) { - if (node->childflag & (1 << b)) ; - else if (node->child[b].node) + if (node->childflag & (1 << b)) { + /* pass */ + } + else if (node->child[b].node) { occ_build_sh_normalize(node->child[b].node); + } } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index b1b88fc9fd5..b64a6b85ef7 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -505,7 +505,9 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); if (re->r.scemode & R_PREVIEWBUTS) { - if (re->result && re->result->rectx == re->rectx && re->result->recty == re->recty) ; + if (re->result && re->result->rectx == re->rectx && re->result->recty == re->recty) { + /* pass */ + } else { render_result_free(re->result); re->result = NULL; @@ -654,8 +656,12 @@ static void *do_part_thread(void *pa_v) } else if (render_display_draw_enabled(&R)) { /* on break, don't merge in result for preview renders, looks nicer */ - if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)) ; - else render_result_merge(R.result, pa->result); + if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)) { + /* pass */ + } + else { + render_result_merge(R.result, pa->result); + } } } diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 49c2bf1d053..a93dde7e813 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -481,7 +481,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) case TEX_PD_COLOR_PARTAGE: if (pd->coba) { if (do_colorband(pd->coba, age, col)) { - texres->talpha= 1; + texres->talpha = TRUE; copy_v3_v3(&texres->tr, col); texres->tin *= col[3]; texres->ta = texres->tin; @@ -494,7 +494,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) if (pd->coba) { if (do_colorband(pd->coba, speed, col)) { - texres->talpha= 1; + texres->talpha = TRUE; copy_v3_v3(&texres->tr, col); texres->tin *= col[3]; texres->ta = texres->tin; @@ -503,7 +503,7 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) break; } case TEX_PD_COLOR_PARTVEL: - texres->talpha= 1; + texres->talpha = TRUE; mul_v3_fl(vec, pd->speed_scale); copy_v3_v3(&texres->tr, vec); texres->ta = texres->tin; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 982f7e7d824..0511b03b42d 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -887,12 +887,12 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], fx = (t[0] + 1.0f) / 2.0f; fy = (t[1] + 1.0f) / 2.0f; } - else if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy, t[0], t[1], t[2]); - else if (wrap==MTEX_SPHERE) map_to_sphere(&fx, &fy, t[0], t[1], t[2]); + else if (wrap == MTEX_TUBE) map_to_tube( &fx, &fy, t[0], t[1], t[2]); + else if (wrap == MTEX_SPHERE) map_to_sphere(&fx, &fy, t[0], t[1], t[2]); else { - if (texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); - else if (texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); - else cubemap(mtex, vlr, n, t[0], t[1], t[2], &fx, &fy); + if (texco == TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); + else if (texco == TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); + else cubemap(mtex, vlr, n, t[0], t[1], t[2], &fx, &fy); } /* repeat */ @@ -953,10 +953,17 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (t[1]<=0.0f) { fx= t[0]+dxt[0]; fy= t[0]+dyt[0]; - if (fx>=0.0f && fy>=0.0f && t[0]>=0.0f); - else if (fx<=0.0f && fy<=0.0f && t[0]<=0.0f); - else ok= 0; + if (fx>=0.0f && fy>=0.0f && t[0]>=0.0f) { + /* pass */ + } + else if (fx<=0.0f && fy<=0.0f && t[0]<=0.0f) { + /* pass */ + } + else { + ok = 0; + } } + if (ok) { if (wrap==MTEX_TUBE) { map_to_tube(area, area+1, t[0], t[1], t[2]); @@ -1096,7 +1103,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, float tmpvec[3]; int retval=0; /* return value, int:0, col:1, nor:2, everything:3 */ - texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */ + texres->talpha = FALSE; /* is set when image texture returns alpha (considered premul) */ if (tex->use_nodes && tex->nodetree) { retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread, @@ -1193,7 +1200,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, if (tex->flag & TEX_COLORBAND) { float col[4]; if (do_colorband(tex->coba, texres->tin, col)) { - texres->talpha= 1; + texres->talpha = TRUE; texres->tr= col[0]; texres->tg= col[1]; texres->tb= col[2]; @@ -2445,7 +2452,9 @@ void do_material_tex(ShadeInput *shi, Render *re) copy_v3_v3(nor, texres.nor); - if (mtex->normapspace == MTEX_NSPACE_CAMERA); + if (mtex->normapspace == MTEX_NSPACE_CAMERA) { + /* pass */ + } else if (mtex->normapspace == MTEX_NSPACE_WORLD) { mul_mat3_m4_v3(re->viewmat, nor); } @@ -2922,10 +2931,14 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) } if (mtex->mapto & MAP_ALPHA) { if (rgb) { - if (texres.talpha) texres.tin= texres.ta; - else texres.tin = rgb_to_bw(&texres.tr); + if (texres.talpha) { + texres.tin = texres.ta; + } + else { + texres.tin = rgb_to_bw(&texres.tr); + } } - + col_r[3]*= texres.tin; } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 0d894073cee..285cd02c4ff 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -271,16 +271,26 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) har= R.sortedhalos[a]; /* layer test, clip halo with y */ - if ((har->lay & lay)==0); - else if (testrect.ymin > har->maxy); - else if (testrect.ymax < har->miny); + if ((har->lay & lay) == 0) { + /* pass */ + } + else if (testrect.ymin > har->maxy) { + /* pass */ + } + else if (testrect.ymax < har->miny) { + /* pass */ + } else { minx= floor(har->xs-har->rad); maxx= ceil(har->xs+har->rad); - if (testrect.xmin > maxx); - else if (testrect.xmax < minx); + if (testrect.xmin > maxx) { + /* pass */ + } + else if (testrect.xmax < minx) { + /* pass */ + } else { minx= MAX2(minx, testrect.xmin); @@ -980,7 +990,9 @@ static void convert_to_key_alpha(RenderPart *pa, RenderLayer *rl) float *rectf= rlpp[sample]->rectf; for (y= pa->rectx*pa->recty; y>0; y--, rectf+=4) { - if (rectf[3] >= 1.0f); + if (rectf[3] >= 1.0f) { + /* pass */ + } else if (rectf[3] > 0.0f) { rectf[0] /= rectf[3]; rectf[1] /= rectf[3]; @@ -1833,16 +1845,23 @@ static void renderhalo_post(RenderResult *rr, float *rectf, HaloRen *har) /* pos har->miny= miny= haloys - har->rad/R.ycor; har->maxy= maxy= haloys + har->rad/R.ycor; - if (maxy<0); - else if (rr->rectyrecty < miny) { + /* pass */ + } else { - minx= floor(haloxs-har->rad); - maxx= ceil(haloxs+har->rad); + minx = floor(haloxs - har->rad); + maxx = ceil(haloxs + har->rad); - if (maxx<0); - else if (rr->rectxrectx < minx) { + /* pass */ + } else { - if (minx<0) minx= 0; if (maxx>=rr->rectx) maxx= rr->rectx-1; if (miny<0) miny= 0; @@ -2099,7 +2118,9 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua copy_v3_v3(nor, shi->vn); - if (R.r.bake_normal_space == R_BAKE_SPACE_CAMERA); + if (R.r.bake_normal_space == R_BAKE_SPACE_CAMERA) { + /* pass */ + } else if (R.r.bake_normal_space == R_BAKE_SPACE_TANGENT) { float mat[3][3], imat[3][3]; diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 6395a04b534..172af3a6c6f 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -976,10 +976,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, if (ma->mtex[0]) { - if ( (ma->mode & MA_HALOTEX) ) har->tex= 1; - else if (har->mat->septex & (1<<0)); /* only 1 level textures */ + if (ma->mode & MA_HALOTEX) { + har->tex = 1; + } + else if (har->mat->septex & (1 << 0)) { + /* only 1 level textures */ + } else { - mtex= ma->mtex[0]; copy_v3_v3(texvec, vec); diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 6883710d1be..873657ec6ba 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -123,30 +123,45 @@ float mistfactor(float zcor, float const co[3]) { float fac, hi; - fac= zcor - R.wrld.miststa; /* zcor is calculated per pixel */ + fac = zcor - R.wrld.miststa; /* zcor is calculated per pixel */ /* fac= -co[2]-R.wrld.miststa; */ - if (fac>0.0f) { - if (fac< R.wrld.mistdist) { + if (fac > 0.0f) { + if (fac < R.wrld.mistdist) { - fac= (fac/(R.wrld.mistdist)); + fac = (fac / R.wrld.mistdist); - if (R.wrld.mistype==0) fac*= fac; - else if (R.wrld.mistype==1); - else fac= sqrt(fac); + if (R.wrld.mistype == 0) { + fac *= fac; + } + else if (R.wrld.mistype == 1) { + /* pass */ + } + else { + fac = sqrt(fac); + } + } + else { + fac = 1.0f; } - else fac= 1.0f; } - else fac= 0.0f; + else { + fac = 0.0f; + } /* height switched off mist */ if (R.wrld.misthi!=0.0f && fac!=0.0f) { /* at height misthi the mist is completely gone */ - hi= R.viewinv[0][2]*co[0]+R.viewinv[1][2]*co[1]+R.viewinv[2][2]*co[2]+R.viewinv[3][2]; + hi = R.viewinv[0][2] * co[0] + + R.viewinv[1][2] * co[1] + + R.viewinv[2][2] * co[2] + + R.viewinv[3][2]; - if (hi>R.wrld.misthi) fac= 0.0f; + if (hi > R.wrld.misthi) { + fac = 0.0f; + } else if (hi>0.0f) { hi= (R.wrld.misthi-hi)/R.wrld.misthi; fac*= hi*hi; @@ -1351,7 +1366,9 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* this complex construction screams for a nicer implementation! (ton) */ if (R.r.mode & R_SHADOW) { if (ma->mode & MA_SHADOW) { - if (lar->type==LA_HEMI || lar->type==LA_AREA); + if (lar->type == LA_HEMI || lar->type == LA_AREA) { + /* pass */ + } else if ((ma->mode & MA_RAYBIAS) && (lar->mode & LA_SHAD_RAY) && (vlr->flag & R_SMOOTH)) { float thresh= shi->obr->ob->smoothresh; if (inp>thresh) @@ -1466,8 +1483,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int if (shadfac[3]>0.0f && shi->spec!=0.0f && !(lar->mode & LA_NO_SPEC) && !(lar->mode & LA_ONLYSHADOW)) { - if (!(passflag & (SCE_PASS_COMBINED|SCE_PASS_SPEC))); - else if (lar->type==LA_HEMI) { + if (!(passflag & (SCE_PASS_COMBINED | SCE_PASS_SPEC))) { + /* pass */ + } + else if (lar->type == LA_HEMI) { float t; /* hemi uses no spec shaders (yet) */ diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 69e738e840d..9b7a521db41 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -238,7 +238,9 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd) float indexf, t, idxf; int index; - if (rr > (RD_TABLE_RANGE_2*RD_TABLE_RANGE_2)); + if (rr > (RD_TABLE_RANGE_2 * RD_TABLE_RANGE_2)) { + /* pass */ + } else if (rr > RD_TABLE_RANGE) { rr= sqrt(rr); indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE_2); diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index bf6962d0087..ba62baae897 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -2038,7 +2038,9 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) MEM_freeN(temprectp); - if (neg); /* z values for negative are already correct */ + if (neg) { + /* z values for negative are already correct */ + } else { /* clear not filled z values */ for (len= xs*ys -1; len>=0; len--) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2f238cd22e7..ef9e25e0fef 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -255,8 +255,12 @@ void wm_event_do_notifiers(bContext *C) for (win = wm->windows.first; win; win = win->next) { /* filter out notifiers */ - if (note->category == NC_SCREEN && note->reference && note->reference != win->screen) ; - else if (note->category == NC_SCENE && note->reference && note->reference != win->screen->scene) ; + if (note->category == NC_SCREEN && note->reference && note->reference != win->screen) { + /* pass */ + } + else if (note->category == NC_SCENE && note->reference && note->reference != win->screen->scene) { + /* pass */ + } else { ScrArea *sa; ARegion *ar; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 7b78dbedb31..c6bd912e89b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -190,9 +190,12 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) /* cases 1 and 2 */ if (oldwmlist->first == NULL) { - if (G.main->wm.first) ; /* nothing todo */ - else + if (G.main->wm.first) { + /* nothing todo */ + } + else { wm_add_default(C); + } } else { /* cases 3 and 4 */ -- cgit v1.2.3 From 35f0ded3776bc08fb52e8068a8a91374192d5b2f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 10:01:54 +0000 Subject: fix for logical errors - range check on hair_velocity_smoothing() was off by one. - cloth sim parm's are used before NULL check in readfile.c --- source/blender/blenkernel/intern/implicit.c | 2 +- source/blender/blenloader/intern/readfile.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index ebb95a6561e..2b23e8450ae 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1450,7 +1450,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0); j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1); k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2); - if (i < 0 || j < 0 || k < 0 || i > 10 || j >= 10 || k >= 10) + if (i < 0 || j < 0 || k < 0 || i >= 10 || j >= 10 || k >= 10) continue; grid[i][j][k].velocity[0] += lV[v][0]; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 26d9fb9e829..fdb68d4cc17 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3567,10 +3567,10 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->clmd->clothObject = NULL; psys->clmd->sim_parms= newdataadr(fd, psys->clmd->sim_parms); - psys->clmd->sim_parms->effector_weights = NULL; psys->clmd->coll_parms= newdataadr(fd, psys->clmd->coll_parms); if (psys->clmd->sim_parms) { + psys->clmd->sim_parms->effector_weights = NULL; if (psys->clmd->sim_parms->presets > 10) psys->clmd->sim_parms->presets = 0; } -- cgit v1.2.3 From aedf450746f1373beb82b9844e66b7ea1c828814 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 12:28:19 +0000 Subject: code cleanup: use checks for empty rather then size in the BGE --- source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 6 +++--- .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 183da9d252e..c890f0c3dc5 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -147,7 +147,7 @@ void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it) int startvertex, endvertex; int startindex, endindex; - it.array = (m_displayArrays.size() > 0)? m_displayArrays[m_startarray]: NULL; + it.array = m_displayArrays.empty() ? NULL : m_displayArrays[m_startarray]; if (it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) { it.array = NULL; @@ -368,7 +368,7 @@ bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) size_t i; // verify if we can join - if (m_joinSlot || m_joinedSlots.size() || target->m_joinSlot) + if (m_joinSlot || (m_joinedSlots.empty() == false) || target->m_joinSlot) return false; if (!Equals(target)) @@ -461,7 +461,7 @@ bool RAS_MeshSlot::Split(bool force) abort(); } - if (target->m_displayArrays.size()) { + if (target->m_displayArrays.empty() == false) { target->m_endvertex = target->m_displayArrays.back()->m_vertex.size(); target->m_endindex = target->m_displayArrays.back()->m_index.size(); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 67423123a7a..a0da1c79baa 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -359,7 +359,7 @@ void RAS_OpenGLRasterizer::ClearCachingInfo(void) void RAS_OpenGLRasterizer::FlushDebugShapes() { - if (!m_debugShapes.size()) + if (m_debugShapes.empty()) return; // DrawDebugLines -- cgit v1.2.3 From c0a9f3f6a1bea9abec2b5e2efe6eb18b01972489 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 12:31:56 +0000 Subject: code cleanup: grease pencil eraser had duplicated logic for getting screen coords of a point, move into a static function. --- source/blender/editors/gpencil/gpencil_paint.c | 107 +++++++++---------------- 1 file changed, 40 insertions(+), 67 deletions(-) diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index de7c2c41a6d..b6857249abf 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -792,6 +792,37 @@ static short gp_stroke_eraser_strokeinside(const int mval[], const int UNUSED(mv return 0; } +static void gp_point_to_xy(ARegion *ar, View2D *v2d, rctf *subrect, bGPDstroke *gps, bGPDspoint *pt, + int *r_x, int *r_y) +{ + int xyval[2]; + + if (gps->flag & GP_STROKE_3DSPACE) { + if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + *r_x = xyval[0]; + *r_y = xyval[1]; + } + else { + *r_x = V2D_IS_CLIPPED; + *r_y = V2D_IS_CLIPPED; + } + } + else if (gps->flag & GP_STROKE_2DSPACE) { + UI_view2d_view_to_region(v2d, pt->x, pt->y, r_x, r_y); + } + else { + if (subrect == NULL) { /* normal 3D view */ + *r_x = (int)(pt->x / 100 * ar->winx); + *r_y = (int)(pt->y / 100 * ar->winy); + } + else { /* camera view, use subrect */ + *r_x = (int)((pt->x / 100) * BLI_rctf_size_x(subrect)) + subrect->xmin; + *r_y = (int)((pt->y / 100) * BLI_rctf_size_y(subrect)) + subrect->ymin; + } + } +} + + /* eraser tool - evaluation per stroke */ // TODO: this could really do with some optimization (KD-Tree/BVH?) static void gp_stroke_eraser_dostroke(tGPsdata *p, @@ -800,7 +831,6 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, { bGPDspoint *pt1, *pt2; int x0 = 0, y0 = 0, x1 = 0, y1 = 0; - int xyval[2]; int i; if (gps->totpoints == 0) { @@ -810,33 +840,11 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, BLI_freelinkN(&gpf->strokes, gps); } else if (gps->totpoints == 1) { - /* get coordinates */ - if (gps->flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_int_global(p->ar, &gps->points->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { - x0 = xyval[0]; - y0 = xyval[1]; - } - else { - x0 = V2D_IS_CLIPPED; - y0 = V2D_IS_CLIPPED; - } - } - else if (gps->flag & GP_STROKE_2DSPACE) { - UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0); - } - else { - if (p->subrect == NULL) { /* normal 3D view */ - x0 = (int)(gps->points->x / 100 * p->ar->winx); - y0 = (int)(gps->points->y / 100 * p->ar->winy); - } - else { /* camera view, use subrect */ - x0 = (int)((gps->points->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin; - y0 = (int)((gps->points->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin; - } - } + gp_point_to_xy(p->ar, p->v2d, p->subrect, gps, gps->points, &x0, &y0); /* do boundbox check first */ - if (BLI_rcti_isect_pt(rect, x0, y0)) { + + if ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) { /* only check if point is inside */ if (((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) { /* free stroke */ @@ -853,48 +861,13 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* get points to work with */ pt1 = gps->points + i; pt2 = gps->points + i + 1; - - /* get coordinates */ - if (gps->flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_int_global(p->ar, &pt1->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { - x0 = xyval[0]; - y0 = xyval[1]; - } - else { - x0 = V2D_IS_CLIPPED; - y0 = V2D_IS_CLIPPED; - } - if (ED_view3d_project_int_global(p->ar, &pt2->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { - x1 = xyval[0]; - y1 = xyval[1]; - } - else { - x1 = V2D_IS_CLIPPED; - y1 = V2D_IS_CLIPPED; - } - } - else if (gps->flag & GP_STROKE_2DSPACE) { - UI_view2d_view_to_region(p->v2d, pt1->x, pt1->y, &x0, &y0); - - UI_view2d_view_to_region(p->v2d, pt2->x, pt2->y, &x1, &y1); - } - else { - if (p->subrect == NULL) { /* normal 3D view */ - x0 = (int)(pt1->x / 100 * p->ar->winx); - y0 = (int)(pt1->y / 100 * p->ar->winy); - x1 = (int)(pt2->x / 100 * p->ar->winx); - y1 = (int)(pt2->y / 100 * p->ar->winy); - } - else { /* camera view, use subrect */ - x0 = (int)((pt1->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin; - y0 = (int)((pt1->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin; - x1 = (int)((pt2->x / 100) * BLI_rctf_size_x(p->subrect)) + p->subrect->xmin; - y1 = (int)((pt2->y / 100) * BLI_rctf_size_y(p->subrect)) + p->subrect->ymin; - } - } - + + gp_point_to_xy(p->ar, p->v2d, p->subrect, gps, pt1, &x0, &y0); + gp_point_to_xy(p->ar, p->v2d, p->subrect, gps, pt2, &x1, &y1); + /* check that point segment of the boundbox of the eraser stroke */ - if (BLI_rcti_isect_pt(rect, x0, y0) || BLI_rcti_isect_pt(rect, x1, y1)) { + if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) || + ((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1))) { /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that linewidth is irrelevant -- cgit v1.2.3 From ccd9f1491a137754aabf214d27f4785a04d10841 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 14:00:18 +0000 Subject: style cleanup: line length, rename V3D_PROJ_RET_SUCCESS -> V3D_PROJ_RET_OK --- source/blender/editors/armature/editarmature.c | 23 +++++++++++----- .../blender/editors/armature/editarmature_sketch.c | 12 ++++---- source/blender/editors/armature/meshlaplacian.c | 4 ++- source/blender/editors/curve/editfont.c | 5 ++-- source/blender/editors/gpencil/drawgpencil.c | 21 ++++++++------ source/blender/editors/gpencil/gpencil_paint.c | 28 +++++++++++++------ source/blender/editors/include/ED_view3d.h | 2 +- source/blender/editors/mesh/editmesh_select.c | 6 ++-- source/blender/editors/mesh/editmesh_slide.c | 8 +++--- source/blender/editors/mesh/editmesh_tools.c | 8 +++--- source/blender/editors/mesh/meshtools.c | 2 +- source/blender/editors/physics/particle_edit.c | 14 +++++----- source/blender/editors/sculpt_paint/paint_cursor.c | 4 +-- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 32 +++++++++++----------- source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 2 +- .../blender/editors/space_view3d/view3d_select.c | 7 +++-- source/blender/editors/space_view3d/view3d_view.c | 10 +++---- source/blender/editors/transform/transform.c | 6 ++-- source/blender/editors/transform/transform_snap.c | 8 +++--- 21 files changed, 116 insertions(+), 90 deletions(-) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 46bbf6f0683..ffdced3262f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -661,7 +661,9 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) /* helpful warnings... */ /* TODO: add warnings to be careful about actions, applying deforms first, etc. */ if (ob->adt && ob->adt->action) - BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose"); + BKE_report(op->reports, RPT_WARNING, + "Actions on this armature will be destroyed by this new rest pose as the " + "transforms stored are relative to the old rest pose"); /* Get editbones of active armature to alter */ ED_armature_to_edit(ob); @@ -1591,7 +1593,8 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ -static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) +static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], + ListBase *edbo, int findunsel, int *selmask) { EditBone *ebone; rcti rect; @@ -2556,7 +2559,8 @@ void updateDuplicateSubtarget(EditBone *dupBone, ListBase *editbones, Object *ob } -EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones, Object *src_ob, Object *dst_ob) +EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones, + Object *src_ob, Object *dst_ob) { EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone"); @@ -3036,7 +3040,8 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone newbone->parent = start->parent; /* TODO, copy more things to the new bone */ - newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE); + newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | + BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE); /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge * - potentially several tips for side chains leading to some tree exist... @@ -4481,7 +4486,8 @@ void ARMATURE_OT_align(wmOperatorType *ot) /* ***************** Pose tools ********************* */ -// XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer +/* XXX bone_looper is only to be used when we want to access settings + * (i.e. editability/visibility/selected) that context doesn't offer */ static int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, Bone *, void *)) { @@ -4511,7 +4517,8 @@ static int bone_looper(Object *ob, Bone *bone, void *data, /* called from editview.c, for mode-less pose selection */ /* assumes scene obact and basact is still on old situation */ -int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend, short deselect, short toggle) +int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, + short extend, short deselect, short toggle) { Object *ob = base->object; Bone *nearBone; @@ -4757,7 +4764,9 @@ static void add_vgroups__mapFunc(void *userData, int index, const float co[3], copy_v3_v3(verts[index], co); } -static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, float scale) +static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, + bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, + float (*root)[3], float (*tip)[3], int *selected, float scale) { /* Create vertex group weights from envelopes */ diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 5ba4a232250..68d8a8d721e 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -646,7 +646,7 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in short pval[2]; int pdist; - if (ED_view3d_project_short_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_short_global(ar, stk->points[i].p, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -682,7 +682,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, { copy_v3_v3(vec, bone->head); mul_m4_v3(ob->obmat, vec); - if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -699,7 +699,7 @@ static SK_Point *sk_snapPointArmature(bContext *C, Object *ob, ListBase *ebones, copy_v3_v3(vec, bone->tail); mul_m4_v3(ob->obmat, vec); - if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_short_noclip(ar, vec, pval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]); @@ -939,7 +939,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr initgrabz(ar->regiondata, fp[0], fp[1], fp[2]); /* method taken from editview.c - mouse_cursor() */ - if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_short_global(ar, fp, cval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { VECSUB2D(mval_f, cval, dd->mval); ED_view3d_win_to_delta(ar, mval_f, dvec); sub_v3_v3v3(vec, fp, dvec); @@ -1793,8 +1793,8 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc short start_val[2], end_val[2]; short dist; - if ((ED_view3d_project_short_global(ar, gest->stk->points[0].p, start_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) && - (ED_view3d_project_short_global(ar, sk_lastStrokePoint(gest->stk)->p, end_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS)) + if ((ED_view3d_project_short_global(ar, gest->stk->points[0].p, start_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_short_global(ar, sk_lastStrokePoint(gest->stk)->p, end_val, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1])); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 522622ec5c4..e7efd7936c0 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1254,7 +1254,9 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float hit.index = -1; hit.dist = FLT_MAX; - if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, isect_mdef.vec, 0.0, &hit, harmonic_ray_callback, data) != -1) { + if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, isect_mdef.vec, + 0.0, &hit, harmonic_ray_callback, data) != -1) + { len= isect_mdef.labda; isect_mdef.face = mface = mface1 + hit.index; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index b11d640256c..b379ce6e5cf 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -441,8 +441,9 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float 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 */ + /* seems to assume view align ? TODO - look into this, could be an operator option */ + ED_object_base_init_transform(C, base, NULL, rot); + BKE_object_where_is_calc(scene, obedit); obedit->loc[0] += offset[0]; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 5ff4ccbd126..3b26c46a410 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -149,7 +149,8 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn /* ----- Existing Strokes Drawing (3D and Point) ------ */ /* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, + int offsx, int offsy, int winx, int winy) { /* draw point */ if (sflag & GP_STROKE_3DSPACE) { @@ -508,7 +509,8 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int glDepthMask(0); glEnable(GL_DEPTH_TEST); - /* first arg is normally rv3d->dist, but this isn't available here and seems to work quite well without */ + /* first arg is normally rv3d->dist, but this isn't + * available here and seems to work quite well without */ bglPolygonOffset(1.0f, 1.0f); #if 0 glEnable(GL_POLYGON_OFFSET_LINE); @@ -579,7 +581,8 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, /* draw 'onionskins' (frame left + right) */ if (gpl->flag & GP_LAYER_ONIONSKIN) { - /* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/ + /* drawing method - only immediately surrounding (gstep = 0), + * or within a frame range on either side (gstep > 0)*/ if (gpl->gstep) { bGPDframe *gf; float fac; @@ -640,7 +643,8 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) && (gpf->flag & GP_FRAME_PAINT)) { - /* Buffer stroke needs to be drawn with a different linestyle to help differentiate them from normal strokes. */ + /* Buffer stroke needs to be drawn with a different linestyle + * to help differentiate them from normal strokes. */ gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag); } } @@ -724,8 +728,8 @@ void draw_gpencil_2dimage(const bContext *C) } /* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly - * Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes - */ + * Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, + * second time with onlyv2d=0 for screen-aligned strokes */ void draw_gpencil_view2d(const bContext *C, short onlyv2d) { ScrArea *sa = CTX_wm_area(C); @@ -750,9 +754,8 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d) } /* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly - * Note: this gets called twice - first time with only3d=1 to draw 3d-strokes, second time with only3d=0 for screen-aligned strokes - */ - + * Note: this gets called twice - first time with only3d=1 to draw 3d-strokes, + * second time with only3d=0 for screen-aligned strokes */ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) { bGPdata *gpd; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index b6857249abf..c07f0db7114 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -279,7 +279,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] /* method taken from editview.c - mouse_cursor() */ /* TODO, use ED_view3d_project_float_global */ - if (ED_view3d_project_int_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { VECSUB2D(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec); sub_v3_v3v3(out, rvec, dvec); @@ -395,8 +395,10 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure) pts = &gps->points[gps->totpoints - 1]; - /* special case for poly lines: normally, depth is needed only when creating new stroke from buffer, - * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates + /* special case for poly lines: normally, + * depth is needed only when creating new stroke from buffer, + * but poly lines are converting to stroke instantly, + * so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; @@ -798,7 +800,7 @@ static void gp_point_to_xy(ARegion *ar, View2D *v2d, rctf *subrect, bGPDstroke * int xyval[2]; if (gps->flag & GP_STROKE_3DSPACE) { - if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { *r_x = xyval[0]; *r_y = xyval[1]; } @@ -1396,13 +1398,17 @@ static void gpencil_draw_status_indicators(tGPsdata *p) /* print status info */ switch (p->paintmode) { case GP_PAINTMODE_ERASER: - ED_area_headerprint(p->sa, "Grease Pencil Erase Session: Hold and drag LMB or RMB to erase | ESC/Enter to end"); + ED_area_headerprint(p->sa, + "Grease Pencil Erase Session: Hold and drag LMB or RMB to erase |" + " ESC/Enter to end"); break; case GP_PAINTMODE_DRAW_STRAIGHT: - ED_area_headerprint(p->sa, "Grease Pencil Line Session: Hold and drag LMB to draw | ESC/Enter to end"); + ED_area_headerprint(p->sa, "Grease Pencil Line Session: Hold and drag LMB to draw | " + "ESC/Enter to end"); break; case GP_PAINTMODE_DRAW: - ED_area_headerprint(p->sa, "Grease Pencil Freehand Session: Hold and drag LMB to draw | ESC/Enter to end"); + ED_area_headerprint(p->sa, "Grease Pencil Freehand Session: Hold and drag LMB to draw | " + "ESC/Enter to end"); break; default: /* unhandled future cases */ @@ -1678,7 +1684,8 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) //printf("\t\tGP - start stroke\n"); /* we may need to set up paint env again if we're resuming */ - /* XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions */ + /* XXX: watch it with the paintmode! in future, + * it'd be nice to allow changing paint-mode when in sketching-sessions */ /* XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support */ if (gp_session_initdata(C, p)) @@ -1862,7 +1869,10 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH: /* event doesn't need to be handled */ - //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); +#if 0 + printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", + event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); +#endif break; } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index b81e08ed7ef..f71133d3118 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -119,7 +119,7 @@ void ED_view3d_depth_tag_update(struct RegionView3D *rv3d); /* return values for ED_view3d_project_...() */ typedef enum { - V3D_PROJ_RET_SUCCESS = 0, + V3D_PROJ_RET_OK = 0, V3D_PROJ_RET_CLIP_NEAR = 1, /* can't avoid this when in perspective mode, (can't avoid) */ V3D_PROJ_RET_CLIP_BB = 2, /* bounding box clip - RV3D_CLIPPING */ V3D_PROJ_RET_CLIP_WIN = 3, /* outside window bounds */ diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index da87767e492..680d15ec51e 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1059,11 +1059,11 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) /* We can't be sure this has already been set... */ ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_object(vc.ar, eed->v1->co, v1_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { length_1 = len_squared_v2v2(mvalf, v1_co); } - if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_object(vc.ar, eed->v2->co, v2_co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { length_2 = len_squared_v2v2(mvalf, v2_co); } #if 0 @@ -1090,7 +1090,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) float co[2], tdist; BM_face_calc_center_mean(f, cent); - if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_object(vc.ar, cent, co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { tdist = len_squared_v2v2(mvalf, co); if (tdist < best_dist) { /* printf("Best face: %p (%f)\n", f, tdist);*/ diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index e42b95c6013..eaf0c14a0a8 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -390,8 +390,8 @@ static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2]) mul_v3_m4v3(v2_proj, vso->obj->obmat, edge->v2->co); /* we could use ED_view3d_project_float_object here, but for now dont since we dont have the context */ - if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) && - (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS)) + if ((ED_view3d_project_float_global(vso->active_region, v1_proj, v1_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_global(vso->active_region, v2_proj, v2_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { const float dist = dist_to_line_segment_v2(mval, v1_proj, v2_proj); if (dist < min_dist) { @@ -458,8 +458,8 @@ static void vtx_slide_update(VertexSlideOp *vso, wmEvent *event) mul_v3_m4v3(start_vtx_proj, vso->obj->obmat, vso->start_vtx->co); mul_v3_m4v3(edge_other_proj, vso->obj->obmat, other->co); - if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) || - (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS)) + if ((ED_view3d_project_float_global(vso->active_region, edge_other_proj, edge_other_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) || + (ED_view3d_project_float_global(vso->active_region, start_vtx_proj, start_vtx_proj, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK)) { /* not much we can do here */ return; diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 879e20fcf8b..0d78d850e74 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -165,7 +165,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { float mval[2], co_proj[3], no_dummy[3]; int dist_dummy; - if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_object(ar, eve->co, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { if (snapObjectsContext(C, mval, &dist_dummy, co_proj, no_dummy, SNAP_NOT_OBEDIT)) { mul_v3_m4v3(eve->co, obedit->imat, co_proj); } @@ -767,8 +767,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { float co1[3], co2[3]; - if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) && - (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS)) + if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { /* 2D rotate by 90d while adding. * (x, y) = (y, -x) @@ -2772,7 +2772,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) screen_vert_coords = sco = MEM_mallocN(bm->totvert * sizeof(float) * 2, __func__); BM_ITER_MESH_INDEX (bv, &iter, bm, BM_VERTS_OF_MESH, i) { - if (ED_view3d_project_float_object(ar, bv->co, *sco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_object(ar, bv->co, *sco, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { copy_v2_fl(*sco, FLT_MAX); /* set error value */ } BM_elem_index_set(bv, i); /* set_ok */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 42d82fff38e..f265113708a 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1237,7 +1237,7 @@ int ED_mesh_pick_face_vert(bContext *C, Mesh *me, Object *ob, const int mval[2], const int v_idx = me->mloop[mp->loopstart + fidx].v; dm->getVertCo(dm, v_idx, co); mul_m4_v3(ob->obmat, co); - if (ED_view3d_project_float_global(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_global(ar, co, sco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { len = len_squared_v2v2(mval_f, sco); if (len < len_best) { len_best = len; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index dc490c94b38..1010c0efce4 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -411,7 +411,7 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2 /* used to calculate here but all callers have the screen_co already, so pass as arg */ #if 0 if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK) { return 0; } @@ -448,7 +448,7 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float * int screen_co[2]; /* TODO, should this check V3D_PROJ_TEST_CLIP_BB too? */ - if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK) { return 0; } @@ -473,7 +473,7 @@ static int key_inside_rect(PEData *data, const float co[3]) { int screen_co[2]; - if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(data->vc.ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) != V3D_PROJ_RET_OK) { return 0; } @@ -1665,7 +1665,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short LOOP_KEYS { copy_v3_v3(co, key->co); mul_m4_v3(mat, co); - if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) && + if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) && key_test_depth(&data, co, screen_co)) { @@ -1685,7 +1685,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short copy_v3_v3(co, key->co); mul_m4_v3(mat, co); - if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) && + if ((ED_view3d_project_int_global(ar, co, screen_co, V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) && BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], IS_CLIPPED) && key_test_depth(&data, co, screen_co)) { @@ -2797,7 +2797,7 @@ static void brush_cut(PEData *data, int pa_index) if (edit->points[pa_index].flag & PEP_HIDE) return; - if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) + if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) return; rad2= data->rad * data->rad; @@ -2822,7 +2822,7 @@ static void brush_cut(PEData *data, int pa_index) /* calculate path time closest to root that was inside the circle */ for (k=1, key++; k<=keys; k++, key++) { - if ((ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) || + if ((ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) || key_test_depth(data, key->co, screen_co) == 0) { x0 = (float)screen_co[0]; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 6120229190d..e3d714b1917 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -322,8 +322,8 @@ static int project_brush_radius(ViewContext *vc, add_v3_v3v3(offset, location, ortho); /* project the center of the brush, and the tangent point to the view onto the screen */ - if ((ED_view3d_project_float_global(vc->ar, location, p1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) && - (ED_view3d_project_float_global(vc->ar, offset, p2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS)) + if ((ED_view3d_project_float_global(vc->ar, location, p1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && + (ED_view3d_project_float_global(vc->ar, offset, p2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) { /* the distance between these points is the size of the projected brush in pixels */ return len_v2v2(p1, p2); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 5a79368ac49..6b3017b8638 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -848,7 +848,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_n { float vertco[2]; - if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_global(vc->ar, vert_nor, vertco, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { float delta[2]; float dist_squared; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 84a69b811ca..1b008c27fc0 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -787,7 +787,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa (vos->flag & V3D_CACHE_TEXT_GLOBALSPACE) ? rv3d->persmat : rv3d->persmatob, (vos->flag & V3D_CACHE_TEXT_LOCALCLIP) != 0, vos->vec, vos->sco, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { tot++; } @@ -1885,7 +1885,7 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo if (bp->hide == 0) { int screen_co[2]; if (ED_view3d_project_int_object(vc->ar, dl ? co : bp->vec, screen_co, - V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, bp, screen_co[0], screen_co[1]); } @@ -1995,7 +1995,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, const flo V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN; int screen_co[2]; - if (ED_view3d_project_int_object(data->vc.ar, co, screen_co, flag) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_object(data->vc.ar, co, screen_co, flag) != V3D_PROJ_RET_OK) { return; } @@ -2067,10 +2067,10 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN : V3D_PROJ_TEST_NOP; - if (ED_view3d_project_int_object(data->vc.ar, v0co, screen_co_a, flag) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_object(data->vc.ar, v0co, screen_co_a, flag) != V3D_PROJ_RET_OK) { return; } - if (ED_view3d_project_int_object(data->vc.ar, v1co, screen_co_b, flag) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_object(data->vc.ar, v1co, screen_co_b, flag) != V3D_PROJ_RET_OK) { return; } @@ -2128,7 +2128,7 @@ static void mesh_foreachScreenFace__mapFunc(void *userData, int index, const flo if (efa && !BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { int screen_co[2]; if (ED_view3d_project_int_object(data->vc.ar, cent, screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { data->func(data->userData, efa, screen_co[0], screen_co[1], index); } @@ -2178,24 +2178,24 @@ void nurbs_foreachScreenVert( if (cu->drawflag & CU_HIDE_HANDLES) { if (ED_view3d_project_int_object(vc->ar, bezt->vec[1], screen_co, - V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, NULL, bezt, 1, screen_co[0], screen_co[1]); } } else { if (ED_view3d_project_int_object(vc->ar, bezt->vec[0], screen_co, - V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, NULL, bezt, 0, screen_co[0], screen_co[1]); } if (ED_view3d_project_int_object(vc->ar, bezt->vec[1], screen_co, - V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, NULL, bezt, 1, screen_co[0], screen_co[1]); } if (ED_view3d_project_int_object(vc->ar, bezt->vec[2], screen_co, - V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, NULL, bezt, 2, screen_co[0], screen_co[1]); } @@ -2210,7 +2210,7 @@ void nurbs_foreachScreenVert( if (bp->hide == 0) { int screen_co[2]; if (ED_view3d_project_int_object(vc->ar, bp->vec, screen_co, - V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, nu, bp, NULL, -1, screen_co[0], screen_co[1]); } @@ -2232,7 +2232,7 @@ void mball_foreachScreenElem( for (ml = mb->editelems->first; ml; ml = ml->next) { int screen_co[2]; if (ED_view3d_project_int_object(vc->ar, &ml->x, screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { func(userData, ml, screen_co[0], screen_co[1]); } @@ -2255,7 +2255,7 @@ void armature_foreachScreenBone( /* project head location to screenspace */ if (ED_view3d_project_int_object(vc->ar, ebone->head, screen_co_a, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { points_proj_tot++; } @@ -2266,7 +2266,7 @@ void armature_foreachScreenBone( /* project tail location to screenspace */ if (ED_view3d_project_int_object(vc->ar, ebone->tail, screen_co_b, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { points_proj_tot++; } @@ -2302,7 +2302,7 @@ void pose_foreachScreenBone( /* project head location to screenspace */ if (ED_view3d_project_int_object(vc->ar, pchan->pose_head, screen_co_a, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { points_proj_tot++; } @@ -2313,7 +2313,7 @@ void pose_foreachScreenBone( /* project tail location to screenspace */ if (ED_view3d_project_int_object(vc->ar, pchan->pose_tail, screen_co_b, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { points_proj_tot++; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 00d35a5d2e1..c6bcbfbf50d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -558,7 +558,7 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) int co[2]; /* we don't want the clipping for cursor */ - if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(ar, give_cursor(scene, v3d), co, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { setlinestyle(0); cpack(0xFF); circ((float)co[0], (float)co[1], 10.0); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 735f7b5ea4a..504f746637e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3534,7 +3534,7 @@ static int view3d_cursor3d_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent * /* flip = */ initgrabz(rv3d, fp[0], fp[1], fp[2]); } - if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { short depth_used = FALSE; if (U.uiflag & USER_ZBUF_CURSOR) { /* maybe this should be accessed some other way */ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 53f2c2e9f5e..5f0bb180711 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -120,7 +120,7 @@ int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const int m initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); - if (ret == V3D_PROJ_RET_SUCCESS) { + if (ret == V3D_PROJ_RET_OK) { const float mval_f[2] = {(float)(mval_cpy[0] - mval[0]), (float)(mval_cpy[1] - mval[1])}; ED_view3d_win_to_delta(vc->ar, mval_f, dvec); @@ -1506,7 +1506,8 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese } } } - else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend, deselect, toggle) ) { /* then bone is found */ + else if (ED_do_pose_selectbuffer(scene, basact, buffer, hits, extend, deselect, toggle) ) { + /* then bone is found */ /* we make the armature selected: * not-selected active object in posemode won't work well for tools */ @@ -2639,7 +2640,7 @@ static int object_circle_select(ViewContext *vc, int select, const int mval[2], if (((base->flag & SELECT) == 0) && BASE_SELECTABLE(vc->v3d, base)) { float screen_co[2]; if (ED_view3d_project_float_global(vc->ar, base->object->obmat[3], screen_co, - V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_SUCCESS) + V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN) == V3D_PROJ_RET_OK) { if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { ED_base_object_select(base, select); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index f138a95b0ef..84b1505c900 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -863,7 +863,7 @@ eV3DProjStatus ED_view3d_project_base(struct ARegion *ar, struct Base *base) eV3DProjStatus ret = ED_view3d_project_short_global(ar, base->object->obmat[3], &base->sx, V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_WIN); - if (ret != V3D_PROJ_RET_SUCCESS) { + if (ret != V3D_PROJ_RET_OK) { base->sx = IS_CLIPPED; base->sy = 0; } @@ -949,7 +949,7 @@ static eV3DProjStatus ed_view3d_project__internal(ARegion *ar, return V3D_PROJ_RET_CLIP_NEAR; } - return V3D_PROJ_RET_SUCCESS; + return V3D_PROJ_RET_OK; } eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], const int is_local, @@ -957,7 +957,7 @@ eV3DProjStatus ED_view3d_project_short_ex(ARegion *ar, float perspmat[4][4], con { float tvec[2]; eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); - if (ret == V3D_PROJ_RET_SUCCESS) { + if (ret == V3D_PROJ_RET_OK) { if ((tvec[0] > -32700.0 && tvec[0] < 32700.0f) && (tvec[1] > -32700.0 && tvec[1] < 32700.0f)) { @@ -976,7 +976,7 @@ eV3DProjStatus ED_view3d_project_int_ex(ARegion *ar, float perspmat[4][4], const { float tvec[2]; eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); - if (ret == V3D_PROJ_RET_SUCCESS) { + if (ret == V3D_PROJ_RET_OK) { if ((tvec[0] > -2140000000.0 && tvec[0] < 2140000000.0f) && (tvec[1] > -2140000000.0 && tvec[1] < 2140000000.0f)) { @@ -995,7 +995,7 @@ eV3DProjStatus ED_view3d_project_float_ex(ARegion *ar, float perspmat[4][4], con { float tvec[2]; eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); - if (ret == V3D_PROJ_RET_SUCCESS) { + if (ret == V3D_PROJ_RET_OK) { if (finite(tvec[0]) && finite(tvec[1])) { diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index be568fcb9d8..be4e580de01 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -230,7 +230,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) { if (t->spacetype == SPACE_VIEW3D) { if (t->ar->regiontype == RGN_TYPE_WINDOW) { - if (ED_view3d_project_int_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { adr[0] = (int)2140000000.0f; /* this is what was done in 2.64, perhaps we can be smarter? */ adr[1] = (int)2140000000.0f; } @@ -355,7 +355,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) case SPACE_VIEW3D: { if (t->ar->regiontype == RGN_TYPE_WINDOW) { - if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_global(t->ar, vec, adr, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { /* XXX, 2.64 and prior did this, weak! */ adr[0] = t->ar->winx / 2.0f; adr[1] = t->ar->winy / 2.0f; @@ -4853,7 +4853,7 @@ static void calcNonProportionalEdgeSlide(TransInfo *t, SlideData *sld, const flo sv->edge_len = len_v3v3(dw_p, up_p); mul_v3_m4v3(v_proj, t->obedit->obmat, sv->v->co); - if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_global(t->ar, v_proj, v_proj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { dist = len_squared_v2v2(mval, v_proj); if (dist < min_dist) { min_dist = dist; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 2f2b31de89d..94b8abb8850 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -317,7 +317,7 @@ void applyProject(TransInfo *t) copy_v3_v3(iloc, td->ob->obmat[3]); } - if (ED_view3d_project_float_global(t->ar, iloc, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_float_global(t->ar, iloc, mval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) { // if (t->flag & (T_EDIT|T_POSE)) { // mul_m4_v3(imat, loc); @@ -603,7 +603,7 @@ int updateSelectedSnapPoint(TransInfo *t) int dx, dy; int dist; - if (ED_view3d_project_int_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(t->ar, p->co, screen_loc, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { continue; } @@ -1236,7 +1236,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh new_depth = len_v3v3(location, ray_start); - if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); } else { @@ -1297,7 +1297,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4], new_depth = len_v3v3(location, ray_start); - if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_SUCCESS) { + if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); } else { -- cgit v1.2.3 From e3ab85a3f589fd6d649caf8fbe71ea70e0a217de Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 7 Oct 2012 14:15:50 +0000 Subject: Revert fix for #31806, needs a better solution, can hang compiling some shaders. --- intern/cycles/render/svm.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index da287a10199..844ce01569f 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -274,17 +274,6 @@ void SVMCompiler::stack_clear_users(ShaderNode *node, set& done) foreach(ShaderInput *in, output->links) in->stack_offset = SVM_STACK_INVALID; - - /* unmark any nodes that have no more valid outputs, see [#31806] */ - if(done.find(output->parent) != done.end()) { - all_done = true; - foreach(ShaderOutput *pout, output->parent->outputs) - if(pout->stack_offset != SVM_STACK_INVALID) - all_done = false; - - if(all_done) - done.erase(output->parent); - } } } } -- cgit v1.2.3 From c80c4c896aedae7c711d10e6f133d3bdca460de3 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Sun, 7 Oct 2012 15:39:47 +0000 Subject: Fix file descriptor leak in BLI_file_ungzip_to_mem and small memleak in wm_window_title. --- source/blender/blenlib/intern/fileops.c | 2 ++ source/blender/windowmanager/intern/wm_window.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 1df904f617a..883cdfde426 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -140,6 +140,8 @@ char *BLI_file_ungzip_to_mem(const char *from_file, int *size_r) } else break; } + + gzclose(gzfile); if (size == 0) { MEM_freeN(mem); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index d0bed4e5965..44827302d7d 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -300,11 +300,9 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) void wm_window_title(wmWindowManager *wm, wmWindow *win) { - /* handle the 'temp' window, only set title when not set before */ if (win->screen && win->screen->temp) { - char *title = GHOST_GetTitle(win->ghostwin); - if (title == NULL || title[0] == 0) - GHOST_SetTitle(win->ghostwin, "Blender"); + /* nothing to do for 'temp' windows, + * because WM_window_open_temp always sets window title */ } else { -- cgit v1.2.3 From 9fcb7cd520dd5b1befcff9115a707a2b4cfa718a Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 7 Oct 2012 19:10:03 +0000 Subject: BGE: When applying movement to an object with the Character physics type, use the btKinematicCharacterController's setWalkDirection() instead of moving the physics object ourselves. This reduces issues with tunneling (the character going through other objects). --- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 14 +++++++++----- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 81bf66d9536..240bda811f0 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -895,18 +895,22 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc return; } - // btRigidBody* body = GetRigidBody(); // not used anymore - btVector3 dloc(dlocX,dlocY,dlocZ); btTransform xform = m_object->getWorldTransform(); if (local) - { dloc = xform.getBasis()*dloc; + + if (m_characterController) + { + m_characterController->setWalkDirection(dloc/GetPhysicsEnvironment()->getNumTimeSubSteps()); } + else + { - xform.setOrigin(xform.getOrigin() + dloc); - SetCenterOfMassTransform(xform); + xform.setOrigin(xform.getOrigin() + dloc); + SetCenterOfMassTransform(xform); + } } } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index c499a1ef75c..59e40a6f91a 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -115,6 +115,11 @@ protected: virtual void setLinearAirDamping(float damping); virtual void setUseEpa(bool epa); + int getNumTimeSubSteps() + { + return m_numTimeSubSteps; + } + virtual void beginFrame(); virtual void endFrame() {} /// Perform an integration step of duration 'timeStep'. -- cgit v1.2.3 From 7b37e78c91d2a7a9c95c7a0f5bbe74fbca18c07c Mon Sep 17 00:00:00 2001 From: Dan Eicher Date: Sun, 7 Oct 2012 20:07:30 +0000 Subject: Grease Pencil py-api * new/remove for GPencil frames/strokes/ * add/pop for points * clear for frame/layer & grease_pencil * copy for frame + fix for free_gpencil_frames() not clearing the active frame --- source/blender/blenkernel/intern/gpencil.c | 1 + source/blender/makesrna/intern/rna_gpencil.c | 259 ++++++++++++++++++++++++-- source/blender/makesrna/intern/rna_main_api.c | 29 +++ 3 files changed, 271 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 84871375788..76b00ffdb1c 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -87,6 +87,7 @@ void free_gpencil_frames(bGPDlayer *gpl) free_gpencil_strokes(gpf); BLI_freelinkN(&gpl->frames, gpf); } + gpl->actframe = NULL; } /* Free all of the gp-layers for a viewport (list should be &gpd->layers or so) */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index bf7f4984ea1..ae1c7fd2d5b 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -111,6 +111,108 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); } +static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count) +{ + if (stroke->points == NULL) + stroke->points = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points"); + else + stroke->points = MEM_reallocN(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count)); + + stroke->totpoints += count; +} + +static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, int index) +{ + bGPDspoint *pt_tmp = stroke->points; + + /* python style negative indexing */ + if (index < 0) { + index += stroke->totpoints; + } + + if (stroke->totpoints <= index || index < 0) { + BKE_report(reports, RPT_ERROR, "GPencilStrokePoints.pop: index out of range"); + return; + } + + stroke->totpoints--; + + stroke->points = MEM_callocN(sizeof(bGPDspoint) * stroke->totpoints, "gp_stroke_points"); + + if (index > 0) + memcpy(stroke->points, pt_tmp, sizeof(bGPDspoint) * index); + + if (index < stroke->totpoints) + memcpy(&stroke->points[index], &pt_tmp[index + 1], sizeof(bGPDspoint) * (stroke->totpoints - index)); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + +static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame) +{ + bGPDstroke *stroke = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); + + BLI_addtail(&frame->strokes, stroke); + + return stroke; +} + +static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, bGPDstroke *stroke) +{ + if (BLI_findindex(&frame->strokes, stroke) == -1) { + BKE_reportf(reports, RPT_ERROR, "Stroke not found in grease pencil frame"); + return; + } + + BLI_freelinkN(&frame->strokes, stroke); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + +static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, int frame_number) +{ + if (BKE_gpencil_layer_find_frame(layer, frame_number)) { + BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number"); + return NULL; + } + + bGPDframe *frame = gpencil_frame_addnew(layer, frame_number); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + + return frame; +} + +static void rna_GPencil_frame_remove(bGPDlayer *layer, ReportList *reports, bGPDframe *frame) +{ + if (BLI_findindex(&layer->frames, frame) == -1) { + BKE_reportf(reports, RPT_ERROR, "Frame not found in grease pencil layer"); + return; + } + + gpencil_layer_delframe(layer, frame); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); +} + +static bGPDframe *rna_GPencil_frame_copy(bGPDlayer *layer, bGPDframe *src) +{ + bGPDframe *frame = gpencil_frame_duplicate(src); + + while (BKE_gpencil_layer_find_frame(layer, frame->framenum)) { + frame->framenum++; + } + + BLI_addtail(&layer->frames, frame); + + WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); + + return frame; +} + static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int setactive) { bGPDlayer *gl = gpencil_layer_addnew(gpd, name, setactive); @@ -122,14 +224,7 @@ static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int seta static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlayer *layer) { - bGPDlayer *gl; - - for (gl = gpd->layers.first; gl; gl = gl->next) { - if (gl == layer) - break; - } - - if (gl == NULL) { + if (BLI_findindex(&gpd->layers, layer) == -1) { BKE_reportf(reports, RPT_ERROR, "Layer not found in grease pencil data"); return; } @@ -139,6 +234,27 @@ static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlaye WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } +static void rna_GPencil_frame_clear(bGPDframe *frame) +{ + free_gpencil_strokes(frame); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + +static void rna_GPencil_layer_clear(bGPDlayer *layer) +{ + free_gpencil_frames(layer); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + +static void rna_GPencil_clear(bGPdata *gpd) +{ + free_gpencil_layers(&gpd->layers); + + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); +} + #else static void rna_def_gpencil_stroke_point(BlenderRNA *brna) @@ -154,19 +270,49 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "x"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Coordinates", ""); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pressure"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it"); - RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); +} + +static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + /* PropertyRNA *parm; */ + + RNA_def_property_srna(cprop, "GPencilStrokePoints"); + srna = RNA_def_struct(brna, "GPencilStrokePoints", NULL); + RNA_def_struct_sdna(srna, "bGPDstroke"); + RNA_def_struct_ui_text(srna, "Grease Pencil Stroke Points", "Collection of grease pencil stroke points"); + + func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add"); + RNA_def_function_ui_description(func, "Add a new grease pencil stroke point"); + RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the stroke", 1, INT_MAX); + + func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop"); + RNA_def_function_ui_description(func, "Remove a grease pencil stroke point"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_int(func, "index", -1, INT_MIN, INT_MAX, "Index", "point index", INT_MIN, INT_MAX); } static void rna_def_gpencil_stroke(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + static EnumPropertyItem stroke_draw_mode_items[] = { + {0, "SCREEN", 0, "Screen", "Stroke is in screen-space"}, + {GP_STROKE_3DSPACE, "3DSPACE", 0, "3d Space", "Stroke is in 3d-space"}, + {GP_STROKE_2DSPACE, "2DSPACE", 0, "2d Space", "stroke is in 2d-space"}, + {GP_STROKE_2DIMAGE, "2DIMAGE", 0, "2d Image", "Stroke is in 2d-space (but with special 'image' scaling)"}, + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "GPencilStroke", NULL); RNA_def_struct_sdna(srna, "bGPDstroke"); @@ -177,15 +323,45 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "points", "totpoints"); RNA_def_property_struct_type(prop, "GPencilStrokePoint"); RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points"); - - /* Flags - Readonly type-info really... */ - /* TODO... */ + rna_def_gpencil_stroke_points_api(brna, prop); + + prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, stroke_draw_mode_items); + RNA_def_property_ui_text(prop, "Draw Mode", ""); + RNA_def_property_update(prop, 0, "rna_GPencil_update"); +} + +static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "GPencilStrokes"); + srna = RNA_def_struct(brna, "GPencilStrokes", NULL); + RNA_def_struct_sdna(srna, "bGPDframe"); + RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames"); + + func = RNA_def_function(srna, "new", "rna_GPencil_stroke_new"); + RNA_def_function_ui_description(func, "Add a new grease pencil frame"); + parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "", "The newly created stroke"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_GPencil_stroke_remove"); + RNA_def_function_ui_description(func, "Remove a grease pencil frame"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "stroke", "GPencilStroke", "Stroke", "The stroke to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); } static void rna_def_gpencil_frame(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + FunctionRNA *func; srna = RNA_def_struct(brna, "GPencilFrame", NULL); RNA_def_struct_sdna(srna, "bGPDframe"); @@ -196,7 +372,8 @@ static void rna_def_gpencil_frame(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "strokes", NULL); RNA_def_property_struct_type(prop, "GPencilStroke"); RNA_def_property_ui_text(prop, "Strokes", "Freehand curves defining the sketch on this frame"); - + rna_def_gpencil_strokes_api(brna, prop); + /* Frame Number */ prop = RNA_def_property(srna, "frame_number", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "framenum"); @@ -211,12 +388,51 @@ static void rna_def_gpencil_frame(BlenderRNA *brna) prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_SELECT); RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in the DopeSheet"); + + func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear"); + RNA_def_function_ui_description(func, "Remove all the grease pencil frame data"); +} + +static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "GPencilFrames"); + srna = RNA_def_struct(brna, "GPencilFrames", NULL); + RNA_def_struct_sdna(srna, "bGPDlayer"); + RNA_def_struct_ui_text(srna, "Grease Pencil Frames", "Collection of grease pencil frames"); + + func = RNA_def_function(srna, "new", "rna_GPencil_frame_new"); + RNA_def_function_ui_description(func, "Add a new grease pencil frame"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_int(func, "frame_number", 1, MINFRAME, MAXFRAME, "Frame Number", "The frame on which this sketch appears", MINFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "frame", "GPencilFrame", "", "The newly created frame"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_GPencil_frame_remove"); + RNA_def_function_ui_description(func, "Remove a grease pencil frame"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "frame", "GPencilFrame", "Frame", "The frame to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + + func = RNA_def_function(srna, "copy", "rna_GPencil_frame_copy"); + RNA_def_function_ui_description(func, "Copy a grease pencil frame"); + parm = RNA_def_pointer(func, "source", "GPencilFrame", "Source", "The source frame"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "copy", "GPencilFrame", "", "The newly copied frame"); + RNA_def_function_return(func, parm); } static void rna_def_gpencil_layer(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + FunctionRNA *func; srna = RNA_def_struct(brna, "GPencilLayer", NULL); RNA_def_struct_sdna(srna, "bGPDlayer"); @@ -234,7 +450,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "frames", NULL); RNA_def_property_struct_type(prop, "GPencilFrame"); RNA_def_property_ui_text(prop, "Frames", "Sketches for this layer on different frames"); - + rna_def_gpencil_frames_api(brna, prop); + /* Active Frame */ prop = RNA_def_property(srna, "active_frame", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "actframe"); @@ -317,9 +534,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY); RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update"); + + func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear"); + RNA_def_function_ui_description(func, "Remove all the grease pencil layer data"); } -static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop) +static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop) { StructRNA *srna; PropertyRNA *prop; @@ -357,7 +577,8 @@ static void rna_def_gpencil_data(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - + FunctionRNA *func; + static EnumPropertyItem draw_mode_items[] = { {GP_DATA_VIEWALIGN, "CURSOR", 0, "Cursor", "Draw stroke at the 3D cursor"}, {0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weird, GP_DATA_VIEWALIGN is inverted */ @@ -376,7 +597,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "layers", NULL); RNA_def_property_struct_type(prop, "GPencilLayer"); RNA_def_property_ui_text(prop, "Layers", ""); - rna_def_gpencil_layers(brna, prop); + rna_def_gpencil_layers_api(brna, prop); /* Flags */ prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); @@ -390,6 +611,8 @@ static void rna_def_gpencil_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping"); RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL); + func = RNA_def_function(srna, "clear", "rna_GPencil_clear"); + RNA_def_function_ui_description(func, "Remove all the grease pencil data"); } /* --- */ diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index f5c59aa583a..cd9b3965713 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -71,6 +71,7 @@ #include "BKE_speaker.h" #include "BKE_movieclip.h" #include "BKE_mask.h" +#include "BKE_gpencil.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" @@ -92,6 +93,7 @@ #include "DNA_node_types.h" #include "DNA_movieclip_types.h" #include "DNA_mask_types.h" +#include "DNA_gpencil_types.h" #include "ED_screen.h" @@ -561,6 +563,19 @@ static void rna_Main_masks_remove(Main *bmain, Mask *mask) /* XXX python now has invalid pointer? */ } +static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, bGPdata *gpd) +{ + if (ID_REAL_USERS(gpd) <= 0) { + BKE_gpencil_free(gpd); + BKE_libblock_free(&bmain->gpencil, gpd); + } + else + BKE_reportf(reports, RPT_ERROR, "Grease Pencil \"%s\" must have zero users to be removed, found %d", + gpd->id.name + 2, ID_REAL_USERS(gpd)); + + /* XXX python now has invalid pointer? */ +} + /* tag functions, all the same */ static void rna_Main_cameras_tag(Main *bmain, int value) { tag_main_lb(&bmain->camera, value); } static void rna_Main_scenes_tag(Main *bmain, int value) { tag_main_lb(&bmain->scene, value); } @@ -1509,6 +1524,20 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop) parm = RNA_def_boolean(func, "value", 0, "Value", ""); RNA_def_property_flag(parm, PROP_REQUIRED); + func = RNA_def_function(srna, "new", "gpencil_data_addnew"); + RNA_def_function_flag(func, FUNC_NO_SELF); + parm = RNA_def_string(func, "name", "GreasePencil", 0, "", "New name for the datablock"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "New grease pencil datablock"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_grease_pencil_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a grease pencil instance from the current blendfile"); + parm = RNA_def_pointer(func, "grease_pencil", "GreasePencil", "", "Grease Pencil to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_funcs(prop, "rna_Main_gpencil_is_updated_get", NULL); -- cgit v1.2.3 From 2e81400b77a0b8dad99a11ed269ce81b0ea5023e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Oct 2012 23:58:57 +0000 Subject: minor edit to type checking macro to avoid clangs static checker tagging the var as possibly NULL. --- source/blender/blenlib/BLI_utildefines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index ebb40c18c21..5321de4393b 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -130,7 +130,7 @@ /* can be used in simple macros */ #define CHECK_TYPE_INLINE(val, type) \ - ((void)(((type *)0) == (val))) + ((void)(((type *)0) != (val))) #ifndef SWAP # define SWAP(type, a, b) { \ -- cgit v1.2.3 From ebb8d3996cfe7936d4a9a9ce85223e4d42646e31 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 00:51:55 +0000 Subject: code cleanup: replace VECADDISFAC with math function. --- source/blender/render/intern/source/shadeinput.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index ff543b8ce06..36e9f4cb785 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -87,12 +87,6 @@ extern struct Render R; * */ -#define VECADDISFAC(v1,v3,fac) { \ - *(v1 + 0) += *(v3 + 0) * (fac); \ - *(v1 + 1) += *(v3 + 1) * (fac); \ - *(v1 + 2) += *(v3 + 2) * (fac); \ -} (void)0 - /* initialize material variables in shadeinput, * doing inverse gamma correction where applicable */ void shade_input_init_material(ShadeInput *shi) @@ -121,13 +115,13 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) shi->depth--; /* a couple of passes */ - VECADDISFAC(shr->combined, shr_t.combined, fac); + madd_v3_v3fl(shr->combined, shr_t.combined, fac); if (shi->passflag & SCE_PASS_SPEC) - VECADDISFAC(shr->spec, shr_t.spec, fac); + madd_v3_v3fl(shr->spec, shr_t.spec, fac); if (shi->passflag & SCE_PASS_DIFFUSE) - VECADDISFAC(shr->diff, shr_t.diff, fac); + madd_v3_v3fl(shr->diff, shr_t.diff, fac); if (shi->passflag & SCE_PASS_SHADOW) - VECADDISFAC(shr->shad, shr_t.shad, fac); + madd_v3_v3fl(shr->shad, shr_t.shad, fac); negate_v3(shi->vn); negate_v3(shi->facenor); -- cgit v1.2.3 From 5807726ca749af5b1a7fc4387febc473349b2789 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 01:05:37 +0000 Subject: quiet invalid warning in ffmpeg_log_callback with -Wmissing-format-attribute. --- source/blender/imbuf/intern/util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 833671e3f2f..2d04b7c7413 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -223,6 +223,10 @@ static int isqtime(const char *name) #ifdef WITH_FFMPEG +/* BLI_vsnprintf in ffmpeg_log_callback() causes invalid warning */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-format-attribute" + static char ffmpeg_last_error[1024]; static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg) @@ -240,6 +244,8 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_lis } } +#pragma GCC diagnostic pop + void IMB_ffmpeg_init(void) { av_register_all(); -- cgit v1.2.3 From 99dd59f08c4825fb1f97ea7d94b644047466021a Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 8 Oct 2012 01:25:21 +0000 Subject: BGE: Disable depth testing when drawing the overhead profile information in the Blenderplayer. This keeps the text from being blocked by geometry in the scene. --- source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 9cd6715f3d2..4bf81bf543e 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -359,7 +359,8 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, glGetIntegerv(GL_LIGHTING, (GLint*)&light); glDisable(GL_LIGHTING); - + glDisable(GL_DEPTH_TEST); + // Set up viewing settings glMatrixMode(GL_PROJECTION); glPushMatrix(); -- cgit v1.2.3 From 2fd27753506013d602cbafe9fbb99649ba01c26c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 02:20:47 +0000 Subject: fix for crash in the sequencer if the video file fails to load (missing NULL check on imbuf), all other uses of sequencer_imbuf_assign_spaces() check for NULL or assume IMB_allocImBuf() succeeds. --- source/blender/blenkernel/intern/sequencer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 90c3347a1df..49ed7f80be3 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1965,13 +1965,16 @@ static ImBuf *copy_from_ibuf_still(SeqRenderData context, Sequence *seq, float n static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, ImBuf *ibuf) { + /* warning: ibuf may be NULL if the video fails to load */ if (nr == 0 || nr == seq->len - 1) { /* we have to store a copy, since the passed ibuf * could be preprocessed afterwards (thereby silently * changing the cached image... */ ibuf = IMB_dupImBuf(ibuf); - sequencer_imbuf_assign_spaces(context.scene, ibuf); + if (ibuf) { + sequencer_imbuf_assign_spaces(context.scene, ibuf); + } if (nr == 0) { BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); -- cgit v1.2.3 From aa1e50be946dfeb17f9bb98b242bdbf6775f1ab6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 02:51:42 +0000 Subject: add option to build without blenders default avi codec. --- CMakeLists.txt | 2 ++ SConstruct | 1 + build_files/cmake/config/blender_lite.cmake | 1 + source/blender/CMakeLists.txt | 5 ++++- source/blender/blenkernel/CMakeLists.txt | 8 +++++++- source/blender/blenkernel/intern/writeavi.c | 22 +++++++++++++++------- source/blender/imbuf/CMakeLists.txt | 8 +++++++- source/blender/imbuf/intern/IMB_anim.h | 4 +++- source/blender/imbuf/intern/anim_movie.c | 22 ++++++++++++++++++++-- source/blender/imbuf/intern/indexer.c | 27 ++++++++++++++++++++++----- source/blender/imbuf/intern/util.c | 5 +++++ 11 files changed, 87 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f0ef41fe59..9ec75e9c782 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,6 +206,7 @@ option(WITH_IMAGE_REDCODE "Enable RedCode Image Support" OFF) option(WITH_IMAGE_FRAMESERVER "Enable image FrameServer Support for rendering" ON) # Audio/Video format support +option(WITH_CODEC_AVI "Enable Blenders own AVI file support (raw/jpeg)" ON) option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF) option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF) @@ -2123,6 +2124,7 @@ if(FIRST_RUN) info_cfg_option(WITH_OPENAL) info_cfg_option(WITH_SDL) info_cfg_option(WITH_JACK) + info_cfg_option(WITH_CODEC_AVI) info_cfg_option(WITH_CODEC_FFMPEG) info_cfg_option(WITH_CODEC_SNDFILE) diff --git a/SConstruct b/SConstruct index 7676b44f759..7b92a0cb25c 100644 --- a/SConstruct +++ b/SConstruct @@ -366,6 +366,7 @@ else: # TODO, make optional env['CPPFLAGS'].append('-DWITH_AUDASPACE') +env['CPPFLAGS'].append('-DWITH_AVI') # lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir B.root_build_dir = env['BF_BUILDDIR'] diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake index ae07743191b..de3cfd166b7 100644 --- a/build_files/cmake/config/blender_lite.cmake +++ b/build_files/cmake/config/blender_lite.cmake @@ -10,6 +10,7 @@ set(WITH_SYSTEM_GLEW ON CACHE FORCE BOOL) set(WITH_BUILDINFO OFF CACHE FORCE BOOL) set(WITH_BULLET OFF CACHE FORCE BOOL) +set(WITH_CODEC_AVI OFF CACHE FORCE BOOL) set(WITH_CODEC_FFMPEG OFF CACHE FORCE BOOL) set(WITH_CODEC_SNDFILE OFF CACHE FORCE BOOL) set(WITH_CYCLES OFF CACHE FORCE BOOL) diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index 92785804b01..ae3f3dce396 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -101,7 +101,6 @@ add_subdirectory(blenloader) add_subdirectory(ikplugin) add_subdirectory(gpu) add_subdirectory(imbuf) -add_subdirectory(avi) add_subdirectory(nodes) add_subdirectory(modifiers) add_subdirectory(makesdna) @@ -124,6 +123,10 @@ if(WITH_IMAGE_CINEON) add_subdirectory(imbuf/intern/cineon) endif() +if(WITH_CODEC_AVI) + add_subdirectory(avi) +endif() + if(WITH_CODEC_QUICKTIME) add_subdirectory(quicktime) endif() diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index efdb80433c6..2a1ff49881f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -25,7 +25,6 @@ set(INC . - ../avi ../blenfont ../blenlib ../blenloader @@ -292,6 +291,13 @@ if(WITH_IMAGE_HDR) add_definitions(-DWITH_HDR) endif() +if(WITH_CODEC_AVI) + list(APPEND INC + ../avi + ) + add_definitions(-DWITH_AVI) +endif() + if(WITH_CODEC_QUICKTIME) list(APPEND INC ../quicktime diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index dab44b5463c..9f29cb8b137 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -47,7 +47,11 @@ #include "BKE_report.h" #include "BKE_writeavi.h" -#include "AVI_avi.h" + +/* ********************** general blender movie support ***************************** */ + +#ifdef WITH_AVI +# include "AVI_avi.h" /* callbacks */ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports); @@ -55,30 +59,31 @@ static void end_avi(void); static int append_avi(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports); static void filepath_avi(char *string, RenderData *rd); - -/* ********************** general blender movie support ***************************** */ +#endif /* WITH_AVI */ #ifdef WITH_QUICKTIME -#include "quicktime_export.h" +# include "quicktime_export.h" #endif #ifdef WITH_FFMPEG -#include "BKE_writeffmpeg.h" +# include "BKE_writeffmpeg.h" #endif #include "BKE_writeframeserver.h" bMovieHandle *BKE_movie_handle_get(const char imtype) { - static bMovieHandle mh; + static bMovieHandle mh = {0}; /* set the default handle, as builtin */ +#ifdef WITH_AVI mh.start_movie = start_avi; mh.append_movie = append_avi; mh.end_movie = end_avi; mh.get_next_frame = NULL; mh.get_movie_path = filepath_avi; - +#endif + /* do the platform specific handles */ #ifdef WITH_QUICKTIME if (imtype == R_IMF_IMTYPE_QUICKTIME) { @@ -114,6 +119,8 @@ bMovieHandle *BKE_movie_handle_get(const char imtype) /* ****************************************************************** */ +#ifdef WITH_AVI + static AviMovie *avi = NULL; static void filepath_avi(char *string, RenderData *rd) @@ -219,6 +226,7 @@ static void end_avi(void) MEM_freeN(avi); avi = NULL; } +#endif /* WITH_AVI */ /* similar to BKE_makepicstring() */ void BKE_movie_filepath_get(char *string, RenderData *rd) diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index bbe70a7d73f..344ae604ed4 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -25,7 +25,6 @@ set(INC . - ../avi ../blenkernel ../blenlib ../blenloader @@ -143,6 +142,13 @@ if(WITH_IMAGE_REDCODE) add_definitions(-DWITH_REDCODE) endif() +if(WITH_CODEC_AVI) + list(APPEND INC + ../avi + ) + add_definitions(-DWITH_AVI) +endif() + if(WITH_CODEC_QUICKTIME) list(APPEND INC ../quicktime diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index d5cc4929aed..ed349e8f7eb 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -62,7 +62,9 @@ #include "imbuf.h" -#include "AVI_avi.h" +#ifdef WITH_AVI +# include "AVI_avi.h" +#endif #ifdef WITH_QUICKTIME # if defined(_WIN32) || defined(__APPLE__) diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 394f5169046..4aeba9af89d 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -78,7 +78,9 @@ #include "imbuf.h" -#include "AVI_avi.h" +#ifdef WITH_AVI +# include "AVI_avi.h" +#endif #ifdef WITH_QUICKTIME #if defined(_WIN32) || defined(__APPLE__) @@ -185,6 +187,7 @@ static void an_stringenc(char *string, const char *head, const char *tail, unsig BLI_stringenc(string, head, tail, numlen, pic); } +#ifdef WITH_AVI static void free_anim_avi(struct anim *anim) { #if defined(_WIN32) && !defined(FREE_WINDOWS) @@ -219,6 +222,7 @@ static void free_anim_avi(struct anim *anim) anim->duration = 0; } +#endif /* WITH_AVI */ #ifdef WITH_FFMPEG static void free_anim_ffmpeg(struct anim *anim); @@ -235,7 +239,10 @@ void IMB_free_anim(struct anim *anim) } free_anim_movie(anim); + +#ifdef WITH_AVI free_anim_avi(anim); +#endif #ifdef WITH_QUICKTIME free_anim_quicktime(anim); @@ -287,7 +294,7 @@ struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex, char return(anim); } - +#ifdef WITH_AVI static int startavi(struct anim *anim) { @@ -397,7 +404,9 @@ static int startavi(struct anim *anim) return 0; } +#endif /* WITH_AVI */ +#ifdef WITH_AVI static ImBuf *avi_fetchibuf(struct anim *anim, int position) { ImBuf *ibuf = NULL; @@ -447,6 +456,7 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position) return ibuf; } +#endif /* WITH_AVI */ #ifdef WITH_FFMPEG @@ -1206,7 +1216,11 @@ static ImBuf *anim_getnew(struct anim *anim) if (anim == NULL) return(NULL); free_anim_movie(anim); + +#ifdef WITH_AVI free_anim_avi(anim); +#endif + #ifdef WITH_QUICKTIME free_anim_quicktime(anim); #endif @@ -1233,6 +1247,7 @@ static ImBuf *anim_getnew(struct anim *anim) if (startmovie(anim)) return (NULL); ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); /* fake */ break; +#ifdef WITH_AVI case ANIM_AVI: if (startavi(anim)) { printf("couldnt start avi\n"); @@ -1240,6 +1255,7 @@ static ImBuf *anim_getnew(struct anim *anim) } ibuf = IMB_allocImBuf(anim->x, anim->y, 24, 0); break; +#endif #ifdef WITH_QUICKTIME case ANIM_QTIME: if (startquicktime(anim)) return (0); @@ -1331,11 +1347,13 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, int position, IMB_convert_rgba_to_abgr(ibuf); } break; +#ifdef WITH_AVI case ANIM_AVI: ibuf = avi_fetchibuf(anim, position); if (ibuf) anim->curposition = position; break; +#endif #ifdef WITH_QUICKTIME case ANIM_QTIME: ibuf = qtime_fetchibuf(anim, position); diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index f35a4345366..593e08062fe 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -36,18 +36,19 @@ #include "IMB_indexer.h" #include "IMB_anim.h" -#include "AVI_avi.h" #include "imbuf.h" #include "MEM_guardedalloc.h" #include "DNA_userdef_types.h" #include "BKE_global.h" -#ifdef WITH_FFMPEG - -#include "ffmpeg_compat.h" +#ifdef WITH_AVI +# include "AVI_avi.h" +#endif -#endif //WITH_FFMPEG +#ifdef WITH_FFMPEG +# include "ffmpeg_compat.h" +#endif static char magic[] = "BlenMIdx"; @@ -989,6 +990,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, * - internal AVI (fallback) rebuilder * ---------------------------------------------------------------------- */ +#ifdef WITH_AVI typedef struct FallbackIndexBuilderContext { int anim_type; @@ -1149,6 +1151,8 @@ static void index_rebuild_fallback(FallbackIndexBuilderContext *context, } } +#endif /* WITH_AVI */ + /* ---------------------------------------------------------------------- * - public API * ---------------------------------------------------------------------- */ @@ -1164,15 +1168,19 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, IMB_Timecod context = index_ffmpeg_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality); break; #endif +#ifdef WITH_AVI default: context = index_fallback_create_context(anim, tcs_in_use, proxy_sizes_in_use, quality); break; +#endif } if (context) context->anim_type = anim->curtype; return context; + + (void)tcs_in_use, (void)proxy_sizes_in_use, (void)quality; } void IMB_anim_index_rebuild(struct IndexBuildContext *context, @@ -1184,10 +1192,14 @@ void IMB_anim_index_rebuild(struct IndexBuildContext *context, index_rebuild_ffmpeg((FFmpegIndexBuilderContext *)context, stop, do_update, progress); break; #endif +#ifdef WITH_AVI default: index_rebuild_fallback((FallbackIndexBuilderContext *)context, stop, do_update, progress); break; +#endif } + + (void)stop, (void)do_update, (void)progress; } void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop) @@ -1198,10 +1210,15 @@ void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop) index_rebuild_ffmpeg_finish((FFmpegIndexBuilderContext *)context, stop); break; #endif +#ifdef WITH_AVI default: index_rebuild_fallback_finish((FallbackIndexBuilderContext *)context, stop); break; +#endif } + + (void)stop; + (void)proxy_sizes; /* static defined at top of the file */ } diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 2d04b7c7413..8dd791c8508 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -211,7 +211,12 @@ int IMB_ispic(const char *filename) static int isavi(const char *name) { +#ifdef WITH_AVI return AVI_is_avi(name); +#else + (void)name; + return FALSE; +#endif } #ifdef WITH_QUICKTIME -- cgit v1.2.3 From 244ce92dbd1f32960e0f909933d99cd0e6027dcc Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 8 Oct 2012 03:28:11 +0000 Subject: BGE: Setting up the RAS_ICanvas interface as the primary way to alter the OpenGL viewport. This helps to eliminate OpenGL calls in weird places like the physics code and to reduce glGet calls, which are expensive. There should be no functional changes (except maybe a very slight speed improvement). --- .../BlenderRoutines/KX_BlenderCanvas.cpp | 24 ++++++++++++++++++++++ .../gameengine/BlenderRoutines/KX_BlenderCanvas.h | 3 +++ source/gameengine/GamePlayer/common/GPC_Canvas.cpp | 22 ++++++++++++++++++++ source/gameengine/GamePlayer/common/GPC_Canvas.h | 3 +++ source/gameengine/Ketsji/KX_Camera.cpp | 8 ++++---- source/gameengine/Ketsji/KX_Dome.cpp | 5 ++--- source/gameengine/Ketsji/KX_Dome.h | 2 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 3 +-- source/gameengine/Ketsji/KX_Scene.cpp | 10 ++++++++- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 22 ++++++++------------ .../Physics/Bullet/CcdPhysicsEnvironment.h | 2 +- .../Physics/Dummy/DummyPhysicsEnvironment.h | 2 +- .../Physics/common/PHY_IPhysicsEnvironment.h | 2 +- .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 3 +-- source/gameengine/Rasterizer/RAS_ICanvas.h | 7 +++++++ 15 files changed, 88 insertions(+), 30 deletions(-) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 4f450bcd668..0b41cceb646 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -33,6 +33,7 @@ #include "KX_BlenderCanvas.h" #include "DNA_screen_types.h" #include +#include KX_BlenderCanvas::KX_BlenderCanvas(struct wmWindow *win, RAS_Rect &rect, struct ARegion *ar) : @@ -44,6 +45,8 @@ m_frame_rect(rect) // area boundaries needed for mouse coordinates in Letterbox framing mode m_area_left = ar->winrct.xmin; m_area_top = ar->winrct.ymax; + + glGetIntegerv(GL_VIEWPORT, (GLint*)m_viewport); } KX_BlenderCanvas::~KX_BlenderCanvas() @@ -166,10 +169,31 @@ SetViewPort( m_area_rect.SetRight(minx + x2); m_area_rect.SetTop(miny + y2); + m_viewport[0] = minx+x1; + m_viewport[1] = miny+y1; + m_viewport[2] = vp_width; + m_viewport[3] = vp_height; + glViewport(minx + x1, miny + y1, vp_width, vp_height); glScissor(minx + x1, miny + y1, vp_width, vp_height); } + const int* +KX_BlenderCanvas:: +GetViewPort() { +#ifdef DEBUG + // If we're in a debug build, we might as well make sure our values don't differ + // from what the gpu thinks we have. This could lead to nasty, hard to find bugs. + int viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + assert(viewport[0] == m_viewport[0]); + assert(viewport[1] == m_viewport[1]); + assert(viewport[2] == m_viewport[2]); + assert(viewport[3] == m_viewport[3]); +#endif + + return m_viewport; +} void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate) { diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index ee7997abb39..004f7dd0dd9 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -61,6 +61,7 @@ private: /** Rect that defines the area used for rendering, relative to the context */ RAS_Rect m_displayarea; + int m_viewport[4]; public: /* Construct a new canvas. @@ -150,6 +151,8 @@ public: int x1, int y1, int x2, int y2 ); + const int* + GetViewPort(); void SetMouseState( diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index 7581484a41f..b5c1c29238a 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -57,6 +57,8 @@ GPC_Canvas::GPC_Canvas( m_displayarea.m_y1 = 0; m_displayarea.m_x2 = width; m_displayarea.m_y2 = height; + + glGetIntegerv(GL_VIEWPORT, (GLint*)m_viewport); } @@ -121,11 +123,31 @@ void GPC_Canvas::SetViewPort(int x1, int y1, int x2, int y2) * whole canvas/rendertools mess. */ glEnable(GL_SCISSOR_TEST); + + m_viewport[0] = x1; + m_viewport[1] = y1; + m_viewport[2] = x2-x1 + 1; + m_viewport[3] = y2-y1 + 1; glViewport(x1,y1,x2-x1 + 1,y2-y1 + 1); glScissor(x1,y1,x2-x1 + 1,y2-y1 + 1); }; +const int *GPC_Canvas::GetViewPort() +{ +#ifdef DEBUG + // If we're in a debug build, we might as well make sure our values don't differ + // from what the gpu thinks we have. This could lead to nasty, hard to find bugs. + int viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + assert(viewport[0] == m_viewport[0]); + assert(viewport[1] == m_viewport[1]); + assert(viewport[2] == m_viewport[2]); + assert(viewport[3] == m_viewport[3]); +#endif + + return m_viewport; +} void GPC_Canvas::ClearBuffer( int type diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index 453b9505183..2a597c4c43d 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -90,6 +90,8 @@ protected: * relative to the context */ RAS_Rect m_displayarea; + int *m_viewport; + /** Storage for the banners to display. */ TBannerMap m_banners; /** State of banner display. */ @@ -153,6 +155,7 @@ public: ); void SetViewPort(int x1, int y1, int x2, int y2); + const int *GetViewPort(); void ClearColor(float r, float g, float b, float a); diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index c0071ab22f6..90912409af1 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -956,7 +956,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition, } } - GLint viewport[4]; + const GLint *viewport; GLdouble win[3]; GLdouble modelmatrix[16]; GLdouble projmatrix[16]; @@ -967,7 +967,7 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, getScreenPosition, m_modelmatrix.getValue(modelmatrix); m_projmatrix.getValue(projmatrix); - glGetIntegerv(GL_VIEWPORT, viewport); + viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort(); gluProject(vect[0], vect[1], vect[2], modelmatrix, projmatrix, viewport, &win[0], &win[1], &win[2]); @@ -999,7 +999,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect, MT_Vector3 vect; MT_Point3 campos, screenpos; - GLint viewport[4]; + const GLint *viewport; GLdouble win[3]; GLdouble modelmatrix[16]; GLdouble projmatrix[16]; @@ -1010,7 +1010,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, getScreenVect, m_modelmatrix.getValue(modelmatrix); m_projmatrix.getValue(projmatrix); - glGetIntegerv(GL_VIEWPORT, viewport); + viewport = KX_GetActiveEngine()->GetCanvas()->GetViewPort(); vect[0] = x * viewport[2]; vect[1] = y * viewport[3]; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index fd3a18a9d2a..87b0cfc1269 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -90,8 +90,7 @@ KX_Dome::KX_Dome ( } //setting the viewport size - GLuint viewport[4]={0}; - glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); + const int *viewport = m_canvas->GetViewPort(); SetViewPort(viewport); @@ -178,7 +177,7 @@ KX_Dome::~KX_Dome (void) glDeleteLists(dlistId, (GLsizei) m_numimages); } -void KX_Dome::SetViewPort(GLuint viewport[4]) +void KX_Dome::SetViewPort(const int viewport[4]) { if (canvaswidth != m_viewport.GetWidth() || canvasheight != m_viewport.GetHeight()) { diff --git a/source/gameengine/Ketsji/KX_Dome.h b/source/gameengine/Ketsji/KX_Dome.h index 24177af5d60..17eec3a5fcb 100644 --- a/source/gameengine/Ketsji/KX_Dome.h +++ b/source/gameengine/Ketsji/KX_Dome.h @@ -119,7 +119,7 @@ public: void RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i); void BindImages(int i); - void SetViewPort(GLuint viewport[4]); + void SetViewPort(const int viewport[4]); void CalculateFrustum(KX_Camera* cam); void RotateCamera(KX_Camera* cam, int i); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index c2857141058..e446e5338bc 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -275,8 +275,7 @@ void KX_KetsjiEngine::InitDome(short res, short mode, short angle, float resbuf, void KX_KetsjiEngine::RenderDome() { - GLuint viewport[4]={0}; - glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); + const GLint *viewport = m_canvas->GetViewPort(); m_dome->SetViewPort(viewport); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a4237f9fabe..f6ab9af261e 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1502,7 +1502,15 @@ void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int planes[4].setValue(cplanes[2].getValue()); // top planes[5].setValue(cplanes[3].getValue()); // bottom CullingInfo info(layer); - dbvt_culling = m_physicsEnvironment->cullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res); + + double mvmat[16] = {0}; + cam->GetModelviewMatrix().getValue(mvmat); + double pmat[16] = {0}; + cam->GetProjectionMatrix().getValue(pmat); + + dbvt_culling = m_physicsEnvironment->cullingTest(PhysicsCullingCallback,&info,planes,5,m_dbvt_occlusion_res, + KX_GetActiveEngine()->GetCanvas()->GetViewPort(), + mvmat, pmat); } if (!dbvt_culling) { // the physics engine couldn't help us, do it the hard way diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 55bbc0d33b9..82a60e756d7 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -57,7 +57,6 @@ btRaycastVehicle::btVehicleTuning gTuning; #include "LinearMath/btAabbUtil2.h" #include "MT_Matrix4x4.h" #include "MT_Vector3.h" -#include "GL/glew.h" #ifdef WIN32 void DrawRasterizerLine(const float* from,const float* to,int color); @@ -1309,22 +1308,19 @@ struct OcclusionBuffer m[14] = btScalar(m1[ 2]*m2[12]+m1[ 6]*m2[13]+m1[10]*m2[14]+m1[14]*m2[15]); m[15] = btScalar(m1[ 3]*m2[12]+m1[ 7]*m2[13]+m1[11]*m2[14]+m1[15]*m2[15]); } - void setup(int size) + void setup(int size, const int *view, double modelview[16], double projection[16]) { m_initialized=false; m_occlusion=false; // compute the size of the buffer - GLint v[4]; - GLdouble m[16],p[16]; int maxsize; double ratio; - glGetIntegerv(GL_VIEWPORT,v); - maxsize = (v[2] > v[3]) ? v[2] : v[3]; + maxsize = (view[2] > view[3]) ? view[2] : view[3]; assert(maxsize > 0); ratio = 1.0/(2*maxsize); // ensure even number - m_sizes[0] = 2*((int)(size*v[2]*ratio+0.5)); - m_sizes[1] = 2*((int)(size*v[3]*ratio+0.5)); + m_sizes[0] = 2*((int)(size*view[2]*ratio+0.5)); + m_sizes[1] = 2*((int)(size*view[3]*ratio+0.5)); m_scales[0]=btScalar(m_sizes[0]/2); m_scales[1]=btScalar(m_sizes[1]/2); m_offsets[0]=m_scales[0]+0.5f; @@ -1332,10 +1328,8 @@ struct OcclusionBuffer // prepare matrix // at this time of the rendering, the modelview matrix is the // world to camera transformation and the projection matrix is - // camera to clip transformation. combine both so that - glGetDoublev(GL_MODELVIEW_MATRIX,m); - glGetDoublev(GL_PROJECTION_MATRIX,p); - CMmat4mul(m_wtc,p,m); + // camera to clip transformation. combine both so that + CMmat4mul(m_wtc, projection, modelview); } void initialize() { @@ -1795,7 +1789,7 @@ struct DbvtCullingCallback : btDbvt::ICollide }; static OcclusionBuffer gOcb; -bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4 *planes, int nplanes, int occlusionRes) +bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { if (!m_cullingTree) return false; @@ -1812,7 +1806,7 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user // if occlusionRes != 0 => occlusion culling if (occlusionRes) { - gOcb.setup(occlusionRes); + gOcb.setup(occlusionRes, viewport, modelview, projection); dispatcher.m_ocb = &gOcb; // occlusion culling, the direction of the view is taken from the first plan which MUST be the near plane btDbvt::collideOCL(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 59e40a6f91a..453380b69ca 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -188,7 +188,7 @@ protected: btTypedConstraint* getConstraintById(int constraintId); virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes); + virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]); //Methods for gamelogic collision/physics callbacks diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 9c109168b18..4ddfe4d69e0 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -73,7 +73,7 @@ public: } virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes) { return false; } + virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; } //gamelogic callbacks diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 3f8699d25d2..77016859c3f 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -161,7 +161,7 @@ class PHY_IPhysicsEnvironment //culling based on physical broad phase // the plane number must be set as follow: near, far, left, right, top, botton // the near plane must be the first one and must always be present, it is used to get the direction of the view - virtual bool cullingTest(PHY_CullingCallback callback, void *userData, PHY__Vector4* planeNormals, int planeNumber, int occlusionRes) = 0; + virtual bool cullingTest(PHY_CullingCallback callback, void *userData, PHY__Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0; //Methods for gamelogic collision/physics callbacks //todo: diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 7312b521788..0ae8908e946 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -398,8 +398,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if (num_filters <= 0) return; - GLuint viewport[4]={0}; - glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); + const GLint *viewport = canvas->GetViewPort(); RAS_Rect rect = canvas->GetWindowArea(); int rect_width = rect.GetWidth()+1, rect_height = rect.GetHeight()+1; diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index 713a06845ac..f045eb7e423 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -180,6 +180,13 @@ public: int x2, int y2 ) = 0; + /** + * Get the visible viewport + */ + virtual + const int* + GetViewPort() = 0; + virtual void SetMouseState( -- cgit v1.2.3 From d0f702df8f5c483d3617a25c50076e97060b991a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 03:33:02 +0000 Subject: fix [#32799] right click select in filebrowser breaks opening folders own regression since 2.63, The path length for FILE_OT_select_bookmark was too short as well (256 --> FILE_MAXDIR). --- source/blender/editors/space_file/file_ops.c | 39 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index fcbeb064e4d..7a364eb8685 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -307,7 +307,7 @@ void FILE_OT_select_border(wmOperatorType *ot) ot->poll = ED_operator_file_active; ot->cancel = WM_border_select_cancel; - /* rna */ + /* properties */ WM_operator_properties_gesture_border(ot, 1); } @@ -347,6 +347,8 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) void FILE_OT_select(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Activate/Select File"; ot->description = "Activate/select file"; @@ -356,10 +358,13 @@ void FILE_OT_select(wmOperatorType *ot) ot->invoke = file_select_invoke; ot->poll = ED_operator_file_active; - /* rna */ - RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); - RNA_def_boolean(ot->srna, "fill", FALSE, "Fill", "Select everything beginning with the last selection"); - RNA_def_boolean(ot->srna, "open", TRUE, "Open", "Open a directory when selecting it"); + /* properties */ + prop = RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "fill", FALSE, "Fill", "Select everything beginning with the last selection"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "open", TRUE, "Open", "Open a directory when selecting it"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) @@ -404,9 +409,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) ot->exec = file_select_all_exec; ot->poll = ED_operator_file_active; - /* rna */ - - + /* properties */ } /* ---------- BOOKMARKS ----------- */ @@ -432,6 +435,8 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) void FILE_OT_select_bookmark(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Select Directory"; ot->description = "Select a bookmarked directory"; @@ -441,7 +446,9 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) ot->exec = bookmark_select_exec; ot->poll = ED_operator_file_active; - RNA_def_string(ot->srna, "dir", "", 256, "Dir", ""); + /* properties */ + prop = RNA_def_string(ot->srna, "dir", "", FILE_MAXDIR, "Dir", ""); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) @@ -498,6 +505,8 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) void FILE_OT_delete_bookmark(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Delete Bookmark"; ot->description = "Delete selected bookmark"; @@ -507,7 +516,9 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) ot->exec = bookmark_delete_exec; ot->poll = ED_operator_file_active; - RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000); + /* properties */ + prop = RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) @@ -819,7 +830,8 @@ void FILE_OT_execute(struct wmOperatorType *ot) /* api callbacks */ ot->exec = file_exec; ot->poll = file_operator_poll; - + + /* properties */ prop = RNA_def_boolean(ot->srna, "need_active", 0, "Need Active", "Only execute if there's an active selected file in the file list"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -1123,6 +1135,8 @@ int file_directory_new_exec(bContext *C, wmOperator *op) void FILE_OT_directory_new(struct wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Create New Directory"; ot->description = "Create a new directory"; @@ -1133,7 +1147,8 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) ot->exec = file_directory_new_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ - RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Name of new directory"); + prop = RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Name of new directory"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -- cgit v1.2.3 From 718dea866588b13af6c362bed1bc6e33588fafe3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 8 Oct 2012 04:42:06 +0000 Subject: Patch [#32639] Pose breakdown confirm by Return Key Thanks Julien DUROURE (julien) --- source/blender/editors/armature/poseSlide.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index cdcb3ab4683..31398948b82 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -631,6 +631,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, wmEvent *evt) switch (evt->type) { case LEFTMOUSE: /* confirm */ + case RETKEY: { /* return to normal cursor and header status */ ED_area_headerprint(pso->sa, NULL); -- cgit v1.2.3 From 565e7c8e3cbb4aee0c1b8f17b43f63055c4384f7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 8 Oct 2012 05:57:52 +0000 Subject: Display enum descriptions in tooltips for operators using a "type" or "mode" property Changes: This commit adds a second line to the tooltips (below the generic operator description) showing the appropriate description for each enum option. This brings it more into line enum properties in Blender which also show this sort of information. Rationale: Operators such as Snap and Mirror in the Action and Graph Editors use an enum to control their behaviour (respectively, "how to snap" or "what to use as the mirror line"). In the menus, these options are displayed using a submenu, but hovering over each of these items for more information from a tooltip only shows the (relatively unhelpful) generic operator tooltip/description. Another area where these descriptions are useful is for Keying Sets, where it's now possible to see the descriptions for what each Keying Set does/affects/requires. Again, this is more helpful than just the generic tooltip, which would be something like "Insert keyframes using a Keying Set". --- source/blender/editors/interface/interface.c | 35 +++++++++++++++++++++-- source/blender/editors/space_action/action_edit.c | 27 +++++++++-------- source/blender/editors/space_graph/graph_edit.c | 33 ++++++++++++++------- 3 files changed, 69 insertions(+), 26 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index df18498559e..d442ce1b04b 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3869,12 +3869,41 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) } } else if (ELEM3(type, BUT_GET_RNAENUM_IDENTIFIER, BUT_GET_RNAENUM_LABEL, BUT_GET_RNAENUM_TIP)) { + PointerRNA *ptr = NULL; + PropertyRNA *prop = NULL; + int value = 0; + + /* get the enum property... */ if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { + /* enum property */ + ptr = &but->rnapoin; + prop = but->rnaprop; + value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but); + } + else if (but->optype) { + PointerRNA *opptr = uiButGetOperatorPtrRNA(but); + wmOperatorType *ot = but->optype; + + /* if the default property of the operator is enum and it is set, + * fetch the tooltip of the selected value so that "Snap" and "Mirror" + * operator menus in the Anim Editors will show tooltips for the different + * operations instead of the meaningless generic operator tooltip + */ + if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) { + if (RNA_struct_contains_property(opptr, ot->prop)) { + ptr = opptr; + prop = ot->prop; + value = RNA_property_enum_get(opptr, ot->prop); + } + } + } + + /* get strings from matching enum item */ + if (ptr && prop) { if (!item) { int i; - int value = (but->type == ROW) ? (int)but->hardmax : (int)ui_get_but_val(but); - RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &items, &totitems, &free_items); - + + RNA_property_enum_items_gettexted(C, ptr, prop, &items, &totitems, &free_items); for (i = 0, item = items; i < totitems; i++, item++) { if (item->identifier[0] && item->value == value) break; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 7635f85a37e..3865234a25d 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1369,10 +1369,14 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) /* defines for snap keyframes tool */ static EnumPropertyItem prop_actkeys_snap_types[] = { - {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", ""}, - {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry? - {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry? - {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""}, + {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", + "Snap selected keyframes to the current frame"}, + {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", + "Snap selected keyframes to the nearest (whole) frame. Use to fix accidental sub-frame offsets"}, + {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", + "Snap selected keyframes to the nearest second"}, + {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", + "Snap selected keyframes to the nearest marker"}, {0, NULL, 0, NULL, NULL} }; @@ -1473,9 +1477,12 @@ void ACTION_OT_snap(wmOperatorType *ot) /* defines for mirror keyframes tool */ static EnumPropertyItem prop_actkeys_mirror_types[] = { - {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", ""}, - {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", ""}, - {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", ""}, + {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", + "Flip times of selected keyframes using the current frame as the mirror line"}, + {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", + "Flip values of selected keyframes (i.e. negative values become positive, and vica versa)"}, + {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", + "Flip times of selected keyframes using the first selected marker as the reference point"}, {0, NULL, 0, NULL, NULL} }; @@ -1497,12 +1504,8 @@ static void mirror_action_keys(bAnimContext *ac, short mode) /* for 'first selected marker' mode, need to find first selected marker first! */ // XXX should this be made into a helper func in the API? if (mode == ACTKEYS_MIRROR_MARKER) { - TimeMarker *marker = NULL; + TimeMarker *marker = ED_markers_get_first_selected(ac->markers); - /* find first selected marker */ - marker = ED_markers_get_first_selected(ac->markers); - - /* store marker's time (if available) */ if (marker) ked.f1 = (float)marker->frame; else diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 7107a6a2369..bff64f8348f 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1824,12 +1824,18 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot) /* defines for snap keyframes tool */ static EnumPropertyItem prop_graphkeys_snap_types[] = { - {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", ""}, - {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", ""}, - {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry? - {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry? - {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""}, - {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", ""}, + {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", + "Snap selected keyframes to the current frame"}, + {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", + "Set values of selected keyframes to the cursor value (Y/Horizontal component)"}, + {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", + "Snap selected keyframes to the nearest (whole) frame. Use to fix accidental sub-frame offsets"}, + {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", + "Snap selected keyframes to the nearest second"}, + {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", + "Snap selected keyframes to the nearest marker"}, + {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", + "Flatten handles for a smoother transition"}, {0, NULL, 0, NULL, NULL} }; @@ -1932,11 +1938,16 @@ void GRAPH_OT_snap(wmOperatorType *ot) /* defines for mirror keyframes tool */ static EnumPropertyItem prop_graphkeys_mirror_types[] = { - {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", ""}, - {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", ""}, - {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", ""}, - {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", ""}, - {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", ""}, + {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", + "Flip times of selected keyframes using the current frame as the mirror line"}, + {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", + "Flip values of selectd keyframes using the cursor value (Y/Horizontal component) as the mirror line"}, + {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", + "Flip times of selected keyframes, effectively reversing the order they appear in"}, + {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", + "Flip values of selected keyframes (i.e. negative values become positive, and vica versa)"}, + {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", + "Flip times of selected keyframes using the first selected marker as the reference point"}, {0, NULL, 0, NULL, NULL} }; -- cgit v1.2.3 From 8b765373e1c33a38848f7b0a4082a9f195e5f420 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 8 Oct 2012 06:21:36 +0000 Subject: Bugfix: No enum tooltips displayed for many 3D view navigation tools (+ Code cleanup) * Enum tooltips will only be detected in the case that we assign that as the default property (ot->prop) of the operator. Set all of the offending properties to get this status, since those operators would be useless without that property anyway * Improved the wording/capitalisation of a few of these tooltips and labels --- source/blender/editors/space_view3d/view3d_edit.c | 22 +++++++++++++--------- source/blender/editors/space_view3d/view3d_view.c | 1 - 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 504f746637e..4e8981f16bd 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -966,7 +966,6 @@ static int viewrotate_cancel(bContext *C, wmOperator *op) void VIEW3D_OT_rotate(wmOperatorType *ot) { - /* identifiers */ ot->name = "Rotate view"; ot->description = "Rotate the view"; @@ -2901,7 +2900,7 @@ static EnumPropertyItem prop_view_items[] = { {RV3D_VIEW_RIGHT, "RIGHT", 0, "Right", "View From the Right"}, {RV3D_VIEW_TOP, "TOP", 0, "Top", "View From the Top"}, {RV3D_VIEW_BOTTOM, "BOTTOM", 0, "Bottom", "View From the Bottom"}, - {RV3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the active camera"}, + {RV3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the Active Camera"}, {0, NULL, 0, NULL, NULL} }; @@ -3125,7 +3124,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) /* identifiers */ ot->name = "View numpad"; - ot->description = "Set the view"; + ot->description = "Use a preset viewpoint"; ot->idname = "VIEW3D_OT_viewnumpad"; /* api callbacks */ @@ -3135,8 +3134,8 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) /* flags */ ot->flag = 0; - prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view"); - RNA_def_property_flag(prop, PROP_SKIP_SAVE); + ot->prop = RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "Preset viewpoint to use"); + RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active object's axis"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -3213,7 +3212,9 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot) /* flags */ ot->flag = 0; - RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit"); + + /* properties */ + ot->prop = RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit"); } static EnumPropertyItem prop_view_pan_items[] = { @@ -3262,7 +3263,9 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot) /* flags */ ot->flag = 0; - RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan"); + + /* Properties */ + ot->prop = RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan"); } static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op)) @@ -3290,7 +3293,7 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot) { /* identifiers */ ot->name = "View Persp/Ortho"; - ot->description = "Switch the current view from perspective/orthographic"; + ot->description = "Switch the current view from perspective/orthographic projection"; ot->idname = "VIEW3D_OT_view_persportho"; /* api callbacks */ @@ -3406,7 +3409,8 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot) /* flags */ ot->flag = 0; - + + /* properties */ RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Background image index to remove", 0, INT_MAX); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 84b1505c900..e4a6d7e1b17 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1647,7 +1647,6 @@ static int localview_exec(bContext *C, wmOperator *op) void VIEW3D_OT_localview(wmOperatorType *ot) { - /* identifiers */ ot->name = "Local View"; ot->description = "Toggle display of selected object(s) separately and centered in view"; -- cgit v1.2.3 From 8b7f410f95cca51f7ff6dc0ca5c6729d0268ccc6 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 8 Oct 2012 06:28:06 +0000 Subject: Code cleanup - silence some "uninitialised" warnings in BMesh code There are still a lot more in bmo_bevel.c and bmo_extrude.c, but those don't seem that easy to fix. --- source/blender/bmesh/intern/bmesh_walkers_impl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index a72bfe47127..225ea6c2ef6 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -499,7 +499,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker) BMEdge *e = lwalk->cur, *nexte = NULL; BMLoop *l; BMVert *v; - int i; + int i = 0; owalk = *lwalk; BMW_state_remove(walker); @@ -534,7 +534,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker) } else if (l) { /* NORMAL EDGE WITH FACES */ int vert_edge_tot; - int stopi; + int stopi = 0; v = BM_edge_other_vert(e, lwalk->lastv); -- cgit v1.2.3 From 321e9d8011f5d0e200c8206487b3e1253469b552 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Oct 2012 06:38:34 +0000 Subject: Fix #32803: Incorrect sequencer color space for newly added scenes --- source/blender/blenkernel/intern/scene.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index f8777f87369..96e64f30156 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -54,6 +54,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_callbacks.h" +#include "BLI_string.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -175,6 +176,9 @@ Scene *BKE_scene_copy(Scene *sce, int type) BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings); BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings); BKE_color_managed_view_settings_copy(&scen->r.im_format.view_settings, &sce->r.im_format.view_settings); + + BLI_strncpy(scen->sequencer_colorspace_settings.name, sce->sequencer_colorspace_settings.name, + sizeof(scen->sequencer_colorspace_settings.name)); } /* tool settings */ @@ -350,6 +354,7 @@ Scene *BKE_scene_add(const char *name) Scene *sce; ParticleEditSettings *pset; int a; + const char *colorspace_name; sce = BKE_libblock_alloc(&bmain->scene, ID_SCE, name); sce->lay = sce->layact = 1; @@ -563,8 +568,13 @@ Scene *BKE_scene_add(const char *name) sound_create_scene(sce); + /* color management */ + colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER); + BKE_color_managed_display_settings_init(&sce->display_settings); BKE_color_managed_view_settings_init(&sce->view_settings); + BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name, + sizeof(sce->sequencer_colorspace_settings.name)); return sce; } -- cgit v1.2.3 From 8b7896814f5ee2cea4c43d409f55ff57649c8661 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 07:08:29 +0000 Subject: code cleanup: reduce change the size of some float vectors that were bigger then they needed to be. update to clang_array_check.py - parse function definitions lazily for some speedup. --- build_files/cmake/clang_array_check.py | 84 +++++++++++++--------- source/blender/editors/interface/interface_ops.c | 2 +- source/blender/editors/mesh/editmesh_bvh.c | 6 +- source/blender/editors/mesh/editmesh_rip.c | 2 +- source/blender/editors/mesh/editmesh_tools.c | 2 +- source/blender/editors/sculpt_paint/paint_intern.h | 2 +- source/blender/editors/sculpt_paint/paint_stroke.c | 19 +++-- source/blender/editors/sculpt_paint/sculpt.c | 2 +- .../blender/editors/sculpt_paint/sculpt_intern.h | 2 +- .../blender/editors/space_outliner/outliner_draw.c | 2 +- 10 files changed, 69 insertions(+), 54 deletions(-) diff --git a/build_files/cmake/clang_array_check.py b/build_files/cmake/clang_array_check.py index df45648f975..3070c27f769 100644 --- a/build_files/cmake/clang_array_check.py +++ b/build_files/cmake/clang_array_check.py @@ -19,12 +19,15 @@ Invocation: """ +# delay parsing functions until we need them +USE_LAZY_INIT = True + # ----------------------------------------------------------------------------- # predefined function/arg sizes, handy sometimes, but not complete... defs_precalc = { - "glColor3bv": {0: 3}, - "glColor4bv": {0: 4}, + "glColor3bv": {0: 3}, + "glColor4bv": {0: 4}, "glColor3ubv": {0: 3}, "glColor4ubv": {0: 4}, @@ -32,11 +35,11 @@ defs_precalc = { "glColor4usv": {0: 3}, "glColor4usv": {0: 4}, - "glColor3fv": {0: 3}, - "glColor4fv": {0: 4}, + "glColor3fv": {0: 3}, + "glColor4fv": {0: 4}, - "glColor3dv": {0: 3}, - "glColor4dv": {0: 4}, + "glColor3dv": {0: 3}, + "glColor4dv": {0: 4}, "glVertex2fv": {0: 2}, "glVertex3fv": {0: 3}, @@ -52,12 +55,12 @@ defs_precalc = { "glRasterPos4dv": {0: 4}, "glRasterPos2fv": {0: 2}, - "glRasterPos3fv": {0: 3}, + "glRasterPos3fv": {0: 3}, "glRasterPos4fv": {0: 4}, "glRasterPos2sv": {0: 2}, - "glRasterPos3sv": {0: 3}, - "glRasterPos4sv": {0: 4}, + "glRasterPos3sv": {0: 3}, + "glRasterPos4sv": {0: 4}, "glTexCoord2fv": {0: 2}, "glTexCoord3fv": {0: 3}, @@ -112,10 +115,11 @@ args = sys.argv[2:] # print(args) tu = index.parse(sys.argv[1], args) -print 'Translation unit:', tu.spelling +print('Translation unit: %s' % tu.spelling) # ----------------------------------------------------------------------------- + def function_parm_wash_tokens(parm): # print(parm.kind) assert parm.kind in (CursorKind.PARM_DECL, @@ -174,22 +178,21 @@ def parm_size(node_child): # print(" ".join([t.spelling for t in tokens])) # NOT PERFECT CODE, EXTRACT SIZE FROM TOKENS - if len(tokens) >= 3: # foo [ 1 ] - if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and - (tokens[-2].kind == TokenKind.LITERAL and tokens[-2].spelling.isdigit()) and - (tokens[-1].kind == TokenKind.PUNCTUATION and tokens[-1].spelling == "]")): + if len(tokens) >= 3: # foo [ 1 ] + if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and + (tokens[-2].kind == TokenKind.LITERAL and tokens[-2].spelling.isdigit()) and + (tokens[-1].kind == TokenKind.PUNCTUATION and tokens[-1].spelling == "]")): # --- return int(tokens[-2].spelling) return -1 - def function_get_arg_sizes(node): # Return a dict if (index: size) items # {arg_indx: arg_array_size, ... ] arg_sizes = {} - if node.spelling == "BM_vert_create" or 1: + if 1: # node.spelling == "BM_vert_create", for debugging node_parms = [node_child for node_child in node.get_children() if node_child.kind == CursorKind.PARM_DECL] @@ -211,11 +214,19 @@ def function_get_arg_sizes(node): # ----------------------------------------------------------------------------- _defs = {} + def lookup_function_size_def(func_id): - return _defs.get(func_id, ()) + if USE_LAZY_INIT: + result = _defs.get(func_id, {}) + if type(result) != dict: + result = _defs[func_id] = function_get_arg_sizes(result) + return result + else: + return _defs.get(func_id, {}) # ----------------------------------------------------------------------------- + def file_check_arg_sizes(tu): # main checking function @@ -224,7 +235,13 @@ def file_check_arg_sizes(tu): Loop over args and validate sizes for args we KNOW the size of. """ assert node.kind == CursorKind.CALL_EXPR - # print("---", " <~> ".join([" ".join([t.spelling for t in C.get_tokens()]) for C in node.get_children()])) + + if 0: + print("---", + " <~> ".join( + [" ".join([t.spelling for t in C.get_tokens()]) + for C in node.get_children()] + )) # print(node.location) # first child is the function call, skip that. @@ -283,36 +300,32 @@ def file_check_arg_sizes(tu): if size != -1 and size != 0: # nice print! - ''' - print("".join([t.spelling for t in func.get_tokens()]), - i, - " ".join([t.spelling for t in dec.get_tokens()])) - ''' + if 0: + print("".join([t.spelling for t in func.get_tokens()]), + i, + " ".join([t.spelling for t in dec.get_tokens()])) # testing # size_def = 100 - - if size < size_def: + if size < size_def and size != 1: location = node.location print("%s:%d:%d: argument %d is size %d, should be %d" % (location.file, location.line, - location.column, - i + 1, size, size_def - )) - + location.column, + i + 1, size, size_def + )) # we dont really care what we are looking at, just scan entire file for # function calls. - + def recursive_func_call_check(node): - if node.kind == CursorKind.CALL_EXPR: validate_arg_size(node) - + for c in node.get_children(): recursive_func_call_check(c) - + recursive_func_call_check(tu.cursor) @@ -322,7 +335,10 @@ def file_check_arg_sizes(tu): def recursive_arg_sizes(node, ): # print(node.kind, node.spelling) if node.kind == CursorKind.FUNCTION_DECL: - args_sizes = function_get_arg_sizes(node) + if USE_LAZY_INIT: + args_sizes = node + else: + args_sizes = function_get_arg_sizes(node) #if args_sizes: # print(node.spelling, args_sizes) _defs[node.spelling] = args_sizes diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 1ee06b1ff64..e4e2598c494 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -216,7 +216,7 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3 /* set sample from accumulated values */ static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye) { - float col[4]; + float col[3]; mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot); eyedropper_color_set(C, eye, col); } diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index c249d764ac1..e84fa90fe5c 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -371,9 +371,9 @@ int BMBVH_VertVisible(BMBVHTree *tree, BMEdge *e, RegionView3D *r3d) } #endif -static BMFace *edge_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float *hitout, BMEdge *e) +static BMFace *edge_ray_cast(BMBVHTree *tree, const float co[3], const float dir[3], float *r_hitout, BMEdge *e) { - BMFace *f = BMBVH_RayCast(tree, co, dir, hitout, NULL); + BMFace *f = BMBVH_RayCast(tree, co, dir, r_hitout, NULL); if (f && BM_edge_in_face(f, e)) return NULL; @@ -392,7 +392,7 @@ static void scale_point(float c1[3], const float p[3], const float s) int BMBVH_EdgeVisible(BMBVHTree *tree, BMEdge *e, ARegion *ar, View3D *v3d, Object *obedit) { BMFace *f; - float co1[3], co2[3], co3[3], dir1[4], dir2[4], dir3[4]; + float co1[3], co2[3], co3[3], dir1[3], dir2[3], dir3[3]; float origin[3], invmat[4][4]; float epsilon = 0.01f; float end[3]; diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 001d584416f..0b3d178e2e8 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -59,7 +59,7 @@ static float edbm_rip_rip_edgedist(ARegion *ar, float mat[][4], const float co1[3], const float co2[3], const float mvalf[2]) { - float vec1[3], vec2[3]; + float vec1[2], vec2[2]; ED_view3d_project_float_v2_m4(ar, co1, vec1, mat); ED_view3d_project_float_v2_m4(ar, co2, vec2, mat); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 0d78d850e74..891e1487781 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -765,7 +765,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent done = FALSE; BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { - float co1[3], co2[3]; + float co1[2], co2[2]; if ((ED_view3d_project_float_object(vc.ar, eed->v1->co, co1, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) && (ED_view3d_project_float_object(vc.ar, eed->v2->co, co2, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK)) diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 794e7755636..162e2fa15d6 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -51,7 +51,7 @@ struct wmOperator; struct wmOperatorType; /* paint_stroke.c */ -typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], float mouse[2]); +typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2]); typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2]); typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr); typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 7fabaf7f23d..2ae24db7c33 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -139,13 +139,13 @@ static float event_tablet_data(wmEvent *event, int *pen_flip) } /* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */ -static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2]) +static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, const float mouse_in[2]) { Scene *scene = CTX_data_scene(C); Paint *paint = paint_get_active_from_context(C); Brush *brush = paint_brush(paint); PaintStroke *stroke = op->customdata; - float mouse[3]; + float mouse_out[2]; PointerRNA itemptr; float location[3]; float pressure; @@ -159,24 +159,24 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev if (stroke->vc.obact->sculpt) { float delta[2]; - BKE_brush_jitter_pos(scene, brush, mouse_in, mouse); + BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out); /* XXX: meh, this is round about because * 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); + sub_v2_v2v2(delta, mouse_out, mouse_in); mul_v2_fl(delta, pressure); - add_v2_v2v2(mouse, mouse_in, delta); + add_v2_v2v2(mouse_out, mouse_in, delta); } } else { - copy_v2_v2(mouse, mouse_in); + copy_v2_v2(mouse_out, mouse_in); } /* TODO: can remove the if statement once all modes have this */ if (stroke->get_location) - stroke->get_location(C, location, mouse); + stroke->get_location(C, location, mouse_out); else zero_v3(location); @@ -184,12 +184,11 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev RNA_collection_add(op->ptr, "stroke", &itemptr); RNA_float_set_array(&itemptr, "location", location); - RNA_float_set_array(&itemptr, "mouse", mouse); + RNA_float_set_array(&itemptr, "mouse", mouse_out); RNA_boolean_set(&itemptr, "pen_flip", pen_flip); RNA_float_set(&itemptr, "pressure", pressure); - stroke->last_mouse_position[0] = mouse[0]; - stroke->last_mouse_position[1] = mouse[1]; + copy_v2_v2(stroke->last_mouse_position, mouse_out); stroke->update_step(C, stroke, &itemptr); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 3d3e86d2acb..e03c2fbfd21 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3738,7 +3738,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin) * (This allows us to ignore the GL depth buffer) * Returns 0 if the ray doesn't hit the mesh, non-zero otherwise */ -int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2]) +int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]) { ViewContext vc; Object *ob; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 0852378974e..acb906e4a91 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -65,7 +65,7 @@ void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct void free_sculptsession_deformMats(struct SculptSession *ss); /* Stroke */ -int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2]); +int sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2]); /* Undo */ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index e8aa01af6b2..d2e47427b94 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1531,7 +1531,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio { TreeElement *te; int starty, startx; - float col[4]; + float col[3]; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once -- cgit v1.2.3 From f299813bfaf4634ec29f6b5972f54fbe21dd2707 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 8 Oct 2012 07:40:57 +0000 Subject: Do not use nodeLabel() to generate new nodes' names, this is an UI func returning translated strings, which should never get into data. And it may generates dummy names in some situations (like all new Filter nodes were getting "Soften" as name (default option), better to always get "Filter" in this case!). (Note for Lockal: also checked fcurves/drivers, but those names are directly taken from RNA prop name, hence they are as UI label, translated in the current language, but not stored in data. So no problem here ;) ). --- source/blender/blenkernel/intern/node.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 8cede4f51a5..60cb1049a35 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -326,10 +326,13 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp) ntype->initfunc(ntree, node, ntemp); /* initialize the node name with the node label. - * note: do this after the initfunc so nodes get - * their data set which may be used in naming + * note: do this after the initfunc so nodes get their data set which may be used in naming * (node groups for example) */ - BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR); + /* XXX Do not use nodeLabel() here, it returns translated content, which should *only* be used + * in UI, *never* in data... + * This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler + * than adding a "no translate" flag to this func (and labelfunc() as well). */ + BLI_strncpy(node->name, node->typeinfo->name, NODE_MAXSTR); nodeUniqueName(ntree, node); ntree->update |= NTREE_UPDATE_NODES; -- cgit v1.2.3 From 9fa36b12cc6b123ca1c0f1034ab2539c09081db6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 08:28:05 +0000 Subject: style cleanup: pep8 --- .../modules/bl_i18n_utils/bl_process_msg.py | 2 +- release/scripts/modules/bpy/path.py | 4 +-- release/scripts/modules/bpy_extras/mesh_utils.py | 2 +- release/scripts/modules/bpy_types.py | 8 +++--- release/scripts/modules/bpyml.py | 2 +- release/scripts/modules/console_python.py | 4 +-- release/scripts/modules/console_shell.py | 4 +-- release/scripts/modules/rna_info.py | 4 +-- release/scripts/modules/rna_xml.py | 2 +- .../scripts/startup/bl_operators/add_mesh_torus.py | 8 +++--- release/scripts/startup/bl_operators/anim.py | 6 ++--- release/scripts/startup/bl_operators/clip.py | 14 +++++----- release/scripts/startup/bl_operators/console.py | 2 +- release/scripts/startup/bl_operators/mesh.py | 2 +- release/scripts/startup/bl_operators/object.py | 12 ++++----- .../bl_operators/screen_play_rendered_anim.py | 2 +- release/scripts/startup/bl_operators/wm.py | 6 ++--- release/scripts/startup/bl_ui/__init__.py | 4 +-- .../startup/bl_ui/properties_data_armature.py | 7 +++-- .../scripts/startup/bl_ui/properties_data_bone.py | 18 ++++++------- .../startup/bl_ui/properties_data_modifier.py | 4 +-- release/scripts/startup/bl_ui/properties_object.py | 6 ++--- .../scripts/startup/bl_ui/properties_particle.py | 31 +++++++++++----------- .../startup/bl_ui/properties_physics_cloth.py | 8 +++--- .../startup/bl_ui/properties_physics_common.py | 2 +- .../bl_ui/properties_physics_dynamicpaint.py | 7 +++-- .../startup/bl_ui/properties_physics_field.py | 7 +++-- .../startup/bl_ui/properties_physics_smoke.py | 6 ++--- .../startup/bl_ui/properties_physics_softbody.py | 6 ++--- release/scripts/startup/bl_ui/properties_render.py | 2 +- .../scripts/startup/bl_ui/properties_texture.py | 10 +++++-- release/scripts/startup/bl_ui/space_clip.py | 4 +-- release/scripts/startup/bl_ui/space_console.py | 2 +- release/scripts/startup/bl_ui/space_userpref.py | 8 +++--- .../scripts/startup/bl_ui/space_userpref_keymap.py | 4 +-- release/scripts/startup/bl_ui/space_view3d.py | 8 +++--- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 18 +++++++------ release/scripts/startup/keyingsets_builtins.py | 4 +-- 38 files changed, 123 insertions(+), 127 deletions(-) diff --git a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py index 33d3be63b0b..cf545840b6f 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_process_msg.py +++ b/release/scripts/modules/bl_i18n_utils/bl_process_msg.py @@ -298,7 +298,7 @@ def dump_messages_pytext(messages, check_ctxt): # check it has a 'text' argument for (arg_pos, (arg_kw, arg)) in enumerate(func.parameters.items()): if ((arg_kw in translate_kw) and - (arg.is_output == False) and + (arg.is_output is False) and (arg.type == 'STRING')): func_translate_args.setdefault(func_id, []).append((arg_kw, diff --git a/release/scripts/modules/bpy/path.py b/release/scripts/modules/bpy/path.py index 41fe052c434..d32b69b501c 100644 --- a/release/scripts/modules/bpy/path.py +++ b/release/scripts/modules/bpy/path.py @@ -264,8 +264,8 @@ def module_names(path, recursive=False): if recursive: for mod_name, mod_path in module_names(directory, True): modules.append(("%s.%s" % (filename, mod_name), - mod_path, - )) + mod_path, + )) return modules diff --git a/release/scripts/modules/bpy_extras/mesh_utils.py b/release/scripts/modules/bpy_extras/mesh_utils.py index ad0fe06b68b..ad3cf8c08ec 100644 --- a/release/scripts/modules/bpy_extras/mesh_utils.py +++ b/release/scripts/modules/bpy_extras/mesh_utils.py @@ -232,7 +232,7 @@ def edge_loops_from_tessfaces(mesh, tessfaces=None, seams=()): ed_adj = edges[context_loop[-1]] if len(ed_adj) != 2: # the original edge had 2 other edges - if other_dir and flipped == False: + if other_dir and flipped is False: flipped = True # only flip the list once context_loop.reverse() ed_adj[:] = [] diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 9ad9a7affc3..4cd823d9184 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -689,10 +689,10 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): files = [] for directory in searchpaths: files.extend([(f, os.path.join(directory, f)) - for f in os.listdir(directory) - if (not f.startswith(".")) - if ((filter_ext is None) or - (filter_ext(os.path.splitext(f)[1]))) + for f in os.listdir(directory) + if (not f.startswith(".")) + if ((filter_ext is None) or + (filter_ext(os.path.splitext(f)[1]))) ]) files.sort() diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py index 42d2bf94fba..e942006010b 100644 --- a/release/scripts/modules/bpyml.py +++ b/release/scripts/modules/bpyml.py @@ -160,7 +160,7 @@ if __name__ == "__main__": from bpyml_test import * draw = [ - ui()[ + ui()[ split()[ column()[ prop(data='context.scene.render', property='use_stamp_time', text='Time'), diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index 582a1c6ae14..18d448b764f 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -30,7 +30,7 @@ _BPY_MAIN_OWN = True def add_scrollback(text, text_type): for l in text.split("\n"): bpy.ops.console.scrollback_append(text=l.replace("\t", " "), - type=text_type) + type=text_type) def replace_help(namespace): @@ -195,7 +195,7 @@ def execute(context): # insert a new blank line bpy.ops.console.history_append(text="", current_character=0, - remove_duplicates=True) + remove_duplicates=True) # Insert the output into the editor # not quite correct because the order might have changed, diff --git a/release/scripts/modules/console_shell.py b/release/scripts/modules/console_shell.py index 8beff24eedb..42348f453cd 100644 --- a/release/scripts/modules/console_shell.py +++ b/release/scripts/modules/console_shell.py @@ -26,7 +26,7 @@ language_id = "shell" def add_scrollback(text, text_type): for l in text.split("\n"): bpy.ops.console.scrollback_append(text=l.replace("\t", " "), - type=text_type) + type=text_type) def shell_run(text): @@ -57,7 +57,7 @@ def execute(context): # insert a new blank line bpy.ops.console.history_append(text="", current_character=0, - remove_duplicates=True) + remove_duplicates=True) sc.prompt = os.getcwd() + PROMPT return {'FINISHED'} diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py index 0ef2ac5164d..6f4b63fc99a 100644 --- a/release/scripts/modules/rna_info.py +++ b/release/scripts/modules/rna_info.py @@ -249,7 +249,7 @@ class InfoPropertyRNA: def get_arg_default(self, force=True): default = self.default_str - if default and (force or self.is_required == False): + if default and (force or self.is_required is False): return "%s=%s" % (self.identifier, default) return self.identifier @@ -493,7 +493,7 @@ def BuildRNAInfo(): # Arrange so classes are always defined in the correct order deps_ok = False - while deps_ok == False: + while deps_ok is False: deps_ok = True rna_done = set() diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 2ea978419b9..fc8e3125228 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -250,7 +250,7 @@ def xml2rna(root_xml, if value_xml.startswith("#"): # read hexidecimal value as float array value_xml_split = value_xml[1:] - value_xml_coerce = [int(value_xml_split[i:i + 2], 16) / 255 for i in range(0, len(value_xml_split), 2)] + value_xml_coerce = [int(value_xml_split[i:i + 2], 16) / 255 for i in range(0, len(value_xml_split), 2)] del value_xml_split else: value_xml_split = value_xml.split() diff --git a/release/scripts/startup/bl_operators/add_mesh_torus.py b/release/scripts/startup/bl_operators/add_mesh_torus.py index 6c48ae72e4b..7da4d8a480d 100644 --- a/release/scripts/startup/bl_operators/add_mesh_torus.py +++ b/release/scripts/startup/bl_operators/add_mesh_torus.py @@ -49,9 +49,9 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg): angle = 2 * pi * minor_index / minor_seg vec = quat * Vector((major_rad + (cos(angle) * minor_rad), - 0.0, - (sin(angle) * minor_rad), - )) + 0.0, + (sin(angle) * minor_rad), + )) verts.extend(vec[:]) @@ -133,7 +133,7 @@ class AddTorus(Operator, object_utils.AddObjectHelper): ) def execute(self, context): - if self.use_abso == True: + if self.use_abso is True: extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5 self.major_radius = self.abso_minor_rad + extra_helper self.minor_radius = extra_helper diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index c5fc3c50f3f..902c7007fb9 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -214,7 +214,7 @@ class BakeAction(Operator): 'OBJECT' in self.bake_types, self.clear_constraints, True, - ) + ) if action is None: self.report({'INFO'}, "Nothing to bake") @@ -252,8 +252,8 @@ class ClearUselessActions(Operator): for action in bpy.data.actions: # if only user is "fake" user... - if ((self.only_unused is False) or - (action.use_fake_user and action.users == 1)): + if ((self.only_unused is False) or + (action.use_fake_user and action.users == 1)): # if it has F-Curves, then it's a "action library" # (i.e. walk, wave, jump, etc.) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index c45d2f2e702..70967a01d1c 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -57,7 +57,7 @@ def CLIP_set_viewport_background(context, all_screens, clip, clip_user): space_v3d.show_background_images = True CLIP_spaces_walk(context, all_screens, 'VIEW_3D', 'VIEW_3D', - set_background, clip, clip_user) + set_background, clip, clip_user) def CLIP_camera_for_clip(context, clip): @@ -329,7 +329,7 @@ object's movement caused by this constraint""" if not con: self.report({'ERROR'}, - "Motion Tracking constraint to be converted not found") + "Motion Tracking constraint to be converted not found") return {'CANCELLED'} @@ -341,7 +341,7 @@ object's movement caused by this constraint""" if not clip: self.report({'ERROR'}, - "Movie clip to use tracking data from isn't set") + "Movie clip to use tracking data from isn't set") return {'CANCELLED'} @@ -461,9 +461,9 @@ class CLIP_OT_setup_tracking_scene(Operator): scene.camera = camob camob.matrix_local = (Matrix.Translation((7.481, -6.508, 5.344)) * - Matrix.Rotation(0.815, 4, 'Z') * - Matrix.Rotation(0.011, 4, 'Y') * - Matrix.Rotation(1.109, 4, 'X')) + Matrix.Rotation(0.815, 4, 'Z') * + Matrix.Rotation(0.011, 4, 'Y') * + Matrix.Rotation(1.109, 4, 'X')) return camob @@ -629,7 +629,7 @@ class CLIP_OT_setup_tracking_scene(Operator): if need_stabilization: tree.links.new(distortion.outputs["Image"], - stabilize.inputs["Image"]) + stabilize.inputs["Image"]) tree.links.new(stabilize.outputs["Image"], scale.inputs["Image"]) else: tree.links.new(distortion.outputs["Image"], scale.inputs["Image"]) diff --git a/release/scripts/startup/bl_operators/console.py b/release/scripts/startup/bl_operators/console.py index fd95da02b28..307165a4d18 100644 --- a/release/scripts/startup/bl_operators/console.py +++ b/release/scripts/startup/bl_operators/console.py @@ -129,6 +129,6 @@ class ConsoleLanguage(Operator): # insert a new blank line bpy.ops.console.history_append(text="", current_character=0, - remove_duplicates=True) + remove_duplicates=True) return {'FINISHED'} diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py index 3dc25d84aca..df21349da47 100644 --- a/release/scripts/startup/bl_operators/mesh.py +++ b/release/scripts/startup/bl_operators/mesh.py @@ -92,7 +92,7 @@ class MeshMirrorUV(Operator): puvs[i] = tuple(uv.uv for uv in uv_loops[lstart:lend]) puvs_cpy[i] = tuple(uv.copy() for uv in puvs[i]) puvsel[i] = (False not in - (uv.select for uv in uv_loops[lstart:lend])) + (uv.select for uv in uv_loops[lstart:lend])) # Vert idx of the poly. vidxs[i] = tuple(l.vertex_index for l in loops[lstart:lend]) # As we have no poly.center yet... diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 5000d718182..4e90f2e8585 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -408,13 +408,13 @@ class ShapeTransfer(Operator): n2loc_to = v2_to + target_normals[i2] * edlen_to pt = barycentric_transform(orig_shape_coords[i1], - v2, v1, n1loc, - v2_to, v1_to, n1loc_to) + v2, v1, n1loc, + v2_to, v1_to, n1loc_to) median_coords[i1].append(pt) pt = barycentric_transform(orig_shape_coords[i2], - v1, v2, n2loc, - v1_to, v2_to, n2loc_to) + v1, v2, n2loc, + v1_to, v2_to, n2loc_to) median_coords[i2].append(pt) # apply the offsets to the new shape @@ -507,7 +507,7 @@ class JoinUVs(Operator): if obj_other != obj and obj_other.type == 'MESH': mesh_other = obj_other.data if mesh_other != mesh: - if mesh_other.tag == False: + if mesh_other.tag is False: mesh_other.tag = True if len(mesh_other.loops) != nbr_loops: @@ -520,7 +520,7 @@ class JoinUVs(Operator): len(mesh_other.polygons), nbr_loops, ), - ) + ) else: uv_other = mesh_other.uv_layers.active if not uv_other: diff --git a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py index 32658d353d9..694412e51d7 100644 --- a/release/scripts/startup/bl_operators/screen_play_rendered_anim.py +++ b/release/scripts/startup/bl_operators/screen_play_rendered_anim.py @@ -89,7 +89,7 @@ class PlayRenderedAnim(Operator): if player_path == "": player_path = guess_player_path(preset) - if is_movie == False and preset in {'FRAMECYCLER', 'RV', 'MPLAYER'}: + if is_movie is False and preset in {'FRAMECYCLER', 'RV', 'MPLAYER'}: # replace the number with '#' file_a = rd.frame_path(frame=0) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 21843d80742..eac90a8b091 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -608,9 +608,9 @@ class WM_OT_context_collection_boolean_set(Operator): except: continue - if value_orig == True: + if value_orig is True: is_set = True - elif value_orig == False: + elif value_orig is False: pass else: self.report({'WARNING'}, "Non boolean value found: %s[ ].%s" % @@ -1583,7 +1583,7 @@ class WM_OT_addon_enable(Operator): "version %d.%d.%d and might not " "function (correctly), " "though it is enabled") % - info_ver) + info_ver) return {'FINISHED'} else: return {'CANCELLED'} diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index 847807029fa..09d866c2ae5 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -95,7 +95,7 @@ def register(): items = [('All', "All", ""), ('Enabled', "Enabled", ""), ('Disabled', "Disabled", ""), - ] + ] items_unique = set() @@ -120,7 +120,7 @@ def register(): items=[('OFFICIAL', "Official", "Officially supported"), ('COMMUNITY', "Community", "Maintained by community developers"), ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)"), - ], + ], name="Support", description="Display support level", default={'OFFICIAL', 'COMMUNITY'}, diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index e194d7a1370..50c34be1414 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -285,10 +285,9 @@ class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel): row.prop(itasc, "damping_max", text="Damp", slider=True) row.prop(itasc, "damping_epsilon", text="Eps", slider=True) -from bl_ui.properties_animviz import ( - MotionPathButtonsPanel, - OnionSkinButtonsPanel, - ) +from bl_ui.properties_animviz import (MotionPathButtonsPanel, + OnionSkinButtonsPanel, + ) class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_data_bone.py b/release/scripts/startup/bl_ui/properties_data_bone.py index e6d9affee93..1e70483864c 100644 --- a/release/scripts/startup/bl_ui/properties_data_bone.py +++ b/release/scripts/startup/bl_ui/properties_data_bone.py @@ -251,52 +251,52 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel, Panel): split.active = pchan.is_in_ik_chain row = split.row() row.prop(pchan, "ik_stiffness_x", text="Stiffness", slider=True) - row.active = pchan.lock_ik_x == False and pchan.is_in_ik_chain + row.active = pchan.lock_ik_x is False and pchan.is_in_ik_chain split = layout.split(percentage=0.25) sub = split.row() sub.prop(pchan, "use_ik_limit_x", text="Limit") - sub.active = pchan.lock_ik_x == False and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_x is False and pchan.is_in_ik_chain sub = split.row(align=True) sub.prop(pchan, "ik_min_x", text="") sub.prop(pchan, "ik_max_x", text="") - sub.active = pchan.lock_ik_x == False and pchan.use_ik_limit_x and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_x is False and pchan.use_ik_limit_x and pchan.is_in_ik_chain split = layout.split(percentage=0.25) split.prop(pchan, "lock_ik_y", icon='LOCKED' if pchan.lock_ik_y else 'UNLOCKED', text="Y") split.active = pchan.is_in_ik_chain row = split.row() row.prop(pchan, "ik_stiffness_y", text="Stiffness", slider=True) - row.active = pchan.lock_ik_y == False and pchan.is_in_ik_chain + row.active = pchan.lock_ik_y is False and pchan.is_in_ik_chain split = layout.split(percentage=0.25) sub = split.row() sub.prop(pchan, "use_ik_limit_y", text="Limit") - sub.active = pchan.lock_ik_y == False and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_y is False and pchan.is_in_ik_chain sub = split.row(align=True) sub.prop(pchan, "ik_min_y", text="") sub.prop(pchan, "ik_max_y", text="") - sub.active = pchan.lock_ik_y == False and pchan.use_ik_limit_y and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_y is False and pchan.use_ik_limit_y and pchan.is_in_ik_chain split = layout.split(percentage=0.25) split.prop(pchan, "lock_ik_z", icon='LOCKED' if pchan.lock_ik_z else 'UNLOCKED', text="Z") split.active = pchan.is_in_ik_chain sub = split.row() sub.prop(pchan, "ik_stiffness_z", text="Stiffness", slider=True) - sub.active = pchan.lock_ik_z == False and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_z is False and pchan.is_in_ik_chain split = layout.split(percentage=0.25) sub = split.row() sub.prop(pchan, "use_ik_limit_z", text="Limit") - sub.active = pchan.lock_ik_z == False and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_z is False and pchan.is_in_ik_chain sub = split.row(align=True) sub.prop(pchan, "ik_min_z", text="") sub.prop(pchan, "ik_max_z", text="") - sub.active = pchan.lock_ik_z == False and pchan.use_ik_limit_z and pchan.is_in_ik_chain + sub.active = pchan.lock_ik_z is False and pchan.use_ik_limit_z and pchan.is_in_ik_chain split = layout.split(percentage=0.25) split.label(text="Stretch:") diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index ed390be49f5..0398cb36b18 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -397,7 +397,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = layout.column() - if md.use_mirror_merge == True: + if md.use_mirror_merge is True: col.prop(md, "merge_threshold") col.label(text="Mirror Object:") col.prop(md, "mirror_object", text="") @@ -559,7 +559,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col = split.column() row = col.row() - row.active = (md.object is None or md.use_object_screw_offset == False) + row.active = (md.object is None or md.use_object_screw_offset is False) row.prop(md, "screw_offset") row = col.row() row.active = (md.object is not None) diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index f2c631b7ab1..8a668b5d95b 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -290,10 +290,8 @@ class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel): row.prop(ob, "slow_parent_offset", text="Offset") -from bl_ui.properties_animviz import ( - MotionPathButtonsPanel, - OnionSkinButtonsPanel, - ) +from bl_ui.properties_animviz import (MotionPathButtonsPanel, + OnionSkinButtonsPanel) class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index aa0ea1d2d9e..f29589faa2d 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -21,12 +21,11 @@ import bpy from bpy.types import Panel from rna_prop_ui import PropertyPanel -from bl_ui.properties_physics_common import ( - point_cache_ui, - effector_weights_ui, - basic_force_field_settings_ui, - basic_force_field_falloff_ui, - ) +from bl_ui.properties_physics_common import (point_cache_ui, + effector_weights_ui, + basic_force_field_settings_ui, + basic_force_field_falloff_ui, + ) def particle_panel_enabled(context, psys): @@ -52,7 +51,7 @@ def particle_panel_poll(cls, context): if not settings: return False - return settings.is_fluid == False and (engine in cls.COMPAT_ENGINES) + return settings.is_fluid is False and (engine in cls.COMPAT_ENGINES) def particle_get_settings(context): @@ -133,13 +132,13 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): split = layout.split(percentage=0.32) col = split.column() col.label(text="Name:") - if part.is_fluid == False: + if part.is_fluid is False: col.label(text="Settings:") col.label(text="Type:") col = split.column() col.prop(psys, "name", text="") - if part.is_fluid == False: + if part.is_fluid is False: row = col.row() row.enabled = particle_panel_enabled(context, psys) row.template_ID(psys, "settings", new="particle.new") @@ -279,7 +278,7 @@ class PARTICLE_PT_hair_dynamics(ParticleButtonsPanel, Panel): cloth = psys.cloth.settings - layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked == False + layout.enabled = psys.use_hair_dynamics and psys.point_cache.is_baked is False split = layout.split() @@ -813,7 +812,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): sub.active = (part.use_strand_primitive is False) sub.prop(part, "use_render_adaptive") sub = col.column() - sub.active = part.use_render_adaptive or part.use_strand_primitive == True + sub.active = part.use_render_adaptive or part.use_strand_primitive is True sub.prop(part, "adaptive_angle") sub = col.column() sub.active = (part.use_render_adaptive is True and part.use_strand_primitive is False) @@ -831,9 +830,9 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): row = layout.row() col = row.column() - if part.type == 'HAIR' and part.use_strand_primitive == True and part.child_type == 'INTERPOLATED': + if part.type == 'HAIR' and part.use_strand_primitive is True and part.child_type == 'INTERPOLATED': layout.prop(part, "use_simplify") - if part.use_simplify == True: + if part.use_simplify is True: row = layout.row() row.prop(part, "simplify_refsize") row.prop(part, "simplify_rate") @@ -841,7 +840,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): row = layout.row() row.prop(part, "use_simplify_viewport") sub = row.row() - sub.active = part.use_simplify_viewport == True + sub.active = part.use_simplify_viewport is True sub.prop(part, "simplify_viewport") elif part.render_type == 'OBJECT': @@ -988,11 +987,11 @@ class PARTICLE_PT_draw(ParticleButtonsPanel, Panel): if part.draw_percentage != 100 and psys is not None: if part.type == 'HAIR': - if psys.use_hair_dynamics and psys.point_cache.is_baked == False: + if psys.use_hair_dynamics and psys.point_cache.is_baked is False: layout.row().label(text="Display percentage makes dynamics inaccurate without baking!") else: phystype = part.physics_type - if phystype != 'NO' and phystype != 'KEYED' and psys.point_cache.is_baked == False: + if phystype != 'NO' and phystype != 'KEYED' and psys.point_cache.is_baked is False: layout.row().label(text="Display percentage makes dynamics inaccurate without baking!") row = layout.row() diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index 33b977b5f04..e5db1eec37e 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -20,10 +20,8 @@ import bpy from bpy.types import Menu, Panel -from bl_ui.properties_physics_common import ( - point_cache_ui, - effector_weights_ui, - ) +from bl_ui.properties_physics_common import (point_cache_ui, + effector_weights_ui) def cloth_panel_enabled(md): @@ -178,7 +176,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): ob = context.object cloth = context.cloth.settings - layout.active = cloth.use_stiffness_scale and cloth_panel_enabled(md) + layout.active = (cloth.use_stiffness_scale and cloth_panel_enabled(md)) split = layout.split() diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py b/release/scripts/startup/bl_ui/properties_physics_common.py index 7f824d94431..00a35b233da 100644 --- a/release/scripts/startup/bl_ui/properties_physics_common.py +++ b/release/scripts/startup/bl_ui/properties_physics_common.py @@ -160,7 +160,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype): col = split.column() - if cache.is_baked == True: + if cache.is_baked is True: col.operator("ptcache.free_bake", text="Free Bake") else: col.operator("ptcache.bake", text="Bake").bake = True diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py index db0794d8a8a..fa37e9cd10f 100644 --- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py +++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py @@ -20,10 +20,9 @@ import bpy from bpy.types import Panel -from bl_ui.properties_physics_common import ( - point_cache_ui, - effector_weights_ui, - ) +from bl_ui.properties_physics_common import (point_cache_ui, + effector_weights_ui, + ) class PhysicButtonsPanel(): diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py b/release/scripts/startup/bl_ui/properties_physics_field.py index 569037cb0da..6b5612d7836 100644 --- a/release/scripts/startup/bl_ui/properties_physics_field.py +++ b/release/scripts/startup/bl_ui/properties_physics_field.py @@ -20,10 +20,9 @@ import bpy from bpy.types import Panel -from bl_ui.properties_physics_common import ( - basic_force_field_settings_ui, - basic_force_field_falloff_ui, - ) +from bl_ui.properties_physics_common import (basic_force_field_settings_ui, + basic_force_field_falloff_ui, + ) class PhysicButtonsPanel(): diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py index 1b333f1e505..acbaad4f961 100644 --- a/release/scripts/startup/bl_ui/properties_physics_smoke.py +++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py @@ -20,10 +20,8 @@ import bpy from bpy.types import Panel -from bl_ui.properties_physics_common import ( - point_cache_ui, - effector_weights_ui, - ) +from bl_ui.properties_physics_common import (point_cache_ui, + effector_weights_ui) class PhysicButtonsPanel(): diff --git a/release/scripts/startup/bl_ui/properties_physics_softbody.py b/release/scripts/startup/bl_ui/properties_physics_softbody.py index b043c1f9b68..a69e7955de5 100644 --- a/release/scripts/startup/bl_ui/properties_physics_softbody.py +++ b/release/scripts/startup/bl_ui/properties_physics_softbody.py @@ -20,10 +20,8 @@ import bpy from bpy.types import Panel -from bl_ui.properties_physics_common import ( - point_cache_ui, - effector_weights_ui, - ) +from bl_ui.properties_physics_common import (point_cache_ui, + effector_weights_ui) def softbody_panel_enabled(md): diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 74f4c719cd5..544462e1242 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -225,7 +225,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel): # TODO: Change the following to iterate over existing presets custom_framerate = (fps_rate not in {23.98, 24, 25, 29.97, 30, 50, 59.94, 60}) - if custom_framerate == True: + if custom_framerate is True: fps_label_text = "Custom (" + str(fps_rate) + " fps)" else: fps_label_text = str(fps_rate) + " fps" diff --git a/release/scripts/startup/bl_ui/properties_texture.py b/release/scripts/startup/bl_ui/properties_texture.py index 46a17675c91..9e6bfe6889e 100644 --- a/release/scripts/startup/bl_ui/properties_texture.py +++ b/release/scripts/startup/bl_ui/properties_texture.py @@ -111,8 +111,14 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel, Panel): engine = context.scene.render.engine if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")): return False - return ((context.material or context.world or context.lamp or context.brush or context.texture or context.particle_system or isinstance(context.space_data.pin_id, ParticleSettings)) - and (engine in cls.COMPAT_ENGINES)) + return ((context.material or + context.world or + context.lamp or + context.brush or + context.texture or + context.particle_system or + isinstance(context.space_data.pin_id, ParticleSettings)) and + (engine in cls.COMPAT_ENGINES)) def draw(self, context): layout = self.layout diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index b0e8a847084..7732a0c6400 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -942,7 +942,7 @@ class CLIP_MT_track(Menu): props.action = 'UPTO' props = layout.operator("clip.clear_track_path", - text="Clear Track Path") + text="Clear Track Path") props.action = 'ALL' layout.separator() @@ -957,7 +957,7 @@ class CLIP_MT_track(Menu): layout.separator() props = layout.operator("clip.track_markers", - text="Track Frame Backwards") + text="Track Frame Backwards") props.backwards = True props = layout.operator("clip.track_markers", text="Track Backwards") diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index 7ded4954f80..5ff179902a3 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -86,7 +86,7 @@ class CONSOLE_MT_language(Menu): def add_scrollback(text, text_type): for l in text.split("\n"): bpy.ops.console.scrollback_append(text=l.replace('\t', ' '), - type=text_type) + type=text_type) if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 64bf1e29348..0c3c0e5a696 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1084,10 +1084,10 @@ class USERPREF_PT_addons(Panel): continue # check if addon should be visible with current filters - if ((filter == "All") or - (filter == info["category"]) or - (filter == "Enabled" and is_enabled) or - (filter == "Disabled" and not is_enabled)): + if ((filter == "All") or + (filter == info["category"]) or + (filter == "Enabled" and is_enabled) or + (filter == "Disabled" and not is_enabled)): if search and search not in info["name"].lower(): if info["author"]: diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 6646da4a91a..da498268b9b 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -218,8 +218,8 @@ class InputKeyMapPanel: layout.context_pointer_set("keymap", km) filtered_items = [kmi for kmi in km.keymap_items - if filter_text in kmi.idname.lower() or - filter_text in kmi.name.lower()] + if (filter_text in kmi.idname.lower() or + filter_text in kmi.name.lower())] if filtered_items: col = layout.column() diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index a77c5818fca..a21d8527158 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -223,8 +223,8 @@ class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base): layout.separator() obj = context.object - if (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and - obj.data.draw_type in {'BBONE', 'ENVELOPE'}): + 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': @@ -580,7 +580,7 @@ class VIEW3D_MT_select_edit_mesh(Menu): layout.separator() layout.operator("mesh.select_by_number_vertices", text="By Number of Verts") - if context.scene.tool_settings.mesh_select_mode[2] == False: + if context.scene.tool_settings.mesh_select_mode[2] is False: layout.operator("mesh.select_non_manifold", text="Non Manifold") layout.operator("mesh.select_loose_verts", text="Loose Verts/Edges") layout.operator_menu_enum("mesh.select_similar", "type", text="Similar") @@ -2282,7 +2282,7 @@ class VIEW3D_PT_view3d_properties(Panel): if lock_object.type == 'ARMATURE': col.prop_search(view, "lock_bone", lock_object.data, "edit_bones" if lock_object.mode == 'EDIT' - else "bones", + else "bones", text="") else: col.prop(view, "lock_cursor", text="Lock to Cursor") diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 1b67b30d17a..0d939b2de78 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -520,8 +520,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row = col.row(align=True) ups = toolsettings.unified_paint_settings - if ((ups.use_unified_size and ups.use_locked_size) or - ((not ups.use_unified_size) and brush.use_locked_size)): + if ((ups.use_unified_size and ups.use_locked_size) or + ((not ups.use_unified_size) and brush.use_locked_size)): self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED') self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius") else: @@ -707,8 +707,8 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel): @classmethod def poll(cls, context): settings = cls.paint_settings(context) - return (settings and settings.brush and (context.sculpt_object or - context.image_paint_object)) + return (settings and settings.brush and + (context.sculpt_object or context.image_paint_object)) def draw(self, context): layout = self.layout @@ -747,10 +747,12 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel): @classmethod def poll(cls, context): settings = cls.paint_settings(context) - return (settings and settings.brush and (context.sculpt_object or - context.vertex_paint_object or - context.weight_paint_object or - context.image_paint_object)) + return (settings and + settings.brush and + (context.sculpt_object or + context.vertex_paint_object or + context.weight_paint_object or + context.image_paint_object)) def draw(self, context): layout = self.layout diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py index b7693880f9c..6ad87375738 100644 --- a/release/scripts/startup/keyingsets_builtins.py +++ b/release/scripts/startup/keyingsets_builtins.py @@ -360,10 +360,10 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): # add rotation properties if they will if bone.lock_rotations_4d: # can check individually - if (bone.lock_rotation == (False, False, False)) and (bone.lock_rotation_w == False): + if (bone.lock_rotation == (False, False, False)) and (bone.lock_rotation_w is False): ksi.addProp(ks, bone, prop) else: - if bone.lock_rotation_w == False: + if bone.lock_rotation_w is False: ksi.addProp(ks, bone, prop, 0) # w = 0 for i in range(3): -- cgit v1.2.3 From e91badc2666aa04af34473d71dc576afb52eec06 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 8 Oct 2012 08:44:48 +0000 Subject: Code cleanup - Convert if blocks to switch --- .../editors/space_outliner/outliner_tools.c | 44 ++++++++++++++-------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index bf76fdda61e..09df1d57b2b 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -1160,37 +1160,49 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) 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 (event <= 0) + return OPERATOR_CANCELLED; + + switch (datalevel) { + case TSE_POSE_CHANNEL: + { outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb, 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) { + break; + + case TSE_BONE: + { outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb, 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) { + break; + + case TSE_EBONE: + { outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb, 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) { + break; + + case TSE_SEQUENCE: + { Scene *scene = CTX_data_scene(C); outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb, scene); } - } - else if (datalevel == TSE_RNA_STRUCT) { - if (event == 5) { - outliner_do_data_operation(soops, datalevel, event, &soops->tree, data_select_linked_cb, C); - } + break; + + case TSE_RNA_STRUCT: + if (event == 5) { + outliner_do_data_operation(soops, datalevel, event, &soops->tree, data_select_linked_cb, C); + } + break; + + default: + break; } return OPERATOR_FINISHED; -- cgit v1.2.3 From 1487ef9828d576088eac3a792069ea95d15579af Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 09:39:35 +0000 Subject: quiet msvc warning & allow zero arguments to add functions. --- source/blender/makesrna/intern/rna_curve.c | 4 ++-- source/blender/makesrna/intern/rna_fcurve.c | 2 +- source/blender/makesrna/intern/rna_gpencil.c | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index c47cb8ef2af..8cba5899b76 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -1163,7 +1163,7 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_Curve_spline_points_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); - RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); #if 0 func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); @@ -1190,7 +1190,7 @@ static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add"); RNA_def_function_ui_description(func, "Add a number of points to this spline"); RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS); - RNA_def_int(func, "count", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); #if 0 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 24b14fdb884..d899b5833bb 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -1497,7 +1497,7 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add"); RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve"); - RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove"); RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve"); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index ae1c7fd2d5b..fffee4b61ef 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -113,12 +113,14 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) static void rna_GPencil_stroke_point_add(bGPDstroke *stroke, int count) { - if (stroke->points == NULL) - stroke->points = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points"); - else - stroke->points = MEM_reallocN(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count)); + if (count > 0) { + if (stroke->points == NULL) + stroke->points = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points"); + else + stroke->points = MEM_reallocN(stroke->points, sizeof(bGPDspoint) * (stroke->totpoints + count)); - stroke->totpoints += count; + stroke->totpoints += count; + } } static void rna_GPencil_stroke_point_pop(bGPDstroke *stroke, ReportList *reports, int index) @@ -174,12 +176,14 @@ static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, bGP static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, int frame_number) { + bGPDframe *frame; + if (BKE_gpencil_layer_find_frame(layer, frame_number)) { BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number"); return NULL; } - bGPDframe *frame = gpencil_frame_addnew(layer, frame_number); + frame = gpencil_frame_addnew(layer, frame_number); WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL); @@ -293,7 +297,7 @@ static void rna_def_gpencil_stroke_points_api(BlenderRNA *brna, PropertyRNA *cpr func = RNA_def_function(srna, "add", "rna_GPencil_stroke_point_add"); RNA_def_function_ui_description(func, "Add a new grease pencil stroke point"); - RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the stroke", 1, INT_MAX); + RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the stroke", 0, INT_MAX); func = RNA_def_function(srna, "pop", "rna_GPencil_stroke_point_pop"); RNA_def_function_ui_description(func, "Remove a grease pencil stroke point"); -- cgit v1.2.3 From 7614428c09de832df4a39038ceec4eb5e2951800 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 10:03:01 +0000 Subject: style cleanup: pep8 --- build_files/buildbot/master.cfg | 7 ++++--- build_files/buildbot/master_unpack.py | 2 +- build_files/buildbot/slave_pack.py | 6 +++--- build_files/cmake/cmake_static_check_clang_array.py | 2 +- build_files/cmake/cmake_static_check_cppcheck.py | 2 +- build_files/cmake/cmake_static_check_smatch.py | 2 +- build_files/cmake/cmake_static_check_sparse.py | 2 +- build_files/cmake/cmake_static_check_splint.py | 2 +- build_files/cmake/project_source_info.py | 2 +- doc/python_api/sphinx_doc_gen.py | 2 +- source/blender/python/rna_dump.py | 4 ++-- source/tests/batch_import.py | 12 ++++++------ source/tests/bl_load_addons.py | 2 +- source/tests/bl_load_py_modules.py | 2 +- source/tests/bl_mesh_modifiers.py | 2 +- 15 files changed, 26 insertions(+), 25 deletions(-) diff --git a/build_files/buildbot/master.cfg b/build_files/buildbot/master.cfg index 066c133d335..1bd47303b2f 100644 --- a/build_files/buildbot/master.cfg +++ b/build_files/buildbot/master.cfg @@ -28,8 +28,8 @@ c['slavePortnum'] = 9989 from buildbot.changes.svnpoller import SVNPoller c['change_source'] = SVNPoller( - 'https://svn.blender.org/svnroot/bf-blender/trunk/', - pollinterval=1200) + 'https://svn.blender.org/svnroot/bf-blender/trunk/', + pollinterval=1200) # BUILDERS # @@ -137,7 +137,8 @@ c['schedulers'] = [] # builderNames=buildernames, # periodicBuildTimer=24*60*60)) -c['schedulers'].append(timed.Nightly(name='nightly', +c['schedulers'].append(timed.Nightly( + name='nightly', builderNames=buildernames, hour=3, minute=0)) diff --git a/build_files/buildbot/master_unpack.py b/build_files/buildbot/master_unpack.py index f67bd294496..ecacf3bff6f 100644 --- a/build_files/buildbot/master_unpack.py +++ b/build_files/buildbot/master_unpack.py @@ -112,7 +112,7 @@ branch = get_branch(packagename) if platform == '': sys.stderr.write('Failed to detect platform ' + - 'from package: %r\n' % packagename) + 'from package: %r\n' % packagename) sys.exit(1) # extract diff --git a/build_files/buildbot/slave_pack.py b/build_files/buildbot/slave_pack.py index 654efd72876..eafb25ac7b0 100644 --- a/build_files/buildbot/slave_pack.py +++ b/build_files/buildbot/slave_pack.py @@ -50,9 +50,9 @@ if builder.find('scons') != -1: install_dir = os.path.join('..', 'install', builder) scons_options += ['WITH_BF_NOBLENDER=True', 'WITH_BF_PLAYER=False', - 'BF_BUILDDIR=' + build_dir, - 'BF_INSTALLDIR=' + install_dir, - 'WITHOUT_BF_INSTALL=True'] + 'BF_BUILDDIR=' + build_dir, + 'BF_INSTALLDIR=' + install_dir, + 'WITHOUT_BF_INSTALL=True'] config = None bits = None diff --git a/build_files/cmake/cmake_static_check_clang_array.py b/build_files/cmake/cmake_static_check_clang_array.py index 8afaf0805f2..941407170ff 100644 --- a/build_files/cmake/cmake_static_check_clang_array.py +++ b/build_files/cmake/cmake_static_check_clang_array.py @@ -52,7 +52,7 @@ def main(): [c] + [("-I%s" % i) for i in inc_dirs] + [("-D%s" % d) for d in defs] - ) + ) check_commands.append((c, cmd)) diff --git a/build_files/cmake/cmake_static_check_cppcheck.py b/build_files/cmake/cmake_static_check_cppcheck.py index 4ea357162ca..c458e8ede11 100644 --- a/build_files/cmake/cmake_static_check_cppcheck.py +++ b/build_files/cmake/cmake_static_check_cppcheck.py @@ -55,7 +55,7 @@ def main(): [c] + [("-I%s" % i) for i in inc_dirs] + [("-D%s" % d) for d in defs] - ) + ) check_commands.append((c, cmd)) diff --git a/build_files/cmake/cmake_static_check_smatch.py b/build_files/cmake/cmake_static_check_smatch.py index eebb2e94f93..5681d2ae5ed 100644 --- a/build_files/cmake/cmake_static_check_smatch.py +++ b/build_files/cmake/cmake_static_check_smatch.py @@ -50,7 +50,7 @@ def main(): [c] + [("-I%s" % i) for i in inc_dirs] + [("-D%s" % d) for d in defs] - ) + ) check_commands.append((c, cmd)) diff --git a/build_files/cmake/cmake_static_check_sparse.py b/build_files/cmake/cmake_static_check_sparse.py index 8862fc78bb5..4f4eb838dd5 100644 --- a/build_files/cmake/cmake_static_check_sparse.py +++ b/build_files/cmake/cmake_static_check_sparse.py @@ -48,7 +48,7 @@ def main(): [c] + [("-I%s" % i) for i in inc_dirs] + [("-D%s" % d) for d in defs] - ) + ) check_commands.append((c, cmd)) diff --git a/build_files/cmake/cmake_static_check_splint.py b/build_files/cmake/cmake_static_check_splint.py index b753a6122cd..7be28c01af8 100644 --- a/build_files/cmake/cmake_static_check_splint.py +++ b/build_files/cmake/cmake_static_check_splint.py @@ -80,7 +80,7 @@ def main(): [c] + [("-I%s" % i) for i in inc_dirs] + [("-D%s" % d) for d in defs] - ) + ) check_commands.append((c, cmd)) diff --git a/build_files/cmake/project_source_info.py b/build_files/cmake/project_source_info.py index ed17ec5bac4..17a9327a358 100644 --- a/build_files/cmake/project_source_info.py +++ b/build_files/cmake/project_source_info.py @@ -85,7 +85,7 @@ def makefile_log(): print("running make with --dry-run ...") process = subprocess.Popen(["make", "--always-make", "--dry-run", "--keep-going", "VERBOSE=1"], stdout=subprocess.PIPE, - ) + ) while process.poll(): time.sleep(1) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 186f67b0df6..0e6ef764116 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -399,7 +399,7 @@ SPHINX_THEMES = {'bf': ['blender-org'], # , 'naiad', available_themes = SPHINX_THEMES['bf'] + SPHINX_THEMES['sphinx'] if ARGS.sphinx_theme not in available_themes: - print ("Please choose a theme among: %s" % ', '.join(available_themes)) + print("Please choose a theme among: %s" % ', '.join(available_themes)) sys.exit() if ARGS.sphinx_theme in SPHINX_THEMES['bf']: diff --git a/source/blender/python/rna_dump.py b/source/blender/python/rna_dump.py index 489f011e693..15cc60d997e 100644 --- a/source/blender/python/rna_dump.py +++ b/source/blender/python/rna_dump.py @@ -95,7 +95,7 @@ def seek(r, txt, recurs): if GEN_PATH: newtxt = txt + '.' + item - if item == 'rna_type' and VERBOSE_TYPE == False: # just avoid because it spits out loads of data + if item == 'rna_type' and VERBOSE_TYPE is False: # just avoid because it spits out loads of data continue value = getattr(r, item, None) @@ -114,7 +114,7 @@ def seek(r, txt, recurs): except: length = 0 - if VERBOSE == False and length >= 4: + if VERBOSE is False and length >= 4: for i in (0, length - 1): if i > 0: if PRINT_DATA: diff --git a/source/tests/batch_import.py b/source/tests/batch_import.py index 5c228c014ca..177ab8ea0b0 100644 --- a/source/tests/batch_import.py +++ b/source/tests/batch_import.py @@ -63,12 +63,12 @@ def clear_scene(): def batch_import(operator="", - path="", - save_path="", - match="", - start=0, - end=sys.maxsize, - ): + path="", + save_path="", + match="", + start=0, + end=sys.maxsize, + ): import addon_utils _reset_all = addon_utils.reset_all # XXX, hack diff --git a/source/tests/bl_load_addons.py b/source/tests/bl_load_addons.py index 21a0101d684..5d9ac750362 100644 --- a/source/tests/bl_load_addons.py +++ b/source/tests/bl_load_addons.py @@ -36,7 +36,7 @@ def reload_addons(do_reload=True, do_reverse=True): for mod_name in list(addons.keys()): addon_utils.disable(mod_name) - assert(bool(addons) == False) + assert(bool(addons) is False) # Run twice each time. for i in (0, 1): diff --git a/source/tests/bl_load_py_modules.py b/source/tests/bl_load_py_modules.py index 619cad67cb8..b634b4c4385 100644 --- a/source/tests/bl_load_py_modules.py +++ b/source/tests/bl_load_py_modules.py @@ -49,7 +49,7 @@ def load_addons(): for mod_name in list(addons.keys()): addon_utils.disable(mod_name) - assert(bool(addons) == False) + assert(bool(addons) is False) for mod in modules: mod_name = mod.__name__ diff --git a/source/tests/bl_mesh_modifiers.py b/source/tests/bl_mesh_modifiers.py index 390679800f6..92fae25df16 100644 --- a/source/tests/bl_mesh_modifiers.py +++ b/source/tests/bl_mesh_modifiers.py @@ -846,7 +846,7 @@ if __name__ == "__main__": @persistent def load_handler(dummy): print("Load Handler:", bpy.data.filepath) - if load_handler.first == False: + if load_handler.first is False: bpy.app.handlers.scene_update_post.remove(load_handler) try: main() -- cgit v1.2.3 From 5b14ce7218e0929d412f7daa4627390bb76de0fc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 10:04:36 +0000 Subject: update to ubuntu theme --- .../presets/interface_theme/ubuntu_ambiance.xml | 214 ++++++++++----------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml index d54766ec88f..cc02d2e5c84 100644 --- a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml +++ b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml @@ -1,47 +1,47 @@ - + wire="#93237f"> @@ -71,7 +71,7 @@ - @@ -109,14 +109,14 @@ - + + view_sliders="#9c9c9c"> + list_text="#e2e2e2" + list_text_hi="#f47421" + list_title="#ffffff"> @@ -175,8 +175,8 @@ selected_file="#6b395a" tiles="#3c3b37"> - + list_text="#e2e2e2" + list_text_hi="#f47421" + list_title="#ffffff"> @@ -265,7 +265,7 @@ vertex_size="3"> + back="#29001b"> @@ -333,7 +333,7 @@ view_sliders="#969696"> - + syntax_numbers="#972144" + syntax_string="#6e00ff"> @@ -532,13 +532,13 @@ + text="#dddddd" + text_sel="#dddddd"> @@ -574,7 +574,7 @@ shadetop="20" show_shaded="TRUE" text="#dfdbcf" - text_sel="#fffbed"> + text_sel="#f47421"> @@ -615,7 +615,7 @@ shadetop="25" show_shaded="FALSE" text="#dddddd" - text_sel="#fff7fb"> + text_sel="#ffffff"> @@ -627,7 +627,7 @@ shadetop="5" show_shaded="TRUE" text="#dfdbcf" - text_sel="#ffffff"> + text_sel="#dfdbcf"> @@ -639,16 +639,16 @@ shadetop="21" show_shaded="TRUE" text="#dfdfdf" - text_sel="#ffffff"> + text_sel="#dfdfdf"> - @@ -685,7 +685,7 @@ shadetop="-10" show_shaded="TRUE" text="#dfdbcf" - text_sel="#fffaec"> + text_sel="#ffffff"> @@ -721,7 +721,7 @@ shadetop="25" show_shaded="FALSE" text="#ffffff" - text_sel="#ffffff"> + text_sel="#ff5d0d"> -- cgit v1.2.3 From 5a721a40717576b55c676160e0820e61a637abff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 10:19:59 +0000 Subject: speaker and empty where hardly visible --- release/scripts/presets/interface_theme/ubuntu_ambiance.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml index cc02d2e5c84..05075f06239 100644 --- a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml +++ b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml @@ -21,7 +21,7 @@ edge_select="#f47421" edge_sharp="#ff4c00" edge_facesel="#4b4b4b" - empty="#000000" + empty="#93237f" face="#75757512" extra_face_angle="#002000" extra_face_area="#0059ee" @@ -44,7 +44,7 @@ outline_width="2" panel="#a5a5a57f" skin_root="#000000" - speaker="#000000" + speaker="#93237f" transform="#ffffff" handle_vect="#409030" handle_sel_vect="#82c036" -- cgit v1.2.3 From ea3db4a71ae8e88635ad042222eb318a2dabc682 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Oct 2012 10:50:18 +0000 Subject: resize info header (was too much white space) --- release/datafiles/startup.blend | Bin 405076 -> 405076 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/release/datafiles/startup.blend b/release/datafiles/startup.blend index 3db58b8fb69..8b0e052fad8 100644 Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ -- cgit v1.2.3 From 10547d4c67388b909d6def623bca82d19b751880 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 8 Oct 2012 11:02:11 +0000 Subject: Allow user config files in qtcreator project. The blender.config file used for local #defines in qtcreator projects is rewritten on every project update. To avoid losing user settings these can now be written to an optional blender_custom.config file, which is then merged into the main blender.config on updates. --- build_files/cmake/cmake_qtcreator_project.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index 32d20489e6a..c0a5b34318f 100755 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -105,7 +105,14 @@ def create_qtc_project_main(): qtc_cfg = os.path.join(PROJECT_DIR, "%s.config" % FILE_NAME) f = open(qtc_cfg, 'w') - f.write("// ADD PREDEFINED MACROS HERE!\n") + f.write("// ADD PREDEFINED MACROS TO %s_custom.config!\n" % FILE_NAME) + qtc_custom_cfg = os.path.join(PROJECT_DIR, "%s_custom.config" % FILE_NAME) + if os.path.exists(qtc_custom_cfg): + f.write(fc.read()) + fc = open(qtc_custom_cfg, 'r') + f.write(fc.read()) + fc.close() + f.write("\n") defines_final = [("#define %s %s" % (item[0], quote_define(item[1]))) for item in defines] if sys.platform != "win32": defines_final += cmake_compiler_defines() -- cgit v1.2.3 From db54caf430071090b9e3bfa86deba778166447ef Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Oct 2012 11:48:51 +0000 Subject: Fix #32800: Cycles viewport incredible slow with high number of tiles Final rendering is clamping tile resolution if it's too small, which was missing for viewport --- source/blender/editors/space_view3d/view3d_draw.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index c6bcbfbf50d..c5246b1ad1f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2856,6 +2856,12 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw engine->tile_x = ceil(ar->winx / (float)scene->r.xparts); engine->tile_y = ceil(ar->winy / (float)scene->r.yparts); + /* clamp small tile sizes to prevent inefficient threading utilization + * the same happens for final renders as well + */ + engine->tile_x = MAX2(engine->tile_x, 64); + engine->tile_y = MAX2(engine->tile_x, 64); + type->view_update(engine, C); rv3d->render_engine = engine; -- cgit v1.2.3 From 5a9bb39e34ec7938599e6ece30198b359cf47187 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 8 Oct 2012 12:02:55 +0000 Subject: Fix for own commit r51178, duplicate line. --- build_files/cmake/cmake_qtcreator_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py index c0a5b34318f..83ea761e2d1 100755 --- a/build_files/cmake/cmake_qtcreator_project.py +++ b/build_files/cmake/cmake_qtcreator_project.py @@ -108,7 +108,6 @@ def create_qtc_project_main(): f.write("// ADD PREDEFINED MACROS TO %s_custom.config!\n" % FILE_NAME) qtc_custom_cfg = os.path.join(PROJECT_DIR, "%s_custom.config" % FILE_NAME) if os.path.exists(qtc_custom_cfg): - f.write(fc.read()) fc = open(qtc_custom_cfg, 'r') f.write(fc.read()) fc.close() -- cgit v1.2.3 From 6a82b985c30f783fcd927d1044b32a1c9253da35 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 8 Oct 2012 12:15:18 +0000 Subject: Fix #32815: cycles environment render as lamp crash with resolution >= 1024. --- intern/cycles/render/light.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 5c1737bd60a..d77516a1b18 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -68,20 +68,15 @@ static void dump_background_pixels(Device *device, DeviceScene *dscene, int res, main_task.shader_w = width*height; /* disabled splitting for now, there's an issue with multi-GPU mem_copy_from */ -#if 0 list split_tasks; main_task.split_max_size(split_tasks, 128*128); foreach(DeviceTask& task, split_tasks) { device->task_add(task); device->task_wait(); + device->mem_copy_from(d_output, task.shader_x, 1, task.shader_w, sizeof(float4)); } -#else - device->task_add(main_task); - device->task_wait(); -#endif - device->mem_copy_from(d_output, 0, 1, d_output.size(), sizeof(float4)); device->mem_free(d_input); device->mem_free(d_output); -- cgit v1.2.3 From 4a5f09fc6556746a7eb209c60e9259fdec37dcad Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Oct 2012 12:58:37 +0000 Subject: Fix #32795: Memory leak when rendering to video file --- source/blender/render/intern/source/pipeline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index b64a6b85ef7..1859de0039d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2117,6 +2117,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* note; the way it gets 32 bits rects is weak... */ if (ibuf->rect == NULL) { ibuf->rect = MEM_mapallocN(sizeof(int) * rres.rectx * rres.recty, "temp 32 bits rect"); + ibuf->mall |= IB_rect; RE_ResultGet32(re, ibuf->rect); do_free = TRUE; } @@ -2130,6 +2131,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie if (do_free) { MEM_freeN(ibuf->rect); ibuf->rect = NULL; + ibuf->mall &= ~IB_rect; } /* imbuf knows which rects are not part of ibuf */ -- cgit v1.2.3 From 018195ffae81099aafe99b26607688d3aef7c977 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 8 Oct 2012 12:59:12 +0000 Subject: fix:[#32784] Crash when Exporting to Collada file (.dae) (was a utf8-character conversion problem) --- source/blender/collada/DocumentExporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 7683ec1e9cd..bd7ad16dabd 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -160,7 +160,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce) clear_global_id_map(); COLLADABU::NativeString native_filename = - COLLADABU::NativeString(std::string(this->export_settings->filepath)); + COLLADABU::NativeString(std::string(this->export_settings->filepath), COLLADABU::NativeString::ENCODING_UTF8); COLLADASW::StreamWriter sw(native_filename); fprintf(stdout, "Collada export: %s\n", this->export_settings->filepath); -- cgit v1.2.3 From 82310c2f596972bc91a9ce192ae5f4bf43d4a625 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Oct 2012 13:57:49 +0000 Subject: committing 'a' to merge into the tag --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 56dfdf404f8..741a001142f 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,7 +51,7 @@ extern "C" { /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR +#define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ #define BLENDER_VERSION_CYCLE alpha -- cgit v1.2.3 From de6e47ab3dbe46f1d5ba3e1eef27f14c5b9ccccb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Oct 2012 17:41:27 +0000 Subject: Correction to zoom-t-mouse formula which was broken since view2d drag zoom refactoring --- source/blender/editors/interface/view2d_ops.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 5ac20829480..eb2f6c62351 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -849,8 +849,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dx) - (mval_faci * dx); - v2d->cur.xmin += ofs - dx; - v2d->cur.xmax += ofs + dx; + v2d->cur.xmin -= ofs + dx; + v2d->cur.xmax -= ofs - dx; } else { v2d->cur.xmin -= dx; @@ -868,8 +868,8 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op) float mval_faci = 1.0f - mval_fac; float ofs = (mval_fac * dy) - (mval_faci * dy); - v2d->cur.ymin += ofs - dy; - v2d->cur.ymax += ofs + dy; + v2d->cur.ymin -= ofs + dy; + v2d->cur.ymax -= ofs - dy; } else { v2d->cur.ymin -= dy; @@ -1045,13 +1045,13 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* set transform amount, and add current deltas to stored total delta (for redo) */ if (U.uiflag & USER_ZOOM_INVERT) { - RNA_float_set(op->ptr, "deltax", -dx); - RNA_float_set(op->ptr, "deltay", -dy); - } - else { - RNA_float_set(op->ptr, "deltax", dx); - RNA_float_set(op->ptr, "deltay", dy); + dx *= -1; + dy *= -1; } + + RNA_float_set(op->ptr, "deltax", dx); + RNA_float_set(op->ptr, "deltay", dy); + vzd->dx += dx; vzd->dy += dy; -- cgit v1.2.3 From 1d6dff7e344f54b1bff6cf9064c6b96ce1d0aacb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 8 Oct 2012 20:01:36 +0000 Subject: Some minor fixes about curves' tilt... --- source/blender/editors/transform/transform.c | 7 +++++-- source/blender/editors/transform/transform_ops.c | 16 +++++++++++----- source/blender/makesrna/intern/rna_curve.c | 4 ++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index be4e580de01..ef32829a71e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -4037,12 +4037,15 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c); - sprintf(str, "Tilt: %s %s", &c[0], t->proptext); + sprintf(str, "Tilt: %s° %s", &c[0], t->proptext); final = DEG2RADF(final); + + /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */ + t->values[0] = final; } else { - sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext); + sprintf(str, "Tilt: %.2f° %s", RAD2DEGF(final), t->proptext); } for (i = 0; i < t->total; i++, td++) { diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 81a4c082dcc..6cc5f19e731 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -605,8 +605,10 @@ static void TRANSFORM_OT_trackball(struct wmOperatorType *ot) static void TRANSFORM_OT_rotate(struct wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ - ot->name = "Rotate"; + ot->name = "Rotate"; ot->description = "Rotate selected items"; ot->idname = OP_ROTATION; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; @@ -618,15 +620,18 @@ static void TRANSFORM_OT_rotate(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_screenactive; - RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); + prop = RNA_def_float(ot->srna, "value", 0.0f, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); + RNA_def_property_subtype(prop, PROP_ANGLE); Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP); } static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ - ot->name = "Tilt"; + ot->name = "Tilt"; /* optionals - * "Tilt selected vertices" * "Specify an extra axis rotation for selected vertices of 3d curve" */ @@ -641,9 +646,10 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) ot->cancel = transform_cancel; ot->poll = ED_operator_editcurve_3d; - RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); + prop = RNA_def_float(ot->srna, "value", 0.0, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2); + RNA_def_property_subtype(prop, PROP_ANGLE); - Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_SNAP); + Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP); } static void TRANSFORM_OT_warp(struct wmOperatorType *ot) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 8cba5899b76..b42fb0664f8 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -721,7 +721,7 @@ static void rna_def_bpoint(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Number values */ - prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View"); @@ -808,7 +808,7 @@ static void rna_def_beztriple(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_update_points"); /* Number values */ - prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "alfa"); /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/ RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View"); -- cgit v1.2.3 From bfadb9c27259b1160696de6381c23f2ad06e9751 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 8 Oct 2012 20:25:07 +0000 Subject: Minor UI messages typo fixes. --- source/blender/editors/space_action/action_edit.c | 2 +- source/blender/editors/space_graph/graph_edit.c | 4 ++-- source/blender/makesrna/intern/rna_particle.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 3865234a25d..39922904da3 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1480,7 +1480,7 @@ static EnumPropertyItem prop_actkeys_mirror_types[] = { {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", "Flip times of selected keyframes using the current frame as the mirror line"}, {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", - "Flip values of selected keyframes (i.e. negative values become positive, and vica versa)"}, + "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"}, {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", "Flip times of selected keyframes using the first selected marker as the reference point"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index bff64f8348f..15ad590b5d4 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1941,11 +1941,11 @@ static EnumPropertyItem prop_graphkeys_mirror_types[] = { {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", "Flip times of selected keyframes using the current frame as the mirror line"}, {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", - "Flip values of selectd keyframes using the cursor value (Y/Horizontal component) as the mirror line"}, + "Flip values of selected keyframes using the cursor value (Y/Horizontal component) as the mirror line"}, {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", "Flip times of selected keyframes, effectively reversing the order they appear in"}, {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", - "Flip values of selected keyframes (i.e. negative values become positive, and vica versa)"}, + "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"}, {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", "Flip times of selected keyframes using the first selected marker as the reference point"}, {0, NULL, 0, NULL, NULL} diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 89638389fd2..363d2dc020a 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -2135,7 +2135,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_float_default(prop, 0.2); RNA_def_property_ui_text(prop, "Adaptive Subframe Threshold", "The relative distance a particle can move before requiring more subframes " - "(target Courant number); 0.1-0.3 is the recommended range"); + "(target current number); 0.1-0.3 is the recommended range"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop = RNA_def_property(srna, "jitter_factor", PROP_FLOAT, PROP_NONE); -- cgit v1.2.3 From 6536e2d01a264986cfbfd7fe351e524bb9d778c6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 8 Oct 2012 21:03:35 +0000 Subject: And more UI messages fixes... --- source/blender/editors/object/object_transform.c | 8 +++++--- source/blender/editors/screen/area.c | 2 +- source/blender/editors/space_action/action_edit.c | 2 +- source/blender/editors/space_graph/graph_edit.c | 2 +- source/blender/editors/space_text/text_ops.c | 2 +- source/blender/editors/transform/transform_ops.c | 4 ++-- source/blender/makesrna/intern/rna_gpencil.c | 6 +++--- source/blender/makesrna/intern/rna_object_force.c | 2 +- source/blender/makesrna/intern/rna_space.c | 2 +- source/blender/makesrna/intern/rna_texture.c | 2 +- 10 files changed, 17 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 9129d651d4d..1b08235b75c 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -962,8 +962,10 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) { static EnumPropertyItem prop_set_center_types[] = { {GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"}, - {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"}, - {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"}, + {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", + "Move object origin to center of object geometry"}, + {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", + "Move object origin to position of the 3D cursor"}, {0, NULL, 0, NULL, NULL} }; @@ -975,7 +977,7 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Origin"; - ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3d cursor"; + ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3D cursor"; ot->idname = "OBJECT_OT_origin_set"; /* api callbacks */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7c377a041e7..ad9b0f61eb1 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1526,7 +1526,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) but = uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, editortype_pup(), xco, yco, UI_UNIT_X + 10, UI_UNIT_Y, &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, - TIP_("Display current editor type (click for menu of available types)")); + TIP_("Display current editor type (click for a menu of available types)")); uiButSetFunc(but, spacefunc, NULL, NULL); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 39922904da3..cd036d7cb50 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1372,7 +1372,7 @@ static EnumPropertyItem prop_actkeys_snap_types[] = { {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", "Snap selected keyframes to the current frame"}, {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", - "Snap selected keyframes to the nearest (whole) frame. Use to fix accidental sub-frame offsets"}, + "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame offsets)"}, {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", "Snap selected keyframes to the nearest second"}, {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 15ad590b5d4..c5fa64d3a70 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1829,7 +1829,7 @@ static EnumPropertyItem prop_graphkeys_snap_types[] = { {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", "Set values of selected keyframes to the cursor value (Y/Horizontal component)"}, {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", - "Snap selected keyframes to the nearest (whole) frame. Use to fix accidental sub-frame offsets"}, + "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame offsets)"}, {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", "Snap selected keyframes to the nearest second"}, {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 75b8e2f218d..b2fb16ff7fe 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3352,7 +3352,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot) /* identifiers */ ot->name = "To 3D Object"; ot->idname = "TEXT_OT_to_3d_object"; - ot->description = "Create 3d text object from active text data block"; + ot->description = "Create 3D text object from active text data block"; /* api callbacks */ ot->exec = text_to_3d_object_exec; diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 6cc5f19e731..fc0c174a525 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -634,8 +634,8 @@ static void TRANSFORM_OT_tilt(struct wmOperatorType *ot) ot->name = "Tilt"; /* optionals - * "Tilt selected vertices" - * "Specify an extra axis rotation for selected vertices of 3d curve" */ - ot->description = "Tilt selected control vertices of 3d curve"; + * "Specify an extra axis rotation for selected vertices of 3D curve" */ + ot->description = "Tilt selected control vertices of 3D curve"; ot->idname = OP_TILT; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index fffee4b61ef..b0fcfb9b540 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -312,9 +312,9 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) static EnumPropertyItem stroke_draw_mode_items[] = { {0, "SCREEN", 0, "Screen", "Stroke is in screen-space"}, - {GP_STROKE_3DSPACE, "3DSPACE", 0, "3d Space", "Stroke is in 3d-space"}, - {GP_STROKE_2DSPACE, "2DSPACE", 0, "2d Space", "stroke is in 2d-space"}, - {GP_STROKE_2DIMAGE, "2DIMAGE", 0, "2d Image", "Stroke is in 2d-space (but with special 'image' scaling)"}, + {GP_STROKE_3DSPACE, "3DSPACE", 0, "3D Space", "Stroke is in 3D-space"}, + {GP_STROKE_2DSPACE, "2DSPACE", 0, "2D Space", "Stroke is in 2D-space"}, + {GP_STROKE_2DIMAGE, "2DIMAGE", 0, "2D Image", "Stroke is in 2D-space (but with special 'image' scaling)"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 1c896133408..39f85ebc742 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -1307,7 +1307,7 @@ static void rna_def_field(BlenderRNA *brna) prop = RNA_def_property(srna, "use_2d_force", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_TEX_2D); - RNA_def_property_ui_text(prop, "2D", "Apply force only in 2d"); + RNA_def_property_ui_text(prop, "2D", "Apply force only in 2D"); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); prop = RNA_def_property(srna, "use_root_coords", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index ff5f4988cc1..bfd0f731626 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1324,7 +1324,7 @@ static void rna_def_background_image(BlenderRNA *brna) srna = RNA_def_struct(brna, "BackgroundImage", NULL); RNA_def_struct_sdna(srna, "BGpic"); - RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3d View background"); + RNA_def_struct_ui_text(srna, "Background Image", "Image and settings for display in the 3D View background"); prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "source"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 45e3d15b9be..202c53cb75d 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -71,7 +71,7 @@ EnumPropertyItem texture_type_items[] = { {TEX_POINTDENSITY, "POINT_DENSITY", ICON_TEXTURE, "Point Density", ""}, {TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", "Procedural - create a fractal noise texture"}, {TEX_VORONOI, "VORONOI", ICON_TEXTURE, "Voronoi", "Procedural - create cell-like patterns based on Worley noise"}, - {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3d texture based on volumetric data"}, + {TEX_VOXELDATA, "VOXEL_DATA", ICON_TEXTURE, "Voxel Data", "Create a 3D texture based on volumetric data"}, {TEX_WOOD, "WOOD", ICON_TEXTURE, "Wood", "Procedural - wave generated bands or rings, with optional noise"}, {TEX_OCEAN, "OCEAN", ICON_TEXTURE, "Ocean", "Use a texture generated by an Ocean modifier"}, {0, NULL, 0, NULL, NULL} -- cgit v1.2.3 From a2a9b6b9a3287a59139f1c371731e9b19e71f686 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 9 Oct 2012 00:59:40 +0000 Subject: Made the autokeying warning optional by adding a user pref for this By default, this is enabled, so that newbie users who are most likely to be caught short by this will get the benefits of this option, while seasoned animators are likely to know where to go to turn things off (i.e. the scratch- an-itch urge is quite a powerful motivating force...) --- release/scripts/startup/bl_ui/space_userpref.py | 1 + source/blender/editors/transform/transform.c | 8 +++++--- source/blender/makesdna/DNA_userdef_types.h | 1 + source/blender/makesrna/intern/rna_userdef.c | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 0c3c0e5a696..df30c3ee9ae 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -324,6 +324,7 @@ class USERPREF_PT_edit(Panel): col.separator() col.prop(edit, "use_auto_keying", text="Auto Keyframing:") + col.prop(edit, "use_auto_keying_warning") sub = col.column() diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ef32829a71e..2fe68b20806 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1617,9 +1617,11 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo Object *ob = OBACT; /* draw autokeyframing hint in the corner */ - if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { - drawAutoKeyWarning(t, ar); - } + if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) { + if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { + drawAutoKeyWarning(t, ar); + } + } } void saveTransform(bContext *C, TransInfo *t, wmOperator *op) diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 218027209a8..4c196a15db1 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -544,6 +544,7 @@ extern UserDef U; /* from blenkernel blender.c */ /* toolsettings->autokey_flag */ #define AUTOKEY_FLAG_ONLYKEYINGSET (1<<6) +#define AUTOKEY_FLAG_NOWARNING (1<<7) #define ANIMRECORD_FLAG_WITHNLA (1<<10) /* transopts */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9c989121aa4..e1cf7a13f59 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2745,6 +2745,11 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTAVAIL); RNA_def_property_ui_text(prop, "Auto Keyframe Insert Available", "Automatic keyframe insertion in available F-Curves"); + + prop = RNA_def_property(srna, "use_auto_keying_warning", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_NOWARNING); + RNA_def_property_ui_text(prop, "Show Auto Keying Warning", + "Show warning indicators when transforming Object and Bones if Auto Keying is enabled"); /* keyframing settings */ prop = RNA_def_property(srna, "use_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3 From acf3a2790e82f5b3e1eee768dd084af0eac60285 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 01:07:08 +0000 Subject: api changelog for 2.64 and 2.63 (which I missed last release) --- doc/python_api/rst/change_log.rst | 1499 ++++++++++++++++++++++++++++++++ doc/python_api/sphinx_changelog_gen.py | 13 +- 2 files changed, 1507 insertions(+), 5 deletions(-) diff --git a/doc/python_api/rst/change_log.rst b/doc/python_api/rst/change_log.rst index 4d8f9a5171e..c1f3c2e4267 100644 --- a/doc/python_api/rst/change_log.rst +++ b/doc/python_api/rst/change_log.rst @@ -2397,3 +2397,1502 @@ Removed * **ffmpeg_packetsize** * **ffmpeg_video_bitrate** +2.62 to 2.63 +============ + +bpy.types.ThemeView3D +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeView3D.camera` +* :class:`bpy.types.ThemeView3D.empty` + +bpy.types.KeyingSet +------------------- + +Added +^^^^^ + +* :class:`bpy.types.KeyingSet.bl_description` +* :class:`bpy.types.KeyingSet.bl_idname` + +Renamed +^^^^^^^ + +* **name** -> :class:`bpy.types.KeyingSet.bl_label` + +bpy.types.BlendDataScenes +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendDataScenes.tag` + +bpy.types.RenderEngine +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.RenderEngine.camera_override` + +bpy.types.BackgroundImage +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BackgroundImage.show_on_foreground` + +bpy.types.CyclesRenderSettings +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.CyclesRenderSettings.preview_active_layer` +* :class:`bpy.types.CyclesRenderSettings.sample_clamp` + +bpy.types.ToolSettings +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.ToolSettings.double_threshold` + +bpy.types.Image +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Image.render_slot` + +bpy.types.MovieTrackingStabilization +------------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.MovieTrackingStabilization.filter_type` + +bpy.types.DomainFluidSettings +----------------------------- + +Removed +^^^^^^^ + +* **viscosity_preset** + +bpy.types.ParticleSettings +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ParticleSettings.use_rotations` + +bpy.types.SceneGameData +----------------------- + +Renamed +^^^^^^^ + +* **dome_tesselation** -> :class:`bpy.types.SceneGameData.dome_tessellation` + +bpy.types.RegionView3D +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.RegionView3D.update` + +bpy.types.Scene +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Scene.active_layer` + +bpy.types.ShaderNodeTexEnvironment +---------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodeTexEnvironment.projection` + +bpy.types.UserPreferencesEdit +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesEdit.fcurve_unselected_alpha` + +bpy.types.MeshTextureFace +------------------------- + +Removed +^^^^^^^ + +* **pin_uv** +* **select_uv** + +bpy.types.Menu +-------------- + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.Menu.path_menu` (self, searchpaths, operator, props_default, filter_ext), *was (self, searchpaths, operator, props_default)* + +bpy.types.CompositorNodeDistanceMatte +------------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeDistanceMatte.channel` + +bpy.types.KeyingSetInfo +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.KeyingSetInfo.bl_description` + +bpy.types.KeyingSets +-------------------- + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.KeyingSets.new` (idname, name), *was (name)* + +bpy.types.CompositorNodeOutputFile +---------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeOutputFile.active_input` +* :class:`bpy.types.CompositorNodeOutputFile.active_input_index` +* :class:`bpy.types.CompositorNodeOutputFile.base_path` + +Removed +^^^^^^^ + +* **filepath** +* **frame_end** +* **frame_start** + +Renamed +^^^^^^^ + +* **image_settings** -> :class:`bpy.types.CompositorNodeOutputFile.format` + +bpy.types.CyclesCameraSettings +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.CyclesCameraSettings.aperture_fstop` +* :class:`bpy.types.CyclesCameraSettings.aperture_type` + +bpy.types.Struct +---------------- + +Added +^^^^^ + +* :class:`bpy.types.Struct.translation_context` + +bpy.types.ThemeSequenceEditor +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeSequenceEditor.movieclip_strip` +* :class:`bpy.types.ThemeSequenceEditor.preview_back` + +bpy.types.TexMapping +-------------------- + +Renamed +^^^^^^^ + +* **location** -> :class:`bpy.types.TexMapping.translation` + +bpy.types.ArmatureActuator +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ArmatureActuator.influence` + +bpy.types.ThemeTextEditor +------------------------- + +Removed +^^^^^^^ + +* **scroll_bar** + +bpy.types.ThemeUserInterface +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeUserInterface.wcol_tooltip` + +bpy.types.MeshEdge +------------------ + +Removed +^^^^^^^ + +* **is_fgon** + +bpy.types.Brush +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Brush.sculpt_capabilities` + +Renamed +^^^^^^^ + +* **use_space_atten** -> :class:`bpy.types.Brush.use_space_attenuation` + +bpy.types.ShaderNodeMapping +--------------------------- + +Renamed +^^^^^^^ + +* **location** -> :class:`bpy.types.ShaderNodeMapping.translation` + +bpy.types.Mesh +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Mesh.auto_texspace` +* :class:`bpy.types.Mesh.calc_tessface` +* :class:`bpy.types.Mesh.loops` +* :class:`bpy.types.Mesh.polygons` +* :class:`bpy.types.Mesh.tessface_uv_textures` +* :class:`bpy.types.Mesh.tessface_vertex_colors` +* :class:`bpy.types.Mesh.tessfaces` +* :class:`bpy.types.Mesh.unit_test_compare` +* :class:`bpy.types.Mesh.uv_layer_clone` +* :class:`bpy.types.Mesh.uv_layer_clone_index` +* :class:`bpy.types.Mesh.uv_layer_stencil` +* :class:`bpy.types.Mesh.uv_layer_stencil_index` +* :class:`bpy.types.Mesh.uv_layers` + +Removed +^^^^^^^ + +* **faces** +* **layers_float** +* **layers_string** + +Renamed +^^^^^^^ + +* **layers_int** -> :class:`bpy.types.Mesh.polygon_layers_float` +* **layers_int** -> :class:`bpy.types.Mesh.polygon_layers_int` +* **layers_int** -> :class:`bpy.types.Mesh.polygon_layers_string` + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.Mesh.update` (calc_edges, calc_tessface), *was (calc_edges)* + +bpy.types.Key +------------- + +Added +^^^^^ + +* :class:`bpy.types.Key.eval_time` + +bpy.types.LatticeModifier +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.LatticeModifier.strength` + +bpy.types.UserPreferencesView +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesView.quit_dialog` + + +2.63 to 2.64 +============ + +bpy.types.CyclesLampSettings +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CyclesLampSettings.samples` + +bpy.types.Histogram +------------------- + +Added +^^^^^ + +* :class:`bpy.types.Histogram.show_line` + +bpy.types.ThemeView3D +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeView3D.bone_pose_active` +* :class:`bpy.types.ThemeView3D.skin_root` + +bpy.types.GameObjectSettings +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.GameObjectSettings.fall_speed` +* :class:`bpy.types.GameObjectSettings.jump_speed` +* :class:`bpy.types.GameObjectSettings.step_height` + + +bpy.types.BlendData +------------------- + +Added +^^^^^ + +* :class:`bpy.types.BlendData.masks` + + +bpy.types.TextureNodeMixRGB +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.TextureNodeMixRGB.use_clamp` + +bpy.types.SmokeCollSettings +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SmokeCollSettings.collision_type` + +bpy.types.CompositorNodes +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodes.active` + +bpy.types.RenderEngine +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.RenderEngine.resolution_x` +* :class:`bpy.types.RenderEngine.resolution_y` +* :class:`bpy.types.RenderEngine.tile_x` +* :class:`bpy.types.RenderEngine.tile_y` + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.RenderEngine.begin_result` (x, y, w, h, layer), *was (x, y, w, h)* +* :class:`bpy.types.RenderEngine.end_result` (result, cancel), *was (result)* + +bpy.types.BackgroundImage +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.BackgroundImage.draw_depth` +* :class:`bpy.types.BackgroundImage.frame_method` + +bpy.types.SmokeDomainSettings +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SmokeDomainSettings.cell_size` +* :class:`bpy.types.SmokeDomainSettings.density` +* :class:`bpy.types.SmokeDomainSettings.domain_resolution` +* :class:`bpy.types.SmokeDomainSettings.scale` +* :class:`bpy.types.SmokeDomainSettings.start_point` + +bpy.types.CyclesRenderSettings +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.CyclesRenderSettings.aa_samples` +* :class:`bpy.types.CyclesRenderSettings.ao_samples` +* :class:`bpy.types.CyclesRenderSettings.blur_glossy` +* :class:`bpy.types.CyclesRenderSettings.diffuse_samples` +* :class:`bpy.types.CyclesRenderSettings.glossy_samples` +* :class:`bpy.types.CyclesRenderSettings.mesh_light_samples` +* :class:`bpy.types.CyclesRenderSettings.preview_aa_samples` +* :class:`bpy.types.CyclesRenderSettings.preview_start_resolution` +* :class:`bpy.types.CyclesRenderSettings.progressive` +* :class:`bpy.types.CyclesRenderSettings.transmission_samples` + +Removed +^^^^^^^ + +* **blur_caustics** +* **debug_min_size** + +bpy.types.ActionGroup +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ActionGroup.color_set` +* :class:`bpy.types.ActionGroup.colors` + +Removed +^^^^^^^ + +* **custom_color** + +bpy.types.WipeSequence +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.WipeSequence.input_1` +* :class:`bpy.types.WipeSequence.input_count` + +bpy.types.ToolSettings +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.ToolSettings.snap_node_element` +* :class:`bpy.types.ToolSettings.use_proportional_edit_mask` + +bpy.types.ThemeClipEditor +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeClipEditor.space_list` +* :class:`bpy.types.ThemeClipEditor.strips` +* :class:`bpy.types.ThemeClipEditor.strips_selected` + +bpy.types.Image +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Image.colorspace_settings` +* :class:`bpy.types.Image.frame_duration` +* :class:`bpy.types.Image.gl_touch` +* :class:`bpy.types.Image.scale` +* :class:`bpy.types.Image.view_as_render` + + +bpy.types.ThemeDopeSheet +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.ThemeDopeSheet.summary` + +bpy.types.MovieClipUser +----------------------- + +Renamed +^^^^^^^ + +* **current_frame** -> :class:`bpy.types.MovieClipUser.frame_current` + +bpy.types.TransformSequence +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.TransformSequence.input_1` +* :class:`bpy.types.TransformSequence.input_count` + +bpy.types.ImageSequence +----------------------- + +Removed +^^^^^^^ + +* **color_balance** +* **use_color_balance** + +bpy.types.DupliObject +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.DupliObject.index` +* :class:`bpy.types.DupliObject.particle_index` + +bpy.types.RenderSettings +------------------------ + +Removed +^^^^^^^ + +* **use_color_management** +* **use_radiosity** + +bpy.types.Curve +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Curve.bevel_factor_end` +* :class:`bpy.types.Curve.bevel_factor_start` + +bpy.types.MovieClip +------------------- + +Added +^^^^^ + +* :class:`bpy.types.MovieClip.colorspace_settings` +* :class:`bpy.types.MovieClip.frame_duration` +* :class:`bpy.types.MovieClip.frame_offset` +* :class:`bpy.types.MovieClip.frame_start` + +bpy.types.CompositorNodeTree +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeTree.chunk_size` +* :class:`bpy.types.CompositorNodeTree.edit_quality` +* :class:`bpy.types.CompositorNodeTree.render_quality` +* :class:`bpy.types.CompositorNodeTree.two_pass` +* :class:`bpy.types.CompositorNodeTree.use_opencl` + +bpy.types.SpaceUVEditor +----------------------- + +Removed +^^^^^^^ + +* **cursor_location** +* **pivot_point** + +bpy.types.RemeshModifier +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.RemeshModifier.use_smooth_shade` + +bpy.types.CurveMapping +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.CurveMapping.update` + +bpy.types.CompositorNodeMixRGB +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeMixRGB.use_clamp` + +bpy.types.ParticleSettings +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ParticleSettings.use_scale_dupli` + +bpy.types.SceneGameData +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.SceneGameData.deactivation_angular_threshold` +* :class:`bpy.types.SceneGameData.deactivation_linear_threshold` +* :class:`bpy.types.SceneGameData.deactivation_time` + +bpy.types.SoundSequence +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.SoundSequence.show_waveform` + +bpy.types.Scene +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Scene.display_settings` +* :class:`bpy.types.Scene.sequence_editor_clear` +* :class:`bpy.types.Scene.sequence_editor_create` +* :class:`bpy.types.Scene.sequencer_colorspace_settings` +* :class:`bpy.types.Scene.view_settings` + +Removed +^^^^^^^ + +* **collada_export** + +bpy.types.Armature +------------------ + +Removed +^^^^^^^ + +* **use_deform_envelopes** +* **use_deform_preserve_volume** +* **use_deform_vertex_groups** + +bpy.types.MeshUVLoopLayer +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.MeshUVLoopLayer.name` + +bpy.types.CurveMap +------------------ + +Added +^^^^^ + +* :class:`bpy.types.CurveMap.evaluate` + +bpy.types.ShaderNodeTexEnvironment +---------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodeTexEnvironment.image_user` + +bpy.types.SolidifyModifier +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SolidifyModifier.use_flip_normals` + +bpy.types.TextureNodeMath +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.TextureNodeMath.use_clamp` + +bpy.types.SceneRenderLayer +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SceneRenderLayer.layers_exclude` +* :class:`bpy.types.SceneRenderLayer.samples` + +bpy.types.CompositorNodeViewer +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeViewer.center_x` +* :class:`bpy.types.CompositorNodeViewer.center_y` +* :class:`bpy.types.CompositorNodeViewer.tile_order` + +bpy.types.ClothCollisionSettings +-------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ClothCollisionSettings.vertex_group_self_collisions` + +bpy.types.SpeedControlSequence +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.SpeedControlSequence.input_1` +* :class:`bpy.types.SpeedControlSequence.input_count` + +bpy.types.ActionConstraint +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ActionConstraint.use_bone_object_action` + +bpy.types.CompositorNodeScale +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeScale.frame_method` +* :class:`bpy.types.CompositorNodeScale.offset_x` +* :class:`bpy.types.CompositorNodeScale.offset_y` + +bpy.types.SpaceDopeSheetEditor +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.SpaceDopeSheetEditor.show_group_colors` + +bpy.types.MetaSequence +---------------------- + +Removed +^^^^^^^ + +* **color_balance** +* **use_color_balance** + +bpy.types.ShaderNodeMixRGB +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodeMixRGB.use_clamp` + +bpy.types.FollowTrackConstraint +------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.FollowTrackConstraint.frame_method` + +bpy.types.EffectSequence +------------------------ + +Removed +^^^^^^^ + +* **color_balance** +* **use_color_balance** + +bpy.types.ThemeNLAEditor +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.ThemeNLAEditor.active_action` +* :class:`bpy.types.ThemeNLAEditor.active_action_unset` +* :class:`bpy.types.ThemeNLAEditor.meta_strips` +* :class:`bpy.types.ThemeNLAEditor.meta_strips_selected` +* :class:`bpy.types.ThemeNLAEditor.sound_strips` +* :class:`bpy.types.ThemeNLAEditor.sound_strips_selected` +* :class:`bpy.types.ThemeNLAEditor.transition_strips` +* :class:`bpy.types.ThemeNLAEditor.transition_strips_selected` +* :class:`bpy.types.ThemeNLAEditor.tweak` +* :class:`bpy.types.ThemeNLAEditor.tweak_duplicate` + +Removed +^^^^^^^ + +* **bars** +* **bars_selected** + +bpy.types.SculptCapabilities +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SculptCapabilities.has_overlay` +* :class:`bpy.types.SculptCapabilities.has_texture_angle` +* :class:`bpy.types.SculptCapabilities.has_texture_angle_source` + +bpy.types.ImageFormatSettings +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ImageFormatSettings.display_settings` +* :class:`bpy.types.ImageFormatSettings.view_settings` + + +bpy.types.Property +------------------ + +Added +^^^^^ + +* :class:`bpy.types.Property.is_library_editable` + +bpy.types.MovieTrackingTrack +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.MovieTrackingTrack.grease_pencil` +* :class:`bpy.types.MovieTrackingTrack.motion_model` +* :class:`bpy.types.MovieTrackingTrack.use_alpha_preview` +* :class:`bpy.types.MovieTrackingTrack.use_brute` +* :class:`bpy.types.MovieTrackingTrack.use_mask` +* :class:`bpy.types.MovieTrackingTrack.use_normalization` + +Removed +^^^^^^^ + +* **pattern_max** +* **pattern_min** +* **pyramid_levels** +* **search_max** +* **search_min** +* **tracker** + +bpy.types.CompositorNodeBlur +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeBlur.use_variable_size` + +bpy.types.Object +---------------- + +Added +^^^^^ + +* :class:`bpy.types.Object.dm_info` +* :class:`bpy.types.Object.is_deform_modified` +* :class:`bpy.types.Object.layers_local_view` + +Renamed +^^^^^^^ + +* **animation_visualisation** -> :class:`bpy.types.Object.animation_visualization` + +bpy.types.UserPreferencesSystem +------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesSystem.use_gpu_mipmap` + +Removed +^^^^^^^ + +* **compute_device** +* **compute_device_type** + +bpy.types.Sequence +------------------ + +Added +^^^^^ + +* :class:`bpy.types.Sequence.modifiers` +* :class:`bpy.types.Sequence.use_linear_modifiers` + +Removed +^^^^^^^ + +* **input_1** +* **input_2** +* **input_3** +* **input_count** +* **waveform** + +bpy.types.ConsoleLine +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ConsoleLine.type` + +bpy.types.Region +---------------- + +Added +^^^^^ + +* :class:`bpy.types.Region.view2d` +* :class:`bpy.types.Region.x` +* :class:`bpy.types.Region.y` + +bpy.types.SpaceClipEditor +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceClipEditor.grease_pencil_source` +* :class:`bpy.types.SpaceClipEditor.mask` +* :class:`bpy.types.SpaceClipEditor.mask_draw_type` +* :class:`bpy.types.SpaceClipEditor.pivot_point` +* :class:`bpy.types.SpaceClipEditor.show_graph_hidden` +* :class:`bpy.types.SpaceClipEditor.show_graph_only_selected` +* :class:`bpy.types.SpaceClipEditor.show_mask_smooth` +* :class:`bpy.types.SpaceClipEditor.show_seconds` + +bpy.types.NodeSocket +-------------------- + +Added +^^^^^ + +* :class:`bpy.types.NodeSocket.hide` +* :class:`bpy.types.NodeSocket.is_linked` + +bpy.types.MovieClipSequence +--------------------------- + +Removed +^^^^^^^ + +* **color_balance** +* **use_color_balance** + +bpy.types.Node +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Node.color` +* :class:`bpy.types.Node.hide` +* :class:`bpy.types.Node.mute` +* :class:`bpy.types.Node.select` +* :class:`bpy.types.Node.show_options` +* :class:`bpy.types.Node.show_preview` +* :class:`bpy.types.Node.use_custom_color` + +bpy.types.SceneSequence +----------------------- + +Removed +^^^^^^^ + +* **color_balance** +* **use_color_balance** + +bpy.types.CompositorNodeOutputFile +---------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeOutputFile.file_slots` +* :class:`bpy.types.CompositorNodeOutputFile.layer_slots` + +Removed +^^^^^^^ + +* **active_input** + +bpy.types.ObjectBase +-------------------- + +Added +^^^^^ + +* :class:`bpy.types.ObjectBase.layers_local_view` + +bpy.types.CyclesCameraSettings +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.CyclesCameraSettings.fisheye_fov` +* :class:`bpy.types.CyclesCameraSettings.fisheye_lens` +* :class:`bpy.types.CyclesCameraSettings.panorama_type` + +bpy.types.CompositorNodeDefocus +------------------------------- + +Removed +^^^^^^^ + +* **samples** + +bpy.types.KeyMapItems +--------------------- + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.KeyMapItems.new` (idname, type, value, any, shift, ctrl, alt, oskey, key_modifier, head), *was (idname, type, value, any, shift, ctrl, alt, oskey, key_modifier)* + +bpy.types.CollisionSettings +--------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CollisionSettings.stickiness` + +Removed +^^^^^^^ + +* **stickness** + +bpy.types.GlowSequence +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.GlowSequence.input_1` +* :class:`bpy.types.GlowSequence.input_count` + +bpy.types.MouseSensor +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.MouseSensor.use_pulse` + +bpy.types.MovieSequence +----------------------- + +Removed +^^^^^^^ + +* **color_balance** +* **use_color_balance** + +bpy.types.Pose +-------------- + +Renamed +^^^^^^^ + +* **animation_visualisation** -> :class:`bpy.types.Pose.animation_visualization` + +bpy.types.ThemeSequenceEditor +----------------------------- + +Removed +^^^^^^^ + +* **plugin_strip** + +bpy.types.IMAGE_UV_sculpt +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.IMAGE_UV_sculpt.prop_unified_weight` + +bpy.types.SpaceImageEditor +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceImageEditor.cursor_location` +* :class:`bpy.types.SpaceImageEditor.mask` +* :class:`bpy.types.SpaceImageEditor.mask_draw_type` +* :class:`bpy.types.SpaceImageEditor.mode` +* :class:`bpy.types.SpaceImageEditor.pivot_point` +* :class:`bpy.types.SpaceImageEditor.show_mask_smooth` +* :class:`bpy.types.SpaceImageEditor.show_maskedit` + +Removed +^^^^^^^ + +* **curve** +* **use_grease_pencil** +* **use_image_paint** + +bpy.types.UserPreferencesFilePaths +---------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesFilePaths.i18n_branches_directory` + +Removed +^^^^^^^ + +* **sequence_plugin_directory** +* **texture_plugin_directory** + +bpy.types.CompositorNodeDilateErode +----------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeDilateErode.edge` +* :class:`bpy.types.CompositorNodeDilateErode.falloff` +* :class:`bpy.types.CompositorNodeDilateErode.type` + +bpy.types.ScrewModifier +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.ScrewModifier.use_smooth_shade` + +bpy.types.SpaceNodeEditor +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceNodeEditor.cursor_location` +* :class:`bpy.types.SpaceNodeEditor.edit_tree` +* :class:`bpy.types.SpaceNodeEditor.show_highlight` +* :class:`bpy.types.SpaceNodeEditor.use_hidden_preview` + +bpy.types.SpaceView3D +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceView3D.layers_local_view` +* :class:`bpy.types.SpaceView3D.show_backface_culling` + +bpy.types.Area +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Area.x` +* :class:`bpy.types.Area.y` + +bpy.types.RenderLayer +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.RenderLayer.layers_exclude` + +bpy.types.MovieTracking +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.MovieTracking.dopesheet` + +bpy.types.MovieTrackingSettings +------------------------------- + +Added +^^^^^ + +* :class:`bpy.types.MovieTrackingSettings.default_motion_model` +* :class:`bpy.types.MovieTrackingSettings.use_default_brute` +* :class:`bpy.types.MovieTrackingSettings.use_default_mask` +* :class:`bpy.types.MovieTrackingSettings.use_default_normalization` +* :class:`bpy.types.MovieTrackingSettings.use_tripod_solver` + +Removed +^^^^^^^ + +* **default_pyramid_levels** +* **default_tracker** + +bpy.types.CompositorNodeIDMask +------------------------------ + +Renamed +^^^^^^^ + +* **use_smooth_mask** -> :class:`bpy.types.CompositorNodeIDMask.use_antialiasing` + +bpy.types.UserPreferencesInput +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesInput.ndof_orbit_sensitivity` +* :class:`bpy.types.UserPreferencesInput.ndof_view_rotate_method` + +bpy.types.Brush +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Brush.mask_tool` +* :class:`bpy.types.Brush.weight` + +bpy.types.SpaceSequenceEditor +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceSequenceEditor.overlay_type` + +Removed +^^^^^^^ + +* **use_grease_pencil** + +bpy.types.MovieTrackingMarkers +------------------------------ + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.MovieTrackingMarkers.find_frame` (frame, exact), *was (frame)* + +bpy.types.UILayout +------------------ + +Added +^^^^^ + +* :class:`bpy.types.UILayout.template_colormanaged_view_settings` +* :class:`bpy.types.UILayout.template_colorspace_settings` + +Function Arguments +^^^^^^^^^^^^^^^^^^ + +* :class:`bpy.types.UILayout.template_image_settings` (image_settings, color_management), *was (image_settings)* + +bpy.types.ID +------------ + +Added +^^^^^ + +* :class:`bpy.types.ID.is_library_indirect` + +bpy.types.SpaceGraphEditor +-------------------------- + +Added +^^^^^ + +* :class:`bpy.types.SpaceGraphEditor.show_group_colors` + +bpy.types.Mesh +-------------- + +Added +^^^^^ + +* :class:`bpy.types.Mesh.skin_vertices` + +Removed +^^^^^^^ + +* **sticky** + +bpy.types.ShaderNodes +--------------------- + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodes.active` + +bpy.types.ColorSequence +----------------------- + +Added +^^^^^ + +* :class:`bpy.types.ColorSequence.input_count` + +bpy.types.ShaderNodeMath +------------------------ + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodeMath.use_clamp` + +bpy.types.Paint +--------------- + +Added +^^^^^ + +* :class:`bpy.types.Paint.input_samples` + +bpy.types.ShaderNodeTexImage +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ShaderNodeTexImage.image_user` +* :class:`bpy.types.ShaderNodeTexImage.projection` +* :class:`bpy.types.ShaderNodeTexImage.projection_blend` + +bpy.types.UserPreferencesView +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.UserPreferencesView.use_mouse_depth_cursor` + +Renamed +^^^^^^^ + +* **use_mouse_auto_depth** -> :class:`bpy.types.UserPreferencesView.use_mouse_depth_navigate` + +bpy.types.CompositorNodeMath +---------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CompositorNodeMath.use_clamp` + +bpy.types.Material +------------------ + +Added +^^^^^ + +* :class:`bpy.types.Material.use_uv_project` + +bpy.types.ThemeNodeEditor +------------------------- + +Added +^^^^^ + +* :class:`bpy.types.ThemeNodeEditor.frame_node` +* :class:`bpy.types.ThemeNodeEditor.node_active` +* :class:`bpy.types.ThemeNodeEditor.node_selected` + +bpy.types.Camera +---------------- + +Removed +^^^^^^^ + +* **use_panorama** + +bpy.types.UnifiedPaintSettings +------------------------------ + +Added +^^^^^ + +* :class:`bpy.types.UnifiedPaintSettings.use_unified_weight` +* :class:`bpy.types.UnifiedPaintSettings.weight` + +bpy.types.TextureNodes +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.TextureNodes.active` + +bpy.types.MovieTrackingMarker +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.MovieTrackingMarker.pattern_bound_box` +* :class:`bpy.types.MovieTrackingMarker.pattern_corners` +* :class:`bpy.types.MovieTrackingMarker.search_max` +* :class:`bpy.types.MovieTrackingMarker.search_min` + +bpy.types.CyclesWorldSettings +----------------------------- + +Added +^^^^^ + +* :class:`bpy.types.CyclesWorldSettings.samples` + +bpy.types.LatticePoint +---------------------- + +Added +^^^^^ + +* :class:`bpy.types.LatticePoint.select` diff --git a/doc/python_api/sphinx_changelog_gen.py b/doc/python_api/sphinx_changelog_gen.py index 3ded1035123..afc253940d4 100644 --- a/doc/python_api/sphinx_changelog_gen.py +++ b/doc/python_api/sphinx_changelog_gen.py @@ -28,15 +28,15 @@ blender --background --python doc/python_api/sphinx_changelog_gen.py -- --dump # create changelog blender --background --python doc/python_api/sphinx_changelog_gen.py -- \ - --api_from blender_2_56_1.py \ - --api_to blender_2_57_0.py \ + --api_from blender_2_63_0.py \ + --api_to blender_2_64_0.py \ --api_out changes.rst # Api comparison can also run without blender -python doc/python_api/sphinx_changelog_gen.py \ - --api_from blender_api_2_56_6.py \ - --api_to blender_api_2_57.py \ +python doc/python_api/sphinx_changelog_gen.py -- \ + --api_from blender_api_2_63_0.py \ + --api_to blender_api_2_64_0.py \ --api_out changes.rst # Save the latest API dump in this folder, renaming it with its revision. @@ -307,6 +307,8 @@ def api_changelog(api_from, api_to, api_out): fout.close() + print("Written: %r" % api_out) + def main(): import sys @@ -347,6 +349,7 @@ def main(): args = parser.parse_args(argv) # In this example we wont use the args if not argv: + print("No args given!") parser.print_help() return -- cgit v1.2.3 From b16ca24d98961e91775d2be90fb544e4f966bae5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 03:14:38 +0000 Subject: code cleanup: quiet -Wreorder --- source/gameengine/Ketsji/KX_GameObject.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 80634c3d8fc..cfc7b81bde5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -109,10 +109,10 @@ KX_GameObject::KX_GameObject( m_xray(false), m_pHitObject(NULL), m_pObstacleSimulation(NULL), - m_actionManager(NULL), - m_isDeformable(false), + m_pInstanceObjects(NULL), m_pDupliGroupObject(NULL), - m_pInstanceObjects(NULL) + m_actionManager(NULL), + m_isDeformable(false) #ifdef WITH_PYTHON , m_attr_dict(NULL) #endif -- cgit v1.2.3 From 62d3754a40540a246a7b0e50324df548f91c2d9b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 03:44:29 +0000 Subject: fix for r51198, text wasn't flashing (gcc4.7, 64bit linux) --- source/blender/editors/transform/transform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 2fe68b20806..775e8d2de8e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1586,7 +1586,8 @@ static void drawAutoKeyWarning(TransInfo *t, ARegion *ar) * We multiply by two to speed up the odd/even time-in-seconds = on/off toggle. * - Always start with warning shown so that animators are more likely to notice when starting to transform */ - show_warning = (int)(t->last_update * 2.0) & 1; + + show_warning = ((int)((t->last_update - floor(t->last_update)) * 2.0) & 1); if ((show_warning) || (t->state == TRANS_STARTING)) { const char printable[] = "Auto Keying On"; -- cgit v1.2.3 From 8d2835b5e55e901483ad839d87f11d7ada4d21a8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 05:58:09 +0000 Subject: patch [#31875] Patch to get scene access through a game object from Jay Parker (battery) --- doc/python_api/rst/bge.types.rst | 16 +++++++++++++--- source/gameengine/Ketsji/KX_GameObject.cpp | 14 +++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index 6599cfeb2b2..e628db07e83 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -333,7 +333,8 @@ Types .. attribute:: useContinue - The actions continue option, True or False. When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame. + The actions continue option, True or False. When True, the action will always play from where last left off, + otherwise negative events to this actuator will reset it to its start frame. :type: boolean @@ -879,7 +880,8 @@ Types .. note:: - Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the :data:`invalid` attribute to check. + Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, + if an object may have been removed since last accessing it use the :data:`invalid` attribute to check. KX_GameObject can be subclassed to extend functionality. For example: @@ -999,6 +1001,12 @@ Types :type: :class:`KX_GameObject` or None + .. attribute:: scene + + The object's scene. (read-only). + + :type: :class:`KX_Scene` or None + .. attribute:: visible visibility flag. @@ -4558,7 +4566,9 @@ Types .. data:: KX_ACT_ARMATURE_RUN - Just make sure the armature will be updated on the next graphic frame. This is the only persistent mode of the actuator: it executes automatically once per frame until stopped by a controller + Just make sure the armature will be updated on the next graphic frame. + This is the only persistent mode of the actuator: + it executes automatically once per frame until stopped by a controller :value: 0 diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index cfc7b81bde5..a8f3c54508c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1682,7 +1682,8 @@ PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("name", KX_GameObject, pyattr_get_name), KX_PYATTRIBUTE_RO_FUNCTION("parent", KX_GameObject, pyattr_get_parent), KX_PYATTRIBUTE_RO_FUNCTION("members", KX_GameObject, pyattr_get_instance_objects), - KX_PYATTRIBUTE_RO_FUNCTION("group", KX_GameObject, pyattr_get_dupli_group_object), + KX_PYATTRIBUTE_RO_FUNCTION("group", KX_GameObject, pyattr_get_dupli_group_object), + KX_PYATTRIBUTE_RO_FUNCTION("scene", KX_GameObject, pyattr_get_scene), KX_PYATTRIBUTE_RO_FUNCTION("life", KX_GameObject, pyattr_get_life), KX_PYATTRIBUTE_RW_FUNCTION("mass", KX_GameObject, pyattr_get_mass, pyattr_set_mass), KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min), @@ -1988,6 +1989,17 @@ PyObject *KX_GameObject::pyattr_get_instance_objects(void *self_v, const KX_PYAT Py_RETURN_NONE; } +PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject *self = static_cast(self_v); + SG_Node *node = self->GetSGNode(); + KX_Scene *scene = static_cast(node->GetSGClientInfo()); + if (scene) { + return scene->GetProxy(); + } + Py_RETURN_NONE; +} + PyObject *KX_GameObject::pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast(self_v); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 4fde0752a13..4fa3472ba10 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -980,6 +980,7 @@ public: static PyObject* pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_instance_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); -- cgit v1.2.3 From b1c4809f505e2ff4249b1c12c0efb2930a4d94ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 06:03:57 +0000 Subject: rename BGE KX_GameObject attrs * group -> group_parent * members -> group_children so its more clear what direction the relationship is. --- doc/python_api/rst/bge.types.rst | 4 ++-- source/gameengine/Ketsji/KX_GameObject.cpp | 8 ++++---- source/gameengine/Ketsji/KX_GameObject.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index e628db07e83..a173137e50c 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -989,13 +989,13 @@ Types :type: :class:`KX_GameObject` or None - .. attribute:: members + .. attribute:: group_children Returns the list of group members if the object is a group object, otherwise None is returned. :type: :class:`CListValue` of :class:`KX_GameObject` or None - .. attribute:: group + .. attribute:: group_parent Returns the group object that the object belongs to or None if the object is not part of a group. diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index a8f3c54508c..3cfb670d227 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1681,8 +1681,8 @@ PyMethodDef KX_GameObject::Methods[] = { PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("name", KX_GameObject, pyattr_get_name), KX_PYATTRIBUTE_RO_FUNCTION("parent", KX_GameObject, pyattr_get_parent), - KX_PYATTRIBUTE_RO_FUNCTION("members", KX_GameObject, pyattr_get_instance_objects), - KX_PYATTRIBUTE_RO_FUNCTION("group", KX_GameObject, pyattr_get_dupli_group_object), + KX_PYATTRIBUTE_RO_FUNCTION("group_children", KX_GameObject, pyattr_get_group_children), + KX_PYATTRIBUTE_RO_FUNCTION("group_parent", KX_GameObject, pyattr_get_group_parent), KX_PYATTRIBUTE_RO_FUNCTION("scene", KX_GameObject, pyattr_get_scene), KX_PYATTRIBUTE_RO_FUNCTION("life", KX_GameObject, pyattr_get_life), KX_PYATTRIBUTE_RW_FUNCTION("mass", KX_GameObject, pyattr_get_mass, pyattr_set_mass), @@ -1979,7 +1979,7 @@ PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE Py_RETURN_NONE; } -PyObject *KX_GameObject::pyattr_get_instance_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_group_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast(self_v); CListValue* instances = self->GetInstanceObjects(); @@ -2000,7 +2000,7 @@ PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF Py_RETURN_NONE; } -PyObject *KX_GameObject::pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +PyObject *KX_GameObject::pyattr_get_group_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { KX_GameObject* self= static_cast(self_v); KX_GameObject* pivot = self->GetDupliGroupObject(); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 4fa3472ba10..621dd988e00 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -978,8 +978,8 @@ public: static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); - static PyObject* pyattr_get_instance_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_group_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_group_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); -- cgit v1.2.3 From f45acb2bba96341bce7b49cf72bcbd8bbaaafe80 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 06:15:07 +0000 Subject: patch [#31709] Text editor: scroll margin column along with text by Sebastian Nell (codemanx) The margin ignored horizontal scrolling. --- source/blender/editors/space_text/text_draw.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 5111d20b8ee..a68524fcdd6 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1741,6 +1741,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) char linenr[12]; int i, x, y, winx, linecount = 0, lineno = 0; int wraplinecount = 0, wrap_skip = 0; + int margin_column_x; if (st->lheight) st->viewlines = (int)ar->winy / st->lheight; else st->viewlines = 0; @@ -1845,10 +1846,14 @@ void draw_text_main(SpaceText *st, ARegion *ar) if (st->flags & ST_SHOW_MARGIN) { UI_ThemeColor(TH_HILITE); - glBegin(GL_LINES); - glVertex2i(x + st->cwidth * st->margin_column, 0); - glVertex2i(x + st->cwidth * st->margin_column, ar->winy - 2); - glEnd(); + margin_column_x = x + st->cwidth * (st->margin_column - st->left); + + if (margin_column_x >= x) { + glBegin(GL_LINES); + glVertex2i(margin_column_x, 0); + glVertex2i(margin_column_x, ar->winy - 2); + glEnd(); + } } /* draw other stuff */ -- cgit v1.2.3 From 0f8c99e58548bd00436284f1cd471c89f28d25f9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 9 Oct 2012 08:40:20 +0000 Subject: RNA minor fixes: *Bezier points' softbody weight was called just "weight", when it is "weight_softbody" for NURBS ones, made it the same! *Added "weight_softbody" to Lattice points as well. --- source/blender/makesrna/intern/rna_curve.c | 3 ++- source/blender/makesrna/intern/rna_lattice.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index b42fb0664f8..d7e59f3b9dd 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -814,7 +814,8 @@ static void rna_def_beztriple(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "weight"); RNA_def_property_range(prop, 0.01f, 100.0f); RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index d4082cf3d9f..e4a29d9c674 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -240,6 +240,12 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Deformed Location", ""); RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); + prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_range(prop, 0.01f, 100.0f); + RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight"); + RNA_def_property_update(prop, 0, "rna_Lattice_update_data"); + prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", @@ -320,7 +326,7 @@ static void rna_def_lattice(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL); RNA_def_property_ui_text(prop, "Points", "Points of the lattice"); - + /* pointers */ rna_def_animdata_common(srna); } -- cgit v1.2.3 From 9e0dd178134a973b9091705fd62f12ed9ea6434c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 9 Oct 2012 09:14:37 +0000 Subject: Another refactor for 3D view's edit Transform panel. Main changes: *Get rid of the magic numbers for median arrays, use defines instead, should make things a bit more clear and easy to edit (though there are still a bit of "array magic" on median here and there). *Restore and extend use of RNA prop when a single (control)point of curve or lattice is selected, to allow keyframing (was added by sergey for curve radius in r41494, see [#29122], and reverted by myself in previous refactor r44599). --- .../blender/editors/space_view3d/view3d_buttons.c | 359 ++++++++++++--------- 1 file changed, 212 insertions(+), 147 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index c8aca5674a4..1f7bae0b23e 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -86,13 +86,15 @@ #define B_REDR 2 #define B_OBJECTPANELMEDIAN 1008 +#define NBR_TRANSFORM_PROPERTIES 7 + /* temporary struct for storing transform properties */ typedef struct { float ob_eul[4]; /* used for quat too... */ float ob_scale[3]; /* need temp space due to linked values */ float ob_dims[3]; short link_scale; - float ve_median[9]; + float ve_median[NBR_TRANSFORM_PROPERTIES]; int curdef; float *defweightp; } TransformProperties; @@ -131,17 +133,38 @@ static float compute_scale_factor(const float ve_median, const float median) /* is used for both read and write... */ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float lim) { +/* Get rid of those ugly magic numbers, even in a single func they become confusing! */ +/* Location, common to all. */ +/* XXX Those two *must* remain contiguous (used as array)! */ +#define LOC_X 0 +#define LOC_Y 1 +#define LOC_Z 2 +/* Meshes... */ +#define M_CREASE 3 +#define M_WEIGHT 4 +/* XXX Those two *must* remain contiguous (used as array)! */ +#define M_SKIN_X 5 +#define M_SKIN_Y 6 +/* Curves... */ +#define C_BWEIGHT 3 +#define C_WEIGHT 4 +#define C_RADIUS 5 +#define C_TILT 6 +/*Lattice... */ +#define L_WEIGHT 4 + uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : NULL; MDeformVert *dvert = NULL; TransformProperties *tfp; - float median[9], ve_median[9]; - int tot, totw, totweight, totedge, totradius, totskinradius; + float median[NBR_TRANSFORM_PROPERTIES], ve_median[NBR_TRANSFORM_PROPERTIES]; + int tot, totedgedata, totcurvedata, totlattdata, totskinradius, totcurvebweight; + int meshdata = FALSE, i; char defstr[320]; - PointerRNA radius_ptr; + PointerRNA data_ptr; - median[0] = median[1] = median[2] = median[3] = median[4] = median[5] = median[6] = median[7] = median[8] = 0.0; - tot = totw = totweight = totedge = totradius = totskinradius = 0; - defstr[0] = 0; + fill_vn_fl(median, NBR_TRANSFORM_PROPERTIES, 0.0f); + tot = totedgedata = totcurvedata = totlattdata = totskinradius = totcurvebweight = 0; + defstr[0] = '\0'; /* make sure we got storage */ if (v3d->properties_storage == NULL) @@ -162,11 +185,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float evedef = eve; tot++; - add_v3_v3(median, eve->co); + add_v3_v3(&median[LOC_X], eve->co); vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN); if (vs) { - add_v2_v2(median + 7, vs->radius); /* Third val not used currently. */ + add_v2_v2(&median[M_SKIN_X], vs->radius); /* Third val not used currently. */ totskinradius++; } } @@ -176,12 +199,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { float *f; - totedge++; + totedgedata++; f = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_CREASE); - median[3] += f ? *f : 0.0f; + median[M_CREASE] += f ? *f : 0.0f; f = (float *)CustomData_bmesh_get(&bm->edata, eed->head.data, CD_BWEIGHT); - median[6] += f ? *f : 0.0f; + median[M_WEIGHT] += f ? *f : 0.0f; } } @@ -211,6 +234,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float tfp->defweightp = &dvert->dw[0].weight; } } + + meshdata = totedgedata || totskinradius; } else if (ob->type == OB_CURVE || ob->type == OB_SURF) { Curve *cu = ob->data; @@ -229,22 +254,24 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float a = nu->pntsu; while (a--) { if (bezt->f2 & SELECT) { - add_v3_v3(median, bezt->vec[1]); + add_v3_v3(&median[LOC_X], bezt->vec[1]); tot++; - median[4] += bezt->weight; - totweight++; - median[5] += bezt->radius; - totradius++; - selp = bezt; - seltype = &RNA_BezierSplinePoint; + median[C_WEIGHT] += bezt->weight; + median[C_RADIUS] += bezt->radius; + median[C_TILT] += bezt->alfa; + if (!totcurvedata) { /* I.e. first time... */ + selp = bezt; + seltype = &RNA_BezierSplinePoint; + } + totcurvedata++; } else { if (bezt->f1 & SELECT) { - add_v3_v3(median, bezt->vec[0]); + add_v3_v3(&median[LOC_X], bezt->vec[0]); tot++; } if (bezt->f3 & SELECT) { - add_v3_v3(median, bezt->vec[2]); + add_v3_v3(&median[LOC_X], bezt->vec[2]); tot++; } } @@ -256,16 +283,18 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & SELECT) { - add_v3_v3(median, bp->vec); - median[3] += bp->vec[3]; - totw++; + add_v3_v3(&median[LOC_X], bp->vec); + median[C_BWEIGHT] += bp->vec[3]; + totcurvebweight++; tot++; - median[4] += bp->weight; - totweight++; - median[5] += bp->radius; - totradius++; - selp = bp; - seltype = &RNA_SplinePoint; + median[C_WEIGHT] += bp->weight; + median[C_RADIUS] += bp->radius; + median[C_TILT] += bp->alfa; + if (!totcurvedata) { /* I.e. first time... */ + selp = bp; + seltype = &RNA_SplinePoint; + } + totcurvedata++; } bp++; } @@ -273,84 +302,102 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float nu = nu->next; } - if (totradius == 1) - RNA_pointer_create(&cu->id, seltype, selp, &radius_ptr); + if (totcurvedata == 1) + RNA_pointer_create(&cu->id, seltype, selp, &data_ptr); } else if (ob->type == OB_LATTICE) { Lattice *lt = ob->data; BPoint *bp; int a; + StructRNA *seltype = NULL; + void *selp = NULL; a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; bp = lt->editlatt->latt->def; while (a--) { if (bp->f1 & SELECT) { - add_v3_v3(median, bp->vec); + add_v3_v3(&median[LOC_X], bp->vec); tot++; - median[4] += bp->weight; - totweight++; + median[L_WEIGHT] += bp->weight; + if (!totlattdata) { /* I.e. first time... */ + selp = bp; + seltype = &RNA_LatticePoint; + } + totlattdata++; } bp++; } + + if (totlattdata == 1) + RNA_pointer_create(<->id, seltype, selp, &data_ptr); } if (tot == 0) { uiDefBut(block, LABEL, 0, IFACE_("Nothing selected"), 0, 130, 200, 20, NULL, 0, 0, 0, 0, ""); return; } - median[0] /= (float)tot; - median[1] /= (float)tot; - median[2] /= (float)tot; - if (totedge) { - median[3] /= (float)totedge; - median[6] /= (float)totedge; - } - else if (totw) - median[3] /= (float)totw; - if (totweight) - median[4] /= (float)totweight; - if (totradius) - median[5] /= (float)totradius; - if (totskinradius) { - median[7] /= (float)totskinradius; - median[8] /= (float)totskinradius; - } + /* Location, X/Y/Z */ + mul_v3_fl(&median[LOC_X], 1.0f / (float)tot); if (v3d->flag & V3D_GLOBAL_STATS) - mul_m4_v3(ob->obmat, median); + mul_m4_v3(ob->obmat, &median[LOC_X]); + + if (meshdata) { + if (totedgedata) { + median[M_CREASE] /= (float)totedgedata; + median[M_WEIGHT] /= (float)totedgedata; + } + if (totskinradius) { + median[M_SKIN_X] /= (float)totskinradius; + median[M_SKIN_Y] /= (float)totskinradius; + } + } + else if (totcurvedata) { + median[C_WEIGHT] /= (float)totcurvedata; + median[C_RADIUS] /= (float)totcurvedata; + median[C_TILT] /= (float)totcurvedata; + if (totcurvebweight) + median[C_BWEIGHT] /= (float)totcurvebweight; + } + else if (totlattdata) + median[L_WEIGHT] /= (float)totlattdata; if (block) { /* buttons */ uiBut *but; int yi = 200; const int buth = 20 * UI_DPI_ICON_FAC; const int but_margin = 2; + const char *c; memcpy(tfp->ve_median, median, sizeof(tfp->ve_median)); uiBlockBeginAlign(block); if (tot == 1) { - uiDefBut(block, LABEL, 0, IFACE_("Vertex:"), 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, ""); - } - else { - uiDefBut(block, LABEL, 0, IFACE_("Median:"), 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, ""); + if (totcurvedata) /* Curve */ + c = IFACE_("Control Point:"); + else /* Mesh or lattice */ + c = IFACE_("Vertex:"); } + else + c = IFACE_("Median:"); + uiDefBut(block, LABEL, 0, c, 0, yi -= buth, 200, buth, NULL, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); /* Should be no need to translate these. */ but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "X:", 0, yi -= buth, 200, buth, - &(tfp->ve_median[0]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); + &(tfp->ve_median[LOC_X]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); uiButSetUnitType(but, PROP_UNIT_LENGTH); but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Y:", 0, yi -= buth, 200, buth, - &(tfp->ve_median[1]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); + &(tfp->ve_median[LOC_Y]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); uiButSetUnitType(but, PROP_UNIT_LENGTH); but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Z:", 0, yi -= buth, 200, buth, - &(tfp->ve_median[2]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); + &(tfp->ve_median[LOC_Z]), -lim, lim, 10, RNA_TRANSLATION_PREC_DEFAULT, ""); uiButSetUnitType(but, PROP_UNIT_LENGTH); - if (totw == tot) { + if (totcurvebweight == tot) { uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "W:", 0, yi -= buth, 200, buth, - &(tfp->ve_median[3]), 0.01, 100.0, 1, 3, ""); + &(tfp->ve_median[C_BWEIGHT]), 0.01, 100.0, 1, 3, ""); } uiBlockBeginAlign(block); @@ -362,60 +409,60 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float &v3d->flag, 0, 0, 0, 0, "Displays local values"); uiBlockEndAlign(block); - if (totweight == 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Weight:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[4]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); + /* Meshes... */ + if (meshdata) { + if (totedgedata) { + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, + totedgedata == 1 ? IFACE_("Crease:") : IFACE_("Mean Crease:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[M_CREASE]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier")); + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, + totedgedata == 1 ? IFACE_("Bevel Weight:") : IFACE_("Mean Bevel Weight:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[M_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier")); + } + if (totskinradius) { + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, + totskinradius == 1 ? IFACE_("Radius X:") : IFACE_("Mean Radius X:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[M_SKIN_X]), 0.0, 100.0, 1, 3, TIP_("X radius used by Skin modifier")); + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, + totskinradius == 1 ? IFACE_("Radius Y:") : IFACE_("Mean Radius Y:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[M_SKIN_Y]), 0.0, 100.0, 1, 3, TIP_("Y radius used by Skin modifier")); + } } - else if (totweight > 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), - 0, yi -= buth, 200, buth, - &(tfp->ve_median[4]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); + /* Curve... */ + else if (totcurvedata == 1) { + uiDefButR(block, NUM, 0, "Weight", 0, yi -= buth + but_margin, 200, buth, + &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL); + uiDefButR(block, NUM, 0, "Radius", 0, yi -= buth + but_margin, 200, buth, + &data_ptr, "radius", 0, 0.0, 100.0, 1, 3, NULL); + uiDefButR(block, NUM, 0, "Tilt", 0, yi -= buth + but_margin, 200, buth, + &data_ptr, "tilt", 0, -M_PI * 2.0f, M_PI * 2.0f, 1, 3, NULL); } - - if (totradius == 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Radius:"), + else if (totcurvedata > 1) { + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[5]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points")); - } - else if (totradius > 1) { + &(tfp->ve_median[C_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius:"), 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[5]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points")); - } - - if (totskinradius == 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Radius X:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[7]), 0.0, 100.0, 1, 3, TIP_("X radius used by Skin modifier")); - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Radius Y:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[8]), 0.0, 100.0, 1, 3, TIP_("Y radius used by Skin modifier")); - } - else if (totskinradius > 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius X:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[7]), 0.0, 100.0, 1, 3, TIP_("Median X radius used by Skin modifier")); - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius Y:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[8]), 0.0, 100.0, 1, 3, TIP_("Median Y radius used by Skin modifier")); + &(tfp->ve_median[C_RADIUS]), 0.0, 100.0, 1, 3, TIP_("Radius of curve control points")); + but = uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Tilt:"), + 0, yi -= buth + but_margin, 200, buth, + &(tfp->ve_median[C_TILT]), -M_PI * 2.0f, M_PI * 2.0f, 1, 3, + TIP_("Tilt (inclination) of curve control points")); + uiButSetUnitType(but, PROP_UNIT_ROTATION); } - - if (totedge == 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Crease:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[3]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier")); - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Bevel Weight:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[6]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier")); + /* Lattice... */ + else if (totlattdata == 1) { + uiDefButR(block, NUM, 0, "Weight", 0, yi -= buth + but_margin, 200, buth, + &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL); } - else if (totedge > 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Crease:"), - 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[3]), 0.0, 1.0, 1, 3, TIP_("Weight used by SubSurf modifier")); - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Bevel Weight:"), + else if (totlattdata > 1) { + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), 0, yi -= buth + but_margin, 200, buth, - &(tfp->ve_median[6]), 0.0, 1.0, 1, 3, TIP_("Weight used by Bevel modifier")); + &(tfp->ve_median[L_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); } uiBlockEndAlign(block); @@ -427,16 +474,12 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if (v3d->flag & V3D_GLOBAL_STATS) { invert_m4_m4(ob->imat, ob->obmat); - mul_m4_v3(ob->imat, median); - mul_m4_v3(ob->imat, ve_median); + mul_m4_v3(ob->imat, &median[LOC_X]); + mul_m4_v3(ob->imat, &ve_median[LOC_X]); } - sub_v3_v3v3(median, ve_median, median); - median[3] = ve_median[3] - median[3]; - median[4] = ve_median[4] - median[4]; - median[5] = ve_median[5] - median[5]; - median[6] = ve_median[6] - median[6]; - median[7] = ve_median[7] - median[7]; - median[8] = ve_median[8] - median[8]; + i = NBR_TRANSFORM_PROPERTIES; + while (i--) + median[i] = ve_median[i] - median[i]; if (ob->type == OB_MESH) { Mesh *me = ob->data; @@ -445,20 +488,20 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float BMVert *eve; BMIter iter; - if (len_v3(median) > 0.000001f) { + if (len_v3(&median[LOC_X]) > 0.000001f) { BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - add_v3_v3(eve->co, median); + add_v3_v3(eve->co, &median[LOC_X]); } } EDBM_mesh_normals_update(em); } - if (median[3] != 0.0f) { + if (median[M_CREASE] != 0.0f) { BMEdge *eed; - const float sca = compute_scale_factor(ve_median[3], median[3]); + const float sca = compute_scale_factor(ve_median[M_CREASE], median[M_CREASE]); if (ELEM(sca, 0.0f, 1.0f)) { BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { @@ -494,9 +537,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } - if (median[6] != 0.0f) { + if (median[M_WEIGHT] != 0.0f) { BMEdge *eed; - const float sca = compute_scale_factor(ve_median[6], median[6]); + const float sca = compute_scale_factor(ve_median[M_WEIGHT], median[M_WEIGHT]); if (ELEM(sca, 0.0f, 1.0f)) { BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) { @@ -532,11 +575,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } - if (median[7] != 0.0f) { + if (median[M_SKIN_X] != 0.0f) { BMVert *eve; /* That one is not clamped to [0.0, 1.0]. */ - float sca = ve_median[7]; - if (ve_median[7] - median[7] == 0.0f) { + float sca = ve_median[M_SKIN_X]; + if (ve_median[M_SKIN_X] - median[M_SKIN_X] == 0.0f) { BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN); @@ -546,7 +589,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } else { - sca /= (ve_median[7] - median[7]); + sca /= (ve_median[M_SKIN_X] - median[M_SKIN_X]); BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN); @@ -556,11 +599,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } } - if (median[8] != 0.0f) { + if (median[M_SKIN_Y] != 0.0f) { BMVert *eve; /* That one is not clamped to [0.0, 1.0]. */ - float sca = ve_median[8]; - if (ve_median[8] - median[8] == 0.0f) { + float sca = ve_median[M_SKIN_Y]; + if (ve_median[M_SKIN_Y] - median[M_SKIN_Y] == 0.0f) { BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN); @@ -570,7 +613,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } else { - sca /= (ve_median[8] - median[8]); + sca /= (ve_median[M_SKIN_Y] - median[M_SKIN_Y]); BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { MVertSkin *vs = (MVertSkin *)CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MVERT_SKIN); @@ -589,7 +632,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float BezTriple *bezt; int a; ListBase *nurbs = BKE_curve_editNurbs_get(cu); - const float scale_w = compute_scale_factor(ve_median[4], median[4]); + const float scale_w = compute_scale_factor(ve_median[C_WEIGHT], median[C_WEIGHT]); nu = nurbs->first; while (nu) { @@ -598,11 +641,11 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float a = nu->pntsu; while (a--) { if (bezt->f2 & SELECT) { - add_v3_v3(bezt->vec[0], median); - add_v3_v3(bezt->vec[1], median); - add_v3_v3(bezt->vec[2], median); + add_v3_v3(bezt->vec[0], &median[LOC_X]); + add_v3_v3(bezt->vec[1], &median[LOC_X]); + add_v3_v3(bezt->vec[2], &median[LOC_X]); - if (median[4] != 0.0f) { + if (median[C_WEIGHT] != 0.0f) { if (ELEM(scale_w, 0.0f, 1.0f)) { bezt->weight = scale_w; } @@ -613,14 +656,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } - bezt->radius += median[5]; + bezt->radius += median[C_RADIUS]; + bezt->alfa += median[C_TILT]; } else { if (bezt->f1 & SELECT) { - add_v3_v3(bezt->vec[0], median); + add_v3_v3(bezt->vec[0], &median[LOC_X]); } if (bezt->f3 & SELECT) { - add_v3_v3(bezt->vec[2], median); + add_v3_v3(bezt->vec[2], &median[LOC_X]); } } bezt++; @@ -631,10 +675,10 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & SELECT) { - add_v3_v3(bp->vec, median); - bp->vec[3] += median[3]; + add_v3_v3(bp->vec, &median[LOC_X]); + bp->vec[3] += median[C_BWEIGHT]; - if (median[4] != 0.0f) { + if (median[C_WEIGHT] != 0.0f) { if (ELEM(scale_w, 0.0f, 1.0f)) { bp->weight = scale_w; } @@ -645,7 +689,8 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } - bp->radius += median[5]; + bp->radius += median[C_RADIUS]; + bp->alfa += median[C_TILT]; } bp++; } @@ -660,15 +705,15 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float Lattice *lt = ob->data; BPoint *bp; int a; - const float scale_w = compute_scale_factor(ve_median[4], median[4]); + const float scale_w = compute_scale_factor(ve_median[L_WEIGHT], median[L_WEIGHT]); a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; bp = lt->editlatt->latt->def; while (a--) { if (bp->f1 & SELECT) { - add_v3_v3(bp->vec, median); + add_v3_v3(bp->vec, &median[LOC_X]); - if (median[4] != 0.0f) { + if (median[L_WEIGHT] != 0.0f) { if (ELEM(scale_w, 0.0f, 1.0f)) { bp->weight = scale_w; } @@ -685,7 +730,28 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float /* ED_undo_push(C, "Transform properties"); */ } + +/* Clean up! */ +/* Location, common to all. */ +#undef LOC_X +#undef LOC_Y +#undef LOC_Z +/* Meshes (and lattice)... */ +#undef M_CREASE +#undef M_WEIGHT +#undef M_SKIN_X +#undef M_SKIN_Y +/* Curves... */ +#undef C_BWEIGHT +#undef C_WEIGHT +#undef C_RADIUS +#undef C_TILT +/* Lattice... */ +#undef L_WEIGHT } +#undef NBR_TRANSFORM_PROPERTIES + + #define B_VGRP_PNL_COPY 1 #define B_VGRP_PNL_NORMALIZE 2 #define B_VGRP_PNL_EDIT_SINGLE 8 /* or greater */ @@ -1161,7 +1227,6 @@ static void view3d_panel_object(const bContext *C, Panel *pa) uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); col = uiLayoutColumn(pa->layout, FALSE); - /* row = uiLayoutRow(col, FALSE); */ /* UNUSED */ RNA_id_pointer_create(&ob->id, &obptr); if (ob == obedit) { -- cgit v1.2.3 From 58e8d0b57e5559567751bc4c25eaad7bd9919a8f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 9 Oct 2012 09:38:05 +0000 Subject: OSX zoom pinch was using inverted direction --- source/blender/editors/interface/view2d_ops.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index eb2f6c62351..2c8db53b534 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -941,10 +941,15 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) /* As we have only 1D information (magnify value), feed both axes * with magnify information that is stored in x axis */ - fac = 0.01f * (event->x - event->prevx); + fac = 0.01f * (event->prevx - event->x); dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f; dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f; + if (U.uiflag & USER_ZOOM_INVERT) { + dx *= -1; + dy *= -1; + } + RNA_float_set(op->ptr, "deltax", dx); RNA_float_set(op->ptr, "deltay", dy); -- cgit v1.2.3 From 66edeae182f0afab2eeb8f9988df36aa112972e9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 9 Oct 2012 10:20:25 +0000 Subject: Style cleanup - replace #define lists with enums --- source/blender/makesdna/DNA_userdef_types.h | 415 +++++++++++++++------------- 1 file changed, 229 insertions(+), 186 deletions(-) diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 4c196a15db1..c10850d74e6 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -49,11 +49,14 @@ struct ColorBand; #define MAX_STYLE_NAME 64 /* default uifont_id offered by Blender */ -#define UIFONT_DEFAULT 0 -/*#define UIFONT_BITMAP 1*/ /*UNUSED*/ -/* free slots */ -#define UIFONT_CUSTOM1 2 -#define UIFONT_CUSTOM2 3 +typedef enum eUIFont_ID { + UIFONT_DEFAULT = 0, +/* UIFONT_BITMAP = 1 */ /* UNUSED */ + + /* free slots */ + UIFONT_CUSTOM1 = 2, + UIFONT_CUSTOM2 = 3 +} eUIFont_ID; /* default fonts to load/initalize */ /* first font is the default (index 0), others optional */ @@ -64,7 +67,6 @@ typedef struct uiFont { short uifont_id; /* own id */ short r_to_l; /* fonts that read from left to right */ short pad; - } uiFont; /* this state defines appearance of text */ @@ -79,13 +81,14 @@ typedef struct uiFontStyle { short align; /* text align hint */ float shadowalpha; /* total alpha */ float shadowcolor; /* 1 value, typically white or black anyway */ - } uiFontStyle; /* uiFontStyle->align */ -#define UI_STYLE_TEXT_LEFT 0 -#define UI_STYLE_TEXT_CENTER 1 -#define UI_STYLE_TEXT_RIGHT 2 +typedef enum eFontStyle_Align { + UI_STYLE_TEXT_LEFT = 0, + UI_STYLE_TEXT_CENTER = 1, + UI_STYLE_TEXT_RIGHT = 2 +} eFontStyle_Align; /* this is fed to the layout engine and widget code */ @@ -145,7 +148,6 @@ typedef struct uiPanelColors { } uiPanelColors; typedef struct ThemeUI { - /* Interface Elements (buttons, menus, icons) */ uiWidgetColors wcol_regular, wcol_tool, wcol_text; uiWidgetColors wcol_radio, wcol_option, wcol_toggle; @@ -209,8 +211,8 @@ typedef struct ThemeSpace { char vertex[4], vertex_select[4]; char edge[4], edge_select[4]; char edge_seam[4], edge_sharp[4], edge_facesel[4], edge_crease[4]; - char face[4], face_select[4]; // solid faces - char face_dot[4]; // selected color + char face[4], face_select[4]; /* solid faces */ + char face_dot[4]; /* selected color */ char extra_edge_len[4], extra_face_angle[4], extra_face_area[4], pad3[4]; char normal[4]; char vertex_normal[4]; @@ -224,7 +226,7 @@ typedef struct ThemeSpace { char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], handle_auto_clamped[4]; char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], handle_sel_auto_clamped[4]; - char ds_channel[4], ds_subchannel[4]; // dopesheet + char ds_channel[4], ds_subchannel[4]; /* dopesheet */ char console_output[4], console_input[4], console_info[4], console_error[4]; char console_cursor[4]; @@ -232,10 +234,10 @@ typedef struct ThemeSpace { char vertex_size, outline_width, facedot_size; char noodle_curving; - char syntaxl[4], syntaxn[4], syntaxb[4]; // syntax for textwindow and nodes + char syntaxl[4], syntaxn[4], syntaxb[4]; /* syntax for textwindow and nodes */ char syntaxv[4], syntaxc[4]; - char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; // for sequence editor + char movie[4], movieclip[4], mask[4], image[4], scene[4], audio[4]; /* for sequence editor */ char effect[4], hpad0[4], transition[4], meta[4]; char editmesh_active[4]; @@ -287,8 +289,10 @@ typedef struct ThemeWireColor { } ThemeWireColor; /* flags for ThemeWireColor */ -#define TH_WIRECOLOR_CONSTCOLS (1<<0) -#define TH_WIRECOLOR_TEXTCOLS (1<<1) +typedef enum eWireColor_Flags { + TH_WIRECOLOR_CONSTCOLS = (1 << 0), + TH_WIRECOLOR_TEXTCOLS = (1 << 1), +} eWireColor_Flags; /* A theme */ typedef struct bTheme { @@ -321,7 +325,6 @@ typedef struct bTheme { /*ThemeWireColor tobj[20];*/ int active_theme_area, pad; - } bTheme; /* for the moment only the name. may want to store options with this later */ @@ -345,8 +348,8 @@ typedef struct UserDef { char pythondir[768]; char sounddir[768]; char i18ndir[768]; - char image_editor[1024]; /* 1024 = FILE_MAX */ - char anim_player[1024]; /* 1024 = FILE_MAX */ + char image_editor[1024]; /* 1024 = FILE_MAX */ + char anim_player[1024]; /* 1024 = FILE_MAX */ int anim_player_preset; short v2d_min_gridsize; /* minimum spacing between gridlines in View2D grids */ @@ -393,7 +396,7 @@ typedef struct UserDef { int memcachelimit; int prefetchframes; short frameserverport; - short pad_rot_angle; /*control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use*/ + short pad_rot_angle; /* control the rotation step of the view when PAD2, PAD4, PAD6&PAD8 is use */ short obcenter_dia; short rvisize; /* rotating view icon size */ short rvibright; /* rotating view icon brightness */ @@ -422,7 +425,7 @@ typedef struct UserDef { short autokey_mode; /* autokeying mode */ short autokey_flag; /* flags for autokeying */ - short text_render, pad9; /*options for text rendering*/ + short text_render, pad9; /* options for text rendering */ struct ColorBand coba_weight; /* from texture.h */ @@ -445,218 +448,258 @@ extern UserDef U; /* from blenkernel blender.c */ /* ***************** USERDEF ****************** */ /* userpref/section */ -#define USER_SECTION_INTERFACE 0 -#define USER_SECTION_EDIT 1 -#define USER_SECTION_FILE 2 -#define USER_SECTION_SYSTEM 3 -#define USER_SECTION_THEME 4 -#define USER_SECTION_INPUT 5 -#define USER_SECTION_ADDONS 6 +typedef enum eUserPref_Section { + USER_SECTION_INTERFACE = 0, + USER_SECTION_EDIT = 1, + USER_SECTION_FILE = 2, + USER_SECTION_SYSTEM = 3, + USER_SECTION_THEME = 4, + USER_SECTION_INPUT = 5, + USER_SECTION_ADDONS = 6, +} eUserPref_Section; /* flag */ -#define USER_AUTOSAVE (1 << 0) -/*#define USER_AUTOGRABGRID (1 << 1) deprecated */ -/*#define USER_AUTOROTGRID (1 << 2) deprecated */ -/*#define USER_AUTOSIZEGRID (1 << 3) deprecated */ -#define USER_SCENEGLOBAL (1 << 4) -#define USER_TRACKBALL (1 << 5) -/*#define USER_DUPLILINK (1 << 6) deprecated */ -/*#define USER_FSCOLLUM (1 << 7) deprecated */ -#define USER_MAT_ON_OB (1 << 8) -/*#define USER_NO_CAPSLOCK (1 << 9)*/ /* not used anywhere */ -/*#define USER_VIEWMOVE (1 << 10)*/ /* not used anywhere */ -#define USER_TOOLTIPS (1 << 11) -#define USER_TWOBUTTONMOUSE (1 << 12) -#define USER_NONUMPAD (1 << 13) -#define USER_LMOUSESELECT (1 << 14) -#define USER_FILECOMPRESS (1 << 15) -#define USER_SAVE_PREVIEWS (1 << 16) -#define USER_CUSTOM_RANGE (1 << 17) -#define USER_ADD_EDITMODE (1 << 18) -#define USER_ADD_VIEWALIGNED (1 << 19) -#define USER_RELPATHS (1 << 20) -#define USER_RELEASECONFIRM (1 << 21) -#define USER_SCRIPT_AUTOEXEC_DISABLE (1 << 22) -#define USER_FILENOUI (1 << 23) -#define USER_NONEGFRAMES (1 << 24) -#define USER_TXT_TABSTOSPACES_DISABLE (1 << 25) -#define USER_TOOLTIPS_PYTHON (1 << 26) - +typedef enum eUserPref_Flag { + USER_AUTOSAVE = (1 << 0), +/* USER_AUTOGRABGRID = (1 << 1), deprecated */ +/* USER_AUTOROTGRID = (1 << 2), deprecated */ +/* USER_AUTOSIZEGRID = (1 << 3), deprecated */ + USER_SCENEGLOBAL = (1 << 4), + USER_TRACKBALL = (1 << 5), +/* USER_DUPLILINK = (1 << 6), deprecated */ +/* USER_FSCOLLUM = (1 << 7), deprecated */ + USER_MAT_ON_OB = (1 << 8), +/* USER_NO_CAPSLOCK = (1 << 9), */ /* not used anywhere */ +/* USER_VIEWMOVE = (1 << 10), */ /* not used anywhere */ + USER_TOOLTIPS = (1 << 11), + USER_TWOBUTTONMOUSE = (1 << 12), + USER_NONUMPAD = (1 << 13), + USER_LMOUSESELECT = (1 << 14), + USER_FILECOMPRESS = (1 << 15), + USER_SAVE_PREVIEWS = (1 << 16), + USER_CUSTOM_RANGE = (1 << 17), + USER_ADD_EDITMODE = (1 << 18), + USER_ADD_VIEWALIGNED = (1 << 19), + USER_RELPATHS = (1 << 20), + USER_RELEASECONFIRM = (1 << 21), + USER_SCRIPT_AUTOEXEC_DISABLE = (1 << 22), + USER_FILENOUI = (1 << 23), + USER_NONEGFRAMES = (1 << 24), + USER_TXT_TABSTOSPACES_DISABLE = (1 << 25), + USER_TOOLTIPS_PYTHON = (1 << 26), +} eUserPref_Flag; + /* helper macro for checking frame clamping */ #define FRAMENUMBER_MIN_CLAMP(cfra) { \ if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \ cfra = 0; \ } (void)0 -/* viewzom */ -#define USER_ZOOM_CONT 0 -#define USER_ZOOM_SCALE 1 -#define USER_ZOOM_DOLLY 2 +/* viewzoom */ +typedef enum eViewZoom_Style { + USER_ZOOM_CONT = 0, + USER_ZOOM_SCALE = 1, + USER_ZOOM_DOLLY = 2 +} eViewZoom_Style; /* uiflag */ -// old flag for #define USER_KEYINSERTACT (1 << 0) -// old flag for #define USER_KEYINSERTOBJ (1 << 1) -#define USER_WHEELZOOMDIR (1 << 2) -#define USER_FILTERFILEEXTS (1 << 3) -#define USER_DRAWVIEWINFO (1 << 4) -#define USER_PLAINMENUS (1 << 5) // old EVTTOCONSOLE print ghost events, here for tuhopuu compat. --phase - // old flag for hide pulldown was here -/*#define USER_FLIPFULLSCREEN (1 << 7)*/ /* deprecated */ -#define USER_ALLWINCODECS (1 << 8) -#define USER_MENUOPENAUTO (1 << 9) -#define USER_ZBUF_CURSOR (1 << 10) -#define USER_AUTOPERSP (1 << 11) -#define USER_LOCKAROUND (1 << 12) -#define USER_GLOBALUNDO (1 << 13) -#define USER_ORBIT_SELECTION (1 << 14) -#define USER_ZBUF_ORBIT (1 << 15) -#define USER_HIDE_DOT (1 << 16) -#define USER_SHOW_ROTVIEWICON (1 << 17) -#define USER_SHOW_VIEWPORTNAME (1 << 18) -#define USER_CAM_LOCK_NO_PARENT (1 << 19) -#define USER_ZOOM_TO_MOUSEPOS (1 << 20) -#define USER_SHOW_FPS (1 << 21) -#define USER_MMB_PASTE (1 << 22) -#define USER_MENUFIXEDORDER (1 << 23) -#define USER_CONTINUOUS_MOUSE (1 << 24) -#define USER_ZOOM_INVERT (1 << 25) -#define USER_ZOOM_HORIZ (1 << 26) /* for CONTINUE and DOLLY zoom */ -#define USER_SPLASH_DISABLE (1 << 27) -#define USER_HIDE_RECENT (1 << 28) -#define USER_SHOW_THUMBNAILS (1 << 29) -#define USER_QUIT_PROMPT (1 << 30) +typedef enum eUserpref_UI_Flag { + /* flags 0 and 1 were old flags (for autokeying) that aren't used anymore */ + USER_WHEELZOOMDIR = (1 << 2), + USER_FILTERFILEEXTS = (1 << 3), + USER_DRAWVIEWINFO = (1 << 4), + USER_PLAINMENUS = (1 << 5), + /* flags 6 and 7 were old flags that are no-longer used */ + USER_ALLWINCODECS = (1 << 8), + USER_MENUOPENAUTO = (1 << 9), + USER_ZBUF_CURSOR = (1 << 10), + USER_AUTOPERSP = (1 << 11), + USER_LOCKAROUND = (1 << 12), + USER_GLOBALUNDO = (1 << 13), + USER_ORBIT_SELECTION = (1 << 14), + USER_ZBUF_ORBIT = (1 << 15), + USER_HIDE_DOT = (1 << 16), + USER_SHOW_ROTVIEWICON = (1 << 17), + USER_SHOW_VIEWPORTNAME = (1 << 18), + USER_CAM_LOCK_NO_PARENT = (1 << 19), + USER_ZOOM_TO_MOUSEPOS = (1 << 20), + USER_SHOW_FPS = (1 << 21), + USER_MMB_PASTE = (1 << 22), + USER_MENUFIXEDORDER = (1 << 23), + USER_CONTINUOUS_MOUSE = (1 << 24), + USER_ZOOM_INVERT = (1 << 25), + USER_ZOOM_HORIZ = (1 << 26), /* for CONTINUE and DOLLY zoom */ + USER_SPLASH_DISABLE = (1 << 27), + USER_HIDE_RECENT = (1 << 28), + USER_SHOW_THUMBNAILS = (1 << 29), + USER_QUIT_PROMPT = (1 << 30) +} eUserpref_UI_Flag; /* Auto-Keying mode */ +typedef enum eAutokey_Mode { /* AUTOKEY_ON is a bitflag */ -#define AUTOKEY_ON 1 + AUTOKEY_ON = 1, + /* AUTOKEY_ON + 2**n... (i.e. AUTOKEY_MODE_NORMAL = AUTOKEY_ON + 2) to preserve setting, even when autokey turned off */ -#define AUTOKEY_MODE_NORMAL 3 -#define AUTOKEY_MODE_EDITKEYS 5 + AUTOKEY_MODE_NORMAL = 3, + AUTOKEY_MODE_EDITKEYS = 5 +} eAutokey_Mode; /* Auto-Keying flag * U.autokey_flag (not strictly used when autokeying only - is also used when keyframing these days) * note: AUTOKEY_FLAG_* is used with a macro, search for lines like IS_AUTOKEY_FLAG(INSERTAVAIL) */ -#define AUTOKEY_FLAG_INSERTAVAIL (1<<0) -#define AUTOKEY_FLAG_INSERTNEEDED (1<<1) -#define AUTOKEY_FLAG_AUTOMATKEY (1<<2) -#define AUTOKEY_FLAG_XYZ2RGB (1<<3) - -/* toolsettings->autokey_flag */ -#define AUTOKEY_FLAG_ONLYKEYINGSET (1<<6) -#define AUTOKEY_FLAG_NOWARNING (1<<7) -#define ANIMRECORD_FLAG_WITHNLA (1<<10) +typedef enum eAutokey_Flag { + AUTOKEY_FLAG_INSERTAVAIL = (1 << 0), + AUTOKEY_FLAG_INSERTNEEDED = (1 << 1), + AUTOKEY_FLAG_AUTOMATKEY = (1 << 2), + AUTOKEY_FLAG_XYZ2RGB = (1 << 3), + + /* toolsettings->autokey_flag */ + AUTOKEY_FLAG_ONLYKEYINGSET = (1 << 6), + AUTOKEY_FLAG_NOWARNING = (1 << 7), + ANIMRECORD_FLAG_WITHNLA = (1 << 10), +} eAutokey_Flag; /* transopts */ -#define USER_TR_TOOLTIPS (1 << 0) -#define USER_TR_IFACE (1 << 1) -/*#define USER_TR_MENUS (1 << 2) deprecated*/ -/*#define USER_TR_FILESELECT (1 << 3) deprecated*/ -/*#define USER_TR_TEXTEDIT (1 << 4) deprecated*/ -#define USER_DOTRANSLATE (1 << 5) -#define USER_USETEXTUREFONT (1 << 6) -/*#define CONVERT_TO_UTF8 (1 << 7) deprecated*/ +typedef enum eUserpref_Translation_Flags { + USER_TR_TOOLTIPS = (1 << 0), + USER_TR_IFACE = (1 << 1), +/* USER_TR_MENUS = (1 << 2) deprecated */ +/* USER_TR_FILESELECT = (1 << 3) deprecated */ +/* USER_TR_TEXTEDIT = (1 << 4) deprecated */ + USER_DOTRANSLATE = (1 << 5), + USER_USETEXTUREFONT = (1 << 6), +/* CONVERT_TO_UTF8 = (1 << 7) deprecated */ +} eUserpref_Translation_Flags; /* dupflag */ -#define USER_DUP_MESH (1 << 0) -#define USER_DUP_CURVE (1 << 1) -#define USER_DUP_SURF (1 << 2) -#define USER_DUP_FONT (1 << 3) -#define USER_DUP_MBALL (1 << 4) -#define USER_DUP_LAMP (1 << 5) -#define USER_DUP_IPO (1 << 6) -#define USER_DUP_MAT (1 << 7) -#define USER_DUP_TEX (1 << 8) -#define USER_DUP_ARM (1 << 9) -#define USER_DUP_ACT (1 << 10) -#define USER_DUP_PSYS (1 << 11) +typedef enum eDupli_ID_Flags { + USER_DUP_MESH = (1 << 0), + USER_DUP_CURVE = (1 << 1), + USER_DUP_SURF = (1 << 2), + USER_DUP_FONT = (1 << 3), + USER_DUP_MBALL = (1 << 4), + USER_DUP_LAMP = (1 << 5), + USER_DUP_IPO = (1 << 6), + USER_DUP_MAT = (1 << 7), + USER_DUP_TEX = (1 << 8), + USER_DUP_ARM = (1 << 9), + USER_DUP_ACT = (1 << 10), + USER_DUP_PSYS = (1 << 11) +} eDupli_ID_Flags; /* gameflags */ -// #define USER_DEPRECATED_FLAG 1 -// #define USER_DISABLE_SOUND 2 deprecated, don't use without checking for -// backwards compatibilty in do_versions! -#define USER_DISABLE_MIPMAP 4 -#define USER_DISABLE_VBO 8 -#define USER_DISABLE_AA 16 +typedef enum eOpenGL_RenderingOptions { + /* USER_DEPRECATED_FLAG = (1 << 0), */ + /* USER_DISABLE_SOUND = (1 << 1), */ /* deprecated, don't use without checking for */ + /* backwards compatibilty in do_versions! */ + USER_DISABLE_MIPMAP = (1 << 2), + USER_DISABLE_VBO = (1 << 3), + USER_DISABLE_AA = (1 << 4), +} eOpenGL_RenderingOptions; /* wm draw method */ -#define USER_DRAW_TRIPLE 0 -#define USER_DRAW_OVERLAP 1 -#define USER_DRAW_FULL 2 -#define USER_DRAW_AUTOMATIC 3 -#define USER_DRAW_OVERLAP_FLIP 4 - -/* text draw options*/ -#define USER_TEXT_DISABLE_AA (1 << 0) +typedef enum eWM_DrawMethod { + USER_DRAW_TRIPLE = 0, + USER_DRAW_OVERLAP = 1, + USER_DRAW_FULL = 2, + USER_DRAW_AUTOMATIC = 3, + USER_DRAW_OVERLAP_FLIP = 4, +} eWM_DrawMethod; + +/* text draw options */ +typedef enum eText_Draw_Options { + USER_TEXT_DISABLE_AA = (1 << 0), +} eText_Draw_Options; /* tw_flag (transform widget) */ /* gp_settings (Grease Pencil Settings) */ -#define GP_PAINT_DOSMOOTH (1<<0) -#define GP_PAINT_DOSIMPLIFY (1<<1) +typedef enum eGP_UserdefSettings { + GP_PAINT_DOSMOOTH = (1 << 0), + GP_PAINT_DOSIMPLIFY = (1 << 1), +} eGP_UserdefSettings; /* color picker types */ -#define USER_CP_CIRCLE 0 -#define USER_CP_SQUARE_SV 1 -#define USER_CP_SQUARE_HS 2 -#define USER_CP_SQUARE_HV 3 +typedef enum eColorPicker_Types { + USER_CP_CIRCLE = 0, + USER_CP_SQUARE_SV = 1, + USER_CP_SQUARE_HS = 2, + USER_CP_SQUARE_HV = 3, +} eColorPicker_Types; /* timecode display styles */ +typedef enum eTimecodeStyles { /* as little info as is necessary to show relevant info * with '+' to denote the frames * i.e. HH:MM:SS+FF, MM:SS+FF, SS+FF, or MM:SS */ -#define USER_TIMECODE_MINIMAL 0 + USER_TIMECODE_MINIMAL = 0, + /* reduced SMPTE - (HH:)MM:SS:FF */ -#define USER_TIMECODE_SMPTE_MSF 1 + USER_TIMECODE_SMPTE_MSF = 1, + /* full SMPTE - HH:MM:SS:FF */ -#define USER_TIMECODE_SMPTE_FULL 2 + USER_TIMECODE_SMPTE_FULL = 2, + /* milliseconds for sub-frames - HH:MM:SS.sss */ -#define USER_TIMECODE_MILLISECONDS 3 + USER_TIMECODE_MILLISECONDS = 3, + /* seconds only */ -#define USER_TIMECODE_SECONDS_ONLY 4 + USER_TIMECODE_SECONDS_ONLY = 4, +} eTimecodeStyles; /* theme drawtypes */ -#define TH_MINIMAL 0 -#define TH_ROUNDSHADED 1 -#define TH_ROUNDED 2 -#define TH_OLDSKOOL 3 -#define TH_SHADED 4 +/* XXX: These are probably only for the old UI engine? */ +typedef enum eTheme_DrawTypes { + TH_MINIMAL = 0, + TH_ROUNDSHADED = 1, + TH_ROUNDED = 2, + TH_OLDSKOOL = 3, + TH_SHADED = 4 +} eTheme_DrawTypes; /* ndof_flag (3D mouse options) */ -#define NDOF_SHOW_GUIDE (1 << 0) -#define NDOF_FLY_HELICOPTER (1 << 1) -#define NDOF_LOCK_HORIZON (1 << 2) -/* the following might not need to be saved between sessions, - * but they do need to live somewhere accessible... */ -#define NDOF_SHOULD_PAN (1 << 3) -#define NDOF_SHOULD_ZOOM (1 << 4) -#define NDOF_SHOULD_ROTATE (1 << 5) -/* orbit navigation modes - * only two options, so it's sort of a hybrid bool/enum - * if ((U.ndof_flag & NDOF_ORBIT_MODE) == NDOF_OM_OBJECT)... */ - -// #define NDOF_ORBIT_MODE (1 << 6) -// #define NDOF_OM_TARGETCAMERA 0 -// #define NDOF_OM_OBJECT NDOF_ORBIT_MODE - -/* actually... users probably don't care about what the mode - * is called, just that it feels right */ -/* zoom is up/down if this flag is set (otherwise forward/backward) */ -#define NDOF_ZOOM_UPDOWN (1 << 7) -#define NDOF_ZOOM_INVERT (1 << 8) -#define NDOF_ROTATE_INVERT_AXIS (1 << 9) -#define NDOF_TILT_INVERT_AXIS (1 << 10) -#define NDOF_ROLL_INVERT_AXIS (1 << 11) -#define NDOF_PANX_INVERT_AXIS (1 << 12) -#define NDOF_PANY_INVERT_AXIS (1 << 13) -#define NDOF_PANZ_INVERT_AXIS (1 << 14) -#define NDOF_TURNTABLE (1 << 15) +typedef enum eNdof_Flag { + NDOF_SHOW_GUIDE = (1 << 0), + NDOF_FLY_HELICOPTER = (1 << 1), + NDOF_LOCK_HORIZON = (1 << 2), + + /* the following might not need to be saved between sessions, + * but they do need to live somewhere accessible... */ + NDOF_SHOULD_PAN = (1 << 3), + NDOF_SHOULD_ZOOM = (1 << 4), + NDOF_SHOULD_ROTATE = (1 << 5), + + /* orbit navigation modes + * only two options, so it's sort of a hybrid bool/enum + * if ((U.ndof_flag & NDOF_ORBIT_MODE) == NDOF_OM_OBJECT)... */ + + // NDOF_ORBIT_MODE = (1 << 6), + // #define NDOF_OM_TARGETCAMERA 0 + // #define NDOF_OM_OBJECT NDOF_ORBIT_MODE + + /* actually... users probably don't care about what the mode + * is called, just that it feels right */ + /* zoom is up/down if this flag is set (otherwise forward/backward) */ + NDOF_ZOOM_UPDOWN = (1 << 7), + NDOF_ZOOM_INVERT = (1 << 8), + NDOF_ROTATE_INVERT_AXIS = (1 << 9), + NDOF_TILT_INVERT_AXIS = (1 << 10), + NDOF_ROLL_INVERT_AXIS = (1 << 11), + NDOF_PANX_INVERT_AXIS = (1 << 12), + NDOF_PANY_INVERT_AXIS = (1 << 13), + NDOF_PANZ_INVERT_AXIS = (1 << 14), + NDOF_TURNTABLE = (1 << 15), +} eNdof_Flag; /* compute_device_type */ -#define USER_COMPUTE_DEVICE_NONE 0 -#define USER_COMPUTE_DEVICE_OPENCL 1 -#define USER_COMPUTE_DEVICE_CUDA 2 +typedef enum eCompute_Device_Type { + USER_COMPUTE_DEVICE_NONE = 0, + USER_COMPUTE_DEVICE_OPENCL = 1, + USER_COMPUTE_DEVICE_CUDA = 2, +} eCompute_Device_Type; #ifdef __cplusplus } -- cgit v1.2.3 From 33f35647e96b843e0df4c3304173bd39b7cc2dd5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 9 Oct 2012 10:33:18 +0000 Subject: Motion Tracking: move keyframe settings to per-tracking object settings --- release/scripts/startup/bl_ui/space_clip.py | 4 ++-- source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenkernel/intern/tracking.c | 13 ++++++------- source/blender/blenloader/intern/readfile.c | 19 +++++++++++++++++++ source/blender/editors/space_clip/clip_draw.c | 5 +++-- source/blender/editors/space_clip/tracking_ops.c | 9 ++++----- source/blender/makesdna/DNA_tracking_types.h | 7 ++++++- source/blender/makesrna/intern/rna_tracking.c | 24 ++++++++++++------------ 8 files changed, 53 insertions(+), 30 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 7732a0c6400..17dd1c9cdab 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -311,8 +311,8 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel): col = layout.column(align=True) col.active = not settings.use_tripod_solver - col.prop(settings, "keyframe_a") - col.prop(settings, "keyframe_b") + col.prop(tracking_object, "keyframe_a") + col.prop(tracking_object, "keyframe_b") col = layout.column(align=True) col.active = (tracking_object.is_camera and diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 741a001142f..e1c79f8d6c1 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 264 -#define BLENDER_SUBVERSION 1 +#define BLENDER_SUBVERSION 2 /* 262 was the last editmesh release but its has compatibility code for bmesh data, * so set the minversion to 2.61 */ diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index c9d7ec3964f..7d2fd520c37 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -169,8 +169,6 @@ void BKE_tracking_settings_init(MovieTracking *tracking) tracking->settings.default_minimum_correlation = 0.75; tracking->settings.default_pattern_size = 11; tracking->settings.default_search_size = 61; - tracking->settings.keyframe1 = 1; - tracking->settings.keyframe2 = 30; tracking->settings.dist = 1; tracking->settings.object_distance = 1; @@ -1179,6 +1177,8 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char tracking->objectnr = BLI_countlist(&tracking->objects) - 1; object->scale = 1.0f; + object->keyframe1 = 1; + object->keyframe2 = 30; BKE_tracking_object_unique_name(tracking, object); @@ -2755,10 +2755,11 @@ static int reconstruct_refine_intrinsics_get_flags(MovieTracking *tracking, Movi return flags; } -static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tracksbase) +static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, MovieTrackingObject *object) { + ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); int tot = 0; - int frame1 = tracking->settings.keyframe1, frame2 = tracking->settings.keyframe2; + int frame1 = object->keyframe1, frame2 = object->keyframe2; MovieTrackingTrack *track; track = tracksbase->first; @@ -2779,13 +2780,11 @@ static int reconstruct_count_tracks_on_both_keyframes(MovieTracking *tracking, L int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObject *object, char *error_msg, int error_size) { #ifdef WITH_LIBMV - ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object); - if (tracking->settings.motion_flag & TRACKING_MOTION_MODAL) { /* TODO: check for number of tracks? */ return TRUE; } - else if (reconstruct_count_tracks_on_both_keyframes(tracking, tracksbase) < 8) { + else if (reconstruct_count_tracks_on_both_keyframes(tracking, object) < 8) { BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fdb68d4cc17..606fd48dc2b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8016,6 +8016,25 @@ static void do_versions(FileData *fd, Library *lib, Main *main) do_version_ntree_tex_coord_from_dupli_264(NULL, NULL, ntree); } + if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 2)) { + MovieClip *clip; + + for (clip = main->movieclip.first; clip; clip = clip->id.next) { + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *tracking_object; + + for (tracking_object = tracking->objects.first; + tracking_object; + tracking_object = tracking_object->next) + { + if (tracking_object->keyframe1 == 0 && tracking_object->keyframe2 == 0) { + tracking_object->keyframe1 = tracking->settings.keyframe1; + tracking_object->keyframe2 = tracking->settings.keyframe2; + } + } + } + } + /* 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/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 5e940df2a30..d7936c1e2e8 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -117,6 +117,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc int *points, totseg, i, a; float sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1); MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *act_object = BKE_tracking_object_get_active(tracking); MovieTrackingTrack *act_track = BKE_tracking_track_get_active(&clip->tracking); MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); @@ -218,8 +219,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc /* solver keyframes */ glColor4ub(175, 255, 0, 255); - draw_keyframe(tracking->settings.keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2); - draw_keyframe(tracking->settings.keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2); + draw_keyframe(act_object->keyframe1 + clip->start_frame - 1, CFRA, sfra, framelen, 2); + draw_keyframe(act_object->keyframe2 + clip->start_frame - 1, CFRA, sfra, framelen, 2); /* movie clip animation */ if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) { diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 97f7d7bf132..8dc28bbaee0 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1343,7 +1343,6 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op MovieClip *clip = ED_space_clip_get_clip(sc); Scene *scene = CTX_data_scene(C); MovieTracking *tracking = &clip->tracking; - MovieTrackingSettings *settings = &clip->tracking.settings; MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); int width, height; @@ -1359,7 +1358,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op scj->user = sc->user; scj->context = BKE_tracking_reconstruction_context_new(tracking, object, - settings->keyframe1, settings->keyframe2, width, height); + object->keyframe1, object->keyframe2, width, height); tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats"); @@ -2859,14 +2858,14 @@ static int set_solver_keyframe_exec(bContext *C, wmOperator *op) SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; - MovieTrackingSettings *settings = &tracking->settings; + MovieTrackingObject *object = BKE_tracking_object_get_active(tracking); int keyframe = RNA_enum_get(op->ptr, "keyframe"); int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr); if (keyframe == 0) - settings->keyframe1 = framenr; + object->keyframe1 = framenr; else - settings->keyframe2 = framenr; + object->keyframe2 = framenr; WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 1ab64ed1cc1..c6cefce2994 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -162,7 +162,10 @@ typedef struct MovieTrackingSettings { short speed; /* speed of tracking */ /* ** reconstruction settings ** */ - int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */ + int keyframe1 DNA_DEPRECATED, + keyframe2 DNA_DEPRECATED; /* two keyframes for reconstrution initialization + * were moved to per-tracking object settings + */ /* which camera intrinsics to refine. uses on the REFINE_* flags */ short refine_camera_intrinsics, pad2; @@ -220,6 +223,8 @@ typedef struct MovieTrackingObject { ListBase tracks; /* list of tracks use to tracking this object */ MovieTrackingReconstruction reconstruction; /* reconstruction data for this object */ + + int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */ } MovieTrackingObject; typedef struct MovieTrackingStats { diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 0c62a280935..4b744b160fc 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -567,18 +567,6 @@ static void rna_def_trackingSettings(BlenderRNA *brna) "Limit speed of tracking to make visual feedback easier " "(this does not affect the tracking quality)"); - /* keyframe_a */ - prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "keyframe1"); - RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization"); - - /* keyframe_b */ - prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_int_sdna(prop, NULL, "keyframe2"); - RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization"); - /* intrinsics refinement during bundle adjustment */ prop = RNA_def_property(srna, "refine_intrinsics", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "refine_camera_intrinsics"); @@ -1393,6 +1381,18 @@ static void rna_def_trackingObject(BlenderRNA *brna) RNA_def_property_float_default(prop, 1.0f); RNA_def_property_ui_text(prop, "Scale", "Scale of object solution in camera space"); RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingObject_flushUpdate"); + + /* keyframe_a */ + prop = RNA_def_property(srna, "keyframe_a", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "keyframe1"); + RNA_def_property_ui_text(prop, "Keyframe A", "First keyframe used for reconstruction initialization"); + + /* keyframe_b */ + prop = RNA_def_property(srna, "keyframe_b", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "keyframe2"); + RNA_def_property_ui_text(prop, "Keyframe B", "Second keyframe used for reconstruction initialization"); } static void rna_def_trackingObjects(BlenderRNA *brna, PropertyRNA *cprop) -- cgit v1.2.3 From 6712e7428257b57732f64efcdcea95b40043000b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 9 Oct 2012 10:33:24 +0000 Subject: Motion Tracking; expose View All and Center to Current Frame to View menu of graph view --- release/scripts/startup/bl_ui/space_clip.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 17dd1c9cdab..f7b9f59b066 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -891,6 +891,12 @@ class CLIP_MT_view(Menu): layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b else: + if sc.view == 'GRAPH': + layout.operator_context = 'INVOKE_REGION_PREVIEW' + layout.operator("clip.graph_center_current_frame") + layout.operator("clip.graph_view_all") + layout.operator_context = 'INVOKE_DEFAULT' + layout.prop(sc, "show_seconds") layout.separator() -- cgit v1.2.3 From fca582a2da1998819434021d26de69ef34748591 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 9 Oct 2012 10:36:07 +0000 Subject: Autokey warning - Only show for the active region In response to some of the feedback, I've taken a second look at the situation when multiple views are open, and indeed in that situation having it display in every region and blinking was quite overwhelming (admittedly, I've mainly been testing on single-view setups). Now it only shows for the region that was used for initiating the transform. --- source/blender/editors/transform/transform.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 775e8d2de8e..273d8913497 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1617,10 +1617,16 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo Scene *scene = t->scene; Object *ob = OBACT; - /* draw autokeyframing hint in the corner */ + /* draw autokeyframing hint in the corner + * - only draw if enabled (advanced users may be distracted/annoyed), + * for objects that will be autokeyframed (no point ohterwise), + * AND only for the active region (as showing all is too overwhelming) + */ if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) { - if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { - drawAutoKeyWarning(t, ar); + if (ar == t->ar) { + if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { + drawAutoKeyWarning(t, ar); + } } } } -- cgit v1.2.3 From 27aa05ec36e85cedad81490189f706e9c709387c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 9 Oct 2012 10:41:51 +0000 Subject: Autokey warning - trying with a slight "calmer" color Now it uses the same color used for indicating keyframes instead of using "error" indications. --- source/blender/editors/transform/transform.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 273d8913497..5e31de96e0e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1569,8 +1569,8 @@ static void drawAutoKeyWarning(TransInfo *t, ARegion *ar) { int show_warning; - /* red border around the viewport */ - UI_ThemeColor(TH_REDALERT); + /* colored border around the viewport */ + UI_ThemeColor(TH_VERTEX_SELECT); glBegin(GL_LINE_LOOP); glVertex2f(1, 1); @@ -1596,8 +1596,10 @@ static void drawAutoKeyWarning(TransInfo *t, ARegion *ar) xco = ar->winx - BLF_width_default(printable) - 10; yco = ar->winy - BLF_height_default(printable) - 10; - /* red warning text */ - UI_ThemeColor(TH_REDALERT); + /* warning text (to clarify meaning of overlays) + * - original color was red to match the icon, but that clashes badly with a less nasty border + */ + UI_ThemeColor(TH_VERTEX_SELECT); BLF_draw_default_ascii(xco, ar->winy - 17, 0.0f, printable, sizeof(printable)); /* autokey recording icon... */ -- cgit v1.2.3 From 8730b390fbd222a4c64304992f520cdce94fb710 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Oct 2012 10:56:35 +0000 Subject: patch [#31919] limit the number of bone deform weights per vertex. Many game engines require a limit of 4. from Kesten Broughton (kestion) Usage: In weight paint mode, select the mesh to have its weights culled. Click on "Limit Weights" button. A sub-panel will appear "Limit Number of Vertex Weights" with a slider field "Limit" which you can set to the appropriate level. The default level is 4, and it gets executed upon pressing "Limit Weights" so you will need to do an "undo" if your max bone limit is above 4. The checkbox "All Deform Weights" will consider all vertex weights, not just bone deform weights. --- release/scripts/startup/bl_ui/space_view3d.py | 1 + .../scripts/startup/bl_ui/space_view3d_toolbar.py | 1 + source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + source/blender/editors/object/object_vgroup.c | 172 ++++++++++++++++++++- 5 files changed, 170 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index a21d8527158..d5648a6d3a2 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1247,6 +1247,7 @@ class VIEW3D_MT_paint_weight(Menu): layout.operator("object.vertex_group_clean", text="Clean") layout.operator("object.vertex_group_levels", text="Levels") layout.operator("object.vertex_group_blend", text="Blend") + layout.operator("object.vertex_group_limit_total", text="Limit Total") layout.operator("object.vertex_group_fix", text="Fix Deforms") layout.separator() diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 0d939b2de78..52ffdff9b4f 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -967,6 +967,7 @@ class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel): col.operator("object.vertex_group_clean", text="Clean") col.operator("object.vertex_group_levels", text="Levels") col.operator("object.vertex_group_blend", text="Blend") + col.operator("object.vertex_group_limit_total", text="Limit Total") col.operator("object.vertex_group_fix", text="Fix Deforms") diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 4c83f6ef2ce..a5a69d3dcbc 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -214,6 +214,7 @@ void OBJECT_OT_vertex_group_fix(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_invert(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_blend(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_clean(struct wmOperatorType *ot); +void OBJECT_OT_vertex_group_limit_total(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_mirror(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_set_active(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_sort(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index fa40d579e2b..cd4c73a9f1e 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -188,6 +188,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_vertex_group_levels); WM_operatortype_append(OBJECT_OT_vertex_group_blend); WM_operatortype_append(OBJECT_OT_vertex_group_clean); + WM_operatortype_append(OBJECT_OT_vertex_group_limit_total); WM_operatortype_append(OBJECT_OT_vertex_group_mirror); WM_operatortype_append(OBJECT_OT_vertex_group_set_active); WM_operatortype_append(OBJECT_OT_vertex_group_sort); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b31d2b8b076..0a99340be20 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -83,6 +83,19 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *defgroup); static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg); static void vgroup_delete_all(Object *ob); +static int vertex_group_use_vert_sel(Object *ob) +{ + if (ob->mode == OB_MODE_EDIT) { + return TRUE; + } + else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) { + return TRUE; + } + else { + return FALSE; + } +} + static Lattice *vgroup_edit_lattice(Object *ob) { Lattice *lt = ob->data; @@ -704,7 +717,7 @@ static void vgroup_normalize(Object *ob) int i, dvert_tot = 0; const int def_nr = ob->actdef - 1; - const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); if (!BLI_findlink(&ob->defbase, def_nr)) { return; @@ -1109,7 +1122,7 @@ static void vgroup_levels(Object *ob, float offset, float gain) int i, dvert_tot = 0; const int def_nr = ob->actdef - 1; - const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); if (!BLI_findlink(&ob->defbase, def_nr)) { return; @@ -1143,7 +1156,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active) int i, dvert_tot = 0; const int def_nr = ob->actdef - 1; - const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); if (lock_active && !BLI_findlink(&ob->defbase, def_nr)) { return; @@ -1221,7 +1234,7 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_ MDeformVert *dv, **dvert_array = NULL; int i, dvert_tot = 0; const int def_nr = ob->actdef - 1; - const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); if (!BLI_findlink(&ob->defbase, def_nr)) { return; @@ -1389,13 +1402,119 @@ static void vgroup_blend(Object *ob, const float fac) } } +static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2) +{ + /* qsort sorts in ascending order. We want descending order to save a memcopy + * so this compare function is inverted from the standard greater than comparison qsort needs. + * A normal compare function is called with two pointer arguments and should return an integer less than, equal to, + * or greater than zero corresponding to whether its first argument is considered less than, equal to, + * or greater than its second argument. This does the opposite. */ + const struct MDeformWeight *dw1 = a1, *dw2 = a2; + + if (dw1->weight < dw2->weight) return 1; + else if (dw1->weight > dw2->weight) return -1; + else if (&dw1 < &dw2) return 1; /* compare addresses so we have a stable sort algorithm */ + else return -1; +} + +/* Used for limiting the number of influencing bones per vertex when exporting + * skinned meshes. if all_deform_weights is True, limit all deform modifiers + * to max_weights regardless of type, otherwise, only limit the number of influencing bones per vertex*/ +static int vertex_group_limit_total(Object *ob, + const int max_weights, + const int all_deform_weights) +{ + MDeformVert *dv, **dvert_array = NULL; + int i, dvert_tot = 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); + int is_change = FALSE; + + ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); + + if (dvert_array) { + int defbase_tot = BLI_countlist(&ob->defbase); + const char *vgroup_validmap = (all_deform_weights == FALSE) ? + BKE_objdef_validmap_get(ob, defbase_tot) : + NULL; + int num_to_drop = 0; + + /* only the active group */ + for (i = 0; i < dvert_tot; i++) { + + /* in case its not selected */ + if (!(dv = dvert_array[i])) { + continue; + } + + if (all_deform_weights) { + /* keep only the largest weights, discarding the rest + * qsort will put array in descending order because of invCompare function */ + num_to_drop = dv->totweight - max_weights; + if (num_to_drop > 0) { + qsort(dv->dw, dv->totweight, sizeof(MDeformWeight), inv_cmp_mdef_vert_weights); + dv->dw = MEM_reallocN(dv->dw, sizeof(MDeformWeight) * max_weights); + dv->totweight = max_weights; + is_change = TRUE; + } + } + else { + MDeformWeight *dw_temp; + int bone_count = 0, non_bone_count = 0; + int j; + /* only consider vgroups with bone modifiers attached (in vgroup_validmap) */ + + num_to_drop = dv->totweight - max_weights; + + /* first check if we even need to test further */ + if (num_to_drop > 0) { + /* re-pack dw array so that non-bone weights are first, bone-weighted verts at end + * sort the tail, then copy only the truncated array back to dv->dw */ + dw_temp = MEM_mallocN(sizeof(MDeformWeight) * (dv->totweight), __func__); + bone_count = 0; non_bone_count = 0; + for (j = 0; j < dv->totweight; j++) { + BLI_assert(dv->dw[j].def_nr < defbase_tot); + if (!vgroup_validmap[(dv->dw[j]).def_nr]) { + dw_temp[non_bone_count] = dv->dw[j]; + non_bone_count += 1; + } + else { + dw_temp[dv->totweight - 1 - bone_count] = dv->dw[j]; + bone_count += 1; + } + } + BLI_assert(bone_count + non_bone_count == dv->totweight); + num_to_drop = bone_count - max_weights; + if (num_to_drop > 0) { + qsort(&dw_temp[non_bone_count], bone_count, sizeof(MDeformWeight), inv_cmp_mdef_vert_weights); + dv->totweight -= num_to_drop; + /* Do we want to clean/normalize here? */ + MEM_freeN(dv->dw); + dv->dw = MEM_reallocN(dw_temp, sizeof(MDeformWeight) * dv->totweight); + is_change = TRUE; + } + else { + MEM_freeN(dw_temp); + } + } + } + } + MEM_freeN(dvert_array); + + if (vgroup_validmap) { + MEM_freeN((void *)vgroup_validmap); + } + } + + return is_change; +} + static void vgroup_clean(Object *ob, const float epsilon, int keep_single) { MDeformWeight *dw; MDeformVert *dv, **dvert_array = NULL; int i, dvert_tot = 0; const int def_nr = ob->actdef - 1; - const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); if (!BLI_findlink(&ob->defbase, def_nr)) { return; @@ -1431,7 +1550,7 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin { MDeformVert **dvert_array = NULL; int i, dvert_tot = 0; - const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; + const int use_vert_sel = vertex_group_use_vert_sel(ob); ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); @@ -2665,6 +2784,47 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) "Keep verts assigned to at least one group when cleaning"); } +static int vertex_group_limit_total_exec(bContext *C, wmOperator *op) +{ + Object *ob = ED_object_context(C); + + const int limit = RNA_int_get(op->ptr, "limit"); + const int all_deform_weights = RNA_boolean_get(op->ptr, "all_deform_weights"); + + if (vertex_group_limit_total(ob, limit, all_deform_weights)) { + + 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_GEOM | ND_DATA, ob->data); + + return OPERATOR_FINISHED; + } + else { + BKE_reportf(op->reports, RPT_WARNING, "No vertex groups limited"); + + /* note, would normally return cancelled, except we want the redo + * UI to show up for users to change */ + return OPERATOR_FINISHED; + } +} + +void OBJECT_OT_vertex_group_limit_total(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Limit Number of Weights per Vertex"; + ot->idname = "OBJECT_OT_vertex_group_limit_total"; + ot->description = "Limits deform weights associated with a vertex to a specified number by removing lowest weights"; + + /* api callbacks */ + ot->poll = vertex_group_poll; + ot->exec = vertex_group_limit_total_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_int(ot->srna, "limit", 4, 1, 32, "Limit", "Maximum number of deform weights", 1, 32); + RNA_def_boolean(ot->srna, "all_deform_weights", FALSE, "All Deform Weights", "Cull all deform weights, not just bones"); +} static int vertex_group_mirror_exec(bContext *C, wmOperator *op) { -- cgit v1.2.3 From 4550864f07c7a793c03eaa2c785d5321fb5d52fb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 9 Oct 2012 11:31:25 +0000 Subject: Fix #32824: Color management configuration check was missed on file link/append --- source/blender/windowmanager/intern/wm_operators.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index e4d6b3dd465..ec25e8dcffb 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -79,6 +79,7 @@ #include "BIF_glutil.h" /* for paint cursor */ #include "BLF_api.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -1838,6 +1839,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* mark all library linked objects to be updated */ recalc_all_library_objects(bmain); + IMB_colormanagement_check_file_config(bmain); /* append, rather than linking */ if ((flag & FILE_LINK) == 0) { -- cgit v1.2.3 From affb060c200febc1b967fee2c78a3e2ecc6d7c46 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 9 Oct 2012 11:38:42 +0000 Subject: Revert part of 51209 -- MOUSEZOOM inversion should be done in lots of other places as well, but it's quite large change to be done before 'a' release. For now ignore zoom inverse for 2d view to keep things consistent, would be re-implemented for all areas after this. --- source/blender/editors/interface/view2d_ops.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 2c8db53b534..8be2667a015 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -945,11 +945,6 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) dx = fac * BLI_rctf_size_x(&v2d->cur) / 10.0f; dy = fac * BLI_rctf_size_y(&v2d->cur) / 10.0f; - if (U.uiflag & USER_ZOOM_INVERT) { - dx *= -1; - dy *= -1; - } - RNA_float_set(op->ptr, "deltax", dx); RNA_float_set(op->ptr, "deltay", dy); -- cgit v1.2.3