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:
Diffstat (limited to 'source/blender/editors/object/object_add.c')
-rw-r--r--source/blender/editors/object/object_add.c99
1 files changed, 66 insertions, 33 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 7b6f920e59f..87782e895b5 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -216,14 +216,17 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- if (!scene)
+ if (!scene) {
return;
+ }
- if (loc)
+ if (loc) {
copy_v3_v3(ob->loc, loc);
+ }
- if (rot)
+ if (rot) {
copy_v3_v3(ob->rot, rot);
+ }
BKE_object_where_is_calc(depsgraph, scene, ob);
}
@@ -342,11 +345,13 @@ bool ED_object_add_generic_get_opts(bContext *C,
/* Switch to Edit mode? optional prop */
if ((prop = RNA_struct_find_property(op->ptr, "enter_editmode"))) {
bool _enter_editmode;
- if (!enter_editmode)
+ if (!enter_editmode) {
enter_editmode = &_enter_editmode;
+ }
- if (RNA_property_is_set(op->ptr, prop) && enter_editmode)
+ if (RNA_property_is_set(op->ptr, prop) && enter_editmode) {
*enter_editmode = RNA_property_boolean_get(op->ptr, prop);
+ }
else {
*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
@@ -363,8 +368,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
/* Location! */
{
float _loc[3];
- if (!loc)
+ if (!loc) {
loc = _loc;
+ }
if (RNA_struct_property_is_set(op->ptr, "location")) {
RNA_float_get_array(op->ptr, "location", loc);
@@ -379,15 +385,19 @@ bool ED_object_add_generic_get_opts(bContext *C,
{
bool _is_view_aligned;
float _rot[3];
- if (!is_view_aligned)
+ if (!is_view_aligned) {
is_view_aligned = &_is_view_aligned;
- if (!rot)
+ }
+ if (!rot) {
rot = _rot;
+ }
- if (RNA_struct_property_is_set(op->ptr, "rotation"))
+ if (RNA_struct_property_is_set(op->ptr, "rotation")) {
*is_view_aligned = false;
- else if (RNA_struct_property_is_set(op->ptr, "view_align"))
+ }
+ else if (RNA_struct_property_is_set(op->ptr, "view_align")) {
*is_view_aligned = RNA_boolean_get(op->ptr, "view_align");
+ }
else {
*is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
RNA_boolean_set(op->ptr, "view_align", *is_view_aligned);
@@ -397,8 +407,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
ED_object_rotation_from_view(C, rot, view_align_axis);
RNA_float_set_array(op->ptr, "rotation", rot);
}
- else
+ else {
RNA_float_get_array(op->ptr, "rotation", rot);
+ }
}
return true;
@@ -625,15 +636,17 @@ static int effector_add_exec(bContext *C, wmOperator *op)
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
BLI_addtail(&cu->editnurb->nurbs,
ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
- if (!enter_editmode)
+ if (!enter_editmode) {
ED_object_editmode_exit(C, EM_FREEDATA);
+ }
}
else {
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, local_view_bits);
BKE_object_obdata_size_init(ob, dia);
- if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX))
+ if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) {
ob->empty_drawtype = OB_SINGLE_ARROW;
+ }
}
ob->pd = BKE_partdeflect_new(type);
@@ -686,8 +699,9 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
if (v3d) {
- if (v3d->camera == NULL)
+ if (v3d->camera == NULL) {
v3d->camera = ob;
+ }
if (v3d->scenelock && scene->camera == NULL) {
scene->camera = ob;
}
@@ -797,8 +811,9 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, 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, NULL, loc, rot, enter_editmode, local_view_bits);
BKE_object_obdata_size_init(obedit, RNA_float_get(op->ptr, "radius"));
@@ -862,8 +877,9 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
ED_armature_ebone_add_primitive(obedit, dia, view_aligned);
/* userdef */
- if (newob && !enter_editmode)
+ if (newob && !enter_editmode) {
ED_object_editmode_exit(C, EM_FREEDATA);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
@@ -1246,8 +1262,9 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
RNA_float_set_array(op->ptr, "location", loc);
}
}
- else
+ else {
collection = BLI_findlink(&CTX_data_main(C)->collections, RNA_enum_get(op->ptr, "collection"));
+ }
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
@@ -1392,8 +1409,9 @@ static int object_delete_exec(bContext *C, wmOperator *op)
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
uint changed_count = 0;
- if (CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C)) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, ob);
@@ -2100,8 +2118,9 @@ 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;
+ }
cu->flag &= ~CU_3D;
BKE_curve_curve_dimension_update(cu);
@@ -2166,8 +2185,9 @@ static int convert_exec(bContext *C, wmOperator *op)
me->totcol = mb->totcol;
if (newob->totcol) {
me->mat = MEM_dupallocN(mb->mat);
- for (a = 0; a < newob->totcol; a++)
+ for (a = 0; a < newob->totcol; a++) {
id_us_plus((ID *)me->mat[a]);
+ }
}
convert_ensure_curve_cache(depsgraph, scene, baseob);
@@ -2318,8 +2338,9 @@ static Base *object_add_duplicate_internal(
if (ob->rigidbody_object || ob->rigidbody_constraint) {
Collection *collection;
for (collection = bmain->collections.first; collection; collection = collection->id.next) {
- if (BKE_collection_has_object(collection, ob))
+ if (BKE_collection_has_object(collection, ob)) {
BKE_collection_object_add(bmain, collection, obn);
+ }
}
}
}
@@ -2380,8 +2401,9 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
/* new object becomes active */
- if (BASACT(view_layer) == base)
+ if (BASACT(view_layer) == base) {
ED_object_base_activate(C, basen);
+ }
if (basen->object->data) {
DEG_id_tag_update(basen->object->data, 0);
@@ -2511,13 +2533,16 @@ static bool join_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
+ }
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE, OB_GPENCIL))
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE, OB_GPENCIL)) {
return ED_operator_screenactive(C);
- else
+ }
+ else {
return 0;
+ }
}
static int join_exec(bContext *C, wmOperator *op)
@@ -2540,14 +2565,18 @@ static int join_exec(bContext *C, wmOperator *op)
}
}
- 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);
- else if (ob->type == OB_GPENCIL)
+ }
+ else if (ob->type == OB_GPENCIL) {
return ED_gpencil_join_objects_exec(C, op);
+ }
return OPERATOR_CANCELLED;
}
@@ -2573,14 +2602,17 @@ static bool join_shapes_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
+ }
/* only meshes supported at the moment */
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return ED_operator_screenactive(C);
- else
+ }
+ else {
return 0;
+ }
}
static int join_shapes_exec(bContext *C, wmOperator *op)
@@ -2596,8 +2628,9 @@ static int join_shapes_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return join_mesh_shapes_exec(C, op);
+ }
return OPERATOR_CANCELLED;
}