[Bf-blender-cvs] [38c7fd36ff7] master: Refactor: Rename Object->imat to Object->world_to_object

Sergey Sharybin noreply at git.blender.org
Wed Nov 2 15:53:34 CET 2022


Commit: 38c7fd36ff7a6eb4522a688d38faa086a6313ae6
Author: Sergey Sharybin
Date:   Wed Nov 2 14:41:49 2022 +0100
Branches: master
https://developer.blender.org/rB38c7fd36ff7a6eb4522a688d38faa086a6313ae6

Refactor: Rename Object->imat to Object->world_to_object

The goal is to improve clarity and readability, without
introducing big design changes.

Follows the recent obmat to object_to_world refactor: the
similar naming is used, and it is a run-time only rename,
meaning, there is no affect on .blend files.

This patch does not touch the redundant inversions. Those
can be removed in almost (if not all) cases, but it would
be the best to do it as a separate change.

Differential Revision: https://developer.blender.org/D16367

===================================================================

M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/armature_update.c
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/blenkernel/intern/fluid.c
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenkernel/intern/object.cc
M	source/blender/blenkernel/intern/object_dupli.cc
M	source/blender/blenkernel/intern/object_update.cc
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/softbody.c
M	source/blender/depsgraph/intern/depsgraph_query_iter.cc
M	source/blender/draw/engines/gpencil/gpencil_draw_data.c
M	source/blender/draw/engines/workbench/workbench_shadow.c
M	source/blender/draw/intern/draw_cache_impl_gpencil.cc
M	source/blender/draw/intern/draw_manager_data.cc
M	source/blender/draw/intern/draw_manager_text.cc
M	source/blender/draw/intern/draw_resource.hh
M	source/blender/editors/armature/armature_add.c
M	source/blender/editors/armature/armature_edit.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/gpencil_sculpt_paint.c
M	source/blender/editors/mesh/editmesh_add_gizmo.c
M	source/blender/editors/mesh/editmesh_extrude.c
M	source/blender/editors/mesh/editmesh_polybuild.c
M	source/blender/editors/mesh/editmesh_preselect_elem.c
M	source/blender/editors/mesh/editmesh_select_similar.c
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/object/object_hook.c
M	source/blender/editors/object/object_remesh.cc
M	source/blender/editors/object/object_transform.cc
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/sculpt_paint/paint_vertex.cc
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M	source/blender/editors/space_view3d/view3d_buttons.c
M	source/blender/editors/space_view3d/view3d_snap.c
M	source/blender/editors/transform/transform_convert_particle.c
M	source/blender/editors/transform/transform_gizmo_3d.c
M	source/blender/editors/transform/transform_mode_vert_slide.c
M	source/blender/editors/uvedit/uvedit_unwrap_ops.c
M	source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
M	source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
M	source/blender/io/alembic/exporter/abc_writer_points.cc
M	source/blender/io/alembic/intern/abc_axis_conversion.cc
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/modifiers/intern/MOD_cast.c
M	source/blender/modifiers/intern/MOD_hook.c
M	source/blender/modifiers/intern/MOD_mesh_to_volume.cc
M	source/blender/modifiers/intern/MOD_volume_displace.cc
M	source/blender/modifiers/intern/MOD_volume_to_mesh.cc
M	source/blender/modifiers/intern/MOD_wave.cc
M	source/blender/nodes/geometry/nodes/node_geo_collection_info.cc
M	source/blender/nodes/geometry/nodes/node_geo_object_info.cc
M	source/blender/nodes/shader/nodes/node_shader_tex_coord.cc
M	source/blender/render/intern/texture_pointdensity.c

===================================================================

diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 0f8bf0e9928..e433c26cc54 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2569,7 +2569,7 @@ void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
     }
   }
   else {
-    invert_m4_m4(ob->imat, ob->object_to_world); /* imat is needed */
+    invert_m4_m4(ob->world_to_object, ob->object_to_world); /* world_to_object is needed */
 
     /* 1. clear flags */
     for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index b9f46118c0d..5f749472b2d 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -253,7 +253,7 @@ static void apply_curve_transform(
   }
 
   /* Convert the position to pose-space. */
-  mul_m4_v3(ob->imat, r_vec);
+  mul_m4_v3(ob->world_to_object, r_vec);
 
   /* Set the new radius (it should be the average value). */
   *r_radius = (radius + *r_radius) / 2;
@@ -818,8 +818,8 @@ void BKE_pose_eval_init(struct Depsgraph *depsgraph, Scene *UNUSED(scene), Objec
   BLI_assert(object->pose != NULL);
   BLI_assert((object->pose->flag & POSE_RECALC) == 0);
 
-  /* imat is needed for solvers. */
-  invert_m4_m4(object->imat, object->object_to_world);
+  /* world_to_object is needed for solvers. */
+  invert_m4_m4(object->world_to_object, object->object_to_world);
 
   /* clear flags */
   for (bPoseChannel *pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) {
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 910869bbc72..88ba50fe901 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -581,11 +581,11 @@ static void cloth_to_object(Object *ob, ClothModifierData *clmd, float (*vertexC
 
   if (clmd->clothObject) {
     /* Inverse matrix is not up to date. */
-    invert_m4_m4(ob->imat, ob->object_to_world);
+    invert_m4_m4(ob->world_to_object, ob->object_to_world);
 
     for (i = 0; i < cloth->mvert_num; i++) {
       copy_v3_v3(vertexCos[i], cloth->verts[i].x);
-      mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */
+      mul_m4_v3(ob->world_to_object, vertexCos[i]); /* cloth is in global coords */
     }
   }
 }
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 1f288aef5ad..bcc4ad0cb55 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -227,7 +227,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
       /* cob->ob or cob->pchan might not exist */
       if (cob->ob && cob->pchan) {
         /* copy new pose-matrix back to owner */
-        mul_m4_m4m4(cob->pchan->pose_mat, cob->ob->imat, cob->matrix);
+        mul_m4_m4m4(cob->pchan->pose_mat, cob->ob->world_to_object, cob->matrix);
 
         /* copy inverse of delta back to owner */
         invert_m4_m4(cob->pchan->constinv, delta);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 983e4b3c6e6..c2ae4efbde8 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -875,7 +875,7 @@ static void do_texture_effector(EffectorCache *eff,
   copy_v3_v3(tex_co, point->loc);
 
   if (eff->pd->flag & PFIELD_TEX_OBJECT) {
-    mul_m4_v3(eff->ob->imat, tex_co);
+    mul_m4_v3(eff->ob->world_to_object, tex_co);
 
     if (eff->pd->flag & PFIELD_TEX_2D) {
       tex_co[2] = 0.0f;
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index b0e99e10acc..a3d2d73678c 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3495,12 +3495,12 @@ static Mesh *create_smoke_geometry(FluidDomainSettings *fds, Mesh *orgmesh, Obje
 
     /* Calculate required shift to match domain's global position
      * it was originally simulated at (if object moves without manta step). */
-    invert_m4_m4(ob->imat, ob->object_to_world);
+    invert_m4_m4(ob->world_to_object, ob->object_to_world);
     mul_m4_v3(ob->object_to_world, ob_loc);
     mul_m4_v3(fds->obmat, ob_cache_loc);
     sub_v3_v3v3(fds->obj_shift_f, ob_cache_loc, ob_loc);
     /* Convert shift to local space and apply to vertices. */
-    mul_mat3_m4_v3(ob->imat, fds->obj_shift_f);
+    mul_mat3_m4_v3(ob->world_to_object, fds->obj_shift_f);
     /* Apply shift to vertices. */
     for (int i = 0; i < num_verts; i++) {
       add_v3_v3(mverts[i].co, fds->obj_shift_f);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 666142e3a54..5409bf61274 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2771,12 +2771,12 @@ void BKE_gpencil_update_layer_transforms(const Depsgraph *depsgraph, Object *ob)
       Object *ob_parent = DEG_get_evaluated_object(depsgraph, gpl->parent);
       /* calculate new matrix */
       if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) {
-        mul_m4_m4m4(cur_mat, ob->imat, ob_parent->object_to_world);
+        mul_m4_m4m4(cur_mat, ob->world_to_object, ob_parent->object_to_world);
       }
       else if (gpl->partype == PARBONE) {
         bPoseChannel *pchan = BKE_pose_channel_find_name(ob_parent->pose, gpl->parsubstr);
         if (pchan != NULL) {
-          mul_m4_series(cur_mat, ob->imat, ob_parent->object_to_world, pchan->pose_mat);
+          mul_m4_series(cur_mat, ob->world_to_object, ob_parent->object_to_world, pchan->pose_mat);
         }
         else {
           unit_m4(cur_mat);
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index 53e6d47860f..6d1b7caeea6 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -1336,8 +1336,8 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd)
       mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world);
     }
     else {
-      invert_m4_m4(hmd->object->imat, hmd->object->object_to_world);
-      mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->object_to_world);
+      invert_m4_m4(hmd->object->world_to_object, hmd->object->object_to_world);
+      mul_m4_m4m4(hmd->parentinv, hmd->object->world_to_object, ob->object_to_world);
     }
   }
 }
@@ -1361,8 +1361,8 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData
     mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world);
   }
   else {
-    invert_m4_m4(hmd->object->imat, hmd->object->object_to_world);
-    mul_m4_m4m4(hmd->parentinv, hmd->object->imat, ob->object_to_world);
+    invert_m4_m4(hmd->object->world_to_object, hmd->object->object_to_world);
+    mul_m4_m4m4(hmd->parentinv, hmd->object->world_to_object, ob->object_to_world);
   }
 }
 
@@ -4241,7 +4241,7 @@ void *BKE_object_tfm_backup(Object *ob)
   copy_m4_m4(obtfm->obmat, ob->object_to_world);
   copy_m4_m4(obtfm->parentinv, ob->parentinv);
   copy_m4_m4(obtfm->constinv, ob->constinv);
-  copy_m4_m4(obtfm->imat, ob->imat);
+  copy_m4_m4(obtfm->imat, ob->world_to_object);
 
   return (void *)obtfm;
 }
@@ -4264,7 +4264,7 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt)
   copy_m4_m4(ob->object_to_world, obtfm->obmat);
   copy_m4_m4(ob->parentinv, obtfm->parentinv);
   copy_m4_m4(ob->constinv, obtfm->constinv);
-  copy_m4_m4(ob->imat, obtfm->imat);
+  copy_m4_m4(ob->world_to_object, obtfm->imat);
 }
 
 /** \} */
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index d029d307d6e..a41f7c8bce4 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -589,7 +589,7 @@ static DupliObject *vertex_dupli(const DupliContext *ctx,
 
   /* Space matrix is constructed by removing `obmat` transform,
    * this yields the world-space transform for recursive duplis. */
-  mul_m4_m4m4(space_mat, obmat, inst_ob->imat);
+  mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object);
 
   DupliObject *dob = make_dupli(ctx, inst_ob, obmat, index);
 
@@ -609,10 +609,10 @@ static void make_child_duplis_verts_from_mesh(const DupliContext *ctx,
   const MVert *mvert = vdd->mvert;
   const int totvert = vdd->totvert;
 
-  invert_m4_m4(inst_ob->imat, inst_ob->object_to_world);
+  invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world);
   /* Relative transform from parent to child space. */
   float child_imat[4][4];
-  mul_m4_m4m4(child_imat, inst_ob->imat, ctx->object->object_to_world);
+  mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world);
 
   for (int i = 0; i < totvert; i++) {
     DupliObject *dob = vertex_dupli(
@@ -631,10 +631,10 @@ static void make_child_duplis_verts_from_editmesh(const DupliContext *ctx,
   BMEditMesh *em = vdd->em;
   const bool use_rotation = vdd->params.use_rotation;
 
-  invert_m4_m4(inst_ob->imat, inst_ob->object_to_world);
+  invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world);
   /* Relative transform from parent to child space. */
   float child_imat[4][4];
-  mul_m4_m4m4(child_imat, inst_ob->imat, ctx->object->object_to_world);
+  mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world);
 
   BMVert *v;
   BMIter iter;
@@ -920,7 +920,7 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx,
         make_dupli(ctx_for_instance, &object, matrix, id, &geometry_set, i);
 
         float space_matrix[4][4];
-        mul_m4_m4m4(space_matrix, instance_offset_matrices[i].values, object.imat);
+        mul_m4_m4m4(space_matrix, instance_offset_matrices[i].values, object.world_to_object);
         mul_m4_m4_pre(space_matrix, parent_transform);
         make_recursive_duplis(ctx_for_instance, &object, space_matrix, id, &geometry_set, i);
         break;
@@ -1097,7 +1097,7 @@ static DupliObject *face_dupli(const DupliContext *ctx,
 
   /* Spa

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list