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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.cc219
-rw-r--r--source/blender/editors/object/object_bake_api.c33
-rw-r--r--source/blender/editors/object/object_constraint.c6
-rw-r--r--source/blender/editors/object/object_hook.c18
-rw-r--r--source/blender/editors/object/object_modifier.cc5
-rw-r--r--source/blender/editors/object/object_relations.c22
-rw-r--r--source/blender/editors/object/object_remesh.cc10
-rw-r--r--source/blender/editors/object/object_transform.cc44
-rw-r--r--source/blender/editors/object/object_utils.c24
-rw-r--r--source/blender/editors/object/object_warp.c2
10 files changed, 206 insertions, 177 deletions
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc
index 3ce39b695e0..6075e4250eb 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -322,7 +322,7 @@ void ED_object_base_init_transform_on_add(Object *object, const float loc[3], co
copy_v3_v3(object->rot, rot);
}
- BKE_object_to_mat4(object, object->obmat);
+ BKE_object_to_mat4(object, object->object_to_world);
}
float ED_object_new_primitive_matrix(bContext *C,
@@ -342,14 +342,14 @@ float ED_object_new_primitive_matrix(bContext *C,
invert_m3(rmat);
/* inverse transform for initial rotation and object */
- copy_m3_m4(mat, obedit->obmat);
+ copy_m3_m4(mat, obedit->object_to_world);
mul_m3_m3m3(cmat, rmat, mat);
invert_m3_m3(imat, cmat);
copy_m4_m3(r_primmat, imat);
/* center */
copy_v3_v3(r_primmat[3], loc);
- sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->obmat[3]);
+ sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->object_to_world[3]);
invert_m3_m3(imat, mat);
mul_m3_v3(imat, r_primmat[3]);
@@ -2084,7 +2084,7 @@ static int object_curves_empty_hair_add_exec(bContext *C, wmOperator *op)
Object *curves_ob = ED_object_add_type(
C, OB_CURVES, nullptr, nullptr, nullptr, false, local_view_bits);
- BKE_object_apply_mat4(curves_ob, surface_ob->obmat, false, false);
+ BKE_object_apply_mat4(curves_ob, surface_ob->object_to_world, false, false);
/* Set surface object. */
Curves *curves_id = static_cast<Curves *>(curves_ob->data);
@@ -2561,8 +2561,8 @@ static void make_object_duplilist_real(bContext *C,
id_us_min((ID *)ob_dst->instance_collection);
ob_dst->instance_collection = nullptr;
- copy_m4_m4(ob_dst->obmat, dob->mat);
- BKE_object_apply_mat4(ob_dst, ob_dst->obmat, false, false);
+ copy_m4_m4(ob_dst->object_to_world, dob->mat);
+ BKE_object_apply_mat4(ob_dst, ob_dst->object_to_world, false, false);
BLI_ghash_insert(dupli_gh, dob, ob_dst);
if (parent_gh) {
@@ -3017,7 +3017,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
float loc[3], size[3], rot[3][3], eul[3];
float matrix[4][4];
- mat4_to_loc_rot_size(loc, rot, size, ob->obmat);
+ mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world);
mat3_to_eul(eul, rot);
Object *ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits);
@@ -3556,11 +3556,62 @@ void OBJECT_OT_convert(wmOperatorType *ot)
/** \name Duplicate Object Operator
* \{ */
+static void object_add_sync_base_collection(
+ Main *bmain, Scene *scene, ViewLayer *view_layer, Base *base_src, Object *object_new)
+{
+ if ((base_src != nullptr) && (base_src->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT)) {
+ BKE_collection_object_add_from(bmain, scene, base_src->object, object_new);
+ }
+ else {
+ LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer);
+ BKE_collection_object_add(bmain, layer_collection->collection, object_new);
+ }
+}
+
+static void object_add_sync_local_view(Base *base_src, Base *base_new)
+{
+ base_new->local_view_bits = base_src->local_view_bits;
+}
+
+static void object_add_sync_rigid_body(Main *bmain, Object *object_src, Object *object_new)
+{
+ /* 1) duplis should end up in same collection as the original
+ * 2) Rigid Body sim participants MUST always be part of a collection...
+ */
+ /* XXX: is 2) really a good measure here? */
+ if (object_src->rigidbody_object || object_src->rigidbody_constraint) {
+ LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
+ if (BKE_collection_has_object(collection, object_src)) {
+ BKE_collection_object_add(bmain, collection, object_new);
+ }
+ }
+ }
+}
+
/**
* - Assumes `id.new` is correct.
* - Leaves selection of base/object unaltered.
* - Sets #ID.newid pointers.
*/
+static void object_add_duplicate_internal(Main *bmain,
+ Object *ob,
+ const eDupli_ID_Flags dupflag,
+ const eLibIDDuplicateFlags duplicate_options,
+ Object **r_ob_new)
+{
+ if (ob->mode & OB_MODE_POSE) {
+ return;
+ }
+
+ Object *obn = static_cast<Object *>(
+ ID_NEW_SET(ob, BKE_object_duplicate(bmain, ob, dupflag, duplicate_options)));
+ if (r_ob_new) {
+ *r_ob_new = obn;
+ }
+ DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+ return;
+}
+
static Base *object_add_duplicate_internal(Main *bmain,
Scene *scene,
ViewLayer *view_layer,
@@ -3569,49 +3620,25 @@ static Base *object_add_duplicate_internal(Main *bmain,
const eLibIDDuplicateFlags duplicate_options,
Object **r_ob_new)
{
- Base *base, *basen = nullptr;
- Object *obn;
-
- if (ob->mode & OB_MODE_POSE) {
- /* nothing? */
+ Object *object_new = nullptr;
+ object_add_duplicate_internal(bmain, ob, dupflag, duplicate_options, &object_new);
+ if (r_ob_new) {
+ *r_ob_new = object_new;
+ }
+ if (object_new == nullptr) {
+ return nullptr;
}
- else {
- obn = static_cast<Object *>(
- ID_NEW_SET(ob, BKE_object_duplicate(bmain, ob, dupflag, duplicate_options)));
- if (r_ob_new) {
- *r_ob_new = obn;
- }
- DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
-
- BKE_view_layer_synced_ensure(scene, view_layer);
- base = BKE_view_layer_base_find(view_layer, ob);
- if ((base != nullptr) && (base->flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT)) {
- BKE_collection_object_add_from(bmain, scene, ob, obn);
- }
- else {
- LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer);
- BKE_collection_object_add(bmain, layer_collection->collection, obn);
- }
-
- BKE_view_layer_synced_ensure(scene, view_layer);
- basen = BKE_view_layer_base_find(view_layer, obn);
- if (base != nullptr && basen != nullptr) {
- 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...
- */
- /* XXX: is 2) really a good measure here? */
- if (ob->rigidbody_object || ob->rigidbody_constraint) {
- LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
- if (BKE_collection_has_object(collection, ob)) {
- BKE_collection_object_add(bmain, collection, obn);
- }
- }
- }
+ BKE_view_layer_synced_ensure(scene, view_layer);
+ Base *base_src = BKE_view_layer_base_find(view_layer, ob);
+ object_add_sync_base_collection(bmain, scene, view_layer, base_src, object_new);
+ BKE_view_layer_synced_ensure(scene, view_layer);
+ Base *base_new = BKE_view_layer_base_find(view_layer, object_new);
+ if (base_src && base_new) {
+ object_add_sync_local_view(base_src, base_new);
}
- return basen;
+ object_add_sync_rigid_body(bmain, ob, object_new);
+ return base_new;
}
Base *ED_object_add_duplicate(
@@ -3665,70 +3692,70 @@ static int duplicate_exec(bContext *C, wmOperator *op)
* we also want to remap pointers between those... */
BKE_main_id_newptr_and_tag_clear(bmain);
- /* Do not do collection re-syncs for each object; will do it once afterwards.
- * However this means we can't get to new duplicated Base's immediately, will
- * have to process them after the sync. */
- BKE_layer_collection_resync_forbid();
-
/* Duplicate the selected objects, remember data needed to process
- * after the sync (the base of the original object, and the copy of the
- * original object). */
- blender::Vector<std::pair<Base *, Object *>> source_bases_new_objects;
- Object *ob_new_active = nullptr;
+ * after the sync. */
+ struct DuplicateObjectLink {
+ Base *base_src = nullptr;
+ Object *object_new = nullptr;
+
+ DuplicateObjectLink(Base *base_src) : base_src(base_src)
+ {
+ }
+ };
+ blender::Vector<DuplicateObjectLink> object_base_links;
CTX_DATA_BEGIN (C, Base *, base, selected_bases) {
- Object *ob_new = nullptr;
+ object_base_links.append(DuplicateObjectLink(base));
+ }
+ CTX_DATA_END;
+
+ bool new_objects_created = false;
+ for (DuplicateObjectLink &link : object_base_links) {
object_add_duplicate_internal(bmain,
- scene,
- view_layer,
- base->object,
+ link.base_src->object,
dupflag,
LIB_ID_DUPLICATE_IS_SUBPROCESS | LIB_ID_DUPLICATE_IS_ROOT_ID,
- &ob_new);
- if (ob_new == nullptr) {
- continue;
- }
- source_bases_new_objects.append({base, ob_new});
-
- /* note that this is safe to do with this context iterator,
- * the list is made in advance */
- ED_object_base_select(base, BA_DESELECT);
-
- /* new object will become active */
- BKE_view_layer_synced_ensure(scene, view_layer);
- if (BKE_view_layer_active_base_get(view_layer) == base) {
- ob_new_active = ob_new;
+ &link.object_new);
+ if (link.object_new) {
+ new_objects_created = true;
}
}
- CTX_DATA_END;
- BKE_layer_collection_resync_allow();
- if (source_bases_new_objects.is_empty()) {
+ if (!new_objects_created) {
return OPERATOR_CANCELLED;
}
- /* Sync the collection now, after everything is duplicated. */
- BKE_main_collection_sync(bmain);
+ /* Sync that could tag the view_layer out of sync. */
+ for (DuplicateObjectLink &link : object_base_links) {
+ /* note that this is safe to do with this context iterator,
+ * the list is made in advance */
+ ED_object_base_select(link.base_src, BA_DESELECT);
+ if (link.object_new) {
+ object_add_sync_base_collection(bmain, scene, view_layer, link.base_src, link.object_new);
+ object_add_sync_rigid_body(bmain, link.base_src->object, link.object_new);
+ }
+ }
- /* After sync we can get to the new Base data, process it here. */
- for (const auto &item : source_bases_new_objects) {
- Object *ob_new = item.second;
- Base *base_source = item.first;
- BKE_view_layer_synced_ensure(scene, view_layer);
- Base *base_new = BKE_view_layer_base_find(view_layer, ob_new);
- if (base_new == nullptr) {
+ /* Sync the view layer. Everything else should not tag the view_layer out of sync. */
+ BKE_view_layer_synced_ensure(scene, view_layer);
+ const Base *active_base = BKE_view_layer_active_base_get(view_layer);
+ for (DuplicateObjectLink &link : object_base_links) {
+ if (!link.object_new) {
continue;
}
+
+ Base *base_new = BKE_view_layer_base_find(view_layer, link.object_new);
+ BLI_assert(base_new);
ED_object_base_select(base_new, BA_SELECT);
- if (ob_new == ob_new_active) {
+ if (active_base == link.base_src) {
ED_object_base_activate(C, base_new);
}
- if (base_new->object->data) {
- DEG_id_tag_update(static_cast<ID *>(base_new->object->data), 0);
+
+ if (link.object_new->data) {
+ DEG_id_tag_update(static_cast<ID *>(link.object_new->data), 0);
}
- /* #object_add_duplicate_internal will not have done this, since
- * before the collection sync it would not have found the new base yet. */
- base_new->local_view_bits = base_source->local_view_bits;
+
+ object_add_sync_local_view(link.base_src, base_new);
}
/* Note that this will also clear newid pointers and tags. */
@@ -3844,8 +3871,8 @@ static int object_add_named_exec(bContext *C, wmOperator *op)
PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix");
if (RNA_property_is_set(op->ptr, prop_matrix)) {
Object *ob_add = basen->object;
- RNA_property_float_get_array(op->ptr, prop_matrix, &ob_add->obmat[0][0]);
- BKE_object_apply_mat4(ob_add, ob_add->obmat, true, true);
+ RNA_property_float_get_array(op->ptr, prop_matrix, &ob_add->object_to_world[0][0]);
+ BKE_object_apply_mat4(ob_add, ob_add->object_to_world, true, true);
DEG_id_tag_update(&ob_add->id, ID_RECALC_TRANSFORM);
}
@@ -3942,7 +3969,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op)
float mat_dst_unit[4][4];
float final_delta[4][4];
- normalize_m4_m4(mat_src_unit, ob->obmat);
+ normalize_m4_m4(mat_src_unit, ob->object_to_world);
normalize_m4_m4(mat_dst_unit, matrix);
invert_m4(mat_src_unit);
mul_m4_m4m4(final_delta, mat_dst_unit, mat_src_unit);
@@ -4097,7 +4124,7 @@ static int object_join_exec(bContext *C, wmOperator *op)
* If the zero scale is removed, the data on this axis remains un-scaled
* (something that wouldn't work for #invert_m4_m4_safe). */
float imat_test[4][4];
- if (!invert_m4_m4(imat_test, ob->obmat)) {
+ if (!invert_m4_m4(imat_test, ob->object_to_world)) {
BKE_report(op->reports,
RPT_WARNING,
"Active object final transform has one or more zero scaled axes");
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 781866db6a0..d05badc8fee 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -1518,10 +1518,10 @@ static int bake(const BakeAPIRender *bkr,
highpoly[i].me = BKE_mesh_new_from_object(NULL, highpoly[i].ob_eval, false, false);
/* Low-poly to high-poly transformation matrix. */
- copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->obmat);
+ copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world);
invert_m4_m4(highpoly[i].imat, highpoly[i].obmat);
- highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->obmat);
+ highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world);
i++;
}
@@ -1540,18 +1540,19 @@ static int bake(const BakeAPIRender *bkr,
pixel_array_high = MEM_mallocN(sizeof(BakePixel) * targets.pixels_num,
"bake pixels high poly");
- if (!RE_bake_pixels_populate_from_objects(me_low_eval,
- pixel_array_low,
- pixel_array_high,
- highpoly,
- tot_highpoly,
- targets.pixels_num,
- ob_cage != NULL,
- bkr->cage_extrusion,
- bkr->max_ray_distance,
- ob_low_eval->obmat,
- (ob_cage ? ob_cage->obmat : ob_low_eval->obmat),
- me_cage_eval)) {
+ if (!RE_bake_pixels_populate_from_objects(
+ me_low_eval,
+ pixel_array_low,
+ pixel_array_high,
+ highpoly,
+ tot_highpoly,
+ targets.pixels_num,
+ ob_cage != NULL,
+ bkr->cage_extrusion,
+ bkr->max_ray_distance,
+ ob_low_eval->object_to_world,
+ (ob_cage ? ob_cage->object_to_world : ob_low_eval->object_to_world),
+ me_cage_eval)) {
BKE_report(reports, RPT_ERROR, "Error handling selected objects");
goto cleanup;
}
@@ -1629,7 +1630,7 @@ static int bake(const BakeAPIRender *bkr,
targets.result,
me_low_eval,
bkr->normal_swizzle,
- ob_low_eval->obmat);
+ ob_low_eval->object_to_world);
}
else {
/* From multi-resolution. */
@@ -1655,7 +1656,7 @@ static int bake(const BakeAPIRender *bkr,
targets.result,
(me_nores) ? me_nores : me_low_eval,
bkr->normal_swizzle,
- ob_low_eval->obmat);
+ ob_low_eval->object_to_world);
if (md) {
BKE_id_free(NULL, &me_nores->id);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index fa9ded0f989..1386da5dbde 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -2327,14 +2327,14 @@ static bool get_new_constraint_target(
/* Since by default, IK targets the tip of the last bone,
* use the tip of the active PoseChannel if adding a target for an IK Constraint. */
if (con_type == CONSTRAINT_TYPE_KINEMATIC) {
- mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_tail);
+ mul_v3_m4v3(obt->loc, obact->object_to_world, pchanact->pose_tail);
}
else {
- mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_head);
+ mul_v3_m4v3(obt->loc, obact->object_to_world, pchanact->pose_head);
}
}
else {
- copy_v3_v3(obt->loc, obact->obmat[3]);
+ copy_v3_v3(obt->loc, obact->object_to_world[3]);
}
/* restore, BKE_object_add sets active */
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index 27659042f50..63093692e43 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -535,7 +535,7 @@ static int add_hook_object(const bContext *C,
ob = add_hook_object_new(bmain, scene, view_layer, v3d, obedit);
/* transform cent to global coords for loc */
- mul_v3_m4v3(ob->loc, obedit->obmat, cent);
+ mul_v3_m4v3(ob->loc, obedit->object_to_world, cent);
}
md = obedit->modifiers.first;
@@ -556,13 +556,13 @@ static int add_hook_object(const bContext *C,
unit_m4(pose_mat);
- invert_m4_m4(obedit->imat, obedit->obmat);
+ invert_m4_m4(obedit->imat, obedit->object_to_world);
if (mode == OBJECT_ADDHOOK_NEWOB) {
/* pass */
}
else {
/* may overwrite with pose-bone location, below */
- mul_v3_m4v3(cent, obedit->imat, ob->obmat[3]);
+ mul_v3_m4v3(cent, obedit->imat, ob->object_to_world[3]);
}
if (mode == OBJECT_ADDHOOK_SELOB_BONE) {
@@ -576,7 +576,7 @@ static int add_hook_object(const bContext *C,
pchan_act = BKE_pose_channel_active_if_layer_visible(ob);
if (LIKELY(pchan_act)) {
invert_m4_m4(pose_mat, pchan_act->pose_mat);
- mul_v3_m4v3(cent, ob->obmat, pchan_act->pose_mat[3]);
+ mul_v3_m4v3(cent, ob->object_to_world, pchan_act->pose_mat[3]);
mul_v3_m4v3(cent, obedit->imat, cent);
}
}
@@ -588,16 +588,16 @@ static int add_hook_object(const bContext *C,
copy_v3_v3(hmd->cent, cent);
/* matrix calculus */
- /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */
+ /* vert x (obmat x hook->imat) x hook->object_to_world x ob->imat */
/* (parentinv ) */
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_transform_copy(object_eval, ob);
BKE_object_where_is_calc(depsgraph, scene_eval, object_eval);
- invert_m4_m4(object_eval->imat, object_eval->obmat);
+ invert_m4_m4(object_eval->imat, object_eval->object_to_world);
/* apparently this call goes from right to left... */
- mul_m4_series(hmd->parentinv, pose_mat, object_eval->imat, obedit->obmat);
+ mul_m4_series(hmd->parentinv, pose_mat, object_eval->imat, obedit->object_to_world);
DEG_relations_tag_update(bmain);
@@ -834,10 +834,10 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op)
}
/* recenter functionality */
- copy_m3_m4(bmat, ob->obmat);
+ copy_m3_m4(bmat, ob->object_to_world);
invert_m3_m3(imat, bmat);
- sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->obmat[3]);
+ sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->object_to_world[3]);
mul_m3_v3(imat, hmd->cent);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index c7995809438..85a35861329 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -218,7 +218,7 @@ ModifierData *ED_object_modifier_add(
if (ob->mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
- BKE_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md);
+ BKE_sculpt_mask_layers_ensure(nullptr, nullptr, ob, (MultiresModifierData *)new_md);
}
}
else if (type == eModifierType_Skin) {
@@ -2041,7 +2041,8 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
if (object->mode & OB_MODE_SCULPT) {
/* ensure that grid paint mask layer is created */
- BKE_sculpt_mask_layers_ensure(object, mmd);
+ BKE_sculpt_mask_layers_ensure(
+ CTX_data_ensure_evaluated_depsgraph(C), CTX_data_main(C), object, mmd);
}
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 5da19d76259..10068def991 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -272,7 +272,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* inverse parent matrix */
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
- invert_m4_m4(ob->parentinv, workob.obmat);
+ invert_m4_m4(ob->parentinv, workob.object_to_world);
}
else {
ob->partype = PARVERT1;
@@ -280,7 +280,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* inverse parent matrix */
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
- invert_m4_m4(ob->parentinv, workob.obmat);
+ invert_m4_m4(ob->parentinv, workob.object_to_world);
}
}
}
@@ -401,7 +401,7 @@ void ED_object_parent_clear(Object *ob, const int type)
/* 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);
+ BKE_object_apply_mat4(ob, ob->object_to_world, true, false);
break;
}
case CLEAR_PARENT_INVERSE: {
@@ -584,7 +584,7 @@ bool ED_object_parent_set(ReportList *reports,
if (keep_transform) {
/* Was removed because of bug T23577,
* but this can be handy in some cases too T32616, so make optional. */
- BKE_object_apply_mat4(ob, ob->obmat, false, false);
+ BKE_object_apply_mat4(ob, ob->object_to_world, false, false);
}
/* Set the parent (except for follow-path constraint option). */
@@ -706,7 +706,7 @@ bool ED_object_parent_set(ReportList *reports,
BKE_constraint_target_matrix_get(
depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra);
- sub_v3_v3v3(vec, ob->obmat[3], cmat[3]);
+ sub_v3_v3v3(vec, ob->object_to_world[3], cmat[3]);
copy_v3_v3(ob->loc, vec);
}
@@ -729,7 +729,7 @@ bool ED_object_parent_set(ReportList *reports,
ob->partype = PAROBJECT;
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
- invert_m4_m4(ob->parentinv, workob.obmat);
+ invert_m4_m4(ob->parentinv, workob.object_to_world);
}
else if (is_armature_parent && (ob->type == OB_GPENCIL) && (par->type == OB_ARMATURE)) {
if (partype == PAR_ARMATURE) {
@@ -747,7 +747,7 @@ bool ED_object_parent_set(ReportList *reports,
ob->partype = PAROBJECT;
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
- invert_m4_m4(ob->parentinv, workob.obmat);
+ invert_m4_m4(ob->parentinv, workob.object_to_world);
}
else if ((ob->type == OB_GPENCIL) && (par->type == OB_LATTICE)) {
/* Add Lattice modifier */
@@ -758,12 +758,12 @@ bool ED_object_parent_set(ReportList *reports,
ob->partype = PAROBJECT;
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
- invert_m4_m4(ob->parentinv, workob.obmat);
+ invert_m4_m4(ob->parentinv, workob.object_to_world);
}
else {
/* calculate inverse parent matrix */
BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob);
- invert_m4_m4(ob->parentinv, workob.obmat);
+ invert_m4_m4(ob->parentinv, workob.object_to_world);
}
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
@@ -772,7 +772,7 @@ bool ED_object_parent_set(ReportList *reports,
static void parent_set_vert_find(KDTree_3d *tree, Object *child, int vert_par[3], bool is_tri)
{
- const float *co_find = child->obmat[3];
+ const float *co_find = child->object_to_world[3];
if (is_tri) {
KDTreeNearest_3d nearest[3];
int tot;
@@ -1186,7 +1186,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
}
if (type == CLEAR_TRACK_KEEP_TRANSFORM) {
- BKE_object_apply_mat4(ob, ob->obmat, true, true);
+ BKE_object_apply_mat4(ob, ob->object_to_world, true, true);
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc
index 8358bf632d3..c653610d6fe 100644
--- a/source/blender/editors/object/object_remesh.cc
+++ b/source/blender/editors/object/object_remesh.cc
@@ -296,7 +296,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion * /*ar*/, void *arg)
uint pos3d = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
GPU_matrix_push();
- GPU_matrix_mul(cd->active_object->obmat);
+ GPU_matrix_mul(cd->active_object->object_to_world);
/* Draw Rect */
immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f);
@@ -494,7 +494,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
float view_normal[3] = {0.0f, 0.0f, 1.0f};
/* Calculate the view normal. */
- invert_m4_m4(active_object->imat, active_object->obmat);
+ invert_m4_m4(active_object->imat, active_object->object_to_world);
copy_m3_m4(mat, rv3d->viewinv);
mul_m3_v3(mat, view_normal);
copy_m3_m4(mat, active_object->imat);
@@ -535,7 +535,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* Project the selected face in the previous step of the Bounding Box. */
for (int i = 0; i < 4; i++) {
float preview_plane_world_space[3];
- mul_v3_m4v3(preview_plane_world_space, active_object->obmat, cd->preview_plane[i]);
+ mul_v3_m4v3(preview_plane_world_space, active_object->object_to_world, cd->preview_plane[i]);
ED_view3d_project_v2(region, preview_plane_world_space, preview_plane_proj[i]);
}
@@ -582,7 +582,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* Invert object scale. */
float scale[3];
- mat4_to_size(scale, active_object->obmat);
+ mat4_to_size(scale, active_object->object_to_world);
invert_v3(scale);
size_to_mat4(scale_mat, scale);
@@ -593,7 +593,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* Scale the text to constant viewport size. */
float text_pos_word_space[3];
- mul_v3_m4v3(text_pos_word_space, active_object->obmat, text_pos);
+ mul_v3_m4v3(text_pos_word_space, active_object->object_to_world, text_pos);
const float pixelsize = ED_view3d_pixel_size(rv3d, text_pos_word_space);
scale_m4_fl(scale_mat, pixelsize * 0.5f);
mul_m4_m4_post(cd->text_mat, scale_mat);
diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc
index 6604e3da4d2..a863e9ac324 100644
--- a/source/blender/editors/object/object_transform.cc
+++ b/source/blender/editors/object/object_transform.cc
@@ -527,9 +527,9 @@ static void ignore_parent_tx(Main *bmain, Depsgraph *depsgraph, Scene *scene, Ob
LISTBASE_FOREACH (Object *, ob_child, &bmain->objects) {
if (ob_child->parent == ob) {
Object *ob_child_eval = DEG_get_evaluated_object(depsgraph, ob_child);
- BKE_object_apply_mat4(ob_child_eval, ob_child_eval->obmat, true, false);
+ BKE_object_apply_mat4(ob_child_eval, ob_child_eval->object_to_world, true, false);
BKE_object_workob_calc_parent(depsgraph, scene, ob_child_eval, &workob);
- invert_m4_m4(ob_child->parentinv, workob.obmat);
+ invert_m4_m4(ob_child->parentinv, workob.object_to_world);
/* Copy result of BKE_object_apply_mat4(). */
BKE_object_transform_copy(ob_child, ob_child_eval);
/* Make sure evaluated object is in a consistent state with the original one.
@@ -660,11 +660,11 @@ static int apply_objects_internal(bContext *C,
if (do_multi_user) {
obact = CTX_data_active_object(C);
- invert_m4_m4(obact_invmat, obact->obmat);
+ invert_m4_m4(obact_invmat, obact->object_to_world);
Object workob;
BKE_object_workob_calc_parent(depsgraph, scene, obact, &workob);
- copy_m4_m4(obact_parent, workob.obmat);
+ copy_m4_m4(obact_parent, workob.object_to_world);
copy_m4_m4(obact_parentinv, obact->parentinv);
if (apply_objects_internal_need_single_user(C)) {
@@ -989,7 +989,7 @@ static int apply_objects_internal(bContext *C,
float _obmat[4][4], _iobmat[4][4];
float _mat[4][4];
- copy_m4_m4(_obmat, ob->obmat);
+ copy_m4_m4(_obmat, ob->object_to_world);
invert_m4_m4(_iobmat, _obmat);
copy_m4_m4(_mat, _obmat);
@@ -1075,7 +1075,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator * /*op*/)
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
- BKE_object_apply_mat4(ob_eval, ob_eval->obmat, true, true);
+ BKE_object_apply_mat4(ob_eval, ob_eval->object_to_world, true, true);
BKE_object_transform_copy(ob, ob_eval);
/* update for any children that may get moved */
@@ -1274,7 +1274,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(cent, cursor);
- invert_m4_m4(obedit->imat, obedit->obmat);
+ invert_m4_m4(obedit->imat, obedit->object_to_world);
mul_m4_v3(obedit->imat, cent);
}
else {
@@ -1342,7 +1342,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(cent, cursor);
- invert_m4_m4(ob->imat, ob->obmat);
+ invert_m4_m4(ob->imat, ob->object_to_world);
mul_m4_v3(ob->imat, cent);
}
@@ -1363,7 +1363,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
INIT_MINMAX(min, max);
BKE_object_minmax_dupli(depsgraph, scene, ob, min, max, true);
mid_v3_v3v3(cent, min, max);
- invert_m4_m4(ob->imat, ob->obmat);
+ invert_m4_m4(ob->imat, ob->object_to_world);
mul_m4_v3(ob->imat, cent);
}
@@ -1554,7 +1554,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (centermode == ORIGIN_TO_GEOMETRY) {
zero_v3(gpcenter);
BKE_gpencil_centroid_3d(gpd, gpcenter);
- add_v3_v3(gpcenter, ob->obmat[3]);
+ add_v3_v3(gpcenter, ob->object_to_world[3]);
}
if (centermode == ORIGIN_TO_CURSOR) {
copy_v3_v3(gpcenter, cursor);
@@ -1566,8 +1566,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
float offset_local[3];
int i;
- sub_v3_v3v3(offset_global, gpcenter, ob->obmat[3]);
- copy_m3_m4(bmat, obact->obmat);
+ sub_v3_v3v3(offset_global, gpcenter, ob->object_to_world[3]);
+ copy_m3_m4(bmat, obact->object_to_world);
invert_m3_m3(imat, bmat);
mul_m3_v3(imat, offset_global);
mul_v3_m3v3(offset_local, imat, offset_global);
@@ -1699,7 +1699,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ob_other->flag |= OB_DONE;
DEG_id_tag_update(&ob_other->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
- mul_v3_mat3_m4v3(centn, ob_other->obmat, cent); /* omit translation part */
+ mul_v3_mat3_m4v3(centn, ob_other->object_to_world, cent); /* omit translation part */
add_v3_v3(ob_other->loc, centn);
Object *ob_other_eval = DEG_get_evaluated_object(depsgraph, ob_other);
@@ -1873,9 +1873,9 @@ static void object_transform_axis_target_calc_depth_init(XFormAxisData *xfd, con
int center_tot = 0;
for (XFormAxisItem &item : xfd->object_data) {
const Object *ob = item.ob;
- const float *ob_co_a = ob->obmat[3];
+ const float *ob_co_a = ob->object_to_world[3];
float ob_co_b[3];
- add_v3_v3v3(ob_co_b, ob->obmat[3], ob->obmat[2]);
+ add_v3_v3v3(ob_co_b, ob->object_to_world[3], ob->object_to_world[2]);
float view_isect[3], ob_isect[3];
if (isect_line_line_v3(view_co_a, view_co_b, ob_co_a, ob_co_b, view_isect, ob_isect)) {
add_v3_v3(center, view_isect);
@@ -1946,7 +1946,7 @@ static void object_apply_location(Object *ob, const float loc[3])
/* quick but weak */
Object ob_prev = blender::dna::shallow_copy(*ob);
float mat[4][4];
- copy_m4_m4(mat, ob->obmat);
+ copy_m4_m4(mat, ob->object_to_world);
copy_v3_v3(mat[3], loc);
BKE_object_apply_mat4(ob, mat, true, true);
copy_v3_v3(mat[3], ob->loc);
@@ -1961,7 +1961,7 @@ static bool object_orient_to_location(Object *ob,
const bool z_flip)
{
float delta[3];
- sub_v3_v3v3(delta, ob->obmat[3], location);
+ sub_v3_v3v3(delta, ob->object_to_world[3], location);
if (normalize_v3(delta) != 0.0f) {
if (z_flip) {
negate_v3(delta);
@@ -2139,7 +2139,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
float xform_rot_offset_inv_first[3][3];
for (const int i : xfd->object_data.index_range()) {
XFormAxisItem &item = xfd->object_data[i];
- copy_m3_m4(item.xform_rot_offset, item.ob->obmat);
+ copy_m3_m4(item.xform_rot_offset, item.ob->object_to_world);
normalize_m3(item.xform_rot_offset);
if (i == 0) {
@@ -2158,8 +2158,8 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
XFormAxisItem &item = xfd->object_data[i];
if (is_translate_init) {
float ob_axis[3];
- item.xform_dist = len_v3v3(item.ob->obmat[3], location_world);
- normalize_v3_v3(ob_axis, item.ob->obmat[2]);
+ item.xform_dist = len_v3v3(item.ob->object_to_world[3], location_world);
+ normalize_v3_v3(ob_axis, item.ob->object_to_world[2]);
/* Scale to avoid adding distance when moving between surfaces. */
if (normal_found) {
float scale = fabsf(dot_v3v3(ob_axis, normal));
@@ -2173,7 +2173,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
copy_v3_v3(target_normal, normal);
}
else {
- normalize_v3_v3(target_normal, item.ob->obmat[2]);
+ normalize_v3_v3(target_normal, item.ob->object_to_world[2]);
}
#ifdef USE_RELATIVE_ROTATION
@@ -2190,7 +2190,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const
madd_v3_v3fl(loc, target_normal, item.xform_dist);
object_apply_location(item.ob, loc);
/* so orient behaves as expected */
- copy_v3_v3(item.ob->obmat[3], loc);
+ copy_v3_v3(item.ob->object_to_world[3], loc);
}
object_orient_to_location(
diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c
index 50ba5b8af5f..1387282357f 100644
--- a/source/blender/editors/object/object_utils.c
+++ b/source/blender/editors/object/object_utils.c
@@ -114,20 +114,20 @@ bool ED_object_calc_active_center(Object *ob, const bool select_only, float r_ce
{
if (ob->mode & OB_MODE_EDIT) {
if (ED_object_calc_active_center_for_editmode(ob, select_only, r_center)) {
- mul_m4_v3(ob->obmat, r_center);
+ mul_m4_v3(ob->object_to_world, r_center);
return true;
}
return false;
}
if (ob->mode & OB_MODE_POSE) {
if (ED_object_calc_active_center_for_posemode(ob, select_only, r_center)) {
- mul_m4_v3(ob->obmat, r_center);
+ mul_m4_v3(ob->object_to_world, r_center);
return true;
}
return false;
}
if (!select_only || (ob->base_flag & BASE_SELECTED)) {
- copy_v3_v3(r_center, ob->obmat[3]);
+ copy_v3_v3(r_center, ob->object_to_world[3]);
return true;
}
return false;
@@ -245,11 +245,11 @@ void ED_object_xform_skip_child_container_item_ensure(struct XFormObjectSkipChil
if (!BLI_ghash_ensure_p(xcs->obchild_in_obmode_map, ob, &xf_p)) {
struct XFormObjectSkipChild *xf = MEM_mallocN(sizeof(*xf), __func__);
copy_m4_m4(xf->parentinv_orig, ob->parentinv);
- copy_m4_m4(xf->obmat_orig, ob->obmat);
- copy_m4_m4(xf->parent_obmat_orig, ob->parent->obmat);
- invert_m4_m4(xf->parent_obmat_inv_orig, ob->parent->obmat);
+ copy_m4_m4(xf->obmat_orig, ob->object_to_world);
+ copy_m4_m4(xf->parent_obmat_orig, ob->parent->object_to_world);
+ invert_m4_m4(xf->parent_obmat_inv_orig, ob->parent->object_to_world);
if (ob_parent_recurse) {
- copy_m4_m4(xf->parent_recurse_obmat_orig, ob_parent_recurse->obmat);
+ copy_m4_m4(xf->parent_recurse_obmat_orig, ob_parent_recurse->object_to_world);
}
xf->mode = mode;
xf->ob_parent_recurse = ob_parent_recurse;
@@ -274,14 +274,14 @@ void ED_object_xform_skip_child_container_update_all(struct XFormObjectSkipChild
if (xf->mode == XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM) {
/* Parent is transformed, this isn't so compensate. */
Object *ob_parent_eval = DEG_get_evaluated_object(depsgraph, ob->parent);
- mul_m4_m4m4(dmat, xf->parent_obmat_inv_orig, ob_parent_eval->obmat);
+ mul_m4_m4m4(dmat, xf->parent_obmat_inv_orig, ob_parent_eval->object_to_world);
invert_m4(dmat);
}
else if (xf->mode == XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM_INDIRECT) {
/* Calculate parent matrix (from the root transform). */
Object *ob_parent_recurse_eval = DEG_get_evaluated_object(depsgraph, xf->ob_parent_recurse);
float parent_recurse_obmat_inv[4][4];
- invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->obmat);
+ invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world);
mul_m4_m4m4(dmat, xf->parent_recurse_obmat_orig, parent_recurse_obmat_inv);
invert_m4(dmat);
float parent_obmat_calc[4][4];
@@ -296,7 +296,7 @@ void ED_object_xform_skip_child_container_update_all(struct XFormObjectSkipChild
/* Transform this - without transform data. */
Object *ob_parent_recurse_eval = DEG_get_evaluated_object(depsgraph, xf->ob_parent_recurse);
float parent_recurse_obmat_inv[4][4];
- invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->obmat);
+ invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world);
mul_m4_m4m4(dmat, xf->parent_recurse_obmat_orig, parent_recurse_obmat_inv);
invert_m4(dmat);
float obmat_calc[4][4];
@@ -350,7 +350,7 @@ void ED_object_data_xform_container_item_ensure(struct XFormObjectData_Container
void **xf_p;
if (!BLI_ghash_ensure_p(xds->obdata_in_obmode_map, ob->data, &xf_p)) {
struct XFormObjectData_Extra *xf = MEM_mallocN(sizeof(*xf), __func__);
- copy_m4_m4(xf->obmat_orig, ob->obmat);
+ copy_m4_m4(xf->obmat_orig, ob->object_to_world);
xf->ob = ob;
/* Result may be NULL, that's OK. */
xf->xod = ED_object_data_xform_create(ob->data);
@@ -378,7 +378,7 @@ void ED_object_data_xform_container_update_all(struct XFormObjectData_Container
Object *ob_eval = DEG_get_evaluated_object(depsgraph, xf->ob);
float imat[4][4], dmat[4][4];
invert_m4_m4(imat, xf->obmat_orig);
- mul_m4_m4m4(dmat, imat, ob_eval->obmat);
+ mul_m4_m4m4(dmat, imat, ob_eval->object_to_world);
invert_m4(dmat);
ED_object_data_xform_by_mat4(xf->xod, dmat);
diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c
index a1d53cadd06..d1e6e7000d9 100644
--- a/source/blender/editors/object/object_warp.c
+++ b/source/blender/editors/object/object_warp.c
@@ -38,7 +38,7 @@ static void object_warp_calc_view_matrix(float r_mat_view[4][4],
mul_m4_m4m4(viewmat_roll, mat_offset, viewmat);
/* apply the view and the object matrix */
- mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->obmat);
+ mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->object_to_world);
/* get the view-space cursor */
mul_v3_m4v3(r_center_view, viewmat_roll, center);