diff options
author | Martin Felke <martin.felke@googlemail.com> | 2019-03-02 12:43:27 +0300 |
---|---|---|
committer | Martin Felke <martin.felke@googlemail.com> | 2019-03-02 12:43:27 +0300 |
commit | 7faf3f47363058ba4a2dfb15f180deffe706573e (patch) | |
tree | e0e3f60ecc3e133abcf09983056860cc9d6ad3bf /source/blender/editors/object | |
parent | 0c0de344aabd0fb2cfbe998d9b54ca2ac6a70120 (diff) | |
parent | 42faf52d8bcae3b33164069c4c692152cf42b9b3 (diff) |
Merge remote-tracking branch 'origin/master' into fracture_modifier-2.8
# Conflicts:
# intern/cycles/blender/blender_mesh.cpp
# intern/rigidbody/RBI_api.h
# intern/rigidbody/rb_bullet_api.cpp
# source/blender/blenkernel/BKE_rigidbody.h
# source/blender/blenkernel/intern/rigidbody.c
# source/blender/depsgraph/intern/builder/deg_builder_relations.cc
# source/blender/draw/intern/draw_manager.c
# source/blender/editors/physics/rigidbody_object.c
# source/blender/makesdna/DNA_modifier_types.h
# source/blender/makesdna/DNA_rigidbody_types.h
# source/blender/makesrna/intern/rna_modifier.c
# source/blender/makesrna/intern/rna_rigidbody.c
# source/blender/modifiers/intern/MOD_boolean.c
# source/blender/modifiers/intern/MOD_multires.c
# source/blender/modifiers/intern/MOD_remesh.c
Diffstat (limited to 'source/blender/editors/object')
24 files changed, 478 insertions, 1199 deletions
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index db8997c5e0a..f15427e61ac 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -13,9 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Contributor(s): Jacques Beaurain. -# # ***** END GPL LICENSE BLOCK ***** set(INC @@ -50,23 +47,23 @@ set(SRC object_bake_api.c object_collection.c object_constraint.c + object_data_transfer.c object_edit.c object_facemap_ops.c + object_gpencil_modifier.c object_hook.c object_modes.c object_modifier.c - object_gpencil_modifier.c - object_shader_fx.c object_ops.c object_random.c object_relations.c object_select.c + object_shader_fx.c object_shapekey.c - object_data_transfer.c object_transform.c object_utils.c - object_warp.c object_vgroup.c + object_warp.c object_intern.h ) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index c481a62acb7..b69c88ecb7f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_add.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -38,7 +32,7 @@ #include "DNA_camera_types.h" #include "DNA_collection_types.h" #include "DNA_curve_types.h" -#include "DNA_lamp_types.h" +#include "DNA_light_types.h" #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" @@ -73,7 +67,7 @@ #include "BKE_font.h" #include "BKE_gpencil.h" #include "BKE_key.h" -#include "BKE_lamp.h" +#include "BKE_light.h" #include "BKE_lattice.h" #include "BKE_layer.h" #include "BKE_library.h" @@ -90,7 +84,6 @@ #include "BKE_particle.h" #include "BKE_report.h" #include "BKE_scene.h" -#include "BKE_screen.h" #include "BKE_speaker.h" #include "DEG_depsgraph.h" @@ -121,7 +114,7 @@ #include "object_intern.h" -/* this is an exact copy of the define in rna_lamp.c +/* this is an exact copy of the define in rna_light.c * kept here because of linking order. * Icons are only defined here */ const EnumPropertyItem rna_enum_light_type_items[] = { @@ -129,7 +122,7 @@ const EnumPropertyItem rna_enum_light_type_items[] = { {LA_SUN, "SUN", ICON_LIGHT_SUN, "Sun", "Constant direction parallel ray light source"}, {LA_SPOT, "SPOT", ICON_LIGHT_SPOT, "Spot", "Directional cone light source"}, {LA_AREA, "AREA", ICON_LIGHT_AREA, "Area", "Directional area light source"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* copy from rna_object_force.c */ @@ -147,7 +140,7 @@ static const EnumPropertyItem field_type_items[] = { {PFIELD_TURBULENCE, "TURBULENCE", ICON_FORCE_TURBULENCE, "Turbulence", ""}, {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", ""}, {PFIELD_SMOKEFLOW, "SMOKE", ICON_FORCE_SMOKEFLOW, "Smoke Flow", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static EnumPropertyItem lightprobe_type_items[] = { @@ -157,7 +150,7 @@ static EnumPropertyItem lightprobe_type_items[] = { "Planar reflection probe"}, {LIGHTPROBE_TYPE_GRID, "GRID", ICON_LIGHTPROBE_GRID, "Irradiance Volume", "Irradiance probe to capture diffuse indirect lighting"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /************************** Exported *****************************/ @@ -396,7 +389,7 @@ Object *ED_object_add_type( /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) { - ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); + ED_object_editmode_exit(C, EM_FREEDATA); } /* deselects all, sets active object */ @@ -417,8 +410,9 @@ Object *ED_object_add_type( DEG_id_tag_update_ex(bmain, (ID *)ob->data, ID_RECALC_EDITORS); } - if (enter_editmode) - ED_object_editmode_enter(C, EM_IGNORE_LAYER); + if (enter_editmode) { + ED_object_editmode_enter_ex(bmain, scene, ob, 0); + } WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); @@ -446,7 +440,7 @@ static int object_add_exec(bContext *C, wmOperator *op) if (ob->type == OB_LATTICE) { /* lattice is a special case! * we never want to scale the obdata since that is the rest-state */ - copy_v3_fl(ob->size, radius); + copy_v3_fl(ob->scale, radius); } else { BKE_object_obdata_size_init(ob, radius); @@ -471,7 +465,8 @@ void OBJECT_OT_add(wmOperatorType *ot) /* properties */ ED_object_add_unit_props_radius(ot); - RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 0, "Type", ""); + PropertyRNA *prop = RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 0, "Type", ""); + RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); ED_object_add_generic_props(ot, true); } @@ -482,11 +477,11 @@ void OBJECT_OT_add(wmOperatorType *ot) static const char *get_lightprobe_defname(int type) { switch (type) { - case LIGHTPROBE_TYPE_GRID: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "IrradianceVolume"); - case LIGHTPROBE_TYPE_PLANAR: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "ReflectionPlane"); - case LIGHTPROBE_TYPE_CUBE: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "ReflectionCubemap"); + case LIGHTPROBE_TYPE_GRID: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "IrradianceVolume"); + case LIGHTPROBE_TYPE_PLANAR: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "ReflectionPlane"); + case LIGHTPROBE_TYPE_CUBE: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "ReflectionCubemap"); default: - return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "LightProbe"); + return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "LightProbe"); } } @@ -967,6 +962,23 @@ void OBJECT_OT_drop_named_image(wmOperatorType *ot) } /********************* Add Gpencil Operator ********************/ +static bool object_gpencil_add_poll(bContext *C) +{ + Scene *scene = CTX_data_scene(C); + Object *obact = CTX_data_active_object(C); + + if ((scene == NULL) || (ID_IS_LINKED(scene))) { + return false; + } + + if (obact && obact->type == OB_GPENCIL) { + if (obact->mode != OB_MODE_OBJECT) { + return false; + } + } + + return true; +} static int object_gpencil_add_exec(bContext *C, wmOperator *op) { @@ -1006,12 +1018,9 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) } } - float radius = RNA_float_get(op->ptr, "radius"); ob = ED_object_add_type(C, OB_GPENCIL, ob_name, loc, rot, true, local_view_bits); gpd = ob->data; newob = true; - - BKE_object_obdata_size_init(ob, GP_OBGPENCIL_DEFAULT_SIZE * radius); } else { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -1030,7 +1039,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) mul_v3_fl(mat[1], radius); mul_v3_fl(mat[2], radius); - ED_gpencil_create_stroke(C, mat); + ED_gpencil_create_stroke(C, ob, mat); break; } case GP_MONKEY: @@ -1043,7 +1052,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) mul_v3_fl(mat[1], radius); mul_v3_fl(mat[2], radius); - ED_gpencil_create_monkey(C, mat); + ED_gpencil_create_monkey(C, ob, mat); break; } case GP_EMPTY: @@ -1057,7 +1066,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) /* if this is a new object, initialise default stuff (colors, etc.) */ if (newob) { - ED_gpencil_add_defaults(C); + ED_gpencil_add_defaults(C, ob); } return OPERATOR_FINISHED; @@ -1073,7 +1082,7 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot) /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_gpencil_add_exec; - ot->poll = ED_operator_scene_editable; + ot->poll = object_gpencil_add_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1090,12 +1099,12 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot) static const char *get_light_defname(int type) { switch (type) { - case LA_LOCAL: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Point"); - case LA_SUN: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Sun"); - case LA_SPOT: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Spot"); - case LA_AREA: return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Area"); + case LA_LOCAL: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "Point"); + case LA_SUN: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "Sun"); + case LA_SPOT: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "Spot"); + case LA_AREA: return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "Area"); default: - return CTX_DATA_(BLT_I18NCONTEXT_ID_LAMP, "Light"); + return CTX_DATA_(BLT_I18NCONTEXT_ID_LIGHT, "Light"); } } @@ -1103,7 +1112,7 @@ static int object_light_add_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob; - Lamp *la; + Light *la; int type = RNA_enum_get(op->ptr, "type"); ushort local_view_bits; float loc[3], rot[3]; @@ -1129,7 +1138,7 @@ static int object_light_add_exec(bContext *C, wmOperator *op) } BKE_object_obdata_size_init(ob, size); - la = (Lamp *)ob->data; + la = (Light *)ob->data; la->type = type; if (BKE_scene_uses_cycles(scene)) { @@ -1157,7 +1166,7 @@ void OBJECT_OT_light_add(wmOperatorType *ot) /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_light_type_items, 0, "Type", ""); - RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LAMP); + RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_LIGHT); ED_object_add_unit_props_radius(ot); ED_object_add_generic_props(ot, false); @@ -1205,7 +1214,7 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op) } Object *ob = ED_object_add_type(C, OB_EMPTY, collection->id.name + 2, loc, rot, false, local_view_bits); - ob->dup_group = collection; + ob->instance_collection = collection; ob->transflag |= OB_DUPLICOLLECTION; id_us_plus(&collection->id); @@ -1361,7 +1370,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) */ if (use_global && ob->id.lib == NULL) { /* We want to nuke the object, let's nuke it the easy way (not for linked data though)... */ - BKE_libblock_delete(bmain, &ob->id); + BKE_id_delete(bmain, &ob->id); changed_count += 1; continue; } @@ -1600,8 +1609,9 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, BLI_ghash_insert(dupli_gh, dob, ob_dst); if (parent_gh) { void **val; - /* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as 'the same', - * this avoids trying to insert same key several time and raise asserts in debug builds... */ + /* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as + * 'the same', this avoids trying to insert same key several time and + * raise asserts in debug builds... */ if (!BLI_ghash_ensure_p(parent_gh, dob, &val)) { *val = ob_dst; } @@ -1609,7 +1619,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } for (dob = lb_duplis->first; dob; dob = dob->next) { - Object *ob_src = DEG_get_original_object(dob->ob); + Object *ob_src = dob->ob; Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob); /* Remap new object to itself, and clear again newid pointer of orig object. */ @@ -1673,7 +1683,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } } - if (base->object->transflag & OB_DUPLICOLLECTION && base->object->dup_group) { + if (base->object->transflag & OB_DUPLICOLLECTION && base->object->instance_collection) { for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->proxy_group == base->object) { ob->proxy = NULL; @@ -1746,7 +1756,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) static const EnumPropertyItem convert_target_items[] = { {OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve from Mesh/Text", ""}, {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh from Curve/Meta/Surf/Text", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Object *ob) @@ -1759,7 +1769,7 @@ static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Objec if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) { /* We need 'for render' ON here, to enable computing bevel dipslist if needed. * Also makes sense anyway, we would not want e.g. to loose hidden parts etc. */ - BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false); + BKE_displist_make_curveTypes(depsgraph, scene, ob, true, false, NULL); } else if (ob->type == OB_MBALL) { BKE_displist_make_mball(depsgraph, scene, ob); @@ -1981,7 +1991,8 @@ static int convert_exec(bContext *C, wmOperator *op) * datablock, but for until we've got granular update * lets take care by selves. */ - /* XXX This may fail/crash, since BKE_vfont_to_curve() accesses evaluated data in some cases (bastien). */ + /* XXX This may fail/crash, since BKE_vfont_to_curve() + * accesses evaluated data in some cases (bastien). */ BKE_vfont_to_curve(newob, FO_EDIT); newob->type = OB_CURVE; @@ -2143,7 +2154,7 @@ static int convert_exec(bContext *C, wmOperator *op) } // XXX ED_object_editmode_enter(C, 0); -// XXX exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ +// XXX exit_editmode(C, EM_FREEDATA|); /* freedata, but no undo */ if (basact) { /* active base was changed */ @@ -2197,20 +2208,14 @@ void OBJECT_OT_convert(wmOperatorType *ot) /* Does set ID->newid pointers. */ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, int dupflag) { -#define ID_NEW_REMAP_US(a) if ( (a)->id.newid) { (a) = (void *)(a)->id.newid; (a)->id.us++; } -#define ID_NEW_REMAP_US2(a) if (((ID *)a)->newid) { (a) = ((ID *)a)->newid; ((ID *)a)->us++; } - Base *base, *basen = NULL; - Material ***matarar; Object *obn; - ID *id; - int a, didit; if (ob->mode & OB_MODE_POSE) { ; /* nothing? */ } else { - obn = ID_NEW_SET(ob, BKE_object_copy(bmain, ob)); + obn = ID_NEW_SET(ob, BKE_object_duplicate(bmain, ob, dupflag)); DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); base = BKE_view_layer_base_find(view_layer, ob); @@ -2221,8 +2226,11 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer); BKE_collection_object_add(bmain, layer_collection->collection, obn); } + basen = BKE_view_layer_base_find(view_layer, obn); - basen->local_view_bits = base->local_view_bits; + if (base != NULL) { + basen->local_view_bits = base->local_view_bits; + } /* 1) duplis should end up in same collection as the original * 2) Rigid Body sim participants MUST always be part of a collection... @@ -2235,218 +2243,8 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, ViewLayer BKE_collection_object_add(bmain, collection, obn); } } - - /* duplicates using userflags */ - if (dupflag & USER_DUP_ACT) { - BKE_animdata_copy_id_action(bmain, &obn->id, true); - } - - if (dupflag & USER_DUP_MAT) { - for (a = 0; a < obn->totcol; a++) { - id = (ID *)obn->mat[a]; - if (id) { - ID_NEW_REMAP_US(obn->mat[a]) - else { - obn->mat[a] = ID_NEW_SET(obn->mat[a], BKE_material_copy(bmain, obn->mat[a])); - /* duplicate grease pencil settings */ - if (ob->mat[a]->gp_style) { - obn->mat[a]->gp_style = MEM_dupallocN(ob->mat[a]->gp_style); - } - } - id_us_min(id); - - if (dupflag & USER_DUP_ACT) { - BKE_animdata_copy_id_action(bmain, &obn->mat[a]->id, true); - } - } - } - } - if (dupflag & USER_DUP_PSYS) { - ParticleSystem *psys; - for (psys = obn->particlesystem.first; psys; psys = psys->next) { - id = (ID *) psys->part; - if (id) { - ID_NEW_REMAP_US(psys->part) - else { - psys->part = ID_NEW_SET(psys->part, BKE_particlesettings_copy(bmain, psys->part)); - } - - if (dupflag & USER_DUP_ACT) { - BKE_animdata_copy_id_action(bmain, &psys->part->id, true); - } - - id_us_min(id); - } - } - } - - id = obn->data; - didit = 0; - - switch (obn->type) { - case OB_MESH: - if (dupflag & USER_DUP_MESH) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_mesh_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_CURVE: - if (dupflag & USER_DUP_CURVE) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_curve_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_SURF: - if (dupflag & USER_DUP_SURF) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_curve_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_FONT: - if (dupflag & USER_DUP_FONT) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_curve_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_MBALL: - if (dupflag & USER_DUP_MBALL) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_mball_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_LAMP: - if (dupflag & USER_DUP_LAMP) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_lamp_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_ARMATURE: - DEG_id_tag_update(&obn->id, ID_RECALC_GEOMETRY); - if (obn->pose) - BKE_pose_tag_recalc(bmain, obn->pose); - if (dupflag & USER_DUP_ARM) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_armature_copy(bmain, obn->data)); - BKE_pose_rebuild(bmain, obn, obn->data, true); - didit = 1; - } - id_us_min(id); - } - break; - case OB_LATTICE: - if (dupflag != 0) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_lattice_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_CAMERA: - if (dupflag != 0) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_camera_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_LIGHTPROBE: - if (dupflag != 0) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_lightprobe_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_SPEAKER: - if (dupflag != 0) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_speaker_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - case OB_GPENCIL: - if (dupflag != 0) { - ID_NEW_REMAP_US2(obn->data) - else { - obn->data = ID_NEW_SET(obn->data, BKE_gpencil_copy(bmain, obn->data)); - didit = 1; - } - id_us_min(id); - } - break; - } - - /* check if obdata is copied */ - if (didit) { - Key *key = BKE_key_from_object(obn); - - Key *oldkey = BKE_key_from_object(ob); - if (oldkey != NULL) { - ID_NEW_SET(oldkey, key); - } - - if (dupflag & USER_DUP_ACT) { - BKE_animdata_copy_id_action(bmain, (ID *)obn->data, true); - if (key) { - BKE_animdata_copy_id_action(bmain, (ID *)key, true); - } - } - - if (dupflag & USER_DUP_MAT) { - matarar = give_matarar(obn); - if (matarar) { - for (a = 0; a < obn->totcol; a++) { - id = (ID *)(*matarar)[a]; - if (id) { - ID_NEW_REMAP_US((*matarar)[a]) - else { - (*matarar)[a] = ID_NEW_SET((*matarar)[a], BKE_material_copy(bmain, (*matarar)[a])); - } - id_us_min(id); - } - } - } - } - } } return basen; - -#undef ID_NEW_REMAP_US -#undef ID_NEW_REMAP_US2 } /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ @@ -2514,8 +2312,6 @@ static int duplicate_exec(bContext *C, wmOperator *op) copy_object_set_idnew(C); - BKE_main_id_clear_newpoins(bmain); - DEG_relations_tag_update(bmain); DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT); @@ -2594,8 +2390,6 @@ static int add_named_exec(bContext *C, wmOperator *op) copy_object_set_idnew(C); - BKE_main_id_clear_newpoins(bmain); - /* TODO(sergey): Only update relations for the current scene. */ DEG_relations_tag_update(bmain); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 5a650d9dc05..9835d09ec3a 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,17 +15,10 @@ * * The Original Code is Copyright (C) 2004 by Blender Foundation * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Morten Mikkelsen, - * Sergey Sharybin - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_bake.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include <string.h> @@ -43,15 +34,12 @@ #include "DNA_meshdata_types.h" #include "BLI_blenlib.h" -#include "BLI_threads.h" #include "BLI_utildefines.h" #include "BKE_blender.h" -#include "BKE_screen.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_image.h" -#include "BKE_main.h" #include "BKE_material.h" #include "BKE_multires.h" #include "BKE_report.h" @@ -120,14 +108,22 @@ typedef struct MultiresBakerJobData { typedef struct { Scene *scene; ListBase data; - bool bake_clear; /* Clear the images before baking */ - int bake_filter; /* Bake-filter, aka margin */ - short mode; /* mode of baking (displacement, normals, AO) */ - bool use_lores_mesh; /* Use low-resolution mesh when baking displacement maps */ - int number_of_rays; /* Number of rays to be cast when doing AO baking */ - float bias; /* Bias between object and start ray point when doing AO baking */ - int threads; /* Number of threads to be used for baking */ - float user_scale; /* User scale used to scale displacement when baking derivative map. */ + /** Clear the images before baking */ + bool bake_clear; + /** Bake-filter, aka margin */ + int bake_filter; + /** mode of baking (displacement, normals, AO) */ + short mode; + /** Use low-resolution mesh when baking displacement maps */ + bool use_lores_mesh; + /** Number of rays to be cast when doing AO baking */ + int number_of_rays; + /** Bias between object and start ray point when doing AO baking */ + float bias; + /** Number of threads to be used for baking */ + int threads; + /** User scale used to scale displacement when baking derivative map. */ + float user_scale; } MultiresBakeJob; static bool multiresbake_check(bContext *C, wmOperator *op) @@ -277,7 +273,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l typedef enum ClearFlag { CLEAR_TANGENT_NORMAL = 1, - CLEAR_DISPLACEMENT = 2 + CLEAR_DISPLACEMENT = 2, } ClearFlag; diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 90b6be215d4..1dda976c8a8 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,16 +15,10 @@ * * The Original Code is Copyright (C) 2004 by Blender Foundation * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_bake_api.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -41,9 +33,7 @@ #include "RNA_enum_types.h" #include "BLI_listbase.h" -#include "BLI_string.h" #include "BLI_fileops.h" -#include "BLI_math_geom.h" #include "BLI_path_util.h" #include "BKE_context.h" @@ -635,9 +625,9 @@ static size_t initialize_internal_images(BakeImages *bake_images, ReportList *re /* create new mesh with edit mode changes and modifiers applied */ static Mesh *bake_mesh_new_from_object(Depsgraph *depsgraph, Main *bmain, Scene *scene, Object *ob) { - ED_object_editmode_load(bmain, ob); + bool apply_modifiers = (ob->type != OB_MESH); + Mesh *me = BKE_mesh_new_from_object(depsgraph, bmain, scene, ob, apply_modifiers, false); - Mesh *me = BKE_mesh_new_from_object(depsgraph, bmain, scene, ob, 1, 0); if (me->flag & ME_AUTOSMOOTH) { BKE_mesh_split_faces(me, true); } @@ -655,7 +645,8 @@ static int bake( const char *custom_cage, const char *filepath, const int width, const int height, const char *identifier, ScrArea *sa, const char *uv_layer) { - /* We build a depsgraph for the baking, so we don't need to change the original data to adjust visibility and modifiers. */ + /* We build a depsgraph for the baking, + * so we don't need to change the original data to adjust visibility and modifiers. */ Depsgraph *depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER); DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer); @@ -805,7 +796,7 @@ static int bake( ob_low_eval = DEG_get_evaluated_object(depsgraph, ob_low); /* get the mesh as it arrives in the renderer */ - me_low = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low); + me_low = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low_eval); /* populate the pixel array with the face data */ if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false) @@ -818,7 +809,7 @@ static int bake( /* prepare cage mesh */ if (ob_cage) { - me_cage = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_cage); + me_cage = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_cage_eval); if ((me_low->totpoly != me_cage->totpoly) || (me_low->totloop != me_cage->totloop)) { BKE_report(reports, RPT_ERROR, "Invalid cage object, the cage mesh must have the same number " @@ -827,6 +818,8 @@ static int bake( } } else if (is_cage) { + BKE_object_eval_reset(ob_low_eval); + ModifierData *md = ob_low_eval->modifiers.first; while (md) { ModifierData *md_next = md->next; @@ -844,7 +837,6 @@ static int bake( md = md_next; } - BKE_object_eval_reset(ob_low_eval); me_cage = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low_eval); RE_bake_pixels_populate(me_cage, pixel_array_low, num_pixels, &bake_images, uv_layer); } @@ -860,10 +852,10 @@ static int bake( /* initialize highpoly_data */ highpoly[i].ob = ob_iter; - highpoly[i].me = bake_mesh_new_from_object(depsgraph, bmain, scene, highpoly[i].ob); highpoly[i].ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); highpoly[i].ob_eval->restrictflag &= ~OB_RESTRICT_RENDER; highpoly[i].ob_eval->base_flag |= (BASE_VISIBLE | BASE_ENABLED_RENDER); + highpoly[i].me = bake_mesh_new_from_object(depsgraph, bmain, scene, highpoly[i].ob_eval); /* lowpoly to highpoly transformation matrix */ copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->obmat); @@ -887,7 +879,7 @@ static int bake( /* populate the pixel arrays with the corresponding face data for each high poly object */ if (!RE_bake_pixels_populate_from_objects( me_low, pixel_array_low, pixel_array_high, highpoly, tot_highpoly, num_pixels, ob_cage != NULL, - cage_extrusion, ob_low->obmat, (ob_cage ? ob_cage->obmat : ob_low->obmat), me_cage)) + cage_extrusion, ob_low_eval->obmat, (ob_cage ? ob_cage->obmat : ob_low_eval->obmat), me_cage)) { BKE_report(reports, RPT_ERROR, "Error handling selected objects"); goto cleanup; @@ -905,10 +897,10 @@ static int bake( } else { /* If low poly is not renderable it should have failed long ago. */ - BLI_assert((ob_low->restrictflag & OB_RESTRICT_RENDER) == 0); + BLI_assert((ob_low_eval->restrictflag & OB_RESTRICT_RENDER) == 0); if (RE_bake_has_engine(re)) { - ok = RE_bake_engine(re, depsgraph, ob_low, 0, pixel_array_low, num_pixels, depth, pass_type, pass_filter, result); + ok = RE_bake_engine(re, depsgraph, ob_low_eval, 0, pixel_array_low, num_pixels, depth, pass_type, pass_filter, result); } else { BKE_report(reports, RPT_ERROR, "Current render engine does not support baking"); @@ -936,13 +928,13 @@ static int bake( } case R_BAKE_SPACE_OBJECT: { - RE_bake_normal_world_to_object(pixel_array_low, num_pixels, depth, result, ob_low, normal_swizzle); + RE_bake_normal_world_to_object(pixel_array_low, num_pixels, depth, result, ob_low_eval, normal_swizzle); break; } case R_BAKE_SPACE_TANGENT: { if (is_selected_to_active) { - RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_low, normal_swizzle, ob_low->obmat); + RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_low, normal_swizzle, ob_low_eval->obmat); } else { /* from multiresolution */ @@ -950,18 +942,20 @@ static int bake( ModifierData *md = NULL; int mode; - md = modifiers_findByType(ob_low, eModifierType_Multires); + BKE_object_eval_reset(ob_low_eval); + md = modifiers_findByType(ob_low_eval, eModifierType_Multires); if (md) { mode = md->mode; md->mode &= ~eModifierMode_Render; } - me_nores = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low); + /* Evaluate modifiers again. */ + me_nores = BKE_mesh_new_from_object(depsgraph, bmain, scene, ob_low_eval, true, false); RE_bake_pixels_populate(me_nores, pixel_array_low, num_pixels, &bake_images, uv_layer); - RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low->obmat); - BKE_libblock_free(bmain, me_nores); + RE_bake_normal_world_to_tangent(pixel_array_low, num_pixels, depth, result, me_nores, normal_swizzle, ob_low_eval->obmat); + BKE_id_free(bmain, me_nores); if (md) md->mode = mode; @@ -1022,8 +1016,8 @@ static int bake( BLI_path_suffix(name, FILE_MAX, bk_image->image->id.name + 2, "_"); } else { - if (ob_low->mat[i]) { - BLI_path_suffix(name, FILE_MAX, ob_low->mat[i]->id.name + 2, "_"); + if (ob_low_eval->mat[i]) { + BLI_path_suffix(name, FILE_MAX, ob_low_eval->mat[i]->id.name + 2, "_"); } else if (me_low->mat[i]) { BLI_path_suffix(name, FILE_MAX, me_low->mat[i]->id.name + 2, "_"); @@ -1070,7 +1064,7 @@ cleanup: int i; for (i = 0; i < tot_highpoly; i++) { if (highpoly[i].me) - BKE_libblock_free(bmain, highpoly[i].me); + BKE_id_free(bmain, highpoly[i].me); } MEM_freeN(highpoly); } @@ -1094,10 +1088,10 @@ cleanup: MEM_freeN(result); if (me_low) - BKE_libblock_free(bmain, me_low); + BKE_id_free(bmain, me_low); if (me_cage) - BKE_libblock_free(bmain, me_cage); + BKE_id_free(bmain, me_cage); DEG_graph_free(depsgraph); diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c index 5e1773bf3c2..61a450205be 100644 --- a/source/blender/editors/object/object_collection.c +++ b/source/blender/editors/object/object_collection.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,16 +15,10 @@ * * The Original Code is Copyright (C) Blender Foundation * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_collection.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -42,7 +34,6 @@ #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_library.h" -#include "BKE_library_remap.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -538,7 +529,7 @@ static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op)) if (!collection) return OPERATOR_CANCELLED; - BKE_libblock_delete(bmain, collection); + BKE_id_delete(bmain, collection); DEG_relations_tag_update(bmain); @@ -562,7 +553,8 @@ void OBJECT_OT_collection_unlink(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) /* Select objects in the same collection as the active */ +/* Select objects in the same collection as the active */ +static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 93ff94edc75..0e7e0d5b8ec 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,16 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Joshua Leung, Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_constraint.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -54,7 +46,6 @@ #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_fcurve.h" -#include "BKE_global.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -105,7 +96,8 @@ ListBase *get_active_constraints(Object *ob) return NULL; } -/* Find the list that a given constraint belongs to, and/or also get the posechannel this is from (if applicable) */ +/* Find the list that a given constraint belongs to, + * and/or also get the posechannel this is from (if applicable) */ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan) { if (r_pchan) @@ -592,7 +584,8 @@ static void object_test_constraint(Main *bmain, Object *owner, bConstraint *con) static const EnumPropertyItem constraint_owner_items[] = { {EDIT_CONSTRAINT_OWNER_OBJECT, "OBJECT", 0, "Object", "Edit a constraint on the active object"}, {EDIT_CONSTRAINT_OWNER_BONE, "BONE", 0, "Bone", "Edit a constraint on the active bone"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL}, +}; static bool edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) @@ -1242,7 +1235,7 @@ static void object_pose_tag_update(Main *bmain, Object *ob) * Note that this is a bit wide here, since we cannot be sure whether there are some locked proxy bones * or not... * XXX Temp hack until new depsgraph hopefully solves this. */ - ob->adt->recalc |= ADT_RECALC_ANIM; + DEG_id_tag_update(&ob->id, ID_RECALC_ANIMATION); } } @@ -1306,7 +1299,8 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) if (BKE_constraint_remove_ex(lb, ob, con, true)) { /* there's no active constraint now, so make sure this is the case */ BKE_constraints_active_set(&ob->constraints, NULL); - ED_object_constraint_update(bmain, ob); /* needed to set the flags on posebones correctly */ + /* needed to set the flags on posebones correctly */ + ED_object_constraint_update(bmain, ob); /* relatiols */ DEG_relations_tag_update(CTX_data_main(C)); @@ -1637,7 +1631,8 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob return false; /* restricted target-type constraints -------------- */ - /* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */ + /* NOTE: for these, we cannot try to add a target object if no valid ones are found, + * since that doesn't work */ /* curve-based constraints - set the only_curve and only_ob flags */ case CONSTRAINT_TYPE_CLAMPTO: case CONSTRAINT_TYPE_FOLLOWPATH: @@ -1854,7 +1849,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* We need to make use of ugly POSE_ANIMATION_WORKAROUND here too, else anim data are not reloaded * after calling `BKE_pose_rebuild()`, which causes T43872. * XXX Temp hack until new depsgraph hopefully solves this. */ - ob->adt->recalc |= ADT_RECALC_ANIM; + DEG_id_tag_update(&ob->id, ID_RECALC_ANIMATION); } DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM); } diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index ad47e07b2e9..34f758900e9 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,16 +15,10 @@ * * The Original Code is Copyright (C) 2014 by Blender Foundation. * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Bastien Montagne. - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_data_transfer.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include "DNA_mesh_types.h" @@ -71,7 +63,8 @@ static const EnumPropertyItem DT_layer_items[] = { #if 0 /* XXX For now, would like to finish/merge work from 2014 gsoc first. */ {DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"}, #endif -#if 0 /* XXX When SkinModifier is enabled, it seems to erase its own CD_MVERT_SKIN layer from final DM :( */ +#if 0 /* XXX When SkinModifier is enabled, + * it seems to erase its own CD_MVERT_SKIN layer from final DM :( */ {DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"}, #endif {DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"}, @@ -88,7 +81,7 @@ static const EnumPropertyItem DT_layer_items[] = { {0, "", 0, "Face Data", ""}, {DT_TYPE_SHARP_FACE, "SMOOTH", 0, "Smooth", "Transfer flat/smooth mark"}, {DT_TYPE_FREESTYLE_FACE, "FREESTYLE_FACE", 0, "Freestyle Mark", "Transfer Freestyle face mark"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* Note: rna_enum_dt_layers_select_src_items enum is from rna_modifier.c */ @@ -142,7 +135,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf( Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); - me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MLOOPUV); + me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MASK_MLOOPUV); num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV); RNA_enum_item_add_separator(&item, &totitem); @@ -164,7 +157,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf( Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); - me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MLOOPCOL); + me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MASK_MLOOPCOL); num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL); RNA_enum_item_add_separator(&item, &totitem); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 59ce42c50a5..cd8eeba73d4 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_edit.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include <stdlib.h> @@ -38,10 +32,8 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_math.h" #include "BLI_utildefines.h" #include "BLI_ghash.h" -#include "BLI_string_utils.h" #include "BLT_translation.h" @@ -73,7 +65,6 @@ #include "BKE_image.h" #include "BKE_lattice.h" #include "BKE_layer.h" -#include "BKE_library.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mball.h" @@ -81,6 +72,7 @@ #include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_paint.h" +#include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_softbody.h" #include "BKE_editmesh.h" @@ -124,8 +116,6 @@ static void move_to_collection_menus_items(struct uiLayout *layout, struct MoveT /* ************* XXX **************** */ static void error(const char *UNUSED(arg)) {} -static void waitcursor(int UNUSED(val)) {} -static int pupmenu(const char *UNUSED(msg)) { return 0; } /* port over here */ static void error_libdata(void) {} @@ -211,21 +201,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); const bool unselected = RNA_boolean_get(op->ptr, "unselected"); - - /* Do nothing if no objects was selected. */ - bool have_selected = false; - for (Base *base = view_layer->object_bases.first; base; base = base->next) { - if (base->flag & BASE_VISIBLE) { - if (base->flag & BASE_SELECTED) { - have_selected = true; - break; - } - } - } - - if (!have_selected) { - return OPERATOR_CANCELLED; - } + bool changed = false; /* Hide selected or unselected objects. */ for (Base *base = view_layer->object_bases.first; base; base = base->next) { @@ -237,15 +213,20 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) if (base->flag & BASE_SELECTED) { ED_object_base_select(base, BA_DESELECT); base->flag |= BASE_HIDDEN; + changed = true; } } else { if (!(base->flag & BASE_SELECTED)) { ED_object_base_select(base, BA_DESELECT); base->flag |= BASE_HIDDEN; + changed = true; } } } + if (!changed) { + return OPERATOR_CANCELLED; + } BKE_layer_collection_sync(scene, view_layer); DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); @@ -293,9 +274,12 @@ static int object_hide_collection_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_layer_collection_set_visible(scene, view_layer, lc, extend); - DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); + + if (BKE_layer_collection_isolate(scene, view_layer, lc, extend)) { + DEG_relations_tag_update(CTX_data_main(C)); + } + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); return OPERATOR_FINISHED; @@ -322,12 +306,6 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout) continue; } - if ((view_layer->runtime_flag & VIEW_LAYER_HAS_HIDE) && - !(lc->runtime_flag & LAYER_COLLECTION_HAS_VISIBLE_OBJECTS)) - { - uiLayoutSetActive(row, false); - } - int icon = ICON_NONE; if (BKE_layer_collection_has_selected_objects(view_layer, lc)) { icon = ICON_LAYER_ACTIVE; @@ -368,7 +346,7 @@ static int object_hide_collection_invoke(bContext *C, wmOperator *op, const wmEv void OBJECT_OT_hide_collection(wmOperatorType *ot) { /* identifiers */ - ot->name = "Hide Objects By Collection"; + ot->name = "Hide Collection"; ot->description = "Show only objects in collection (Shift to extend)"; ot->idname = "OBJECT_OT_hide_collection"; @@ -424,11 +402,11 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f if (obedit->type == OB_MESH) { Mesh *me = obedit->data; - if (me->edit_btmesh == NULL) { + if (me->edit_mesh == NULL) { return false; } - if (me->edit_btmesh->bm->totvert > MESH_MAX_VERTS) { + if (me->edit_mesh->bm->totvert > MESH_MAX_VERTS) { error("Too many vertices"); return false; } @@ -436,9 +414,9 @@ static bool ED_object_editmode_load_ex(Main *bmain, Object *obedit, const bool f EDBM_mesh_load(bmain, obedit); if (freedata) { - EDBM_mesh_free(me->edit_btmesh); - MEM_freeN(me->edit_btmesh); - me->edit_btmesh = NULL; + EDBM_mesh_free(me->edit_mesh); + MEM_freeN(me->edit_mesh); + me->edit_mesh = NULL; } /* will be recalculated as needed. */ { @@ -518,15 +496,12 @@ bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int f { const bool freedata = (flag & EM_FREEDATA) != 0; - if (flag & EM_WAITCURSOR) waitcursor(1); - if (ED_object_editmode_load_ex(bmain, obedit, freedata) == false) { /* in rare cases (background mode) its possible active object * is flagged for editmode, without 'obedit' being set [#35489] */ if (UNLIKELY(obedit && obedit->mode & OB_MODE_EDIT)) { obedit->mode &= ~OB_MODE_EDIT; } - if (flag & EM_WAITCURSOR) waitcursor(0); return true; } @@ -538,11 +513,14 @@ bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int f /* flag object caches as outdated */ BKE_ptcache_ids_from_object(&pidlist, obedit, scene, 0); for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ + /* particles don't need reset on geometry change */ + if (pid->type != PTCACHE_TYPE_PARTICLES) { pid->cache->flag |= PTCACHE_OUTDATED; + } } BLI_freelistN(&pidlist); + BKE_particlesystem_reset_all(obedit); BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED); /* also flush ob recalc, doesn't take much overhead, but used for particles */ @@ -553,8 +531,6 @@ bool ED_object_editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int f obedit->mode &= ~OB_MODE_EDIT; } - if (flag & EM_WAITCURSOR) waitcursor(0); - return (obedit->mode & OB_MODE_EDIT) == 0; } @@ -584,8 +560,6 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag return false; } - if (flag & EM_WAITCURSOR) waitcursor(1); - ob->restore_mode = ob->mode; ob->mode = OB_MODE_EDIT; @@ -611,7 +585,9 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag ok = 1; ED_armature_to_edit(ob->data); /* to ensure all goes in restposition and without striding */ - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); /* XXX: should this be ID_RECALC_GEOMETRY? */ + + /* XXX: should this be ID_RECALC_GEOMETRY? */ + DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene); } @@ -650,8 +626,6 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag WM_main_add_notifier(NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); } - if (flag & EM_WAITCURSOR) waitcursor(0); - return (ob->mode & OB_MODE_EDIT) != 0; } @@ -659,15 +633,11 @@ bool ED_object_editmode_enter(bContext *C, int flag) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob; - if ((flag & EM_IGNORE_LAYER) == 0) { - ob = CTX_data_active_object(C); /* active layer checked here for view3d */ - } - else { - ob = view_layer->basact->object; - } + /* Active layer checked here for view3d, + * callers that don't want view context can call the extended version. */ + ob = CTX_data_active_object(C); if ((ob == NULL) || ID_IS_LINKED(ob)) { return false; } @@ -692,24 +662,24 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) } if (!is_mode_set) { - ED_object_editmode_enter(C, EM_WAITCURSOR); + ED_object_editmode_enter(C, 0); if (obact->mode & mode_flag) { FOREACH_SELECTED_OBJECT_BEGIN(view_layer, v3d, ob) { if ((ob != obact) && (ob->type == obact->type)) { - ED_object_editmode_enter_ex(bmain, scene, ob, EM_WAITCURSOR | EM_NO_CONTEXT); + ED_object_editmode_enter_ex(bmain, scene, ob, EM_NO_CONTEXT); } } FOREACH_SELECTED_OBJECT_END; } } else { - ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); + ED_object_editmode_exit(C, EM_FREEDATA); if ((obact->mode & mode_flag) == 0) { FOREACH_OBJECT_BEGIN(view_layer, ob) { if ((ob != obact) && (ob->type == obact->type)) { - ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA | EM_WAITCURSOR); + ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); } } FOREACH_OBJECT_END; @@ -845,331 +815,6 @@ void OBJECT_OT_posemode_toggle(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* both pointers should exist */ -static void copy_texture_space(Object *to, Object *ob) -{ - float *poin1 = NULL, *poin2 = NULL; - short texflag = 0; - - if (ob->type == OB_MESH) { - texflag = ((Mesh *)ob->data)->texflag; - poin2 = ((Mesh *)ob->data)->loc; - } - else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - texflag = ((Curve *)ob->data)->texflag; - poin2 = ((Curve *)ob->data)->loc; - } - else if (ob->type == OB_MBALL) { - texflag = ((MetaBall *)ob->data)->texflag; - poin2 = ((MetaBall *)ob->data)->loc; - } - else - return; - - if (to->type == OB_MESH) { - ((Mesh *)to->data)->texflag = texflag; - poin1 = ((Mesh *)to->data)->loc; - } - else if (ELEM(to->type, OB_CURVE, OB_SURF, OB_FONT)) { - ((Curve *)to->data)->texflag = texflag; - poin1 = ((Curve *)to->data)->loc; - } - else if (to->type == OB_MBALL) { - ((MetaBall *)to->data)->texflag = texflag; - poin1 = ((MetaBall *)to->data)->loc; - } - else - return; - - memcpy(poin1, poin2, 9 * sizeof(float)); /* this was noted in DNA_mesh, curve, mball */ - - if (to->type == OB_MESH) { - /* pass */ - } - else if (to->type == OB_MBALL) { - BKE_mball_texspace_calc(to); - } - else { - BKE_curve_texspace_calc(to->data); - } - -} - -/* UNUSED, keep in case we want to copy functionality for use elsewhere */ -static void copy_attr(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, short event) -{ - Object *ob; - Base *base; - Curve *cu, *cu1; - Nurb *nu; - - if (ID_IS_LINKED(scene)) return; - - if (!(ob = OBACT(view_layer))) return; - - if (BKE_object_is_in_editmode(ob)) { - /* obedit_copymenu(); */ - return; - } - - if (event == 24) { - /* moved to BKE_object_link_modifiers */ - /* copymenu_modifiers(bmain, scene, v3d, ob); */ - return; - } - - for (base = FIRSTBASE(view_layer); base; base = base->next) { - if (base != BASACT(view_layer)) { - if (TESTBASELIB(v3d, base)) { - DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY); - - 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 */ - 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 */ - copy_v3_v3(base->object->size, ob->size); - copy_v3_v3(base->object->dscale, ob->dscale); - } - 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 */ - base->object->sf = ob->sf; - } - else if (event == 6) { /* dupli */ - base->object->dupon = ob->dupon; - base->object->dupoff = ob->dupoff; - base->object->dupsta = ob->dupsta; - base->object->dupend = ob->dupend; - - base->object->transflag &= ~OB_DUPLI; - base->object->transflag |= (ob->transflag & OB_DUPLI); - - base->object->dup_group = ob->dup_group; - if (ob->dup_group) - id_us_plus(&ob->dup_group->id); - } - else if (event == 17) { /* tex space */ - copy_texture_space(base->object, ob); - } - else if (event == 18) { /* font settings */ - - if (base->object->type == ob->type) { - cu = ob->data; - cu1 = base->object->data; - - cu1->spacemode = cu->spacemode; - cu1->align_y = cu->align_y; - cu1->spacing = cu->spacing; - cu1->linedist = cu->linedist; - cu1->shear = cu->shear; - cu1->fsize = cu->fsize; - cu1->xof = cu->xof; - cu1->yof = cu->yof; - cu1->textoncurve = cu->textoncurve; - cu1->wordspace = cu->wordspace; - cu1->ulpos = cu->ulpos; - cu1->ulheight = cu->ulheight; - if (cu1->vfont) - id_us_min(&cu1->vfont->id); - cu1->vfont = cu->vfont; - id_us_plus((ID *)cu1->vfont); - if (cu1->vfontb) - id_us_min(&cu1->vfontb->id); - cu1->vfontb = cu->vfontb; - id_us_plus((ID *)cu1->vfontb); - if (cu1->vfonti) - id_us_min(&cu1->vfonti->id); - cu1->vfonti = cu->vfonti; - id_us_plus((ID *)cu1->vfonti); - if (cu1->vfontbi) - id_us_min(&cu1->vfontbi->id); - cu1->vfontbi = cu->vfontbi; - id_us_plus((ID *)cu1->vfontbi); - - BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); - - DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY); - } - } - else if (event == 19) { /* bevel settings */ - - if (ELEM(base->object->type, OB_CURVE, OB_FONT)) { - cu = ob->data; - cu1 = base->object->data; - - cu1->bevobj = cu->bevobj; - cu1->taperobj = cu->taperobj; - cu1->width = cu->width; - cu1->bevresol = cu->bevresol; - cu1->ext1 = cu->ext1; - cu1->ext2 = cu->ext2; - - DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY); - } - } - else if (event == 25) { /* curve resolution */ - - if (ELEM(base->object->type, OB_CURVE, OB_FONT)) { - cu = ob->data; - cu1 = base->object->data; - - cu1->resolu = cu->resolu; - cu1->resolu_ren = cu->resolu_ren; - - nu = cu1->nurb.first; - - while (nu) { - nu->resolu = cu1->resolu; - nu = nu->next; - } - - DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY); - } - } - else if (event == 21) { - if (base->object->type == OB_MESH) { - ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf); - - if (md) { - ModifierData *tmd = modifiers_findByType(base->object, eModifierType_Subsurf); - - if (!tmd) { - tmd = modifier_new(eModifierType_Subsurf); - BLI_addtail(&base->object->modifiers, tmd); - } - - modifier_copyData(md, tmd); - DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY); - } - } - } - else if (event == 22) { - /* Copy the constraint channels over */ - BKE_constraints_copy(&base->object->constraints, &ob->constraints, true); - DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE); - DEG_relations_tag_update(bmain); - } - else if (event == 23) { - sbFree(base->object); - BKE_object_copy_softbody(base->object, ob, 0); - - if (!modifiers_findByType(base->object, eModifierType_Softbody)) { - BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody)); - } - - DEG_id_tag_update(&base->object->id, ID_RECALC_COPY_ON_WRITE); - DEG_relations_tag_update(bmain); - } - else if (event == 26) { -#if 0 // XXX old animation system - BKE_nlastrip_copy(s(&base->object->nlastrips, &ob->nlastrips); -#endif // XXX old animation system - } - 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) - cme->flag |= ME_AUTOSMOOTH; - else - cme->flag &= ~ME_AUTOSMOOTH; - } - } - 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) - cu1->flag |= CU_UV_ORCO; - else - cu1->flag &= ~CU_UV_ORCO; - } - } - else if (event == 29) { /* protected bits */ - base->object->protectflag = ob->protectflag; - } - else if (event == 30) { /* index object */ - base->object->index = ob->index; - } - else if (event == 31) { /* object color */ - copy_v4_v4(base->object->col, ob->col); - } - } - } - } -} - -static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, Object *obedit) -{ - Object *ob; - short event; - char str[512]; - - if (!(ob = OBACT(view_layer))) return; - - if (obedit) { -/* if (ob->type == OB_MESH) */ -/* XXX mesh_copy_menu(); */ - return; - } - - /* Object Mode */ - - /* If you change this menu, don't forget to update the menu in header_view3d.c - * view3d_edit_object_copyattrmenu() and in toolbox.c - */ - - strcpy(str, - "Copy Attributes %t|Location %x1|Rotation %x2|Size %x3|Draw Options %x4|" - "Time Offset %x5|Dupli %x6|Object Color %x31|%l|Mass %x7|Damping %x8|All Physical Attributes %x11|Properties %x9|" - "Logic Bricks %x10|Protected Transform %x29|%l"); - - strcat(str, "|Object Constraints %x22"); - strcat(str, "|NLA Strips %x26"); - -/* XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { */ -/* 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) || (ob->type == OB_CURVE)) { - strcat(str, "|Curve Resolution %x25"); - } - - if (ob->type == OB_MESH) { - strcat(str, "|Subsurf Settings %x21|AutoSmooth %x27"); - } - - 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) { - strcat(str, "|Modifiers ... %x24"); - } - - event = pupmenu(str); - if (event <= 0) return; - - copy_attr(bmain, scene, view_layer, v3d, event); -} - /* ******************* force field toggle operator ***************** */ void ED_object_check_force_modifiers(Main *bmain, Scene *scene, Object *object) diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c index a111a73a42c..c46310c8c9d 100644 --- a/source/blender/editors/object/object_facemap_ops.c +++ b/source/blender/editors/object/object_facemap_ops.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,15 +15,10 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_facemap_ops.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include <string.h> @@ -33,8 +26,6 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" -#include "BLI_path_util.h" -#include "BLI_string.h" #include "BLI_listbase.h" #include "DNA_object_types.h" @@ -109,8 +100,8 @@ static void object_fmap_swap_edit_mode(Object *ob, int num1, int num2) if (ob->type == OB_MESH) { Mesh *me = ob->data; - if (me->edit_btmesh) { - BMEditMesh *em = me->edit_btmesh; + if (me->edit_mesh) { + BMEditMesh *em = me->edit_mesh; const int cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP); if (cd_fmap_offset != -1) { @@ -248,7 +239,7 @@ static int face_map_assign_exec(bContext *C, wmOperator *UNUSED(op)) if (fmap) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMFace *efa; BMIter iter; int *map; @@ -296,7 +287,7 @@ static int face_map_remove_from_exec(bContext *C, wmOperator *UNUSED(op)) if (fmap) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMFace *efa; BMIter iter; int *map; @@ -341,7 +332,7 @@ void OBJECT_OT_face_map_remove_from(struct wmOperatorType *ot) static void fmap_select(Object *ob, bool select) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMFace *efa; BMIter iter; int *map; @@ -482,7 +473,7 @@ void OBJECT_OT_face_map_move(wmOperatorType *ot) static EnumPropertyItem fmap_slot_move[] = { {1, "UP", 0, "Up", ""}, {-1, "DOWN", 0, "Down", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* identifiers */ diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index 1523cafa928..a1f529b3bde 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2018 Blender Foundation. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2018 - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_gpencil_modifier.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -39,9 +33,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BLI_math.h" #include "BLI_listbase.h" -#include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" @@ -378,11 +370,6 @@ static int gpencil_edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); - if (!ptr.data) { - CTX_wm_operator_poll_msg_set(C, "Context missing 'modifier'"); - return 0; - } - if (!ob || ID_IS_LINKED(ob)) return 0; if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0; if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) return 0; @@ -587,7 +574,7 @@ static int gpencil_modifier_apply_invoke(bContext *C, wmOperator *op, const wmEv static const EnumPropertyItem gpencil_modifier_apply_as_items[] = { {MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"}, {MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; void OBJECT_OT_gpencil_modifier_apply(wmOperatorType *ot) diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 995f62f3cd8..f65abb2f269 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_hook.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -143,7 +137,7 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMVert *eve; BMIter iter; int index = 0, nr = 0; @@ -323,7 +317,7 @@ static bool object_hook_index_array(Main *bmain, Scene *scene, Object *obedit, DEG_id_tag_update(obedit->data, 0); - em = me->edit_btmesh; + em = me->edit_mesh; EDBM_mesh_normals_update(em); BKE_editmesh_tessface_calc(em); diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 5bdba195a3a..89d8714dbca 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,25 +15,20 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_intern.h - * \ingroup edobj +/** \file + * \ingroup edobj */ #ifndef __OBJECT_INTERN_H__ #define __OBJECT_INTERN_H__ -struct wmOperatorType; struct Object; -struct bContext; struct StructRNA; +struct bContext; struct wmOperator; +struct wmOperatorType; struct ModifierData; @@ -43,7 +36,7 @@ struct ModifierData; enum eObject_Hook_Add_Mode { OBJECT_ADDHOOK_NEWOB = 1, OBJECT_ADDHOOK_SELOB, - OBJECT_ADDHOOK_SELOB_BONE + OBJECT_ADDHOOK_SELOB_BONE, }; /* internal exports only */ @@ -65,8 +58,6 @@ void OBJECT_OT_parent_clear(struct wmOperatorType *ot); void OBJECT_OT_vertex_parent_set(struct wmOperatorType *ot); void OBJECT_OT_track_set(struct wmOperatorType *ot); void OBJECT_OT_track_clear(struct wmOperatorType *ot); -void OBJECT_OT_slow_parent_set(struct wmOperatorType *ot); -void OBJECT_OT_slow_parent_clear(struct wmOperatorType *ot); void OBJECT_OT_make_local(struct wmOperatorType *ot); void OBJECT_OT_make_override_static(struct wmOperatorType *ot); void OBJECT_OT_make_single_user(struct wmOperatorType *ot); @@ -99,7 +90,6 @@ void OBJECT_OT_link_to_collection(struct wmOperatorType *ot); void OBJECT_OT_select_all(struct wmOperatorType *ot); void OBJECT_OT_select_random(struct wmOperatorType *ot); void OBJECT_OT_select_by_type(struct wmOperatorType *ot); -void OBJECT_OT_select_by_layer(struct wmOperatorType *ot); void OBJECT_OT_select_linked(struct wmOperatorType *ot); void OBJECT_OT_select_grouped(struct wmOperatorType *ot); void OBJECT_OT_select_mirror(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index 771bbc5c18c..dd0a37b4498 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -14,14 +12,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_modes.c - * \ingroup edobj +/** \file + * \ingroup edobj * * General utils to handle mode switching, * actual mode switching logic is per-object type. diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 07827a34bdd..8e7a7a71906 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2009 - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_modifier.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -131,7 +125,7 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Scene *s BKE_displist_make_mball(depsgraph, scene, ob); } else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - BKE_displist_make_curveTypes(depsgraph, scene, ob, false, false); + BKE_displist_make_curveTypes(depsgraph, scene, ob, false, false, NULL); } } @@ -286,8 +280,8 @@ static bool object_has_modifier_cb(Object *ob, void *data) } /* Use with ED_object_iter_other(). Sets the total number of levels -* for any multires modifiers on the object to the int pointed to by -* callback_data. */ + * for any multires modifiers on the object to the int pointed to by + * callback_data. */ bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v) { ModifierData *md; @@ -451,10 +445,12 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * return 1; } -int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, ModifierData *md) +int ED_object_modifier_convert(ReportList *UNUSED(reports), + Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, + Object *ob, ModifierData *md) { Object *obn; - ParticleSystem *psys; + ParticleSystem *psys_orig, *psys_eval; ParticleCacheKey *key, **cache; ParticleSettings *part; Mesh *me; @@ -467,20 +463,25 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * if (md->type != eModifierType_ParticleSystem) return 0; if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; - psys = ((ParticleSystemModifierData *)md)->psys; - part = psys->part; + psys_orig = ((ParticleSystemModifierData *)md)->psys; + part = psys_orig->part; - if (part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL) + if (part->ren_as != PART_DRAW_PATH) { + return 0; + } + psys_eval = psys_eval_get(depsgraph, ob, psys_orig); + if (psys_eval->pathcache == NULL) { return 0; + } - totpart = psys->totcached; - totchild = psys->totchildcache; + totpart = psys_eval->totcached; + totchild = psys_eval->totchildcache; if (totchild && (part->draw & PART_DRAW_PARENT) == 0) totpart = 0; /* count */ - cache = psys->pathcache; + cache = psys_eval->pathcache; for (a = 0; a < totpart; a++) { key = cache[a]; @@ -490,7 +491,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - cache = psys->childcache; + cache = psys_eval->childcache; for (a = 0; a < totchild; a++) { key = cache[a]; @@ -517,7 +518,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * medge = me->medge; /* copy coordinates */ - cache = psys->pathcache; + cache = psys_eval->pathcache; for (a = 0; a < totpart; a++) { key = cache[a]; kmax = key->segments; @@ -536,7 +537,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - cache = psys->childcache; + cache = psys_eval->childcache; for (a = 0; a < totchild; a++) { key = cache[a]; kmax = key->segments; @@ -1080,7 +1081,7 @@ static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNU static const EnumPropertyItem modifier_apply_as_items[] = { {MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"}, {MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; void OBJECT_OT_modifier_apply(wmOperatorType *ot) @@ -1105,12 +1106,13 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, md)) + if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md)) return OPERATOR_CANCELLED; DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -1503,7 +1505,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) static void modifier_skin_customdata_delete(Object *ob) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; if (em) BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN); @@ -1639,7 +1641,7 @@ void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot) static const EnumPropertyItem action_items[] = { {SKIN_LOOSE_MARK, "MARK", 0, "Mark", "Mark selected vertices as loose"}, {SKIN_LOOSE_CLEAR, "CLEAR", 0, "Clear", "Set selected vertices as not loose"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; ot->name = "Skin Mark/Clear Loose"; @@ -1899,6 +1901,7 @@ static bool correctivesmooth_poll(bContext *C) static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get(op, ob, eModifierType_CorrectiveSmooth); @@ -1925,9 +1928,17 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) else { /* signal to modifier to recalculate */ csmd->bind_coords_num = (unsigned int)-1; + + /* Force modifier to run, it will call binding routine + * (this has to happen outside of depsgraph evaluation). */ + const int mode = csmd->modifier.mode; + csmd->modifier.mode |= eModifierMode_Realtime; + object_force_modifier_update_for_bind(depsgraph, scene, ob); + csmd->modifier.mode = mode; } - DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + /* We need ID_RECALC_COPY_ON_WRITE to ensure (un)binding is flushed to CoW copies of the object... */ + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -2192,23 +2203,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 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(bmain, eval_time); - * This doesn't work with drivers: - * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); - */ - - /* Modifying the global scene isn't nice, but we can do it in - * this part of the process before a threaded job is created */ - - //scene->r.cfra = f; - //ED_update_for_newframe(bmain, scene); - - /* ok, this doesn't work with drivers, but is way faster. - * let's use this for now and hope nobody wants to drive the time value... */ + /* For now only simple animation of time value is supported, nothing else. + * No drivers or other modifier parameters. */ BKE_animsys_evaluate_animdata(CTX_data_depsgraph(C), scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); och->time[i] = omd->time; @@ -2306,7 +2302,8 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) lmd->flag |= MOD_LAPLACIANDEFORM_BIND; } - /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */ + /* Force modifier to run, it will call binding routine + * (this has to happen outside of depsgraph evaluation). */ const int mode = lmd->modifier.mode; lmd->modifier.mode |= eModifierMode_Realtime; object_force_modifier_update_for_bind(depsgraph, scene, ob); @@ -2368,7 +2365,8 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op) smd->flags |= MOD_SDEF_BIND; } - /* Force modifier to run, it will call binding routine (this has to happen outside of depsgraph evaluation). */ + /* Force modifier to run, it will call binding routine + * (this has to happen outside of depsgraph evaluation). */ const int mode = smd->modifier.mode; smd->modifier.mode |= eModifierMode_Realtime; object_force_modifier_update_for_bind(depsgraph, scene, ob); @@ -2540,7 +2538,7 @@ static void apply_scale(Depsgraph *depsgraph, Object* ob, Scene* scene) apply_transform(depsgraph, ob, scene, smat); /*clear scale too*/ - ob->size[0] = ob->size[1] = ob->size[2] = 1.0f; + ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f; } static int fracture_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) @@ -2675,7 +2673,7 @@ static Object* do_convert_meshisland_to_object(Main* bmain, Shard *mi, Scene* sc copy_qt_qt(ob_new->quat, ob->quat); copy_v3_v3(ob_new->rotAxis, ob->rotAxis); ob_new->rotAngle = ob->rotAngle; - copy_v3_v3(ob_new->size, ob->size); + copy_v3_v3(ob_new->scale, ob->scale); } if (rbw) { @@ -2717,7 +2715,7 @@ static Object* do_convert_meshisland_to_object(Main* bmain, Shard *mi, Scene* sc ob_new->data = BKE_mesh_copy(bmain, mi->mesh);//BKE_fracture_mesh_copy(mi->mesh, ob); me = (Mesh*)ob_new->data; - me->edit_btmesh = NULL; + me->edit_mesh = NULL; //correct vertex positions, they are off by centroid location for (mv = me->mvert, v = 0; v < me->totvert; v++, mv++) @@ -2741,7 +2739,7 @@ static Object* do_convert_meshisland_to_object(Main* bmain, Shard *mi, Scene* sc //except fore external mode... there it can be set, so in general use it... since we dont want separate external //mode any more - copy_v3_v3(ob_new->size, size); + copy_v3_v3(ob_new->scale, size); copy_v3_v3(ob_new->loc, loc); copy_qt_qt(ob_new->quat, rot); quat_to_eulO(ob_new->rot, ob_new->rotmode, rot); @@ -3109,7 +3107,7 @@ static Object* do_convert_meshIsland(Main* bmain, Depsgraph *depsgraph, Shard *m ob_new->data = BKE_fracture_mesh_copy(mi->mesh, ob); me = (Mesh*)ob_new->data; - me->edit_btmesh = NULL; + me->edit_mesh = NULL; //last parameter here means deferring removing the bake after all has been converted. ED_rigidbody_object_add(bmain, scene, ob_new, RBO_TYPE_ACTIVE, reports, true); @@ -3168,7 +3166,7 @@ static Object* do_convert_meshIsland(Main* bmain, Depsgraph *depsgraph, Shard *m rotset[3] = false; } - copy_v3_v3(size, ob->size); + copy_v3_v3(size, ob->scale); if (adaptive || dostep) { @@ -3262,7 +3260,7 @@ static Object* do_convert_meshIsland(Main* bmain, Depsgraph *depsgraph, Shard *m copy_qt_qt(ob_new->quat, rot); quat_to_compatible_eul(ob_new->rot, ob_new->rot, rot); - copy_v3_v3(ob_new->size, size); + copy_v3_v3(ob_new->scale, size); } if (locset[0]) @@ -3314,7 +3312,7 @@ static Object* do_convert_meshIsland(Main* bmain, Depsgraph *depsgraph, Shard *m mul_qt_qtqt(ob_new->quat, ob_new->quat, mi->rot); copy_v3_v3(ob_new->rot, ob->rot); - copy_v3_v3(ob_new->size, ob->size); + copy_v3_v3(ob_new->scale, ob->scale); } (*j)++; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index dff14107f90..940450aa161 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,15 +15,10 @@ * * The Original Code is Copyright (C) 2008 Blender Foundation. * All rights reserved. - * - * - * Contributor(s): Blender Foundation - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_ops.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -87,8 +80,6 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_vertex_parent_set); WM_operatortype_append(OBJECT_OT_track_set); WM_operatortype_append(OBJECT_OT_track_clear); - WM_operatortype_append(OBJECT_OT_slow_parent_set); - WM_operatortype_append(OBJECT_OT_slow_parent_clear); WM_operatortype_append(OBJECT_OT_make_local); WM_operatortype_append(OBJECT_OT_make_override_static); WM_operatortype_append(OBJECT_OT_make_single_user); diff --git a/source/blender/editors/object/object_random.c b/source/blender/editors/object/object_random.c index 8291b68f15f..7c176318c57 100644 --- a/source/blender/editors/object/object_random.c +++ b/source/blender/editors/object/object_random.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,12 +15,10 @@ * * The Original Code is Copyright (C) 2014 by Blender Foundation * All rights reserved. - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_random.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include "MEM_guardedalloc.h" @@ -162,12 +158,12 @@ void TRANSFORM_OT_vertex_random(struct wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - ot->prop = RNA_def_float( + ot->prop = RNA_def_float_distance( ot->srna, "offset", 0.1f, -FLT_MAX, FLT_MAX, "Amount", "Distance to offset", -10.0f, 10.0f); - RNA_def_float(ot->srna, "uniform", 0.0f, 0.0f, 1.0f, "Uniform", + RNA_def_float_factor(ot->srna, "uniform", 0.0f, 0.0f, 1.0f, "Uniform", "Increase for uniform offset distance", 0.0f, 1.0f); - RNA_def_float(ot->srna, "normal", 0.0f, 0.0f, 1.0f, "Normal", + RNA_def_float_factor(ot->srna, "normal", 0.0f, 0.0f, 1.0f, "Normal", "Align offset direction to normals", 0.0f, 1.0f); RNA_def_int(ot->srna, "seed", 0, 0, 10000, "Random Seed", "Seed for the random number generator", 0, 50); } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 867b807c908..4d6864d2023 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_relations.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -39,7 +33,7 @@ #include "DNA_mesh_types.h" #include "DNA_collection_types.h" #include "DNA_constraint_types.h" -#include "DNA_lamp_types.h" +#include "DNA_light_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" #include "DNA_meta_types.h" @@ -70,11 +64,10 @@ #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_editmesh.h" -#include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_fcurve.h" #include "BKE_idprop.h" -#include "BKE_lamp.h" +#include "BKE_light.h" #include "BKE_lattice.h" #include "BKE_layer.h" #include "BKE_library.h" @@ -152,7 +145,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) DEG_id_tag_update(obedit->data, 0); - em = me->edit_btmesh; + em = me->edit_mesh; EDBM_mesh_normals_update(em); BKE_editmesh_tessface_calc(em); @@ -305,9 +298,9 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; /* Get object to work on - use a menu if we need to... */ - if (ob->dup_group && ID_IS_LINKED(ob->dup_group)) { + if (ob->instance_collection && ID_IS_LINKED(ob->instance_collection)) { /* gives menu with list of objects in group */ - /* proxy_group_objects_menu(C, op, ob, ob->dup_group); */ + /* proxy_group_objects_menu(C, op, ob, ob->instance_collection); */ WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; } @@ -341,9 +334,9 @@ static int make_proxy_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - if (gob->dup_group != NULL) { - const ListBase dup_group_objects = BKE_collection_object_cache_get(gob->dup_group); - Base *base = BLI_findlink(&dup_group_objects, RNA_enum_get(op->ptr, "object")); + if (gob->instance_collection != NULL) { + const ListBase instance_collection_objects = BKE_collection_object_cache_get(gob->instance_collection); + Base *base = BLI_findlink(&instance_collection_objects, RNA_enum_get(op->ptr, "object")); ob = base->object; } else { @@ -385,19 +378,20 @@ static int make_proxy_exec(bContext *C, wmOperator *op) } /* Generic itemf's for operators that take library args */ -static const EnumPropertyItem *proxy_collection_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), bool *r_free) +static const EnumPropertyItem *proxy_collection_object_itemf( + bContext *C, PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), bool *r_free) { EnumPropertyItem item_tmp = {0}, *item = NULL; int totitem = 0; int i = 0; Object *ob = ED_object_active_context(C); - if (!ob || !ob->dup_group) + if (!ob || !ob->instance_collection) return DummyRNA_DEFAULT_items; /* find the object to affect */ - FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(ob->dup_group, object) + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(ob->instance_collection, object) { item_tmp.identifier = item_tmp.name = object->id.name + 2; item_tmp.value = i++; @@ -452,7 +446,7 @@ EnumPropertyItem prop_clear_parent_types[] = { "As 'Clear Parent', but keep the current visual transformations of the object"}, {CLEAR_PARENT_INVERSE, "CLEAR_INVERSE", 0, "Clear Parent Inverse", "Reset the transform corrections applied to the parenting relationship, does not remove parenting itself"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* Helper for ED_object_parent_clear() - Remove deform-modifiers associated with parent */ @@ -504,7 +498,8 @@ void ED_object_parent_clear(Object *ob, const int type) switch (type) { case CLEAR_PARENT_ALL: { - /* for deformers, remove corresponding modifiers to prevent a large number of modifiers building up */ + /* for deformers, remove corresponding modifiers to prevent + * a large number of modifiers building up */ object_remove_parent_deform_modifiers(ob, ob->parent); /* clear parenting relationship completely */ @@ -513,14 +508,16 @@ void ED_object_parent_clear(Object *ob, const int type) } case CLEAR_PARENT_KEEP_TRANSFORM: { - /* remove parent, and apply the parented transform result as object's local transforms */ + /* remove parent, and apply the parented transform + * result as object's local transforms */ ob->parent = NULL; BKE_object_apply_mat4(ob, ob->obmat, true, false); break; } case CLEAR_PARENT_INVERSE: { - /* object stays parented, but the parent inverse (i.e. offset from parent to retain binding state) + /* object stays parented, but the parent inverse + * (i.e. offset from parent to retain binding state) * is cleared. In other words: nothing to do here! */ break; } @@ -609,7 +606,7 @@ EnumPropertyItem prop_make_parent_types[] = { {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, {PAR_VERTEX_TRI, "VERTEX_TRI", 0, "Vertex (Triangle)", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, Object *ob, Object *par, @@ -631,7 +628,8 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene, if ((cu->flag & CU_PATH) == 0) { cu->flag |= CU_PATH | CU_FOLLOW; - BKE_displist_make_curveTypes(depsgraph, scene, par, false, false); /* force creation of path data */ + /* force creation of path data */ + BKE_displist_make_curveTypes(depsgraph, scene, par, false, false, NULL); } else { cu->flag |= CU_FOLLOW; @@ -915,7 +913,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { - Object *ob = ED_object_active_context(C); + Object *parent = ED_object_active_context(C); uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); @@ -935,26 +933,46 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", true); #endif - /* ob becomes parent, make the associated menus */ - if (ob->type == OB_ARMATURE) { + + struct { + bool mesh, gpencil; + } has_children_of_type = { 0 }; + + CTX_DATA_BEGIN (C, Object *, child, selected_editable_objects) + { + if (child == parent) { + continue; + } + if (child->type == OB_MESH) { + has_children_of_type.mesh = true; + } + if (child->type == OB_GPENCIL) { + has_children_of_type.gpencil = true; + } + } + CTX_DATA_END; + + if (parent->type == OB_ARMATURE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_NAME); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_ENVELOPE); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_AUTO); + if (has_children_of_type.mesh || has_children_of_type.gpencil) { + uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_AUTO); + } uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE_RELATIVE); } - else if (ob->type == OB_CURVE) { + else if (parent->type == OB_CURVE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_CURVE); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_FOLLOW); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_PATH_CONST); } - else if (ob->type == OB_LATTICE) { + else if (parent->type == OB_LATTICE) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_LATTICE); } /* vertex parenting */ - if (OB_TYPE_SUPPORT_PARVERT(ob->type)) { + if (OB_TYPE_SUPPORT_PARVERT(parent->type)) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX_TRI); } @@ -1057,83 +1075,6 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/************************ Clear Slow Parent Operator *********************/ - -static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); - - CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) - { - if (ob->parent) { - if (ob->partype & PARSLOW) { - ob->partype -= PARSLOW; - BKE_object_where_is_calc(depsgraph, scene, ob); - ob->partype |= PARSLOW; - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); - } - } - } - CTX_DATA_END; - - WM_event_add_notifier(C, NC_SCENE, scene); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Clear Slow Parent"; - ot->description = "Clear the object's slow parent"; - 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; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -/********************** Make Slow Parent Operator *********************/ - -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) - ob->partype |= PARSLOW; - - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); - } - CTX_DATA_END; - - WM_event_add_notifier(C, NC_SCENE, scene); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_slow_parent_set(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Set Slow Parent"; - ot->description = "Set the object's slow parent"; - 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; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - /* ******************** Clear Track Operator ******************* */ enum { @@ -1144,7 +1085,7 @@ enum { static const EnumPropertyItem prop_clear_track_types[] = { {CLEAR_TRACK, "CLEAR", 0, "Clear Track", ""}, {CLEAR_TRACK_KEEP_TRANSFORM, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation (Clear Track)", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* note, poll should check for editable scene */ @@ -1214,7 +1155,7 @@ static const EnumPropertyItem prop_make_track_types[] = { {CREATE_TRACK_DAMPTRACK, "DAMPTRACK", 0, "Damped Track Constraint", ""}, {CREATE_TRACK_TRACKTO, "TRACKTO", 0, "Track To Constraint", ""}, {CREATE_TRACK_LOCKTRACK, "LOCKTRACK", 0, "Lock Track Constraint", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static int track_set_exec(bContext *C, wmOperator *op) @@ -1239,7 +1180,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data->tar = obact; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); - /* Lamp, Camera and Speaker track differently by default */ + /* Light, Camera and Speaker track differently by default */ if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { data->trackflag = TRACK_nZ; } @@ -1262,7 +1203,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data->tar = obact; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); - /* Lamp, Camera and Speaker track differently by default */ + /* Light, Camera and Speaker track differently by default */ if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { data->reserved1 = TRACK_nZ; data->reserved2 = UP_Y; @@ -1286,7 +1227,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data->tar = obact; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); - /* Lamp, Camera and Speaker track differently by default */ + /* Light, Camera and Speaker track differently by default */ if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) { data->trackflag = TRACK_nZ; data->lockflag = LOCK_Y; @@ -1336,7 +1277,7 @@ static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) if (sce->id.lib) return; for (base = FIRSTBASE; base; base = base->next) { - if (TESTBASE(v3d, base)) { + if (BASE_SELECTED(v3d, base)) { nbase = MEM_mallocN(sizeof(Base), "newbase"); *nbase = *base; BLI_addhead(&(sce->base), nbase); @@ -1468,7 +1409,8 @@ static int make_links_data_exec(bContext *C, wmOperator *op) /* new approach, using functions from kernel */ for (a = 0; a < ob_src->totcol; a++) { Material *ma = give_current_material(ob_src, a + 1); - assign_material(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); /* also works with ma==NULL */ + /* also works with `ma == NULL` */ + assign_material(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); } DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); break; @@ -1492,7 +1434,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) /* now add in the collections from the link nodes */ for (collection_node = ob_collections; collection_node; collection_node = collection_node->next) { - if (ob_dst->dup_group != collection_node->link) { + if (ob_dst->instance_collection != collection_node->link) { BKE_collection_object_add(bmain, collection_node->link, ob_dst); } else { @@ -1502,9 +1444,9 @@ static int make_links_data_exec(bContext *C, wmOperator *op) break; } case MAKE_LINKS_DUPLICOLLECTION: - ob_dst->dup_group = ob_src->dup_group; - if (ob_dst->dup_group) { - id_us_plus(&ob_dst->dup_group->id); + ob_dst->instance_collection = ob_src->instance_collection; + if (ob_dst->instance_collection) { + id_us_plus(&ob_dst->instance_collection->id); ob_dst->transflag |= OB_DUPLICOLLECTION; } break; @@ -1601,11 +1543,12 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) {MAKE_LINKS_OBDATA, "OBDATA", 0, "Object Data", ""}, {MAKE_LINKS_MATERIALS, "MATERIAL", 0, "Materials", ""}, {MAKE_LINKS_ANIMDATA, "ANIMATION", 0, "Animation Data", ""}, - {MAKE_LINKS_GROUP, "GROUPS", 0, "Group", ""}, - {MAKE_LINKS_DUPLICOLLECTION, "DUPLICOLLECTION", 0, "DupliGroup", ""}, + {MAKE_LINKS_GROUP, "GROUPS", 0, "Collection", ""}, + {MAKE_LINKS_DUPLICOLLECTION, "DUPLICOLLECTION", 0, "Instance Collection", ""}, {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Modifiers", ""}, {MAKE_LINKS_FONTS, "FONTS", 0, "Fonts", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL}, + }; /* identifiers */ ot->name = "Link Data"; @@ -1654,7 +1597,7 @@ static void single_object_users_collection( Object *ob = cob->ob; /* an object may be in more than one collection */ if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) { - if (!ID_IS_LINKED(ob) && ob->id.us > 1) { + if (!ID_IS_LINKED(ob) && BKE_object_scenes_users_get(bmain, ob) > 1) { ID_NEW_SET(ob, BKE_object_copy(bmain, ob)); } } @@ -1756,7 +1699,7 @@ static void new_id_matar(Main *bmain, Material **matar, const int totcol) static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag) { - Lamp *la; + Light *la; Curve *cu; /* Camera *cam; */ Mesh *me; @@ -1773,7 +1716,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, ViewLayer *view_layer switch (ob->type) { case OB_LAMP: - ob->data = la = ID_NEW_SET(ob->data, BKE_lamp_copy(bmain, ob->data)); + ob->data = la = ID_NEW_SET(ob->data, BKE_light_copy(bmain, ob->data)); break; case OB_CAMERA: ob->data = ID_NEW_SET(ob->data, BKE_camera_copy(bmain, ob->data)); @@ -1867,7 +1810,8 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, V for (a = 1; a <= ob->totcol; a++) { ma = give_current_material(ob, a); if (ma) { - /* do not test for LIB_TAG_NEW or use newid: this functions guaranteed delivers single_users! */ + /* do not test for LIB_TAG_NEW or use newid: + * this functions guaranteed delivers single_users! */ if (ma->id.us > 1) { man = BKE_material_copy(bmain, ma); @@ -2182,7 +2126,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) {MAKE_LOCAL_SELECT_OBDATA, "SELECT_OBDATA", 0, "Selected Objects and Data", ""}, {MAKE_LOCAL_SELECT_OBDATA_MATERIAL, "SELECT_OBDATA_MATERIAL", 0, "Selected Objects, Data and Materials", ""}, {MAKE_LOCAL_ALL, "ALL", 0, "All", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* identifiers */ @@ -2213,8 +2157,9 @@ static void make_override_static_tag_object(Object *obact, Object *ob) return; } - /* Note: all this is very case-by-case bad handling, ultimately we'll want a real full 'automatic', generic - * handling of all this, will probably require adding some override-aware stuff to library_query code... */ + /* Note: all this is very case-by-case bad handling, ultimately we'll want a real full + * 'automatic', generic handling of all this, + * will probably require adding some override-aware stuff to library_query code... */ if (obact->type == OB_ARMATURE && ob->modifiers.first != NULL) { for (ModifierData *md = ob->modifiers.first; md != NULL; md = md->next) { @@ -2256,7 +2201,7 @@ static int make_override_static_invoke(bContext *C, wmOperator *op, const wmEven } /* Get object to work on - use a menu if we need to... */ - if (!ID_IS_LINKED(obact) && obact->dup_group != NULL && ID_IS_LINKED(obact->dup_group)) { + if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && ID_IS_LINKED(obact->instance_collection)) { /* Gives menu with list of objects in group. */ WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; @@ -2291,9 +2236,9 @@ static int make_override_static_exec(bContext *C, wmOperator *op) bool success = false; - if (!ID_IS_LINKED(obact) && obact->dup_group != NULL && ID_IS_LINKED(obact->dup_group)) { + if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && ID_IS_LINKED(obact->instance_collection)) { Object *obcollection = obact; - Collection *collection = obcollection->dup_group; + Collection *collection = obcollection->instance_collection; const ListBase dup_collection_objects = BKE_collection_object_cache_get(collection); Base *base = BLI_findlink(&dup_collection_objects, RNA_enum_get(op->ptr, "object")); @@ -2356,10 +2301,12 @@ static int make_override_static_exec(bContext *C, wmOperator *op) } FOREACH_COLLECTION_OBJECT_RECURSIVE_END; - /* obcollection is no more duplicollection-ing, it merely parents whole collection of overriding instantiated objects. */ - obcollection->dup_group = NULL; + /* obcollection is no more duplicollection-ing, + * it merely parents whole collection of overriding instantiated objects. */ + obcollection->instance_collection = NULL; - /* Also, we'd likely want to lock by default things like transformations of implicitly overridden objects? */ + /* Also, we'd likely want to lock by default things like + * transformations of implicitly overridden objects? */ DEG_id_tag_update(&scene->id, 0); @@ -2379,7 +2326,8 @@ static int make_override_static_exec(bContext *C, wmOperator *op) success = BKE_override_static_create_from_tag(bmain); - /* Also, we'd likely want to lock by default things like transformations of implicitly overridden objects? */ + /* Also, we'd likely want to lock by default things like + * transformations of implicitly overridden objects? */ /* Cleanup. */ BKE_main_id_clear_newpoins(bmain); @@ -2403,7 +2351,7 @@ static bool make_override_static_poll(bContext *C) return (BKE_override_static_is_enabled() && ED_operator_objectmode(C) && obact != NULL && ((ID_IS_LINKED(obact) && obact->id.tag & LIB_TAG_EXTERN) || - (!ID_IS_LINKED(obact) && obact->dup_group != NULL && ID_IS_LINKED(obact->dup_group)))); + (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && ID_IS_LINKED(obact->instance_collection)))); } void OBJECT_OT_make_override_static(wmOperatorType *ot) @@ -2486,7 +2434,8 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static const EnumPropertyItem type_items[] = { {MAKE_SINGLE_USER_SELECTED, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, {MAKE_SINGLE_USER_ALL, "ALL", 0, "All", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL}, + }; /* identifiers */ ot->name = "Make Single User"; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 0b032a3111a..96dc18b41f0 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_select.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -39,7 +33,7 @@ #include "DNA_modifier_types.h" #include "DNA_scene_types.h" #include "DNA_armature_types.h" -#include "DNA_lamp_types.h" +#include "DNA_light_types.h" #include "DNA_workspace_types.h" #include "DNA_gpencil_types.h" @@ -72,6 +66,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "ED_armature.h" #include "ED_object.h" @@ -126,11 +121,13 @@ void ED_object_base_select(Base *base, eObjectSelect_Mode mode) */ void ED_object_base_activate(bContext *C, Base *base) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); view_layer->basact = base; WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); + WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active); DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_SELECT); } @@ -434,6 +431,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 1, "Type", ""); + RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_ID); } /*********************** Selection by Links *********************/ @@ -445,7 +443,7 @@ enum { OBJECT_SELECT_LINKED_DUPGROUP, OBJECT_SELECT_LINKED_PARTICLE, OBJECT_SELECT_LINKED_LIBRARY, - OBJECT_SELECT_LINKED_LIBRARY_OBDATA + OBJECT_SELECT_LINKED_LIBRARY_OBDATA, }; static const EnumPropertyItem prop_select_linked_types[] = { @@ -456,7 +454,7 @@ static const EnumPropertyItem prop_select_linked_types[] = { {OBJECT_SELECT_LINKED_PARTICLE, "PARTICLE", 0, "Particle System", ""}, {OBJECT_SELECT_LINKED_LIBRARY, "LIBRARY", 0, "Library", ""}, {OBJECT_SELECT_LINKED_LIBRARY_OBDATA, "LIBRARY_OBDATA", 0, "Library (Object Data)", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static bool object_select_all_by_obdata(bContext *C, void *obdata) @@ -503,16 +501,16 @@ static bool object_select_all_by_material(bContext *C, Material *mat) return changed; } -static bool object_select_all_by_dup_group(bContext *C, Object *ob) +static bool object_select_all_by_instance_collection(bContext *C, Object *ob) { bool changed = false; - Collection *dup_group = (ob->transflag & OB_DUPLICOLLECTION) ? ob->dup_group : NULL; + Collection *instance_collection = (ob->transflag & OB_DUPLICOLLECTION) ? ob->instance_collection : NULL; CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { - Collection *dup_group_other = (base->object->transflag & OB_DUPLICOLLECTION) ? base->object->dup_group : NULL; - if (dup_group == dup_group_other) { + Collection *instance_collection_other = (base->object->transflag & OB_DUPLICOLLECTION) ? base->object->instance_collection : NULL; + if (instance_collection == instance_collection_other) { ED_object_base_select(base, BA_SELECT); changed = true; } @@ -652,10 +650,10 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) changed = object_select_all_by_material(C, mat); } else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) { - if (ob->dup_group == NULL) + if (ob->instance_collection == NULL) return OPERATOR_CANCELLED; - changed = object_select_all_by_dup_group(C, ob); + changed = object_select_all_by_instance_collection(C, ob); } else if (nr == OBJECT_SELECT_LINKED_PARTICLE) { if (BLI_listbase_is_empty(&ob->particlesystem)) @@ -733,7 +731,7 @@ static const EnumPropertyItem prop_select_grouped_types[] = { {OBJECT_GRPSEL_COLOR, "COLOR", 0, "Color", "Object Color"}, {OBJECT_GRPSEL_KEYINGSET, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"}, {OBJECT_GRPSEL_LIGHT_TYPE, "LIGHT_TYPE", 0, "Light Type", "Matching light types"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static bool select_grouped_children(bContext *C, Object *ob, const bool recursive) @@ -781,7 +779,8 @@ static bool select_grouped_parent(bContext *C) /* Makes parent active and de-sel #define COLLECTION_MENU_MAX 24 -static bool select_grouped_collection(bContext *C, Object *ob) /* Select objects in the same group as the active */ +/* Select objects in the same group as the active */ +static bool select_grouped_collection(bContext *C, Object *ob) { bool changed = false; Collection *collection, *ob_collections[COLLECTION_MENU_MAX]; @@ -867,16 +866,16 @@ static bool select_grouped_siblings(bContext *C, Object *ob) CTX_DATA_END; return changed; } -static bool select_grouped_lamptype(bContext *C, Object *ob) +static bool select_grouped_lighttype(bContext *C, Object *ob) { - Lamp *la = ob->data; + Light *la = ob->data; bool changed = false; CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (base->object->type == OB_LAMP) { - Lamp *la_test = base->object->data; + Light *la_test = base->object->data; if ((la->type == la_test->type) && ((base->flag & BASE_SELECTED) == 0)) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -922,7 +921,7 @@ static bool select_grouped_color(bContext *C, Object *ob) CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { - if (((base->flag & BASE_SELECTED) == 0) && (compare_v3v3(base->object->col, ob->col, 0.005f))) { + if (((base->flag & BASE_SELECTED) == 0) && (compare_v3v3(base->object->color, ob->color, 0.005f))) { ED_object_base_select(base, BA_SELECT); changed = true; } @@ -1039,7 +1038,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Active object must be a light"); break; } - changed |= select_grouped_lamptype(C, ob); + changed |= select_grouped_lighttype(C, ob); break; default: break; diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c index a7505c4b2cc..8580ea10d35 100644 --- a/source/blender/editors/object/object_shader_fx.c +++ b/source/blender/editors/object/object_shader_fx.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2018 Blender Foundation. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2018 - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_shader_fx.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -39,12 +33,12 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" -#include "BLI_math.h" #include "BLI_listbase.h" -#include "BLI_string.h" #include "BLI_string_utf8.h" #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "BKE_context.h" #include "BKE_main.h" #include "BKE_shader_fx.h" @@ -263,8 +257,6 @@ static const EnumPropertyItem *shaderfx_add_itemf( void OBJECT_OT_shaderfx_add(wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Add Effect"; ot->description = "Add a visual effect to the active object"; @@ -279,9 +271,9 @@ void OBJECT_OT_shaderfx_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop = RNA_def_enum(ot->srna, "type", rna_enum_object_shaderfx_type_items, eShaderFxType_Blur, "Type", ""); - RNA_def_enum_funcs(prop, shaderfx_add_itemf); - ot->prop = prop; + ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_shaderfx_type_items, eShaderFxType_Blur, "Type", ""); + RNA_def_enum_funcs(ot->prop, shaderfx_add_itemf); + RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_ID_ID); /* Abused, for "Light"... */ } /************************ generic functions for operators using names and data context *********************/ diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index cafb3a50202..d445177f236 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, shapekey support - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_shapekey.c - * \ingroup edobj +/** \file + * \ingroup edobj */ diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 1620d1f82f9..ea51fdb5c86 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,14 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * Contributor(s): Blender Foundation, 2002-2008 full recode - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_transform.c - * \ingroup edobj +/** \file + * \ingroup edobj */ @@ -35,7 +29,7 @@ #include "DNA_armature_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" -#include "DNA_lamp_types.h" +#include "DNA_light_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_gpencil_types.h" @@ -228,15 +222,15 @@ static void object_clear_scale(Object *ob, const bool clear_delta) { /* clear scale factors which are not locked */ if ((ob->protectflag & OB_LOCK_SCALEX) == 0) { - ob->size[0] = 1.0f; + ob->scale[0] = 1.0f; if (clear_delta) ob->dscale[0] = 1.0f; } if ((ob->protectflag & OB_LOCK_SCALEY) == 0) { - ob->size[1] = 1.0f; + ob->scale[1] = 1.0f; if (clear_delta) ob->dscale[1] = 1.0f; } if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) { - ob->size[2] = 1.0f; + ob->scale[2] = 1.0f; if (clear_delta) ob->dscale[2] = 1.0f; } } @@ -491,7 +485,8 @@ static int apply_objects_internal( bool has_unparented_layers = false; for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - /* Parented layers aren't supported as we can't easily re-evaluate the scene to sample parent movement */ + /* Parented layers aren't supported as we can't easily re-evaluate + * the scene to sample parent movement */ if (gpl->parent == NULL) { has_unparented_layers = true; break; @@ -515,7 +510,7 @@ static int apply_objects_internal( } if (ob->type == OB_LAMP) { - Lamp *la = ob->data; + Light *la = ob->data; if (la->type == LA_AREA) { if (apply_rot || apply_loc) { BKE_reportf(reports, RPT_ERROR, @@ -635,7 +630,7 @@ static int apply_objects_internal( continue; if (apply_scale) - BKE_tracking_reconstruction_scale(&clip->tracking, ob->size); + BKE_tracking_reconstruction_scale(&clip->tracking, ob->scale); } else if (ob->type == OB_EMPTY) { /* It's possible for empties too, even though they don't @@ -654,12 +649,12 @@ static int apply_objects_internal( (apply_rot == false) && (apply_scale == true)) { - float max_scale = max_fff(fabsf(ob->size[0]), fabsf(ob->size[1]), fabsf(ob->size[2])); + float max_scale = max_fff(fabsf(ob->scale[0]), fabsf(ob->scale[1]), fabsf(ob->scale[2])); ob->empty_drawsize *= max_scale; } } else if (ob->type == OB_LAMP) { - Lamp *la = ob->data; + Light *la = ob->data; if (la->type != LA_AREA) { continue; } @@ -685,7 +680,7 @@ static int apply_objects_internal( if (apply_loc) zero_v3(ob->loc); if (apply_scale) - ob->size[0] = ob->size[1] = ob->size[2] = 1.0f; + ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f; if (apply_rot) { zero_v3(ob->rot); unit_qt(ob->quat); @@ -785,9 +780,9 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "location", 0, "Location", ""); - RNA_def_boolean(ot->srna, "rotation", 0, "Rotation", ""); - RNA_def_boolean(ot->srna, "scale", 0, "Scale", ""); + RNA_def_boolean(ot->srna, "location", true, "Location", ""); + RNA_def_boolean(ot->srna, "rotation", true, "Rotation", ""); + RNA_def_boolean(ot->srna, "scale", true, "Scale", ""); RNA_def_boolean(ot->srna, "properties", true, "Apply Properties", "Modify properties such as curve vertex radius, font size and bone envelope"); } @@ -810,9 +805,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *tob; - float cursor[3], cent[3], cent_neg[3], centn[3]; + float cent[3], cent_neg[3], centn[3]; + const float *cursor = scene->cursor.location; int centermode = RNA_enum_get(op->ptr, "type"); - int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */ ListBase ctx_data_list; CollectionPointerLink *ctx_ob; @@ -825,12 +820,22 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode"); return OPERATOR_CANCELLED; } - else { - /* get the view settings if 'around' isn't set and the view is available */ - View3D *v3d = CTX_wm_view3d(C); - copy_v3_v3(cursor, scene->cursor.location); - if (v3d && !RNA_struct_property_is_set(op->ptr, "center")) - around = scene->toolsettings->transform_pivot_point; + + int around; + { + PropertyRNA *prop_center = RNA_struct_find_property(op->ptr, "center"); + if (RNA_property_is_set(op->ptr, prop_center)) { + around = RNA_property_enum_get(op->ptr, prop_center); + } + else { + if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CENTER_BOUNDS) { + around = V3D_AROUND_CENTER_BOUNDS; + } + else { + around = V3D_AROUND_CENTER_MEDIAN; + } + RNA_property_enum_set(op->ptr, prop_center, around); + } } zero_v3(cent); @@ -838,7 +843,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (obedit) { if (obedit->type == OB_MESH) { Mesh *me = obedit->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMVert *eve; BMIter iter; @@ -899,8 +904,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) for (tob = bmain->object.first; tob; tob = tob->id.next) { if (tob->data) ((ID *)tob->data)->tag &= ~LIB_TAG_DOIT; - if (tob->dup_group) - ((ID *)tob->dup_group)->tag &= ~LIB_TAG_DOIT; + if (tob->instance_collection) + ((ID *)tob->instance_collection)->tag &= ~LIB_TAG_DOIT; } for (ctx_ob = ctx_data_list.first; @@ -921,8 +926,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (ob->data == NULL) { /* special support for dupligroups */ - if ((ob->transflag & OB_DUPLICOLLECTION) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) { - if (ID_IS_LINKED(ob->dup_group)) { + if ((ob->transflag & OB_DUPLICOLLECTION) && ob->instance_collection && (ob->instance_collection->id.tag & LIB_TAG_DOIT) == 0) { + if (ID_IS_LINKED(ob->instance_collection)) { tot_lib_error++; } else { @@ -939,10 +944,10 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_m4_v3(ob->imat, cent); } - add_v3_v3(ob->dup_group->dupli_ofs, cent); + add_v3_v3(ob->instance_collection->instance_offset, cent); tot_change++; - ob->dup_group->id.tag |= LIB_TAG_DOIT; + ob->instance_collection->id.tag |= LIB_TAG_DOIT; do_inverse_offset = true; } } @@ -1007,7 +1012,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Curve *cu = ob->data; - if (ob->bb == NULL && (centermode != ORIGIN_TO_CURSOR)) { + if (ob->runtime.bb == NULL && (centermode != ORIGIN_TO_CURSOR)) { /* do nothing*/ } else { @@ -1016,8 +1021,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } else { /* extra 0.5 is the height o above line */ - cent[0] = 0.5f * (ob->bb->vec[4][0] + ob->bb->vec[0][0]); - cent[1] = 0.5f * (ob->bb->vec[0][1] + ob->bb->vec[2][1]); + cent[0] = 0.5f * (ob->runtime.bb->vec[4][0] + ob->runtime.bb->vec[0][0]); + cent[1] = 0.5f * (ob->runtime.bb->vec[0][1] + ob->runtime.bb->vec[2][1]); } cent[2] = 0.0f; @@ -1122,7 +1127,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) float diff_mat[4][4]; float inverse_diff_mat[4][4]; - /* recalculate all strokes (all layers are considered without evaluating lock attributtes) */ + /* recalculate all strokes + * (all layers are considered without evaluating lock attributes) */ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* calculate difference matrix */ ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat); @@ -1192,7 +1198,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if ((ob_other->flag & OB_DONE) == 0 && ((ob->data && (ob->data == ob_other->data)) || - (ob->dup_group == ob_other->dup_group && + (ob->instance_collection == ob_other->instance_collection && (ob->transflag | ob_other->transflag) & OB_DUPLICOLLECTION))) { ob_other->flag |= OB_DONE; @@ -1203,7 +1209,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BKE_object_where_is_calc(depsgraph, scene, ob_other); if (ob_other->type == OB_ARMATURE) { - BKE_pose_where_is(depsgraph, scene, ob_other); /* needed for bone parents */ + /* needed for bone parents */ + BKE_pose_where_is(depsgraph, scene, ob_other); } ignore_parent_tx(C, bmain, scene, ob_other); } @@ -1250,13 +1257,13 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) "Calculate the center of mass from the surface area"}, {ORIGIN_TO_CENTER_OF_MASS_VOLUME, "ORIGIN_CENTER_OF_VOLUME", 0, "Origin to Center of Mass (Volume)", "Calculate the center of mass from the volume (must be manifold geometry with consistent normals)"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static const EnumPropertyItem prop_set_bounds_types[] = { {V3D_AROUND_CENTER_MEDIAN, "MEDIAN", 0, "Median Center", ""}, {V3D_AROUND_CENTER_BOUNDS, "BOUNDS", 0, "Bounds Center", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* identifiers */ @@ -1278,17 +1285,16 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) } /* -------------------------------------------------------------------- */ - /** \name Transform Axis Target * - * Note this is an experemental operator to point lamps/cameras at objects. + * Note this is an experemental operator to point lights/cameras at objects. * We may re-work how this behaves based on user feedback. * - campbell. * \{ */ /* When using multiple objects, apply their relative rotational offset to the active object. */ #define USE_RELATIVE_ROTATION -/* Disable overlays, ignoring user setting (lamp wire gets in the way). */ +/* Disable overlays, ignoring user setting (light wire gets in the way). */ #define USE_RENDER_OVERRIDE /* Calculate a depth if the cursor isn't already over a depth (not essential but feels buggy without). */ #define USE_FAKE_DEPTH_INIT @@ -1355,12 +1361,12 @@ static void object_transform_axis_target_calc_depth_init(struct XFormAxisData *x static bool object_is_target_compat(const Object *ob) { if (ob->type == OB_LAMP) { - const Lamp *la = ob->data; + const Light *la = ob->data; if (ELEM(la->type, LA_SUN, LA_SPOT, LA_AREA)) { return true; } } - /* We might want to enable this later, for now just lamps */ + /* We might want to enable this later, for now just lights. */ #if 0 else if (ob->type == OB_CAMERA) { return true; @@ -1396,10 +1402,10 @@ static void object_apply_rotation(Object *ob, const float rmat[3][3]) float rmat4[4][4]; copy_m4_m3(rmat4, rmat); - copy_v3_v3(size, ob->size); + copy_v3_v3(size, ob->scale); copy_v3_v3(loc, ob->loc); BKE_object_apply_mat4(ob, rmat4, true, true); - copy_v3_v3(ob->size, size); + copy_v3_v3(ob->scale, size); copy_v3_v3(ob->loc, loc); } /* We may want to extract this to: BKE_object_apply_location */ @@ -1651,7 +1657,8 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const copy_v3_v3(loc, location_world); madd_v3_v3fl(loc, target_normal, item->xform_dist); object_apply_location(item->ob, loc); - copy_v3_v3(item->ob->obmat[3], loc); /* so orient behaves as expected */ + /* so orient behaves as expected */ + copy_v3_v3(item->ob->obmat[3], loc); } object_orient_to_location(item->ob, item->rot_mat, item->rot_mat[2], location_world); diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c index 780942f04d2..39f5dad7698 100644 --- a/source/blender/editors/object/object_utils.c +++ b/source/blender/editors/object/object_utils.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -14,12 +12,10 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_utils.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include <stdlib.h> diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 036689509e9..f3181f227b2 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,16 +15,10 @@ * * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Ove M Henriksen. - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_vgroup.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include <string.h> @@ -50,7 +42,6 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BLI_linklist_stack.h" #include "BLI_utildefines_stack.h" @@ -90,7 +81,9 @@ static bool vertex_group_use_vert_sel(Object *ob) if (ob->mode == OB_MODE_EDIT) { return true; } - else if (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_VERT_SEL) { + else if ((ob->type == OB_MESH) && + ((Mesh *)ob->data)->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL)) + { return true; } else { @@ -155,8 +148,8 @@ bool ED_vgroup_parray_alloc(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, co { Mesh *me = (Mesh *)id; - if (me->edit_btmesh) { - BMEditMesh *em = me->edit_btmesh; + if (me->edit_mesh) { + BMEditMesh *em = me->edit_mesh; BMesh *bm = em->bm; const int cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT); BMIter iter; @@ -514,7 +507,7 @@ static void ED_mesh_defvert_mirror_update_em( const int cd_dvert_offset) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMVert *eve_mirr; bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; @@ -551,7 +544,7 @@ static void ED_mesh_defvert_mirror_update_ob(Object *ob, int def_nr, int vidx) void ED_vgroup_vert_active_mirror(Object *ob, int def_nr) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; MDeformVert *dvert_act; if (me->editflag & ME_EDIT_MIRROR_X) { @@ -588,7 +581,7 @@ static void vgroup_remove_weight(Object *ob, const int def_nr) static bool vgroup_normalize_active_vertex(Object *ob, eVGroupSelect subset_type) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; BMVert *eve_act; int v_act; MDeformVert *dvert_act; @@ -627,7 +620,7 @@ static bool vgroup_normalize_active_vertex(Object *ob, eVGroupSelect subset_type static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; MDeformVert *dvert_act; int i, vgroup_tot, subset_count; const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); @@ -683,7 +676,7 @@ static const EnumPropertyItem WT_vertex_group_select_item[] = { "BONE_DEFORM", 0, "Deform Pose Bones", "All Vertex Groups assigned to Deform Bones"}, {WT_VGROUP_ALL, "ALL", 0, "All Groups", "All Vertex Groups"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; const EnumPropertyItem *ED_object_vgroup_selection_itemf_helper( @@ -903,8 +896,8 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) if (ob->type == OB_MESH) { Mesh *me = ob->data; - if (me->edit_btmesh) { - BMEditMesh *em = me->edit_btmesh; + if (me->edit_mesh) { + BMEditMesh *em = me->edit_mesh; const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); /* warning, this lookup is _not_ fast */ @@ -960,7 +953,9 @@ float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) } void ED_vgroup_select_by_name(Object *ob, const char *name) -{ /* note: ob->actdef==0 signals on painting to create a new one, if a bone in posemode is selected */ +{ + /* note: ob->actdef==0 signals on painting to create a new one, + * if a bone in posemode is selected */ ob->actdef = defgroup_name_index(ob, name) + 1; } @@ -978,8 +973,8 @@ static void vgroup_select_verts(Object *ob, int select) if (ob->type == OB_MESH) { Mesh *me = ob->data; - if (me->edit_btmesh) { - BMEditMesh *em = me->edit_btmesh; + if (me->edit_mesh) { + BMEditMesh *em = me->edit_mesh; const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); if (cd_dvert_offset != -1) { @@ -1623,7 +1618,7 @@ enum { VGROUP_TOGGLE, VGROUP_LOCK, VGROUP_UNLOCK, - VGROUP_INVERT + VGROUP_INVERT, }; static const EnumPropertyItem vgroup_lock_actions[] = { @@ -1631,7 +1626,7 @@ static const EnumPropertyItem vgroup_lock_actions[] = { {VGROUP_LOCK, "LOCK", 0, "Lock", "Lock all vertex groups"}, {VGROUP_UNLOCK, "UNLOCK", 0, "Unlock", "Unlock all vertex groups"}, {VGROUP_INVERT, "INVERT", 0, "Invert", "Invert the lock state of all vertex groups"}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; static void vgroup_lock_all(Object *ob, int action) @@ -1946,20 +1941,22 @@ static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2) { /* qsort sorts in ascending order. We want descending order to save a memcopy * so this compare function is inverted from the standard greater than comparison qsort needs. - * A normal compare function is called with two pointer arguments and should return an integer less than, equal to, - * or greater than zero corresponding to whether its first argument is considered less than, equal to, - * or greater than its second argument. This does the opposite. */ + * A normal compare function is called with two pointer arguments and should return an integer + * less than, equal to, or greater than zero corresponding to whether its first argument is + * considered less than, equal to, or greater than its second argument. + * This does the opposite. */ const struct MDeformWeight *dw1 = a1, *dw2 = a2; if (dw1->weight < dw2->weight) return 1; else if (dw1->weight > dw2->weight) return -1; - else if (&dw1 < &dw2) return 1; /* compare addresses so we have a stable sort algorithm */ + else if (&dw1 < &dw2) return 1; /* compare address for stable sort algorithm */ else return -1; } /* Used for limiting the number of influencing bones per vertex when exporting * skinned meshes. if all_deform_weights is True, limit all deform modifiers - * to max_weights regardless of type, otherwise, only limit the number of influencing bones per vertex*/ + * to max_weights regardless of type, otherwise, + * only limit the number of influencing bones per vertex. */ static int vgroup_limit_total_subset( Object *ob, const bool *vgroup_validmap, @@ -2214,7 +2211,7 @@ void ED_vgroup_mirror( /* only the active group */ if (ob->type == OB_MESH) { Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; if (em) { const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT); @@ -2391,8 +2388,8 @@ static void vgroup_assign_verts(Object *ob, const float weight) if (ob->type == OB_MESH) { Mesh *me = ob->data; - if (me->edit_btmesh) { - BMEditMesh *em = me->edit_btmesh; + if (me->edit_mesh) { + BMEditMesh *em = me->edit_mesh; int cd_dvert_offset; BMIter iter; @@ -2679,8 +2676,10 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "all", 0, "All", "Remove all vertex groups"); - RNA_def_boolean(ot->srna, "all_unlocked", 0, "All Unlocked", "Remove all unlocked vertex groups"); + PropertyRNA *prop = RNA_def_boolean(ot->srna, "all", 0, "All", "Remove all vertex groups"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); + prop = RNA_def_boolean(ot->srna, "all_unlocked", 0, "All Unlocked", "Remove all unlocked vertex groups"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } static int vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op)) @@ -3626,7 +3625,7 @@ static void vgroup_sort_bone_hierarchy(Object *ob, ListBase *bonebase) enum { SORT_TYPE_NAME = 0, - SORT_TYPE_BONEHIERARCHY = 1 + SORT_TYPE_BONEHIERARCHY = 1, }; static int vertex_group_sort_exec(bContext *C, wmOperator *op) @@ -3667,7 +3666,7 @@ void OBJECT_OT_vertex_group_sort(wmOperatorType *ot) static const EnumPropertyItem vgroup_sort_type[] = { {SORT_TYPE_NAME, "NAME", 0, "Name", ""}, {SORT_TYPE_BONEHIERARCHY, "BONE_HIERARCHY", 0, "Bone Hierarchy", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; ot->name = "Sort Vertex Groups"; @@ -3718,7 +3717,7 @@ void OBJECT_OT_vertex_group_move(wmOperatorType *ot) static const EnumPropertyItem vgroup_slot_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, - {0, NULL, 0, NULL, NULL} + {0, NULL, 0, NULL, NULL}, }; /* identifiers */ @@ -3742,7 +3741,7 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr) MDeformVert *dvert_act; Mesh *me = ob->data; - BMEditMesh *em = me->edit_btmesh; + BMEditMesh *em = me->edit_mesh; float weight_act; int i; diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c index d28ed71c382..753e29ca9a7 100644 --- a/source/blender/editors/object/object_warp.c +++ b/source/blender/editors/object/object_warp.c @@ -1,6 +1,4 @@ /* - * ***** BEGIN GPL LICENSE BLOCK ***** - * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -17,12 +15,10 @@ * * The Original Code is Copyright (C) 2013 by Blender Foundation * All rights reserved. - * - * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/object/object_warp.c - * \ingroup edobj +/** \file + * \ingroup edobj */ #include "DNA_object_types.h" |