Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOve Murberg Henriksen <sorayasilvermoon@hotmail.com>2012-04-03 15:55:39 +0400
committerOve Murberg Henriksen <sorayasilvermoon@hotmail.com>2012-04-03 15:55:39 +0400
commit244836b18da1bbb6be94b7a5353ae8beaff1eb9d (patch)
tree4ed1f20cb3fd9835b9eee8d49f3abfe4267c4008 /source/blender/editors/object
parent4fb535070ecaae57dc3f6521e447d42c6cc57193 (diff)
parenta7798884a5ab806723a9e773fbd3a387369786b0 (diff)
svn merge ^/trunk/blender -r44562:45364
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.c497
-rw-r--r--source/blender/editors/object/object_bake.c339
-rw-r--r--source/blender/editors/object/object_constraint.c281
-rw-r--r--source/blender/editors/object/object_edit.c584
-rw-r--r--source/blender/editors/object/object_group.c96
-rw-r--r--source/blender/editors/object/object_hook.c221
-rw-r--r--source/blender/editors/object/object_intern.h1
-rw-r--r--source/blender/editors/object/object_lattice.c76
-rw-r--r--source/blender/editors/object/object_modifier.c542
-rw-r--r--source/blender/editors/object/object_ops.c44
-rw-r--r--source/blender/editors/object/object_relations.c552
-rw-r--r--source/blender/editors/object/object_select.c217
-rw-r--r--source/blender/editors/object/object_shapekey.c142
-rw-r--r--source/blender/editors/object/object_transform.c240
-rw-r--r--source/blender/editors/object/object_vgroup.c961
15 files changed, 2427 insertions, 2366 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 27ed9f5b46e..3717591e412 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -123,7 +123,7 @@ void ED_object_location_from_view(bContext *C, float *loc)
void ED_object_rotation_from_view(bContext *C, float *rot)
{
RegionView3D *rv3d= CTX_wm_region_view3d(C);
- if(rv3d) {
+ if (rv3d) {
float quat[4];
copy_qt_qt(quat, rv3d->viewquat);
quat[0]= -quat[0];
@@ -174,7 +174,7 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, float *loc, fl
invert_m3_m3(imat, mat);
mul_m3_v3(imat, primmat[3]);
- if(v3d) return v3d->grid;
+ if (v3d) return v3d->grid;
return 1.0f;
}
@@ -193,7 +193,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode)
prop = RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view");
RNA_def_property_update_runtime(prop, view_align_update);
- if(do_editmode) {
+ if (do_editmode) {
prop = RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode",
"Enter editmode when adding this object");
RNA_def_property_flag(prop, PROP_HIDDEN|PROP_SKIP_SAVE);
@@ -212,23 +212,23 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode)
static void object_add_generic_invoke_options(bContext *C, wmOperator *op)
{
- if(RNA_struct_find_property(op->ptr, "enter_editmode")) /* optional */
+ 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);
- if(!RNA_struct_property_is_set(op->ptr, "location")) {
+ if (!RNA_struct_property_is_set(op->ptr, "location")) {
float loc[3];
ED_object_location_from_view(C, loc);
RNA_float_set_array(op->ptr, "location", loc);
}
- if(!RNA_struct_property_is_set(op->ptr, "layers")) {
+ 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) {
+ if (v3d) {
layer = (v3d->scenelock && !v3d->localvd)? scene->layact: v3d->layact;
}
else {
@@ -257,15 +257,15 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc,
int view_align;
*enter_editmode = FALSE;
- if(RNA_struct_find_property(op->ptr, "enter_editmode") && RNA_boolean_get(op->ptr, "enter_editmode")) {
+ if (RNA_struct_find_property(op->ptr, "enter_editmode") && RNA_boolean_get(op->ptr, "enter_editmode")) {
*enter_editmode = TRUE;
}
- if(RNA_struct_property_is_set(op->ptr, "layers")) {
+ 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])
+ for (a=0; a<20; a++) {
+ if (layer_values[a])
*layer |= (1 << a);
else
*layer &= ~(1 << a);
@@ -278,11 +278,11 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc,
}
/* in local view we additionally add local view layers,
- not part of operator properties */
- if(v3d && v3d->localvd)
+ * not part of operator properties */
+ if (v3d && v3d->localvd)
*layer |= v3d->lay;
- if(RNA_struct_property_is_set(op->ptr, "rotation"))
+ 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");
@@ -303,7 +303,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc,
RNA_float_get_array(op->ptr, "location", loc);
- if(*layer == 0) {
+ if (*layer == 0) {
BKE_report(op->reports, RPT_ERROR, "Property 'layer' has no values set");
return 0;
}
@@ -339,7 +339,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot,
ED_render_id_flush_update(bmain, ob->data);
}
- if(enter_editmode)
+ if (enter_editmode)
ED_object_enter_editmode(C, EM_IGNORE_LAYER);
WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene);
@@ -354,7 +354,7 @@ static int object_add_exec(bContext *C, wmOperator *op)
unsigned int layer;
float loc[3], rot[3];
- 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, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer);
@@ -365,18 +365,18 @@ static int object_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Object";
+ ot->name = "Add Object";
ot->description = "Add an object to the scene";
- ot->idname= "OBJECT_OT_add";
+ ot->idname = "OBJECT_OT_add";
/* api callbacks */
- ot->invoke= ED_object_add_generic_invoke;
- ot->exec= object_add_exec;
+ ot->invoke = ED_object_add_generic_invoke;
+ ot->exec = object_add_exec;
- ot->poll= ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", object_type_items, 0, "Type", "");
@@ -411,10 +411,10 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
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, &enter_editmode, &layer, NULL))
return NULL;
- if(type==PFIELD_GUIDE) {
+ if (type==PFIELD_GUIDE) {
ob= ED_object_add_type(C, OB_CURVE, loc, rot, FALSE, layer);
rename_id(&ob->id, "CurveGuide");
@@ -423,7 +423,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_PATH, 1));
- if(!enter_editmode)
+ if (!enter_editmode)
ED_object_exit_editmode(C, EM_FREEDATA);
}
else {
@@ -448,7 +448,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
/* 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)
+ if (effector_add_type(C, op, RNA_enum_get(op->ptr, "type")) == NULL)
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -457,20 +457,20 @@ static int effector_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_effector_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Effector";
+ ot->name = "Add Effector";
ot->description = "Add an empty object with a physics effector to the scene";
- ot->idname= "OBJECT_OT_effector_add";
+ ot->idname = "OBJECT_OT_effector_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= effector_add_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = effector_add_exec;
- ot->poll= ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
- ot->prop= RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", "");
ED_object_add_generic_props(ot, TRUE);
}
@@ -491,7 +491,7 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
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, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer);
@@ -512,16 +512,16 @@ void OBJECT_OT_camera_add(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Add Camera";
+ ot->name = "Add Camera";
ot->description = "Add a camera object to the scene";
- ot->idname= "OBJECT_OT_camera_add";
+ ot->idname = "OBJECT_OT_camera_add";
/* api callbacks */
- ot->exec= object_camera_add_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = object_camera_add_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
@@ -545,10 +545,10 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op)
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))
+ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
- if(obedit==NULL || obedit->type!=OB_MBALL) {
+ if (obedit==NULL || obedit->type!=OB_MBALL) {
obedit= ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer);
newob = 1;
}
@@ -578,7 +578,7 @@ static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
layout= uiPupMenuLayout(pup);
- if(!obedit || obedit->type == OB_MBALL)
+ if (!obedit || obedit->type == OB_MBALL)
uiItemsEnumO(layout, op->type->idname, "type");
else
uiItemsEnumO(layout, "OBJECT_OT_metaball_add", "type");
@@ -590,17 +590,17 @@ static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
void OBJECT_OT_metaball_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Metaball";
- ot->description= "Add an metaball object to the scene";
- ot->idname= "OBJECT_OT_metaball_add";
+ ot->name = "Add Metaball";
+ ot->description = "Add an metaball object to the scene";
+ ot->idname = "OBJECT_OT_metaball_add";
/* api callbacks */
- ot->invoke= object_metaball_add_invoke;
- ot->exec= object_metaball_add_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->invoke = object_metaball_add_invoke;
+ ot->exec = object_metaball_add_exec;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", "");
ED_object_add_generic_props(ot, TRUE);
@@ -614,10 +614,10 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
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))
+ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
- if(obedit && obedit->type==OB_FONT)
+ if (obedit && obedit->type==OB_FONT)
return OPERATOR_CANCELLED;
obedit= ED_object_add_type(C, OB_FONT, loc, rot, enter_editmode, layer);
@@ -630,17 +630,17 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
void OBJECT_OT_text_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Text";
+ ot->name = "Add Text";
ot->description = "Add a text object to the scene";
- ot->idname= "OBJECT_OT_text_add";
+ 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;
+ ot->invoke = ED_object_add_generic_invoke;
+ ot->exec = object_add_text_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
@@ -655,7 +655,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
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))
+ if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) {
@@ -665,7 +665,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
}
else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
- if(obedit==NULL) {
+ if (obedit==NULL) {
BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature");
return OPERATOR_CANCELLED;
}
@@ -685,17 +685,17 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_armature_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Armature";
+ ot->name = "Add Armature";
ot->description = "Add an armature object to the scene";
- ot->idname= "OBJECT_OT_armature_add";
+ 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;
+ ot->invoke = ED_object_add_generic_invoke;
+ ot->exec = object_armature_add_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
@@ -723,7 +723,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
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, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer);
@@ -733,7 +733,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
rename_id(&ob->id, get_lamp_defname(type));
rename_id(&la->id, get_lamp_defname(type));
- if(scene_use_new_shading_nodes(scene)) {
+ if (scene_use_new_shading_nodes(scene)) {
ED_node_shader_default(scene, &la->id);
la->use_nodes= 1;
}
@@ -752,20 +752,20 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL}};
/* identifiers */
- ot->name= "Add Lamp";
+ ot->name = "Add Lamp";
ot->description = "Add a lamp object to the scene";
- ot->idname= "OBJECT_OT_lamp_add";
+ ot->idname = "OBJECT_OT_lamp_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_lamp_add_exec;
- ot->poll= ED_operator_objectmode;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_lamp_add_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", "");
ED_object_add_generic_props(ot, FALSE);
}
@@ -779,10 +779,10 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
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, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
- if(group) {
+ if (group) {
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer);
@@ -811,7 +811,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op)
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, &enter_editmode, &layer, NULL))
return OPERATOR_CANCELLED;
ob= ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer);
@@ -843,16 +843,16 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_speaker_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Speaker";
+ ot->name = "Add Speaker";
ot->description = "Add a speaker object to the scene";
- ot->idname= "OBJECT_OT_speaker_add";
+ ot->idname = "OBJECT_OT_speaker_add";
/* api callbacks */
- ot->exec= object_speaker_add_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = object_speaker_add_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
@@ -863,23 +863,23 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Add Group Instance";
+ ot->name = "Add Group Instance";
ot->description = "Add a dupligroup instance";
- ot->idname= "OBJECT_OT_group_instance_add";
+ ot->idname = "OBJECT_OT_group_instance_add";
/* api callbacks */
- ot->invoke= WM_enum_search_invoke;
- ot->exec= group_instance_add_exec;
+ ot->invoke = WM_enum_search_invoke;
+ ot->exec = group_instance_add_exec;
- ot->poll= ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
RNA_def_enum_funcs(prop, RNA_group_itemf);
- ot->prop= prop;
+ ot->prop = prop;
ED_object_add_generic_props(ot, FALSE);
}
@@ -892,7 +892,7 @@ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base)
DAG_id_type_tag(bmain, ID_OB);
BLI_remlink(&scene->base, base);
free_libblock_us(&bmain->object, base->object);
- if(scene->basact==base) scene->basact= NULL;
+ if (scene->basact==base) scene->basact= NULL;
MEM_freeN(base);
}
@@ -903,12 +903,12 @@ static int object_delete_exec(bContext *C, wmOperator *op)
const short use_global= RNA_boolean_get(op->ptr, "use_global");
/* int islamp= 0; */ /* UNUSED */
- if(CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C))
return OPERATOR_CANCELLED;
CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
- /* if(base->object->type==OB_LAMP) islamp= 1; */
+ /* if (base->object->type==OB_LAMP) islamp= 1; */
/* deselect object -- it could be used in other scenes */
base->object->flag &= ~SELECT;
@@ -946,17 +946,17 @@ static int object_delete_exec(bContext *C, wmOperator *op)
void OBJECT_OT_delete(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Delete";
+ ot->name = "Delete";
ot->description = "Delete selected objects";
- ot->idname= "OBJECT_OT_delete";
+ ot->idname = "OBJECT_OT_delete";
/* api callbacks */
- ot->invoke= WM_operator_confirm;
- ot->exec= object_delete_exec;
- ot->poll= ED_operator_objectmode;
+ ot->invoke = WM_operator_confirm;
+ ot->exec = object_delete_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "use_global", 0, "Delete Globally", "Remove object from all scenes");
}
@@ -978,18 +978,18 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
CTX_DATA_END;
/* materials */
- if( dupflag & USER_DUP_MAT) {
+ if ( dupflag & USER_DUP_MAT) {
mao= bmain->mat.first;
- while(mao) {
- if(mao->id.newid) {
+ while (mao) {
+ if (mao->id.newid) {
ma= (Material *)mao->id.newid;
- if(dupflag & USER_DUP_TEX) {
- for(a=0; a<MAX_MTEX; a++) {
- if(ma->mtex[a]) {
+ if (dupflag & USER_DUP_TEX) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (ma->mtex[a]) {
id= (ID *)ma->mtex[a]->tex;
- if(id) {
+ if (id) {
ID_NEW_US(ma->mtex[a]->tex)
else ma->mtex[a]->tex= copy_texture(ma->mtex[a]->tex);
id->us--;
@@ -999,7 +999,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
}
#if 0 // XXX old animation system
id= (ID *)ma->ipo;
- if(id) {
+ if (id) {
ID_NEW_US(ma->ipo)
else ma->ipo= copy_ipo(ma->ipo);
id->us--;
@@ -1012,13 +1012,13 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
#if 0 // XXX old animation system
/* lamps */
- if( dupflag & USER_DUP_IPO) {
+ if ( dupflag & USER_DUP_IPO) {
Lamp *la= bmain->lamp.first;
- while(la) {
- if(la->id.newid) {
+ while (la) {
+ if (la->id.newid) {
Lamp *lan= (Lamp *)la->id.newid;
id= (ID *)lan->ipo;
- if(id) {
+ if (id) {
ID_NEW_US(lan->ipo)
else lan->ipo= copy_ipo(lan->ipo);
id->us--;
@@ -1030,12 +1030,12 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
/* ipos */
ipo= bmain->ipo.first;
- while(ipo) {
- if(ipo->id.lib==NULL && ipo->id.newid) {
+ while (ipo) {
+ if (ipo->id.lib==NULL && ipo->id.newid) {
Ipo *ipon= (Ipo *)ipo->id.newid;
IpoCurve *icu;
- for(icu= ipon->curve.first; icu; icu= icu->next) {
- if(icu->driver) {
+ for (icu= ipon->curve.first; icu; icu= icu->next) {
+ if (icu->driver) {
ID_NEW(icu->driver->ob);
}
}
@@ -1059,23 +1059,23 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
DupliObject *dob;
GHash *dupli_gh= NULL, *parent_gh= NULL;
- if(!(base->object->transflag & OB_DUPLI))
+ if (!(base->object->transflag & OB_DUPLI))
return;
lb= object_duplilist(scene, base->object);
- if(use_hierarchy || use_base_parent) {
+ if (use_hierarchy || use_base_parent) {
dupli_gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_object_duplilist_real dupli_gh");
parent_gh= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "make_object_duplilist_real parent_gh");
}
- for(dob= lb->first; dob; dob= dob->next) {
+ for (dob= lb->first; dob; dob= dob->next) {
Base *basen;
Object *ob= copy_object(dob->ob);
/* font duplis can have a totcol without material, we get them from parent
- * should be implemented better...
- */
- if(ob->mat==NULL) ob->totcol= 0;
+ * should be implemented better...
+ */
+ if (ob->mat==NULL) ob->totcol= 0;
basen= MEM_dupallocN(base);
basen->flag &= ~(OB_FROMDUPLI|OB_FROMGROUP);
@@ -1097,14 +1097,14 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
copy_m4_m4(ob->obmat, dob->mat);
object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
- if(dupli_gh)
+ if (dupli_gh)
BLI_ghash_insert(dupli_gh, dob, ob);
- if(parent_gh)
+ if (parent_gh)
BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, dob->index), ob);
}
if (use_hierarchy) {
- for(dob= lb->first; dob; dob= dob->next) {
+ for (dob= lb->first; dob; dob= dob->next) {
/* original parents */
Object *ob_src= dob->ob;
Object *ob_src_par= ob_src->parent;
@@ -1113,7 +1113,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
Object *ob_dst_par= NULL;
/* find parent that was also made real */
- if(ob_src_par) {
+ if (ob_src_par) {
GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, dob->index);
ob_dst_par = BLI_ghash_lookup(parent_gh, pair);
BLI_ghashutil_pairfree(pair);
@@ -1143,7 +1143,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
* still work out ok */
object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE);
- /* to set ob_dst->orig and incase theres any other discrepicies */
+ /* to set ob_dst->orig and in case theres any other discrepicies */
DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB);
}
}
@@ -1151,7 +1151,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
else if (use_base_parent) {
/* since we are ignoring the internal hierarchy - parent all to the
* base object */
- for(dob= lb->first; dob; dob= dob->next) {
+ for (dob= lb->first; dob; dob= dob->next) {
/* original parents */
Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob);
@@ -1167,9 +1167,9 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
}
}
- if(dupli_gh)
+ if (dupli_gh)
BLI_ghash_free(dupli_gh, NULL, NULL);
- if(parent_gh)
+ if (parent_gh)
BLI_ghash_free(parent_gh, BLI_ghashutil_pairfree, NULL);
copy_object_set_idnew(C, 0);
@@ -1209,17 +1209,17 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Make Duplicates Real";
+ ot->name = "Make Duplicates Real";
ot->description = "Make dupli objects attached to this object real";
- ot->idname= "OBJECT_OT_duplicates_make_real";
+ ot->idname = "OBJECT_OT_duplicates_make_real";
/* api callbacks */
- ot->exec= object_duplicates_make_real_exec;
+ ot->exec = object_duplicates_make_real_exec;
- ot->poll= ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "use_base_parent", 0, "Parent", "Parent newly created objects to the original duplicator");
RNA_def_boolean(ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships");
@@ -1234,12 +1234,12 @@ static EnumPropertyItem convert_target_items[]= {
static void curvetomesh(Scene *scene, Object *ob)
{
- if(ob->disp.first == NULL)
+ if (ob->disp.first == NULL)
makeDispListCurveTypes(scene, ob, 0); /* force creation */
nurbs_to_mesh(ob); /* also does users */
- if(ob->type == OB_MESH)
+ if (ob->type == OB_MESH)
object_free_modifiers(ob);
}
@@ -1299,7 +1299,7 @@ static int convert_exec(bContext *C, wmOperator *op)
ob->flag &= ~OB_DONE;
/* flag data thats not been edited (only needed for !keep_original) */
- if(ob->data) {
+ if (ob->data) {
((ID *)ob->data)->flag |= LIB_DOIT;
}
}
@@ -1308,17 +1308,17 @@ static int convert_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
ob= base->object;
- if(ob->flag & OB_DONE || !IS_TAGGED(ob->data)) {
+ if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) {
if (ob->type != target) {
base->flag &= ~SELECT;
ob->flag &= ~SELECT;
}
/* obdata already modified */
- if(!IS_TAGGED(ob->data)) {
+ if (!IS_TAGGED(ob->data)) {
/* When 2 objects with linked data are selected, converting both
* would keep modifiers on all but the converted object [#26003] */
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
object_free_modifiers(ob); /* after derivedmesh calls! */
}
}
@@ -1336,16 +1336,17 @@ static int convert_exec(bContext *C, wmOperator *op)
/* make a new copy of the mesh */
newob->data= copy_mesh(me);
- } else {
+ }
+ else {
newob = ob;
}
mesh_to_curve(scene, newob);
- if(newob->type==OB_CURVE)
+ if (newob->type==OB_CURVE)
object_free_modifiers(newob); /* after derivedmesh calls! */
}
- else if(ob->type==OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */
+ else if (ob->type==OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */
ob->flag |= OB_DONE;
if (keep_original) {
@@ -1358,7 +1359,8 @@ static int convert_exec(bContext *C, wmOperator *op)
/* make a new copy of the mesh */
newob->data= copy_mesh(me);
- } else {
+ }
+ else {
newob = ob;
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
@@ -1372,12 +1374,12 @@ static int convert_exec(bContext *C, wmOperator *op)
DM_to_mesh(dm, newob->data, newob);
- /* re-tesselation is called by DM_to_mesh */
+ /* re-tessellation is called by DM_to_mesh */
dm->release(dm);
object_free_modifiers(newob); /* after derivedmesh calls! */
}
- else if(ob->type==OB_FONT) {
+ else if (ob->type==OB_FONT) {
ob->flag |= OB_DONE;
if (keep_original) {
@@ -1389,7 +1391,8 @@ static int convert_exec(bContext *C, wmOperator *op)
/* make a new copy of the curve */
newob->data= copy_curve(ob->data);
- } else {
+ }
+ else {
newob= ob;
}
@@ -1401,28 +1404,28 @@ static int convert_exec(bContext *C, wmOperator *op)
newob->type= OB_CURVE;
cu->type= OB_CURVE;
- if(cu->vfont) {
+ if (cu->vfont) {
cu->vfont->id.us--;
cu->vfont= NULL;
}
- if(cu->vfontb) {
+ if (cu->vfontb) {
cu->vfontb->id.us--;
cu->vfontb= NULL;
}
- if(cu->vfonti) {
+ if (cu->vfonti) {
cu->vfonti->id.us--;
cu->vfonti= NULL;
}
- if(cu->vfontbi) {
+ if (cu->vfontbi) {
cu->vfontbi->id.us--;
cu->vfontbi= NULL;
}
if (!keep_original) {
/* other users */
- if(cu->id.us>1) {
- for(ob1= bmain->object.first; ob1; ob1=ob1->id.next) {
- if(ob1->data==ob->data) {
+ if (cu->id.us>1) {
+ for (ob1= bmain->object.first; ob1; ob1=ob1->id.next) {
+ if (ob1->data==ob->data) {
ob1->type= OB_CURVE;
ob1->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
}
@@ -1430,20 +1433,20 @@ static int convert_exec(bContext *C, wmOperator *op)
}
}
- for(nu=cu->nurb.first; nu; nu=nu->next)
+ for (nu=cu->nurb.first; nu; nu=nu->next)
nu->charidx= 0;
- if(target == OB_MESH) {
+ if (target == OB_MESH) {
curvetomesh(scene, newob);
/* meshes doesn't use displist */
freedisplist(&newob->disp);
}
}
- else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
ob->flag |= OB_DONE;
- if(target == OB_MESH) {
+ if (target == OB_MESH) {
if (keep_original) {
basen= duplibase_for_convert(scene, base, NULL);
newob= basen->object;
@@ -1453,7 +1456,8 @@ static int convert_exec(bContext *C, wmOperator *op)
/* make a new copy of the curve */
newob->data= copy_curve(ob->data);
- } else {
+ }
+ else {
newob= ob;
/* meshes doesn't use displist */
@@ -1463,7 +1467,7 @@ static int convert_exec(bContext *C, wmOperator *op)
curvetomesh(scene, newob);
}
}
- else if(ob->type==OB_MBALL && target == OB_MESH) {
+ else if (ob->type==OB_MBALL && target == OB_MESH) {
Object *baseob;
base->flag &= ~SELECT;
@@ -1480,7 +1484,7 @@ static int convert_exec(bContext *C, wmOperator *op)
makeDispListMBall(scene, baseob);
}
- if(!(baseob->flag & OB_DONE)) {
+ if (!(baseob->flag & OB_DONE)) {
baseob->flag |= OB_DONE;
basen= duplibase_for_convert(scene, base, baseob);
@@ -1494,9 +1498,9 @@ static int convert_exec(bContext *C, wmOperator *op)
me= newob->data;
me->totcol= mb->totcol;
- if(newob->totcol) {
+ if (newob->totcol) {
me->mat= MEM_dupallocN(mb->mat);
- for(a=0; a<newob->totcol; a++) id_us_plus((ID *)me->mat[a]);
+ for (a=0; a<newob->totcol; a++) id_us_plus((ID *)me->mat[a]);
}
mball_to_mesh(&baseob->disp, newob->data);
@@ -1515,8 +1519,8 @@ static int convert_exec(bContext *C, wmOperator *op)
/* tag obdata if it was been changed */
/* If the original object is active then make this object active */
- if(basen) {
- if(ob == obact) {
+ if (basen) {
+ if (ob == obact) {
/* store new active base to update BASACT */
basact= basen;
}
@@ -1530,8 +1534,8 @@ static int convert_exec(bContext *C, wmOperator *op)
}
/* delete original if needed */
- if(basedel) {
- if(!keep_original)
+ if (basedel) {
+ if (!keep_original)
ED_base_object_free_and_unlink(bmain, scene, basedel);
basedel = NULL;
@@ -1539,7 +1543,7 @@ static int convert_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if(!keep_original) {
+ if (!keep_original) {
if (mballConverted) {
Base *base= scene->base.first, *tmpbase;
while (base) {
@@ -1564,7 +1568,8 @@ static int convert_exec(bContext *C, wmOperator *op)
/* active base was changed */
ED_base_object_activate(C, basact);
BASACT= basact;
- } else if (BASACT->object->flag & OB_DONE) {
+ }
+ else if (BASACT->object->flag & OB_DONE) {
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, BASACT->object);
WM_event_add_notifier(C, NC_OBJECT|ND_DATA, BASACT->object);
}
@@ -1580,30 +1585,30 @@ static int convert_exec(bContext *C, wmOperator *op)
void OBJECT_OT_convert(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Convert to";
+ ot->name = "Convert to";
ot->description = "Convert selected objects to another type";
- ot->idname= "OBJECT_OT_convert";
+ ot->idname = "OBJECT_OT_convert";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= convert_exec;
- ot->poll= convert_poll;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = convert_exec;
+ ot->poll = convert_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to");
+ ot->prop = RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to");
RNA_def_boolean(ot->srna, "keep_original", 0, "Keep Original", "Keep original objects instead of replacing them");
}
/**************************** Duplicate ************************/
/*
- dupflag: a flag made from constants declared in DNA_userdef_types.h
- The flag tells adduplicate() weather to copy data linked to the object, or to reference the existing data.
- U.dupflag for default operations or you can construct a flag as python does
- if the dupflag is 0 then no data will be copied (linked duplicate) */
+ * dupflag: a flag made from constants declared in DNA_userdef_types.h
+ * The flag tells adduplicate() weather to copy data linked to the object, or to reference the existing data.
+ * U.dupflag for default operations or you can construct a flag as python does
+ * if the dupflag is 0 then no data will be copied (linked duplicate) */
/* used below, assumes id.new is correct */
/* leaves selection of base/object unaltered */
@@ -1616,7 +1621,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
int a, didit;
ob= base->object;
- if(ob->mode & OB_MODE_POSE) {
+ if (ob->mode & OB_MODE_POSE) {
; /* nothing? */
}
else {
@@ -1628,42 +1633,42 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */
basen->object= obn;
- if(basen->flag & OB_FROMGROUP) {
+ if (basen->flag & OB_FROMGROUP) {
Group *group;
- for(group= bmain->group.first; group; group= group->id.next) {
- if(object_in_group(ob, group))
+ for (group= bmain->group.first; group; group= group->id.next) {
+ if (object_in_group(ob, group))
add_to_group(group, obn, scene, basen);
}
}
/* duplicates using userflags */
- if(dupflag & USER_DUP_ACT) {
+ if (dupflag & USER_DUP_ACT) {
BKE_copy_animdata_id_action(&obn->id);
}
- if(dupflag & USER_DUP_MAT) {
- for(a=0; a<obn->totcol; a++) {
+ if (dupflag & USER_DUP_MAT) {
+ for (a=0; a<obn->totcol; a++) {
id= (ID *)obn->mat[a];
- if(id) {
+ if (id) {
ID_NEW_US(obn->mat[a])
else obn->mat[a]= copy_material(obn->mat[a]);
id->us--;
- if(dupflag & USER_DUP_ACT) {
+ if (dupflag & USER_DUP_ACT) {
BKE_copy_animdata_id_action(&obn->mat[a]->id);
}
}
}
}
- if(dupflag & USER_DUP_PSYS) {
+ if (dupflag & USER_DUP_PSYS) {
ParticleSystem *psys;
- for(psys=obn->particlesystem.first; psys; psys=psys->next) {
+ for (psys=obn->particlesystem.first; psys; psys=psys->next) {
id= (ID*) psys->part;
- if(id) {
+ if (id) {
ID_NEW_US(psys->part)
else psys->part= psys_copy_settings(psys->part);
- if(dupflag & USER_DUP_ACT) {
+ if (dupflag & USER_DUP_ACT) {
BKE_copy_animdata_id_action(&psys->part->id);
}
@@ -1677,12 +1682,12 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
switch(obn->type) {
case OB_MESH:
- if(dupflag & USER_DUP_MESH) {
+ if (dupflag & USER_DUP_MESH) {
ID_NEW_US2( obn->data )
else {
obn->data= copy_mesh(obn->data);
- if(obn->fluidsimSettings) {
+ if (obn->fluidsimSettings) {
obn->fluidsimSettings->orgMesh = (Mesh *)obn->data;
}
@@ -1692,7 +1697,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_CURVE:
- if(dupflag & USER_DUP_CURVE) {
+ if (dupflag & USER_DUP_CURVE) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_curve(obn->data);
@@ -1702,7 +1707,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_SURF:
- if(dupflag & USER_DUP_SURF) {
+ if (dupflag & USER_DUP_SURF) {
ID_NEW_US2( obn->data )
else {
obn->data= copy_curve(obn->data);
@@ -1712,7 +1717,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_FONT:
- if(dupflag & USER_DUP_FONT) {
+ if (dupflag & USER_DUP_FONT) {
ID_NEW_US2( obn->data )
else {
obn->data= copy_curve(obn->data);
@@ -1722,7 +1727,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_MBALL:
- if(dupflag & USER_DUP_MBALL) {
+ if (dupflag & USER_DUP_MBALL) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_mball(obn->data);
@@ -1732,7 +1737,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_LAMP:
- if(dupflag & USER_DUP_LAMP) {
+ if (dupflag & USER_DUP_LAMP) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_lamp(obn->data);
@@ -1744,9 +1749,9 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
case OB_ARMATURE:
obn->recalc |= OB_RECALC_DATA;
- if(obn->pose) obn->pose->flag |= POSE_RECALC;
+ if (obn->pose) obn->pose->flag |= POSE_RECALC;
- if(dupflag & USER_DUP_ARM) {
+ if (dupflag & USER_DUP_ARM) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_armature(obn->data);
@@ -1759,7 +1764,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
break;
case OB_LATTICE:
- if(dupflag!=0) {
+ if (dupflag!=0) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_lattice(obn->data);
@@ -1769,7 +1774,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_CAMERA:
- if(dupflag!=0) {
+ if (dupflag!=0) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_camera(obn->data);
@@ -1779,7 +1784,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
break;
case OB_SPEAKER:
- if(dupflag!=0) {
+ if (dupflag!=0) {
ID_NEW_US2(obn->data )
else {
obn->data= copy_speaker(obn->data);
@@ -1792,34 +1797,34 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
}
/* check if obdata is copied */
- if(didit) {
+ if (didit) {
Key *key = ob_get_key(obn);
- if(dupflag & USER_DUP_ACT) {
+ if (dupflag & USER_DUP_ACT) {
bActuator *act;
BKE_copy_animdata_id_action((ID *)obn->data);
- if(key) {
+ if (key) {
BKE_copy_animdata_id_action((ID*)key);
}
/* Update the duplicated action in the action actuators */
for (act = obn->actuators.first; act; act = act->next) {
- if(act->type == ACT_ACTION) {
+ if (act->type == ACT_ACTION) {
bActionActuator* actact = (bActionActuator*) act->data;
- if(ob->adt && actact->act == ob->adt->action) {
+ if (ob->adt && actact->act == ob->adt->action) {
actact->act = obn->adt->action;
}
}
}
}
- if(dupflag & USER_DUP_MAT) {
+ if (dupflag & USER_DUP_MAT) {
matarar= give_matarar(obn);
- if(matarar) {
- for(a=0; a<obn->totcol; a++) {
+ if (matarar) {
+ for (a=0; a<obn->totcol; a++) {
id= (ID *)(*matarar)[a];
- if(id) {
+ if (id) {
ID_NEW_US( (*matarar)[a] )
else (*matarar)[a]= copy_material((*matarar)[a]);
@@ -1878,7 +1883,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
Base *basen= object_add_duplicate_internal(bmain, scene, base, dupflag);
/* note that this is safe to do with this context iterator,
- the list is made in advance */
+ * the list is made in advance */
ED_base_object_select(base, BA_DESELECT);
if (basen == NULL) {
@@ -1886,10 +1891,10 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
/* new object becomes active */
- if(BASACT==base)
+ if (BASACT==base)
ED_base_object_activate(C, basen);
- if(basen->object->data) {
+ if (basen->object->data) {
DAG_id_tag_update(basen->object->data, 0);
}
}
@@ -1910,16 +1915,16 @@ void OBJECT_OT_duplicate(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Duplicate Objects";
+ ot->name = "Duplicate Objects";
ot->description = "Duplicate selected objects";
- ot->idname= "OBJECT_OT_duplicate";
+ ot->idname = "OBJECT_OT_duplicate";
/* api callbacks */
- ot->exec= duplicate_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = duplicate_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* to give to transform */
RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
@@ -1943,7 +1948,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
/* find object, create fake base */
RNA_string_get(op->ptr, "name", name);
ob= (Object *)find_id("OB", name);
- if(ob==NULL)
+ if (ob==NULL)
return OPERATOR_CANCELLED;
base= MEM_callocN(sizeof(Base), "duplibase");
@@ -1981,16 +1986,16 @@ static int add_named_exec(bContext *C, wmOperator *op)
void OBJECT_OT_add_named(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Named Object";
+ ot->name = "Add Named Object";
ot->description = "Add named object";
- ot->idname= "OBJECT_OT_add_named";
+ ot->idname = "OBJECT_OT_add_named";
/* api callbacks */
- ot->exec= add_named_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = add_named_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data");
RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add");
@@ -2017,20 +2022,20 @@ static int join_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
- if(scene->obedit) {
+ if (scene->obedit) {
BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode");
return OPERATOR_CANCELLED;
}
- else if(object_data_is_libdata(ob)) {
+ else if (object_data_is_libdata(ob)) {
BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
return OPERATOR_CANCELLED;
}
- if(ob->type == OB_MESH)
+ if (ob->type == OB_MESH)
return join_mesh_exec(C, op);
- else if(ELEM(ob->type, OB_CURVE, OB_SURF))
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF))
return join_curve_exec(C, op);
- else if(ob->type == OB_ARMATURE)
+ else if (ob->type == OB_ARMATURE)
return join_armature_exec(C, op);
return OPERATOR_CANCELLED;
@@ -2039,16 +2044,16 @@ static int join_exec(bContext *C, wmOperator *op)
void OBJECT_OT_join(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Join";
+ ot->name = "Join";
ot->description = "Join selected objects into active object";
- ot->idname= "OBJECT_OT_join";
+ ot->idname = "OBJECT_OT_join";
/* api callbacks */
- ot->exec= join_exec;
- ot->poll= join_poll;
+ ot->exec = join_exec;
+ ot->poll = join_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/**************************** Join as Shape Key*************************/
@@ -2070,16 +2075,16 @@ static int join_shapes_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
- if(scene->obedit) {
+ if (scene->obedit) {
BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode");
return OPERATOR_CANCELLED;
}
- else if(object_data_is_libdata(ob)) {
+ else if (object_data_is_libdata(ob)) {
BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata");
return OPERATOR_CANCELLED;
}
- if(ob->type == OB_MESH)
+ if (ob->type == OB_MESH)
return join_mesh_shapes_exec(C, op);
return OPERATOR_CANCELLED;
@@ -2088,14 +2093,14 @@ static int join_shapes_exec(bContext *C, wmOperator *op)
void OBJECT_OT_join_shapes(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Join as Shapes";
+ ot->name = "Join as Shapes";
ot->description = "Merge selected objects to shapes of active object";
- ot->idname= "OBJECT_OT_join_shapes";
+ ot->idname = "OBJECT_OT_join_shapes";
/* api callbacks */
- ot->exec= join_shapes_exec;
- ot->poll= join_shapes_poll;
+ ot->exec = join_shapes_exec;
+ ot->poll = join_shapes_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 340a6df8bf6..deefcfd6989 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -30,11 +30,6 @@
* \ingroup edobj
*/
-
-/*
- meshtools.c: no editmode (violated already :), tools operating on meshes
-*/
-
#include <string.h>
#include "MEM_guardedalloc.h"
@@ -86,7 +81,7 @@
/* ****************** multires BAKING ********************** */
/* holder of per-object data needed for bake job
- needed to make job totally thread-safe */
+ * needed to make job totally thread-safe */
typedef struct MultiresBakerJobData {
struct MultiresBakerJobData *next, *prev;
DerivedMesh *lores_dm, *hires_dm;
@@ -166,10 +161,11 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
data->mface[face_num].v3, data->mface[face_num].v4};
const int smoothnormal= (data->mface[face_num].flag & ME_SMOOTH);
- if(!smoothnormal) { /* flat */
- if(data->precomputed_normals) {
+ if (!smoothnormal) { /* flat */
+ if (data->precomputed_normals) {
copy_v3_v3(norm, &data->precomputed_normals[3*face_num]);
- } else {
+ }
+ else {
float nor[3];
float *p0, *p1, *p2;
const int iGetNrVerts= data->mface[face_num].v4!=0 ? 4 : 3;
@@ -178,16 +174,18 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[],
p1= data->mvert[indices[1]].co;
p2= data->mvert[indices[2]].co;
- if(iGetNrVerts==4) {
+ if (iGetNrVerts==4) {
float *p3= data->mvert[indices[3]].co;
normal_quad_v3(nor, p0, p1, p2, p3);
- } else {
+ }
+ else {
normal_tri_v3(nor, p0, p1, p2);
}
copy_v3_v3(norm, nor);
}
- } else {
+ }
+ else {
short *no= data->mvert[indices[vert_index]].no;
normal_short_to_float_v3(norm, no);
@@ -239,12 +237,12 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y)
w= 1-u-v;
/* the sign is the same at all face vertices for any non degenerate face.
- Just in case we clamp the interpolated value though. */
+ * Just in case we clamp the interpolated value though. */
sign= (tang0[3]*u + tang1[3]*v + tang2[3]*w)<0 ? (-1.0f) : 1.0f;
/* this sequence of math is designed specifically as is with great care
- to be compatible with our shader. Please don't change without good reason. */
- for(r= 0; r<3; r++) {
+ * to be compatible with our shader. Please don't change without good reason. */
+ for (r= 0; r<3; r++) {
from_tang[0][r]= tang0[r]*u + tang1[r]*v + tang2[r]*w;
from_tang[2][r]= no0[r]*u + no1[r]*v + no2[r]*w;
}
@@ -263,8 +261,8 @@ static void set_rast_triangle(const MBakeRast *bake_rast, const int x, const int
const int w= bake_rast->w;
const int h= bake_rast->h;
- if(x>=0 && x<w && y>=0 && y<h) {
- if((bake_rast->texels[y*w+x])==0) {
+ if (x>=0 && x<w && y>=0 && y<h) {
+ if ((bake_rast->texels[y*w+x])==0) {
flush_pixel(bake_rast->data, x, y);
bake_rast->texels[y*w+x]= FILTER_MASK_USED;
}
@@ -282,29 +280,29 @@ static void rasterize_half(const MBakeRast *bake_rast,
const int h= bake_rast->h;
int y, y0, y1;
- if(y1_in<=0 || y0_in>=h)
+ if (y1_in<=0 || y0_in>=h)
return;
y0= y0_in<0 ? 0 : y0_in;
y1= y1_in>=h ? h : y1_in;
- for(y= y0; y<y1; y++) {
+ for (y= y0; y<y1; y++) {
/*-b(x-x0) + a(y-y0) = 0 */
int iXl, iXr, x;
float x_l= s_stable!=0 ? (s0_s + (((s1_s-s0_s)*(y-t0_s))/(t1_s-t0_s))) : s0_s;
float x_r= l_stable!=0 ? (s0_l + (((s1_l-s0_l)*(y-t0_l))/(t1_l-t0_l))) : s0_l;
- if(is_mid_right!=0)
+ if (is_mid_right!=0)
SWAP(float, x_l, x_r);
iXl= (int)ceilf(x_l);
iXr= (int)ceilf(x_r);
- if(iXr>0 && iXl<w) {
+ if (iXr>0 && iXl<w) {
iXl= iXl<0?0:iXl;
iXr= iXr>=w?w:iXr;
- for(x= iXl; x<iXr; x++)
+ for (x= iXl; x<iXr; x++)
set_rast_triangle(bake_rast, x, y);
}
}
@@ -323,19 +321,20 @@ static void bake_rasterize(const MBakeRast *bake_rast, const float st0_in[2], co
int is_mid_right= 0, ylo, yhi, yhi_beg;
/* skip degenerates */
- if((slo==smi && tlo==tmi) || (slo==shi && tlo==thi) || (smi==shi && tmi==thi))
+ if ((slo==smi && tlo==tmi) || (slo==shi && tlo==thi) || (smi==shi && tmi==thi))
return;
/* sort by T */
- if(tlo>tmi && tlo>thi) {
+ if (tlo>tmi && tlo>thi) {
SWAP(float, shi, slo);
SWAP(float, thi, tlo);
- } else if(tmi>thi) {
+ }
+ else if (tmi>thi) {
SWAP(float, shi, smi);
SWAP(float, thi, tmi);
}
- if(tlo>tmi) {
+ if (tlo>tmi) {
SWAP(float, slo, smi);
SWAP(float, tlo, tmi);
}
@@ -353,7 +352,7 @@ static void bake_rasterize(const MBakeRast *bake_rast, const float st0_in[2], co
static int multiresbake_test_break(MultiresBakeRender *bkr)
{
- if(!bkr->stop) {
+ if (!bkr->stop) {
/* this means baker is executed outside from job system */
return 0;
}
@@ -373,12 +372,12 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData
MTFace *mtface= dm->getTessFaceDataArray(dm, CD_MTFACE);
float *pvtangent= NULL;
- if(CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1)
+ if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1)
DM_add_tangent_layer(dm);
pvtangent= DM_get_tessface_data_layer(dm, CD_TANGENT);
- if(tot_face > 0) { /* sanity check */
+ if (tot_face > 0) { /* sanity check */
int f= 0;
MBakeRast bake_rast;
MResolvePixelData data={NULL};
@@ -395,25 +394,25 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData
data.lvl= lvl;
data.pass_data= passKnownData;
- if(initBakeData)
+ if (initBakeData)
data.bake_data= initBakeData(bkr, ima);
init_bake_rast(&bake_rast, ibuf, &data, flush_pixel);
- for(f= 0; f<tot_face; f++) {
+ for (f= 0; f<tot_face; f++) {
MTFace *mtfate= &mtface[f];
int verts[3][2], nr_tris, t;
- if(multiresbake_test_break(bkr))
+ if (multiresbake_test_break(bkr))
break;
- if(mtfate->tpage!=ima)
+ if (mtfate->tpage!=ima)
continue;
data.face_index= f;
/* might support other forms of diagonal splits later on such as
- split by shortest diagonal.*/
+ * split by shortest diagonal.*/
verts[0][0]=0;
verts[1][0]=1;
verts[2][0]=2;
@@ -423,7 +422,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData
verts[2][1]=3;
nr_tris= mface[f].v4!=0 ? 2 : 1;
- for(t= 0; t<nr_tris; t++) {
+ for (t= 0; t<nr_tris; t++) {
data.i0 = verts[0][t];
data.i1 = verts[1][t];
data.i2 = verts[2][t];
@@ -433,17 +432,17 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData
bkr->baked_faces++;
- if(bkr->do_update)
+ if (bkr->do_update)
*bkr->do_update= 1;
- if(bkr->progress)
+ if (bkr->progress)
*bkr->progress= ((float)bkr->baked_objects + (float)bkr->baked_faces / tot_face) / bkr->tot_obj;
}
- if(applyBakeData)
+ if (applyBakeData)
applyBakeData(data.bake_data);
- if(freeBakeData)
+ if (freeBakeData)
freeBakeData(data.bake_data);
}
}
@@ -475,7 +474,7 @@ static void interp_barycentric_tri_data(float data[3][3], float u, float v, floa
}
/* mode = 0: interpolate normals,
- mode = 1: interpolate coord */
+ * mode = 1: interpolate coord */
static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, float crn_y, int mode, float res[3])
{
int x0, x1, y0, y1;
@@ -491,12 +490,13 @@ static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, f
u= crn_x-x0;
v= crn_y-y0;
- if(mode == 0) {
+ if (mode == 0) {
copy_v3_v3(data[0], grid[y0 * grid_size + x0].no);
copy_v3_v3(data[1], grid[y0 * grid_size + x1].no);
copy_v3_v3(data[2], grid[y1 * grid_size + x1].no);
copy_v3_v3(data[3], grid[y1 * grid_size + x0].no);
- } else {
+ }
+ else {
copy_v3_v3(data[0], grid[y0 * grid_size + x0].co);
copy_v3_v3(data[1], grid[y0 * grid_size + x1].co);
copy_v3_v3(data[2], grid[y1 * grid_size + x1].co);
@@ -522,10 +522,11 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig
face_side= (grid_size<<1)-1;
- if(lvl==0) {
+ if (lvl==0) {
g_index= grid_offset[face_index];
S= mdisp_rot_face_to_crn(mface.v4 ? 4 : 3, face_side, u*(face_side-1), v*(face_side-1), &crn_x, &crn_y);
- } else {
+ }
+ else {
int side= (1 << (lvl-1)) + 1;
int grid_index= origindex[face_index];
int loc_offs= face_index % (1<<(2*lvl));
@@ -544,25 +545,26 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig
CLAMP(crn_x, 0.0f, grid_size);
CLAMP(crn_y, 0.0f, grid_size);
- if(n != NULL)
+ if (n != NULL)
interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 0, n);
- if(co != NULL)
+ if (co != NULL)
interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 1, co);
}
/* mode = 0: interpolate normals,
- mode = 1: interpolate coord */
+ * mode = 1: interpolate coord */
static void interp_bilinear_mface(DerivedMesh *dm, MFace *mface, const float u, const float v, const int mode, float res[3])
{
float data[4][3];
- if(mode == 0) {
+ if (mode == 0) {
dm->getVertNo(dm, mface->v1, data[0]);
dm->getVertNo(dm, mface->v2, data[1]);
dm->getVertNo(dm, mface->v3, data[2]);
dm->getVertNo(dm, mface->v4, data[3]);
- } else {
+ }
+ else {
dm->getVertCo(dm, mface->v1, data[0]);
dm->getVertCo(dm, mface->v2, data[1]);
dm->getVertCo(dm, mface->v3, data[2]);
@@ -573,16 +575,17 @@ static void interp_bilinear_mface(DerivedMesh *dm, MFace *mface, const float u,
}
/* mode = 0: interpolate normals,
- mode = 1: interpolate coord */
+ * mode = 1: interpolate coord */
static void interp_barycentric_mface(DerivedMesh *dm, MFace *mface, const float u, const float v, const int mode, float res[3])
{
float data[3][3];
- if(mode == 0) {
+ if (mode == 0) {
dm->getVertNo(dm, mface->v1, data[0]);
dm->getVertNo(dm, mface->v2, data[1]);
dm->getVertNo(dm, mface->v3, data[2]);
- } else {
+ }
+ else {
dm->getVertCo(dm, mface->v1, data[0]);
dm->getVertCo(dm, mface->v2, data[1]);
dm->getVertCo(dm, mface->v3, data[2]);
@@ -604,7 +607,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
height_data->height_max= -FLT_MAX;
height_data->height_min= FLT_MAX;
- if(!bkr->use_lores_mesh) {
+ if (!bkr->use_lores_mesh) {
SubsurfModifierData smd= {{NULL}};
int ss_lvl= bkr->tot_lvl - bkr->lvl;
@@ -613,7 +616,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
smd.levels= smd.renderLevels= ss_lvl;
smd.flags|= eSubsurfModifierFlag_SubsurfUv;
- if(bkr->simple)
+ if (bkr->simple)
smd.subdivType= ME_SIMPLE_SUBSURF;
height_data->ssdm= subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0);
@@ -651,24 +654,25 @@ static void apply_heights_data(void *bake_data)
float height, *heights= height_data->heights;
float min= height_data->height_min, max= height_data->height_max;
- for(x= 0; x<ibuf->x; x++) {
- for(y =0; y<ibuf->y; y++) {
+ for (x= 0; x<ibuf->x; x++) {
+ for (y =0; y<ibuf->y; y++) {
i= ibuf->x*y + x;
- if(((char*)ibuf->userdata)[i] != FILTER_MASK_USED)
+ if (((char*)ibuf->userdata)[i] != FILTER_MASK_USED)
continue;
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
float *rrgbf= ibuf->rect_float + i*4;
- if(max-min > 1e-5f) height= (heights[i]-min)/(max-min);
+ if (max-min > 1e-5f) height= (heights[i]-min)/(max-min);
else height= 0;
rrgbf[0]=rrgbf[1]=rrgbf[2]= height;
- } else {
+ }
+ else {
char *rrgb= (char*)ibuf->rect + i*4;
- if(max-min > 1e-5f) height= (heights[i]-min)/(max-min);
+ if (max-min > 1e-5f) height= (heights[i]-min)/(max-min);
else height= 0;
rrgb[0]=rrgb[1]=rrgb[2]= FTOCHAR(height);
@@ -683,7 +687,7 @@ static void free_heights_data(void *bake_data)
{
MHeightBakeData *height_data= (MHeightBakeData*)bake_data;
- if(height_data->ssdm)
+ if (height_data->ssdm)
height_data->ssdm->release(height_data->ssdm);
MEM_freeN(height_data->heights);
@@ -691,11 +695,11 @@ static void free_heights_data(void *bake_data)
}
/* MultiresBake callback for heights baking
- general idea:
- - find coord of point with specified UV in hi-res mesh (let's call it p1)
- - find coord of point and normal with specified UV in lo-res mesh (or subdivided lo-res
- mesh to make texture smoother) let's call this point p0 and n.
- - height wound be dot(n, p1-p0) */
+ * general idea:
+ * - find coord of point with specified UV in hi-res mesh (let's call it p1)
+ * - find coord of point and normal with specified UV in lo-res mesh (or subdivided lo-res
+ * mesh to make texture smoother) let's call this point p0 and n.
+ * - height wound be dot(n, p1-p0) */
static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data,
const int face_index, const int lvl, const float st[2],
float UNUSED(tangmat[3][3]), const int x, const int y)
@@ -715,10 +719,11 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
st1= mtface[face_index].uv[1];
st2= mtface[face_index].uv[2];
- if(mface.v4) {
+ if (mface.v4) {
st3= mtface[face_index].uv[3];
resolve_quad_uv(uv, st, st0, st1, st2, st3);
- } else
+ }
+ else
resolve_tri_uv(uv, st, st0, st1, st2);
CLAMP(uv[0], 0.0f, 1.0f);
@@ -726,15 +731,17 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
get_ccgdm_data(lores_dm, hires_dm, height_data->origindex, lvl, face_index, uv[0], uv[1], p1, 0);
- if(height_data->ssdm) {
+ if (height_data->ssdm) {
get_ccgdm_data(lores_dm, height_data->ssdm, height_data->origindex, 0, face_index, uv[0], uv[1], p0, n);
- } else {
+ }
+ else {
lores_dm->getTessFace(lores_dm, face_index, &mface);
- if(mface.v4) {
+ if (mface.v4) {
interp_bilinear_mface(lores_dm, &mface, uv[0], uv[1], 1, p0);
interp_bilinear_mface(lores_dm, &mface, uv[0], uv[1], 0, n);
- } else {
+ }
+ else {
interp_barycentric_mface(lores_dm, &mface, uv[0], uv[1], 1, p0);
interp_barycentric_mface(lores_dm, &mface, uv[0], uv[1], 0, n);
}
@@ -744,25 +751,26 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
len= dot_v3v3(n, vec);
height_data->heights[pixel]= len;
- if(len<height_data->height_min) height_data->height_min= len;
- if(len>height_data->height_max) height_data->height_max= len;
+ if (len<height_data->height_min) height_data->height_min= len;
+ if (len>height_data->height_max) height_data->height_max= len;
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
float *rrgbf= ibuf->rect_float + pixel*4;
rrgbf[3]= 1.0f;
ibuf->userflags= IB_RECT_INVALID;
- } else {
+ }
+ else {
char *rrgb= (char*)ibuf->rect + pixel*4;
rrgb[3]= 255;
}
}
/* MultiresBake callback for normals' baking
- general idea:
- - find coord and normal of point with specified UV in hi-res mesh
- - multiply it by tangmat
- - vector in color space would be norm(vec) /2 + (0.5, 0.5, 0.5) */
+ * general idea:
+ * - find coord and normal of point with specified UV in hi-res mesh
+ * - multiply it by tangmat
+ * - vector in color space would be norm(vec) /2 + (0.5, 0.5, 0.5) */
static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data,
const int face_index, const int lvl, const float st[2],
float tangmat[3][3], const int x, const int y)
@@ -782,10 +790,11 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
st1= mtface[face_index].uv[1];
st2= mtface[face_index].uv[2];
- if(mface.v4) {
+ if (mface.v4) {
st3= mtface[face_index].uv[3];
resolve_quad_uv(uv, st, st0, st1, st2, st3);
- } else
+ }
+ else
resolve_tri_uv(uv, st, st0, st1, st2);
CLAMP(uv[0], 0.0f, 1.0f);
@@ -798,7 +807,7 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
mul_v3_fl(vec, 0.5);
add_v3_v3(vec, tmp);
- if(ibuf->rect_float) {
+ if (ibuf->rect_float) {
float *rrgbf= ibuf->rect_float + pixel*4;
rrgbf[0]= vec[0];
rrgbf[1]= vec[1];
@@ -806,7 +815,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
rrgbf[3]= 1.0f;
ibuf->userflags= IB_RECT_INVALID;
- } else {
+ }
+ else {
unsigned char *rrgb= (unsigned char *)ibuf->rect + pixel*4;
rgb_float_to_uchar(rrgb, vec);
rrgb[3]= 255;
@@ -824,12 +834,12 @@ static void count_images(MultiresBakeRender *bkr)
totface= dm->getNumTessFaces(dm);
- for(a= 0; a<totface; a++)
+ for (a= 0; a<totface; a++)
mtface[a].tpage->id.flag&= ~LIB_DOIT;
- for(a= 0; a<totface; a++) {
+ for (a= 0; a<totface; a++) {
Image *ima= mtface[a].tpage;
- if((ima->id.flag&LIB_DOIT)==0) {
+ if ((ima->id.flag&LIB_DOIT)==0) {
LinkData *data= BLI_genericNodeN(ima);
BLI_addtail(&bkr->image, data);
bkr->tot_image++;
@@ -837,7 +847,7 @@ static void count_images(MultiresBakeRender *bkr)
}
}
- for(a= 0; a<totface; a++)
+ for (a= 0; a<totface; a++)
mtface[a].tpage->id.flag&= ~LIB_DOIT;
}
@@ -845,11 +855,11 @@ static void bake_images(MultiresBakeRender *bkr)
{
LinkData *link;
- for(link= bkr->image.first; link; link= link->next) {
+ for (link= bkr->image.first; link; link= link->next) {
Image *ima= (Image*)link->data;
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
- if(ibuf->x>0 && ibuf->y>0) {
+ if (ibuf->x>0 && ibuf->y>0) {
ibuf->userdata= MEM_callocN(ibuf->y*ibuf->x, "MultiresBake imbuf mask");
switch(bkr->mode) {
@@ -871,26 +881,26 @@ static void finish_images(MultiresBakeRender *bkr)
{
LinkData *link;
- for(link= bkr->image.first; link; link= link->next) {
+ for (link= bkr->image.first; link; link= link->next) {
Image *ima= (Image*)link->data;
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
- if(ibuf->x<=0 || ibuf->y<=0)
+ if (ibuf->x<=0 || ibuf->y<=0)
continue;
RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter);
ibuf->userflags|= IB_BITMAPDIRTY;
- if(ibuf->rect_float)
+ if (ibuf->rect_float)
ibuf->userflags|= IB_RECT_INVALID;
- if(ibuf->mipmap[0]) {
+ if (ibuf->mipmap[0]) {
ibuf->userflags|= IB_MIPMAP_INVALID;
imb_freemipmapImBuf(ibuf);
}
- if(ibuf->userdata) {
+ if (ibuf->userdata) {
MEM_freeN(ibuf->userdata);
ibuf->userdata= NULL;
}
@@ -915,7 +925,7 @@ static int multiresbake_check(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
ob= base->object;
- if(ob->type != OB_MESH) {
+ if (ob->type != OB_MESH) {
BKE_report(op->reports, RPT_ERROR, "Basking of multires data only works with active object which is a mesh");
ok= 0;
@@ -926,25 +936,26 @@ static int multiresbake_check(bContext *C, wmOperator *op)
mmd= get_multires_modifier(scene, ob, 0);
/* Multi-resolution should be and be last in the stack */
- if(ok && mmd) {
+ if (ok && mmd) {
ModifierData *md;
ok= mmd->totlvl>0;
- for(md = (ModifierData*)mmd->modifier.next; md && ok; md = md->next) {
+ for (md = (ModifierData*)mmd->modifier.next; md && ok; md = md->next) {
if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
ok= 0;
}
}
- } else ok= 0;
+ }
+ else ok= 0;
- if(!ok) {
+ if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Multires data baking requires multi-resolution object");
break;
}
- if(!me->mtpoly) {
+ if (!me->mtpoly) {
BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking");
ok= 0;
@@ -954,7 +965,7 @@ static int multiresbake_check(bContext *C, wmOperator *op)
while (ok && a--) {
Image *ima = me->mtpoly[a].tpage;
- if(!ima) {
+ if (!ima) {
BKE_report(op->reports, RPT_ERROR, "You should have active texture to use multires baker");
ok= 0;
@@ -962,25 +973,26 @@ static int multiresbake_check(bContext *C, wmOperator *op)
else {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
- if(!ibuf) {
+ if (!ibuf) {
BKE_report(op->reports, RPT_ERROR, "Baking should happend to image with image buffer");
ok= 0;
- } else {
- if(ibuf->rect==NULL && ibuf->rect_float==NULL)
+ }
+ else {
+ if (ibuf->rect==NULL && ibuf->rect_float==NULL)
ok= 0;
- if(ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4))
+ if (ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4))
ok= 0;
- if(!ok)
+ if (!ok)
BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type");
}
}
}
}
- if(!ok)
+ if (!ok)
break;
}
CTX_DATA_END;
@@ -996,17 +1008,18 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
*lvl= mmd->lvl;
- if(*lvl==0) {
+ if (*lvl==0) {
DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob);
dm= CDDM_copy(tmp_dm);
tmp_dm->release(tmp_dm);
- } else {
+ }
+ else {
MultiresModifierData tmp_mmd= *mmd;
DerivedMesh *cddm= CDDM_from_mesh(me, ob);
tmp_mmd.lvl= *lvl;
tmp_mmd.sculptlvl= *lvl;
- dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0, 0);
+ dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0);
cddm->release(cddm);
}
@@ -1026,7 +1039,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
tmp_mmd.lvl= mmd->totlvl;
tmp_mmd.sculptlvl= mmd->totlvl;
- dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0, 0);
+ dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0);
cddm->release(cddm);
return dm;
@@ -1038,13 +1051,13 @@ static void clear_images(MTFace *mtface, int totface)
const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f};
const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f};
- for(a= 0; a<totface; a++)
+ for (a= 0; a<totface; a++)
mtface[a].tpage->id.flag&= ~LIB_DOIT;
- for(a= 0; a<totface; a++) {
+ for (a= 0; a<totface; a++) {
Image *ima= mtface[a].tpage;
- if((ima->id.flag&LIB_DOIT)==0) {
+ if ((ima->id.flag&LIB_DOIT)==0) {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
@@ -1052,7 +1065,7 @@ static void clear_images(MTFace *mtface, int totface)
}
}
- for(a= 0; a<totface; a++)
+ for (a= 0; a<totface; a++)
mtface[a].tpage->id.flag&= ~LIB_DOIT;
}
@@ -1062,10 +1075,10 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
int objects_baked= 0;
- if(!multiresbake_check(C, op))
+ if (!multiresbake_check(C, op))
return OPERATOR_CANCELLED;
- if(scene->r.bake_flag&R_BAKE_CLEAR) { /* clear images */
+ if (scene->r.bake_flag&R_BAKE_CLEAR) { /* clear images */
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
Mesh *me;
@@ -1092,7 +1105,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
/* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */
bkr.lores_dm= multiresbake_create_loresdm(scene, ob, &bkr.lvl);
- if(!bkr.lores_dm)
+ if (!bkr.lores_dm)
continue;
bkr.hires_dm= multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple);
@@ -1108,7 +1121,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if(!objects_baked)
+ if (!objects_baked)
BKE_report(op->reports, RPT_ERROR, "No objects found to bake from");
return OPERATOR_FINISHED;
@@ -1135,7 +1148,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj)
multires_force_update(ob);
lores_dm = multiresbake_create_loresdm(scene, ob, &lvl);
- if(!lores_dm)
+ if (!lores_dm)
continue;
data= MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data");
@@ -1156,8 +1169,8 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
tot_obj= BLI_countlist(&bkj->data);
- if(bkj->bake_clear) { /* clear images */
- for(data= bkj->data.first; data; data= data->next) {
+ if (bkj->bake_clear) { /* clear images */
+ for (data= bkj->data.first; data; data= data->next) {
DerivedMesh *dm= data->lores_dm;
MTFace *mtface= CustomData_get_layer(&dm->faceData, CD_MTFACE);
@@ -1165,7 +1178,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa
}
}
- for(data= bkj->data.first; data; data= data->next) {
+ for (data= bkj->data.first; data; data= data->next) {
MultiresBakeRender bkr= {0};
/* copy data stored in job descriptor */
@@ -1219,13 +1232,13 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
MultiresBakeJob *bkr;
wmJob *steve;
- if(!multiresbake_check(C, op))
+ if (!multiresbake_check(C, op))
return OPERATOR_CANCELLED;
bkr= MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data");
init_multiresbake_job(C, bkr);
- if(!bkr->data.first) {
+ if (!bkr->data.first) {
BKE_report(op->reports, RPT_ERROR, "No objects found to bake from");
return OPERATOR_CANCELLED;
}
@@ -1283,10 +1296,10 @@ static int test_bake_internal(bContext *C, ReportList *reports)
{
Scene *scene= CTX_data_scene(C);
- if((scene->r.bake_flag & R_BAKE_TO_ACTIVE) && CTX_data_active_object(C)==NULL) {
+ if ((scene->r.bake_flag & R_BAKE_TO_ACTIVE) && CTX_data_active_object(C)==NULL) {
BKE_report(reports, RPT_ERROR, "No active object");
}
- else if(scene->r.bake_mode==RE_BAKE_AO && scene->world==NULL) {
+ else if (scene->r.bake_mode==RE_BAKE_AO && scene->world==NULL) {
BKE_report(reports, RPT_ERROR, "No world set up");
}
else {
@@ -1309,12 +1322,12 @@ static void init_bake_internal(BakeRender *bkr, bContext *C)
bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL;
bkr->re= RE_NewRender("_Bake View_");
- if(scene->r.bake_mode==RE_BAKE_AO) {
+ if (scene->r.bake_mode==RE_BAKE_AO) {
/* If raytracing or AO is disabled, switch it on temporarily for baking. */
bkr->prev_wo_amb_occ = (scene->world->mode & WO_AMB_OCC) != 0;
scene->world->mode |= WO_AMB_OCC;
}
- if(scene->r.bake_mode==RE_BAKE_AO || bkr->actob) {
+ if (scene->r.bake_mode==RE_BAKE_AO || bkr->actob) {
bkr->prev_r_raytrace = (scene->r.mode & R_RAYTRACE) != 0;
scene->r.mode |= R_RAYTRACE;
}
@@ -1325,22 +1338,22 @@ static void finish_bake_internal(BakeRender *bkr)
RE_Database_Free(bkr->re);
/* restore raytrace and AO */
- if(bkr->scene->r.bake_mode==RE_BAKE_AO)
- if(bkr->prev_wo_amb_occ == 0)
+ if (bkr->scene->r.bake_mode==RE_BAKE_AO)
+ if (bkr->prev_wo_amb_occ == 0)
bkr->scene->world->mode &= ~WO_AMB_OCC;
- if(bkr->scene->r.bake_mode==RE_BAKE_AO || bkr->actob)
- if(bkr->prev_r_raytrace == 0)
+ if (bkr->scene->r.bake_mode==RE_BAKE_AO || bkr->actob)
+ if (bkr->prev_r_raytrace == 0)
bkr->scene->r.mode &= ~R_RAYTRACE;
- if(bkr->result==BAKE_RESULT_OK) {
+ if (bkr->result==BAKE_RESULT_OK) {
Image *ima;
/* force OpenGL reload and mipmap recalc */
- for(ima= G.main->image.first; ima; ima= ima->id.next) {
- if(ima->ok==IMA_OK_LOADED) {
+ for (ima= G.main->image.first; ima; ima= ima->id.next) {
+ if (ima->ok==IMA_OK_LOADED) {
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
- if(ibuf) {
- if(ibuf->userflags & IB_BITMAPDIRTY) {
+ if (ibuf) {
+ if (ibuf->userflags & IB_BITMAPDIRTY) {
GPU_free_image(ima);
imb_freemipmapImBuf(ibuf);
}
@@ -1389,9 +1402,9 @@ static void bake_update(void *bkv)
{
BakeRender *bkr= bkv;
- if(bkr->sa && bkr->sa->spacetype==SPACE_IMAGE) { /* incase the user changed while baking */
+ if (bkr->sa && bkr->sa->spacetype==SPACE_IMAGE) { /* in case the user changed while baking */
SpaceImage *sima= bkr->sa->spacedata.first;
- if(sima)
+ if (sima)
sima->image= RE_bake_shade_get_image();
}
}
@@ -1401,9 +1414,9 @@ static void bake_freejob(void *bkv)
BakeRender *bkr= bkv;
finish_bake_internal(bkr);
- if(bkr->result==BAKE_RESULT_NO_OBJECTS)
+ if (bkr->result==BAKE_RESULT_NO_OBJECTS)
BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to");
- else if(bkr->result==BAKE_RESULT_FEEDBACK_LOOP)
+ else if (bkr->result==BAKE_RESULT_FEEDBACK_LOOP)
BKE_report(bkr->reports, RPT_WARNING, "Feedback loop detected");
MEM_freeN(bkr);
@@ -1414,7 +1427,7 @@ static void bake_freejob(void *bkv)
static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
+ if (0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
/* running render */
@@ -1439,14 +1452,15 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
Scene *scene= CTX_data_scene(C);
int result= OPERATOR_CANCELLED;
- if(is_multires_bake(scene)) {
+ if (is_multires_bake(scene)) {
result= multiresbake_image_exec(C, op);
- } else {
+ }
+ else {
/* only one render job at a time */
- if(WM_jobs_test(CTX_wm_manager(C), scene))
+ if (WM_jobs_test(CTX_wm_manager(C), scene))
return OPERATOR_CANCELLED;
- if(test_bake_internal(C, op->reports)==0) {
+ if (test_bake_internal(C, op->reports)==0) {
return OPERATOR_CANCELLED;
}
else {
@@ -1488,10 +1502,11 @@ static int bake_image_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
int result= OPERATOR_CANCELLED;
- if(is_multires_bake(scene)) {
+ if (is_multires_bake(scene)) {
result= multiresbake_image_exec_locked(C, op);
- } else {
- if(test_bake_internal(C, op->reports)==0) {
+ }
+ else {
+ if (test_bake_internal(C, op->reports)==0) {
return OPERATOR_CANCELLED;
}
else {
@@ -1511,9 +1526,9 @@ static int bake_image_exec(bContext *C, wmOperator *op)
bkr.ready= 0;
BLI_insert_thread(&threads, &bkr);
- while(bkr.ready==0) {
+ while (bkr.ready==0) {
PIL_sleep_ms(50);
- if(bkr.ready)
+ if (bkr.ready)
break;
/* used to redraw in 2.4x but this is just for exec in 2.5 */
@@ -1522,9 +1537,9 @@ static int bake_image_exec(bContext *C, wmOperator *op)
}
BLI_end_threads(&threads);
- if(bkr.result==BAKE_RESULT_NO_OBJECTS)
+ if (bkr.result==BAKE_RESULT_NO_OBJECTS)
BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to");
- else if(bkr.result==BAKE_RESULT_FEEDBACK_LOOP)
+ else if (bkr.result==BAKE_RESULT_FEEDBACK_LOOP)
BKE_report(op->reports, RPT_ERROR, "Feedback loop detected");
finish_bake_internal(&bkr);
@@ -1541,12 +1556,12 @@ static int bake_image_exec(bContext *C, wmOperator *op)
void OBJECT_OT_bake_image(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Bake";
- ot->description= "Bake image textures of selected objects";
- ot->idname= "OBJECT_OT_bake_image";
+ ot->name = "Bake";
+ ot->description = "Bake image textures of selected objects";
+ ot->idname = "OBJECT_OT_bake_image";
/* api callbacks */
- ot->exec= bake_image_exec;
- ot->invoke= objects_bake_render_invoke;
- ot->modal= objects_bake_render_modal;
+ ot->exec = bake_image_exec;
+ ot->invoke = objects_bake_render_invoke;
+ ot->modal = objects_bake_render_modal;
}
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index a90edb29c29..ec3567454df 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -142,6 +142,7 @@ bConstraint *get_active_constraint (Object *ob)
}
/* -------------- Constraint Management (Add New, Remove, Rename) -------------------- */
+#ifdef WITH_PYTHON
/* ------------- PyConstraints ------------------ */
/* this callback sets the text-file to be used for selected menu item */
@@ -160,7 +161,6 @@ static void validate_pyconstraint_cb (void *arg1, void *arg2)
data->text = text;
}
-#ifdef WITH_PYTHON
/* this returns a string for the list of usable pyconstraint script names */
static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex)
{
@@ -391,8 +391,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
/* if the number of points does not match the amount required by the chain length,
* free the points array and request a rebind...
*/
- if ((data->points == NULL) || (data->numpoints != data->chainlen+1))
- {
+ if ((data->points == NULL) || (data->numpoints != data->chainlen+1)) {
/* free the points array */
if (data->points) {
MEM_freeN(data->points);
@@ -406,17 +405,17 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
else if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data = curcon->data;
- if((data->flag&CAMERASOLVER_ACTIVECLIP)==0) {
- if(data->clip != NULL && data->track[0]) {
+ if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0) {
+ if (data->clip != NULL && data->track[0]) {
MovieTracking *tracking= &data->clip->tracking;
MovieTrackingObject *tracking_object;
- if(data->object[0])
+ if (data->object[0])
tracking_object= BKE_tracking_named_object(tracking, data->object);
else
tracking_object= BKE_tracking_get_camera_object(tracking);
- if(!tracking_object) {
+ if (!tracking_object) {
curcon->flag |= CONSTRAINT_DISABLE;
}
else {
@@ -430,13 +429,13 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
else if (curcon->type == CONSTRAINT_TYPE_CAMERASOLVER) {
bCameraSolverConstraint *data = curcon->data;
- if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
+ if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
curcon->flag |= CONSTRAINT_DISABLE;
}
else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data = curcon->data;
- if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
+ if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
curcon->flag |= CONSTRAINT_DISABLE;
}
@@ -590,19 +589,19 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
if (pchan)
list = &pchan->constraints;
else {
- //if (G.f & G_DEBUG)
+ //if (G.debug & G_DEBUG)
//printf("edit_constraint_property_get: No active bone for object '%s'\n", (ob)? ob->id.name+2 : "<None>");
return NULL;
}
}
else {
- //if (G.f & G_DEBUG)
+ //if (G.debug & G_DEBUG)
//printf("edit_constraint_property_get: defaulting to getting list in the standard way\n");
list = get_active_constraints(ob);
}
con = constraints_findByName(list, constraint_name);
- //if (G.f & G_DEBUG)
+ //if (G.debug & G_DEBUG)
//printf("constraint found = %p, %s\n", (void *)con, (con)?con->name:"<Not found>");
if (con && (type != 0) && (con->type != type))
@@ -645,16 +644,16 @@ static int stretchto_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Reset Original Length";
- ot->idname= "CONSTRAINT_OT_stretchto_reset";
- ot->description= "Reset original length of bone for Stretch To Constraint";
+ ot->name = "Reset Original Length";
+ ot->idname = "CONSTRAINT_OT_stretchto_reset";
+ ot->description = "Reset original length of bone for Stretch To Constraint";
- ot->exec= stretchto_reset_exec;
- ot->invoke= stretchto_reset_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = stretchto_reset_exec;
+ ot->invoke = stretchto_reset_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -688,16 +687,16 @@ static int limitdistance_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Reset Distance";
- ot->idname= "CONSTRAINT_OT_limitdistance_reset";
- ot->description= "Reset limiting distance for Limit Distance Constraint";
+ ot->name = "Reset Distance";
+ ot->idname = "CONSTRAINT_OT_limitdistance_reset";
+ ot->description = "Reset limiting distance for Limit Distance Constraint";
- ot->exec= limitdistance_reset_exec;
- ot->invoke= limitdistance_reset_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = limitdistance_reset_exec;
+ ot->invoke = limitdistance_reset_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -814,16 +813,16 @@ static int childof_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Set Inverse";
- ot->idname= "CONSTRAINT_OT_childof_set_inverse";
- ot->description= "Set inverse correction for ChildOf constraint";
+ ot->name = "Set Inverse";
+ ot->idname = "CONSTRAINT_OT_childof_set_inverse";
+ ot->description = "Set inverse correction for ChildOf constraint";
- ot->exec= childof_set_inverse_exec;
- ot->invoke= childof_set_inverse_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = childof_set_inverse_exec;
+ ot->invoke = childof_set_inverse_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -834,7 +833,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op)
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL;
- if(data==NULL) {
+ if (data==NULL) {
BKE_report(op->reports, RPT_ERROR, "Childof constraint not found");
return OPERATOR_CANCELLED;
}
@@ -858,16 +857,16 @@ static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UN
void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Inverse";
- ot->idname= "CONSTRAINT_OT_childof_clear_inverse";
- ot->description= "Clear inverse correction for ChildOf constraint";
+ ot->name = "Clear Inverse";
+ ot->idname = "CONSTRAINT_OT_childof_clear_inverse";
+ ot->description = "Clear inverse correction for ChildOf constraint";
- ot->exec= childof_clear_inverse_exec;
- ot->invoke= childof_clear_inverse_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = childof_clear_inverse_exec;
+ ot->invoke = childof_clear_inverse_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -905,16 +904,16 @@ static int objectsolver_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent
void CONSTRAINT_OT_objectsolver_set_inverse (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Set Inverse";
- ot->idname= "CONSTRAINT_OT_objectsolver_set_inverse";
- ot->description= "Set inverse correction for ObjectSolver constraint";
+ 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;
- ot->invoke= objectsolver_set_inverse_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = objectsolver_set_inverse_exec;
+ ot->invoke = objectsolver_set_inverse_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -924,7 +923,7 @@ static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op)
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL;
- if(data==NULL) {
+ if (data==NULL) {
BKE_report(op->reports, RPT_ERROR, "Childof constraint not found");
return OPERATOR_CANCELLED;
}
@@ -948,16 +947,16 @@ static int objectsolver_clear_inverse_invoke(bContext *C, wmOperator *op, wmEven
void CONSTRAINT_OT_objectsolver_clear_inverse (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Inverse";
- ot->idname= "CONSTRAINT_OT_objectsolver_clear_inverse";
- ot->description= "Clear inverse correction for ObjectSolver constraint";
+ 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;
- ot->invoke= objectsolver_clear_inverse_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = objectsolver_clear_inverse_exec;
+ ot->invoke = objectsolver_clear_inverse_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -978,11 +977,11 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con)
void ED_object_constraint_update(Object *ob)
{
- if(ob->pose) update_pose_constraint_flags(ob->pose);
+ if (ob->pose) update_pose_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);
+ 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);
}
@@ -990,7 +989,7 @@ void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *o
{
ED_object_constraint_update(ob);
- if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
+ if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
DAG_scene_sort(bmain, scene);
}
@@ -1016,7 +1015,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op))
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) {
+ if (is_ik) {
BIK_clear_data(ob->pose);
}
@@ -1034,16 +1033,16 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op))
void CONSTRAINT_OT_delete (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Delete Constraint";
- ot->idname= "CONSTRAINT_OT_delete";
- ot->description= "Remove constraint from constraint stack";
+ ot->name = "Delete Constraint";
+ ot->idname = "CONSTRAINT_OT_delete";
+ ot->description = "Remove constraint from constraint stack";
/* callbacks */
- ot->exec= constraint_delete_exec;
- ot->poll= constraint_poll;
+ ot->exec = constraint_delete_exec;
+ ot->poll = constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int constraint_move_down_exec (bContext *C, wmOperator *op)
@@ -1079,17 +1078,17 @@ static int constraint_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNU
void CONSTRAINT_OT_move_down (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Move Constraint Down";
- ot->idname= "CONSTRAINT_OT_move_down";
- ot->description= "Move constraint down in constraint stack";
+ ot->name = "Move Constraint Down";
+ ot->idname = "CONSTRAINT_OT_move_down";
+ ot->description = "Move constraint down in constraint stack";
/* callbacks */
- ot->exec= constraint_move_down_exec;
- ot->invoke= constraint_move_down_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = constraint_move_down_exec;
+ ot->invoke = constraint_move_down_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -1126,17 +1125,17 @@ static int constraint_move_up_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE
void CONSTRAINT_OT_move_up (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Move Constraint Up";
- ot->idname= "CONSTRAINT_OT_move_up";
- ot->description= "Move constraint up in constraint stack";
+ ot->name = "Move Constraint Up";
+ ot->idname = "CONSTRAINT_OT_move_up";
+ ot->description = "Move constraint up in constraint stack";
/* callbacks */
- ot->exec= constraint_move_up_exec;
- ot->invoke= constraint_move_up_invoke;
- ot->poll= edit_constraint_poll;
+ ot->exec = constraint_move_up_exec;
+ ot->invoke = constraint_move_up_invoke;
+ ot->poll = edit_constraint_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -1161,7 +1160,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
/* force depsgraph to get recalculated since relationships removed */
DAG_scene_sort(bmain, scene); /* sort order of objects */
- /* note, calling BIK_clear_data() isnt needed here */
+ /* note, calling BIK_clear_data() isn't needed here */
/* do updates */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1174,12 +1173,12 @@ void POSE_OT_constraints_clear(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clear Pose Constraints";
- ot->idname= "POSE_OT_constraints_clear";
- ot->description= "Clear all the constraints for the selected bones";
+ ot->idname = "POSE_OT_constraints_clear";
+ ot->description = "Clear all the constraints for the selected bones";
/* callbacks */
- ot->exec= pose_constraints_clear_exec;
- ot->poll= ED_operator_posemode; // XXX - do we want to ensure there are selected bones too?
+ ot->exec = pose_constraints_clear_exec;
+ ot->poll = ED_operator_posemode; // XXX - do we want to ensure there are selected bones too?
}
@@ -1209,12 +1208,12 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clear Object Constraints";
- ot->idname= "OBJECT_OT_constraints_clear";
- ot->description= "Clear all the constraints for the active Object only";
+ ot->idname = "OBJECT_OT_constraints_clear";
+ ot->description = "Clear all the constraints for the active Object only";
/* callbacks */
- ot->exec= object_constraints_clear_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = object_constraints_clear_exec;
+ ot->poll = ED_operator_object_active_editable;
}
/************************ copy all constraints operators *********************/
@@ -1254,16 +1253,16 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
void POSE_OT_constraints_copy(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Constraints to Selected";
- ot->idname= "POSE_OT_constraints_copy";
+ ot->name = "Copy Constraints to Selected";
+ ot->idname = "POSE_OT_constraints_copy";
ot->description = "Copy constraints to other selected bones";
/* api callbacks */
- ot->exec= pose_constraint_copy_exec;
- ot->poll= ED_operator_posemode;
+ ot->exec = pose_constraint_copy_exec;
+ ot->poll = ED_operator_posemode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1295,16 +1294,16 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_constraints_copy(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Constraints to Selected";
- ot->idname= "OBJECT_OT_constraints_copy";
+ ot->name = "Copy Constraints to Selected";
+ ot->idname = "OBJECT_OT_constraints_copy";
ot->description = "Copy constraints to other selected objects";
/* api callbacks */
- ot->exec= object_constraint_copy_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = object_constraint_copy_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/************************ add constraint operators *********************/
@@ -1501,7 +1500,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
/* get the target objects, adding them as need be */
if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) {
/* method of setting target depends on the type of target we've got
- * - by default, just set the first target (distinction here is only for multiple-targetted constraints)
+ * - by default, just set the first target (distinction here is only for multiple-targeted constraints)
*/
if (tar_pchan)
set_constraint_nth_target(con, tar_ob, tar_pchan->name, 0);
@@ -1610,77 +1609,77 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_constraint_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Constraint";
+ ot->name = "Add Constraint";
ot->description = "Add a constraint to the active object";
- ot->idname= "OBJECT_OT_constraint_add";
+ ot->idname = "OBJECT_OT_constraint_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_constraint_add_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_constraint_add_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
}
void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Constraint (with Targets)";
+ ot->name = "Add Constraint (with Targets)";
ot->description = "Add a constraint to the active object, with target (where applicable) set to the selected Objects/Bones";
- ot->idname= "OBJECT_OT_constraint_add_with_targets";
+ ot->idname = "OBJECT_OT_constraint_add_with_targets";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_constraint_add_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_constraint_add_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
}
void POSE_OT_constraint_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Constraint";
+ ot->name = "Add Constraint";
ot->description = "Add a constraint to the active bone";
- ot->idname= "POSE_OT_constraint_add";
+ ot->idname = "POSE_OT_constraint_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= pose_constraint_add_exec;
- ot->poll= ED_operator_posemode;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = pose_constraint_add_exec;
+ ot->poll = ED_operator_posemode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
}
void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Constraint (with Targets)";
+ ot->name = "Add Constraint (with Targets)";
ot->description = "Add a constraint to the active bone, with target (where applicable) set to the selected Objects/Bones";
- ot->idname= "POSE_OT_constraint_add_with_targets";
+ ot->idname = "POSE_OT_constraint_add_with_targets";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= pose_constraint_add_exec;
- ot->poll= ED_operator_posemode;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = pose_constraint_add_exec;
+ ot->poll = ED_operator_posemode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
}
/************************ IK Constraint operators *********************/
@@ -1753,17 +1752,17 @@ static int pose_ik_add_exec(bContext *C, wmOperator *op)
void POSE_OT_ik_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add IK to Bone";
- ot->description= "Add IK Constraint to the active Bone";
- ot->idname= "POSE_OT_ik_add";
+ ot->name = "Add IK to Bone";
+ ot->description = "Add IK Constraint to the active Bone";
+ ot->idname = "POSE_OT_ik_add";
/* api callbacks */
- ot->invoke= pose_ik_add_invoke;
- ot->exec= pose_ik_add_exec;
- ot->poll= ED_operator_posemode;
+ ot->invoke = pose_ik_add_invoke;
+ ot->exec = pose_ik_add_exec;
+ ot->poll = ED_operator_posemode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "with_targets", 1, "With Targets", "Assign IK Constraint with targets derived from the select bones/objects");
@@ -1804,15 +1803,15 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
void POSE_OT_ik_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove IK";
- ot->description= "Remove all IK Constraints from selected bones";
- ot->idname= "POSE_OT_ik_clear";
+ ot->name = "Remove IK";
+ ot->description = "Remove all IK Constraints from selected bones";
+ ot->idname = "POSE_OT_ik_clear";
/* api callbacks */
- ot->exec= pose_ik_clear_exec;
- ot->poll= ED_operator_posemode;
+ ot->exec = pose_ik_clear_exec;
+ ot->poll = ED_operator_posemode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 11ceda8a61f..2fbc2966bc8 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -121,7 +121,7 @@ Object *ED_object_context(bContext *C)
Object *ED_object_active_context(bContext *C)
{
Object *ob= NULL;
- if(C) {
+ if (C) {
ob= ED_object_context(C);
if (!ob) ob= CTX_data_active_object(C);
}
@@ -140,8 +140,8 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op))
int changed = 0;
/* XXX need a context loop to handle such cases */
- for(base = FIRSTBASE; base; base=base->next) {
- if((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) {
+ for (base = FIRSTBASE; base; base=base->next) {
+ if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) {
base->flag |= SELECT;
base->object->flag = base->flag;
base->object->restrictflag &= ~OB_RESTRICT_VIEW;
@@ -161,16 +161,16 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Restrict View";
+ ot->name = "Clear Restrict View";
ot->description = "Reveal the object by setting the hide flag";
- ot->idname= "OBJECT_OT_hide_view_clear";
+ ot->idname = "OBJECT_OT_hide_view_clear";
/* api callbacks */
- ot->exec= object_hide_view_clear_exec;
- ot->poll= ED_operator_view3d_active;
+ ot->exec = object_hide_view_clear_exec;
+ ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_hide_view_set_exec(bContext *C, wmOperator *op)
@@ -181,7 +181,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
const int unselected= RNA_boolean_get(op->ptr, "unselected");
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
- if(!unselected) {
+ if (!unselected) {
if (base->flag & SELECT) {
base->flag &= ~SELECT;
base->object->flag = base->flag;
@@ -215,16 +215,16 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_hide_view_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Set Restrict View";
+ ot->name = "Set Restrict View";
ot->description = "Hide the object by setting the hide flag";
- ot->idname= "OBJECT_OT_hide_view_set";
+ ot->idname = "OBJECT_OT_hide_view_set";
/* api callbacks */
- ot->exec= object_hide_view_set_exec;
- ot->poll= ED_operator_view3d_active;
+ ot->exec = object_hide_view_set_exec;
+ ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
@@ -237,14 +237,14 @@ static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op))
/* XXX need a context loop to handle such cases */
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob->restrictflag & OB_RESTRICT_RENDER) {
+ if (ob->restrictflag & OB_RESTRICT_RENDER) {
ob->restrictflag &= ~OB_RESTRICT_RENDER;
changed= 1;
}
}
CTX_DATA_END;
- if(changed)
+ if (changed)
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL);
return OPERATOR_FINISHED;
@@ -254,16 +254,16 @@ void OBJECT_OT_hide_render_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Restrict Render";
+ ot->name = "Clear Restrict Render";
ot->description = "Reveal the render object by setting the hide render flag";
- ot->idname= "OBJECT_OT_hide_render_clear";
+ ot->idname = "OBJECT_OT_hide_render_clear";
/* api callbacks */
- ot->exec= object_hide_render_clear_exec;
- ot->poll= ED_operator_view3d_active;
+ ot->exec = object_hide_render_clear_exec;
+ ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_hide_render_set_exec(bContext *C, wmOperator *op)
@@ -271,7 +271,7 @@ static int object_hide_render_set_exec(bContext *C, wmOperator *op)
const int unselected= RNA_boolean_get(op->ptr, "unselected");
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
- if(!unselected) {
+ if (!unselected) {
if (base->flag & SELECT) {
base->object->restrictflag |= OB_RESTRICT_RENDER;
}
@@ -290,16 +290,16 @@ static int object_hide_render_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_hide_render_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Set Restrict Render";
+ ot->name = "Set Restrict Render";
ot->description = "Hide the render object by setting the hide render flag";
- ot->idname= "OBJECT_OT_hide_render_set";
+ ot->idname = "OBJECT_OT_hide_render_set";
/* api callbacks */
- ot->exec= object_hide_render_set_exec;
- ot->poll= ED_operator_view3d_active;
+ ot->exec = object_hide_render_set_exec;
+ ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects");
}
@@ -314,55 +314,55 @@ void ED_object_exit_editmode(bContext *C, int flag)
Object *obedit= CTX_data_edit_object(C);
int freedata = flag & EM_FREEDATA;
- if(obedit==NULL) return;
+ if (obedit==NULL) return;
- if(flag & EM_WAITCURSOR) waitcursor(1);
- if(obedit->type==OB_MESH) {
+ if (flag & EM_WAITCURSOR) waitcursor(1);
+ if (obedit->type==OB_MESH) {
Mesh *me= obedit->data;
-// if(EM_texFaceCheck())
+// if (EM_texFaceCheck())
- if(me->edit_btmesh->bm->totvert>MESH_MAX_VERTS) {
+ if (me->edit_btmesh->bm->totvert>MESH_MAX_VERTS) {
error("Too many vertices");
return;
}
- EDBM_LoadEditBMesh(scene, obedit);
+ EDBM_mesh_load(obedit);
- if(freedata) {
- EDBM_FreeEditBMesh(me->edit_btmesh);
+ if (freedata) {
+ EDBM_mesh_free(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
me->edit_btmesh= NULL;
}
- if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT) {
+ if (obedit->restore_mode & OB_MODE_WEIGHT_PAINT) {
mesh_octree_table(NULL, NULL, NULL, 'e');
mesh_mirrtopo_table(NULL, 'e');
}
}
else if (obedit->type==OB_ARMATURE) {
ED_armature_from_edit(obedit);
- if(freedata)
+ if (freedata)
ED_armature_edit_free(obedit);
}
- else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) {
+ else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
load_editNurb(obedit);
- if(freedata) free_editNurb(obedit);
+ if (freedata) free_editNurb(obedit);
}
- else if(obedit->type==OB_FONT && freedata) {
+ else if (obedit->type==OB_FONT && freedata) {
load_editText(obedit);
- if(freedata) free_editText(obedit);
+ if (freedata) free_editText(obedit);
}
- else if(obedit->type==OB_LATTICE) {
+ else if (obedit->type==OB_LATTICE) {
load_editLatt(obedit);
- if(freedata) free_editLatt(obedit);
+ if (freedata) free_editLatt(obedit);
}
- else if(obedit->type==OB_MBALL) {
+ else if (obedit->type==OB_MBALL) {
load_editMball(obedit);
- if(freedata) free_editMball(obedit);
+ if (freedata) free_editMball(obedit);
}
/* freedata only 0 now on file saves and render */
- if(freedata) {
+ if (freedata) {
ListBase pidlist;
PTCacheID *pid;
@@ -371,8 +371,8 @@ void ED_object_exit_editmode(bContext *C, int flag)
/* flag object caches as outdated */
BKE_ptcache_ids_from_object(&pidlist, obedit, NULL, 0);
- for(pid=pidlist.first; pid; pid=pid->next) {
- if(pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */
+ for (pid=pidlist.first; pid; pid=pid->next) {
+ if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */
pid->cache->flag |= PTCACHE_OUTDATED;
}
BLI_freelistN(&pidlist);
@@ -382,10 +382,10 @@ void ED_object_exit_editmode(bContext *C, int flag)
/* also flush ob recalc, doesn't take much overhead, but used for particles */
DAG_id_tag_update(&obedit->id, OB_RECALC_OB|OB_RECALC_DATA);
- if(flag & EM_DO_UNDO)
+ if (flag & EM_DO_UNDO)
ED_undo_push(C, "Editmode");
- if(flag & EM_WAITCURSOR) waitcursor(0);
+ if (flag & EM_WAITCURSOR) waitcursor(0);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene);
@@ -403,17 +403,17 @@ void ED_object_enter_editmode(bContext *C, int flag)
View3D *v3d= NULL;
int ok= 0;
- if(scene->id.lib) return;
+ if (scene->id.lib) return;
- if(sa && sa->spacetype==SPACE_VIEW3D)
+ if (sa && sa->spacetype==SPACE_VIEW3D)
v3d= sa->spacedata.first;
- if((flag & EM_IGNORE_LAYER)==0) {
+ if ((flag & EM_IGNORE_LAYER)==0) {
base= CTX_data_active_base(C); /* active layer checked here for view3d */
- if(base==NULL) return;
- else if(v3d && (base->lay & v3d->lay)==0) return;
- else if(!v3d && (base->lay & scene->lay)==0) return;
+ if (base==NULL) return;
+ else if (v3d && (base->lay & v3d->lay)==0) return;
+ else if (!v3d && (base->lay & scene->lay)==0) return;
}
else {
base= scene->basact;
@@ -428,22 +428,32 @@ void ED_object_enter_editmode(bContext *C, int flag)
return;
}
- if(flag & EM_WAITCURSOR) waitcursor(1);
+ if (flag & EM_WAITCURSOR) waitcursor(1);
ob->restore_mode = ob->mode;
/* note, when switching scenes the object can have editmode data but
* not be scene->obedit: bug 22954, this avoids calling self eternally */
- if((ob->restore_mode & OB_MODE_EDIT)==0)
+ if ((ob->restore_mode & OB_MODE_EDIT)==0)
ED_object_toggle_modes(C, ob->mode);
ob->mode= OB_MODE_EDIT;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
+ BMEditMesh *em;
ok= 1;
- scene->obedit= ob; // context sees this
-
- EDBM_MakeEditBMesh(CTX_data_tool_settings(C), scene, ob);
+ scene->obedit = ob; /* context sees this */
+
+ EDBM_mesh_make(CTX_data_tool_settings(C), scene, ob);
+
+ em = BMEdit_FromObject(ob);
+ if (LIKELY(em)) {
+ /* order doesn't matter */
+ EDBM_mesh_normals_update(em);
+ BMEdit_RecalcTessellation(em);
+
+ BM_mesh_select_mode_flush(em->bm);
+ }
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, scene);
}
@@ -453,12 +463,12 @@ void ED_object_enter_editmode(bContext *C, int flag)
/*
* The function object_data_is_libdata make a problem here, the
* check for ob->proxy return 0 and let blender enter to edit mode
- * this causa a crash when you try leave the edit mode.
+ * this causes a crash when you try leave the edit mode.
* The problem is that i can't remove the ob->proxy check from
* object_data_is_libdata that prevent the bugfix #6614, so
* i add this little hack here.
*/
- if(arm->id.lib) {
+ if (arm->id.lib) {
error_libdata();
return;
}
@@ -470,28 +480,28 @@ void ED_object_enter_editmode(bContext *C, int flag)
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene);
}
- else if(ob->type==OB_FONT) {
+ else if (ob->type==OB_FONT) {
scene->obedit= ob; // XXX for context
ok= 1;
make_editText(ob);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_TEXT, scene);
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
scene->obedit= ob; // XXX for context
ok= 1;
make_editMball(ob);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MBALL, scene);
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
scene->obedit= ob; // XXX for context
ok= 1;
make_editLatt(ob);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_LATTICE, scene);
}
- else if(ob->type==OB_SURF || ob->type==OB_CURVE) {
+ else if (ob->type==OB_SURF || ob->type==OB_CURVE) {
ok= 1;
scene->obedit= ob; // XXX for context
make_editNurb(ob);
@@ -499,7 +509,7 @@ void ED_object_enter_editmode(bContext *C, int flag)
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_CURVE, scene);
}
- if(ok) {
+ if (ok) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
else {
@@ -508,15 +518,15 @@ void ED_object_enter_editmode(bContext *C, int flag)
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene);
}
- if(flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode");
- if(flag & EM_WAITCURSOR) waitcursor(0);
+ if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode");
+ if (flag & EM_WAITCURSOR) waitcursor(0);
}
static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ToolSettings *toolsettings = CTX_data_tool_settings(C);
- if(!CTX_data_edit_object(C))
+ if (!CTX_data_edit_object(C))
ED_object_enter_editmode(C, EM_WAITCURSOR);
else
ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */
@@ -531,7 +541,7 @@ static int editmode_toggle_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
/* covers proxies too */
- if(ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib)
+ if (ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib)
return 0;
if (ob->restrictflag & OB_RESTRICT_VIEW)
@@ -547,17 +557,17 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Toggle Editmode";
+ ot->name = "Toggle Editmode";
ot->description = "Toggle object's editmode";
- ot->idname= "OBJECT_OT_editmode_toggle";
+ ot->idname = "OBJECT_OT_editmode_toggle";
/* api callbacks */
- ot->exec= editmode_toggle_exec;
+ ot->exec = editmode_toggle_exec;
- ot->poll= editmode_toggle_poll;
+ ot->poll = editmode_toggle_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* *************************** */
@@ -566,12 +576,12 @@ static int posemode_exec(bContext *C, wmOperator *UNUSED(op))
{
Base *base= CTX_data_active_base(C);
- if(base->object->type==OB_ARMATURE) {
- if(base->object==CTX_data_edit_object(C)) {
+ if (base->object->type==OB_ARMATURE) {
+ if (base->object==CTX_data_edit_object(C)) {
ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO);
ED_armature_enter_posemode(C, base);
}
- else if(base->object->mode & OB_MODE_POSE)
+ else if (base->object->mode & OB_MODE_POSE)
ED_armature_exit_posemode(C, base);
else
ED_armature_enter_posemode(C, base);
@@ -585,16 +595,16 @@ static int posemode_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_posemode_toggle(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Toggle Pose Mode";
- ot->idname= "OBJECT_OT_posemode_toggle";
- ot->description= "Enable or disable posing/selecting bones";
+ ot->name = "Toggle Pose Mode";
+ ot->idname = "OBJECT_OT_posemode_toggle";
+ ot->description = "Enable or disable posing/selecting bones";
/* api callbacks */
- ot->exec= posemode_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = posemode_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flag */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
@@ -606,7 +616,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
char *str;
prop= ob->prop.first;
- while(prop) {
+ while (prop) {
tot++;
prop= prop->next;
}
@@ -620,7 +630,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
tot= 0;
prop= ob->prop.first;
- while(prop) {
+ while (prop) {
tot++;
strcat(str, "|");
strcat(str, prop->name);
@@ -630,23 +640,25 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
nr= pupmenu(str);
if ( nr==1 || nr==2 ) {
- for(base= FIRSTBASE; base; base= base->next) {
- if((base != BASACT) &&(TESTBASELIB(v3d, base))) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if ((base != BASACT) &&(TESTBASELIB(v3d, base))) {
if (nr==1) { /* replace */
copy_properties( &base->object->prop, &ob->prop );
- } else {
- for(prop = ob->prop.first; prop; prop= prop->next ) {
+ }
+ else {
+ for (prop = ob->prop.first; prop; prop= prop->next ) {
set_ob_property(base->object, prop);
}
}
}
}
- } else if(nr>0) {
+ }
+ else if (nr>0) {
prop = BLI_findlink(&ob->prop, nr-4); /* account for first 3 menu items & menu index starting at 1*/
- if(prop) {
- for(base= FIRSTBASE; base; base= base->next) {
- if((base != BASACT) &&(TESTBASELIB(v3d, base))) {
+ if (prop) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if ((base != BASACT) &&(TESTBASELIB(v3d, base))) {
set_ob_property(base->object, prop);
}
}
@@ -661,9 +673,9 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob)
//XXX no longer used - to be removed - replaced by logicbricks_copy_exec
Base *base;
- for(base= FIRSTBASE; base; base= base->next) {
- if(base->object != ob) {
- if(TESTBASELIB(v3d, base)) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (base->object != ob) {
+ if (TESTBASELIB(v3d, base)) {
/* first: free all logic */
free_sensors(&base->object->sensors);
@@ -697,7 +709,7 @@ static void copy_texture_space(Object *to, Object *ob)
float *poin1= NULL, *poin2= NULL;
short texflag= 0;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
texflag= ((Mesh *)ob->data)->texflag;
poin2= ((Mesh *)ob->data)->loc;
}
@@ -705,14 +717,14 @@ static void copy_texture_space(Object *to, Object *ob)
texflag= ((Curve *)ob->data)->texflag;
poin2= ((Curve *)ob->data)->loc;
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
texflag= ((MetaBall *)ob->data)->texflag;
poin2= ((MetaBall *)ob->data)->loc;
}
else
return;
- if(to->type==OB_MESH) {
+ if (to->type==OB_MESH) {
((Mesh *)to->data)->texflag= texflag;
poin1= ((Mesh *)to->data)->loc;
}
@@ -720,7 +732,7 @@ static void copy_texture_space(Object *to, Object *ob)
((Curve *)to->data)->texflag= texflag;
poin1= ((Curve *)to->data)->loc;
}
- else if(to->type==OB_MBALL) {
+ else if (to->type==OB_MBALL) {
((MetaBall *)to->data)->texflag= texflag;
poin1= ((MetaBall *)to->data)->loc;
}
@@ -729,7 +741,7 @@ static void copy_texture_space(Object *to, Object *ob)
memcpy(poin1, poin2, 9*sizeof(float)); /* this was noted in DNA_mesh, curve, mball */
- if(to->type==OB_MESH) {
+ if (to->type==OB_MESH) {
/* pass */
}
else if (to->type == OB_MBALL) {
@@ -741,7 +753,7 @@ static void copy_texture_space(Object *to, Object *ob)
}
-/* UNUSED, keep incase we want to copy functionality for use elsewhere */
+/* UNUSED, keep in case we want to copy functionality for use elsewhere */
static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
{
Object *ob;
@@ -750,58 +762,58 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
Nurb *nu;
int do_scene_sort= 0;
- if(scene->id.lib) return;
+ if (scene->id.lib) return;
- if(!(ob=OBACT)) return;
+ if (!(ob=OBACT)) return;
- if(scene->obedit) { // XXX get from context
+ if (scene->obedit) { // XXX get from context
/* obedit_copymenu(); */
return;
}
- if(event==9) {
+ if (event==9) {
copymenu_properties(scene, v3d, ob);
return;
}
- else if(event==10) {
+ else if (event==10) {
copymenu_logicbricks(scene, v3d, ob);
return;
}
- else if(event==24) {
+ else if (event==24) {
/* moved to object_link_modifiers */
/* copymenu_modifiers(bmain, scene, v3d, ob); */
return;
}
- for(base= FIRSTBASE; base; base= base->next) {
- if(base != BASACT) {
- if(TESTBASELIB(v3d, base)) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (base != BASACT) {
+ if (TESTBASELIB(v3d, base)) {
base->object->recalc |= OB_RECALC_OB;
- if(event==1) { /* loc */
+ if (event==1) { /* loc */
copy_v3_v3(base->object->loc, ob->loc);
copy_v3_v3(base->object->dloc, ob->dloc);
}
- else if(event==2) { /* rot */
+ else if (event==2) { /* rot */
copy_v3_v3(base->object->rot, ob->rot);
copy_v3_v3(base->object->drot, ob->drot);
copy_qt_qt(base->object->quat, ob->quat);
copy_qt_qt(base->object->dquat, ob->dquat);
}
- else if(event==3) { /* size */
+ else if (event==3) { /* size */
copy_v3_v3(base->object->size, ob->size);
copy_v3_v3(base->object->dscale, ob->dscale);
}
- else if(event==4) { /* drawtype */
+ else if (event==4) { /* drawtype */
base->object->dt= ob->dt;
base->object->dtx= ob->dtx;
base->object->empty_drawtype= ob->empty_drawtype;
base->object->empty_drawsize= ob->empty_drawsize;
}
- else if(event==5) { /* time offs */
+ else if (event==5) { /* time offs */
base->object->sf= ob->sf;
}
- else if(event==6) { /* dupli */
+ else if (event==6) { /* dupli */
base->object->dupon= ob->dupon;
base->object->dupoff= ob->dupoff;
base->object->dupsta= ob->dupsta;
@@ -811,17 +823,17 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
base->object->transflag |= (ob->transflag & OB_DUPLI);
base->object->dup_group= ob->dup_group;
- if(ob->dup_group)
+ if (ob->dup_group)
id_lib_extern(&ob->dup_group->id);
}
- else if(event==7) { /* mass */
+ else if (event==7) { /* mass */
base->object->mass= ob->mass;
}
- else if(event==8) { /* damping */
+ else if (event==8) { /* damping */
base->object->damping= ob->damping;
base->object->rdamping= ob->rdamping;
}
- else if(event==11) { /* all physical attributes */
+ else if (event==11) { /* all physical attributes */
base->object->gameflag = ob->gameflag;
base->object->inertia = ob->inertia;
base->object->formfactor = ob->formfactor;
@@ -836,12 +848,12 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
base->object->bsoft= copy_bulletsoftbody(ob->bsoft);
}
- else if(event==17) { /* tex space */
+ else if (event==17) { /* tex space */
copy_texture_space(base->object, ob);
}
- else if(event==18) { /* font settings */
+ else if (event==18) { /* font settings */
- if(base->object->type==ob->type) {
+ if (base->object->type==ob->type) {
cu= ob->data;
cu1= base->object->data;
@@ -856,16 +868,16 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
cu1->wordspace= cu->wordspace;
cu1->ulpos= cu->ulpos;
cu1->ulheight= cu->ulheight;
- if(cu1->vfont) cu1->vfont->id.us--;
+ if (cu1->vfont) cu1->vfont->id.us--;
cu1->vfont= cu->vfont;
id_us_plus((ID *)cu1->vfont);
- if(cu1->vfontb) cu1->vfontb->id.us--;
+ if (cu1->vfontb) cu1->vfontb->id.us--;
cu1->vfontb= cu->vfontb;
id_us_plus((ID *)cu1->vfontb);
- if(cu1->vfonti) cu1->vfonti->id.us--;
+ if (cu1->vfonti) cu1->vfonti->id.us--;
cu1->vfonti= cu->vfonti;
id_us_plus((ID *)cu1->vfonti);
- if(cu1->vfontbi) cu1->vfontbi->id.us--;
+ if (cu1->vfontbi) cu1->vfontbi->id.us--;
cu1->vfontbi= cu->vfontbi;
id_us_plus((ID *)cu1->vfontbi);
@@ -877,9 +889,9 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
base->object->recalc |= OB_RECALC_DATA;
}
}
- else if(event==19) { /* bevel settings */
+ else if (event==19) { /* bevel settings */
- if(ELEM(base->object->type, OB_CURVE, OB_FONT)) {
+ if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
cu= ob->data;
cu1= base->object->data;
@@ -893,9 +905,9 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
base->object->recalc |= OB_RECALC_DATA;
}
}
- else if(event==25) { /* curve resolution */
+ else if (event==25) { /* curve resolution */
- if(ELEM(base->object->type, OB_CURVE, OB_FONT)) {
+ if (ELEM(base->object->type, OB_CURVE, OB_FONT)) {
cu= ob->data;
cu1= base->object->data;
@@ -904,7 +916,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
nu= cu1->nurb.first;
- while(nu) {
+ while (nu) {
nu->resolu= cu1->resolu;
nu= nu->next;
}
@@ -912,7 +924,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
base->object->recalc |= OB_RECALC_DATA;
}
}
- else if(event==21) {
+ else if (event==21) {
if (base->object->type==OB_MESH) {
ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf);
@@ -929,15 +941,15 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
}
}
}
- else if(event==22) {
+ else if (event==22) {
/* Copy the constraint channels over */
copy_constraints(&base->object->constraints, &ob->constraints, TRUE);
do_scene_sort= 1;
}
- else if(event==23) {
+ else if (event==23) {
base->object->softflag= ob->softflag;
- if(base->object->soft) sbFree(base->object->soft);
+ if (base->object->soft) sbFree(base->object->soft);
base->object->soft= copy_softbody(ob->soft);
@@ -945,47 +957,47 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody));
}
}
- else if(event==26) {
+ else if (event==26) {
#if 0 // XXX old animation system
copy_nlastrips(&base->object->nlastrips, &ob->nlastrips);
#endif // XXX old animation system
}
- else if(event==27) { /* autosmooth */
+ else if (event==27) { /* autosmooth */
if (base->object->type==OB_MESH) {
Mesh *me= ob->data;
Mesh *cme= base->object->data;
cme->smoothresh= me->smoothresh;
- if(me->flag & ME_AUTOSMOOTH)
+ if (me->flag & ME_AUTOSMOOTH)
cme->flag |= ME_AUTOSMOOTH;
else
cme->flag &= ~ME_AUTOSMOOTH;
}
}
- else if(event==28) { /* UV orco */
- if(ELEM(base->object->type, OB_CURVE, OB_SURF)) {
+ else if (event==28) { /* UV orco */
+ if (ELEM(base->object->type, OB_CURVE, OB_SURF)) {
cu= ob->data;
cu1= base->object->data;
- if(cu->flag & CU_UV_ORCO)
+ if (cu->flag & CU_UV_ORCO)
cu1->flag |= CU_UV_ORCO;
else
cu1->flag &= ~CU_UV_ORCO;
}
}
- else if(event==29) { /* protected bits */
+ else if (event==29) { /* protected bits */
base->object->protectflag= ob->protectflag;
}
- else if(event==30) { /* index object */
+ else if (event==30) { /* index object */
base->object->index= ob->index;
}
- else if(event==31) { /* object color */
+ else if (event==31) { /* object color */
copy_v4_v4(base->object->col, ob->col);
}
}
}
}
- if(do_scene_sort)
+ if (do_scene_sort)
DAG_scene_sort(bmain, scene);
DAG_ids_flush_update(bmain, 0);
@@ -997,7 +1009,7 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v
short event;
char str[512];
- if(!(ob=OBACT)) return;
+ if (!(ob=OBACT)) return;
if (scene->obedit) { // XXX get from context
// if (ob->type == OB_MESH)
@@ -1023,27 +1035,27 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v
// strcat(str, "|Texture Space%x17");
// }
- if(ob->type == OB_FONT) strcat(str, "|Font Settings%x18|Bevel Settings%x19");
- if(ob->type == OB_CURVE) strcat(str, "|Bevel Settings%x19|UV Orco%x28");
+ if (ob->type == OB_FONT) strcat(str, "|Font Settings%x18|Bevel Settings%x19");
+ if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings%x19|UV Orco%x28");
- if((ob->type == OB_FONT) || (ob->type == OB_CURVE)) {
+ if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) {
strcat(str, "|Curve Resolution%x25");
}
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
strcat(str, "|Subsurf Settings%x21|AutoSmooth%x27");
}
- if(ob->soft) strcat(str, "|Soft Body Settings%x23");
+ if (ob->soft) strcat(str, "|Soft Body Settings%x23");
strcat(str, "|Pass Index%x30");
- if(ob->type==OB_MESH || ob->type==OB_CURVE || ob->type==OB_LATTICE || ob->type==OB_SURF) {
+ if (ob->type==OB_MESH || ob->type==OB_CURVE || ob->type==OB_LATTICE || ob->type==OB_SURF) {
strcat(str, "|Modifiers ...%x24");
}
event= pupmenu(str);
- if(event<= 0) return;
+ if (event<= 0) return;
copy_attr(bmain, scene, v3d, event);
}
@@ -1054,10 +1066,10 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
- if(ob->pd == NULL)
+ if (ob->pd == NULL)
ob->pd = object_add_collision_fields(PFIELD_FORCE);
- if(ob->pd->forcefield == 0)
+ if (ob->pd->forcefield == 0)
ob->pd->forcefield = PFIELD_FORCE;
else
ob->pd->forcefield = 0;
@@ -1071,16 +1083,16 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Toggle Force Field";
+ ot->name = "Toggle Force Field";
ot->description = "Toggle object's force field";
- ot->idname= "OBJECT_OT_forcefield_toggle";
+ ot->idname = "OBJECT_OT_forcefield_toggle";
/* api callbacks */
- ot->exec= forcefield_toggle_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = forcefield_toggle_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ********************************************** */
@@ -1137,16 +1149,16 @@ static int object_calculate_paths_exec (bContext *C, wmOperator *op)
void OBJECT_OT_paths_calculate (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Calculate Object Paths";
- ot->idname= "OBJECT_OT_paths_calculate";
- ot->description= "Calculate paths for the selected bones";
+ ot->name = "Calculate Object Paths";
+ ot->idname = "OBJECT_OT_paths_calculate";
+ ot->description = "Calculate paths for the selected bones";
/* api callbacks */
- ot->exec= object_calculate_paths_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = object_calculate_paths_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* --------- */
@@ -1181,13 +1193,13 @@ static int object_clear_paths_exec (bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_paths_clear (wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Object Paths";
- ot->idname= "OBJECT_OT_paths_clear";
- ot->description= "Clear path caches for selected bones";
+ ot->name = "Clear Object Paths";
+ ot->idname = "OBJECT_OT_paths_clear";
+ ot->description = "Clear path caches for selected bones";
/* api callbacks */
- ot->exec= object_clear_paths_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = object_clear_paths_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1205,7 +1217,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
mesh_set_smooth_flag(ob, !clear);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1213,11 +1225,11 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
done= 1;
}
- else if ELEM(ob->type, OB_SURF, OB_CURVE) {
+ else if (ELEM(ob->type, OB_SURF, OB_CURVE)) {
cu= ob->data;
- for(nu=cu->nurb.first; nu; nu=nu->next) {
- if(!clear) nu->flag |= ME_SMOOTH;
+ for (nu=cu->nurb.first; nu; nu=nu->next) {
+ if (!clear) nu->flag |= ME_SMOOTH;
else nu->flag &= ~ME_SMOOTH;
}
@@ -1240,31 +1252,31 @@ static int shade_poll(bContext *C)
void OBJECT_OT_shade_flat(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Shade Flat";
- ot->description= "Display faces 'flat'";
- ot->idname= "OBJECT_OT_shade_flat";
+ ot->name = "Shade Flat";
+ ot->description = "Display faces 'flat'";
+ ot->idname = "OBJECT_OT_shade_flat";
/* api callbacks */
- ot->poll= shade_poll;
- ot->exec= shade_smooth_exec;
+ ot->poll = shade_poll;
+ ot->exec = shade_smooth_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
void OBJECT_OT_shade_smooth(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Shade Smooth";
- ot->description= "Display faces 'smooth' (using vertex normals)";
- ot->idname= "OBJECT_OT_shade_smooth";
+ ot->name = "Shade Smooth";
+ ot->description = "Display faces 'smooth' (using vertex normals)";
+ ot->idname = "OBJECT_OT_shade_smooth";
/* api callbacks */
- ot->poll= shade_poll;
- ot->exec= shade_smooth_exec;
+ ot->poll = shade_poll;
+ ot->exec = shade_smooth_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ********************** */
@@ -1279,31 +1291,31 @@ static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d)
float x, y, space;
int a, b, done;
- if(scene->obedit) return; // XXX get from context
- if(scene->id.lib) return;
+ if (scene->obedit) return; // XXX get from context
+ if (scene->id.lib) return;
- for(base= FIRSTBASE; base; base= base->next) {
- if(TESTBASELIB(v3d, base)) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (TESTBASELIB(v3d, base)) {
ob= base->object;
done= 0;
- for(a=1; a<=ob->totcol; a++) {
+ for (a=1; a<=ob->totcol; a++) {
ma= give_current_material(ob, a);
- if(ma) {
- for(b=0; b<MAX_MTEX; b++) {
- if(ma->mtex[b] && ma->mtex[b]->tex) {
+ if (ma) {
+ for (b=0; b<MAX_MTEX; b++) {
+ if (ma->mtex[b] && ma->mtex[b]->tex) {
tex= ma->mtex[b]->tex;
- if(tex->type==TEX_IMAGE && tex->ima) {
+ if (tex->type==TEX_IMAGE && tex->ima) {
ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, NULL);
/* texturespace */
space= 1.0;
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
float size[3];
mesh_get_texspace(ob->data, NULL, NULL, size);
space= size[0]/size[1];
}
- else if(ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
+ else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) {
Curve *cu= ob->data;
space= cu->size[0]/cu->size[1];
}
@@ -1311,17 +1323,17 @@ static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d)
x= ibuf->x/space;
y= ibuf->y;
- if(x>y) ob->size[0]= ob->size[1]*x/y;
+ if (x>y) ob->size[0]= ob->size[1]*x/y;
else ob->size[1]= ob->size[0]*y/x;
done= 1;
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
}
- if(done) break;
+ if (done) break;
}
}
- if(done) break;
+ if (done) break;
}
}
}
@@ -1336,12 +1348,12 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(
Object *ob;
int totitem= 0;
- if(!C) /* needed for docs */
+ if (!C) /* needed for docs */
return object_mode_items;
ob = CTX_data_active_object(C);
- while(ob && input->identifier) {
- if((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) ||
+ while (ob && input->identifier) {
+ if ((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) ||
(ob->type == OB_CURVE) || (ob->type == OB_SURF) ||
(ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) ||
(input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) ||
@@ -1362,19 +1374,19 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(
static const char *object_mode_op_string(int mode)
{
- if(mode & OB_MODE_EDIT)
+ if (mode & OB_MODE_EDIT)
return "OBJECT_OT_editmode_toggle";
- if(mode == OB_MODE_SCULPT)
+ if (mode == OB_MODE_SCULPT)
return "SCULPT_OT_sculptmode_toggle";
- if(mode == OB_MODE_VERTEX_PAINT)
+ if (mode == OB_MODE_VERTEX_PAINT)
return "PAINT_OT_vertex_paint_toggle";
- if(mode == OB_MODE_WEIGHT_PAINT)
+ if (mode == OB_MODE_WEIGHT_PAINT)
return "PAINT_OT_weight_paint_toggle";
- if(mode == OB_MODE_TEXTURE_PAINT)
+ if (mode == OB_MODE_TEXTURE_PAINT)
return "PAINT_OT_texture_paint_toggle";
- if(mode == OB_MODE_PARTICLE_EDIT)
+ if (mode == OB_MODE_PARTICLE_EDIT)
return "PARTICLE_OT_particle_edit_toggle";
- if(mode == OB_MODE_POSE)
+ if (mode == OB_MODE_POSE)
return "OBJECT_OT_posemode_toggle";
return NULL;
}
@@ -1385,27 +1397,27 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o
{
ObjectMode mode = RNA_enum_get(op->ptr, "mode");
- if(ob) {
- if(mode == OB_MODE_OBJECT)
+ if (ob) {
+ if (mode == OB_MODE_OBJECT)
return 1;
switch(ob->type) {
case OB_MESH:
- if(mode & (OB_MODE_EDIT|OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))
+ if (mode & (OB_MODE_EDIT|OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))
return 1;
return 0;
case OB_CURVE:
case OB_SURF:
case OB_FONT:
case OB_MBALL:
- if(mode & (OB_MODE_EDIT))
+ if (mode & (OB_MODE_EDIT))
return 1;
return 0;
case OB_LATTICE:
- if(mode & (OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT))
+ if (mode & (OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT))
return 1;
case OB_ARMATURE:
- if(mode & (OB_MODE_EDIT|OB_MODE_POSE))
+ if (mode & (OB_MODE_EDIT|OB_MODE_POSE))
return 1;
}
}
@@ -1420,23 +1432,23 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
ObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT;
int toggle = RNA_boolean_get(op->ptr, "toggle");
- if(!ob || !object_mode_set_compat(C, op, ob))
+ if (!ob || !object_mode_set_compat(C, op, ob))
return OPERATOR_PASS_THROUGH;
/* Exit current mode if it's not the mode we're setting */
- if(ob->mode != OB_MODE_OBJECT && ob->mode != mode)
+ if (ob->mode != OB_MODE_OBJECT && ob->mode != mode)
WM_operator_name_call(C, object_mode_op_string(ob->mode), WM_OP_EXEC_REGION_WIN, NULL);
- if(mode != OB_MODE_OBJECT) {
+ if (mode != OB_MODE_OBJECT) {
/* Enter new mode */
- if(ob->mode != mode || toggle)
+ if (ob->mode != mode || toggle)
WM_operator_name_call(C, object_mode_op_string(mode), WM_OP_EXEC_REGION_WIN, NULL);
- if(toggle) {
- if(ob->mode == mode)
+ if (toggle) {
+ if (ob->mode == mode)
/* For toggling, store old mode so we know what to go back to */
ob->restore_mode = restore_mode;
- else if(ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) {
+ else if (ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) {
WM_operator_name_call(C, object_mode_op_string(ob->restore_mode), WM_OP_EXEC_REGION_WIN, NULL);
}
}
@@ -1450,17 +1462,17 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Set Object Mode";
+ ot->name = "Set Object Mode";
ot->description = "Sets the object interaction mode";
- ot->idname= "OBJECT_OT_mode_set";
+ ot->idname = "OBJECT_OT_mode_set";
/* api callbacks */
- ot->exec= object_mode_set_exec;
+ ot->exec = object_mode_set_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= 0; /* no register/undo here, leave it to operators being called */
+ ot->flag = 0; /* no register/undo here, leave it to operators being called */
prop= RNA_def_enum(ot->srna, "mode", object_mode_items, OB_MODE_OBJECT, "Mode", "");
RNA_def_enum_funcs(prop, object_mode_set_itemsf);
@@ -1472,19 +1484,19 @@ void OBJECT_OT_mode_set(wmOperatorType *ot)
void ED_object_toggle_modes(bContext *C, int mode)
{
- if(mode & OB_MODE_SCULPT)
+ if (mode & OB_MODE_SCULPT)
WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if(mode & OB_MODE_VERTEX_PAINT)
+ if (mode & OB_MODE_VERTEX_PAINT)
WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if(mode & OB_MODE_WEIGHT_PAINT)
+ if (mode & OB_MODE_WEIGHT_PAINT)
WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if(mode & OB_MODE_TEXTURE_PAINT)
+ if (mode & OB_MODE_TEXTURE_PAINT)
WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if(mode & OB_MODE_PARTICLE_EDIT)
+ if (mode & OB_MODE_PARTICLE_EDIT)
WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if(mode & OB_MODE_POSE)
+ if (mode & OB_MODE_POSE)
WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
- if(mode & OB_MODE_EDIT)
+ if (mode & OB_MODE_EDIT)
WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL);
}
@@ -1515,16 +1527,16 @@ static int game_property_new(bContext *C, wmOperator *op)
void OBJECT_OT_game_property_new(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "New Game Property";
- ot->description= "Create a new property available to the game engine";
- ot->idname= "OBJECT_OT_game_property_new";
+ ot->name = "New Game Property";
+ ot->description = "Create a new property available to the game engine";
+ ot->idname = "OBJECT_OT_game_property_new";
/* api callbacks */
- ot->exec= game_property_new;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = game_property_new;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", gameproperty_type_items, GPROP_FLOAT, "Type", "Type of game property to add");
RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the game property to add");
@@ -1536,12 +1548,12 @@ static int game_property_remove(bContext *C, wmOperator *op)
bProperty *prop;
int index= RNA_int_get(op->ptr, "index");
- if(!ob)
+ if (!ob)
return OPERATOR_CANCELLED;
prop= BLI_findlink(&ob->prop, index);
- if(prop) {
+ if (prop) {
BLI_remlink(&ob->prop, prop);
free_property(prop);
@@ -1556,16 +1568,16 @@ static int game_property_remove(bContext *C, wmOperator *op)
void OBJECT_OT_game_property_remove(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove Game Property";
- ot->description= "Remove game property";
- ot->idname= "OBJECT_OT_game_property_remove";
+ ot->name = "Remove Game Property";
+ ot->description = "Remove game property";
+ ot->idname = "OBJECT_OT_game_property_remove";
/* api callbacks */
- ot->exec= game_property_remove;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = game_property_remove;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to remove ", 0, INT_MAX);
}
@@ -1591,10 +1603,10 @@ static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), P
bProperty *prop;
int a, totitem= 0;
- if(!ob)
+ if (!ob)
return gameprops_items;
- for(a=1, prop= ob->prop.first; prop; prop=prop->next, a++) {
+ for (a=1, prop= ob->prop.first; prop; prop=prop->next, a++) {
tmp.value= a;
tmp.identifier= prop->name;
tmp.name= prop->name;
@@ -1614,10 +1626,10 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
int type = RNA_enum_get(op->ptr, "operation");
int propid= RNA_enum_get(op->ptr, "property");
- if(propid > 0) { /* copy */
+ if (propid > 0) { /* copy */
prop = BLI_findlink(&ob->prop, propid-1);
- if(prop) {
+ if (prop) {
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
if (ob != ob_iter)
set_ob_property(ob_iter, prop);
@@ -1633,7 +1645,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
/* merge - the default when calling with no argument */
else
- for(prop = ob->prop.first; prop; prop= prop->next)
+ for (prop = ob->prop.first; prop; prop= prop->next)
set_ob_property(ob_iter, prop);
}
}
@@ -1647,20 +1659,20 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot)
{
PropertyRNA *prop;
/* identifiers */
- ot->name= "Copy Game Property";
- ot->idname= "OBJECT_OT_game_property_copy";
+ ot->name = "Copy Game Property";
+ ot->idname = "OBJECT_OT_game_property_copy";
/* api callbacks */
- ot->exec= game_property_copy_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = game_property_copy_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", "");
prop=RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy");
RNA_def_enum_funcs(prop, gameprops_itemf);
- ot->prop=prop;
+ ot->prop = prop;
}
static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1676,15 +1688,15 @@ static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_game_property_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Game Property";
- ot->idname= "OBJECT_OT_game_property_clear";
+ ot->name = "Clear Game Property";
+ ot->idname = "OBJECT_OT_game_property_clear";
/* api callbacks */
- ot->exec= game_property_clear_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = game_property_clear_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/************************ Copy Logic Bricks ***********************/
@@ -1694,7 +1706,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob=ED_object_active_context(C);
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
- if(ob != ob_iter) {
+ if (ob != ob_iter) {
/* first: free all logic */
free_sensors(&ob_iter->sensors);
unlink_controllers(&ob_iter->controllers);
@@ -1717,7 +1729,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
ob_iter->state= ob->state;
ob_iter->init_state= ob->init_state;
- if(ob_iter->totcol==ob->totcol) {
+ if (ob_iter->totcol==ob->totcol) {
ob_iter->actcol= ob->actcol;
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter);
}
@@ -1733,16 +1745,16 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Logic Bricks to Selected";
+ ot->name = "Copy Logic Bricks to Selected";
ot->description = "Copy logic bricks to other selected objects";
- ot->idname= "OBJECT_OT_logic_bricks_copy";
+ ot->idname = "OBJECT_OT_logic_bricks_copy";
/* api callbacks */
- ot->exec= logicbricks_copy_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = logicbricks_copy_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1750,7 +1762,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob=ED_object_active_context(C);
CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
- if(ob != ob_iter) {
+ if (ob != ob_iter) {
ob_iter->gameflag = ob->gameflag;
ob_iter->gameflag2 = ob->gameflag2;
ob_iter->inertia = ob->inertia;
@@ -1767,7 +1779,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
ob_iter->collision_boundtype = ob->collision_boundtype;
ob_iter->margin = ob->margin;
ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft);
- if(ob->restrictflag & OB_RESTRICT_RENDER)
+ if (ob->restrictflag & OB_RESTRICT_RENDER)
ob_iter->restrictflag |= OB_RESTRICT_RENDER;
else
ob_iter->restrictflag &= ~OB_RESTRICT_RENDER;
@@ -1781,14 +1793,14 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Game Physics Properties to Selected";
+ ot->name = "Copy Game Physics Properties to Selected";
ot->description = "Copy game physics properties to other selected objects";
- ot->idname= "OBJECT_OT_game_physics_copy";
+ ot->idname = "OBJECT_OT_game_physics_copy";
/* api callbacks */
- ot->exec= game_physics_copy_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->exec = game_physics_copy_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c
index 1b8c0fd0840..34410b87e79 100644
--- a/source/blender/editors/object/object_group.c
+++ b/source/blender/editors/object/object_group.c
@@ -67,13 +67,13 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
Group *group;
int ok = 0;
- if(!ob) return OPERATOR_CANCELLED;
+ if (!ob) return OPERATOR_CANCELLED;
/* linking to same group requires its own loop so we can avoid
- looking up the active objects groups each time */
+ * looking up the active objects groups each time */
- for(group= bmain->group.first; group; group=group->id.next) {
- if(object_in_group(ob, group)) {
+ for (group= bmain->group.first; group; group=group->id.next) {
+ if (object_in_group(ob, group)) {
/* Assign groups to selected objects */
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
add_to_group(group, base->object, scene, base);
@@ -83,7 +83,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
}
}
- if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
+ if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
DAG_scene_sort(bmain, scene);
WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
@@ -94,16 +94,16 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
void GROUP_OT_objects_add_active(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Selected To Active Group";
+ ot->name = "Add Selected To Active Group";
ot->description = "Add the object to an object group that contains the active object";
- ot->idname= "GROUP_OT_objects_add_active";
+ ot->idname = "GROUP_OT_objects_add_active";
/* api callbacks */
- ot->exec= objects_add_active_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = objects_add_active_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int objects_remove_active_exec(bContext *C, wmOperator *op)
@@ -114,13 +114,13 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
Group *group;
int ok = 0;
- if(!ob) return OPERATOR_CANCELLED;
+ if (!ob) return OPERATOR_CANCELLED;
/* linking to same group requires its own loop so we can avoid
- looking up the active objects groups each time */
+ * looking up the active objects groups each time */
- for(group= bmain->group.first; group; group=group->id.next) {
- if(object_in_group(ob, group)) {
+ for (group= bmain->group.first; group; group=group->id.next) {
+ if (object_in_group(ob, group)) {
/* Assign groups to selected objects */
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
rem_from_group(group, base->object, scene, base);
@@ -130,7 +130,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
}
}
- if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
+ if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
DAG_scene_sort(bmain, scene);
WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
@@ -141,16 +141,16 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
void GROUP_OT_objects_remove_active(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove Selected From Active Group";
+ ot->name = "Remove Selected From Active Group";
ot->description = "Remove the object from an object group that contains the active object";
- ot->idname= "GROUP_OT_objects_remove_active";
+ ot->idname = "GROUP_OT_objects_remove_active";
/* api callbacks */
- ot->exec= objects_remove_active_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = objects_remove_active_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op))
@@ -161,7 +161,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
group = NULL;
- while((group = find_group(base->object, group)))
+ while ((group = find_group(base->object, group)))
rem_from_group(group, base->object, scene, base);
}
CTX_DATA_END;
@@ -175,16 +175,16 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op))
void GROUP_OT_objects_remove(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove From Groups";
+ ot->name = "Remove From Groups";
ot->description = "Remove selected objects from all groups";
- ot->idname= "GROUP_OT_objects_remove";
+ ot->idname = "GROUP_OT_objects_remove";
/* api callbacks */
- ot->exec= group_objects_remove_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = group_objects_remove_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int group_create_exec(bContext *C, wmOperator *op)
@@ -212,16 +212,16 @@ static int group_create_exec(bContext *C, wmOperator *op)
void GROUP_OT_create(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Create New Group";
+ ot->name = "Create New Group";
ot->description = "Create an object group from selected objects";
- ot->idname= "GROUP_OT_create";
+ ot->idname = "GROUP_OT_create";
/* api callbacks */
- ot->exec= group_create_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = group_create_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME-2, "Name", "Name of the new group");
}
@@ -234,7 +234,7 @@ static int group_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Group *group;
- if(ob == NULL)
+ if (ob == NULL)
return OPERATOR_CANCELLED;
group= add_group("Group");
@@ -248,15 +248,15 @@ static int group_add_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_group_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add to Group";
- ot->idname= "OBJECT_OT_group_add";
+ ot->name = "Add to Group";
+ ot->idname = "OBJECT_OT_group_add";
ot->description = "Add an object to a new group";
/* api callbacks */
- ot->exec= group_add_exec;
+ ot->exec = group_add_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int group_link_exec(bContext *C, wmOperator *op)
@@ -265,7 +265,7 @@ static int group_link_exec(bContext *C, wmOperator *op)
Object *ob= ED_object_context(C);
Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group"));
- if(ELEM(NULL, ob, group))
+ if (ELEM(NULL, ob, group))
return OPERATOR_CANCELLED;
add_to_group(group, ob, scene, NULL);
@@ -280,21 +280,21 @@ void OBJECT_OT_group_link(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Link to Group";
- ot->idname= "OBJECT_OT_group_link";
+ ot->name = "Link to Group";
+ ot->idname = "OBJECT_OT_group_link";
ot->description = "Add an object to an existing group";
/* api callbacks */
- ot->exec= group_link_exec;
- ot->invoke= WM_enum_search_invoke;
+ ot->exec = group_link_exec;
+ ot->invoke = WM_enum_search_invoke;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", "");
RNA_def_enum_funcs(prop, RNA_group_local_itemf);
- ot->prop= prop;
+ ot->prop = prop;
}
static int group_remove_exec(bContext *C, wmOperator *UNUSED(op))
@@ -303,7 +303,7 @@ static int group_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= ED_object_context(C);
Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
- if(!ob || !group)
+ if (!ob || !group)
return OPERATOR_CANCELLED;
rem_from_group(group, ob, scene, NULL); /* base will be used if found */
@@ -316,13 +316,13 @@ static int group_remove_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_group_remove(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove Group";
- ot->idname= "OBJECT_OT_group_remove";
+ ot->name = "Remove Group";
+ ot->idname = "OBJECT_OT_group_remove";
/* api callbacks */
- ot->exec= group_remove_exec;
+ ot->exec = group_remove_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 8b5a9ae6c9b..4e967b6791b 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -79,9 +79,9 @@ static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, floa
int *index, nr, totvert=0;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++;
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++;
}
- if(totvert==0) return 0;
+ if (totvert==0) return 0;
*indexar= index= MEM_mallocN(4*totvert, "hook indexar");
*tot= totvert;
@@ -89,7 +89,7 @@ static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, floa
zero_v3(cent);
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
*index= nr; index++;
add_v3_v3(cent, eve->co);
}
@@ -105,7 +105,7 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl
{
zero_v3(cent);
- if(obedit->actdef) {
+ if (obedit->actdef) {
const int defgrp_index= obedit->actdef-1;
int totvert=0;
@@ -117,14 +117,14 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- if(dvert) {
- if(defvert_find_weight(dvert, defgrp_index) > 0.0f) {
+ if (dvert) {
+ if (defvert_find_weight(dvert, defgrp_index) > 0.0f) {
add_v3_v3(cent, eve->co);
totvert++;
}
}
}
- if(totvert) {
+ if (totvert) {
bDeformGroup *dg = BLI_findlink(&obedit->defbase, defgrp_index);
BLI_strncpy(name, dg->name, sizeof(dg->name));
mul_v3_fl(cent, 1.0f/(float)totvert);
@@ -147,9 +147,9 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
return;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if(nr==hmd->indexar[index]) {
+ if (nr==hmd->indexar[index]) {
BM_elem_select_set(em->bm, eve, TRUE);
- if(index < hmd->totindex-1) index++;
+ if (index < hmd->totindex-1) index++;
}
nr++;
@@ -166,25 +166,25 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar
/* count */
a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw;
bp= editlatt->def;
- while(a--) {
- if(bp->f1 & SELECT) {
- if(bp->hide==0) totvert++;
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ if (bp->hide==0) totvert++;
}
bp++;
}
- if(totvert==0) return 0;
+ if (totvert==0) return 0;
*indexar= index= MEM_mallocN(4*totvert, "hook indexar");
*tot= totvert;
nr= 0;
- cent[0]= cent[1]= cent[2]= 0.0;
+ zero_v3(cent);
a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw;
bp= editlatt->def;
- while(a--) {
- if(bp->f1 & SELECT) {
- if(bp->hide==0) {
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ if (bp->hide==0) {
*index= nr; index++;
add_v3_v3(cent, bp->vec);
}
@@ -208,10 +208,10 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
/* count */
a= editlt->pntsu*editlt->pntsv*editlt->pntsw;
bp= editlt->def;
- while(a--) {
- if(hmd->indexar[index]==nr) {
+ while (a--) {
+ if (hmd->indexar[index]==nr) {
bp->f1 |= SELECT;
- if(index < hmd->totindex-1) index++;
+ if (index < hmd->totindex-1) index++;
}
nr++;
bp++;
@@ -226,49 +226,49 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo
BezTriple *bezt;
int *index, a, nr, totvert=0;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(bezt->f1 & SELECT) totvert++;
- if(bezt->f2 & SELECT) totvert++;
- if(bezt->f3 & SELECT) totvert++;
+ while (a--) {
+ if (bezt->f1 & SELECT) totvert++;
+ if (bezt->f2 & SELECT) totvert++;
+ if (bezt->f3 & SELECT) totvert++;
bezt++;
}
}
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(bp->f1 & SELECT) totvert++;
+ while (a--) {
+ if (bp->f1 & SELECT) totvert++;
bp++;
}
}
}
- if(totvert==0) return 0;
+ if (totvert==0) return 0;
*indexar= index= MEM_mallocN(4*totvert, "hook indexar");
*tot= totvert;
nr= 0;
- cent[0]= cent[1]= cent[2]= 0.0;
+ zero_v3(cent);
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(bezt->f1 & SELECT) {
+ while (a--) {
+ if (bezt->f1 & SELECT) {
*index= nr; index++;
add_v3_v3(cent, bezt->vec[0]);
}
nr++;
- if(bezt->f2 & SELECT) {
+ if (bezt->f2 & SELECT) {
*index= nr; index++;
add_v3_v3(cent, bezt->vec[1]);
}
nr++;
- if(bezt->f3 & SELECT) {
+ if (bezt->f3 & SELECT) {
*index= nr; index++;
add_v3_v3(cent, bezt->vec[2]);
}
@@ -279,8 +279,8 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(bp->f1 & SELECT) {
+ while (a--) {
+ if (bp->f1 & SELECT) {
*index= nr; index++;
add_v3_v3(cent, bp->vec);
}
@@ -308,15 +308,16 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int *
BMEditMesh *em;
- EDBM_LoadEditBMesh(scene, obedit);
- EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit);
+ EDBM_mesh_load(obedit);
+ EDBM_mesh_make(scene->toolsettings, scene, obedit);
em = me->edit_btmesh;
/* check selected vertices first */
- if( return_editmesh_indexar(em, tot, indexar, cent_r)) {
+ if ( return_editmesh_indexar(em, tot, indexar, cent_r)) {
return 1;
- } else {
+ }
+ else {
int ret = return_editmesh_vgroup(obedit, em, name, cent_r);
return ret;
}
@@ -342,24 +343,24 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
BezTriple *bezt;
int index=0, a, nr=0;
- for(nu= editnurb->first; nu; nu= nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu= editnurb->first; nu; nu= nu->next) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(nr == hmd->indexar[index]) {
+ while (a--) {
+ if (nr == hmd->indexar[index]) {
bezt->f1 |= SELECT;
- if(index<hmd->totindex-1) index++;
+ if (index<hmd->totindex-1) index++;
}
nr++;
- if(nr == hmd->indexar[index]) {
+ if (nr == hmd->indexar[index]) {
bezt->f2 |= SELECT;
- if(index<hmd->totindex-1) index++;
+ if (index<hmd->totindex-1) index++;
}
nr++;
- if(nr == hmd->indexar[index]) {
+ if (nr == hmd->indexar[index]) {
bezt->f3 |= SELECT;
- if(index<hmd->totindex-1) index++;
+ if (index<hmd->totindex-1) index++;
}
nr++;
@@ -369,10 +370,10 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(nr == hmd->indexar[index]) {
+ while (a--) {
+ if (nr == hmd->indexar[index]) {
bp->f1 |= SELECT;
- if(index<hmd->totindex-1) index++;
+ if (index<hmd->totindex-1) index++;
}
nr++;
bp++;
@@ -386,10 +387,10 @@ static void object_hook_select(Object *ob, HookModifierData *hmd)
if (hmd->indexar == NULL)
return;
- if(ob->type==OB_MESH) select_editbmesh_hook(ob, hmd);
- else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd);
- else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd);
- else if(ob->type==OB_SURF) select_editcurve_hook(ob, hmd);
+ if (ob->type==OB_MESH) select_editbmesh_hook(ob, hmd);
+ else if (ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd);
+ else if (ob->type==OB_CURVE) select_editcurve_hook(ob, hmd);
+ else if (ob->type==OB_SURF) select_editcurve_hook(ob, hmd);
}
/* special poll operators for hook operators */
@@ -505,16 +506,16 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
void OBJECT_OT_hook_add_selobj(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Hook to Selected Object";
- ot->description= "Hook selected vertices to the first selected Object";
- ot->idname= "OBJECT_OT_hook_add_selob";
+ ot->name = "Hook to Selected Object";
+ ot->description = "Hook selected vertices to the first selected Object";
+ ot->idname = "OBJECT_OT_hook_add_selob";
/* api callbacks */
- ot->exec= object_add_hook_selob_exec;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_add_hook_selob_exec;
+ ot->poll = hook_op_edit_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_add_hook_newob_exec(bContext *C, wmOperator *UNUSED(op))
@@ -533,16 +534,16 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_hook_add_newobj(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Hook to New Object";
- ot->description= "Hook selected vertices to the first selected Object";
- ot->idname= "OBJECT_OT_hook_add_newob";
+ ot->name = "Hook to New Object";
+ ot->description = "Hook selected vertices to the first selected Object";
+ ot->idname = "OBJECT_OT_hook_add_newob";
/* api callbacks */
- ot->exec= object_add_hook_newob_exec;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_add_hook_newob_exec;
+ ot->poll = hook_op_edit_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_hook_remove_exec(bContext *C, wmOperator *op)
@@ -578,10 +579,10 @@ static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), Pr
ModifierData *md = NULL;
int a, totitem= 0;
- if(!ob)
+ if (!ob)
return DummyRNA_NULL_items;
- for(a=0, md=ob->modifiers.first; md; md= md->next, a++) {
+ for (a=0, md=ob->modifiers.first; md; md= md->next, a++) {
if (md->type==eModifierType_Hook) {
tmp.value= a;
tmp.icon = ICON_HOOK;
@@ -602,24 +603,24 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Remove Hook";
- ot->idname= "OBJECT_OT_hook_remove";
- ot->description= "Remove a hook from the active object";
+ ot->name = "Remove Hook";
+ ot->idname = "OBJECT_OT_hook_remove";
+ ot->description = "Remove a hook from the active object";
/* api callbacks */
- ot->exec= object_hook_remove_exec;
- ot->invoke= WM_menu_invoke;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_hook_remove_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->poll = hook_op_edit_poll;
/* flags */
/* this operator removes modifier which isn't stored in local undo stack,
- so redoing it from redo panel gives totally weird results */
- ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
+ * so redoing it from redo panel gives totally weird results */
+ ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove");
RNA_def_enum_funcs(prop, hook_mod_itemf);
- ot->prop= prop;
+ ot->prop = prop;
}
static int object_hook_reset_exec(bContext *C, wmOperator *op)
@@ -643,10 +644,10 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op)
}
/* reset functionality */
- if(hmd->object) {
+ if (hmd->object) {
bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget);
- if(hmd->subtarget[0] && pchan) {
+ if (hmd->subtarget[0] && pchan) {
float imat[4][4], mat[4][4];
/* calculate the world-space matrix for the pose-channel target first, then carry on as usual */
@@ -672,16 +673,16 @@ void OBJECT_OT_hook_reset(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Reset Hook";
- ot->description= "Recalculate and clear offset transformation";
- ot->idname= "OBJECT_OT_hook_reset";
+ ot->name = "Reset Hook";
+ ot->description = "Recalculate and clear offset transformation";
+ ot->idname = "OBJECT_OT_hook_reset";
/* callbacks */
- ot->exec= object_hook_reset_exec;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_hook_reset_exec;
+ ot->poll = hook_op_edit_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
@@ -728,16 +729,16 @@ void OBJECT_OT_hook_recenter(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Recenter Hook";
- ot->description= "Set hook center to cursor position";
- ot->idname= "OBJECT_OT_hook_recenter";
+ ot->name = "Recenter Hook";
+ ot->description = "Set hook center to cursor position";
+ ot->idname = "OBJECT_OT_hook_recenter";
/* callbacks */
- ot->exec= object_hook_recenter_exec;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_hook_recenter_exec;
+ ot->poll = hook_op_edit_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
@@ -770,11 +771,11 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
/* assign functionality */
- if(!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) {
+ if (!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) {
BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
return OPERATOR_CANCELLED;
}
- if(hmd->indexar)
+ if (hmd->indexar)
MEM_freeN(hmd->indexar);
copy_v3_v3(hmd->cent, cent);
@@ -792,18 +793,18 @@ void OBJECT_OT_hook_assign(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Assign to Hook";
- ot->description= "Assign the selected vertices to a hook";
- ot->idname= "OBJECT_OT_hook_assign";
+ ot->name = "Assign to Hook";
+ ot->description = "Assign the selected vertices to a hook";
+ ot->idname = "OBJECT_OT_hook_assign";
/* callbacks */
- ot->exec= object_hook_assign_exec;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_hook_assign_exec;
+ ot->poll = hook_op_edit_poll;
/* flags */
/* this operator changes data stored in modifier which doesn't get pushed to undo stack,
- so redoing it from redo panel gives totally weird results */
- ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
+ * so redoing it from redo panel gives totally weird results */
+ ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to");
@@ -843,16 +844,16 @@ void OBJECT_OT_hook_select(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Select Hook";
- ot->description= "Select affected vertices on mesh";
- ot->idname= "OBJECT_OT_hook_select";
+ ot->name = "Select Hook";
+ ot->description = "Select affected vertices on mesh";
+ ot->idname = "OBJECT_OT_hook_select";
/* callbacks */
- ot->exec= object_hook_select_exec;
- ot->poll= hook_op_edit_poll;
+ ot->exec = object_hook_select_exec;
+ ot->poll = hook_op_edit_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove");
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 651272323f3..19eb3575241 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -159,7 +159,6 @@ void OBJECT_OT_multires_external_pack(struct wmOperatorType *ot);
void OBJECT_OT_meshdeform_bind(struct wmOperatorType *ot);
void OBJECT_OT_explode_refresh(struct wmOperatorType *ot);
void OBJECT_OT_ocean_bake(struct wmOperatorType *ot);
-void OBJECT_OT_test_multires(struct wmOperatorType *ot);
/* object_constraint.c */
void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 9f3bc9bbf37..4ba62541c60 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -70,12 +70,12 @@ void free_editLatt(Object *ob)
{
Lattice *lt= ob->data;
- if(lt->editlatt) {
+ if (lt->editlatt) {
Lattice *editlt= lt->editlatt->latt;
- if(editlt->def)
+ if (editlt->def)
MEM_freeN(editlt->def);
- if(editlt->dvert)
+ if (editlt->dvert)
free_dverts(editlt->dvert, editlt->pntsu*editlt->pntsv*editlt->pntsw);
MEM_freeN(editlt);
@@ -93,20 +93,20 @@ void make_editLatt(Object *obedit)
free_editLatt(obedit);
actkey= ob_get_keyblock(obedit);
- if(actkey)
+ if (actkey)
key_to_latt(actkey, lt);
lt->editlatt= MEM_callocN(sizeof(EditLatt), "editlatt");
lt->editlatt->latt= MEM_dupallocN(lt);
lt->editlatt->latt->def= MEM_dupallocN(lt->def);
- if(lt->dvert) {
+ if (lt->dvert) {
int tot= lt->pntsu*lt->pntsv*lt->pntsw;
lt->editlatt->latt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot);
}
- if(lt->key) lt->editlatt->shapenr= obedit->shapenr;
+ if (lt->key) lt->editlatt->shapenr= obedit->shapenr;
}
void load_editLatt(Object *obedit)
@@ -120,19 +120,19 @@ void load_editLatt(Object *obedit)
lt= obedit->data;
editlt= lt->editlatt->latt;
- if(lt->editlatt->shapenr) {
+ if (lt->editlatt->shapenr) {
actkey= BLI_findlink(&lt->key->block, lt->editlatt->shapenr-1);
/* active key: vertices */
tot= editlt->pntsu*editlt->pntsv*editlt->pntsw;
- if(actkey->data) MEM_freeN(actkey->data);
+ if (actkey->data) MEM_freeN(actkey->data);
fp=actkey->data= MEM_callocN(lt->key->elemsize*tot, "actkey->data");
actkey->totelem= tot;
bp= editlt->def;
- while(tot--) {
+ while (tot--) {
copy_v3_v3(fp, bp->vec);
fp+= 3;
bp++;
@@ -154,12 +154,12 @@ void load_editLatt(Object *obedit)
lt->typew= editlt->typew;
}
- if(lt->dvert) {
+ if (lt->dvert) {
free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
lt->dvert= NULL;
}
- if(editlt->dvert) {
+ if (editlt->dvert) {
tot= lt->pntsu*lt->pntsv*lt->pntsw;
lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
@@ -179,8 +179,8 @@ void ED_setflagsLatt(Object *obedit, int flag)
a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
- while(a--) {
- if(bp->hide==0) {
+ while (a--) {
+ if (bp->hide==0) {
bp->f1= flag;
}
bp++;
@@ -201,9 +201,9 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
bp= lt->editlatt->latt->def;
a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
- while(a--) {
- if(bp->hide==0) {
- if(bp->f1) {
+ while (a--) {
+ if (bp->hide==0) {
+ if (bp->f1) {
action = SEL_DESELECT;
break;
}
@@ -223,8 +223,8 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
bp= lt->editlatt->latt->def;
a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
- while(a--) {
- if(bp->hide==0) {
+ while (a--) {
+ if (bp->hide==0) {
bp->f1 ^= 1;
}
bp++;
@@ -240,16 +240,16 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op)
void LATTICE_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select or Deselect All";
- ot->description= "Change selection of all UVW control points";
- ot->idname= "LATTICE_OT_select_all";
+ ot->name = "(De)select All";
+ ot->description = "Change selection of all UVW control points";
+ ot->idname = "LATTICE_OT_select_all";
/* api callbacks */
- ot->exec= lattice_select_all_exec;
- ot->poll= ED_operator_editlattice;
+ ot->exec = lattice_select_all_exec;
+ ot->poll = ED_operator_editlattice;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
@@ -258,7 +258,7 @@ static int make_regular_poll(bContext *C)
{
Object *ob;
- if(ED_operator_editlattice(C)) return 1;
+ if (ED_operator_editlattice(C)) return 1;
ob= CTX_data_active_object(C);
return (ob && ob->type==OB_LATTICE);
@@ -269,7 +269,7 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob= CTX_data_edit_object(C);
Lattice *lt;
- if(ob) {
+ if (ob) {
lt= ob->data;
resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
}
@@ -288,16 +288,16 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op))
void LATTICE_OT_make_regular(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Make Regular";
- ot->description= "Set UVW control points a uniform distance apart";
- ot->idname= "LATTICE_OT_make_regular";
+ ot->name = "Make Regular";
+ ot->description = "Set UVW control points a uniform distance apart";
+ ot->idname = "LATTICE_OT_make_regular";
/* api callbacks */
- ot->exec= make_regular_exec;
- ot->poll= make_regular_poll;
+ ot->exec = make_regular_exec;
+ ot->poll = make_regular_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/****************************** Mouse Selection *************************/
@@ -307,10 +307,10 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in
struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData;
float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y);
- if((bp->f1 & SELECT)==data->select)
+ if ((bp->f1 & SELECT)==data->select)
temp += 5;
- if(temp<data->dist) {
+ if (temp<data->dist) {
data->dist = temp;
data->bp = bp;
@@ -343,8 +343,8 @@ int mouse_lattice(bContext *C, const int mval[2], int extend)
view3d_set_viewcontext(C, &vc);
bp= findnearestLattvert(&vc, mval, 1);
- if(bp) {
- if(extend==0) {
+ if (bp) {
+ if (extend==0) {
ED_setflagsLatt(vc.obedit, 0);
bp->f1 |= SELECT;
}
@@ -392,7 +392,7 @@ static void free_undoLatt(void *data)
{
UndoLattice *ult= (UndoLattice*)data;
- if(ult->def) MEM_freeN(ult->def);
+ if (ult->def) MEM_freeN(ult->def);
MEM_freeN(ult);
}
@@ -410,7 +410,7 @@ static void *get_editlatt(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
- if(obedit && obedit->type==OB_LATTICE) {
+ if (obedit && obedit->type==OB_LATTICE) {
Lattice *lt= obedit->data;
return lt->editlatt;
}
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 55dbbb50958..cd2fa4f93b6 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -91,19 +91,19 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
ModifierTypeInfo *mti = modifierType_getInfo(type);
/* only geometry objects should be able to get modifiers [#25291] */
- if(!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
+ if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name+2);
return NULL;
}
- if(mti->flags&eModifierTypeFlag_Single) {
- if(modifiers_findByType(ob, type)) {
+ if (mti->flags&eModifierTypeFlag_Single) {
+ if (modifiers_findByType(ob, type)) {
BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed");
return NULL;
}
}
- if(type == eModifierType_ParticleSystem) {
+ if (type == eModifierType_ParticleSystem) {
/* don't need to worry about the new modifier's name, since that is set to the number
* of particle systems which shouldn't have too many duplicates
*/
@@ -113,10 +113,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
/* get new modifier data to add */
new_md= modifier_new(type);
- if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
+ if (mti->flags&eModifierTypeFlag_RequiresOriginalData) {
md = ob->modifiers.first;
- while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
+ while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
md = md->next;
BLI_insertlinkbefore(&ob->modifiers, md, new_md);
@@ -124,7 +124,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
else
BLI_addtail(&ob->modifiers, new_md);
- if(name)
+ if (name)
BLI_strncpy(new_md->name, name, sizeof(new_md->name));
/* make sure modifier data has unique name */
@@ -132,22 +132,22 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc
modifier_unique_name(&ob->modifiers, new_md);
/* special cases */
- if(type == eModifierType_Softbody) {
- if(!ob->soft) {
+ if (type == eModifierType_Softbody) {
+ if (!ob->soft) {
ob->soft= sbNew(scene);
ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
}
}
- else if(type == eModifierType_Collision) {
- if(!ob->pd)
+ else if (type == eModifierType_Collision) {
+ if (!ob->pd)
ob->pd= object_add_collision_fields(0);
ob->pd->deflect= 1;
DAG_scene_sort(bmain, scene);
}
- else if(type == eModifierType_Surface)
+ else if (type == eModifierType_Surface)
DAG_scene_sort(bmain, scene);
- else if(type == eModifierType_Multires)
+ else if (type == eModifierType_Multires)
/* set totlvl from existing MDISPS layer if object already had it */
multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob);
}
@@ -164,70 +164,60 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr
/* It seems on rapid delete it is possible to
* get called twice on same modifier, so make
* sure it is in list. */
- for(obmd=ob->modifiers.first; obmd; obmd=obmd->next)
- if(obmd==md)
+ for (obmd=ob->modifiers.first; obmd; obmd=obmd->next)
+ if (obmd==md)
break;
- if(!obmd)
+ if (!obmd)
return 0;
/* special cases */
- if(md->type == eModifierType_ParticleSystem) {
+ if (md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd=(ParticleSystemModifierData*)md;
BLI_remlink(&ob->particlesystem, psmd->psys);
psys_free(ob, psmd->psys);
psmd->psys= NULL;
}
- else if(md->type == eModifierType_Softbody) {
- if(ob->soft) {
+ else if (md->type == eModifierType_Softbody) {
+ if (ob->soft) {
sbFree(ob->soft);
ob->soft= NULL;
ob->softflag= 0;
}
}
- else if(md->type == eModifierType_Collision) {
- if(ob->pd)
+ else if (md->type == eModifierType_Collision) {
+ if (ob->pd)
ob->pd->deflect= 0;
*sort_depsgraph = 1;
}
- else if(md->type == eModifierType_Surface) {
- if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE)
+ else if (md->type == eModifierType_Surface) {
+ if (ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE)
ob->pd->shape = PFIELD_SHAPE_PLANE;
*sort_depsgraph = 1;
}
- else if(md->type == eModifierType_Smoke) {
+ else if (md->type == eModifierType_Smoke) {
ob->dt = OB_TEXTURE;
}
- else if(md->type == eModifierType_Multires) {
+ else if (md->type == eModifierType_Multires) {
int ok= 1;
- Mesh *me= ob->data;
ModifierData *tmpmd;
- /* ensure MDISPS CustomData layer is't used by another multires modifiers */
- for(tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next)
- if(tmpmd!=md && tmpmd->type == eModifierType_Multires) {
+ /* ensure MDISPS CustomData layer isn't used by another multires modifiers */
+ for (tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next)
+ if (tmpmd!=md && tmpmd->type == eModifierType_Multires) {
ok= 0;
break;
}
- if(ok) {
- if(me->edit_btmesh) {
- BMEditMesh *em= me->edit_btmesh;
- /* CustomData_external_remove is used here only to mark layer as non-external
- for further free-ing, so zero element count looks safer than em->totface */
- CustomData_external_remove(&em->bm->ldata, &me->id, CD_MDISPS, 0);
- BM_data_layer_free(em->bm, &em->bm->ldata, CD_MDISPS);
- } else {
- CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop);
- CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop);
- }
+ if (ok) {
+ multires_customdata_delete(ob->data);
}
}
- if(ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
+ if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
ob->particlesystem.first == NULL) {
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
}
@@ -245,7 +235,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob
ok= object_modifier_remove(ob, md, &sort_depsgraph);
- if(!ok) {
+ if (!ok) {
BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name);
return 0;
}
@@ -253,7 +243,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* sorting has to be done after the update so that dynamic systems can react properly */
- if(sort_depsgraph)
+ if (sort_depsgraph)
DAG_scene_sort(bmain, scene);
return 1;
@@ -264,10 +254,10 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob)
ModifierData *md = ob->modifiers.first;
int sort_depsgraph = 0;
- if(!md)
+ if (!md)
return;
- while(md) {
+ while (md) {
ModifierData *next_md;
next_md= md->next;
@@ -280,19 +270,19 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* sorting has to be done after the update so that dynamic systems can react properly */
- if(sort_depsgraph)
+ if (sort_depsgraph)
DAG_scene_sort(bmain, scene);
}
int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md)
{
- if(md->prev) {
+ if (md->prev) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if(mti->type!=eModifierTypeType_OnlyDeform) {
+ if (mti->type!=eModifierTypeType_OnlyDeform) {
ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type);
- if(nmti->flags&eModifierTypeFlag_RequiresOriginalData) {
+ if (nmti->flags&eModifierTypeFlag_RequiresOriginalData) {
BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data");
return 0;
}
@@ -307,13 +297,13 @@ int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md
int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData *md)
{
- if(md->next) {
+ if (md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
+ if (mti->flags&eModifierTypeFlag_RequiresOriginalData) {
ModifierTypeInfo *nmti = modifierType_getInfo(md->next->type);
- if(nmti->type!=eModifierTypeType_OnlyDeform) {
+ if (nmti->type!=eModifierTypeType_OnlyDeform) {
BKE_report(reports, RPT_WARNING, "Cannot move beyond a non-deforming modifier");
return 0;
}
@@ -339,43 +329,43 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
int totvert=0, totedge=0, cvert=0;
int totpart=0, totchild=0;
- if(md->type != eModifierType_ParticleSystem) return 0;
- if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0;
+ if (md->type != eModifierType_ParticleSystem) return 0;
+ if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0;
psys=((ParticleSystemModifierData *)md)->psys;
part= psys->part;
- if(part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL)
+ if (part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL)
return 0;
totpart= psys->totcached;
totchild= psys->totchildcache;
- if(totchild && (part->draw&PART_DRAW_PARENT)==0)
+ if (totchild && (part->draw&PART_DRAW_PARENT)==0)
totpart= 0;
/* count */
cache= psys->pathcache;
- for(a=0; a<totpart; a++) {
+ for (a=0; a<totpart; a++) {
key= cache[a];
- if(key->steps > 0) {
+ if (key->steps > 0) {
totvert+= key->steps+1;
totedge+= key->steps;
}
}
cache= psys->childcache;
- for(a=0; a<totchild; a++) {
+ for (a=0; a<totchild; a++) {
key= cache[a];
- if(key->steps > 0) {
+ if (key->steps > 0) {
totvert+= key->steps+1;
totedge+= key->steps;
}
}
- if(totvert==0) return 0;
+ if (totvert==0) return 0;
/* add new mesh */
obn= add_object(scene, OB_MESH);
@@ -393,12 +383,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
/* copy coordinates */
cache= psys->pathcache;
- for(a=0; a<totpart; a++) {
+ for (a=0; a<totpart; a++) {
key= cache[a];
kmax= key->steps;
- for(k=0; k<=kmax; k++,key++,cvert++,mvert++) {
+ for (k=0; k<=kmax; k++,key++,cvert++,mvert++) {
copy_v3_v3(mvert->co,key->co);
- if(k) {
+ if (k) {
medge->v1= cvert-1;
medge->v2= cvert;
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE;
@@ -412,12 +402,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
}
cache=psys->childcache;
- for(a=0; a<totchild; a++) {
+ for (a=0; a<totchild; a++) {
key=cache[a];
kmax=key->steps;
- for(k=0; k<=kmax; k++,key++,cvert++,mvert++) {
+ for (k=0; k<=kmax; k++,key++,cvert++,mvert++) {
copy_v3_v3(mvert->co,key->co);
- if(k) {
+ if (k) {
medge->v1=cvert-1;
medge->v2=cvert;
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE;
@@ -447,15 +437,15 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
}
/*
- It should be ridiculously easy to extract the original verts that we want
- and form the shape data. We can probably use the CD KEYINDEX layer (or
- whatever I ended up calling it, too tired to check now), though this would
- by necassity have to make some potentially ugly assumptions about the order
- of the mesh data :-/ you can probably assume in 99% of cases that the first
- element of a given index is the original, and any subsequent duplicates are
- copies/interpolates, but that's an assumption that would need to be tested
- and then predominantly stated in comments in a half dozen headers.
- */
+ * It should be ridiculously easy to extract the original verts that we want
+ * and form the shape data. We can probably use the CD KEYINDEX layer (or
+ * whatever I ended up calling it, too tired to check now), though this would
+ * by necessity have to make some potentially ugly assumptions about the order
+ * of the mesh data :-/ you can probably assume in 99% of cases that the first
+ * element of a given index is the original, and any subsequent duplicates are
+ * copies/interpolates, but that's an assumption that would need to be tested
+ * and then predominantly stated in comments in a half dozen headers.
+ */
if (ob->type==OB_MESH) {
DerivedMesh *dm;
@@ -463,7 +453,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
Key *key=me->key;
KeyBlock *kb;
- if(!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
+ if (!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to Shapes");
return 0;
}
@@ -474,11 +464,11 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M
return 0;
}
- if(key == NULL) {
+ if (key == NULL) {
key= me->key= add_key((ID *)me);
key->type= KEY_RELATIVE;
/* if that was the first key block added, then it was the basis.
- * Initialise it with the mesh, and add another for the modifier */
+ * Initialize it with the mesh, and add another for the modifier */
kb= add_keyblock(key, NULL);
mesh_to_key(me, kb);
}
@@ -511,21 +501,22 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
Mesh *me = ob->data;
MultiresModifierData *mmd= find_multires_modifier_before(scene, md);
- if(me->key && mti->type != eModifierTypeType_NonGeometrical) {
+ if (me->key && mti->type != eModifierTypeType_NonGeometrical) {
BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys");
return 0;
}
/* Multires: ensure that recent sculpting is applied */
- if(md->type == eModifierType_Multires)
+ if (md->type == eModifierType_Multires)
multires_force_update(ob);
if (mmd && mmd->totlvl && mti->type==eModifierTypeType_OnlyDeform) {
- if(!multiresModifier_reshapeFromDeformMod (scene, mmd, ob, md)) {
+ if (!multiresModifier_reshapeFromDeformMod (scene, mmd, ob, md)) {
BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
return 0;
}
- } else {
+ }
+ else {
dm = mesh_create_derived_for_modifier(scene, ob, md, 1);
if (!dm) {
BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
@@ -536,10 +527,8 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
dm->release(dm);
- if(md->type == eModifierType_Multires) {
- CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop);
- CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop);
- }
+ if (md->type == eModifierType_Multires)
+ multires_customdata_delete(me);
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
@@ -553,7 +542,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
}
cu = ob->data;
- BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tesselated/bevel vertices");
+ BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices");
vertexCos = curve_getVertexCos(cu, &cu->nurb, &numVerts);
mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0);
@@ -569,13 +558,13 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob,
}
/* lattice modifier can be applied to particle system too */
- if(ob->particlesystem.first) {
+ if (ob->particlesystem.first) {
ParticleSystem *psys = ob->particlesystem.first;
- for(; psys; psys=psys->next) {
+ for (; psys; psys=psys->next) {
- if(psys->part->type != PART_HAIR)
+ if (psys->part->type != PART_HAIR)
continue;
psys_apply_hair_lattice(scene, ob, psys);
@@ -592,7 +581,8 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi
if (scene->obedit) {
BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in editmode");
return 0;
- } else if (((ID*) ob->data)->us>1) {
+ }
+ else if (((ID*) ob->data)->us>1) {
BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data");
return 0;
}
@@ -609,7 +599,8 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi
md->mode= prev_mode;
return 0;
}
- } else {
+ }
+ else {
if (!modifier_apply_obdata(reports, scene, ob, md)) {
md->mode= prev_mode;
return 0;
@@ -643,7 +634,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type= RNA_enum_get(op->ptr, "type");
- if(!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
@@ -658,20 +649,19 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr)
ModifierTypeInfo *mti;
int totitem= 0, a;
- if(!ob)
+ if (!ob)
return modifier_type_items;
- for(a=0; modifier_type_items[a].identifier; a++) {
+ for (a=0; modifier_type_items[a].identifier; a++) {
md_item= &modifier_type_items[a];
- if(md_item->identifier[0]) {
+ if (md_item->identifier[0]) {
mti= modifierType_getInfo(md_item->value);
- if(mti->flags & eModifierTypeFlag_NoUserAdd)
+ if (mti->flags & eModifierTypeFlag_NoUserAdd)
continue;
- if(!((mti->flags & eModifierTypeFlag_AcceptsCVs) ||
- (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh))))
+ if (!object_support_modifier_type(ob, md_item->value))
continue;
}
else {
@@ -681,7 +671,7 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr)
continue;
}
- if(group_item) {
+ if (group_item) {
RNA_enum_item_add(&item, &totitem, group_item);
group_item= NULL;
}
@@ -700,22 +690,22 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Add Modifier";
+ ot->name = "Add Modifier";
ot->description = "Add a modifier to the active object";
- ot->idname= "OBJECT_OT_modifier_add";
+ ot->idname = "OBJECT_OT_modifier_add";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= modifier_add_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = modifier_add_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "type", modifier_type_items, eModifierType_Subsurf, "Type", "");
RNA_def_enum_funcs(prop, modifier_add_itemf);
- ot->prop= prop;
+ ot->prop = prop;
}
/************************ generic functions for operators using mod names and data context *********************/
@@ -783,15 +773,15 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int mode_orig = ob ? ob->mode : 0;
- if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md))
+ if (!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
/* if cloth/softbody was removed, particle mode could be cleared */
- if(mode_orig & OB_MODE_PARTICLE_EDIT)
- if((ob->mode & OB_MODE_PARTICLE_EDIT)==0)
- if(scene->basact && scene->basact->object==ob)
+ if (mode_orig & OB_MODE_PARTICLE_EDIT)
+ if ((ob->mode & OB_MODE_PARTICLE_EDIT)==0)
+ if (scene->basact && scene->basact->object==ob)
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
return OPERATOR_FINISHED;
@@ -807,16 +797,16 @@ static int modifier_remove_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
void OBJECT_OT_modifier_remove(wmOperatorType *ot)
{
- ot->name= "Remove Modifier";
- ot->description= "Remove a modifier from the active object";
- ot->idname= "OBJECT_OT_modifier_remove";
+ ot->name = "Remove Modifier";
+ ot->description = "Remove a modifier from the active object";
+ ot->idname = "OBJECT_OT_modifier_remove";
- ot->invoke= modifier_remove_invoke;
- ot->exec= modifier_remove_exec;
- ot->poll= edit_modifier_poll;
+ ot->invoke = modifier_remove_invoke;
+ ot->exec = modifier_remove_exec;
+ ot->poll = edit_modifier_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -827,7 +817,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
+ if (!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
return OPERATOR_CANCELLED;
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -846,16 +836,16 @@ static int modifier_move_up_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
{
- ot->name= "Move Up Modifier";
- ot->description= "Move modifier up in the stack";
- ot->idname= "OBJECT_OT_modifier_move_up";
+ ot->name = "Move Up Modifier";
+ ot->description = "Move modifier up in the stack";
+ ot->idname = "OBJECT_OT_modifier_move_up";
- ot->invoke= modifier_move_up_invoke;
- ot->exec= modifier_move_up_exec;
- ot->poll= edit_modifier_poll;
+ ot->invoke = modifier_move_up_invoke;
+ ot->exec = modifier_move_up_exec;
+ ot->poll = edit_modifier_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -866,7 +856,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if(!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
+ if (!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
return OPERATOR_CANCELLED;
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -885,16 +875,16 @@ static int modifier_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE
void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
{
- ot->name= "Move Down Modifier";
- ot->description= "Move modifier down in the stack";
- ot->idname= "OBJECT_OT_modifier_move_down";
+ ot->name = "Move Down Modifier";
+ ot->description = "Move modifier down in the stack";
+ ot->idname = "OBJECT_OT_modifier_move_down";
- ot->invoke= modifier_move_down_invoke;
- ot->exec= modifier_move_down_exec;
- ot->poll= edit_modifier_poll;
+ ot->invoke = modifier_move_down_invoke;
+ ot->exec = modifier_move_down_exec;
+ ot->poll = edit_modifier_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -907,7 +897,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int apply_as= RNA_enum_get(op->ptr, "apply_as");
- if(!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
+ if (!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) {
return OPERATOR_CANCELLED;
}
@@ -932,16 +922,16 @@ static EnumPropertyItem modifier_apply_as_items[] = {
void OBJECT_OT_modifier_apply(wmOperatorType *ot)
{
- ot->name= "Apply Modifier";
- ot->description= "Apply modifier and remove from the stack";
- ot->idname= "OBJECT_OT_modifier_apply";
+ ot->name = "Apply Modifier";
+ ot->description = "Apply modifier and remove from the stack";
+ ot->idname = "OBJECT_OT_modifier_apply";
- ot->invoke= modifier_apply_invoke;
- ot->exec= modifier_apply_exec;
- ot->poll= edit_modifier_poll;
+ ot->invoke = modifier_apply_invoke;
+ ot->exec = modifier_apply_exec;
+ ot->poll = edit_modifier_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry");
edit_modifier_properties(ot);
@@ -956,7 +946,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if(!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
+ if (!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
return OPERATOR_CANCELLED;
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -975,16 +965,16 @@ static int modifier_convert_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
void OBJECT_OT_modifier_convert(wmOperatorType *ot)
{
- ot->name= "Convert Modifier";
- ot->description= "Convert particles to a mesh object";
- ot->idname= "OBJECT_OT_modifier_convert";
+ ot->name = "Convert Modifier";
+ ot->description = "Convert particles to a mesh object";
+ ot->idname = "OBJECT_OT_modifier_convert";
- ot->invoke= modifier_convert_invoke;
- ot->exec= modifier_convert_exec;
- ot->poll= edit_modifier_poll;
+ ot->invoke = modifier_convert_invoke;
+ ot->exec = modifier_convert_exec;
+ ot->poll = edit_modifier_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -995,7 +985,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if(!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
+ if (!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
return OPERATOR_CANCELLED;
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1014,16 +1004,16 @@ static int modifier_copy_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve
void OBJECT_OT_modifier_copy(wmOperatorType *ot)
{
- ot->name= "Copy Modifier";
- ot->description= "Duplicate modifier at the same position in the stack";
- ot->idname= "OBJECT_OT_modifier_copy";
+ ot->name = "Copy Modifier";
+ ot->description = "Duplicate modifier at the same position in the stack";
+ ot->idname = "OBJECT_OT_modifier_copy";
- ot->invoke= modifier_copy_invoke;
- ot->exec= modifier_copy_exec;
- ot->poll= edit_modifier_poll;
+ ot->invoke = modifier_copy_invoke;
+ ot->exec = modifier_copy_exec;
+ ot->poll = edit_modifier_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -1059,16 +1049,16 @@ static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, wmE
void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
{
- ot->name= "Delete Higher Levels";
- ot->description= "Deletes the higher resolution mesh, potential loss of detail";
- ot->idname= "OBJECT_OT_multires_higher_levels_delete";
+ ot->name = "Delete Higher Levels";
+ ot->description = "Deletes the higher resolution mesh, potential loss of detail";
+ ot->idname = "OBJECT_OT_multires_higher_levels_delete";
- ot->poll= multires_poll;
- ot->invoke= multires_higher_levels_delete_invoke;
- ot->exec= multires_higher_levels_delete_exec;
+ ot->poll = multires_poll;
+ ot->invoke = multires_higher_levels_delete_invoke;
+ ot->exec = multires_higher_levels_delete_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -1100,16 +1090,16 @@ static int multires_subdivide_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE
void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
{
- ot->name= "Multires Subdivide";
- ot->description= "Add a new level of subdivision";
- ot->idname= "OBJECT_OT_multires_subdivide";
+ ot->name = "Multires Subdivide";
+ ot->description = "Add a new level of subdivision";
+ ot->idname = "OBJECT_OT_multires_subdivide";
- ot->poll= multires_poll;
- ot->invoke= multires_subdivide_invoke;
- ot->exec= multires_subdivide_exec;
+ ot->poll = multires_poll;
+ ot->invoke = multires_subdivide_invoke;
+ ot->exec = multires_subdivide_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -1124,25 +1114,25 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
- if(mmd->lvl==0) {
+ if (mmd->lvl==0) {
BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions");
return OPERATOR_CANCELLED;
}
CTX_DATA_BEGIN(C, Object*, selob, selected_editable_objects) {
- if(selob->type == OB_MESH && selob != ob) {
+ if (selob->type == OB_MESH && selob != ob) {
secondob= selob;
break;
}
}
CTX_DATA_END;
- if(!secondob) {
+ if (!secondob) {
BKE_report(op->reports, RPT_ERROR, "Second selected mesh object require to copy shape from");
return OPERATOR_CANCELLED;
}
- if(!multiresModifier_reshape(scene, mmd, ob, secondob)) {
+ if (!multiresModifier_reshape(scene, mmd, ob, secondob)) {
BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices");
return OPERATOR_CANCELLED;
}
@@ -1163,77 +1153,19 @@ static int multires_reshape_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(
void OBJECT_OT_multires_reshape(wmOperatorType *ot)
{
- ot->name= "Multires Reshape";
- ot->description= "Copy vertex coordinates from other object";
- ot->idname= "OBJECT_OT_multires_reshape";
+ ot->name = "Multires Reshape";
+ ot->description = "Copy vertex coordinates from other object";
+ ot->idname = "OBJECT_OT_multires_reshape";
- ot->poll= multires_poll;
- ot->invoke= multires_reshape_invoke;
- ot->exec= multires_reshape_exec;
+ ot->poll = multires_poll;
+ ot->invoke = multires_reshape_invoke;
+ ot->exec = multires_reshape_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
-static int multires_test_exec(bContext *C, wmOperator *op)
-{
- Object *ob= ED_object_active_context(C);
- Mesh *me = ob->data;
- MPoly *mp;
- MDisps *mdisps;
- int i, x = RNA_int_get(op->ptr, "x"), y = RNA_int_get(op->ptr, "y");
-
- if (ob->type != OB_MESH || !me)
- return OPERATOR_CANCELLED;
-
- mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- if (!mdisps)
- return OPERATOR_CANCELLED;
-
- mp = me->mpoly;
- for (i=0; i<me->totpoly; i++, mp++) {
- MLoop *ml;
- int j;
-
- ml = me->mloop + mp->loopstart;
- for (j=0; j<mp->totloop; j++, ml++) {
- MLoop *ml_prev = ME_POLY_LOOP_PREV(me->mloop, mp, j);
- MLoop *ml_next = ME_POLY_LOOP_NEXT(me->mloop, mp, j);
-
- if ((me->mvert[ml->v].flag&SELECT) && (me->mvert[ml_prev->v].flag&SELECT) && (me->mvert[ml_next->v].flag&SELECT)) {
- MDisps *md = mdisps + mp->loopstart + j;
- int res = sqrt(md->totdisp);
-
- if (x >= res) x = res-1;
- if (y >= res) y = res-1;
-
- md->disps[y*res + x][2] += 1.0;
- }
- }
- }
-
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_test_multires(wmOperatorType *ot)
-{
- ot->name= "Multires Object Mode Test";
- ot->description= "";
- ot->idname= "OBJECT_OT_test_multires";
-
- ot->poll= multires_poll;
- ot->exec= multires_test_exec;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
- RNA_def_int(ot->srna, "x", 0, 0, 100, "x", "x", 0, 100);
- RNA_def_int(ot->srna, "y", 0, 0, 100, "y", "y", 0, 100);
-}
-
/****************** multires save external operator *********************/
@@ -1245,15 +1177,15 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
int relative= RNA_boolean_get(op->ptr, "relative_path");
- if(!me)
+ if (!me)
return OPERATOR_CANCELLED;
- if(CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (CustomData_external_test(&me->ldata, CD_MDISPS))
return OPERATOR_CANCELLED;
RNA_string_get(op->ptr, "filepath", path);
- if(relative)
+ if (relative)
BLI_path_rel(path, G.main->name);
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
@@ -1277,10 +1209,10 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U
if (!mmd)
return OPERATOR_CANCELLED;
- if(CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (CustomData_external_test(&me->ldata, CD_MDISPS))
return OPERATOR_CANCELLED;
- if(RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath"))
return multires_external_save_exec(C, op);
op->customdata= me;
@@ -1295,17 +1227,17 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U
void OBJECT_OT_multires_external_save(wmOperatorType *ot)
{
- ot->name= "Multires Save External";
- ot->description= "Save displacements to an external file";
- ot->idname= "OBJECT_OT_multires_external_save";
+ ot->name = "Multires Save External";
+ ot->description = "Save displacements to an external file";
+ ot->idname = "OBJECT_OT_multires_external_save";
- // XXX modifier no longer in context after file browser .. ot->poll= multires_poll;
- ot->exec= multires_external_save_exec;
- ot->invoke= multires_external_save_invoke;
- ot->poll= multires_poll;
+ // XXX modifier no longer in context after file browser .. ot->poll = multires_poll;
+ ot->exec = multires_external_save_exec;
+ ot->invoke = multires_external_save_invoke;
+ ot->poll = multires_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY);
edit_modifier_properties(ot);
@@ -1318,7 +1250,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_active_context(C);
Mesh *me= ob->data;
- if(!CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (!CustomData_external_test(&me->ldata, CD_MDISPS))
return OPERATOR_CANCELLED;
// XXX don't remove..
@@ -1329,15 +1261,15 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_multires_external_pack(wmOperatorType *ot)
{
- ot->name= "Multires Pack External";
- ot->description= "Pack displacements from an external file";
- ot->idname= "OBJECT_OT_multires_external_pack";
+ ot->name = "Multires Pack External";
+ ot->description = "Pack displacements from an external file";
+ ot->idname = "OBJECT_OT_multires_external_pack";
- ot->poll= multires_poll;
- ot->exec= multires_external_pack_exec;
+ ot->poll = multires_poll;
+ ot->exec = multires_external_pack_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/********************* multires apply base ***********************/
@@ -1368,16 +1300,16 @@ static int multires_base_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
{
- ot->name= "Multires Apply Base";
- ot->description= "Modify the base mesh to conform to the displaced mesh";
- ot->idname= "OBJECT_OT_multires_base_apply";
+ ot->name = "Multires Apply Base";
+ ot->description = "Modify the base mesh to conform to the displaced mesh";
+ ot->idname = "OBJECT_OT_multires_base_apply";
- ot->poll= multires_poll;
- ot->invoke= multires_base_apply_invoke;
- ot->exec= multires_base_apply_exec;
+ ot->poll = multires_poll;
+ ot->invoke = multires_base_apply_invoke;
+ ot->exec = multires_base_apply_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -1398,15 +1330,15 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
if (!mmd)
return OPERATOR_CANCELLED;
- if(mmd->bindcagecos) {
+ if (mmd->bindcagecos) {
MEM_freeN(mmd->bindcagecos);
- if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
- if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
- if(mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);
- if(mmd->bindoffsets) MEM_freeN(mmd->bindoffsets);
- if(mmd->dynverts) MEM_freeN(mmd->dynverts);
- if(mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */
- if(mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */
+ if (mmd->dyngrid) MEM_freeN(mmd->dyngrid);
+ if (mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
+ if (mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);
+ if (mmd->bindoffsets) MEM_freeN(mmd->bindoffsets);
+ if (mmd->dynverts) MEM_freeN(mmd->dynverts);
+ if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */
+ if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */
mmd->bindcagecos= NULL;
mmd->dyngrid= NULL;
@@ -1430,17 +1362,17 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
mmd->bindfunc= mesh_deform_bind;
mmd->modifier.mode |= eModifierMode_Realtime;
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
dm= mesh_create_derived_view(scene, ob, 0);
dm->release(dm);
}
- else if(ob->type == OB_LATTICE) {
+ else if (ob->type == OB_LATTICE) {
lattice_calc_modifiers(scene, ob);
}
- else if(ob->type==OB_MBALL) {
+ else if (ob->type==OB_MBALL) {
makeDispListMBall(scene, ob);
}
- else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+ else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
makeDispListCurveTypes(scene, ob, 0);
}
@@ -1462,17 +1394,17 @@ static int meshdeform_bind_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
void OBJECT_OT_meshdeform_bind(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Mesh Deform Bind";
+ ot->name = "Mesh Deform Bind";
ot->description = "Bind mesh to cage in mesh deform modifier";
- ot->idname= "OBJECT_OT_meshdeform_bind";
+ ot->idname = "OBJECT_OT_meshdeform_bind";
/* api callbacks */
- ot->poll= meshdeform_poll;
- ot->invoke= meshdeform_bind_invoke;
- ot->exec= meshdeform_bind_exec;
+ ot->poll = meshdeform_poll;
+ ot->invoke = meshdeform_bind_invoke;
+ ot->exec = meshdeform_bind_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -1510,16 +1442,16 @@ static int explode_refresh_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
void OBJECT_OT_explode_refresh(wmOperatorType *ot)
{
- ot->name= "Explode Refresh";
- ot->description= "Refresh data in the Explode modifier";
- ot->idname= "OBJECT_OT_explode_refresh";
+ ot->name = "Explode Refresh";
+ ot->description = "Refresh data in the Explode modifier";
+ ot->idname = "OBJECT_OT_explode_refresh";
- ot->poll= explode_poll;
- ot->invoke= explode_refresh_invoke;
- ot->exec= explode_refresh_exec;
+ ot->poll = explode_poll;
+ ot->invoke = explode_refresh_invoke;
+ ot->exec = explode_refresh_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
}
@@ -1654,8 +1586,8 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
/* precalculate time variable before baking */
for (f=omd->bakestart; f<=omd->bakeend; f++) {
/* from physics_fluid.c:
-
- * XXX: This can't be used due to an anim sys optimisation that ignores recalc object animation,
+ *
+ * XXX: This can't be used due to an anim sys optimization that ignores recalc object animation,
* leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
* --> BKE_animsys_evaluate_all_animation(G.main, eval_time);
* This doesn't work with drivers:
@@ -1680,7 +1612,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
ocean = BKE_add_ocean();
init_ocean_modifier_bake(ocean, omd);
- /*
+#if 0
BKE_bake_ocean(ocean, och);
omd->oceancache = och;
@@ -1690,7 +1622,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- */
+#endif
/* job stuff */
@@ -1725,16 +1657,16 @@ static int ocean_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
void OBJECT_OT_ocean_bake(wmOperatorType *ot)
{
- ot->name= "Bake Ocean";
- ot->description= "Bake an image sequence of ocean data";
- ot->idname= "OBJECT_OT_ocean_bake";
+ ot->name = "Bake Ocean";
+ ot->description = "Bake an image sequence of ocean data";
+ ot->idname = "OBJECT_OT_ocean_bake";
- ot->poll= ocean_bake_poll;
- ot->invoke= ocean_bake_invoke;
- ot->exec= ocean_bake_exec;
+ ot->poll = ocean_bake_poll;
+ ot->invoke = ocean_bake_invoke;
+ ot->exec = ocean_bake_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
edit_modifier_properties(ot);
RNA_def_boolean(ot->srna, "free", FALSE, "Free", "Free the bake, rather than generating it");
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 4307bd71c1b..115d452fd4e 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -215,8 +215,6 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_bake_image);
WM_operatortype_append(OBJECT_OT_drop_named_material);
-
- WM_operatortype_append(OBJECT_OT_test_multires);
}
void ED_operatormacros_object(void)
@@ -224,27 +222,27 @@ void ED_operatormacros_object(void)
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
- ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER);
- if(ot) {
+ ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER);
+ if (ot) {
ot->description = "Duplicate selected objects and move them";
WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
- otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
}
/* grr, should be able to pass options on... */
- ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO|OPTYPE_REGISTER);
- if(ot) {
+ ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO|OPTYPE_REGISTER);
+ if (ot) {
ot->description = "Duplicate selected objects and move them";
- otmacro= WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
+ otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
RNA_boolean_set(otmacro->ptr, "linked", TRUE);
- otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+ otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
}
/* XXX */
- ot= WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER);
- if(ot) {
+ ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER);
+ if (ot) {
ot->description = "Add named object at cursor";
RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add");
@@ -266,7 +264,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
int i;
/* Objects, Regardless of Mode -------------------------------------------------- */
- keymap= WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
+ keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
/* Note: this keymap works disregarding mode */
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
@@ -289,8 +287,8 @@ void ED_keymap_object(wmKeyConfig *keyconf)
/* Object Mode ---------------------------------------------------------------- */
/* Note: this keymap gets disabled in non-objectmode, */
- keymap= WM_keymap_find(keyconf, "Object Mode", 0, 0);
- keymap->poll= object_mode_poll;
+ keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0);
+ keymap->poll = object_mode_poll;
/* object mode supports PET now */
ED_object_generic_keymap(keyconf, keymap, 1);
@@ -394,7 +392,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0);
- for(i=0; i<=5; i++) {
+ for (i=0; i<=5; i++) {
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0);
RNA_int_set(kmi->ptr, "level", i);
}
@@ -403,11 +401,14 @@ void ED_keymap_object(wmKeyConfig *keyconf)
/* ################################ LATTICE ################################### */
/* ############################################################################ */
- keymap= WM_keymap_find(keyconf, "Lattice", 0, 0);
- keymap->poll= ED_operator_editlattice;
+ keymap = WM_keymap_find(keyconf, "Lattice", 0, 0);
+ keymap->poll = ED_operator_editlattice;
+
+ kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+ kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
- WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0);
-
WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
/* menus */
@@ -421,7 +422,7 @@ void ED_object_generic_keymap(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyM
wmKeyMapItem *kmi;
/* used by mesh, curve & lattice only */
- if(do_pet) {
+ if (do_pet) {
/* context ops */
kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit_falloff");
@@ -432,7 +433,8 @@ void ED_object_generic_keymap(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyM
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_objects");
- } else { // Edit mode
+ }
+ else { // Edit mode
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 1e075fd4d43..57d0de522a1 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -124,46 +124,46 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* we need 1 to 3 selected vertices */
- if(obedit->type==OB_MESH) {
+ if (obedit->type==OB_MESH) {
Mesh *me= obedit->data;
BMEditMesh *em;
- EDBM_LoadEditBMesh(scene, obedit);
- EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit);
+ EDBM_mesh_load(obedit);
+ EDBM_mesh_make(scene->toolsettings, scene, obedit);
em= me->edit_btmesh;
/* derivedMesh might be needed for solving parenting,
- so re-create it here */
+ * so re-create it here */
makeDerivedMesh(scene, obedit, em, CD_MASK_BAREMESH, 0);
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- if(v1==0) v1= nr;
- else if(v2==0) v2= nr;
- else if(v3==0) v3= nr;
- else if(v4==0) v4= nr;
+ if (v1==0) v1= nr;
+ else if (v2==0) v2= nr;
+ else if (v3==0) v3= nr;
+ else if (v4==0) v4= nr;
else break;
}
nr++;
}
}
- else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) {
+ else if (ELEM(obedit->type, OB_SURF, OB_CURVE)) {
ListBase *editnurb= object_editcurve_get(obedit);
cu= obedit->data;
nu= editnurb->first;
- while(nu) {
- if(nu->type == CU_BEZIER) {
+ while (nu) {
+ if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while(a--) {
- if(BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
- if(v1==0) v1= nr;
- else if(v2==0) v2= nr;
- else if(v3==0) v3= nr;
- else if(v4==0) v4= nr;
+ while (a--) {
+ if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) {
+ if (v1==0) v1= nr;
+ else if (v2==0) v2= nr;
+ else if (v3==0) v3= nr;
+ else if (v4==0) v4= nr;
else break;
}
nr++;
@@ -173,12 +173,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
else {
bp= nu->bp;
a= nu->pntsu*nu->pntsv;
- while(a--) {
- if(bp->f1 & SELECT) {
- if(v1==0) v1= nr;
- else if(v2==0) v2= nr;
- else if(v3==0) v3= nr;
- else if(v4==0) v4= nr;
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ if (v1==0) v1= nr;
+ else if (v2==0) v2= nr;
+ else if (v3==0) v3= nr;
+ else if (v4==0) v4= nr;
else break;
}
nr++;
@@ -188,17 +188,17 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
nu= nu->next;
}
}
- else if(obedit->type==OB_LATTICE) {
+ else if (obedit->type==OB_LATTICE) {
Lattice *lt= obedit->data;
a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw;
bp= lt->editlatt->latt->def;
- while(a--) {
- if(bp->f1 & SELECT) {
- if(v1==0) v1= nr;
- else if(v2==0) v2= nr;
- else if(v3==0) v3= nr;
- else if(v4==0) v4= nr;
+ while (a--) {
+ if (bp->f1 & SELECT) {
+ if (v1==0) v1= nr;
+ else if (v2==0) v2= nr;
+ else if (v3==0) v3= nr;
+ else if (v4==0) v4= nr;
else break;
}
nr++;
@@ -206,28 +206,28 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
}
}
- if(v4 || !((v1 && v2==0 && v3==0) || (v1 && v2 && v3)) ) {
+ if (v4 || !((v1 && v2==0 && v3==0) || (v1 && v2 && v3)) ) {
BKE_report(op->reports, RPT_ERROR, "Select either 1 or 3 vertices to parent to");
return OPERATOR_CANCELLED;
}
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob != obedit) {
+ if (ob != obedit) {
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
par= obedit->parent;
- while(par) {
- if(par==ob) break;
+ while (par) {
+ if (par==ob) break;
par= par->parent;
}
- if(par) {
+ if (par) {
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
}
else {
Object workob;
ob->parent= BASACT->object;
- if(v3) {
+ if (v3) {
ob->partype= PARVERT3;
ob->par1= v1-1;
ob->par2= v2-1;
@@ -260,17 +260,17 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_parent_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Make Vertex Parent";
+ ot->name = "Make Vertex Parent";
ot->description = "Parent selected objects to the selected vertices";
- ot->idname= "OBJECT_OT_vertex_parent_set";
+ ot->idname = "OBJECT_OT_vertex_parent_set";
/* api callbacks */
- ot->invoke= WM_operator_confirm;
- ot->poll= vertex_parent_set_poll;
- ot->exec= vertex_parent_set_exec;
+ ot->invoke = WM_operator_confirm;
+ ot->poll = vertex_parent_set_poll;
+ ot->exec = vertex_parent_set_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/********************** Make Proxy Operator *************************/
@@ -319,13 +319,11 @@ static int make_proxy_exec (bContext *C, wmOperator *op)
GroupObject *go;
Scene *scene= CTX_data_scene(C);
- if (gob->dup_group != NULL)
- {
+ if (gob->dup_group != NULL) {
go= BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "object"));
ob= go->ob;
}
- else
- {
+ else {
ob= gob;
gob = NULL;
}
@@ -377,7 +375,7 @@ static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSE
Object *ob= ED_object_active_context(C);
GroupObject *go;
- if(!ob || !ob->dup_group)
+ if (!ob || !ob->dup_group)
return DummyRNA_DEFAULT_items;
/* find the object to affect */
@@ -398,22 +396,22 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Make Proxy";
- ot->idname= "OBJECT_OT_proxy_make";
- ot->description= "Add empty object to become local replacement data of a library-linked object";
+ ot->name = "Make Proxy";
+ ot->idname = "OBJECT_OT_proxy_make";
+ ot->description = "Add empty object to become local replacement data of a library-linked object";
/* callbacks */
- ot->invoke= make_proxy_invoke;
- ot->exec= make_proxy_exec;
- ot->poll= ED_operator_object_active;
+ ot->invoke = make_proxy_invoke;
+ ot->exec = make_proxy_exec;
+ ot->poll = ED_operator_object_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */
RNA_def_enum_funcs(prop, proxy_group_object_itemf);
- ot->prop= prop;
+ ot->prop = prop;
}
/********************** Clear Parent Operator ******************* */
@@ -432,17 +430,17 @@ void ED_object_parent_clear(bContext *C, int type)
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
{
- if(ob->parent == NULL)
+ if (ob->parent == NULL)
continue;
- if(type == 0) {
+ if (type == 0) {
ob->parent= NULL;
}
- else if(type == 1) {
+ else if (type == 1) {
ob->parent= NULL;
object_apply_mat4(ob, ob->obmat, TRUE, FALSE);
}
- else if(type == 2)
+ else if (type == 2)
unit_m4(ob->parentinv);
ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
@@ -466,20 +464,20 @@ static int parent_clear_exec(bContext *C, wmOperator *op)
void OBJECT_OT_parent_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Parent";
+ ot->name = "Clear Parent";
ot->description = "Clear the object's parenting";
- ot->idname= "OBJECT_OT_parent_clear";
+ ot->idname = "OBJECT_OT_parent_clear";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= parent_clear_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = parent_clear_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
- ot->prop= RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", "");
}
/* ******************** Make Parent Operator *********************** */
@@ -526,38 +524,38 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
par->recalc |= OB_RECALC_OB;
/* preconditions */
- if(partype==PAR_FOLLOW || partype==PAR_PATH_CONST) {
- if(par->type!=OB_CURVE)
+ if (partype==PAR_FOLLOW || partype==PAR_PATH_CONST) {
+ if (par->type!=OB_CURVE)
return 0;
else {
Curve *cu= par->data;
- if((cu->flag & CU_PATH)==0) {
+ if ((cu->flag & CU_PATH)==0) {
cu->flag |= CU_PATH|CU_FOLLOW;
makeDispListCurveTypes(scene, par, 0); /* force creation of path data */
}
else cu->flag |= CU_FOLLOW;
/* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */
- if(partype == PAR_FOLLOW) {
+ if (partype == PAR_FOLLOW) {
/* get or create F-Curve */
bAction *act = verify_adt_action(&cu->id, 1);
FCurve *fcu = verify_fcurve(act, NULL, "eval_time", 0, 1);
- /* setup dummy 'generator' modifier here to get 1-1 correspondance still working */
+ /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */
if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first)
add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
}
/* fall back on regular parenting now (for follow only) */
- if(partype == PAR_FOLLOW)
+ if (partype == PAR_FOLLOW)
partype= PAR_OBJECT;
}
}
- else if(partype==PAR_BONE) {
+ else if (partype==PAR_BONE) {
pchan= get_active_posechannel(par);
- if(pchan==NULL) {
+ if (pchan==NULL) {
BKE_report(reports, RPT_ERROR, "No active Bone");
return 0;
}
@@ -588,8 +586,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
if (partype == PAR_PATH_CONST) {
/* don't do anything here, since this is not technically "parenting" */
}
- else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm))
- {
+ else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm)) {
/* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created
* NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers
*/
@@ -598,8 +595,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
/* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */
// XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet
- if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE))
- {
+ if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) {
ModifierData *md;
switch (partype) {
@@ -624,7 +620,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
ob->partype= PAROBJECT; /* note, dna define, not operator property */
/* constraint */
- if(partype == PAR_PATH_CONST) {
+ if (partype == PAR_PATH_CONST) {
bConstraint *con;
bFollowPathConstraint *data;
float cmat[4][4], vec[3];
@@ -641,12 +637,12 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
ob->loc[1] = vec[1];
ob->loc[2] = vec[2];
}
- else if(pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) {
- if(partype == PAR_ARMATURE_NAME)
+ else if (pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) {
+ if (partype == PAR_ARMATURE_NAME)
create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_NAME, 0);
- else if(partype == PAR_ARMATURE_ENVELOPE)
+ else if (partype == PAR_ARMATURE_ENVELOPE)
create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_ENVELOPE, 0);
- else if(partype == PAR_ARMATURE_AUTO) {
+ else if (partype == PAR_ARMATURE_AUTO) {
WM_cursor_wait(1);
create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_AUTO, 0);
WM_cursor_wait(0);
@@ -709,19 +705,19 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSE
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_OBJECT);
/* ob becomes parent, make the associated menus */
- if(ob->type==OB_ARMATURE) {
+ if (ob->type==OB_ARMATURE) {
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_NAME);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_ENVELOPE);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_AUTO);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_BONE);
}
- else if(ob->type==OB_CURVE) {
+ else if (ob->type==OB_CURVE) {
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_CURVE);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_FOLLOW);
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_PATH_CONST);
}
- else if(ob->type == OB_LATTICE) {
+ else if (ob->type == OB_LATTICE) {
uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_LATTICE);
}
@@ -734,18 +730,18 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSE
void OBJECT_OT_parent_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Make Parent";
+ ot->name = "Make Parent";
ot->description = "Set the object's parenting";
- ot->idname= "OBJECT_OT_parent_set";
+ ot->idname = "OBJECT_OT_parent_set";
/* api callbacks */
- ot->invoke= parent_set_invoke;
- ot->exec= parent_set_exec;
+ ot->invoke = parent_set_invoke;
+ ot->exec = parent_set_exec;
- ot->poll= ED_operator_object_active;
+ ot->poll = ED_operator_object_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", "");
}
@@ -791,17 +787,17 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Make Parent without Inverse";
+ ot->name = "Make Parent without Inverse";
ot->description = "Set the object's parenting without setting the inverse parent correction";
- ot->idname= "OBJECT_OT_parent_no_inverse_set";
+ ot->idname = "OBJECT_OT_parent_no_inverse_set";
/* api callbacks */
- ot->invoke= WM_operator_confirm;
- ot->exec= parent_noinv_set_exec;
- ot->poll= ED_operator_object_active_editable;
+ ot->invoke = WM_operator_confirm;
+ ot->exec = parent_noinv_set_exec;
+ ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/************************ Clear Slow Parent Operator *********************/
@@ -812,8 +808,8 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene= CTX_data_scene(C);
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob->parent) {
- if(ob->partype & PARSLOW) {
+ if (ob->parent) {
+ if (ob->partype & PARSLOW) {
ob->partype -= PARSLOW;
where_is_object(scene, ob);
ob->partype |= PARSLOW;
@@ -833,17 +829,17 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Slow Parent";
+ ot->name = "Clear Slow Parent";
ot->description = "Clear the object's slow parent";
- ot->idname= "OBJECT_OT_slow_parent_clear";
+ ot->idname = "OBJECT_OT_slow_parent_clear";
/* api callbacks */
- ot->invoke= WM_operator_confirm;
- ot->exec= object_slow_parent_clear_exec;
- ot->poll= ED_operator_view3d_active;
+ ot->invoke = WM_operator_confirm;
+ ot->exec = object_slow_parent_clear_exec;
+ ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/********************** Make Slow Parent Operator *********************/
@@ -854,7 +850,7 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene= CTX_data_scene(C);
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob->parent)
+ if (ob->parent)
ob->partype |= PARSLOW;
ob->recalc |= OB_RECALC_OB;
@@ -872,17 +868,17 @@ void OBJECT_OT_slow_parent_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Set Slow Parent";
+ ot->name = "Set Slow Parent";
ot->description = "Set the object's slow parent";
- ot->idname= "OBJECT_OT_slow_parent_set";
+ ot->idname = "OBJECT_OT_slow_parent_set";
/* api callbacks */
- ot->invoke= WM_operator_confirm;
- ot->exec= object_slow_parent_set_exec;
- ot->poll= ED_operator_view3d_active;
+ ot->invoke = WM_operator_confirm;
+ ot->exec = object_slow_parent_set_exec;
+ ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ******************** Clear Track Operator ******************* */
@@ -900,7 +896,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
int type= RNA_enum_get(op->ptr, "type");
- if(CTX_data_edit_object(C)) {
+ if (CTX_data_edit_object(C)) {
BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
return OPERATOR_CANCELLED;
}
@@ -918,7 +914,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
remove_constraint(&ob->constraints, con);
}
- if(type == 1)
+ if (type == 1)
object_apply_mat4(ob, ob->obmat, TRUE, TRUE);
}
CTX_DATA_END;
@@ -933,20 +929,20 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
void OBJECT_OT_track_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear track";
+ ot->name = "Clear track";
ot->description = "Clear tracking constraint or flag from object";
- ot->idname= "OBJECT_OT_track_clear";
+ ot->idname = "OBJECT_OT_track_clear";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_track_clear_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_track_clear_exec;
- ot->poll= ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
- ot->prop= RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", "");
}
/************************** Make Track Operator *****************************/
@@ -966,12 +962,12 @@ static int track_set_exec(bContext *C, wmOperator *op)
int type= RNA_enum_get(op->ptr, "type");
- if(type == 1) {
+ if (type == 1) {
bConstraint *con;
bDampTrackConstraint *data;
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob!=obact) {
+ if (ob!=obact) {
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK);
data = con->data;
@@ -985,12 +981,12 @@ static int track_set_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
- else if(type == 2) {
+ else if (type == 2) {
bConstraint *con;
bTrackToConstraint *data;
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob!=obact) {
+ if (ob!=obact) {
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO);
data = con->data;
@@ -1006,12 +1002,12 @@ static int track_set_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
- else if(type == 3) {
+ else if (type == 3) {
bConstraint *con;
bLockTrackConstraint *data;
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob!=obact) {
+ if (ob!=obact) {
con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK);
data = con->data;
@@ -1038,21 +1034,21 @@ static int track_set_exec(bContext *C, wmOperator *op)
void OBJECT_OT_track_set(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Make Track";
+ ot->name = "Make Track";
ot->description = "Make the object track another object, either by constraint or old way or locked track";
- ot->idname= "OBJECT_OT_track_set";
+ ot->idname = "OBJECT_OT_track_set";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= track_set_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = track_set_exec;
- ot->poll= ED_operator_objectmode;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", "");
}
/************************** Move to Layer Operator *****************************/
@@ -1062,14 +1058,14 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op)
int values[20], a;
unsigned int lay= 0;
- if(!RNA_struct_property_is_set(op->ptr, "layers")) {
+ if (!RNA_struct_property_is_set(op->ptr, "layers")) {
/* note: layers are set in bases, library objects work for this */
CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
lay |= base->lay;
}
CTX_DATA_END;
- for(a=0; a<20; a++)
+ for (a=0; a<20; a++)
values[a]= (lay & (1<<a));
RNA_boolean_set_array(op->ptr, "layers", values);
@@ -1077,8 +1073,8 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op)
else {
RNA_boolean_get_array(op->ptr, "layers", values);
- for(a=0; a<20; a++)
- if(values[a])
+ for (a=0; a<20; a++)
+ if (values[a])
lay |= (1 << a);
}
@@ -1088,7 +1084,7 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op)
static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
View3D *v3d= CTX_wm_view3d(C);
- if(v3d && v3d->localvd) {
+ if (v3d && v3d->localvd) {
return WM_operator_confirm_message(C, op, "Move from localview");
}
else {
@@ -1108,9 +1104,9 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
lay= move_to_layer_init(C, op);
lay &= 0xFFFFFF;
- if(lay==0) return OPERATOR_CANCELLED;
+ if (lay==0) return OPERATOR_CANCELLED;
- if(v3d && v3d->localvd) {
+ if (v3d && v3d->localvd) {
/* now we can move out of localview. */
/* note: layers are set in bases, library objects work for this */
CTX_DATA_BEGIN(C, Base*, base, selected_bases) {
@@ -1119,7 +1115,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
base->object->lay= lay;
base->object->flag &= ~SELECT;
base->flag &= ~SELECT;
- /* if(base->object->type==OB_LAMP) islamp= 1; */
+ /* if (base->object->type==OB_LAMP) islamp= 1; */
}
CTX_DATA_END;
}
@@ -1131,7 +1127,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
local= base->lay & 0xFF000000;
base->lay= lay + local;
base->object->lay= lay;
- /* if(base->object->type==OB_LAMP) islamp= 1; */
+ /* if (base->object->type==OB_LAMP) islamp= 1; */
}
CTX_DATA_END;
}
@@ -1149,17 +1145,17 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
void OBJECT_OT_move_to_layer(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Move to Layer";
+ ot->name = "Move to Layer";
ot->description = "Move the object to different layers";
- ot->idname= "OBJECT_OT_move_to_layer";
+ ot->idname = "OBJECT_OT_move_to_layer";
/* api callbacks */
- ot->invoke= move_to_layer_invoke;
- ot->exec= move_to_layer_exec;
- ot->poll= ED_operator_objectmode;
+ ot->invoke = move_to_layer_invoke;
+ ot->exec = move_to_layer_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", "");
@@ -1173,11 +1169,11 @@ static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr))
Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1);
Base *base, *nbase;
- if(sce==0) return;
- if(sce->id.lib) return;
+ if (sce==0) return;
+ if (sce->id.lib) return;
- for(base= FIRSTBASE; base; base= base->next) {
- if(TESTBASE(v3d, base)) {
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (TESTBASE(v3d, base)) {
nbase= MEM_mallocN( sizeof(Base), "newbase");
*nbase= *base;
@@ -1193,24 +1189,24 @@ static int make_links_scene_exec(bContext *C, wmOperator *op)
Main *bmain= CTX_data_main(C);
Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
- if(scene_to==NULL) {
+ if (scene_to==NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene not found");
return OPERATOR_CANCELLED;
}
- if(scene_to == CTX_data_scene(C)) {
+ if (scene_to == CTX_data_scene(C)) {
BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene");
return OPERATOR_CANCELLED;
}
- if(scene_to->id.lib) {
+ if (scene_to->id.lib) {
BKE_report(op->reports, RPT_ERROR, "Can't link objects into a linked scene");
return OPERATOR_CANCELLED;
}
CTX_DATA_BEGIN(C, Base*, base, selected_bases)
{
- if(!object_in_scene(base->object, scene_to)) {
+ if (!object_in_scene(base->object, scene_to)) {
Base *nbase= MEM_mallocN( sizeof(Base), "newbase");
*nbase= *base;
BLI_addhead( &(scene_to->base), nbase);
@@ -1270,7 +1266,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
ob= ED_object_active_context(C);
CTX_DATA_BEGIN(C, Object*, obt, selected_editable_objects) {
- if(ob != obt) {
+ if (ob != obt) {
if (allow_make_links_data(event, ob, obt)) {
switch(event) {
case MAKE_LINKS_OBDATA: /* obdata */
@@ -1288,7 +1284,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
case MAKE_LINKS_MATERIALS:
/* new approach, using functions from kernel */
- for(a=0; a<ob->totcol; a++) {
+ for (a=0; a<ob->totcol; a++) {
Material *ma= give_current_material(ob, a+1);
assign_material(obt, ma, a+1); /* also works with ma==NULL */
}
@@ -1299,7 +1295,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
case MAKE_LINKS_DUPLIGROUP:
obt->dup_group= ob->dup_group;
- if(obt->dup_group) {
+ if (obt->dup_group) {
id_lib_extern(&obt->dup_group->id);
obt->transflag |= OB_DUPLIGROUP;
}
@@ -1327,22 +1323,22 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Link Objects to Scene";
+ ot->name = "Link Objects to Scene";
ot->description = "Link selection to another scene";
- ot->idname= "OBJECT_OT_make_links_scene";
+ ot->idname = "OBJECT_OT_make_links_scene";
/* api callbacks */
- ot->invoke= WM_enum_search_invoke;
- ot->exec= make_links_scene_exec;
+ ot->invoke = WM_enum_search_invoke;
+ ot->exec = make_links_scene_exec;
/* better not run the poll check */
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
RNA_def_enum_funcs(prop, RNA_scene_local_itemf);
- ot->prop= prop;
+ ot->prop = prop;
}
void OBJECT_OT_make_links_data(wmOperatorType *ot)
@@ -1356,19 +1352,19 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL}};
/* identifiers */
- ot->name= "Link Data";
+ ot->name = "Link Data";
ot->description = "Make links from the active object to other selected objects";
- ot->idname= "OBJECT_OT_make_links_data";
+ ot->idname = "OBJECT_OT_make_links_data";
/* api callbacks */
- ot->exec= make_links_data_exec;
- ot->poll= ED_operator_object_active;
+ ot->exec = make_links_data_exec;
+ ot->poll = ED_operator_object_active;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", make_links_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", make_links_items, 0, "Type", "");
}
@@ -1382,7 +1378,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag)
clear_sca_new_poins(); /* sensor/contr/act */
/* duplicate (must set newid) */
- for(base= FIRSTBASE; base; base= base->next) {
+ for (base= FIRSTBASE; base; base= base->next) {
ob= base->object;
/* newid may still have some trash from Outliner tree building,
@@ -1390,8 +1386,8 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag)
*/
ob->id.newid = NULL;
- if( (base->flag & flag)==flag ) {
- if(ob->id.lib==NULL && ob->id.us>1) {
+ if ( (base->flag & flag)==flag ) {
+ if (ob->id.lib==NULL && ob->id.us>1) {
/* base gets copy of object */
obn= copy_object(ob);
base->object= obn;
@@ -1401,10 +1397,10 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag)
}
ID_NEW(scene->camera);
- if(v3d) ID_NEW(v3d->camera);
+ if (v3d) ID_NEW(v3d->camera);
/* object pointers */
- for(base= FIRSTBASE; base; base= base->next) {
+ for (base= FIRSTBASE; base; base= base->next) {
object_relink(base->object);
}
@@ -1417,8 +1413,8 @@ void ED_object_single_user(Scene *scene, Object *ob)
{
Base *base;
- for(base= FIRSTBASE; base; base= base->next) {
- if(base->object == ob) base->flag |= OB_DONE;
+ for (base= FIRSTBASE; base; base= base->next) {
+ if (base->object == ob) base->flag |= OB_DONE;
else base->flag &= ~OB_DONE;
}
@@ -1430,15 +1426,15 @@ static void new_id_matar(Material **matar, int totcol)
ID *id;
int a;
- for(a=0; a<totcol; a++) {
+ for (a=0; a<totcol; a++) {
id= (ID *)matar[a];
- if(id && id->lib == NULL) {
- if(id->newid) {
+ if (id && id->lib == NULL) {
+ if (id->newid) {
matar[a]= (Material *)id->newid;
id_us_plus(id->newid);
id->us--;
}
- else if(id->us>1) {
+ else if (id->us>1) {
matar[a]= copy_material(matar[a]);
id->us--;
id->newid= (ID *)matar[a];
@@ -1458,12 +1454,12 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
ID *id;
int a;
- for(base= FIRSTBASE; base; base= base->next) {
+ for (base= FIRSTBASE; base; base= base->next) {
ob= base->object;
- if(ob->id.lib==NULL && (base->flag & flag)==flag ) {
+ if (ob->id.lib==NULL && (base->flag & flag)==flag ) {
id= ob->data;
- if(id && id->us>1 && id->lib==NULL) {
+ if (id && id->us>1 && id->lib==NULL) {
ob->recalc= OB_RECALC_DATA;
BKE_copy_animdata_id_action(id);
@@ -1471,8 +1467,8 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
switch(ob->type) {
case OB_LAMP:
ob->data= la= copy_lamp(ob->data);
- for(a=0; a<MAX_MTEX; a++) {
- if(la->mtex[a]) {
+ for (a=0; a<MAX_MTEX; a++) {
+ if (la->mtex[a]) {
ID_NEW(la->mtex[a]->object);
}
}
@@ -1508,8 +1504,8 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
ob->data= copy_speaker(ob->data);
break;
default:
- if (G.f & G_DEBUG)
- printf("ERROR single_obdata_users: can't copy %s\n", id->name);
+ if (G.debug & G_DEBUG)
+ printf("ERROR %s: can't copy %s\n", __func__, id->name);
return;
}
@@ -1522,7 +1518,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
}
me= bmain->mesh.first;
- while(me) {
+ while (me) {
ID_NEW(me->texcomesh);
me= me->id.next;
}
@@ -1533,9 +1529,9 @@ static void single_object_action_users(Scene *scene, int flag)
Object *ob;
Base *base;
- for(base= FIRSTBASE; base; base= base->next) {
+ for (base= FIRSTBASE; base; base= base->next) {
ob= base->object;
- if(ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
+ if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
ob->recalc= OB_RECALC_DATA;
BKE_copy_animdata_id_action(&ob->id);
}
@@ -1550,26 +1546,26 @@ static void single_mat_users(Scene *scene, int flag, int do_textures)
Tex *tex;
int a, b;
- for(base= FIRSTBASE; base; base= base->next) {
+ for (base= FIRSTBASE; base; base= base->next) {
ob= base->object;
- if(ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
+ if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) {
- for(a=1; a<=ob->totcol; a++) {
+ for (a=1; a<=ob->totcol; a++) {
ma= give_current_material(ob, a);
- if(ma) {
+ if (ma) {
/* do not test for LIB_NEW: this functions guaranteed delivers single_users! */
- if(ma->id.us>1) {
+ if (ma->id.us>1) {
man= copy_material(ma);
BKE_copy_animdata_id_action(&man->id);
man->id.us= 0;
assign_material(ob, man, a);
- if(do_textures) {
- for(b=0; b<MAX_MTEX; b++) {
- if(ma->mtex[b] && (tex= ma->mtex[b]->tex)) {
- if(tex->id.us>1) {
+ if (do_textures) {
+ for (b=0; b<MAX_MTEX; b++) {
+ if (ma->mtex[b] && (tex= ma->mtex[b]->tex)) {
+ if (tex->id.us>1) {
tex->id.us--;
tex= copy_texture(tex);
BKE_copy_animdata_id_action(&tex->id);
@@ -1590,14 +1586,14 @@ static void do_single_tex_user(Tex **from)
Tex *tex, *texn;
tex= *from;
- if(tex==NULL) return;
+ if (tex==NULL) return;
- if(tex->id.newid) {
+ if (tex->id.newid) {
*from= (Tex *)tex->id.newid;
id_us_plus(tex->id.newid);
tex->id.us--;
}
- else if(tex->id.us>1) {
+ else if (tex->id.us>1) {
texn= copy_texture(tex);
BKE_copy_animdata_id_action(&texn->id);
tex->id.newid= (ID *)texn;
@@ -1614,30 +1610,30 @@ static void single_tex_users_expand(Main *bmain)
World *wo;
int b;
- for(ma= bmain->mat.first; ma; ma=ma->id.next) {
- if(ma->id.flag & LIB_NEW) {
- for(b=0; b<MAX_MTEX; b++) {
- if(ma->mtex[b] && ma->mtex[b]->tex) {
+ for (ma= bmain->mat.first; ma; ma=ma->id.next) {
+ if (ma->id.flag & LIB_NEW) {
+ for (b=0; b<MAX_MTEX; b++) {
+ if (ma->mtex[b] && ma->mtex[b]->tex) {
do_single_tex_user( &(ma->mtex[b]->tex) );
}
}
}
}
- for(la= bmain->lamp.first; la; la=la->id.next) {
- if(la->id.flag & LIB_NEW) {
- for(b=0; b<MAX_MTEX; b++) {
- if(la->mtex[b] && la->mtex[b]->tex) {
+ for (la= bmain->lamp.first; la; la=la->id.next) {
+ if (la->id.flag & LIB_NEW) {
+ for (b=0; b<MAX_MTEX; b++) {
+ if (la->mtex[b] && la->mtex[b]->tex) {
do_single_tex_user( &(la->mtex[b]->tex) );
}
}
}
}
- for(wo= bmain->world.first; wo; wo=wo->id.next) {
- if(wo->id.flag & LIB_NEW) {
- for(b=0; b<MAX_MTEX; b++) {
- if(wo->mtex[b] && wo->mtex[b]->tex) {
+ for (wo= bmain->world.first; wo; wo=wo->id.next) {
+ if (wo->id.flag & LIB_NEW) {
+ for (b=0; b<MAX_MTEX; b++) {
+ if (wo->mtex[b] && wo->mtex[b]->tex) {
do_single_tex_user( &(wo->mtex[b]->tex) );
}
}
@@ -1655,27 +1651,27 @@ static void single_mat_users_expand(Main *bmain)
Material *ma;
int a;
- for(ob=bmain->object.first; ob; ob=ob->id.next)
- if(ob->id.flag & LIB_NEW)
+ for (ob=bmain->object.first; ob; ob=ob->id.next)
+ if (ob->id.flag & LIB_NEW)
new_id_matar(ob->mat, ob->totcol);
- for(me=bmain->mesh.first; me; me=me->id.next)
- if(me->id.flag & LIB_NEW)
+ for (me=bmain->mesh.first; me; me=me->id.next)
+ if (me->id.flag & LIB_NEW)
new_id_matar(me->mat, me->totcol);
- for(cu=bmain->curve.first; cu; cu=cu->id.next)
- if(cu->id.flag & LIB_NEW)
+ for (cu=bmain->curve.first; cu; cu=cu->id.next)
+ if (cu->id.flag & LIB_NEW)
new_id_matar(cu->mat, cu->totcol);
- for(mb=bmain->mball.first; mb; mb=mb->id.next)
- if(mb->id.flag & LIB_NEW)
+ for (mb=bmain->mball.first; mb; mb=mb->id.next)
+ if (mb->id.flag & LIB_NEW)
new_id_matar(mb->mat, mb->totcol);
/* material imats */
- for(ma=bmain->mat.first; ma; ma=ma->id.next)
- if(ma->id.flag & LIB_NEW)
- for(a=0; a<MAX_MTEX; a++)
- if(ma->mtex[a])
+ for (ma=bmain->mat.first; ma; ma=ma->id.next)
+ if (ma->id.flag & LIB_NEW)
+ for (a=0; a<MAX_MTEX; a++)
+ if (ma->mtex[a])
ID_NEW(ma->mtex[a]->object);
}
@@ -1684,7 +1680,7 @@ void ED_object_single_users(Main *bmain, Scene *scene, int full)
{
single_object_users(scene, NULL, 0);
- if(full) {
+ if (full) {
single_obdata_users(bmain, scene, 0);
single_object_action_users(scene, 0);
single_mat_users_expand(bmain);
@@ -1704,12 +1700,12 @@ static void make_local_makelocalmaterial(Material *ma)
id_make_local(&ma->id, 0);
- for(b=0; b<MAX_MTEX; b++)
- if(ma->mtex[b] && ma->mtex[b]->tex)
+ for (b=0; b<MAX_MTEX; b++)
+ if (ma->mtex[b] && ma->mtex[b]->tex)
id_make_local(&ma->mtex[b]->tex->id, 0);
adt= BKE_animdata_from_id(&ma->id);
- if(adt) BKE_animdata_make_local(adt);
+ if (adt) BKE_animdata_make_local(adt);
/* nodetree? XXX */
}
@@ -1724,7 +1720,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
ID *id;
int a, b, mode= RNA_enum_get(op->ptr, "type");
- if(mode==3) {
+ if (mode==3) {
BKE_library_make_local(bmain, NULL, 0); /* NULL is all libs */
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
@@ -1733,14 +1729,14 @@ static int make_local_exec(bContext *C, wmOperator *op)
clear_id_newpoins();
CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
- if(ob->id.lib)
+ if (ob->id.lib)
id_make_local(&ob->id, 0);
}
CTX_DATA_END;
/* maybe object pointers */
CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
- if(ob->id.lib==NULL) {
+ if (ob->id.lib==NULL) {
ID_NEW(ob->parent);
}
}
@@ -1749,51 +1745,51 @@ static int make_local_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
id= ob->data;
- if(id && mode>1) {
+ if (id && mode>1) {
id_make_local(id, 0);
adt= BKE_animdata_from_id(id);
- if(adt) BKE_animdata_make_local(adt);
+ if (adt) BKE_animdata_make_local(adt);
/* tag indirect data direct */
matarar= (Material ***)give_matarar(ob);
- if(matarar) {
- for(a=0; a<ob->totcol; a++) {
+ if (matarar) {
+ for (a=0; a<ob->totcol; a++) {
ma= (*matarar)[a];
- if(ma)
+ if (ma)
id_lib_extern(&ma->id);
}
}
}
- for(psys=ob->particlesystem.first; psys; psys=psys->next)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next)
id_make_local(&psys->part->id, 0);
adt= BKE_animdata_from_id(&ob->id);
- if(adt) BKE_animdata_make_local(adt);
+ if (adt) BKE_animdata_make_local(adt);
}
CTX_DATA_END;
- if(mode>1) {
+ if (mode>1) {
CTX_DATA_BEGIN(C, Object*, ob, selected_objects) {
- if(ob->type==OB_LAMP) {
+ if (ob->type==OB_LAMP) {
la= ob->data;
- for(b=0; b<MAX_MTEX; b++)
- if(la->mtex[b] && la->mtex[b]->tex)
+ for (b=0; b<MAX_MTEX; b++)
+ if (la->mtex[b] && la->mtex[b]->tex)
id_make_local(&la->mtex[b]->tex->id, 0);
}
else {
- for(a=0; a<ob->totcol; a++) {
+ for (a=0; a<ob->totcol; a++) {
ma= ob->mat[a];
- if(ma)
+ if (ma)
make_local_makelocalmaterial(ma);
}
matarar= (Material ***)give_matarar(ob);
- if(matarar) {
- for(a=0; a<ob->totcol; a++) {
+ if (matarar) {
+ for (a=0; a<ob->totcol; a++) {
ma= (*matarar)[a];
- if(ma)
+ if (ma)
make_local_makelocalmaterial(ma);
}
}
@@ -1816,20 +1812,20 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL}};
/* identifiers */
- ot->name= "Make Local";
+ ot->name = "Make Local";
ot->description = "Make library linked datablocks local to this file";
- ot->idname= "OBJECT_OT_make_local";
+ ot->idname = "OBJECT_OT_make_local";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= make_local_exec;
- ot->poll= ED_operator_objectmode;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = make_local_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
}
static int make_single_user_exec(bContext *C, wmOperator *op)
@@ -1839,20 +1835,20 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */
int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
- if(RNA_boolean_get(op->ptr, "object"))
+ if (RNA_boolean_get(op->ptr, "object"))
single_object_users(scene, v3d, flag);
- if(RNA_boolean_get(op->ptr, "obdata"))
+ if (RNA_boolean_get(op->ptr, "obdata"))
single_obdata_users(bmain, scene, flag);
- if(RNA_boolean_get(op->ptr, "material"))
+ if (RNA_boolean_get(op->ptr, "material"))
single_mat_users(scene, flag, RNA_boolean_get(op->ptr, "texture"));
#if 0 /* can't do this separate from materials */
- if(RNA_boolean_get(op->ptr, "texture"))
+ if (RNA_boolean_get(op->ptr, "texture"))
single_mat_users(scene, flag, TRUE);
#endif
- if(RNA_boolean_get(op->ptr, "animation"))
+ if (RNA_boolean_get(op->ptr, "animation"))
single_object_action_users(scene, flag);
clear_id_newpoins();
@@ -1869,20 +1865,20 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
{0, NULL, 0, NULL, NULL}};
/* identifiers */
- ot->name= "Make Single User";
+ ot->name = "Make Single User";
ot->description = "Make linked data local to each object";
- ot->idname= "OBJECT_OT_make_single_user";
+ ot->idname = "OBJECT_OT_make_single_user";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= make_single_user_exec;
- ot->poll= ED_operator_objectmode;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = make_single_user_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- ot->prop= RNA_def_enum(ot->srna, "type", type_items, SELECT, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", type_items, SELECT, "Type", "");
RNA_def_boolean(ot->srna, "object", 0, "Object", "Make single user objects");
RNA_def_boolean(ot->srna, "obdata", 0, "Object Data", "Make single user object data");
@@ -1900,7 +1896,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even
RNA_string_get(op->ptr, "name", name);
ma= (Material *)find_id("MA", name);
- if(base==NULL || ma==NULL)
+ if (base==NULL || ma==NULL)
return OPERATOR_CANCELLED;
assign_material(base->object, ma, 1);
@@ -1917,16 +1913,16 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Drop Named Material on Object";
+ ot->name = "Drop Named Material on Object";
ot->description = "";
- ot->idname= "OBJECT_OT_drop_named_material";
+ ot->idname = "OBJECT_OT_drop_named_material";
/* api callbacks */
- ot->invoke= drop_named_material_invoke;
- ot->poll= ED_operator_objectmode;
+ ot->invoke = drop_named_material_invoke;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_UNDO;
+ ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME-2, "Name", "Material name to assign");
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 69372ac1a90..53726d70cf9 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -107,7 +107,7 @@ void ED_base_object_activate(bContext *C, Base *base)
/* sets scene->basact */
BASACT= base;
- if(base) {
+ if (base) {
/* XXX old signals, remember to handle notifiers now! */
// select_actionchannel_by_name(base->object->action, "Object", 1);
@@ -123,12 +123,12 @@ void ED_base_object_activate(bContext *C, Base *base)
static int objects_selectable_poll(bContext *C)
{
/* we don't check for linked scenes here, selection is
- still allowed then for inspection of scene */
+ * still allowed then for inspection of scene */
Object *obact= CTX_data_active_object(C);
- if(CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C))
return 0;
- if(obact && obact->mode)
+ if (obact && obact->mode)
return 0;
return 1;
@@ -151,7 +151,7 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op)
}
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
- if(base->object->type==obtype) {
+ if (base->object->type==obtype) {
ED_base_object_select(base, BA_SELECT);
}
}
@@ -165,21 +165,21 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op)
void OBJECT_OT_select_by_type(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select By Type";
+ ot->name = "Select By Type";
ot->description = "Select all visible objects that are of a type";
- ot->idname= "OBJECT_OT_select_by_type";
+ ot->idname = "OBJECT_OT_select_by_type";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_select_by_type_exec;
- ot->poll= objects_selectable_poll;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_select_by_type_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
- ot->prop= RNA_def_enum(ot->srna, "type", object_type_items, 1, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", object_type_items, 1, "Type", "");
}
/*********************** Selection by Links *********************/
@@ -225,67 +225,67 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
}
ob= OBACT;
- if(ob==NULL){
+ if (ob==NULL) {
BKE_report(op->reports, RPT_ERROR, "No Active Object");
return OPERATOR_CANCELLED;
}
- if(nr==1) {
+ if (nr==1) {
// XXX old animation system
//ipo= ob->ipo;
//if(ipo==0) return OPERATOR_CANCELLED;
return OPERATOR_CANCELLED;
}
- else if(nr==2) {
- if(ob->data==NULL) return OPERATOR_CANCELLED;
+ else if (nr==2) {
+ if (ob->data==NULL) return OPERATOR_CANCELLED;
obdata= ob->data;
}
- else if(nr==3 || nr==4) {
+ else if (nr==3 || nr==4) {
mat= give_current_material(ob, ob->actcol);
- if(mat==NULL) return OPERATOR_CANCELLED;
- if(nr==4) {
- if(mat->mtex[ (int)mat->texact ]) tex= mat->mtex[ (int)mat->texact ]->tex;
- if(tex==NULL) return OPERATOR_CANCELLED;
+ if (mat==NULL) return OPERATOR_CANCELLED;
+ if (nr==4) {
+ if (mat->mtex[ (int)mat->texact ]) tex= mat->mtex[ (int)mat->texact ]->tex;
+ if (tex==NULL) return OPERATOR_CANCELLED;
}
}
- else if(nr==5) {
- if(ob->dup_group==NULL) return OPERATOR_CANCELLED;
+ else if (nr==5) {
+ if (ob->dup_group==NULL) return OPERATOR_CANCELLED;
}
- else if(nr==6) {
- if(ob->particlesystem.first==NULL) return OPERATOR_CANCELLED;
+ else if (nr==6) {
+ if (ob->particlesystem.first==NULL) return OPERATOR_CANCELLED;
}
- else if(nr==7) {
+ else if (nr==7) {
/* do nothing */
}
- else if(nr==8) {
- if(ob->data==NULL) return OPERATOR_CANCELLED;
+ else if (nr==8) {
+ if (ob->data==NULL) return OPERATOR_CANCELLED;
}
else
return OPERATOR_CANCELLED;
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
- if(nr==1) {
+ if (nr==1) {
// XXX old animation system
//if(base->object->ipo==ipo) base->flag |= SELECT;
//changed = 1;
}
- else if(nr==2) {
- if(base->object->data==obdata) base->flag |= SELECT;
+ else if (nr==2) {
+ if (base->object->data==obdata) base->flag |= SELECT;
changed = 1;
}
- else if(nr==3 || nr==4) {
+ else if (nr==3 || nr==4) {
ob= base->object;
- for(a=1; a<=ob->totcol; a++) {
+ for (a=1; a<=ob->totcol; a++) {
mat1= give_current_material(ob, a);
- if(nr==3) {
- if(mat1==mat) base->flag |= SELECT;
+ if (nr==3) {
+ if (mat1==mat) base->flag |= SELECT;
changed = 1;
}
- else if(mat1 && nr==4) {
- for(b=0; b<MAX_MTEX; b++) {
- if(mat1->mtex[b]) {
- if(tex==mat1->mtex[b]->tex) {
+ else if (mat1 && nr==4) {
+ for (b=0; b<MAX_MTEX; b++) {
+ if (mat1->mtex[b]) {
+ if (tex==mat1->mtex[b]->tex) {
base->flag |= SELECT;
changed = 1;
break;
@@ -295,19 +295,19 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
}
}
}
- else if(nr==5) {
- if(base->object->dup_group==ob->dup_group) {
+ else if (nr==5) {
+ if (base->object->dup_group==ob->dup_group) {
base->flag |= SELECT;
changed = 1;
}
}
- else if(nr==6) {
+ else if (nr==6) {
/* loop through other, then actives particles*/
ParticleSystem *psys;
ParticleSystem *psys_act;
- for(psys=base->object->particlesystem.first; psys; psys=psys->next) {
- for(psys_act=ob->particlesystem.first; psys_act; psys_act=psys_act->next) {
+ for (psys=base->object->particlesystem.first; psys; psys=psys->next) {
+ for (psys_act=ob->particlesystem.first; psys_act; psys_act=psys_act->next) {
if (psys->part == psys_act->part) {
base->flag |= SELECT;
changed = 1;
@@ -320,14 +320,14 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
}
}
}
- else if(nr==7) {
- if(ob->id.lib == base->object->id.lib) {
+ else if (nr==7) {
+ if (ob->id.lib == base->object->id.lib) {
base->flag |= SELECT;
changed= 1;
}
}
- else if(nr==8) {
- if(base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) {
+ else if (nr==8) {
+ if (base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) {
base->flag |= SELECT;
changed= 1;
}
@@ -347,21 +347,21 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
void OBJECT_OT_select_linked(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Linked";
+ ot->name = "Select Linked";
ot->description = "Select all visible objects that are linked";
- ot->idname= "OBJECT_OT_select_linked";
+ ot->idname = "OBJECT_OT_select_linked";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_select_linked_exec;
- ot->poll= objects_selectable_poll;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_select_linked_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
- ot->prop= RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", "");
}
/*********************** Selected Grouped ********************/
@@ -414,7 +414,7 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se
baspar= object_in_scene(basact->object->parent, scene);
/* can be NULL if parent in other scene */
- if(baspar && BASE_SELECTABLE(v3d, baspar)) {
+ if (baspar && BASE_SELECTABLE(v3d, baspar)) {
ED_base_object_select(basact, BA_DESELECT);
ED_base_object_select(baspar, BA_SELECT);
ED_base_object_activate(C, baspar);
@@ -492,7 +492,7 @@ static short select_grouped_object_hooks(bContext *C, Object *ob)
return changed;
}
-/* Select objects woth the same parent as the active (siblings),
+/* Select objects with the same parent as the active (siblings),
* parent can be NULL also */
static short select_grouped_siblings(bContext *C, Object *ob)
{
@@ -569,7 +569,7 @@ static short objects_share_gameprop(Object *a, Object *b)
bProperty *prop;
/*make a copy of all its properties*/
- for( prop= a->prop.first; prop; prop = prop->next ) {
+ for ( prop= a->prop.first; prop; prop = prop->next ) {
if ( get_ob_property(b, prop->name) )
return 1;
}
@@ -644,23 +644,23 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
}
ob= OBACT;
- if(ob==NULL) {
+ if (ob==NULL) {
BKE_report(op->reports, RPT_ERROR, "No Active Object");
return OPERATOR_CANCELLED;
}
- if(nr==1) changed |= select_grouped_children(C, ob, 1);
- else if(nr==2) changed |= select_grouped_children(C, ob, 0);
- else if(nr==3) changed |= select_grouped_parent(C);
- else if(nr==4) changed |= select_grouped_siblings(C, ob);
- else if(nr==5) changed |= select_grouped_type(C, ob);
- else if(nr==6) changed |= select_grouped_layer(C, ob);
- else if(nr==7) changed |= select_grouped_group(C, ob);
- else if(nr==8) changed |= select_grouped_object_hooks(C, ob);
- else if(nr==9) changed |= select_grouped_index_object(C, ob);
- else if(nr==10) changed |= select_grouped_color(C, ob);
- else if(nr==11) changed |= select_grouped_gameprops(C, ob);
- else if(nr==12) changed |= select_grouped_keyingset(C, ob);
+ if (nr==1) changed |= select_grouped_children(C, ob, 1);
+ else if (nr==2) changed |= select_grouped_children(C, ob, 0);
+ else if (nr==3) changed |= select_grouped_parent(C);
+ else if (nr==4) changed |= select_grouped_siblings(C, ob);
+ else if (nr==5) changed |= select_grouped_type(C, ob);
+ else if (nr==6) changed |= select_grouped_layer(C, ob);
+ else if (nr==7) changed |= select_grouped_group(C, ob);
+ else if (nr==8) changed |= select_grouped_object_hooks(C, ob);
+ else if (nr==9) changed |= select_grouped_index_object(C, ob);
+ else if (nr==10) changed |= select_grouped_color(C, ob);
+ else if (nr==11) changed |= select_grouped_gameprops(C, ob);
+ else if (nr==12) changed |= select_grouped_keyingset(C, ob);
if (changed) {
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
@@ -673,21 +673,21 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op)
void OBJECT_OT_select_grouped(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Grouped";
+ ot->name = "Select Grouped";
ot->description = "Select all visible objects grouped by various properties";
- ot->idname= "OBJECT_OT_select_grouped";
+ ot->idname = "OBJECT_OT_select_grouped";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_select_grouped_exec;
- ot->poll= objects_selectable_poll;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_select_grouped_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
- ot->prop= RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
}
/************************* Select by Layer **********************/
@@ -708,7 +708,7 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op)
}
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {
- if(base->lay == (1<< (layernum -1)))
+ if (base->lay == (1<< (layernum -1)))
ED_base_object_select(base, BA_SELECT);
}
CTX_DATA_END;
@@ -722,17 +722,17 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op)
void OBJECT_OT_select_by_layer(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select by Layer";
+ ot->name = "Select by Layer";
ot->description = "Select all visible objects on a layer";
- ot->idname= "OBJECT_OT_select_by_layer";
+ ot->idname = "OBJECT_OT_select_by_layer";
/* api callbacks */
/*ot->invoke = XXX - need a int grid popup*/
- ot->exec= object_select_by_layer_exec;
- ot->poll= objects_selectable_poll;
+ ot->exec = object_select_by_layer_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
@@ -770,7 +770,8 @@ static int object_select_all_exec(bContext *C, wmOperator *op)
case SEL_INVERT:
if (base->flag & SELECT) {
ED_base_object_select(base, BA_DESELECT);
- } else {
+ }
+ else {
ED_base_object_select(base, BA_SELECT);
}
break;
@@ -787,16 +788,16 @@ void OBJECT_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select or Deselect All";
+ ot->name = "(De)select All";
ot->description = "Change selection of all visible objects in scene";
- ot->idname= "OBJECT_OT_select_all";
+ ot->idname = "OBJECT_OT_select_all";
/* api callbacks */
- ot->exec= object_select_all_exec;
- ot->poll= objects_selectable_poll;
+ ot->exec = object_select_all_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
@@ -836,16 +837,16 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Same Group";
+ ot->name = "Select Same Group";
ot->description = "Select object in the same group";
- ot->idname= "OBJECT_OT_select_same_group";
+ ot->idname = "OBJECT_OT_select_same_group";
/* api callbacks */
- ot->exec= object_select_same_group_exec;
- ot->poll= objects_selectable_poll;
+ ot->exec = object_select_same_group_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_string(ot->srna, "group", "", MAX_ID_NAME, "Group", "Name of the group to select");
}
@@ -863,12 +864,12 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
flip_side_name(tmpname, primbase->object->id.name+2, TRUE);
- if(strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */
+ if (strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */
Object *ob= (Object *)find_id("OB", tmpname);
- if(ob) {
+ if (ob) {
Base *secbase= object_in_scene(ob, scene);
- if(secbase) {
+ if (secbase) {
ED_base_object_select(secbase, BA_SELECT);
}
}
@@ -889,16 +890,16 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Mirror";
+ ot->name = "Select Mirror";
ot->description = "Select the Mirror objects of the selected object eg. L.sword -> R.sword";
- ot->idname= "OBJECT_OT_select_mirror";
+ ot->idname = "OBJECT_OT_select_mirror";
/* api callbacks */
- ot->exec= object_select_mirror_exec;
- ot->poll= objects_selectable_poll;
+ ot->exec = object_select_mirror_exec;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -936,17 +937,17 @@ static int object_select_random_exec(bContext *C, wmOperator *op)
void OBJECT_OT_select_random(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Random";
+ ot->name = "Select Random";
ot->description = "Set select on random visible objects";
- ot->idname= "OBJECT_OT_select_random";
+ ot->idname = "OBJECT_OT_select_random";
/* api callbacks */
- /*ot->invoke= object_select_random_invoke XXX - need a number popup ;*/
+ /*ot->invoke = object_select_random_invoke XXX - need a number popup ;*/
ot->exec = object_select_random_exec;
- ot->poll= objects_selectable_poll;
+ ot->poll = objects_selectable_poll;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f);
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index b186f788bbf..959bda22263 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -76,7 +76,7 @@
static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int from_mix)
{
- if(object_insert_shape_key(scene, ob, NULL, from_mix)) {
+ if (object_insert_shape_key(scene, ob, NULL, from_mix)) {
Key *key= ob_get_key(ob);
ob->shapenr= BLI_countlist(&key->block);
@@ -94,22 +94,22 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
//IpoCurve *icu;
key= ob_get_key(ob);
- if(key==NULL)
+ if (key==NULL)
return 0;
kb= BLI_findlink(&key->block, ob->shapenr-1);
- if(kb) {
- for(rkb= key->block.first; rkb; rkb= rkb->next)
- if(rkb->relative == ob->shapenr-1)
+ if (kb) {
+ for (rkb= key->block.first; rkb; rkb= rkb->next)
+ if (rkb->relative == ob->shapenr-1)
rkb->relative= 0;
BLI_remlink(&key->block, kb);
key->totkey--;
- if(key->refkey== kb) {
+ if (key->refkey== kb) {
key->refkey= key->block.first;
- if(key->refkey) {
+ if (key->refkey) {
/* apply new basis key on original data */
switch(ob->type) {
case OB_MESH:
@@ -126,36 +126,36 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
}
}
- if(kb->data) MEM_freeN(kb->data);
+ if (kb->data) MEM_freeN(kb->data);
MEM_freeN(kb);
- for(kb= key->block.first; kb; kb= kb->next)
- if(kb->adrcode>=ob->shapenr)
+ for (kb= key->block.first; kb; kb= kb->next)
+ if (kb->adrcode>=ob->shapenr)
kb->adrcode--;
#if 0 // XXX old animation system
- if(key->ipo) {
+ if (key->ipo) {
- for(icu= key->ipo->curve.first; icu; icu= icu->next) {
- if(icu->adrcode==ob->shapenr-1) {
+ for (icu= key->ipo->curve.first; icu; icu= icu->next) {
+ if (icu->adrcode==ob->shapenr-1) {
BLI_remlink(&key->ipo->curve, icu);
free_ipo_curve(icu);
break;
}
}
- for(icu= key->ipo->curve.first; icu; icu= icu->next)
- if(icu->adrcode>=ob->shapenr)
+ for (icu= key->ipo->curve.first; icu; icu= icu->next)
+ if (icu->adrcode>=ob->shapenr)
icu->adrcode--;
}
#endif // XXX old animation system
- if(ob->shapenr>1) ob->shapenr--;
+ if (ob->shapenr>1) ob->shapenr--;
}
- if(key->totkey==0) {
- if(GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL;
- else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
- else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
+ if (key->totkey==0) {
+ if (GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL;
+ else if (GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
+ else if (GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
free_libblock_us(&(bmain->key), key);
}
@@ -172,33 +172,33 @@ static int object_shape_key_mirror(bContext *C, Object *ob)
Key *key;
key= ob_get_key(ob);
- if(key==NULL)
+ if (key==NULL)
return 0;
kb= BLI_findlink(&key->block, ob->shapenr-1);
- if(kb) {
+ if (kb) {
int i1, i2;
float *fp1, *fp2;
float tvec[3];
char *tag_elem= MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror");
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
MVert *mv;
mesh_octree_table(ob, NULL, NULL, 's');
- for(i1=0, mv=me->mvert; i1<me->totvert; i1++, mv++) {
+ for (i1=0, mv=me->mvert; i1<me->totvert; i1++, mv++) {
i2= mesh_get_x_mirror_vert(ob, i1);
- if(i2==i1) {
+ if (i2==i1) {
fp1= ((float *)kb->data) + i1*3;
fp1[0] = -fp1[0];
tag_elem[i1]= 1;
}
- else if(i2 != -1) {
- if(tag_elem[i1]==0 && tag_elem[i2]==0) {
+ else if (i2 != -1) {
+ if (tag_elem[i1]==0 && tag_elem[i2]==0) {
fp1= ((float *)kb->data) + i1*3;
fp2= ((float *)kb->data) + i2*3;
@@ -224,17 +224,17 @@ static int object_shape_key_mirror(bContext *C, Object *ob)
/* half but found up odd value */
const int pntsu_half = (lt->pntsu / 2) + (lt->pntsu % 2);
- /* currently editmode isnt supported by mesh so
+ /* currently editmode isn't supported by mesh so
* ignore here for now too */
- /* if(lt->editlatt) lt= lt->editlatt->latt; */
+ /* if (lt->editlatt) lt= lt->editlatt->latt; */
- for(w=0; w<lt->pntsw; w++) {
- for(v=0; v<lt->pntsv; v++) {
- for(u=0; u<pntsu_half; u++) {
+ for (w=0; w<lt->pntsw; w++) {
+ for (v=0; v<lt->pntsv; v++) {
+ for (u=0; u<pntsu_half; u++) {
int u_inv= (lt->pntsu - 1) - u;
float tvec[3];
- if(u == u_inv) {
+ if (u == u_inv) {
i1= LT_INDEX(lt, u, v, w);
fp1= ((float *)kb->data) + i1*3;
fp1[0]= -fp1[0];
@@ -296,16 +296,16 @@ static int shape_key_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_shape_key_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Shape Key";
- ot->idname= "OBJECT_OT_shape_key_add";
- ot->description= "Add shape key to the object";
+ ot->name = "Add Shape Key";
+ ot->idname = "OBJECT_OT_shape_key_add";
+ ot->description = "Add shape key to the object";
/* api callbacks */
- ot->poll= shape_key_mode_poll;
- ot->exec= shape_key_add_exec;
+ ot->poll = shape_key_mode_poll;
+ ot->exec = shape_key_add_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "from_mix", 1, "From Mix", "Create the new shape key from the existing mix of keys");
@@ -315,7 +315,7 @@ static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
- if(!ED_object_shape_key_remove(C, ob))
+ if (!ED_object_shape_key_remove(C, ob))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -324,16 +324,16 @@ static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_shape_key_remove(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove Shape Key";
- ot->idname= "OBJECT_OT_shape_key_remove";
- ot->description= "Remove shape key from the object";
+ ot->name = "Remove Shape Key";
+ ot->idname = "OBJECT_OT_shape_key_remove";
+ ot->description = "Remove shape key from the object";
/* api callbacks */
- ot->poll= shape_key_mode_poll;
- ot->exec= shape_key_remove_exec;
+ ot->poll = shape_key_mode_poll;
+ ot->exec = shape_key_remove_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
@@ -342,10 +342,10 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
Key *key= ob_get_key(ob);
KeyBlock *kb= ob_get_keyblock(ob);
- if(!key || !kb)
+ if (!key || !kb)
return OPERATOR_CANCELLED;
- for(kb=key->block.first; kb; kb=kb->next)
+ for (kb=key->block.first; kb; kb=kb->next)
kb->curval= 0.0f;
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -357,23 +357,23 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_shape_key_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Shape Keys";
- ot->description= "Clear weights for all shape keys";
- ot->idname= "OBJECT_OT_shape_key_clear";
+ ot->name = "Clear Shape Keys";
+ ot->description = "Clear weights for all shape keys";
+ ot->idname = "OBJECT_OT_shape_key_clear";
/* api callbacks */
- ot->poll= shape_key_poll;
- ot->exec= shape_key_clear_exec;
+ ot->poll = shape_key_poll;
+ ot->exec = shape_key_clear_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
- if(!object_shape_key_mirror(C, ob))
+ if (!object_shape_key_mirror(C, ob))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -382,15 +382,15 @@ static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_shape_key_mirror(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Mirror Shape Key";
- ot->idname= "OBJECT_OT_shape_key_mirror";
+ ot->name = "Mirror Shape Key";
+ ot->idname = "OBJECT_OT_shape_key_mirror";
/* api callbacks */
- ot->poll= shape_key_mode_poll;
- ot->exec= shape_key_mirror_exec;
+ ot->poll = shape_key_mode_poll;
+ ot->exec = shape_key_mirror_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -401,26 +401,26 @@ static int shape_key_move_exec(bContext *C, wmOperator *op)
int type= RNA_enum_get(op->ptr, "type");
Key *key= ob_get_key(ob);
- if(key) {
+ if (key) {
KeyBlock *kb, *kb_other;
int shapenr_act= ob->shapenr-1;
int shapenr_swap= shapenr_act + type;
kb= BLI_findlink(&key->block, shapenr_act);
- if((type==-1 && kb->prev==NULL) || (type==1 && kb->next==NULL)) {
+ if ((type==-1 && kb->prev==NULL) || (type==1 && kb->next==NULL)) {
return OPERATOR_CANCELLED;
}
- for(kb_other= key->block.first; kb_other; kb_other= kb_other->next) {
- if(kb_other->relative == shapenr_act) {
+ for (kb_other= key->block.first; kb_other; kb_other= kb_other->next) {
+ if (kb_other->relative == shapenr_act) {
kb_other->relative += type;
}
- else if(kb_other->relative == shapenr_swap) {
+ else if (kb_other->relative == shapenr_swap) {
kb_other->relative -= type;
}
}
- if(type==-1) {
+ if (type==-1) {
/* move back */
kb_other= kb->prev;
BLI_remlink(&key->block, kb);
@@ -451,15 +451,15 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot)
};
/* identifiers */
- ot->name= "Move Shape Key";
- ot->idname= "OBJECT_OT_shape_key_move";
+ ot->name = "Move Shape Key";
+ ot->idname = "OBJECT_OT_shape_key_move";
/* api callbacks */
- ot->poll= shape_key_mode_poll;
- ot->exec= shape_key_move_exec;
+ ot->poll = shape_key_mode_poll;
+ ot->exec = shape_key_move_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
}
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 45db21749a5..474d10ffbd8 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -40,6 +40,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_group_types.h"
+#include "DNA_lattice_types.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
@@ -118,7 +119,7 @@ static void object_clear_rot(Object *ob)
if ((ob->protectflag & OB_LOCK_ROTZ) == 0)
ob->quat[3]= ob->dquat[3]= 0.0f;
- // TODO: does this quat need normalising now?
+ // TODO: does this quat need normalizing now?
}
else {
/* the flag may have been set for the other modes, so just ignore the extra flag... */
@@ -215,7 +216,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
KeyingSet *ks;
/* sanity checks */
- if ELEM(NULL, clear_func, default_ksName) {
+ if (ELEM(NULL, clear_func, default_ksName)) {
BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform func or Keying Set Name");
return OPERATOR_CANCELLED;
}
@@ -259,16 +260,16 @@ static int object_location_clear_exec(bContext *C, wmOperator *op)
void OBJECT_OT_location_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Location";
+ ot->name = "Clear Location";
ot->description = "Clear the object's location";
- ot->idname= "OBJECT_OT_location_clear";
+ ot->idname = "OBJECT_OT_location_clear";
/* api callbacks */
- ot->exec= object_location_clear_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->exec = object_location_clear_exec;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_rotation_clear_exec(bContext *C, wmOperator *op)
@@ -279,16 +280,16 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op)
void OBJECT_OT_rotation_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Rotation";
+ ot->name = "Clear Rotation";
ot->description = "Clear the object's rotation";
- ot->idname= "OBJECT_OT_rotation_clear";
+ ot->idname = "OBJECT_OT_rotation_clear";
/* api callbacks */
- ot->exec= object_rotation_clear_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->exec = object_rotation_clear_exec;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_scale_clear_exec(bContext *C, wmOperator *op)
@@ -299,16 +300,16 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op)
void OBJECT_OT_scale_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Scale";
+ ot->name = "Clear Scale";
ot->description = "Clear the object's scale";
- ot->idname= "OBJECT_OT_scale_clear";
+ ot->idname = "OBJECT_OT_scale_clear";
/* api callbacks */
- ot->exec= object_scale_clear_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->exec = object_scale_clear_exec;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* --------------- */
@@ -345,16 +346,16 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_origin_clear(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clear Origin";
+ ot->name = "Clear Origin";
ot->description = "Clear the object's origin";
- ot->idname= "OBJECT_OT_origin_clear";
+ ot->idname = "OBJECT_OT_origin_clear";
/* api callbacks */
- ot->exec= object_origin_clear_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->exec = object_origin_clear_exec;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/*************************** Apply Transformation ****************************/
@@ -367,8 +368,8 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob )
Object *ob_child;
/* a change was made, adjust the children to compensate */
- for(ob_child=bmain->object.first; ob_child; ob_child=ob_child->id.next) {
- if(ob_child->parent == ob) {
+ for (ob_child=bmain->object.first; ob_child; ob_child=ob_child->id.next) {
+ if (ob_child->parent == ob) {
object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE);
what_does_parent(scene, ob_child, &workob);
invert_m4_m4(ob_child->parentinv, workob.obmat);
@@ -386,33 +387,39 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
/* first check if we can execute */
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if(ob->type==OB_MESH) {
- if(ID_REAL_USERS(ob->data) > 1) {
+ if (ob->type==OB_MESH) {
+ if (ID_REAL_USERS(ob->data) > 1) {
BKE_report(reports, RPT_ERROR, "Can't apply to a multi user mesh, doing nothing");
return OPERATOR_CANCELLED;
}
}
- else if(ob->type==OB_ARMATURE) {
- if(ID_REAL_USERS(ob->data) > 1) {
+ else if (ob->type==OB_ARMATURE) {
+ if (ID_REAL_USERS(ob->data) > 1) {
BKE_report(reports, RPT_ERROR, "Can't apply to a multi user armature, doing nothing");
return OPERATOR_CANCELLED;
}
}
- else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ else if (ob->type == OB_LATTICE) {
+ if (ID_REAL_USERS(ob->data) > 1) {
+ BKE_report(reports, RPT_ERROR, "Can't apply to a multi user lattice, doing nothing");
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu;
- if(ID_REAL_USERS(ob->data) > 1) {
+ if (ID_REAL_USERS(ob->data) > 1) {
BKE_report(reports, RPT_ERROR, "Can't apply to a multi user curve, doing nothing");
return OPERATOR_CANCELLED;
}
cu= ob->data;
- if(!(cu->flag & CU_3D) && (apply_rot || apply_loc)) {
+ if (!(cu->flag & CU_3D) && (apply_rot || apply_loc)) {
BKE_report(reports, RPT_ERROR, "Neither rotation nor location could be applied to a 2d curve, doing nothing");
return OPERATOR_CANCELLED;
}
- if(cu->key) {
+ if (cu->key) {
BKE_report(reports, RPT_ERROR, "Can't apply to a curve with vertex keys, doing nothing");
return OPERATOR_CANCELLED;
}
@@ -424,11 +431,11 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
/* calculate rotation/scale matrix */
- if(apply_scale && apply_rot)
+ if (apply_scale && apply_rot)
object_to_mat3(ob, rsmat);
- else if(apply_scale)
+ else if (apply_scale)
object_scale_to_mat3(ob, rsmat);
- else if(apply_rot) {
+ else if (apply_rot) {
float tmat[3][3], timat[3][3];
/* simple rotation matrix */
@@ -446,10 +453,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
copy_m4_m3(mat, rsmat);
/* calculate translation */
- if(apply_loc) {
+ if (apply_loc) {
copy_v3_v3(mat[3], ob->loc);
- if(!(apply_scale && apply_rot)) {
+ if (!(apply_scale && apply_rot)) {
/* correct for scale and rotation that is still applied */
object_to_mat3(ob, obmat);
invert_m3_m3(iobmat, obmat);
@@ -459,7 +466,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
}
/* apply to object data */
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
MVert *mvert;
@@ -467,16 +474,16 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
/* adjust data */
mvert= me->mvert;
- for(a=0; a<me->totvert; a++, mvert++)
+ for (a=0; a<me->totvert; a++, mvert++)
mul_m4_v3(mat, mvert->co);
- if(me->key) {
+ if (me->key) {
KeyBlock *kb;
- for(kb=me->key->block.first; kb; kb=kb->next) {
+ for (kb=me->key->block.first; kb; kb=kb->next) {
float *fp= kb->data;
- for(a=0; a<kb->totelem; a++, fp+=3)
+ for (a=0; a<kb->totelem; a++, fp+=3)
mul_m4_v3(mat, fp);
}
}
@@ -487,7 +494,17 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
else if (ob->type==OB_ARMATURE) {
ED_armature_apply_transform(ob, mat);
}
- else if(ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ else if (ob->type == OB_LATTICE) {
+ Lattice *lt = ob->data;
+ BPoint *bp = lt->def;
+ int a = lt->pntsu * lt->pntsv * lt->pntsw;
+
+ while (a--) {
+ mul_m4_v3(mat, bp->vec);
+ bp++;
+ }
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= ob->data;
Nurb *nu;
@@ -496,10 +513,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
scale = mat3_to_scale(rsmat);
- for(nu=cu->nurb.first; nu; nu=nu->next) {
- if(nu->type == CU_BEZIER) {
+ for (nu=cu->nurb.first; nu; nu=nu->next) {
+ if (nu->type == CU_BEZIER) {
a= nu->pntsu;
- for(bezt= nu->bezt; a--; bezt++) {
+ for (bezt= nu->bezt; a--; bezt++) {
mul_m4_v3(mat, bezt->vec[0]);
mul_m4_v3(mat, bezt->vec[1]);
mul_m4_v3(mat, bezt->vec[2]);
@@ -509,7 +526,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
}
else {
a= nu->pntsu*nu->pntsv;
- for(bp= nu->bp; a--; bp++)
+ for (bp= nu->bp; a--; bp++)
mul_m4_v3(mat, bp->vec);
}
}
@@ -517,18 +534,18 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
else
continue;
- if(apply_loc)
+ if (apply_loc)
zero_v3(ob->loc);
- if(apply_scale)
+ if (apply_scale)
ob->size[0]= ob->size[1]= ob->size[2]= 1.0f;
- if(apply_rot) {
+ if (apply_rot) {
zero_v3(ob->rot);
unit_qt(ob->quat);
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
}
where_is_object(scene, ob);
- if(ob->type==OB_ARMATURE) {
+ if (ob->type==OB_ARMATURE) {
where_is_pose(scene, ob); /* needed for bone parents */
}
@@ -540,7 +557,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
}
CTX_DATA_END;
- if(!change)
+ if (!change)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
@@ -564,7 +581,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- if(!change)
+ if (!change)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
@@ -574,16 +591,16 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_visual_transform_apply(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Apply Visual Transform";
+ ot->name = "Apply Visual Transform";
ot->description = "Apply the object's visual transformation to its data";
- ot->idname= "OBJECT_OT_visual_transform_apply";
+ ot->idname = "OBJECT_OT_visual_transform_apply";
/* api callbacks */
- ot->exec= visual_transform_apply_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->exec = visual_transform_apply_exec;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int object_transform_apply_exec(bContext *C, wmOperator *op)
@@ -592,7 +609,7 @@ static int object_transform_apply_exec(bContext *C, wmOperator *op)
const int rot= RNA_boolean_get(op->ptr, "rotation");
const int sca= RNA_boolean_get(op->ptr, "scale");
- if(loc || rot || sca) {
+ if (loc || rot || sca) {
return apply_objects_internal(C, op->reports, loc, rot, sca);
}
else {
@@ -603,16 +620,16 @@ static int object_transform_apply_exec(bContext *C, wmOperator *op)
void OBJECT_OT_transform_apply(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Apply Object Transform";
+ ot->name = "Apply Object Transform";
ot->description = "Apply the object's transformation to its data";
- ot->idname= "OBJECT_OT_transform_apply";
+ ot->idname = "OBJECT_OT_transform_apply";
/* api callbacks */
- ot->exec= object_transform_apply_exec;
- ot->poll= ED_operator_objectmode;
+ ot->exec = object_transform_apply_exec;
+ ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "location", 0, "Location", "");
RNA_def_boolean(ot->srna, "rotation", 0, "Rotation", "");
@@ -645,32 +662,33 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else {
- /* get the view settings if 'around' isnt set and the view is available */
+ /* get the view settings if 'around' isn't set and the view is available */
View3D *v3d= CTX_wm_view3d(C);
copy_v3_v3(cursor, give_cursor(scene, v3d));
- if(v3d && !RNA_struct_property_is_set(op->ptr, "center"))
+ if (v3d && !RNA_struct_property_is_set(op->ptr, "center"))
around= v3d->around;
}
zero_v3(cent);
- if(obedit) {
+ if (obedit) {
INIT_MINMAX(min, max);
- if(obedit->type==OB_MESH) {
+ if (obedit->type==OB_MESH) {
Mesh *me= obedit->data;
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMIter iter;
int total = 0;
- if(centermode == ORIGIN_TO_CURSOR) {
+ if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(cent, cursor);
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, cent);
- } else {
+ }
+ else {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if(around==V3D_CENTROID) {
+ if (around==V3D_CENTROID) {
total++;
add_v3_v3(cent, eve->co);
mul_v3_fl(cent, 1.0f/(float)total);
@@ -686,7 +704,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
sub_v3_v3(eve->co, cent);
}
- EDBM_RecalcNormals(em);
+ EDBM_mesh_normals_update(em);
tot_change++;
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
}
@@ -699,31 +717,31 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
for (tob= bmain->object.first; tob; tob= tob->id.next) {
- if(tob->data)
+ if (tob->data)
((ID *)tob->data)->flag &= ~LIB_DOIT;
- if(tob->dup_group)
+ if (tob->dup_group)
((ID *)tob->dup_group)->flag &= ~LIB_DOIT;
}
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
- if((ob->flag & OB_DONE)==0) {
+ if ((ob->flag & OB_DONE)==0) {
int do_inverse_offset = FALSE;
ob->flag |= OB_DONE;
- if(centermode == ORIGIN_TO_CURSOR) {
+ if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(cent, cursor);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, cent);
}
- if(ob->data == NULL) {
+ if (ob->data == NULL) {
/* special support for dupligroups */
- if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.flag & LIB_DOIT)==0) {
- if(ob->dup_group->id.lib) {
+ if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.flag & LIB_DOIT)==0) {
+ if (ob->dup_group->id.lib) {
tot_lib_error++;
}
else {
- if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
else {
/* only bounds support */
INIT_MINMAX(min, max);
@@ -745,11 +763,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
tot_lib_error++;
}
- if(obedit==NULL && ob->type==OB_MESH) {
+ if (obedit==NULL && ob->type==OB_MESH) {
Mesh *me= ob->data;
- if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
- else if(around==V3D_CENTROID) { mesh_center_median(me, cent); }
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if (around==V3D_CENTROID) { mesh_center_median(me, cent); }
else { mesh_center_bounds(me, cent); }
negate_v3_v3(cent_neg, cent);
@@ -762,12 +780,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= ob->data;
- if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
- else if(around==V3D_CENTROID) { curve_center_median(cu, cent); }
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if (around==V3D_CENTROID) { curve_center_median(cu, cent); }
else { curve_center_bounds(cu, cent); }
/* don't allow Z change if curve is 2D */
- if((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
+ if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
cent[2] = 0.0;
negate_v3_v3(cent_neg, cent);
@@ -777,23 +795,23 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
cu->id.flag |= LIB_DOIT;
do_inverse_offset= TRUE;
- if(obedit) {
+ if (obedit) {
if (centermode == GEOMETRY_TO_ORIGIN) {
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
}
break;
}
}
- else if(ob->type==OB_FONT) {
+ else if (ob->type==OB_FONT) {
/* get from bb */
Curve *cu= ob->data;
- if(cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) {
+ if (cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) {
/* do nothing*/
}
else {
- if(centermode == ORIGIN_TO_CURSOR) {
+ if (centermode == ORIGIN_TO_CURSOR) {
/* done */
}
else {
@@ -811,12 +829,14 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
do_inverse_offset= TRUE;
}
}
- else if(ob->type==OB_ARMATURE) {
+ else if (ob->type==OB_ARMATURE) {
bArmature *arm = ob->data;
- if(ID_REAL_USERS(arm) > 1) {
- /*BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature");
- return;*/
+ if (ID_REAL_USERS(arm) > 1) {
+#if 0
+ BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature");
+ return;
+#endif
tot_multiuser_arm_error++;
}
else {
@@ -834,15 +854,15 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(bmain, scene, ob);
- if(obedit)
+ if (obedit)
break;
}
}
else if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
- if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
- else if(around==V3D_CENTROID) { BKE_metaball_center_median(mb, cent); }
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if (around==V3D_CENTROID) { BKE_metaball_center_median(mb, cent); }
else { BKE_metaball_center_bounds(mb, cent); }
negate_v3_v3(cent_neg, cent);
@@ -852,7 +872,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
mb->id.flag |= LIB_DOIT;
do_inverse_offset= TRUE;
- if(obedit) {
+ if (obedit) {
if (centermode == GEOMETRY_TO_ORIGIN) {
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
}
@@ -861,7 +881,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
/* offset other selected objects */
- if(do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
+ if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
/* was the object data modified
* note: the functions above must set 'cent' */
copy_v3_v3(centn, cent);
@@ -869,7 +889,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
add_v3_v3(ob->loc, centn);
where_is_object(scene, ob);
- if(ob->type==OB_ARMATURE) {
+ if (ob->type==OB_ARMATURE) {
where_is_pose(scene, ob); /* needed for bone parents */
}
@@ -877,7 +897,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* other users? */
CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
- if( (ob_other->flag & OB_DONE)==0 &&
+ if ( (ob_other->flag & OB_DONE)==0 &&
( (ob->data && (ob->data == ob_other->data)) ||
(ob->dup_group==ob_other->dup_group && (ob->transflag|ob_other->transflag) & OB_DUPLIGROUP) )
) {
@@ -889,7 +909,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
add_v3_v3(ob_other->loc, centn);
where_is_object(scene, ob_other);
- if(ob_other->type==OB_ARMATURE) {
+ if (ob_other->type==OB_ARMATURE) {
where_is_pose(scene, ob_other); /* needed for bone parents */
}
ignore_parent_tx(bmain, scene, ob_other);
@@ -902,7 +922,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
for (tob= bmain->object.first; tob; tob= tob->id.next)
- if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT))
+ if (tob->data && (((ID *)tob->data)->flag & LIB_DOIT))
DAG_id_tag_update(&tob->id, OB_RECALC_OB|OB_RECALC_DATA);
if (tot_change) {
@@ -938,20 +958,20 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
};
/* identifiers */
- ot->name= "Set Origin";
+ 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->idname= "OBJECT_OT_origin_set";
+ ot->idname = "OBJECT_OT_origin_set";
/* api callbacks */
- ot->invoke= WM_menu_invoke;
- ot->exec= object_origin_set_exec;
+ ot->invoke = WM_menu_invoke;
+ ot->exec = object_origin_set_exec;
- ot->poll= ED_operator_scene_editable;
+ ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
- ot->prop= RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", "");
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index dcf3a400470..c0150d6e3b0 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -92,9 +92,9 @@ static Lattice *vgroup_edit_lattice(Object *ob)
int ED_vgroup_object_is_edit_mode(Object *ob)
{
- if(ob->type == OB_MESH)
- return (((Mesh*)ob->data)->edit_btmesh != NULL);
- else if(ob->type == OB_LATTICE)
+ if (ob->type == OB_MESH)
+ return (BMEdit_FromObject(ob) != NULL);
+ else if (ob->type == OB_LATTICE)
return (((Lattice*)ob->data)->editlatt != NULL);
return 0;
@@ -104,7 +104,7 @@ bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name)
{
bDeformGroup *defgroup;
- if(!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
+ if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type))
return NULL;
defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup");
@@ -137,7 +137,7 @@ void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup)
if (dg == NULL)
return;
- if(ED_vgroup_object_is_edit_mode(ob))
+ if (ED_vgroup_object_is_edit_mode(ob))
vgroup_delete_edit_mode(ob, dg);
else
vgroup_delete_object_mode(ob, dg);
@@ -151,7 +151,7 @@ void ED_vgroup_clear(Object *ob)
while (dg) {
bDeformGroup *next_dg= dg->next;
- if(edit_mode)
+ if (edit_mode)
vgroup_delete_edit_mode(ob, dg);
else
vgroup_delete_object_mode(ob, dg);
@@ -164,12 +164,12 @@ int ED_vgroup_data_create(ID *id)
{
/* create deform verts */
- if(GS(id->name)==ID_ME) {
+ if (GS(id->name)==ID_ME) {
Mesh *me= (Mesh *)id;
me->dvert= CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
return TRUE;
}
- else if(GS(id->name)==ID_LT) {
+ else if (GS(id->name)==ID_LT) {
Lattice *lt= (Lattice *)id;
lt->dvert= MEM_callocN(sizeof(MDeformVert)*lt->pntsu*lt->pntsv*lt->pntsw, "lattice deformVert");
return TRUE;
@@ -184,13 +184,13 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
*dvert_tot = 0;
*dvert_arr = NULL;
- if(id) {
+ if (id) {
switch(GS(id->name)) {
case ID_ME:
{
Mesh *me = (Mesh *)id;
- if(me->edit_btmesh) {
+ if (me->edit_btmesh) {
BMEditMesh *em = me->edit_btmesh;
BMIter iter;
BMVert *eve;
@@ -222,7 +222,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
return 1;
}
- else if(me->dvert) {
+ else if (me->dvert) {
MVert *mvert= me->mvert;
MDeformVert *dvert= me->dvert;
int i;
@@ -255,7 +255,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
Lattice *lt= (Lattice *)id;
lt= (lt->editlatt)? lt->editlatt->latt: lt;
- if(lt->dvert) {
+ if (lt->dvert) {
BPoint *def= lt->def;
*dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw;
*dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me");
@@ -287,7 +287,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
/* returns true if the id type supports weights */
int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot)
{
- if(id) {
+ if (id) {
switch(GS(id->name)) {
case ID_ME:
{
@@ -327,16 +327,16 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from)
ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from, FALSE);
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE);
- if((dvert_array == NULL) && (dvert_array_from != NULL) && ED_vgroup_data_create(ob->data)) {
+ if ((dvert_array == NULL) && (dvert_array_from != NULL) && ED_vgroup_data_create(ob->data)) {
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE);
new_vgroup= TRUE;
}
- if(ob==ob_from || dvert_tot==0 || (dvert_tot != dvert_tot_from) || dvert_array_from==NULL || dvert_array==NULL) {
+ if (ob==ob_from || dvert_tot==0 || (dvert_tot != dvert_tot_from) || dvert_array_from==NULL || dvert_array==NULL) {
if (dvert_array) MEM_freeN(dvert_array);
if (dvert_array_from) MEM_freeN(dvert_array_from);
- if(new_vgroup == TRUE) {
+ if (new_vgroup == TRUE) {
/* free the newly added vgroup since it wasn't compatible */
vgroup_delete_all(ob);
}
@@ -348,11 +348,11 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from)
BLI_duplicatelist(&ob->defbase, &ob_from->defbase);
ob->actdef= ob_from->actdef;
- if(defbase_tot_from < defbase_tot) {
+ if (defbase_tot_from < defbase_tot) {
/* correct vgroup indices because the number of vgroups is being reduced. */
int *remap= MEM_mallocN(sizeof(int) * (defbase_tot + 1), __func__);
- for(i=0; i<=defbase_tot_from; i++) remap[i]= i;
- for(; i<=defbase_tot; i++) remap[i]= 0; /* can't use these, so disable */
+ for (i=0; i<=defbase_tot_from; i++) remap[i]= i;
+ for (; i<=defbase_tot; i++) remap[i]= 0; /* can't use these, so disable */
vgroup_remap_update_users(ob, remap);
MEM_freeN(remap);
@@ -361,13 +361,13 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from)
dvf= dvert_array_from;
dv= dvert_array;
- for(i=0; i<dvert_tot; i++, dvf++, dv++) {
- if((*dv)->dw)
+ for (i=0; i<dvert_tot; i++, dvf++, dv++) {
+ if ((*dv)->dw)
MEM_freeN((*dv)->dw);
*(*dv)= *(*dvf);
- if((*dv)->dw)
+ if ((*dv)->dw)
(*dv)->dw= MEM_dupallocN((*dv)->dw);
}
@@ -430,7 +430,7 @@ static void ED_vgroup_nr_vert_add(Object *ob,
/* get the vert */
ED_vgroup_give_array(ob->data, &dvert, &tot);
- if(dvert==NULL)
+ if (dvert==NULL)
return;
/* check that vertnum is valid before trying to get the relevant dvert */
@@ -456,7 +456,7 @@ static void ED_vgroup_nr_vert_add(Object *ob,
break;
case WEIGHT_ADD:
dw->weight += weight;
- if(dw->weight >= 1.0f)
+ if (dw->weight >= 1.0f)
dw->weight = 1.0f;
break;
case WEIGHT_SUBTRACT:
@@ -464,7 +464,7 @@ static void ED_vgroup_nr_vert_add(Object *ob,
/* if the weight is zero or less then
* remove the vert from the deform group
*/
- if(dw->weight <= 0.0f) {
+ if (dw->weight <= 0.0f) {
defvert_remove_group(dv, dw);
}
break;
@@ -509,11 +509,11 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight,
/* get the deform group number, exit if
* it can't be found
*/
- if(def_nr < 0) return;
+ if (def_nr < 0) return;
/* if there's no deform verts then create some,
*/
- if(ED_vgroup_give_array(ob->data, &dv, &tot) && dv==NULL)
+ if (ED_vgroup_give_array(ob->data, &dv, &tot) && dv==NULL)
ED_vgroup_data_create(ob->data);
/* call another function to do the work
@@ -531,7 +531,7 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum)
/* TODO, this is slow in a loop, better pass def_nr directly, but leave for later... - campbell */
const int def_nr= BLI_findindex(&ob->defbase, dg);
- if(def_nr != -1) {
+ if (def_nr != -1) {
MDeformVert *dvert= NULL;
int tot;
@@ -540,7 +540,7 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum)
*/
ED_vgroup_give_array(ob->data, &dvert, &tot);
- if(dvert) {
+ if (dvert) {
MDeformVert *dv= &dvert[vertnum];
MDeformWeight *dw;
@@ -557,28 +557,28 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum)
Mesh *me;
/* get the deform vertices corresponding to the vertnum */
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
me= ob->data;
- if(me->edit_btmesh) {
+ if (me->edit_btmesh) {
eve= BM_vert_at_index(me->edit_btmesh->bm, vertnum);
- if(!eve) {
+ if (!eve) {
return 0.0f;
}
dv= CustomData_bmesh_get(&me->edit_btmesh->bm->vdata, eve->head.data, CD_MDEFORMVERT);
}
else {
- if(vertnum >= me->totvert) {
+ if (vertnum >= me->totvert) {
return 0.0f;
}
dv = &me->dvert[vertnum];
}
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
- if(lt->dvert) {
- if(vertnum >= lt->pntsu*lt->pntsv*lt->pntsw) {
+ if (lt->dvert) {
+ if (vertnum >= lt->pntsu*lt->pntsv*lt->pntsw) {
return 0.0f;
}
dv = &lt->dvert[vertnum];
@@ -599,7 +599,7 @@ float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum)
{
const int def_nr= BLI_findindex(&ob->defbase, dg);
- if(def_nr == -1) {
+ if (def_nr == -1) {
return -1;
}
@@ -623,7 +623,7 @@ static void vgroup_select_verts(Object *ob, int select)
return;
}
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= ob->data;
if (me->edit_btmesh) {
@@ -641,7 +641,7 @@ static void vgroup_select_verts(Object *ob, int select)
}
/* this has to be called, because this function operates on vertices only */
- if(select) EDBM_select_flush(em); // vertices to edges/faces
+ if (select) EDBM_select_flush(em); // vertices to edges/faces
else EDBM_deselect_flush(em);
}
else {
@@ -666,17 +666,17 @@ static void vgroup_select_verts(Object *ob, int select)
}
}
}
- else if(ob->type == OB_LATTICE) {
+ else if (ob->type == OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
- if(lt->dvert) {
+ if (lt->dvert) {
BPoint *bp;
int a, tot;
dv= lt->dvert;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
- for(a=0, bp= lt->def; a<tot; a++, bp++, dv++) {
+ for (a=0, bp= lt->def; a<tot; a++, bp++, dv++) {
if (defvert_find_index(dv, def_nr)) {
if (select) bp->f1 |= SELECT;
else bp->f1 &= ~SELECT;
@@ -695,10 +695,10 @@ static void vgroup_duplicate(Object *ob)
int i, idg, icdg, dvert_tot=0;
dg = BLI_findlink(&ob->defbase, (ob->actdef-1));
- if(!dg)
+ if (!dg)
return;
- if(!strstr(dg->name, "_copy")) {
+ if (!strstr(dg->name, "_copy")) {
BLI_snprintf(name, sizeof(name), "%s_copy", dg->name);
}
else {
@@ -719,10 +719,10 @@ static void vgroup_duplicate(Object *ob)
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE);
if (dvert_array) {
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
MDeformVert *dv= dvert_array[i];
dw_org = defvert_find_index(dv, idg);
- if(dw_org) {
+ if (dw_org) {
/* defvert_verify_index re-allocs org so need to store the weight first */
dw_cpy = defvert_verify_index(dv, icdg);
dw_cpy->weight = dw_org->weight;
@@ -740,8 +740,7 @@ static void vgroup_normalize(Object *ob)
int i, dvert_tot=0;
const int def_nr= ob->actdef-1;
- Mesh *me = ob->data;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -752,32 +751,32 @@ static void vgroup_normalize(Object *ob)
if (dvert_array) {
float weight_max = 0.0f;
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
dw = defvert_find_index(dv, def_nr);
- if(dw) {
+ if (dw) {
weight_max = MAX2(dw->weight, weight_max);
}
}
- if(weight_max > 0.0f) {
- for(i = 0; i < dvert_tot; i++) {
+ if (weight_max > 0.0f) {
+ for (i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
dw = defvert_find_index(dv, def_nr);
- if(dw) {
+ if (dw) {
dw->weight /= weight_max;
- /* incase of division errors with very low weights */
+ /* in case of division errors with very low weights */
CLAMP(dw->weight, 0.0f, 1.0f);
}
}
@@ -801,21 +800,21 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count)
BLI_array_declare(verts);
BLI_array_reserve(verts, 8);
- while(i--) {
+ while (i--) {
int j = mp->totloop;
int first_l = mp->totloop - 1;
MLoop *ml = &me->mloop[mp->loopstart];
- while(j--) {
+ while (j--) {
/* XXX This assume a vert can only be once in a poly, even though
- * it seems logical to me, not totaly sure of that. */
+ * it seems logical to me, not totally sure of that. */
if (ml->v == vert) {
int a, b, k;
- if(j == first_l) {
+ if (j == first_l) {
/* We are on the first corner. */
a = ml[1].v;
b = ml[j].v;
}
- else if(!j) {
+ else if (!j) {
/* We are on the last corner. */
a = (ml-1)->v;
b = me->mloop[mp->loopstart].v;
@@ -828,15 +827,15 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count)
/* Append a and b verts to array, if not yet present. */
k = BLI_array_count(verts);
/* XXX Maybe a == b is enough? */
- while(k-- && !(a == b && a == -1)) {
- if(verts[k] == a)
+ while (k-- && !(a == b && a == -1)) {
+ if (verts[k] == a)
a = -1;
- else if(verts[k] == b)
+ else if (verts[k] == b)
b = -1;
}
- if(a != -1)
+ if (a != -1)
BLI_array_append(verts, a);
- if(b != -1)
+ if (b != -1)
BLI_array_append(verts, b);
/* Vert found in this poly, we can go to next one! */
@@ -853,22 +852,22 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count)
}
/* get a single point in space by averaging a point cloud (vectors of size 3)
-coord is the place the average is stored, points is the point cloud, count is the number of points in the cloud
-*/
+ * coord is the place the average is stored, points is the point cloud, count is the number of points in the cloud
+ */
static void getSingleCoordinate(MVert *points, int count, float coord[3])
{
int i;
zero_v3(coord);
- for(i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
add_v3_v3(coord, points[i].co);
}
mul_v3_fl(coord, 1.0f/count);
}
/* given a plane and a start and end position,
-compute the amount of vertical distance relative to the plane and store it in dists,
-then get the horizontal and vertical change and store them in changes
-*/
+ * compute the amount of vertical distance relative to the plane and store it in dists,
+ * then get the horizontal and vertical change and store them in changes
+ */
static void getVerticalAndHorizontalChange(const float norm[3], float d, const float coord[3],
const float start[3], float distToStart,
float *end, float (*changes)[2], float *dists, int index)
@@ -892,32 +891,32 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f
// I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc)
static void dm_deform_clear(DerivedMesh *dm, Object *ob)
{
- if(ob->derivedDeform && (ob->derivedDeform)==dm) {
+ if (ob->derivedDeform && (ob->derivedDeform)==dm) {
ob->derivedDeform->needsFree = 1;
ob->derivedDeform->release(ob->derivedDeform);
ob->derivedDeform = NULL;
}
- else if(dm) {
+ else if (dm) {
dm->needsFree = 1;
dm->release(dm);
}
}
-// recalculate the deformation
+/* recalculate the deformation */
static DerivedMesh* dm_deform_recalc(Scene *scene, Object *ob)
{
return mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
}
/* by changing nonzero weights, try to move a vertex in me->mverts with index 'index' to
-distToBe distance away from the provided plane strength can change distToBe so that it moves
-towards distToBe by that percentage cp changes how much the weights are adjusted
-to check the distance
-
-index is the index of the vertex being moved
-norm and d are the plane's properties for the equation: ax + by + cz + d = 0
-coord is a point on the plane
-*/
+ * distToBe distance away from the provided plane strength can change distToBe so that it moves
+ * towards distToBe by that percentage cp changes how much the weights are adjusted
+ * to check the distance
+ *
+ * index is the index of the vertex being moved
+ * norm and d are the plane's properties for the equation: ax + by + cz + d = 0
+ * coord is a point on the plane
+ */
static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
float coord[3], float d, float distToBe, float strength, float cp)
{
@@ -950,56 +949,59 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
copy_v3_v3(oldPos, m.co);
distToStart = dot_v3v3(norm, oldPos) + d;
- if(distToBe == originalDistToBe) {
+ if (distToBe == originalDistToBe) {
distToBe += distToStart - distToStart*strength;
}
- for(i = 0; i < totweight; i++) {
+ for (i = 0; i < totweight; i++) {
dwIndices[i] = i;
dw = (dvert->dw+i);
vc = hc = 0;
- if(!dw->weight) {
+ if (!dw->weight) {
changes[i][0] = 0;
changes[i][1] = 0;
dists[i] = distToStart;
continue;
}
- for(k = 0; k < 2; k++) {
- if(dm) {
+ for (k = 0; k < 2; k++) {
+ if (dm) {
dm_deform_clear(dm, ob); dm = NULL;
}
oldw = dw->weight;
- if(k) {
+ if (k) {
dw->weight *= 1+cp;
- } else {
+ }
+ else {
dw->weight /= 1+cp;
}
- if(dw->weight == oldw) {
+ if (dw->weight == oldw) {
changes[i][0] = 0;
changes[i][1] = 0;
dists[i] = distToStart;
break;
}
- if(dw->weight > 1) {
+ if (dw->weight > 1) {
dw->weight = 1;
}
dm = dm_deform_recalc(scene, ob);
dm->getVert(dm, index, &m);
getVerticalAndHorizontalChange(norm, d, coord, oldPos, distToStart, m.co, changes, dists, i);
dw->weight = oldw;
- if(!k) {
+ if (!k) {
vc = changes[i][0];
hc = changes[i][1];
dist = dists[i];
- } else {
- if(fabs(dist - distToBe) < fabs(dists[i] - distToBe)) {
+ }
+ else {
+ if (fabs(dist - distToBe) < fabs(dists[i] - distToBe)) {
upDown[i] = 0;
changes[i][0] = vc;
changes[i][1] = hc;
dists[i] = dist;
- } else {
+ }
+ else {
upDown[i] = 1;
}
- if(fabs(dists[i] - distToBe) > fabs(distToStart - distToBe)) {
+ if (fabs(dists[i] - distToBe) > fabs(distToStart - distToBe)) {
changes[i][0] = 0;
changes[i][1] = 0;
dists[i] = distToStart;
@@ -1008,19 +1010,19 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
}
}
// sort the changes by the vertical change
- for(k = 0; k < totweight; k++) {
+ for (k = 0; k < totweight; k++) {
float tf;
int ti;
bestIndex = k;
- for(i = k+1; i < totweight; i++) {
+ for (i = k+1; i < totweight; i++) {
dist = dists[i];
- if(fabs(dist) > fabs(dists[i])) {
+ if (fabs(dist) > fabs(dists[i])) {
bestIndex = i;
}
}
// switch with k
- if(bestIndex != k) {
+ if (bestIndex != k) {
ti = upDown[k];
upDown[k] = upDown[bestIndex];
upDown[bestIndex] = ti;
@@ -1044,18 +1046,18 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
}
bestIndex = -1;
// find the best change with an acceptable horizontal change
- for(i = 0; i < totweight; i++) {
- if(fabs(changes[i][0]) > fabs(changes[i][1]*2.0f)) {
+ for (i = 0; i < totweight; i++) {
+ if (fabs(changes[i][0]) > fabs(changes[i][1]*2.0f)) {
bestIndex = i;
break;
}
}
- if(bestIndex != -1) {
+ if (bestIndex != -1) {
wasChange = TRUE;
// it is a good place to stop if it tries to move the opposite direction
// (relative to the plane) of last time
- if(lastIndex != -1) {
- if(wasUp != upDown[bestIndex]) {
+ if (lastIndex != -1) {
+ if (wasUp != upDown[bestIndex]) {
wasChange = FALSE;
}
}
@@ -1063,22 +1065,23 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
wasUp = upDown[bestIndex];
dw = (dvert->dw+dwIndices[bestIndex]);
oldw = dw->weight;
- if(upDown[bestIndex]) {
+ if (upDown[bestIndex]) {
dw->weight *= 1+cp;
- } else {
+ }
+ else {
dw->weight /= 1+cp;
}
- if(dw->weight > 1) {
+ if (dw->weight > 1) {
dw->weight = 1;
}
- if(oldw == dw->weight) {
+ if (oldw == dw->weight) {
wasChange = FALSE;
}
- if(dm) {
+ if (dm) {
dm_deform_clear(dm, ob); dm = NULL;
}
}
- } while(wasChange && (distToStart-distToBe)/fabsf(distToStart-distToBe) ==
+ } while (wasChange && (distToStart-distToBe)/fabsf(distToStart-distToBe) ==
(dists[bestIndex]-distToBe)/fabsf(dists[bestIndex]-distToBe));
MEM_freeN(upDown);
MEM_freeN(changes);
@@ -1087,7 +1090,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
}
/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex
-but it could be used to raise or lower an existing 'bump.' */
+ * but it could be used to raise or lower an existing 'bump.' */
static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, float cp)
{
int i;
@@ -1095,24 +1098,24 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
Mesh *me = ob->data;
MVert *mvert = me->mvert;
int *verts = NULL;
- if(!(me->editflag & ME_EDIT_VERT_SEL))
+ if (!(me->editflag & ME_EDIT_VERT_SEL))
return;
- for(i = 0; i < me->totvert && mvert; i++, mvert++) {
- if(mvert->flag & SELECT) {
+ for (i = 0; i < me->totvert && mvert; i++, mvert++) {
+ if (mvert->flag & SELECT) {
int count=0;
- if((verts = getSurroundingVerts(me, i, &count))) {
+ if ((verts = getSurroundingVerts(me, i, &count))) {
MVert m;
MVert *p = MEM_callocN(sizeof(MVert)*(count), "deformedPoints");
int k;
DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
k = count;
- while(k--) {
+ while (k--) {
dm->getVert(dm, verts[k], &m);
p[k] = m;
}
- if(count >= 3) {
+ if (count >= 3) {
float d /*, dist */ /* UNUSED */, mag;
float coord[3];
float norm[3];
@@ -1120,7 +1123,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
dm->getVert(dm, i, &m);
sub_v3_v3v3(norm, m.co, coord);
mag= normalize_v3(norm);
- if(mag) { /* zeros fix */
+ if (mag) { /* zeros fix */
d = -dot_v3v3(norm, coord);
/* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */
moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
@@ -1141,8 +1144,7 @@ static void vgroup_levels(Object *ob, float offset, float gain)
int i, dvert_tot=0;
const int def_nr= ob->actdef-1;
- Mesh *me = ob->data;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1151,15 +1153,15 @@ static void vgroup_levels(Object *ob, float offset, float gain)
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
if (dvert_array) {
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
dw = defvert_find_index(dv, def_nr);
- if(dw) {
+ if (dw) {
dw->weight = gain * (dw->weight + offset);
CLAMP(dw->weight, 0.0f, 1.0f);
@@ -1177,8 +1179,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
int i, dvert_tot=0;
const int def_nr= ob->actdef-1;
- Mesh *me = ob->data;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
if (lock_active && !BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1187,10 +1188,10 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
if (dvert_array) {
- if(lock_active) {
+ if (lock_active) {
- for(i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ for (i = 0; i < dvert_tot; i++) {
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
@@ -1199,9 +1200,9 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
}
}
else {
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
@@ -1218,17 +1219,17 @@ static void vgroup_lock_all(Object *ob, int action)
{
bDeformGroup *dg;
- if(action == SEL_TOGGLE) {
+ if (action == SEL_TOGGLE) {
action= SEL_SELECT;
- for(dg= ob->defbase.first; dg; dg= dg->next) {
- if(dg->flag & DG_LOCK_WEIGHT) {
+ for (dg= ob->defbase.first; dg; dg= dg->next) {
+ if (dg->flag & DG_LOCK_WEIGHT) {
action= SEL_DESELECT;
break;
}
}
}
- for(dg= ob->defbase.first; dg; dg= dg->next) {
+ for (dg= ob->defbase.first; dg; dg= dg->next) {
switch(action) {
case SEL_SELECT:
dg->flag |= DG_LOCK_WEIGHT;
@@ -1249,9 +1250,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;
-
- Mesh *me = ob->data;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1260,9 +1259,9 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
if (dvert_array) {
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
@@ -1274,10 +1273,10 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_
dw= defvert_find_index(dv, def_nr);
}
- if(dw) {
+ if (dw) {
dw->weight = 1.0f - dw->weight;
- if(auto_remove && dw->weight <= 0.0f) {
+ if (auto_remove && dw->weight <= 0.0f) {
defvert_remove_group(dv, dw);
}
}
@@ -1287,84 +1286,132 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_
}
}
-static void vgroup_blend(Object *ob)
+static void vgroup_blend(Object *ob, const float fac)
{
+ MDeformVert *dv;
MDeformWeight *dw;
- MDeformVert *dvert_array=NULL, *dvert;
int i, dvert_tot=0;
- const int def_nr= ob->actdef-1;
+ const int def_nr= ob->actdef - 1;
- BMEditMesh *em= ((Mesh *)ob->data)->edit_btmesh;
- // ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot);
+ BLI_assert(fac >= 0.0 && fac <= 1.0f);
- if (em==NULL)
+ if (ob->type != OB_MESH) {
return;
+ }
if (BLI_findlink(&ob->defbase, def_nr)) {
+ const float ifac = 1.0f - fac;
+ int i1, i2;
+
+ BMEditMesh *em = BMEdit_FromObject(ob);
+ BMesh *bm = em ? em->bm : NULL;
+ Mesh *me = em ? NULL : ob->data;
+
+ /* bmesh only*/
BMEdge *eed;
BMVert *eve;
BMIter iter;
- int i1, i2;
+ /* mesh only */
+ MDeformVert *dvert_array = NULL;
+
float *vg_weights;
float *vg_users;
int sel1, sel2;
- BM_mesh_elem_index_ensure(em->bm, BM_VERT);
+ if (bm) {
+ BM_mesh_elem_index_ensure(bm, BM_VERT);
+ dvert_tot = bm->totvert;
+ }
+ else {
+ dvert_tot = me->totvert;
+ dvert_array = me->dvert;
+ }
- dvert_tot= em->bm->totvert;
+ vg_weights = MEM_callocN(sizeof(float) * dvert_tot, "vgroup_blend_f");
+ vg_users = MEM_callocN(sizeof(int) * dvert_tot, "vgroup_blend_i");
- vg_weights= MEM_callocN(sizeof(float)*dvert_tot, "vgroup_blend_f");
- vg_users= MEM_callocN(sizeof(int)*dvert_tot, "vgroup_blend_i");
+ if (bm) {
+ BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
+ sel1 = BM_elem_flag_test(eed->v1, BM_ELEM_SELECT);
+ sel2 = BM_elem_flag_test(eed->v2, BM_ELEM_SELECT);
- BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
- sel1= BM_elem_flag_test(eed->v1, BM_ELEM_SELECT);
- sel2= BM_elem_flag_test(eed->v2, BM_ELEM_SELECT);
+ if (sel1 != sel2) {
+ /* i1 is always the selected one */
+ if (sel1) {
+ i1= BM_elem_index_get(eed->v1);
+ i2= BM_elem_index_get(eed->v2);
+ eve= eed->v2;
+ }
+ else {
+ i2= BM_elem_index_get(eed->v1);
+ i1= BM_elem_index_get(eed->v2);
+ eve= eed->v1;
+ }
- if(sel1 != sel2) {
- /* i1 is always the selected one */
- if(sel1==TRUE && sel2==FALSE) {
- i1= BM_elem_index_get(eed->v1);
- i2= BM_elem_index_get(eed->v2);
- eve= eed->v2;
- }
- else {
- i2= BM_elem_index_get(eed->v1);
- i1= BM_elem_index_get(eed->v2);
- eve= eed->v1;
+ dv = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT);
+ dw = defvert_find_index(dv, def_nr);
+ if (dw) {
+ vg_weights[i1] += dw->weight;
+ }
+ vg_users[i1]++;
}
+ }
- vg_users[i1]++;
-
- /* TODO, we may want object mode blending */
- if(em) dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- else dvert= dvert_array+i2;
-
- dw= defvert_find_index(dvert, def_nr);
+ BM_ITER_INDEX(eve, &iter, bm, BM_VERTS_OF_MESH, NULL, i) {
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && vg_users[i] > 0) {
+ dv = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT);
- if(dw) {
- vg_weights[i1] += dw->weight;
+ dw = defvert_verify_index(dv, def_nr);
+ dw->weight = (fac * (vg_weights[i] / (float)vg_users[i])) + (ifac * dw->weight);
+ /* in case of division errors */
+ CLAMP(dw->weight, 0.0f, 1.0f);
}
}
}
+ else {
+ MEdge *ed = me->medge;
+ MVert *mv;
- i= 0;
- BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if(BM_elem_flag_test(eve, BM_ELEM_SELECT) && vg_users[i] > 0) {
- /* TODO, we may want object mode blending */
- if(em) dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- else dvert= dvert_array+i;
+ for (i = 0; i < me->totedge; i++, ed++) {
+ sel1 = me->mvert[ed->v1].flag & SELECT;
+ sel2 = me->mvert[ed->v2].flag & SELECT;
- dw= defvert_verify_index(dvert, def_nr);
- dw->weight= vg_weights[i] / (float)vg_users[i];
+ if (sel1 != sel2) {
+ /* i1 is always the selected one */
+ if (sel1) {
+ i1 = ed->v1;
+ i2 = ed->v2;
+ }
+ else {
+ i2 = ed->v1;
+ i1 = ed->v2;
+ }
- /* incase of division errors */
- CLAMP(dw->weight, 0.0f, 1.0f);
+ dv = &dvert_array[i2];
+ dw = defvert_find_index(dv, def_nr);
+ if (dw) {
+ vg_weights[i1] += dw->weight;
+ }
+ vg_users[i1]++;
+ }
}
- i++;
+ mv = me->mvert;
+ dv = dvert_array;
+
+ for (i = 0; i < dvert_tot; i++, mv++, dv++) {
+ if ((mv->flag & SELECT) && (vg_users[i] > 0)) {
+ dw = defvert_verify_index(dv, def_nr);
+ dw->weight = (fac * (vg_weights[i] / (float)vg_users[i])) + (ifac * dw->weight);
+
+ /* in case of division errors */
+ CLAMP(dw->weight, 0.0f, 1.0f);
+ }
+ }
}
+
MEM_freeN(vg_weights);
MEM_freeN(vg_users);
}
@@ -1376,9 +1423,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single)
MDeformVert *dv, **dvert_array=NULL;
int i, dvert_tot=0;
const int def_nr= ob->actdef-1;
-
- Mesh *me = ob->data;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
@@ -1388,9 +1433,9 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single)
if (dvert_array) {
/* only the active group */
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
@@ -1399,7 +1444,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single)
if (dw) {
if (dw->weight <= epsilon) {
- if(keep_single==FALSE || dv->totweight > 1) {
+ if (keep_single==FALSE || dv->totweight > 1) {
defvert_remove_group(dv, dw); /* dw can be NULL */
}
}
@@ -1413,10 +1458,8 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single)
static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_single)
{
MDeformVert **dvert_array=NULL;
- int i, dvert_tot=0;
-
- Mesh *me = ob->data;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ int i, dvert_tot = 0;
+ const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel);
@@ -1424,24 +1467,24 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin
MDeformVert *dv;
MDeformWeight *dw;
- for(i = 0; i < dvert_tot; i++) {
+ for (i = 0; i < dvert_tot; i++) {
int j;
- /* incase its not selected */
+ /* in case its not selected */
if (!(dv = dvert_array[i])) {
continue;
}
j= dv->totweight;
- while(j--) {
+ while (j--) {
- if(keep_single && dv->totweight == 1)
+ if (keep_single && dv->totweight == 1)
break;
dw= dv->dw + j;
- if(dw->weight <= epsilon) {
+ if (dw->weight <= epsilon) {
defvert_remove_group(dv, dw);
}
}
@@ -1460,9 +1503,9 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
{
BLI_assert(sel || sel_mirr);
- if(sel_mirr && sel) {
+ if (sel_mirr && sel) {
/* swap */
- if(mirror_weights) {
+ if (mirror_weights) {
if (all_vgroups) {
SWAP(MDeformVert, *dvert, *dvert_mirr);
}
@@ -1481,18 +1524,18 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
}
}
- if(flip_vgroups) {
+ if (flip_vgroups) {
defvert_flip(dvert, flip_map, flip_map_len);
defvert_flip(dvert_mirr, flip_map, flip_map_len);
}
}
else {
/* dvert should always be the target, only swaps pointer */
- if(sel_mirr) {
+ if (sel_mirr) {
SWAP(MDeformVert *, dvert, dvert_mirr);
}
- if(mirror_weights) {
+ if (mirror_weights) {
if (all_vgroups) {
defvert_copy(dvert, dvert_mirr);
}
@@ -1502,7 +1545,7 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
}
/* flip map already modified for 'all_vgroups' */
- if(flip_vgroups) {
+ if (flip_vgroups) {
defvert_flip(dvert, flip_map, flip_map_len);
}
}
@@ -1551,45 +1594,45 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
}
/* only the active group */
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= ob->data;
BMEditMesh *em = me->edit_btmesh;
if (em) {
BMIter iter;
- if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
+ if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
goto cleanup;
}
- EDBM_CacheMirrorVerts(em, FALSE);
+ EDBM_verts_mirror_cache_begin(em, FALSE);
/* Go through the list of editverts and assign them */
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
- if((eve_mirr= EDBM_GetMirrorVert(em, eve))) {
+ if ((eve_mirr= EDBM_verts_mirror_get(em, eve))) {
sel= BM_elem_flag_test(eve, BM_ELEM_SELECT);
sel_mirr= BM_elem_flag_test(eve_mirr, BM_ELEM_SELECT);
- if((sel || sel_mirr) && (eve != eve_mirr)) {
+ if ((sel || sel_mirr) && (eve != eve_mirr)) {
dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
dvert_mirr= CustomData_bmesh_get(&em->bm->vdata, eve_mirr->head.data, CD_MDEFORMVERT);
- if(dvert && dvert_mirr) {
+ if (dvert && dvert_mirr) {
VGROUP_MIRR_OP;
}
}
/* don't use these again */
- EDBM_ClearMirrorVert(em, eve);
- EDBM_ClearMirrorVert(em, eve_mirr);
+ EDBM_verts_mirror_cache_clear(em, eve);
+ EDBM_verts_mirror_cache_clear(em, eve_mirr);
}
}
- EDBM_EndMirrorCache(em);
+ EDBM_verts_mirror_cache_end(em);
}
else {
/* object mode / weight paint */
MVert *mv, *mv_mirr;
int vidx, vidx_mirr;
- const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
+ const int use_vert_sel = (me->editflag & ME_EDIT_VERT_SEL) != 0;
if (me->dvert == NULL) {
goto cleanup;
@@ -1600,11 +1643,11 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
}
/* tag verts we have used */
- for(vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) {
+ for (vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) {
mv->flag &= ~ME_VERT_TMP_TAG;
}
- for(vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) {
+ for (vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) {
if ( ((mv->flag & ME_VERT_TMP_TAG) == 0) &&
((vidx_mirr= mesh_get_x_mirror_vert(ob, vidx)) != -1) &&
(vidx != vidx_mirr) &&
@@ -1636,20 +1679,20 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
int pntsu_half;
/* half but found up odd value */
- if(lt->pntsu == 1 || lt->dvert == NULL) {
+ if (lt->pntsu == 1 || lt->dvert == NULL) {
goto cleanup;
}
- /* unlike editmesh we know that by only looping over the first hald of
- * the 'u' indicies it will cover all points except the middle which is
+ /* unlike editmesh we know that by only looping over the first half of
+ * the 'u' indices it will cover all points except the middle which is
* ok in this case */
pntsu_half= lt->pntsu / 2;
- for(w=0; w<lt->pntsw; w++) {
- for(v=0; v<lt->pntsv; v++) {
- for(u=0; u<pntsu_half; u++) {
+ for (w=0; w<lt->pntsw; w++) {
+ for (v=0; v<lt->pntsv; v++) {
+ for (u=0; u<pntsu_half; u++) {
int u_inv= (lt->pntsu - 1) - u;
- if(u != u_inv) {
+ if (u != u_inv) {
BPoint *bp, *bp_mirr;
i1= LT_INDEX(lt, u, v, w);
@@ -1661,7 +1704,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
sel= bp->f1 & SELECT;
sel_mirr= bp_mirr->f1 & SELECT;
- if(sel || sel_mirr) {
+ if (sel || sel_mirr) {
dvert= &lt->dvert[i1];
dvert_mirr= &lt->dvert[i2];
@@ -1692,19 +1735,19 @@ static void vgroup_remap_update_users(Object *ob, int *map)
/* these cases don't use names to refer to vertex groups, so when
* they get deleted the numbers get out of sync, this corrects that */
- if(ob->soft)
+ if (ob->soft)
ob->soft->vertgroup= map[ob->soft->vertgroup];
- for(md=ob->modifiers.first; md; md=md->next) {
- if(md->type == eModifierType_Explode) {
+ for (md=ob->modifiers.first; md; md=md->next) {
+ if (md->type == eModifierType_Explode) {
emd= (ExplodeModifierData*)md;
emd->vgroup= map[emd->vgroup];
}
- else if(md->type == eModifierType_Cloth) {
+ else if (md->type == eModifierType_Cloth) {
clmd= (ClothModifierData*)md;
clsim= clmd->sim_parms;
- if(clsim) {
+ if (clsim) {
clsim->vgroup_mass= map[clsim->vgroup_mass];
clsim->vgroup_bend= map[clsim->vgroup_bend];
clsim->vgroup_struct= map[clsim->vgroup_struct];
@@ -1712,8 +1755,8 @@ static void vgroup_remap_update_users(Object *ob, int *map)
}
}
- for(psys=ob->particlesystem.first; psys; psys=psys->next) {
- for(a=0; a<PSYS_TOT_VG; a++)
+ for (psys=ob->particlesystem.first; psys; psys=psys->next) {
+ for (a=0; a<PSYS_TOT_VG; a++)
psys->vgroup[a]= map[psys->vgroup[a]];
}
}
@@ -1725,8 +1768,8 @@ static void vgroup_delete_update_users(Object *ob, int id)
int *map= MEM_mallocN(sizeof(int) * defbase_tot, "vgroup del");
map[id]= map[0]= 0;
- for(i=1; i<id; i++) map[i]=i;
- for(i=id+1; i<defbase_tot; i++) map[i]=i-1;
+ for (i=1; i<id; i++) map[i]=i;
+ for (i=id+1; i<defbase_tot; i++) map[i]=i-1;
vgroup_remap_update_users(ob, map);
MEM_freeN(map);
@@ -1743,18 +1786,18 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg)
ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot);
- if(dvert_array) {
+ if (dvert_array) {
int i, j;
MDeformVert *dv;
- for(i= 0, dv= dvert_array; i < dvert_tot; i++, dv++) {
+ for (i= 0, dv= dvert_array; i < dvert_tot; i++, dv++) {
MDeformWeight *dw;
dw= defvert_find_index(dv, def_nr);
defvert_remove_group(dv, dw); /* dw can be NULL */
/* inline, make into a function if anything else needs to do this */
- for(j = 0; j < dv->totweight; j++) {
- if(dv->dw[j].def_nr > def_nr) {
+ for (j = 0; j < dv->totweight; j++) {
+ if (dv->dw[j].def_nr > def_nr) {
dv->dw[j].def_nr--;
}
}
@@ -1768,9 +1811,9 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg)
BLI_freelinkN(&ob->defbase, dg);
/* Update the active deform index if necessary */
- if(ob->actdef > def_nr)
+ if (ob->actdef > def_nr)
ob->actdef--;
- if(ob->actdef < 1 && ob->defbase.first)
+ if (ob->actdef < 1 && ob->defbase.first)
ob->actdef= 1;
}
@@ -1782,7 +1825,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr
MDeformVert *dv;
const int def_nr= BLI_findindex(&ob->defbase, dg);
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= ob->data;
if (me->edit_btmesh) {
@@ -1793,7 +1836,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- if(dv && dv->dw && (allverts || BM_elem_flag_test(eve, BM_ELEM_SELECT))) {
+ if (dv && dv->dw && (allverts || BM_elem_flag_test(eve, BM_ELEM_SELECT))) {
MDeformWeight *dw = defvert_find_index(dv, def_nr);
defvert_remove_group(dv, dw); /* dw can be NULL */
}
@@ -1821,15 +1864,15 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr
}
}
}
- else if(ob->type == OB_LATTICE) {
+ else if (ob->type == OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
- if(lt->dvert) {
+ if (lt->dvert) {
BPoint *bp;
int i, tot= lt->pntsu*lt->pntsv*lt->pntsw;
- for(i=0, bp= lt->def; i<tot; i++, bp++) {
- if(allverts || (bp->f1 & SELECT)) {
+ for (i=0, bp= lt->def; i<tot; i++, bp++) {
+ if (allverts || (bp->f1 & SELECT)) {
MDeformWeight *dw;
dv= &lt->dvert[i];
@@ -1853,7 +1896,7 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg)
vgroup_active_remove_verts(ob, TRUE, dg);
/* Make sure that any verts with higher indices are adjusted accordingly */
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
BMEditMesh *em = me->edit_btmesh;
BMIter iter;
@@ -1863,23 +1906,23 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg)
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- if(dvert)
- for(i=0; i<dvert->totweight; i++)
- if(dvert->dw[i].def_nr > dg_index)
+ if (dvert)
+ for (i=0; i<dvert->totweight; i++)
+ if (dvert->dw[i].def_nr > dg_index)
dvert->dw[i].def_nr--;
}
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
BPoint *bp;
MDeformVert *dvert= lt->dvert;
int a, tot;
- if(dvert) {
+ if (dvert) {
tot= lt->pntsu*lt->pntsv*lt->pntsw;
- for(a=0, bp= lt->def; a<tot; a++, bp++, dvert++) {
- for(i=0; i<dvert->totweight; i++){
- if(dvert->dw[i].def_nr > dg_index)
+ for (a=0, bp= lt->def; a<tot; a++, bp++, dvert++) {
+ for (i=0; i<dvert->totweight; i++) {
+ if (dvert->dw[i].def_nr > dg_index)
dvert->dw[i].def_nr--;
}
}
@@ -1892,21 +1935,21 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg)
BLI_freelinkN (&ob->defbase, dg);
/* Update the active deform index if necessary */
- if(ob->actdef > dg_index)
+ if (ob->actdef > dg_index)
ob->actdef--;
- if(ob->actdef < 1 && ob->defbase.first)
+ if (ob->actdef < 1 && ob->defbase.first)
ob->actdef= 1;
/* remove all dverts */
- if(ob->defbase.first == NULL) {
- if(ob->type==OB_MESH) {
+ if (ob->defbase.first == NULL) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
me->dvert= NULL;
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
- if(lt->dvert) {
+ if (lt->dvert) {
MEM_freeN(lt->dvert);
lt->dvert= NULL;
}
@@ -1916,9 +1959,9 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg)
static int vgroup_object_in_edit_mode(Object *ob)
{
- if(ob->type == OB_MESH)
- return (((Mesh*)ob->data)->edit_btmesh != NULL);
- else if(ob->type == OB_LATTICE)
+ if (ob->type == OB_MESH)
+ return (BMEdit_FromObject(ob) != NULL);
+ else if (ob->type == OB_LATTICE)
return (((Lattice*)ob->data)->editlatt != NULL);
return 0;
@@ -1939,10 +1982,10 @@ static int vgroup_object_in_wpaint_vert_select(Object *ob)
static void vgroup_delete(Object *ob)
{
bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef-1);
- if(!dg)
+ if (!dg)
return;
- if(vgroup_object_in_edit_mode(ob))
+ if (vgroup_object_in_edit_mode(ob))
vgroup_delete_edit_mode(ob, dg);
else
vgroup_delete_object_mode(ob, dg);
@@ -1951,14 +1994,14 @@ static void vgroup_delete(Object *ob)
static void vgroup_delete_all(Object *ob)
{
/* Remove all DVerts */
- if(ob->type==OB_MESH) {
+ if (ob->type==OB_MESH) {
Mesh *me= ob->data;
CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
me->dvert= NULL;
}
- else if(ob->type==OB_LATTICE) {
+ else if (ob->type==OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
- if(lt->dvert) {
+ if (lt->dvert) {
MEM_freeN(lt->dvert);
lt->dvert= NULL;
}
@@ -1977,10 +2020,10 @@ static void vgroup_assign_verts(Object *ob, const float weight)
MDeformVert *dv;
const int def_nr= ob->actdef-1;
- if(!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr))
return;
- if(ob->type == OB_MESH) {
+ if (ob->type == OB_MESH) {
Mesh *me= ob->data;
if (me->edit_btmesh) {
@@ -1988,7 +2031,7 @@ static void vgroup_assign_verts(Object *ob, const float weight)
BMIter iter;
BMVert *eve;
- if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT))
+ if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT))
BM_data_layer_add(em->bm, &em->bm->vdata, CD_MDEFORMVERT);
/* Go through the list of editverts and assign them */
@@ -2026,19 +2069,19 @@ static void vgroup_assign_verts(Object *ob, const float weight)
}
}
}
- else if(ob->type == OB_LATTICE) {
+ else if (ob->type == OB_LATTICE) {
Lattice *lt= vgroup_edit_lattice(ob);
BPoint *bp;
int a, tot;
- if(lt->dvert==NULL)
+ if (lt->dvert==NULL)
ED_vgroup_data_create(&lt->id);
dv= lt->dvert;
tot= lt->pntsu*lt->pntsv*lt->pntsw;
- for(a=0, bp= lt->def; a<tot; a++, bp++, dv++) {
- if(bp->f1 & SELECT) {
+ for (a=0, bp= lt->def; a<tot; a++, bp++, dv++) {
+ if (bp->f1 & SELECT) {
MDeformWeight *dw;
dw= defvert_verify_index(dv, def_nr);
@@ -2059,7 +2102,7 @@ static void vgroup_remove_verts(Object *ob, int allverts)
* active group index
*/
bDeformGroup *dg;
- for(dg= ob->defbase.first; dg; dg= dg->next) {
+ for (dg= ob->defbase.first; dg; dg= dg->next) {
vgroup_active_remove_verts(ob, allverts, dg);
}
}
@@ -2073,12 +2116,12 @@ static int vertex_group_poll(bContext *C)
return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib);
}
-static int UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C)
+static int vertex_group_poll_edit(bContext *C)
{
Object *ob= ED_object_context(C);
ID *data= (ob)? ob->data: NULL;
- if(!(ob && !ob->id.lib && data && !data->lib))
+ if (!(ob && !ob->id.lib && data && !data->lib))
return 0;
return vgroup_object_in_edit_mode(ob);
@@ -2090,7 +2133,7 @@ static int vertex_group_poll_edit_or_wpaint_vert_select(bContext *C)
Object *ob= ED_object_context(C);
ID *data= (ob)? ob->data: NULL;
- if(!(ob && !ob->id.lib && data && !data->lib))
+ if (!(ob && !ob->id.lib && data && !data->lib))
return 0;
return ( vgroup_object_in_edit_mode(ob) ||
@@ -2112,22 +2155,22 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_vertex_group_add(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Add Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_add";
+ ot->name = "Add Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_add";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_add_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_add_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int vertex_group_remove_exec(bContext *C, wmOperator *op)
{
Object *ob= ED_object_context(C);
- if(RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all"))
vgroup_delete_all(ob);
else
vgroup_delete(ob);
@@ -2142,18 +2185,18 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_remove(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_remove";
+ ot->name = "Remove Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_remove";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_remove_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_remove_exec;
/* flags */
/* redo operator will fail in this case because vertex groups aren't stored
- in local edit mode stack and toggling "all" property will lead to
- all groups deleted without way to restore them (see [#29527], sergey) */
- ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
+ * in local edit mode stack and toggling "all" property will lead to
+ * all groups deleted without way to restore them (see [#29527], sergey) */
+ ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups");
@@ -2164,7 +2207,7 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *op)
ToolSettings *ts= CTX_data_tool_settings(C);
Object *ob= ED_object_context(C);
- if(RNA_boolean_get(op->ptr, "new"))
+ if (RNA_boolean_get(op->ptr, "new"))
ED_vgroup_add(ob);
vgroup_assign_verts(ob, ts->vgroup_weight);
@@ -2177,18 +2220,18 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_assign(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Assign Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_assign";
+ ot->name = "Assign Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_assign";
/* api callbacks */
- ot->poll= vertex_group_poll_edit_or_wpaint_vert_select;
- ot->exec= vertex_group_assign_exec;
+ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+ ot->exec = vertex_group_assign_exec;
/* flags */
/* redo operator will fail in this case because vertex group assignment
- isn't stored in local edit mode stack and toggling "new" property will
- lead to creating plenty of new veretx groups (see [#29527], sergey) */
- ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
+ * isn't stored in local edit mode stack and toggling "new" property will
+ * lead to creating plenty of new vertex groups (see [#29527], sergey) */
+ ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "new", 0, "New", "Assign vertex to new vertex group");
@@ -2198,12 +2241,12 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op)
{
Object *ob= ED_object_context(C);
- if(RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all"))
vgroup_remove_verts(ob, 0);
else {
bDeformGroup *dg= BLI_findlink(&ob->defbase, ob->actdef - 1);
- if(dg == NULL) {
+ if (dg == NULL) {
return OPERATOR_CANCELLED;
}
@@ -2219,18 +2262,18 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Remove from Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_remove_from";
+ ot->name = "Remove from Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_remove_from";
/* api callbacks */
- ot->poll= vertex_group_poll_edit_or_wpaint_vert_select;
- ot->exec= vertex_group_remove_from_exec;
+ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+ ot->exec = vertex_group_remove_from_exec;
/* flags */
- /* redo operator will fail in this case because vertex groups ssignment
- isn't stored in local edit mode stack and toggling "all" property will lead to
- removing vertices from all groups (see [#29527], sergey) */
- ot->flag= /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
+ /* redo operator will fail in this case because vertex groups assignment
+ * isn't stored in local edit mode stack and toggling "all" property will lead to
+ * removing vertices from all groups (see [#29527], sergey) */
+ ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups");
@@ -2240,7 +2283,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
- if(!ob || ob->id.lib)
+ if (!ob || ob->id.lib)
return OPERATOR_CANCELLED;
vgroup_select_verts(ob, 1);
@@ -2252,15 +2295,15 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_vertex_group_select(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Select Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_select";
+ ot->name = "Select Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_select";
/* api callbacks */
- ot->poll= vertex_group_poll_edit_or_wpaint_vert_select;
- ot->exec= vertex_group_select_exec;
+ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+ ot->exec = vertex_group_select_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
@@ -2276,15 +2319,15 @@ static int vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Deselect Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_deselect";
+ ot->name = "Deselect Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_deselect";
/* api callbacks */
- ot->poll= vertex_group_poll_edit_or_wpaint_vert_select;
- ot->exec= vertex_group_deselect_exec;
+ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select;
+ ot->exec = vertex_group_deselect_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/*Adds a copy of selected vertex group from source object to source object*/
@@ -2303,15 +2346,15 @@ static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_vertex_group_copy(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_copy";
+ ot->name = "Copy Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_copy";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_copy_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_copy_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int vertex_group_levels_exec(bContext *C, wmOperator *op)
@@ -2333,15 +2376,15 @@ static int vertex_group_levels_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_levels(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Vertex Group Levels";
- ot->idname= "OBJECT_OT_vertex_group_levels";
+ ot->name = "Vertex Group Levels";
+ ot->idname = "OBJECT_OT_vertex_group_levels";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_levels_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_levels_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_float(ot->srna, "offset", 0.f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.f);
RNA_def_float(ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.f);
@@ -2363,15 +2406,15 @@ static int vertex_group_normalize_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Normalize Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_normalize";
+ ot->name = "Normalize Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_normalize";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_normalize_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_normalize_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op)
@@ -2391,15 +2434,15 @@ static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Normalize All Vertex Groups";
- ot->idname= "OBJECT_OT_vertex_group_normalize_all";
+ ot->name = "Normalize All Vertex Groups";
+ ot->idname = "OBJECT_OT_vertex_group_normalize_all";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_normalize_all_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_normalize_all_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "lock_active", TRUE, "Lock Active",
"Keep the values of the active group while normalizing others");
@@ -2415,14 +2458,14 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
float cp= RNA_float_get(op->ptr, "accuracy");
ModifierData *md= ob->modifiers.first;
- while(md) {
- if(md->type == eModifierType_Mirror && (md->mode&eModifierMode_Realtime)) {
+ while (md) {
+ if (md->type == eModifierType_Mirror && (md->mode&eModifierMode_Realtime)) {
break;
}
md = md->next;
}
- if(md && md->type == eModifierType_Mirror) {
+ if (md && md->type == eModifierType_Mirror) {
BKE_report(op->reports, RPT_ERROR_INVALID_CONTEXT, "This operator does not support an active mirror modifier");
return OPERATOR_CANCELLED;
}
@@ -2438,17 +2481,17 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Fix Vertex Group Deform";
- ot->idname= "OBJECT_OT_vertex_group_fix";
- ot->description= "Modify the position of selected vertices by changing only their respective "
+ ot->name = "Fix Vertex Group Deform";
+ ot->idname = "OBJECT_OT_vertex_group_fix";
+ ot->description = "Modify the position of selected vertices by changing only their respective "
"groups' weights (this tool may be slow for many vertices)";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_fix_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_fix_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_float(ot->srna, "dist", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "The distance to move to", -10.0f, 10.0f);
RNA_def_float(ot->srna, "strength", 1.f, -2.0f, FLT_MAX, "Strength",
"The distance moved can be changed by this multiplier", -2.0f, 2.0f);
@@ -2471,15 +2514,15 @@ static int vertex_group_lock_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_lock(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Change the Lock On Vertex Groups";
- ot->idname= "OBJECT_OT_vertex_group_lock";
+ ot->name = "Change the Lock On Vertex Groups";
+ ot->idname = "OBJECT_OT_vertex_group_lock";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_lock_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_lock_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
@@ -2501,15 +2544,15 @@ static int vertex_group_invert_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_invert(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Invert Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_invert";
+ ot->name = "Invert Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_invert";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_invert_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_invert_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "auto_assign", TRUE, "Add Weights",
"Add verts from groups that have zero weight before inverting");
@@ -2518,11 +2561,12 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot)
}
-static int vertex_group_blend_exec(bContext *C, wmOperator *UNUSED(op))
+static int vertex_group_blend_exec(bContext *C, wmOperator *op)
{
- Object *ob= ED_object_context(C);
+ Object *ob = ED_object_context(C);
+ float fac = RNA_float_get(op->ptr, "factor");
- vgroup_blend(ob);
+ vgroup_blend(ob, fac);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
@@ -2531,19 +2575,53 @@ static int vertex_group_blend_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
+/* check we have a vertex selection, either in weight paint or editmode */
+static int vertex_group_blend_poll(bContext *C)
+{
+ Object *ob = ED_object_context(C);
+ ID *data = (ob) ? ob->data: NULL;
+
+ if (!(ob && !ob->id.lib && data && !data->lib))
+ return FALSE;
+
+ if (vgroup_object_in_edit_mode(ob)) {
+ return TRUE;
+ }
+ else if ((ob->type == OB_MESH) && (ob->mode & OB_MODE_WEIGHT_PAINT)) {
+ if (ME_EDIT_PAINT_SEL_MODE(((Mesh *)data)) == SCE_SELECT_VERTEX) {
+ return TRUE;
+ }
+ else {
+ CTX_wm_operator_poll_msg_set(C, "Vertex select needs to be enabled in weight paint mode");
+ return FALSE;
+ }
+
+ }
+ else {
+ return FALSE;
+ }
+}
+
void OBJECT_OT_vertex_group_blend(wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
/* identifiers */
- ot->name= "Blend Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_blend";
- ot->description= "";
+ ot->name = "Blend Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_blend";
+ ot->description = "Blend selected vertex weights with unselected for the active group";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_blend_exec;
+ ot->poll = vertex_group_blend_poll;
+ ot->exec = vertex_group_blend_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ prop = RNA_def_property(ot->srna, "factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_ui_text(prop, "Factor", "");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_default(prop, 1.0f);
}
@@ -2555,7 +2633,7 @@ static int vertex_group_clean_exec(bContext *C, wmOperator *op)
int all_groups= RNA_boolean_get(op->ptr,"all_groups");
int keep_single= RNA_boolean_get(op->ptr,"keep_single");
- if(all_groups) vgroup_clean_all(ob, limit, keep_single);
+ if (all_groups) vgroup_clean_all(ob, limit, keep_single);
else vgroup_clean(ob, limit, keep_single);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -2568,16 +2646,16 @@ static int vertex_group_clean_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_clean(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Clean Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_clean";
- ot->description= "Remove Vertex Group assignments which aren't required";
+ ot->name = "Clean Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_clean";
+ ot->description = "Remove Vertex Group assignments which aren't required";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_clean_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_clean_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, 1.0, "Limit", "Remove weights under this limit", 0.001f, 0.99f);
RNA_def_boolean(ot->srna, "all_groups", FALSE, "All Groups", "Clean all vertex groups");
@@ -2605,17 +2683,17 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Mirror Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_mirror";
- ot->description= "Mirror all vertex groups, flip weights and/or names, editing only selected vertices, "
+ ot->name = "Mirror Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_mirror";
+ ot->description = "Mirror all vertex groups, flip weights and/or names, editing only selected vertices, "
"flipping when both sides are selected otherwise copy from unselected";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_mirror_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_mirror_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "mirror_weights", TRUE, "Mirror Weights", "Mirror weights");
@@ -2631,9 +2709,9 @@ static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op))
Base *base;
int retval= OPERATOR_CANCELLED;
- for(base=scene->base.first; base; base= base->next) {
- if(base->object->type==ob->type) {
- if(base->object!=ob && base->object->data==ob->data) {
+ for (base=scene->base.first; base; base= base->next) {
+ if (base->object->type==ob->type) {
+ if (base->object!=ob && base->object->data==ob->data) {
BLI_freelistN(&base->object->defbase);
BLI_duplicatelist(&base->object->defbase, &ob->defbase);
base->object->actdef= ob->actdef;
@@ -2653,16 +2731,16 @@ static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Vertex Groups to Linked";
- ot->idname= "OBJECT_OT_vertex_group_copy_to_linked";
- ot->description= "Copy Vertex Groups to all users of the same Geometry data";
+ ot->name = "Copy Vertex Groups to Linked";
+ ot->idname = "OBJECT_OT_vertex_group_copy_to_linked";
+ ot->description = "Copy Vertex Groups to all users of the same Geometry data";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_copy_to_linked_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_copy_to_linked_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
/*Copy vertex groups from source to target*/ /*warning! overwrites list*/
@@ -2674,16 +2752,16 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
{
- if(obact != ob) {
- if(ED_vgroup_copy_array(ob, obact)) change++;
+ if (obact != ob) {
+ if (ED_vgroup_copy_array(ob, obact)) change++;
else fail++;
}
}
CTX_DATA_END;
- if((change == 0 && fail == 0) || fail) {
+ if ((change == 0 && fail == 0) || fail) {
BKE_reportf(op->reports, RPT_ERROR,
- "Copy to VGroups to Selected warning done %d, failed %d, object data must have matching indicies",
+ "Copy to VGroups to Selected warning done %d, failed %d, object data must have matching indices",
change, fail);
}
@@ -2694,16 +2772,16 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "Copy Vertex Group to Selected";
- ot->idname= "OBJECT_OT_vertex_group_copy_to_selected";
- ot->description= "Copy Vertex Groups to other selected objects with matching indices";
+ ot->name = "Copy Vertex Group to Selected";
+ ot->idname = "OBJECT_OT_vertex_group_copy_to_selected";
+ ot->description = "Copy Vertex Groups to other selected objects with matching indices";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_copy_to_selected_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_copy_to_selected_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int vertex_group_copy_to_selected_single_exec(bContext *C, wmOperator *op)
@@ -2775,10 +2853,10 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop
bDeformGroup *def;
int a, totitem= 0;
- if(!ob)
+ if (!ob)
return vgroup_items;
- for(a=0, def=ob->defbase.first; def; def=def->next, a++) {
+ for (a=0, def=ob->defbase.first; def; def=def->next, a++) {
tmp.value= a;
tmp.icon= ICON_GROUP_VERTEX;
tmp.identifier= def->name;
@@ -2797,26 +2875,26 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot)
PropertyRNA *prop;
/* identifiers */
- ot->name= "Set Active Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_set_active";
- ot->description= "Set the active vertex group";
+ ot->name = "Set Active Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_set_active";
+ ot->description = "Set the active vertex group";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= set_active_group_exec;
- ot->invoke= WM_menu_invoke;
+ ot->poll = vertex_group_poll;
+ ot->exec = set_active_group_exec;
+ ot->invoke = WM_menu_invoke;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
prop= RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active");
RNA_def_enum_funcs(prop, vgroup_itemf);
- ot->prop= prop;
+ ot->prop = prop;
}
-/*creates the name_array parameter for vgroup_do_remap, call this before fiddling
- with the order of vgroups then call vgroup_do_remap after*/
+/* creates the name_array parameter for vgroup_do_remap, call this before fiddling
+ * with the order of vgroups then call vgroup_do_remap after*/
static char *vgroup_init_remap(Object *ob)
{
bDeformGroup *def;
@@ -2825,7 +2903,7 @@ static char *vgroup_init_remap(Object *ob)
char *name;
name= name_array;
- for(def = ob->defbase.first; def; def=def->next) {
+ for (def = ob->defbase.first; def; def=def->next) {
BLI_strncpy(name, def->name, MAX_VGROUP_NAME);
name += MAX_VGROUP_NAME;
}
@@ -2847,28 +2925,28 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
int i;
name= name_array;
- for(def= ob->defbase.first, i=0; def; def=def->next, i++){
+ for (def= ob->defbase.first, i=0; def; def=def->next, i++) {
sort_map[i]= BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name));
name += MAX_VGROUP_NAME;
BLI_assert(sort_map[i] != -1);
}
- if(ob->mode == OB_MODE_EDIT) {
- if(ob->type==OB_MESH) {
- BMEditMesh *em = ((Mesh*)ob->data)->edit_btmesh;
+ if (ob->mode == OB_MODE_EDIT) {
+ if (ob->type==OB_MESH) {
+ BMEditMesh *em = BMEdit_FromObject(ob);
BMIter iter;
BMVert *eve;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
- if(dvert && dvert->totweight){
+ if (dvert && dvert->totweight) {
defvert_remap(dvert, sort_map, defbase_tot);
}
}
}
else {
- BKE_report(op->reports, RPT_ERROR, "Editmode lattice isnt supported yet");
+ BKE_report(op->reports, RPT_ERROR, "Editmode lattice isn't supported yet");
MEM_freeN(sort_map_update);
return OPERATOR_CANCELLED;
}
@@ -2878,16 +2956,16 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
ED_vgroup_give_array(ob->data, &dvert, &dvert_tot);
- /*create as necassary*/
- while(dvert && dvert_tot--) {
- if(dvert->totweight)
+ /*create as necessary*/
+ while (dvert && dvert_tot--) {
+ if (dvert->totweight)
defvert_remap(dvert, sort_map, defbase_tot);
dvert++;
}
}
/* update users */
- for(i=0; i<defbase_tot; i++)
+ for (i=0; i<defbase_tot; i++)
sort_map[i]++;
sort_map_update[0]= 0;
@@ -2936,16 +3014,16 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
void OBJECT_OT_vertex_group_sort(wmOperatorType *ot)
{
- ot->name= "Sort Vertex Groups";
- ot->idname= "OBJECT_OT_vertex_group_sort";
- ot->description= "Sorts vertex groups alphabetically";
+ ot->name = "Sort Vertex Groups";
+ ot->idname = "OBJECT_OT_vertex_group_sort";
+ ot->description = "Sorts vertex groups alphabetically";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vertex_group_sort_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vertex_group_sort_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int vgroup_move_exec(bContext *C, wmOperator *op)
@@ -2967,7 +3045,8 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
BLI_remlink(&ob->defbase, def);
BLI_insertlinkbefore(&ob->defbase, prev, def);
- } else { /*down*/
+ }
+ else { /*down*/
void *next = def->next;
BLI_remlink(&ob->defbase, def);
@@ -2995,15 +3074,15 @@ void OBJECT_OT_vertex_group_move(wmOperatorType *ot)
};
/* identifiers */
- ot->name= "Move Vertex Group";
- ot->idname= "OBJECT_OT_vertex_group_move";
+ ot->name = "Move Vertex Group";
+ ot->idname = "OBJECT_OT_vertex_group_move";
/* api callbacks */
- ot->poll= vertex_group_poll;
- ot->exec= vgroup_move_exec;
+ ot->poll = vertex_group_poll;
+ ot->exec = vgroup_move_exec;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_enum(ot->srna, "direction", vgroup_slot_move, 0, "Direction", "Direction to move, UP or DOWN");
}