From 1c0f374ec3e3200efb07d8c92dfa600540214382 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 14 Feb 2024 16:14:49 +0100 Subject: [PATCH] Object: Move transform matrices to runtime struct The `object_to_world` and `world_to_object` matrices are set during depsgraph evaluation, calculated from the object's animated location, rotation, scale, parenting, and constraints. It's confusing and unnecessary to store them with the original data in DNA. This commit moves them to `ObjectRuntime` and moves the matrices to use the C++ `float4x4` type, giving the potential for simplified code using the C++ abstractions. The matrices are accessible with functions on `Object` directly since they are used so commonly. Though for write access, directly using the runtime struct is necessary. The inverse `world_to_object` matrix is often calculated before it's used, even though it's calculated as part of depsgraph evaluation. Long term we might not want to store this in `ObjectRuntime` at all, and just calculate it on demand. Or at least we should remove the redundant calculations. That should be done separately though. Pull Request: https://projects.blender.org/blender/blender/pulls/118210 --- source/blender/animrig/intern/visualkey.cc | 4 +- source/blender/blenkernel/BKE_object.hh | 2 +- source/blender/blenkernel/BKE_object_types.hh | 3 + source/blender/blenkernel/intern/action.cc | 2 +- source/blender/blenkernel/intern/armature.cc | 10 +- .../blenkernel/intern/armature_deform.cc | 4 +- .../blenkernel/intern/armature_update.cc | 6 +- source/blender/blenkernel/intern/boids.cc | 2 +- source/blender/blenkernel/intern/camera.cc | 22 ++-- source/blender/blenkernel/intern/cloth.cc | 12 +- .../blender/blenkernel/intern/constraint.cc | 86 ++++++++------- .../blender/blenkernel/intern/curve_deform.cc | 4 +- source/blender/blenkernel/intern/curves.cc | 4 +- .../blender/blenkernel/intern/dynamicpaint.cc | 26 ++--- source/blender/blenkernel/intern/effect.cc | 22 ++-- .../blenkernel/intern/fcurve_driver.cc | 16 +-- source/blender/blenkernel/intern/fluid.cc | 28 ++--- .../intern/geometry_set_instances.cc | 2 +- .../blenkernel/intern/gpencil_legacy.cc | 21 ++-- .../blenkernel/intern/grease_pencil.cc | 7 +- source/blender/blenkernel/intern/lattice.cc | 6 +- .../blenkernel/intern/lattice_deform.cc | 6 +- .../blenkernel/intern/mball_tessellate.cc | 13 ++- .../blender/blenkernel/intern/mesh_mirror.cc | 10 +- source/blender/blenkernel/intern/object.cc | 102 +++++++++-------- .../blender/blenkernel/intern/object_dupli.cc | 55 +++++----- .../blenkernel/intern/object_update.cc | 16 +-- source/blender/blenkernel/intern/paint.cc | 2 +- source/blender/blenkernel/intern/particle.cc | 28 ++--- .../blenkernel/intern/particle_child.cc | 6 +- .../blenkernel/intern/particle_system.cc | 34 +++--- source/blender/blenkernel/intern/rigidbody.cc | 18 +-- source/blender/blenkernel/intern/scene.cc | 8 +- source/blender/blenkernel/intern/softbody.cc | 16 +-- source/blender/blenkernel/intern/sound.cc | 11 +- source/blender/blenkernel/intern/vfont.cc | 4 +- source/blender/blenkernel/particle_private.h | 2 +- source/blender/blenlib/BLI_math_matrix.h | 3 +- source/blender/blenlib/BLI_uvproject.h | 4 +- source/blender/blenlib/intern/uvproject.cc | 7 +- .../depsgraph/intern/depsgraph_query_iter.cc | 5 +- .../depsgraph/intern/eval/deg_eval_flush.cc | 2 +- .../draw/engines/basic/basic_engine.cc | 2 +- .../draw/engines/eevee/eevee_lightprobes.cc | 41 +++---- .../draw/engines/eevee/eevee_lights.cc | 4 +- .../draw/engines/eevee/eevee_materials.cc | 2 +- .../draw/engines/eevee/eevee_motion_blur.cc | 4 +- .../draw/engines/eevee/eevee_shadows.cc | 2 +- .../draw/engines/eevee/eevee_volumes.cc | 2 +- .../draw/engines/eevee_next/eevee_instance.cc | 2 +- .../eevee_next/eevee_irradiance_cache.cc | 6 +- .../draw/engines/eevee_next/eevee_light.cc | 2 +- .../engines/eevee_next/eevee_lightprobe.cc | 7 +- .../draw/engines/eevee_next/eevee_pipeline.cc | 6 +- .../draw/engines/eevee_next/eevee_velocity.cc | 9 +- .../engines/gpencil/gpencil_cache_utils.cc | 10 +- .../draw/engines/gpencil/gpencil_draw_data.cc | 8 +- .../draw/engines/gpencil/gpencil_light.hh | 8 +- .../draw/engines/gpencil/gpencil_object.hh | 4 +- .../draw/engines/gpencil/gpencil_shader_fx.cc | 30 ++--- .../draw/engines/gpencil/gpencil_vfx.hh | 4 +- .../draw/engines/overlay/overlay_armature.cc | 54 ++++----- .../draw/engines/overlay/overlay_edit_text.cc | 6 +- .../draw/engines/overlay/overlay_extra.cc | 103 ++++++++++-------- .../engines/overlay/overlay_gpencil_legacy.cc | 6 +- .../draw/engines/overlay/overlay_image.cc | 2 +- .../draw/engines/overlay/overlay_lattice.cc | 2 +- .../draw/engines/overlay/overlay_metaball.cc | 8 +- .../engines/overlay/overlay_motion_path.cc | 7 +- .../engines/overlay/overlay_next_empty.hh | 3 +- .../engines/overlay/overlay_next_instance.cc | 8 +- .../draw/engines/overlay/overlay_outline.cc | 4 +- .../overlay/overlay_viewer_attribute.cc | 5 +- .../engines/overlay/overlay_viewer_text.cc | 2 +- .../draw/engines/overlay/overlay_wireframe.cc | 18 +-- .../draw/engines/select/select_engine.cc | 2 +- .../engines/workbench/workbench_engine.cc | 6 +- .../engines/workbench/workbench_shadow.cc | 2 +- .../engines/workbench/workbench_volume.cc | 4 +- .../intern/draw_cache_impl_gpencil_legacy.cc | 2 +- .../draw/intern/draw_cache_impl_mesh.cc | 8 +- source/blender/draw/intern/draw_curves.cc | 4 +- source/blender/draw/intern/draw_hair.cc | 6 +- source/blender/draw/intern/draw_manager_c.cc | 6 +- .../blender/draw/intern/draw_manager_data.cc | 31 ++++-- .../blender/draw/intern/draw_manager_text.cc | 34 +++--- source/blender/draw/intern/draw_resource.hh | 4 +- source/blender/draw/intern/draw_sculpt.cc | 2 +- source/blender/draw/intern/draw_volume.cc | 4 +- .../editors/animation/anim_motion_paths.cc | 7 +- .../blender/editors/armature/armature_add.cc | 11 +- .../blender/editors/armature/armature_edit.cc | 21 ++-- .../editors/armature/armature_relations.cc | 4 +- .../editors/armature/armature_select.cc | 8 +- .../editors/armature/armature_skinning.cc | 8 +- .../blender/editors/armature/meshlaplacian.cc | 4 +- .../editors/armature/pose_transform.cc | 4 +- source/blender/editors/curve/editcurve.cc | 20 ++-- .../blender/editors/curve/editcurve_paint.cc | 21 ++-- source/blender/editors/curve/editcurve_pen.cc | 10 +- .../blender/editors/curve/editcurve_select.cc | 4 +- source/blender/editors/curve/editfont.cc | 5 +- .../editors/curves/intern/curves_draw.cc | 21 ++-- .../editors/curves/intern/curves_ops.cc | 4 +- .../gpencil_legacy/gpencil_armature.cc | 6 +- .../gpencil_legacy/gpencil_bake_animation.cc | 4 +- .../editors/gpencil_legacy/gpencil_data.cc | 4 +- .../editors/gpencil_legacy/gpencil_edit.cc | 4 +- .../editors/gpencil_legacy/gpencil_mesh.cc | 2 +- .../editors/gpencil_legacy/gpencil_paint.cc | 2 +- .../gpencil_legacy/gpencil_sculpt_paint.cc | 14 +-- .../editors/gpencil_legacy/gpencil_select.cc | 2 +- .../editors/gpencil_legacy/gpencil_utils.cc | 16 +-- .../editors/gpencil_legacy/gpencil_uv.cc | 4 +- .../interface/eyedroppers/eyedropper_depth.cc | 3 +- source/blender/editors/mesh/editface.cc | 4 +- .../editors/mesh/editmesh_add_gizmo.cc | 5 +- source/blender/editors/mesh/editmesh_bevel.cc | 2 +- .../blender/editors/mesh/editmesh_bisect.cc | 4 +- .../blender/editors/mesh/editmesh_extrude.cc | 25 +++-- .../editors/mesh/editmesh_extrude_screw.cc | 8 +- .../editors/mesh/editmesh_extrude_spin.cc | 2 +- .../mesh/editmesh_extrude_spin_gizmo.cc | 2 +- source/blender/editors/mesh/editmesh_inset.cc | 2 +- source/blender/editors/mesh/editmesh_knife.cc | 20 ++-- .../blender/editors/mesh/editmesh_loopcut.cc | 2 +- .../editors/mesh/editmesh_polybuild.cc | 29 ++--- .../editors/mesh/editmesh_preselect_elem.cc | 8 +- .../blender/editors/mesh/editmesh_select.cc | 22 ++-- .../editors/mesh/editmesh_select_similar.cc | 33 +++--- source/blender/editors/mesh/editmesh_tools.cc | 9 +- source/blender/editors/mesh/editmesh_utils.cc | 4 +- source/blender/editors/mesh/meshtools.cc | 6 +- source/blender/editors/object/object_add.cc | 23 ++-- .../blender/editors/object/object_bake_api.cc | 12 +- .../editors/object/object_constraint.cc | 6 +- source/blender/editors/object/object_hook.cc | 24 ++-- .../editors/object/object_relations.cc | 22 ++-- .../blender/editors/object/object_remesh.cc | 15 ++- .../editors/object/object_transform.cc | 52 ++++----- source/blender/editors/object/object_utils.cc | 24 ++-- source/blender/editors/object/object_warp.cc | 2 +- .../blender/editors/physics/particle_edit.cc | 23 ++-- .../editors/physics/particle_object.cc | 16 +-- .../blender/editors/render/render_preview.cc | 2 +- .../sculpt_paint/curves_sculpt_brush.cc | 4 +- .../editors/sculpt_paint/curves_sculpt_ops.cc | 2 +- .../editors/sculpt_paint/paint_cursor.cc | 21 ++-- .../editors/sculpt_paint/paint_image.cc | 2 +- .../editors/sculpt_paint/paint_image_proj.cc | 6 +- .../editors/sculpt_paint/paint_mask.cc | 24 ++-- .../editors/sculpt_paint/paint_stroke.cc | 15 +-- .../editors/sculpt_paint/paint_utils.cc | 6 +- .../editors/sculpt_paint/paint_vertex.cc | 9 +- .../editors/sculpt_paint/paint_weight.cc | 4 +- source/blender/editors/sculpt_paint/sculpt.cc | 42 +++---- .../editors/sculpt_paint/sculpt_cloth.cc | 9 +- .../editors/sculpt_paint/sculpt_detail.cc | 17 +-- .../editors/sculpt_paint/sculpt_face_set.cc | 2 +- .../sculpt_paint/sculpt_filter_mesh.cc | 11 +- .../editors/sculpt_paint/sculpt_ops.cc | 4 +- .../editors/space_view3d/space_view3d.cc | 10 +- .../editors/space_view3d/view3d_buttons.cc | 11 +- .../space_view3d/view3d_camera_control.cc | 4 +- .../editors/space_view3d/view3d_draw.cc | 2 +- .../space_view3d/view3d_gizmo_armature.cc | 3 +- .../space_view3d/view3d_gizmo_camera.cc | 19 ++-- .../space_view3d/view3d_gizmo_empty.cc | 2 +- .../space_view3d/view3d_gizmo_forcefield.cc | 4 +- .../space_view3d/view3d_gizmo_light.cc | 16 +-- .../view3d_gizmo_preselect_type.cc | 7 +- .../editors/space_view3d/view3d_iterators.cc | 15 +-- .../editors/space_view3d/view3d_navigate.cc | 6 +- .../view3d_navigate_smoothview.cc | 4 +- .../space_view3d/view3d_navigate_view_all.cc | 6 +- .../editors/space_view3d/view3d_project.cc | 4 +- .../editors/space_view3d/view3d_select.cc | 9 +- .../editors/space_view3d/view3d_snap.cc | 58 +++++----- .../editors/space_view3d/view3d_utils.cc | 16 +-- .../editors/space_view3d/view3d_view.cc | 6 +- source/blender/editors/transform/transform.hh | 4 +- .../editors/transform/transform_convert.cc | 6 +- .../transform/transform_convert_armature.cc | 4 +- .../transform/transform_convert_curve.cc | 2 +- .../transform/transform_convert_curves.cc | 2 +- .../transform/transform_convert_lattice.cc | 2 +- .../transform/transform_convert_mball.cc | 2 +- .../transform/transform_convert_mesh.cc | 2 +- .../transform/transform_convert_mesh_edge.cc | 2 +- .../transform/transform_convert_mesh_skin.cc | 2 +- .../transform_convert_mesh_vert_cdata.cc | 2 +- .../transform/transform_convert_object.cc | 14 +-- .../transform_convert_object_texspace.cc | 4 +- .../transform/transform_convert_particle.cc | 3 +- .../transform/transform_convert_sculpt.cc | 12 +- .../editors/transform/transform_generics.cc | 6 +- .../editors/transform/transform_gizmo_3d.cc | 46 ++++---- .../editors/transform/transform_mode.cc | 2 +- .../transform/transform_mode_edge_slide.cc | 2 +- .../transform/transform_mode_vert_slide.cc | 14 ++- .../transform/transform_orientations.cc | 29 ++--- .../editors/transform/transform_snap.cc | 4 +- .../transform/transform_snap_object.cc | 9 +- .../blender/editors/uvedit/uvedit_select.cc | 16 +-- .../editors/uvedit/uvedit_unwrap_ops.cc | 17 +-- .../blender_interface/BlenderFileLoader.cpp | 2 +- .../geometry/intern/realize_instances.cc | 3 +- .../intern/MOD_gpencil_legacy_array.cc | 4 +- .../intern/MOD_gpencil_legacy_build.cc | 4 +- .../intern/MOD_gpencil_legacy_hook.cc | 9 +- .../intern/MOD_gpencil_legacy_mirror.cc | 4 +- .../intern/MOD_gpencil_legacy_multiply.cc | 2 +- .../intern/MOD_gpencil_legacy_outline.cc | 6 +- .../intern/MOD_gpencil_legacy_tint.cc | 2 +- .../intern/MOD_gpencil_legacy_weight_angle.cc | 6 +- .../MOD_gpencil_legacy_weight_proximity.cc | 4 +- .../intern/lineart/lineart_cpu.cc | 16 +-- .../intern/lineart/lineart_shadow.cc | 2 +- .../ikplugin/intern/iksolver_plugin.cc | 4 +- .../blender/ikplugin/intern/itasc_plugin.cc | 16 +-- .../io/alembic/exporter/abc_writer_hair.cc | 4 +- .../io/alembic/exporter/abc_writer_points.cc | 2 +- .../io/alembic/intern/abc_axis_conversion.cc | 11 +- .../io/alembic/intern/abc_reader_object.cc | 3 +- .../blender/io/collada/AnimationImporter.cpp | 6 +- .../blender/io/collada/ArmatureImporter.cpp | 4 +- .../blender/io/collada/ControllerExporter.cpp | 4 +- .../blender/io/collada/DocumentImporter.cpp | 4 +- source/blender/io/collada/SkinInfo.cpp | 4 +- source/blender/io/collada/collada_utils.cpp | 12 +- .../intern/abstract_hierarchy_iterator.cc | 2 +- .../io/gpencil/intern/gpencil_io_base.cc | 4 +- .../gpencil/intern/gpencil_io_export_pdf.cc | 2 +- .../gpencil/intern/gpencil_io_export_svg.cc | 2 +- .../ply/exporter/ply_export_load_plydata.cc | 6 +- source/blender/io/stl/exporter/stl_export.cc | 6 +- source/blender/io/usd/hydra/curves.cc | 6 +- source/blender/io/usd/hydra/object.cc | 2 +- .../blender/io/usd/hydra/volume_modifier.cc | 2 +- .../wavefront_obj/exporter/obj_export_mesh.cc | 2 +- .../exporter/obj_export_nurbs.cc | 7 +- source/blender/makesdna/DNA_object_defaults.h | 1 - source/blender/makesdna/DNA_object_types.h | 12 +- .../blender/makesdna/intern/dna_rename_defs.h | 2 - .../blender/makesrna/intern/rna_depsgraph.cc | 2 +- .../makesrna/intern/rna_gpencil_legacy.cc | 8 +- source/blender/makesrna/intern/rna_object.cc | 17 ++- .../blender/makesrna/intern/rna_particle.cc | 2 +- source/blender/modifiers/intern/MOD_array.cc | 6 +- .../blender/modifiers/intern/MOD_boolean.cc | 35 +++--- source/blender/modifiers/intern/MOD_cast.cc | 17 +-- .../blender/modifiers/intern/MOD_collision.cc | 4 +- .../blender/modifiers/intern/MOD_displace.cc | 2 +- .../blender/modifiers/intern/MOD_explode.cc | 4 +- .../intern/MOD_grease_pencil_mirror.cc | 3 +- .../intern/MOD_grease_pencil_tint.cc | 6 +- source/blender/modifiers/intern/MOD_hook.cc | 9 +- .../modifiers/intern/MOD_mesh_to_volume.cc | 4 +- .../modifiers/intern/MOD_meshdeform.cc | 4 +- .../modifiers/intern/MOD_normal_edit.cc | 8 +- .../modifiers/intern/MOD_particleinstance.cc | 2 +- source/blender/modifiers/intern/MOD_screw.cc | 4 +- .../blender/modifiers/intern/MOD_surface.cc | 2 +- .../modifiers/intern/MOD_surfacedeform.cc | 4 +- source/blender/modifiers/intern/MOD_util.cc | 10 +- .../blender/modifiers/intern/MOD_uvproject.cc | 6 +- source/blender/modifiers/intern/MOD_uvwarp.cc | 4 +- .../modifiers/intern/MOD_volume_displace.cc | 8 +- .../modifiers/intern/MOD_volume_to_mesh.cc | 4 +- source/blender/modifiers/intern/MOD_warp.cc | 6 +- source/blender/modifiers/intern/MOD_wave.cc | 4 +- .../modifiers/intern/MOD_weightvgproximity.cc | 6 +- .../nodes/node_geo_collection_info.cc | 8 +- .../geometry/nodes/node_geo_object_info.cc | 4 +- .../geometry/nodes/node_geo_tool_3d_cursor.cc | 4 +- .../shader/nodes/node_shader_tex_coord.cc | 2 +- source/blender/render/RE_bake.h | 6 +- source/blender/render/hydra/camera.cc | 2 +- .../blender/render/hydra/viewport_engine.cc | 2 +- source/blender/render/intern/bake.cc | 8 +- .../render/intern/texture_pointdensity.cc | 10 +- .../windowmanager/xr/intern/wm_xr_session.cc | 2 +- 282 files changed, 1450 insertions(+), 1329 deletions(-) diff --git a/source/blender/animrig/intern/visualkey.cc b/source/blender/animrig/intern/visualkey.cc index a0b1dddf42e..ff7595f6994 100644 --- a/source/blender/animrig/intern/visualkey.cc +++ b/source/blender/animrig/intern/visualkey.cc @@ -211,11 +211,11 @@ Vector visualkey_get_values(PointerRNA *ptr, PropertyRNA *prop) Object *ob = static_cast(ptr->data); /* Loc code is specific... */ if (strstr(identifier, "location")) { - values.extend({ob->object_to_world[3], 3}); + values.extend({ob->object_to_world().location(), 3}); return values; } - copy_m4_m4(tmat, ob->object_to_world); + copy_m4_m4(tmat, ob->object_to_world().ptr()); rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { diff --git a/source/blender/blenkernel/BKE_object.hh b/source/blender/blenkernel/BKE_object.hh index 3c2e219030b..d9200ec24c1 100644 --- a/source/blender/blenkernel/BKE_object.hh +++ b/source/blender/blenkernel/BKE_object.hh @@ -319,7 +319,7 @@ blender::Vector BKE_object_pose_base_array_get(const Scene *scene, void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][4]); /** - * Compute object world transform and store it in `ob->object_to_world`. + * Compute object world transform and store it in `ob->object_to_world().ptr()`. */ void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob); void BKE_object_where_is_calc_ex( diff --git a/source/blender/blenkernel/BKE_object_types.hh b/source/blender/blenkernel/BKE_object_types.hh index fcfbedb4284..0d15d82a02d 100644 --- a/source/blender/blenkernel/BKE_object_types.hh +++ b/source/blender/blenkernel/BKE_object_types.hh @@ -26,6 +26,9 @@ namespace blender::bke { struct GeometrySet; struct ObjectRuntime { + /** Final transformation matrices with constraints & animsys applied. */ + float4x4 object_to_world; + float4x4 world_to_object; /** * The custom data layer mask that was last used * to calculate data_eval and mesh_deform_eval. diff --git a/source/blender/blenkernel/intern/action.cc b/source/blender/blenkernel/intern/action.cc index 111609fb4e1..1f31442af92 100644 --- a/source/blender/blenkernel/intern/action.cc +++ b/source/blender/blenkernel/intern/action.cc @@ -1711,7 +1711,7 @@ void what_does_obaction(Object *ob, workob->runtime = &workob_runtime; /* init workob */ - copy_m4_m4(workob->object_to_world, ob->object_to_world); + copy_m4_m4(workob->runtime->object_to_world.ptr(), ob->object_to_world().ptr()); copy_m4_m4(workob->parentinv, ob->parentinv); copy_m4_m4(workob->constinv, ob->constinv); workob->parent = ob->parent; diff --git a/source/blender/blenkernel/intern/armature.cc b/source/blender/blenkernel/intern/armature.cc index 24302fa9cb4..f112da2d17b 100644 --- a/source/blender/blenkernel/intern/armature.cc +++ b/source/blender/blenkernel/intern/armature.cc @@ -1992,7 +1992,7 @@ void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float o } /* Get inverse of (armature) object's matrix. */ - invert_m4_m4(obmat, ob->object_to_world); + invert_m4_m4(obmat, ob->object_to_world().ptr()); /* multiply given matrix by object's-inverse to find pose-space matrix */ mul_m4_m4m4(outmat, inmat, obmat); @@ -2967,7 +2967,7 @@ void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob) } } else { - invert_m4_m4(ob->world_to_object, ob->object_to_world); /* world_to_object is needed */ + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); /* 1. clear flags */ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { @@ -3068,16 +3068,16 @@ void BKE_pchan_minmax(const Object *ob, pchan->custom_translation[0], pchan->custom_translation[1], pchan->custom_translation[2]); - mul_m4_series(mat, ob->object_to_world, tmp, rmat, smat); + mul_m4_series(mat, ob->object_to_world().ptr(), tmp, rmat, smat); BoundBox bb; BKE_boundbox_init_from_minmax(&bb, bb_custom->min, bb_custom->max); BKE_boundbox_minmax(&bb, mat, r_min, r_max); } else { float vec[3]; - mul_v3_m4v3(vec, ob->object_to_world, pchan_tx->pose_head); + mul_v3_m4v3(vec, ob->object_to_world().ptr(), pchan_tx->pose_head); minmax_v3v3_v3(r_min, r_max, vec); - mul_v3_m4v3(vec, ob->object_to_world, pchan_tx->pose_tail); + mul_v3_m4v3(vec, ob->object_to_world().ptr(), pchan_tx->pose_tail); minmax_v3v3_v3(r_min, r_max, vec); } } diff --git a/source/blender/blenkernel/intern/armature_deform.cc b/source/blender/blenkernel/intern/armature_deform.cc index 1ec7101abb1..99b21353c70 100644 --- a/source/blender/blenkernel/intern/armature_deform.cc +++ b/source/blender/blenkernel/intern/armature_deform.cc @@ -600,9 +600,9 @@ static void armature_deform_coords_impl(const Object *ob_arm, data.bmesh.cd_dvert_offset = cd_dvert_offset; float obinv[4][4]; - invert_m4_m4(obinv, ob_target->object_to_world); + invert_m4_m4(obinv, ob_target->object_to_world().ptr()); - mul_m4_m4m4(data.postmat, obinv, ob_arm->object_to_world); + mul_m4_m4m4(data.postmat, obinv, ob_arm->object_to_world().ptr()); invert_m4_m4(data.premat, data.postmat); if (em_target != nullptr) { diff --git a/source/blender/blenkernel/intern/armature_update.cc b/source/blender/blenkernel/intern/armature_update.cc index 0bcbb5cf0a0..957121ee0cc 100644 --- a/source/blender/blenkernel/intern/armature_update.cc +++ b/source/blender/blenkernel/intern/armature_update.cc @@ -254,11 +254,11 @@ static void apply_curve_transform( * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root). */ if ((ik_data->flag & CONSTRAINT_SPLINEIK_NO_ROOT) == 0) { - mul_m4_v3(ik_data->tar->object_to_world, r_vec); + mul_m4_v3(ik_data->tar->object_to_world().ptr(), r_vec); } /* Convert the position to pose-space. */ - mul_m4_v3(ob->world_to_object, r_vec); + mul_m4_v3(ob->world_to_object().ptr(), r_vec); /* Set the new radius (it should be the average value). */ *r_radius = (radius + *r_radius) / 2; @@ -829,7 +829,7 @@ void BKE_pose_eval_init(Depsgraph *depsgraph, Scene * /*scene*/, Object *object) BLI_assert((object->pose->flag & POSE_RECALC) == 0); /* world_to_object is needed for solvers. */ - invert_m4_m4(object->world_to_object, object->object_to_world); + invert_m4_m4(object->runtime->world_to_object.ptr(), object->object_to_world().ptr()); /* clear flags */ for (bPoseChannel *pchan = static_cast(pose->chanbase.first); pchan != nullptr; diff --git a/source/blender/blenkernel/intern/boids.cc b/source/blender/blenkernel/intern/boids.cc index 85e8f6644ae..55395a6bb47 100644 --- a/source/blender/blenkernel/intern/boids.cc +++ b/source/blender/blenkernel/intern/boids.cc @@ -962,7 +962,7 @@ void boids_precalc_rules(ParticleSettings *part, float cfra) if (flbr->ob && flbr->cfra != cfra) { /* save object locations for velocity calculations */ copy_v3_v3(flbr->oloc, flbr->loc); - copy_v3_v3(flbr->loc, flbr->ob->object_to_world[3]); + copy_v3_v3(flbr->loc, flbr->ob->object_to_world().location()); flbr->cfra = cfra; } } diff --git a/source/blender/blenkernel/intern/camera.cc b/source/blender/blenkernel/intern/camera.cc index 2e00993a7d0..8c1d3b229d1 100644 --- a/source/blender/blenkernel/intern/camera.cc +++ b/source/blender/blenkernel/intern/camera.cc @@ -278,16 +278,18 @@ float BKE_camera_object_dof_distance(const Object *ob) } if (cam->dof.focus_object) { float view_dir[3], dof_dir[3]; - normalize_v3_v3(view_dir, ob->object_to_world[2]); + normalize_v3_v3(view_dir, ob->object_to_world().ptr()[2]); bPoseChannel *pchan = BKE_pose_channel_find_name(cam->dof.focus_object->pose, cam->dof.focus_subtarget); if (pchan) { float posemat[4][4]; - mul_m4_m4m4(posemat, cam->dof.focus_object->object_to_world, pchan->pose_mat); - sub_v3_v3v3(dof_dir, ob->object_to_world[3], posemat[3]); + mul_m4_m4m4(posemat, cam->dof.focus_object->object_to_world().ptr(), pchan->pose_mat); + sub_v3_v3v3(dof_dir, ob->object_to_world().location(), posemat[3]); } else { - sub_v3_v3v3(dof_dir, ob->object_to_world[3], cam->dof.focus_object->object_to_world[3]); + sub_v3_v3v3(dof_dir, + ob->object_to_world().location(), + cam->dof.focus_object->object_to_world().location()); } return fabsf(dot_v3v3(view_dir, dof_dir)); } @@ -682,7 +684,7 @@ static void camera_frame_fit_data_init(const Scene *scene, BKE_camera_params_compute_matrix(params); /* initialize callback data */ - copy_m3_m4(data->camera_rotmat, (float(*)[4])ob->object_to_world); + copy_m3_m4(data->camera_rotmat, (float(*)[4])ob->object_to_world().ptr()); normalize_m3(data->camera_rotmat); /* To transform a plane which is in its homogeneous representation (4d vector), * we need the inverse of the transpose of the transform matrix... */ @@ -884,7 +886,7 @@ bool BKE_camera_view_frame_fit_to_coords(const Depsgraph *depsgraph, static void camera_model_matrix(const Object *camera, float r_modelmat[4][4]) { - copy_m4_m4(r_modelmat, camera->object_to_world); + copy_m4_m4(r_modelmat, camera->object_to_world().ptr()); } static void camera_stereo3d_model_matrix(const Object *camera, @@ -910,7 +912,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, } float size[3]; - mat4_to_size(size, camera->object_to_world); + mat4_to_size(size, camera->object_to_world().ptr()); size_to_mat4(sizemat, size); if (pivot == CAM_S3D_PIVOT_CENTER) { @@ -950,7 +952,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, toeinmat[3][0] = interocular_distance * fac_signed; /* transform */ - normalize_m4_m4(r_modelmat, camera->object_to_world); + normalize_m4_m4(r_modelmat, camera->object_to_world().ptr()); mul_m4_m4m4(r_modelmat, r_modelmat, toeinmat); /* scale back to the original size */ @@ -958,7 +960,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, } else { /* CAM_S3D_PIVOT_LEFT, CAM_S3D_PIVOT_RIGHT */ /* rotate perpendicular to the interocular line */ - normalize_m4_m4(r_modelmat, camera->object_to_world); + normalize_m4_m4(r_modelmat, camera->object_to_world().ptr()); mul_m4_m4m4(r_modelmat, r_modelmat, rotmat); /* translate along the interocular line */ @@ -974,7 +976,7 @@ static void camera_stereo3d_model_matrix(const Object *camera, } } else { - normalize_m4_m4(r_modelmat, camera->object_to_world); + normalize_m4_m4(r_modelmat, camera->object_to_world().ptr()); /* translate - no rotation in CAM_S3D_OFFAXIS, CAM_S3D_PARALLEL */ translate_m4(r_modelmat, -interocular_distance * fac_signed, 0.0f, 0.0f); diff --git a/source/blender/blenkernel/intern/cloth.cc b/source/blender/blenkernel/intern/cloth.cc index 04c385c3b3f..58d6ec3226d 100644 --- a/source/blender/blenkernel/intern/cloth.cc +++ b/source/blender/blenkernel/intern/cloth.cc @@ -272,7 +272,7 @@ static int do_step_cloth( /* Get the current position. */ copy_v3_v3(verts->xconst, positions[i]); - mul_m4_v3(ob->object_to_world, verts->xconst); + mul_m4_v3(ob->object_to_world().ptr(), verts->xconst); if (vert_mass_changed) { verts->mass = clmd->sim_parms->mass; @@ -575,11 +575,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->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); for (i = 0; i < cloth->mvert_num; i++) { copy_v3_v3(vertexCos[i], cloth->verts[i].x); - mul_m4_v3(ob->world_to_object, vertexCos[i]); /* cloth is in global coords */ + mul_m4_v3(ob->world_to_object().ptr(), vertexCos[i]); /* cloth is in global coords */ } } } @@ -759,11 +759,11 @@ static bool cloth_from_object( if (first) { copy_v3_v3(verts->x, positions[i]); - mul_m4_v3(ob->object_to_world, verts->x); + mul_m4_v3(ob->object_to_world().ptr(), verts->x); if (shapekey_rest) { copy_v3_v3(verts->xrest, shapekey_rest[i]); - mul_m4_v3(ob->object_to_world, verts->xrest); + mul_m4_v3(ob->object_to_world().ptr(), verts->xrest); } else { copy_v3_v3(verts->xrest, verts->x); @@ -1153,7 +1153,7 @@ static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh) /* vertex count is already ensured to match */ for (i = 0; i < mesh->verts_num; i++, verts++) { copy_v3_v3(verts->xrest, positions[i]); - mul_m4_v3(ob->object_to_world, verts->xrest); + mul_m4_v3(ob->object_to_world().ptr(), verts->xrest); } } diff --git a/source/blender/blenkernel/intern/constraint.cc b/source/blender/blenkernel/intern/constraint.cc index 0bc4d66ae6a..d64d22b5555 100644 --- a/source/blender/blenkernel/intern/constraint.cc +++ b/source/blender/blenkernel/intern/constraint.cc @@ -155,7 +155,7 @@ bConstraintOb *BKE_constraints_make_evalob( /* Quaternion/Axis-Angle, so Eulers should just use default order. */ cob->rotOrder = EULER_ORDER_DEFAULT; } - copy_m4_m4(cob->matrix, ob->object_to_world); + copy_m4_m4(cob->matrix, ob->object_to_world().ptr()); } else { unit_m4(cob->matrix); @@ -181,7 +181,7 @@ bConstraintOb *BKE_constraints_make_evalob( } /* matrix in world-space */ - mul_m4_m4m4(cob->matrix, ob->object_to_world, cob->pchan->pose_mat); + mul_m4_m4m4(cob->matrix, ob->object_to_world().ptr(), cob->pchan->pose_mat); } else { unit_m4(cob->matrix); @@ -222,7 +222,7 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob) /* cob->ob might not exist! */ if (cob->ob) { /* copy new ob-matrix back to owner */ - copy_m4_m4(cob->ob->object_to_world, cob->matrix); + copy_m4_m4(cob->ob->runtime->object_to_world.ptr(), cob->matrix); /* copy inverse of delta back to owner */ invert_m4_m4(cob->ob->constinv, delta); @@ -233,7 +233,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->world_to_object, cob->matrix); + mul_m4_m4m4(cob->pchan->pose_mat, cob->ob->world_to_object().ptr(), cob->matrix); /* copy inverse of delta back to owner */ invert_m4_m4(cob->pchan->constinv, delta); @@ -282,7 +282,7 @@ void BKE_constraint_mat_convertspace(Object *ob, } else { /* World to pose. */ - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); mul_m4_m4m4(mat, imat, mat); /* Use pose-space as stepping stone for other spaces. */ @@ -326,7 +326,7 @@ void BKE_constraint_mat_convertspace(Object *ob, } else { /* Pose to world. */ - mul_m4_m4m4(mat, ob->object_to_world, mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); /* Use world-space as stepping stone for other spaces. */ if (to != CONSTRAINT_SPACE_WORLD) { /* Call self with slightly different values. */ @@ -436,7 +436,7 @@ void BKE_constraint_mat_convertspace(Object *ob, /* Check if object has a parent. */ if (ob->parent) { /* 'subtract' parent's effects from owner. */ - mul_m4_m4m4(diff_mat, ob->parent->object_to_world, ob->parentinv); + mul_m4_m4m4(diff_mat, ob->parent->object_to_world().ptr(), ob->parentinv); invert_m4_m4_safe(imat, diff_mat); mul_m4_m4m4(mat, imat, mat); } @@ -472,7 +472,7 @@ void BKE_constraint_mat_convertspace(Object *ob, /* check that object has a parent - otherwise this won't work */ if (ob->parent) { /* 'add' parent's effect back to owner */ - mul_m4_m4m4(diff_mat, ob->parent->object_to_world, ob->parentinv); + mul_m4_m4m4(diff_mat, ob->parent->object_to_world().ptr(), ob->parentinv); mul_m4_m4m4(mat, diff_mat, mat); } else { @@ -525,7 +525,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ const int defgroup = BKE_object_defgroup_name_index(ob, substring); /* initialize target matrix using target matrix */ - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); /* get index of vertex group */ if (defgroup == -1) { @@ -591,7 +591,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ * calc_gizmo_stats, V3D_ORIENT_NORMAL case */ /* We need the transpose of the inverse for a normal. */ - copy_m3_m4(imat, ob->object_to_world); + copy_m3_m4(imat, ob->object_to_world().ptr()); invert_m3_m3(tmat, imat); transpose_m3(tmat); @@ -612,7 +612,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ normalize_m4(mat); /* apply the average coordinate as the new location */ - mul_v3_m4v3(mat[3], ob->object_to_world, vec); + mul_v3_m4v3(mat[3], ob->object_to_world().ptr(), vec); } /* function that sets the given matrix based on given vertex group in lattice */ @@ -634,7 +634,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m const int defgroup = BKE_object_defgroup_name_index(ob, substring); /* initialize target matrix using target matrix */ - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); /* get index of vertex group */ if (defgroup == -1) { @@ -668,11 +668,12 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m } } - /* find average location, then multiply by ob->object_to_world to find world-space location */ + /* find average location, then multiply by ob->object_to_world().ptr() to find world-space + * location */ if (grouped) { mul_v3_fl(vec, 1.0f / grouped); } - mul_v3_m4v3(tvec, ob->object_to_world, vec); + mul_v3_m4v3(tvec, ob->object_to_world().ptr(), vec); /* copy new location to matrix */ copy_v3_v3(mat[3], tvec); @@ -691,7 +692,7 @@ static void constraint_target_to_mat4(Object *ob, { /* Case OBJECT */ if (substring[0] == '\0') { - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); BKE_constraint_mat_convertspace(ob, nullptr, cob, mat, from, to, false); } /* Case VERTEXGROUP */ @@ -726,7 +727,7 @@ static void constraint_target_to_mat4(Object *ob, if (headtail < 0.000001f && !(is_bbone && full_bbone)) { /* skip length interpolation if set to head */ - mul_m4_m4m4(mat, ob->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), pchan->pose_mat); } else if (is_bbone && pchan->bone->segments == pchan->runtime.bbone_segments) { /* use point along bbone */ @@ -752,7 +753,7 @@ static void constraint_target_to_mat4(Object *ob, mul_v3_m4v3(tempmat[3], pchan->pose_mat, loc); } - mul_m4_m4m4(mat, ob->object_to_world, tempmat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), tempmat); } else { float tempmat[4][4], loc[3]; @@ -764,11 +765,11 @@ static void constraint_target_to_mat4(Object *ob, copy_m4_m4(tempmat, pchan->pose_mat); copy_v3_v3(tempmat[3], loc); - mul_m4_m4m4(mat, ob->object_to_world, tempmat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), tempmat); } } else { - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); } /* convert matrix space as required */ @@ -1078,7 +1079,7 @@ static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar if (data->flag & CHILDOF_SET_INVERSE) { invert_m4_m4(data->invmat, parmat); if (cob->pchan != nullptr) { - mul_m4_series(data->invmat, data->invmat, cob->ob->object_to_world); + mul_m4_series(data->invmat, data->invmat, cob->ob->object_to_world().ptr()); } copy_m4_m4(inverse_matrix, data->invmat); @@ -1398,8 +1399,8 @@ static void kinematic_get_tarmat(Depsgraph * /*depsgraph*/, else { float vec[3]; /* move grabtarget into world space */ - mul_v3_m4v3(vec, ob->object_to_world, data->grabtarget); - copy_m4_m4(ct->matrix, ob->object_to_world); + mul_v3_m4v3(vec, ob->object_to_world().ptr(), data->grabtarget); + copy_m4_m4(ct->matrix, ob->object_to_world().ptr()); copy_v3_v3(ct->matrix[3], vec); } } @@ -1539,7 +1540,7 @@ static void followpath_get_tarmat(Depsgraph * /*depsgraph*/, copy_v3_v3(totmat[3], vec); - mul_m4_m4m4(ct->matrix, ct->tar->object_to_world, totmat); + mul_m4_m4m4(ct->matrix, ct->tar->object_to_world().ptr(), totmat); } } } @@ -2569,7 +2570,7 @@ static void armdef_get_tarmat(Depsgraph * /*depsgraph*/, bPoseChannel *pchan = BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); if (pchan != nullptr) { - mul_m4_m4m4(ct->matrix, ct->tar->object_to_world, pchan->pose_mat); + mul_m4_m4m4(ct->matrix, ct->tar->object_to_world().ptr(), pchan->pose_mat); return; } } @@ -2626,7 +2627,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, float weight = ct->weight; /* Our object's location in target pose space. */ - invert_m4_m4(iobmat, ct->tar->object_to_world); + invert_m4_m4(iobmat, ct->tar->object_to_world().ptr()); mul_v3_m4v3(co, iobmat, wco); /* Multiply by the envelope weight when appropriate. */ @@ -2651,7 +2652,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, mul_m4_m4m4(basemat, bone->arm_mat, b_bone_rest_mats[index].mat); } - armdef_accumulate_matrix(ct->tar->object_to_world, + armdef_accumulate_matrix(ct->tar->object_to_world().ptr(), iobmat, basemat, b_bone_mats[index + 1].mat, @@ -2665,7 +2666,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, mul_m4_m4m4(basemat, bone->arm_mat, b_bone_rest_mats[index + 1].mat); } - armdef_accumulate_matrix(ct->tar->object_to_world, + armdef_accumulate_matrix(ct->tar->object_to_world().ptr(), iobmat, basemat, b_bone_mats[index + 2].mat, @@ -2676,7 +2677,7 @@ static void armdef_accumulate_bone(const bConstraintTarget *ct, } else { /* Simple bone. This requires DEG_OPCODE_BONE_DONE dependency due to chan_mat. */ - armdef_accumulate_matrix(ct->tar->object_to_world, + armdef_accumulate_matrix(ct->tar->object_to_world().ptr(), iobmat, bone->arm_mat, pchan->chan_mat, @@ -2709,7 +2710,7 @@ static void armdef_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ /* For constraints on bones, use the rest position to bind b-bone segments * and envelopes, to allow safely changing the bone location as if parented. */ copy_v3_v3(input_co, cob->pchan->bone->arm_head); - mul_m4_v3(cob->ob->object_to_world, input_co); + mul_m4_v3(cob->ob->object_to_world().ptr(), input_co); } else { copy_v3_v3(input_co, cob->matrix[3]); @@ -3941,7 +3942,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar unit_m4(totmat); copy_v3_v3(totmat[3], vec); - mul_m4_m4m4(targetMatrix, ct->tar->object_to_world, totmat); + mul_m4_m4m4(targetMatrix, ct->tar->object_to_world().ptr(), totmat); } } @@ -4242,7 +4243,7 @@ static void shrinkwrap_get_tarmat(Depsgraph * /*depsgraph*/, if (BKE_shrinkwrap_init_tree( &tree, target_eval, scon->shrinkType, scon->shrinkMode, do_track_normal)) { - BLI_space_transform_from_matrices(&transform, cob->matrix, ct->tar->object_to_world); + BLI_space_transform_from_matrices(&transform, cob->matrix, ct->tar->object_to_world().ptr()); switch (scon->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: @@ -4916,7 +4917,7 @@ static void followtrack_evaluate_using_3d_position_object(FollowTrackContext *co /* Object matrix of the camera. */ float camera_obmat[4][4]; - copy_m4_m4(camera_obmat, camera_object->object_to_world); + copy_m4_m4(camera_obmat, camera_object->object_to_world().ptr()); /* Calculate inverted matrix of the solved camera at the current time. */ float reconstructed_camera_mat[4][4]; @@ -5068,10 +5069,11 @@ static void followtrack_project_to_depth_object_if_needed(FollowTrackContext *co } float depth_object_mat_inv[4][4]; - invert_m4_m4(depth_object_mat_inv, depth_object->object_to_world); + invert_m4_m4(depth_object_mat_inv, depth_object->object_to_world().ptr()); float ray_start[3], ray_end[3]; - mul_v3_m4v3(ray_start, depth_object_mat_inv, context->camera_object->object_to_world[3]); + mul_v3_m4v3( + ray_start, depth_object_mat_inv, context->camera_object->object_to_world().location()); mul_v3_m4v3(ray_end, depth_object_mat_inv, cob->matrix[3]); float ray_direction[3]; @@ -5094,7 +5096,7 @@ static void followtrack_project_to_depth_object_if_needed(FollowTrackContext *co &tree_data); if (result != -1) { - mul_v3_m4v3(cob->matrix[3], depth_object->object_to_world, hit.co); + mul_v3_m4v3(cob->matrix[3], depth_object->object_to_world().ptr(), hit.co); } free_bvhtree_from_mesh(&tree_data); @@ -5142,9 +5144,9 @@ static void followtrack_evaluate_using_2d_position(FollowTrackContext *context, } float disp[3]; - mul_v3_m4v3(disp, camera_object->object_to_world, vec); + mul_v3_m4v3(disp, camera_object->object_to_world().ptr(), vec); - copy_m4_m4(rmat, camera_object->object_to_world); + copy_m4_m4(rmat, camera_object->object_to_world().ptr()); zero_v3(rmat[3]); mul_m4_m4m4(cob->matrix, cob->matrix, rmat); @@ -5166,10 +5168,10 @@ static void followtrack_evaluate_using_2d_position(FollowTrackContext *context, } float disp[3]; - mul_v3_m4v3(disp, camera_object->object_to_world, vec); + mul_v3_m4v3(disp, camera_object->object_to_world().ptr(), vec); /* apply camera rotation so Z-axis would be co-linear */ - copy_m4_m4(rmat, camera_object->object_to_world); + copy_m4_m4(rmat, camera_object->object_to_world().ptr()); zero_v3(rmat[3]); mul_m4_m4m4(cob->matrix, cob->matrix, rmat); @@ -5315,7 +5317,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase BKE_tracking_camera_get_reconstructed_interpolate(tracking, tracking_object, framenr, mat); invert_m4_m4(imat, mat); - mul_m4_m4m4(parmat, camob->object_to_world, imat); + mul_m4_m4m4(parmat, camob->object_to_world().ptr(), imat); copy_m4_m4(obmat, cob->matrix); @@ -5668,7 +5670,7 @@ bool BKE_constraint_apply_for_object(Depsgraph *depsgraph, BLI_freelinkN(&single_con, new_con); /* Apply transform from matrix. */ - BKE_object_apply_mat4(ob, ob_eval->object_to_world, true, true); + BKE_object_apply_mat4(ob, ob_eval->object_to_world().ptr(), true, true); return true; } @@ -6261,7 +6263,7 @@ void BKE_constraint_target_matrix_get(Depsgraph *depsgraph, cob->ob = (Object *)ownerdata; cob->pchan = nullptr; if (cob->ob) { - copy_m4_m4(cob->matrix, cob->ob->object_to_world); + copy_m4_m4(cob->matrix, cob->ob->object_to_world().ptr()); copy_m4_m4(cob->startmat, cob->matrix); } else { diff --git a/source/blender/blenkernel/intern/curve_deform.cc b/source/blender/blenkernel/intern/curve_deform.cc index f1c8cc2aa20..2dc44376258 100644 --- a/source/blender/blenkernel/intern/curve_deform.cc +++ b/source/blender/blenkernel/intern/curve_deform.cc @@ -47,8 +47,8 @@ struct CurveDeform { static void init_curve_deform(const Object *ob_curve, const Object *ob_target, CurveDeform *cd) { float imat[4][4]; - invert_m4_m4(imat, ob_target->object_to_world); - mul_m4_m4m4(cd->objectspace, imat, ob_curve->object_to_world); + invert_m4_m4(imat, ob_target->object_to_world().ptr()); + mul_m4_m4m4(cd->objectspace, imat, ob_curve->object_to_world().ptr()); invert_m4_m4(cd->curvespace, cd->objectspace); copy_m3_m4(cd->objectspace3, cd->objectspace); cd->no_rot_axis = 0; diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 47cf2784c8c..13ca30045dd 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -312,11 +312,11 @@ void curves_copy_parameters(const Curves &src, Curves &dst) CurvesSurfaceTransforms::CurvesSurfaceTransforms(const Object &curves_ob, const Object *surface_ob) { - this->curves_to_world = float4x4_view(curves_ob.object_to_world); + this->curves_to_world = curves_ob.object_to_world(); this->world_to_curves = math::invert(this->curves_to_world); if (surface_ob != nullptr) { - this->surface_to_world = float4x4_view(surface_ob->object_to_world); + this->surface_to_world = surface_ob->object_to_world(); this->world_to_surface = math::invert(this->surface_to_world); this->surface_to_curves = this->world_to_curves * this->surface_to_world; this->curves_to_surface = this->world_to_surface * this->curves_to_world; diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc b/source/blender/blenkernel/intern/dynamicpaint.cc index fea023a29e6..d4d1ec0c472 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.cc +++ b/source/blender/blenkernel/intern/dynamicpaint.cc @@ -3760,7 +3760,7 @@ struct DynamicPaintBrushVelocityData { const float (*positions_p)[3]; const float (*positions_c)[3]; - float (*obmat)[4]; + const float (*obmat)[4]; float (*prev_obmat)[4]; float timescale; @@ -3778,7 +3778,7 @@ static void dynamic_paint_brush_velocity_compute_cb(void *__restrict userdata, const float(*positions_p)[3] = data->positions_p; const float(*positions_c)[3] = data->positions_c; - float(*obmat)[4] = data->obmat; + const float(*obmat)[4] = data->obmat; float(*prev_obmat)[4] = data->prev_obmat; const float timescale = data->timescale; @@ -3832,7 +3832,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph, float(*positions_p)[3] = reinterpret_cast( mesh_p->vert_positions_for_write().data()); - copy_m4_m4(prev_obmat, ob->object_to_world); + copy_m4_m4(prev_obmat, ob->object_to_world().ptr()); /* current frame mesh */ scene->r.cfra = cur_fra; @@ -3865,7 +3865,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Depsgraph *depsgraph, data.brush_vel = *brushVel; data.positions_p = positions_p; data.positions_c = positions_c; - data.obmat = ob->object_to_world; + data.obmat = ob->object_to_world().ptr(); data.prev_obmat = prev_obmat; data.timescale = timescale; @@ -3905,7 +3905,7 @@ static void dynamicPaint_brushObjectCalculateVelocity( SUBFRAME_RECURSION, BKE_scene_ctime_get(scene), eModifierType_DynamicPaint); - copy_m4_m4(prev_obmat, ob->object_to_world); + copy_m4_m4(prev_obmat, ob->object_to_world().ptr()); /* current frame mesh */ scene->r.cfra = cur_fra; @@ -3920,7 +3920,7 @@ static void dynamicPaint_brushObjectCalculateVelocity( /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); - mul_m4_v3(ob->object_to_world, cur_loc); + mul_m4_v3(ob->object_to_world().ptr(), cur_loc); sub_v3_v3v3(brushVel->v, cur_loc, prev_loc); mul_v3_fl(brushVel->v, 1.0f / timescale); @@ -4329,14 +4329,14 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph, * (Faster than transforming per surface point * coordinates and normals to object space) */ for (ii = 0; ii < numOfVerts; ii++) { - mul_m4_v3(brushOb->object_to_world, positions[ii]); + mul_m4_v3(brushOb->object_to_world().ptr(), positions[ii]); boundInsert(&mesh_bb, positions[ii]); /* for proximity project calculate average normal */ if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) { float nor[3]; copy_v3_v3(nor, vert_normals[ii]); - mul_mat3_m4_v3(brushOb->object_to_world, nor); + mul_mat3_m4_v3(brushOb->object_to_world().ptr(), nor); normalize_v3(nor); add_v3_v3(avg_brushNor, nor); @@ -5933,7 +5933,7 @@ static bool dynamicPaint_surfaceHasMoved(DynamicPaintSurface *surface, Object *o } /* matrix comparison */ - if (!equals_m4m4(bData->prev_obmat, ob->object_to_world)) { + if (!equals_m4m4(bData->prev_obmat, ob->object_to_world().ptr())) { return true; } @@ -6021,7 +6021,7 @@ static void dynamic_paint_generate_bake_data_cb(void *__restrict userdata, mul_v3_v3v3(scaled_nor, temp_nor, ob->scale); bData->bNormal[index].normal_scale = len_v3(scaled_nor); } - mul_mat3_m4_v3(ob->object_to_world, temp_nor); + mul_mat3_m4_v3(ob->object_to_world().ptr(), temp_nor); normalize_v3(temp_nor); negate_v3_v3(bData->bNormal[index].invNorm, temp_nor); } @@ -6059,7 +6059,7 @@ static void dynamic_paint_generate_bake_data_cb(void *__restrict userdata, mul_v3_v3v3(scaled_nor, temp_nor, ob->scale); bData->bNormal[index].normal_scale = len_v3(scaled_nor); } - mul_mat3_m4_v3(ob->object_to_world, temp_nor); + mul_mat3_m4_v3(ob->object_to_world().ptr(), temp_nor); normalize_v3(temp_nor); negate_v3_v3(bData->bNormal[index].invNorm, temp_nor); } @@ -6179,7 +6179,7 @@ static bool dynamicPaint_generateBakeData(DynamicPaintSurface *surface, bData->mesh_bounds.valid = false; for (index = 0; index < canvasNumOfVerts; index++) { copy_v3_v3(canvas_verts[index].v, positions[index]); - mul_m4_v3(ob->object_to_world, canvas_verts[index].v); + mul_m4_v3(ob->object_to_world().ptr(), canvas_verts[index].v); boundInsert(&bData->mesh_bounds, canvas_verts[index].v); } @@ -6209,7 +6209,7 @@ static bool dynamicPaint_generateBakeData(DynamicPaintSurface *surface, dynamicPaint_prepareAdjacencyData(surface, false); /* Copy current frame vertices to check against in next frame */ - copy_m4_m4(bData->prev_obmat, ob->object_to_world); + copy_m4_m4(bData->prev_obmat, ob->object_to_world().ptr()); memcpy(bData->prev_positions, positions.data(), canvasNumOfVerts * sizeof(float[3])); bData->clear = 0; diff --git a/source/blender/blenkernel/intern/effect.cc b/source/blender/blenkernel/intern/effect.cc index 64a0fd77620..e84be58f486 100644 --- a/source/blender/blenkernel/intern/effect.cc +++ b/source/blender/blenkernel/intern/effect.cc @@ -155,8 +155,8 @@ static void precalculate_effector(Depsgraph *depsgraph, EffectorCache *eff) if (eff->ob->runtime->curve_cache->anim_path_accum_length) { BKE_where_on_path( eff->ob, 0.0, eff->guide_loc, eff->guide_dir, nullptr, &eff->guide_radius, nullptr); - mul_m4_v3(eff->ob->object_to_world, eff->guide_loc); - mul_mat3_m4_v3(eff->ob->object_to_world, eff->guide_dir); + mul_m4_v3(eff->ob->object_to_world().ptr(), eff->guide_loc); + mul_mat3_m4_v3(eff->ob->object_to_world().ptr(), eff->guide_dir); } } } @@ -713,8 +713,8 @@ bool get_effector_data(EffectorCache *eff, copy_v3_v3(efd->loc, positions[*efd->index]); copy_v3_v3(efd->nor, vert_normals[*efd->index]); - mul_m4_v3(eff->ob->object_to_world, efd->loc); - mul_mat3_m4_v3(eff->ob->object_to_world, efd->nor); + mul_m4_v3(eff->ob->object_to_world().ptr(), efd->loc); + mul_mat3_m4_v3(eff->ob->object_to_world().ptr(), efd->nor); normalize_v3(efd->nor); @@ -766,23 +766,23 @@ bool get_effector_data(EffectorCache *eff, const Object *ob = eff->ob; /* Use z-axis as normal. */ - normalize_v3_v3(efd->nor, ob->object_to_world[2]); + normalize_v3_v3(efd->nor, ob->object_to_world().ptr()[2]); if (eff->pd && ELEM(eff->pd->shape, PFIELD_SHAPE_PLANE, PFIELD_SHAPE_LINE)) { float temp[3], translate[3]; - sub_v3_v3v3(temp, point->loc, ob->object_to_world[3]); + sub_v3_v3v3(temp, point->loc, ob->object_to_world().location()); project_v3_v3v3(translate, temp, efd->nor); /* for vortex the shape chooses between old / new force */ if (eff->pd->forcefield == PFIELD_VORTEX || eff->pd->shape == PFIELD_SHAPE_LINE) { - add_v3_v3v3(efd->loc, ob->object_to_world[3], translate); + add_v3_v3v3(efd->loc, ob->object_to_world().location(), translate); } else { /* Normally `efd->loc` is closest point on effector XY-plane. */ sub_v3_v3v3(efd->loc, point->loc, translate); } } else { - copy_v3_v3(efd->loc, ob->object_to_world[3]); + copy_v3_v3(efd->loc, ob->object_to_world().location()); } zero_v3(efd->vel); @@ -807,8 +807,8 @@ bool get_effector_data(EffectorCache *eff, } else { /* for some effectors we need the object center every time */ - sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->object_to_world[3]); - normalize_v3_v3(efd->nor2, eff->ob->object_to_world[2]); + sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->object_to_world().location()); + normalize_v3_v3(efd->nor2, eff->ob->object_to_world().ptr()[2]); } } @@ -881,7 +881,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->world_to_object, tex_co); + mul_m4_v3(eff->ob->world_to_object().ptr(), tex_co); if (eff->pd->flag & PFIELD_TEX_2D) { tex_co[2] = 0.0f; diff --git a/source/blender/blenkernel/intern/fcurve_driver.cc b/source/blender/blenkernel/intern/fcurve_driver.cc index 0c1fb82c45d..463bd999a62 100644 --- a/source/blender/blenkernel/intern/fcurve_driver.cc +++ b/source/blender/blenkernel/intern/fcurve_driver.cc @@ -435,7 +435,7 @@ static float dvar_eval_rotDiff(const AnimationEvalContext * /*anim_eval_context* return 0.0f; } - float(*mat[2])[4]; + const float(*mat[2])[4]; /* NOTE: for now, these are all just world-space. */ for (int i = 0; i < 2; i++) { @@ -457,7 +457,7 @@ static float dvar_eval_rotDiff(const AnimationEvalContext * /*anim_eval_context* } else { /* Object. */ - mat[i] = ob->object_to_world; + mat[i] = ob->object_to_world().ptr(); } } @@ -537,7 +537,7 @@ static float dvar_eval_locDiff(const AnimationEvalContext * /*anim_eval_context* else { /* Convert to world-space. */ copy_v3_v3(tmp_loc, pchan->pose_head); - mul_m4_v3(ob->object_to_world, tmp_loc); + mul_m4_v3(ob->object_to_world().ptr(), tmp_loc); } } else { @@ -548,7 +548,7 @@ static float dvar_eval_locDiff(const AnimationEvalContext * /*anim_eval_context* float mat[4][4]; /* Extract transform just like how the constraints do it! */ - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); BKE_constraint_mat_convertspace( ob, nullptr, nullptr, mat, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, false); @@ -562,7 +562,7 @@ static float dvar_eval_locDiff(const AnimationEvalContext * /*anim_eval_context* } else { /* World-space. */ - copy_v3_v3(tmp_loc, ob->object_to_world[3]); + copy_v3_v3(tmp_loc, ob->object_to_world().location()); } } @@ -640,7 +640,7 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex } else { /* World-space matrix. */ - mul_m4_m4m4(mat, ob->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), pchan->pose_mat); } } else { @@ -654,7 +654,7 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex if (dtar->flag & DTAR_FLAG_LOCALSPACE) { if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) { /* Just like how the constraints do it! */ - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); BKE_constraint_mat_convertspace( ob, nullptr, nullptr, mat, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL, false); } @@ -665,7 +665,7 @@ static float dvar_eval_transChan(const AnimationEvalContext * /*anim_eval_contex } else { /* World-space matrix - just the good-old one. */ - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); } } diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index b3d3c8e0d21..9e708c37573 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -432,7 +432,7 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds, copy_v3_v3(fds->global_size, size); copy_v3_v3(fds->dp0, min); - invert_m4_m4(fds->imat, ob->object_to_world); + invert_m4_m4(fds->imat, ob->object_to_world().ptr()); /* Prevent crash when initializing a plane as domain. */ if (!init_resolution || (size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || @@ -498,8 +498,8 @@ static bool fluid_modifier_init( zero_v3(fds->shift_f); add_v3_fl(fds->shift_f, 0.5f); zero_v3(fds->prev_loc); - mul_m4_v3(ob->object_to_world, fds->prev_loc); - copy_m4_m4(fds->obmat, ob->object_to_world); + mul_m4_v3(ob->object_to_world().ptr(), fds->prev_loc); + copy_m4_m4(fds->obmat, ob->object_to_world().ptr()); /* Set resolutions. */ if (fmd->domain->type == FLUID_DOMAIN_TYPE_GAS && @@ -567,11 +567,11 @@ static int get_light(Scene *scene, ViewLayer *view_layer, float *light) Light *la = static_cast(base_tmp->object->data); if (la->type == LA_LOCAL) { - copy_v3_v3(light, base_tmp->object->object_to_world[3]); + copy_v3_v3(light, base_tmp->object->object_to_world().location()); return 1; } if (!found_light) { - copy_v3_v3(light, base_tmp->object->object_to_world[3]); + copy_v3_v3(light, base_tmp->object->object_to_world().location()); found_light = 1; } } @@ -1049,7 +1049,7 @@ static void obstacles_from_mesh(Object *coll_ob, float co[3]; /* Vertex position. */ - mul_m4_v3(coll_ob->object_to_world, positions[i]); + mul_m4_v3(coll_ob->object_to_world().ptr(), positions[i]); manta_pos_to_cell(fds, positions[i]); /* Vertex velocity. */ @@ -2111,7 +2111,7 @@ static void emit_from_mesh( * This is valid because the mesh is copied above. */ for (i = 0; i < numverts; i++) { /* Vertex position. */ - mul_m4_v3(flow_ob->object_to_world, positions[i]); + mul_m4_v3(flow_ob->object_to_world().ptr(), positions[i]); manta_pos_to_cell(fds, positions[i]); /* Vertex velocity. */ @@ -2129,7 +2129,7 @@ static void emit_from_mesh( bb_boundInsert(bb, positions[i]); } mesh->tag_positions_changed(); - mul_m4_v3(flow_ob->object_to_world, flow_center); + mul_m4_v3(flow_ob->object_to_world().ptr(), flow_center); manta_pos_to_cell(fds, flow_center); /* Set emission map. @@ -2198,7 +2198,7 @@ static void adaptive_domain_adjust( float frame_shift_f[3]; float ob_loc[3] = {0}; - mul_m4_v3(ob->object_to_world, ob_loc); + mul_m4_v3(ob->object_to_world().ptr(), ob_loc); sub_v3_v3v3(frame_shift_f, ob_loc, fds->prev_loc); copy_v3_v3(fds->prev_loc, ob_loc); @@ -3488,12 +3488,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->world_to_object, ob->object_to_world); - mul_m4_v3(ob->object_to_world, ob_loc); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_v3(ob->object_to_world().ptr(), 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->world_to_object, fds->obj_shift_f); + mul_mat3_m4_v3(ob->world_to_object().ptr(), fds->obj_shift_f); /* Apply shift to vertices. */ for (int i = 0; i < num_verts; i++) { add_v3_v3(positions[i], fds->obj_shift_f); @@ -3518,8 +3518,8 @@ static int manta_step( bool mode_replay = (mode == FLUID_DOMAIN_CACHE_REPLAY); /* Update object state. */ - invert_m4_m4(fds->imat, ob->object_to_world); - copy_m4_m4(fds->obmat, ob->object_to_world); + invert_m4_m4(fds->imat, ob->object_to_world().ptr()); + copy_m4_m4(fds->obmat, ob->object_to_world().ptr()); /* Gas domain might use adaptive domain. */ if (fds->type == FLUID_DOMAIN_TYPE_GAS) { diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc index bc0deb513cb..2a92990ca63 100644 --- a/source/blender/blenkernel/intern/geometry_set_instances.cc +++ b/source/blender/blenkernel/intern/geometry_set_instances.cc @@ -129,7 +129,7 @@ void Instances::ensure_geometry_instances() Collection &collection = reference.collection(); FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (&collection, object) { const int handle = instances->add_reference(*object); - instances->add_instance(handle, float4x4(object->object_to_world)); + instances->add_instance(handle, object->object_to_world()); float4x4 &transform = instances->transforms().last(); transform.location() -= collection.instance_offset; } diff --git a/source/blender/blenkernel/intern/gpencil_legacy.cc b/source/blender/blenkernel/intern/gpencil_legacy.cc index 4c0acc3551d..342a14a209d 100644 --- a/source/blender/blenkernel/intern/gpencil_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_legacy.cc @@ -2696,7 +2696,7 @@ void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, /* if not layer parented, try with object parented */ if (obparent_eval == nullptr) { if ((ob_eval != nullptr) && (ob_eval->type == OB_GPENCIL_LEGACY)) { - copy_m4_m4(diff_mat, ob_eval->object_to_world); + copy_m4_m4(diff_mat, ob_eval->object_to_world().ptr()); mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_mat); return; } @@ -2706,8 +2706,8 @@ void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, } if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { - mul_m4_m4m4(diff_mat, obparent_eval->object_to_world, gpl->inverse); - add_v3_v3(diff_mat[3], ob_eval->object_to_world[3]); + mul_m4_m4m4(diff_mat, obparent_eval->object_to_world().ptr(), gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->object_to_world().location()); mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_mat); return; } @@ -2715,14 +2715,14 @@ void BKE_gpencil_layer_transform_matrix_get(const Depsgraph *depsgraph, bPoseChannel *pchan = BKE_pose_channel_find_name(obparent_eval->pose, gpl->parsubstr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, obparent_eval->object_to_world, pchan->pose_mat); + mul_m4_m4m4(tmp_mat, obparent_eval->object_to_world().ptr(), pchan->pose_mat); mul_m4_m4m4(diff_mat, tmp_mat, gpl->inverse); - add_v3_v3(diff_mat[3], ob_eval->object_to_world[3]); + add_v3_v3(diff_mat[3], ob_eval->object_to_world().location()); } else { /* if bone not found use object (armature) */ - mul_m4_m4m4(diff_mat, obparent_eval->object_to_world, gpl->inverse); - add_v3_v3(diff_mat[3], ob_eval->object_to_world[3]); + mul_m4_m4m4(diff_mat, obparent_eval->object_to_world().ptr(), gpl->inverse); + add_v3_v3(diff_mat[3], ob_eval->object_to_world().location()); } mul_m4_m4m4(diff_mat, diff_mat, gpl->layer_mat); return; @@ -2776,12 +2776,15 @@ 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->world_to_object, ob_parent->object_to_world); + mul_m4_m4m4(cur_mat, ob->world_to_object().ptr(), ob_parent->object_to_world().ptr()); } else if (gpl->partype == PARBONE) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob_parent->pose, gpl->parsubstr); if (pchan != nullptr) { - mul_m4_series(cur_mat, ob->world_to_object, ob_parent->object_to_world, pchan->pose_mat); + mul_m4_series(cur_mat, + ob->world_to_object().ptr(), + ob_parent->object_to_world().ptr(), + pchan->pose_mat); } else { unit_m4(cur_mat); diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 715732daa45..a913d26d1cf 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -959,7 +959,7 @@ void Layer::update_from_dna_read() float4x4 Layer::to_world_space(const Object &object) const { if (this->parent == nullptr) { - return float4x4(object.object_to_world) * this->local_transform(); + return object.object_to_world() * this->local_transform(); } const Object &parent = *this->parent; return this->parent_to_world(parent) * this->local_transform(); @@ -971,8 +971,7 @@ float4x4 Layer::to_object_space(const Object &object) const return this->local_transform(); } const Object &parent = *this->parent; - return float4x4(object.world_to_object) * this->parent_to_world(parent) * - this->local_transform(); + return object.world_to_object() * this->parent_to_world(parent) * this->local_transform(); } StringRefNull Layer::parent_bone_name() const @@ -990,7 +989,7 @@ void Layer::set_parent_bone_name(const char *new_name) float4x4 Layer::parent_to_world(const Object &parent) const { - const float4x4 parent_object_to_world(parent.object_to_world); + const float4x4 &parent_object_to_world = parent.object_to_world(); if (parent.type == OB_ARMATURE && !this->parent_bone_name().is_empty()) { if (bPoseChannel *channel = BKE_pose_channel_find_name(parent.pose, this->parent_bone_name().c_str())) diff --git a/source/blender/blenkernel/intern/lattice.cc b/source/blender/blenkernel/intern/lattice.cc index 4013c36a56f..aba440d886f 100644 --- a/source/blender/blenkernel/intern/lattice.cc +++ b/source/blender/blenkernel/intern/lattice.cc @@ -338,10 +338,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) BKE_displist_free(<Ob->runtime->curve_cache->disp); } - copy_m4_m4(mat, ltOb->object_to_world); - unit_m4(ltOb->object_to_world); + copy_m4_m4(mat, ltOb->object_to_world().ptr()); + unit_m4(ltOb->runtime->object_to_world.ptr()); BKE_lattice_deform_coords(ltOb, nullptr, vert_coords, uNew * vNew * wNew, 0, nullptr, 1.0f); - copy_m4_m4(ltOb->object_to_world, mat); + copy_m4_m4(ltOb->runtime->object_to_world.ptr(), mat); lt->typeu = typeu; lt->typev = typev; diff --git a/source/blender/blenkernel/intern/lattice_deform.cc b/source/blender/blenkernel/intern/lattice_deform.cc index 9c279be9130..b67ce7c90da 100644 --- a/source/blender/blenkernel/intern/lattice_deform.cc +++ b/source/blender/blenkernel/intern/lattice_deform.cc @@ -82,15 +82,15 @@ LatticeDeformData *BKE_lattice_deform_data_create(const Object *oblatt, const Ob /* for example with a particle system: (ob == nullptr) */ if (ob == nullptr) { /* In deform-space, calc matrix. */ - invert_m4_m4(latmat, oblatt->object_to_world); + invert_m4_m4(latmat, oblatt->object_to_world().ptr()); /* back: put in deform array */ invert_m4_m4(imat, latmat); } else { /* In deform-space, calc matrix. */ - invert_m4_m4(imat, oblatt->object_to_world); - mul_m4_m4m4(latmat, imat, ob->object_to_world); + invert_m4_m4(imat, oblatt->object_to_world().ptr()); + mul_m4_m4m4(latmat, imat, ob->object_to_world().ptr()); /* back: put in deform array. */ invert_m4_m4(imat, latmat); diff --git a/source/blender/blenkernel/intern/mball_tessellate.cc b/source/blender/blenkernel/intern/mball_tessellate.cc index 2cf2366c4dc..b4548913e4b 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.cc +++ b/source/blender/blenkernel/intern/mball_tessellate.cc @@ -1178,9 +1178,10 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje const eEvaluationMode deg_eval_mode = DEG_get_mode(depsgraph); const short parenting_dupli_transflag = (OB_DUPLIFACES | OB_DUPLIVERTS); - copy_m4_m4(obmat, - ob->object_to_world); /* to cope with duplicators from BKE_scene_base_iter_next */ - invert_m4_m4(obinv, ob->object_to_world); + copy_m4_m4( + obmat, + ob->object_to_world().ptr()); /* to cope with duplicators from BKE_scene_base_iter_next */ + invert_m4_m4(obinv, ob->object_to_world().ptr()); BLI_string_split_name_number(ob->id.name + 2, '.', obname, &obnr); @@ -1229,13 +1230,13 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje /* when metaball object has zero scale, then MetaElem to this MetaBall * will not be put to mainb array */ - if (has_zero_axis_m4(bob->object_to_world)) { + if (has_zero_axis_m4(bob->object_to_world().ptr())) { zero_size = 1; } else if (bob->parent) { Object *pob = bob->parent; while (pob) { - if (has_zero_axis_m4(pob->object_to_world)) { + if (has_zero_axis_m4(pob->object_to_world().ptr())) { zero_size = 1; break; } @@ -1299,7 +1300,7 @@ static void init_meta(Depsgraph *depsgraph, PROCESS *process, Scene *scene, Obje * rotation -> * ml local space */ - mul_m4_series((float(*)[4])new_ml->mat, obinv, bob->object_to_world, pos, rot); + mul_m4_series((float(*)[4])new_ml->mat, obinv, bob->object_to_world().ptr(), pos, rot); /* ml local space -> basis object space */ invert_m4_m4((float(*)[4])new_ml->imat, (float(*)[4])new_ml->mat); diff --git a/source/blender/blenkernel/intern/mesh_mirror.cc b/source/blender/blenkernel/intern/mesh_mirror.cc index 78a236e5fe0..3c99f214875 100644 --- a/source/blender/blenkernel/intern/mesh_mirror.cc +++ b/source/blender/blenkernel/intern/mesh_mirror.cc @@ -145,8 +145,8 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* tmp is a transform from coords relative to the object's own origin, * to coords relative to the mirror object origin */ - invert_m4_m4(tmp, mirror_ob->object_to_world); - mul_m4_m4m4(tmp, tmp, ob->object_to_world); + invert_m4_m4(tmp, mirror_ob->object_to_world().ptr()); + mul_m4_m4m4(tmp, tmp, ob->object_to_world().ptr()); /* itmp is the reverse transform back to origin-relative coordinates */ invert_m4_m4(itmp, tmp); @@ -162,9 +162,9 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, /* Account for non-uniform scale in `ob`, see: #87592. */ float ob_scale[3] = { - len_squared_v3(ob->object_to_world[0]), - len_squared_v3(ob->object_to_world[1]), - len_squared_v3(ob->object_to_world[2]), + len_squared_v3(ob->object_to_world().ptr()[0]), + len_squared_v3(ob->object_to_world().ptr()[1]), + len_squared_v3(ob->object_to_world().ptr()[2]), }; /* Scale to avoid precision loss with extreme values. */ const float ob_scale_max = max_fff(UNPACK3(ob_scale)); diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 3ff48b51adf..bc5a26fde1d 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -1177,14 +1177,16 @@ void BKE_object_modifier_hook_reset(Object *ob, HookModifierData *hmd) /* Calculate the world-space matrix for the pose-channel target first, * then carry on as usual. */ - mul_m4_m4m4(mat, hmd->object->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat, hmd->object->object_to_world().ptr(), pchan->pose_mat); invert_m4_m4(imat, mat); - mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world); + mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world().ptr()); } else { - 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); + invert_m4_m4(hmd->object->runtime->world_to_object.ptr(), + hmd->object->object_to_world().ptr()); + mul_m4_m4m4( + hmd->parentinv, hmd->object->world_to_object().ptr(), ob->object_to_world().ptr()); } } } @@ -1202,14 +1204,15 @@ void BKE_object_modifier_gpencil_hook_reset(Object *ob, HookGpencilModifierData /* Calculate the world-space matrix for the pose-channel target first, * then carry on as usual. */ - mul_m4_m4m4(mat, hmd->object->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat, hmd->object->object_to_world().ptr(), pchan->pose_mat); invert_m4_m4(imat, mat); - mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world); + mul_m4_m4m4(hmd->parentinv, imat, ob->object_to_world().ptr()); } else { - 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); + invert_m4_m4(hmd->object->runtime->world_to_object.ptr(), + hmd->object->object_to_world().ptr()); + mul_m4_m4m4(hmd->parentinv, hmd->object->world_to_object().ptr(), ob->object_to_world().ptr()); } } @@ -2980,10 +2983,10 @@ void BKE_object_matrix_local_get(Object *ob, float r_mat[4][4]) BKE_object_get_parent_matrix(ob, ob->parent, par_imat); invert_m4(par_imat); - mul_m4_m4m4(r_mat, par_imat, ob->object_to_world); + mul_m4_m4m4(r_mat, par_imat, ob->object_to_world().ptr()); } else { - copy_m4_m4(r_mat, ob->object_to_world); + copy_m4_m4(r_mat, ob->object_to_world().ptr()); } } @@ -3240,32 +3243,32 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][ } if (ok) { - mul_m4_m4m4(r_parentmat, par->object_to_world, tmat); + mul_m4_m4m4(r_parentmat, par->object_to_world().ptr(), tmat); } else { - copy_m4_m4(r_parentmat, par->object_to_world); + copy_m4_m4(r_parentmat, par->object_to_world().ptr()); } break; } case PARBONE: ob_parbone(ob, par, tmat); - mul_m4_m4m4(r_parentmat, par->object_to_world, tmat); + mul_m4_m4m4(r_parentmat, par->object_to_world().ptr(), tmat); break; case PARVERT1: unit_m4(r_parentmat); give_parvert(par, ob->par1, vec); - mul_v3_m4v3(r_parentmat[3], par->object_to_world, vec); + mul_v3_m4v3(r_parentmat[3], par->object_to_world().ptr(), vec); break; case PARVERT3: ob_parvert3(ob, par, tmat); - mul_m4_m4m4(r_parentmat, par->object_to_world, tmat); + mul_m4_m4m4(r_parentmat, par->object_to_world().ptr(), tmat); break; case PARSKEL: - copy_m4_m4(r_parentmat, par->object_to_world); + copy_m4_m4(r_parentmat, par->object_to_world().ptr()); break; } } @@ -3303,7 +3306,7 @@ static void solve_parenting( /* origin, for help line */ if (set_origin) { if ((ob->partype & PARTYPE) == PARSKEL) { - copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world[3]); + copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world().location()); } else { copy_v3_v3(ob->runtime->parent_display_origin, totmat[3]); @@ -3322,10 +3325,10 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, Object *par = ob->parent; /* calculate parent matrix */ - solve_parenting(ob, par, true, ob->object_to_world, r_originmat); + solve_parenting(ob, par, true, ob->runtime->object_to_world.ptr(), r_originmat); } else { - BKE_object_to_mat4(ob, ob->object_to_world); + BKE_object_to_mat4(ob, ob->runtime->object_to_world.ptr()); } /* try to fall back to the scene rigid body world if none given */ @@ -3342,7 +3345,7 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, } /* set negative scale flag in object */ - if (is_negative_m4(ob->object_to_world)) { + if (is_negative_m4(ob->object_to_world().ptr())) { ob->transflag |= OB_NEG_SCALE; } else { @@ -3390,7 +3393,7 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o BKE_object_workob_clear(workob); workob->runtime = &workob_runtime; - unit_m4(workob->object_to_world); + unit_m4(workob->runtime->object_to_world.ptr()); unit_m4(workob->parentinv); unit_m4(workob->constinv); @@ -3482,8 +3485,8 @@ void BKE_object_apply_parent_inverse(Object *ob) * `inv(parent) @ world = parentinv` * `parentinv = inv(parent) @ world` * - * NOTE: If `ob->object_to_world` has shear, then this `parentinv` is insufficient because - * `parent @ parentinv => shearless result` + * NOTE: If `ob->object_to_world().ptr()` has shear, then this `parentinv` is insufficient + * because `parent @ parentinv => shearless result` * * Thus, local will have shear which cannot be decomposed into TRS: * `local = inv(parent @ parentinv) @ world` @@ -3511,7 +3514,7 @@ void BKE_object_apply_parent_inverse(Object *ob) copy_m4_m4(ob_local, ob->parentinv); invert_m4(ob_local); mul_m4_m4_post(ob_local, par_imat); - mul_m4_m4_post(ob_local, ob->object_to_world); + mul_m4_m4_post(ob_local, ob->object_to_world().ptr()); /* Send use_compat=False so the rotation is predictable. */ BKE_object_apply_mat4(ob, ob_local, false, false); @@ -3613,7 +3616,7 @@ static float3 boundbox_to_dimensions(const Object *ob, const std::optionalobject_to_world)); + const float3 scale = math::to_scale(ob->object_to_world()); return scale * (bounds->max - bounds->min); } @@ -3664,10 +3667,8 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3]) { using namespace blender; if (const std::optional> bounds = BKE_object_boundbox_get(ob)) { - minmax_v3v3_v3( - r_min, r_max, math::transform_point(float4x4(ob->object_to_world), bounds->min)); - minmax_v3v3_v3( - r_min, r_max, math::transform_point(float4x4(ob->object_to_world), bounds->max)); + minmax_v3v3_v3(r_min, r_max, math::transform_point(ob->object_to_world(), bounds->min)); + minmax_v3v3_v3(r_min, r_max, math::transform_point(ob->object_to_world(), bounds->max)); return; } float3 size = ob->scale; @@ -3677,14 +3678,14 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3]) size *= ob->empty_drawsize; } - minmax_v3v3_v3(r_min, r_max, ob->object_to_world[3]); + minmax_v3v3_v3(r_min, r_max, ob->object_to_world().location()); float3 vec; - copy_v3_v3(vec, ob->object_to_world[3]); + copy_v3_v3(vec, ob->object_to_world().location()); add_v3_v3(vec, size); minmax_v3v3_v3(r_min, r_max, vec); - copy_v3_v3(vec, ob->object_to_world[3]); + copy_v3_v3(vec, ob->object_to_world().location()); sub_v3_v3(vec, size); minmax_v3v3_v3(r_min, r_max, vec); } @@ -3730,12 +3731,12 @@ bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const Re * however the issue with empty objects being visible when viewed from the side * is only noticeable in orthographic views. */ float3 view_dir; - sub_v3_v3v3(view_dir, rv3d->viewinv[3], ob->object_to_world[3]); - dot = dot_v3v3(ob->object_to_world[2], view_dir); + sub_v3_v3v3(view_dir, rv3d->viewinv[3], ob->object_to_world().location()); + dot = dot_v3v3(ob->object_to_world().ptr()[2], view_dir); eps = 0.0f; } else { - dot = dot_v3v3(ob->object_to_world[2], rv3d->viewinv[2]); + dot = dot_v3v3(ob->object_to_world().ptr()[2], rv3d->viewinv[2]); eps = 1e-5f; } if (visibility_flag & OB_EMPTY_IMAGE_HIDE_BACK) { @@ -3752,7 +3753,7 @@ bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const Re if (visibility_flag & OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED) { float3 proj, ob_z_axis; - normalize_v3_v3(ob_z_axis, ob->object_to_world[2]); + normalize_v3_v3(ob_z_axis, ob->object_to_world().ptr()[2]); project_plane_v3_v3v3(proj, ob_z_axis, rv3d->viewinv[2]); const float proj_length_sq = len_squared_v3(proj); if (proj_length_sq > 1e-5f) { @@ -3946,7 +3947,7 @@ void BKE_scene_foreach_display_point(Depsgraph *depsgraph, DEG_ITER_OBJECT_FLAG_DUPLI; DEG_OBJECT_ITER_BEGIN (°_iter_settings, ob) { if ((ob->base_flag & BASE_SELECTED) != 0) { - BKE_object_foreach_display_point(ob, ob->object_to_world, func_cb, user_data); + BKE_object_foreach_display_point(ob, ob->object_to_world().ptr(), func_cb, user_data); } } DEG_OBJECT_ITER_END; @@ -3989,10 +3990,10 @@ void *BKE_object_tfm_backup(Object *ob) copy_v3_v3(obtfm->drotAxis, ob->drotAxis); obtfm->rotAngle = ob->rotAngle; obtfm->drotAngle = ob->drotAngle; - copy_m4_m4(obtfm->obmat, ob->object_to_world); + copy_m4_m4(obtfm->obmat, ob->object_to_world().ptr()); copy_m4_m4(obtfm->parentinv, ob->parentinv); copy_m4_m4(obtfm->constinv, ob->constinv); - copy_m4_m4(obtfm->imat, ob->world_to_object); + copy_m4_m4(obtfm->imat, ob->world_to_object().ptr()); return (void *)obtfm; } @@ -4012,10 +4013,10 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) copy_v3_v3(ob->drotAxis, obtfm->drotAxis); ob->rotAngle = obtfm->rotAngle; ob->drotAngle = obtfm->drotAngle; - copy_m4_m4(ob->object_to_world, obtfm->obmat); + copy_m4_m4(ob->runtime->object_to_world.ptr(), obtfm->obmat); copy_m4_m4(ob->parentinv, obtfm->parentinv); copy_m4_m4(ob->constinv, obtfm->constinv); - copy_m4_m4(ob->world_to_object, obtfm->imat); + copy_m4_m4(ob->runtime->world_to_object.ptr(), obtfm->imat); } /** \} */ @@ -5058,7 +5059,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) for (i = 0; i < positions.size(); i++) { if (index[i] != ORIGINDEX_NONE) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world, positions[i]); + mul_v3_m4v3(co, ob->object_to_world().ptr(), positions[i]); BLI_kdtree_3d_insert(tree, index[i], co); tot++; } @@ -5072,7 +5073,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) for (i = 0; i < tot; i++) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world, positions[i]); + mul_v3_m4v3(co, ob->object_to_world().ptr(), positions[i]); BLI_kdtree_3d_insert(tree, i, co); } } @@ -5101,7 +5102,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) a = nu->pntsu; while (a--) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world, bezt->vec[1]); + mul_v3_m4v3(co, ob->object_to_world().ptr(), bezt->vec[1]); BLI_kdtree_3d_insert(tree, i++, co); bezt++; } @@ -5113,7 +5114,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) a = nu->pntsu * nu->pntsv; while (a--) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world, bp->vec); + mul_v3_m4v3(co, ob->object_to_world().ptr(), bp->vec); BLI_kdtree_3d_insert(tree, i++, co); bp++; } @@ -5136,7 +5137,7 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) for (bp = lt->def; i < tot; bp++) { float co[3]; - mul_v3_m4v3(co, ob->object_to_world, bp->vec); + mul_v3_m4v3(co, ob->object_to_world().ptr(), bp->vec); BLI_kdtree_3d_insert(tree, i++, co); } @@ -5357,3 +5358,12 @@ void BKE_object_replace_data_on_shallow_copy(Object *ob, ID *new_data) } /** \} */ + +const blender::float4x4 &Object::object_to_world() const +{ + return this->runtime->object_to_world; +} +const blender::float4x4 &Object::world_to_object() const +{ + return this->runtime->world_to_object; +} diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc index 69c01b92b8c..eb55041d824 100644 --- a/source/blender/blenkernel/intern/object_dupli.cc +++ b/source/blender/blenkernel/intern/object_dupli.cc @@ -507,8 +507,8 @@ static void make_duplis_collection(const DupliContext *ctx) /* Combine collection offset and `obmat`. */ unit_m4(collection_mat); sub_v3_v3(collection_mat[3], collection->instance_offset); - mul_m4_m4m4(collection_mat, ob->object_to_world, collection_mat); - /* Don't access 'ob->object_to_world' from now on. */ + mul_m4_m4m4(collection_mat, ob->object_to_world().ptr(), collection_mat); + /* Don't access 'ob->object_to_world().ptr()' from now on. */ eEvaluationMode mode = DEG_get_mode(ctx->depsgraph); FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (collection, cob, mode) { @@ -516,7 +516,7 @@ static void make_duplis_collection(const DupliContext *ctx) float mat[4][4]; /* Collection dupli-offset, should apply after everything else. */ - mul_m4_m4m4(mat, collection_mat, cob->object_to_world); + mul_m4_m4m4(mat, collection_mat, cob->object_to_world().ptr()); make_dupli(ctx, cob, mat, _base_id); @@ -622,11 +622,11 @@ static DupliObject *vertex_dupli(const DupliContext *ctx, /* Make offset relative to inst_ob using relative child transform. */ mul_mat3_m4_v3(child_imat, obmat[3]); /* Apply `obmat` _after_ the local vertex transform. */ - mul_m4_m4m4(obmat, inst_ob->object_to_world, obmat); + mul_m4_m4m4(obmat, inst_ob->object_to_world().ptr(), obmat); /* 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->world_to_object); + mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object().ptr()); DupliObject *dob = make_dupli(ctx, inst_ob, obmat, index); @@ -645,10 +645,10 @@ static void make_child_duplis_verts_from_mesh(const DupliContext *ctx, const int totvert = vdd->totvert; - invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); + invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); /* Relative transform from parent to child space. */ float child_imat[4][4]; - mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); + mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); for (int i = 0; i < totvert; i++) { DupliObject *dob = vertex_dupli(vdd->params.ctx, @@ -672,10 +672,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->world_to_object, inst_ob->object_to_world); + invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); /* Relative transform from parent to child space. */ float child_imat[4][4]; - mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); + mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); BMVert *v; BMIter iter; @@ -799,7 +799,7 @@ static void make_duplis_font(const DupliContext *ctx) return; } - copy_m4_m4(pmat, par->object_to_world); + copy_m4_m4(pmat, par->object_to_world().ptr()); /* In `par` the family name is stored, use this to find the other objects. */ @@ -844,7 +844,7 @@ static void make_duplis_font(const DupliContext *ctx) mul_m4_v3(pmat, vec); - copy_m4_m4(obmat, par->object_to_world); + copy_m4_m4(obmat, par->object_to_world().ptr()); if (UNLIKELY(ct->rot != 0.0f)) { float rmat[4][4]; @@ -966,7 +966,8 @@ 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].ptr(), object.world_to_object); + mul_m4_m4m4( + space_matrix, instance_offset_matrices[i].ptr(), object.world_to_object().ptr()); mul_m4_m4_pre(space_matrix, parent_transform); make_recursive_duplis(ctx_for_instance, &object, space_matrix, id, &geometry_set, i); break; @@ -999,7 +1000,7 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, } float instance_matrix[4][4]; - mul_m4_m4m4(instance_matrix, collection_matrix, object->object_to_world); + mul_m4_m4m4(instance_matrix, collection_matrix, object->object_to_world().ptr()); make_dupli(&sub_ctx, object, instance_matrix, object_id++); make_recursive_duplis(&sub_ctx, object, collection_matrix, object_id++); @@ -1035,7 +1036,8 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx, static void make_duplis_geometry_set(const DupliContext *ctx) { const GeometrySet *geometry_set = ctx->object->runtime->geometry_set_eval; - make_duplis_geometry_set_impl(ctx, *geometry_set, ctx->object->object_to_world, false, false); + make_duplis_geometry_set_impl( + ctx, *geometry_set, ctx->object->object_to_world().ptr(), false, false); } static const DupliGenerator gen_dupli_geometry_set = { @@ -1141,11 +1143,11 @@ static DupliObject *face_dupli(const DupliContext *ctx, } /* Apply `obmat` _after_ the local face transform. */ - mul_m4_m4m4(obmat, inst_ob->object_to_world, obmat); + mul_m4_m4m4(obmat, inst_ob->object_to_world().ptr(), obmat); /* 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->world_to_object); + mul_m4_m4m4(space_mat, obmat, inst_ob->world_to_object().ptr()); DupliObject *dob = make_dupli(ctx, inst_ob, obmat, index); @@ -1218,9 +1220,9 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx, float child_imat[4][4]; - invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); + invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); /* Relative transform from parent to child space. */ - mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); + mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); const float scale_fac = ctx->object->instance_faces_scale; for (const int a : blender::IndexRange(totface)) { @@ -1265,9 +1267,9 @@ static void make_child_duplis_faces_from_editmesh(const DupliContext *ctx, BLI_assert((vert_positions_deform == nullptr) || (em->bm->elem_index_dirty & BM_VERT) == 0); - invert_m4_m4(inst_ob->world_to_object, inst_ob->object_to_world); + invert_m4_m4(inst_ob->runtime->world_to_object.ptr(), inst_ob->object_to_world().ptr()); /* Relative transform from parent to child space. */ - mul_m4_m4m4(child_imat, inst_ob->world_to_object, ctx->object->object_to_world); + mul_m4_m4m4(child_imat, inst_ob->world_to_object().ptr(), ctx->object->object_to_world().ptr()); const float scale_fac = ctx->object->instance_faces_scale; BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, a) { @@ -1400,7 +1402,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem sim.psmd = psys_get_modifier(par, psys); /* Make sure emitter `world_to_object` is in global coordinates instead of render view * coordinates. */ - invert_m4_m4(par->world_to_object, par->object_to_world); + invert_m4_m4(par->runtime->world_to_object.ptr(), par->object_to_world().ptr()); /* First check for loops (particle system object used as dupli-object). */ if (part->ren_as == PART_DRAW_OB) { @@ -1590,7 +1592,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem b = 0; FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (part->instance_collection, object, mode) { - copy_m4_m4(tmat, oblist[b]->object_to_world); + copy_m4_m4(tmat, oblist[b]->object_to_world().ptr()); /* Apply collection instance offset. */ sub_v3_v3(tmat[3], part->instance_collection->instance_offset); @@ -1613,7 +1615,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } else { float obmat[4][4]; - copy_m4_m4(obmat, ob->object_to_world); + copy_m4_m4(obmat, ob->object_to_world().ptr()); float vec[3]; copy_v3_v3(vec, obmat[3]); @@ -1804,8 +1806,11 @@ ListBase *object_duplilist_preview(Depsgraph *depsgraph, geo_log::GeoModifierLog::find_viewer_node_log_for_path(*viewer_path)) { ctx.preview_base_geometry = &viewer_log->geometry; - make_duplis_geometry_set_impl( - &ctx, viewer_log->geometry, ob_eval->object_to_world, true, ob_eval->type == OB_CURVES); + make_duplis_geometry_set_impl(&ctx, + viewer_log->geometry, + ob_eval->object_to_world().ptr(), + true, + ob_eval->type == OB_CURVES); } } return duplilist; diff --git a/source/blender/blenkernel/intern/object_update.cc b/source/blender/blenkernel/intern/object_update.cc index 9bb51141525..d23507c2416 100644 --- a/source/blender/blenkernel/intern/object_update.cc +++ b/source/blender/blenkernel/intern/object_update.cc @@ -57,7 +57,7 @@ void BKE_object_eval_local_transform(Depsgraph *depsgraph, Object *ob) DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob); /* calculate local matrix */ - BKE_object_to_mat4(ob, ob->object_to_world); + BKE_object_to_mat4(ob, ob->runtime->object_to_world.ptr()); } void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob) @@ -74,18 +74,18 @@ void BKE_object_eval_parent(Depsgraph *depsgraph, Object *ob) /* get local matrix (but don't calculate it, as that was done already!) */ /* XXX: redundant? */ - copy_m4_m4(locmat, ob->object_to_world); + copy_m4_m4(locmat, ob->object_to_world().ptr()); /* get parent effect matrix */ BKE_object_get_parent_matrix(ob, par, totmat); /* total */ mul_m4_m4m4(tmat, totmat, ob->parentinv); - mul_m4_m4m4(ob->object_to_world, tmat, locmat); + mul_m4_m4m4(ob->runtime->object_to_world.ptr(), tmat, locmat); /* origin, for help line */ if ((ob->partype & PARTYPE) == PARSKEL) { - copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world[3]); + copy_v3_v3(ob->runtime->parent_display_origin, par->object_to_world().location()); } else { copy_v3_v3(ob->runtime->parent_display_origin, totmat[3]); @@ -117,9 +117,9 @@ void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob) DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob); /* Make sure inverse matrix is always up to date. This way users of it * do not need to worry about recalculating it. */ - invert_m4_m4_safe(ob->world_to_object, ob->object_to_world); + invert_m4_m4_safe(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); /* Set negative scale flag in object. */ - if (is_negative_m4(ob->object_to_world)) { + if (is_negative_m4(ob->object_to_world().ptr())) { ob->transflag |= OB_NEG_SCALE; } else { @@ -240,8 +240,8 @@ void BKE_object_sync_to_original(Depsgraph *depsgraph, Object *object) /* Base flags. */ object_orig->base_flag = object->base_flag; /* Transformation flags. */ - copy_m4_m4(object_orig->object_to_world, object->object_to_world); - copy_m4_m4(object_orig->world_to_object, object->world_to_object); + copy_m4_m4(object_orig->runtime->object_to_world.ptr(), object->object_to_world().ptr()); + copy_m4_m4(object_orig->runtime->world_to_object.ptr(), object->world_to_object().ptr()); copy_m4_m4(object_orig->constinv, object->constinv); object_orig->transflag = object->transflag; object_orig->flag = object->flag; diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 3c5a3e6d57a..8bb6f1481ce 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1234,7 +1234,7 @@ void BKE_paint_stroke_get_average(const Scene *scene, const Object *ob, float st mul_v3_v3fl(stroke, ups->average_stroke_accum, fac); } else { - copy_v3_v3(stroke, ob->object_to_world[3]); + copy_v3_v3(stroke, ob->object_to_world().location()); } } diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index e7f6395b769..8b01131d01d 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -2299,8 +2299,8 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) nullptr, nullptr); - mul_m4_v3(sim->ob->object_to_world, state.co); - mul_mat3_m4_v3(sim->ob->object_to_world, state.vel); + mul_m4_v3(sim->ob->object_to_world().ptr(), state.co); + mul_mat3_m4_v3(sim->ob->object_to_world().ptr(), state.vel); pd_point_from_particle(sim, pa, &state, &point); @@ -2388,8 +2388,8 @@ bool do_guides(Depsgraph *depsgraph, } } - mul_m4_v3(eff->ob->object_to_world, guidevec); - mul_mat3_m4_v3(eff->ob->object_to_world, guidedir); + mul_m4_v3(eff->ob->object_to_world().ptr(), guidevec); + mul_mat3_m4_v3(eff->ob->object_to_world().ptr(), guidedir); normalize_v3(guidedir); @@ -2918,7 +2918,7 @@ static void psys_thread_create_path(ParticleTask *task, nullptr, orco); - mul_m4_v3(ob->object_to_world, co); + mul_m4_v3(ob->object_to_world().ptr(), co); for (w = 0; w < 4; w++) { sub_v3_v3v3(off1[w], co, key[w]->co); @@ -3381,7 +3381,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re /* dynamic hair is in object space */ /* keyed and baked are already in global space */ if (hair_mesh) { - mul_m4_v3(sim->ob->object_to_world, ca->co); + mul_m4_v3(sim->ob->object_to_world().ptr(), ca->co); } else if (!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, ca->co); @@ -3908,7 +3908,7 @@ void psys_mat_hair_to_global( psys_mat_hair_to_object(ob, mesh, from, pa, facemat); - mul_m4_m4m4(hairmat, ob->object_to_world, facemat); + mul_m4_m4m4(hairmat, ob->object_to_world().ptr(), facemat); } /************************************************/ @@ -4279,7 +4279,7 @@ static void get_cpa_texture(Mesh *mesh, case TEXCO_OBJECT: copy_v3_v3(texvec, par->state.co); if (mtex->object) { - mul_m4_v3(mtex->object->world_to_object, texvec); + mul_m4_v3(mtex->object->world_to_object().ptr(), texvec); } break; case TEXCO_UV: @@ -4369,7 +4369,7 @@ void psys_get_texture( case TEXCO_OBJECT: copy_v3_v3(texvec, pa->state.co); if (mtex->object) { - mul_m4_v3(mtex->object->world_to_object, texvec); + mul_m4_v3(mtex->object->world_to_object().ptr(), texvec); } break; case TEXCO_UV: @@ -4652,8 +4652,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, do_particle_interpolation(psys, p, pa, t, &pind, state); if (pind.mesh) { - mul_m4_v3(sim->ob->object_to_world, state->co); - mul_mat3_m4_v3(sim->ob->object_to_world, state->vel); + mul_m4_v3(sim->ob->object_to_world().ptr(), state->co); + mul_mat3_m4_v3(sim->ob->object_to_world().ptr(), state->vel); } else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) { if ((pa->flag & PARS_REKEY) == 0) { @@ -4676,7 +4676,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, } } else if (totchild) { - // invert_m4_m4(imat, ob->object_to_world); + // invert_m4_m4(imat, ob->object_to_world().ptr()); /* interpolate childcache directly if it exists */ if (psys->childcache) { @@ -4733,7 +4733,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, * positioning it accurately to the surface of the emitter. */ // copy_v3_v3(cpa_1st, co); - // mul_m4_v3(ob->object_to_world, cpa_1st); + // mul_m4_v3(ob->object_to_world().ptr(), cpa_1st); pa = psys->particles + cpa->parent; @@ -5198,7 +5198,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, } if (psys->part->rotmode == PART_ROT_VEL) { - transpose_m3_m4(nmat, ob->world_to_object); + transpose_m3_m4(nmat, ob->world_to_object().ptr()); mul_m3_v3(nmat, nor); normalize_v3(nor); diff --git a/source/blender/blenkernel/intern/particle_child.cc b/source/blender/blenkernel/intern/particle_child.cc index 0ffa82e46bc..b2032d34683 100644 --- a/source/blender/blenkernel/intern/particle_child.cc +++ b/source/blender/blenkernel/intern/particle_child.cc @@ -184,7 +184,7 @@ static void do_kink_spiral(ParticleThreadContext *ctx, zero_v3(kink_base); kink_base[part->kink_axis] = 1.0f; - mul_mat3_m4_v3(ctx->sim.ob->object_to_world, kink_base); + mul_mat3_m4_v3(ctx->sim.ob->object_to_world().ptr(), kink_base); /* Fill in invariant part of modifier context. */ ParticleChildModifierContext modifier_ctx = {nullptr}; @@ -393,7 +393,7 @@ void do_kink(ParticleKey *state, float flat, short type, short axis, - float obmat[4][4], + const float obmat[4][4], int smooth_start) { float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3]; @@ -872,7 +872,7 @@ void do_child_modifiers(const ParticleChildModifierContext *modifier_ctx, part->kink_flat, part->kink, part->kink_axis, - sim->ob->object_to_world, + sim->ob->object_to_world().ptr(), smooth_start); } } diff --git a/source/blender/blenkernel/intern/particle_system.cc b/source/blender/blenkernel/intern/particle_system.cc index ff82ef917da..ce3e10aa146 100644 --- a/source/blender/blenkernel/intern/particle_system.cc +++ b/source/blender/blenkernel/intern/particle_system.cc @@ -759,10 +759,10 @@ void psys_get_birth_coords( /* particles live in global space so */ /* let's convert: */ /* -location */ - mul_m4_v3(ob->object_to_world, loc); + mul_m4_v3(ob->object_to_world().ptr(), loc); /* -normal */ - mul_mat3_m4_v3(ob->object_to_world, nor); + mul_mat3_m4_v3(ob->object_to_world().ptr(), nor); normalize_v3(nor); /* -tangent */ @@ -780,7 +780,7 @@ void psys_get_birth_coords( fac = -sinf(float(M_PI) * (part->tanphase + phase)); madd_v3_v3fl(vtan, utan, fac); - mul_mat3_m4_v3(ob->object_to_world, vtan); + mul_mat3_m4_v3(ob->object_to_world().ptr(), vtan); copy_v3_v3(utan, nor); mul_v3_fl(utan, dot_v3v3(vtan, nor)); @@ -795,7 +795,7 @@ void psys_get_birth_coords( r_vel[1] = 2.0f * (psys_frand(psys, p + 11) - 0.5f); r_vel[2] = 2.0f * (psys_frand(psys, p + 12) - 0.5f); - mul_mat3_m4_v3(ob->object_to_world, r_vel); + mul_mat3_m4_v3(ob->object_to_world().ptr(), r_vel); normalize_v3(r_vel); } @@ -805,7 +805,7 @@ void psys_get_birth_coords( r_ave[1] = 2.0f * (psys_frand(psys, p + 14) - 0.5f); r_ave[2] = 2.0f * (psys_frand(psys, p + 15) - 0.5f); - mul_mat3_m4_v3(ob->object_to_world, r_ave); + mul_mat3_m4_v3(ob->object_to_world().ptr(), r_ave); normalize_v3(r_ave); } @@ -817,7 +817,7 @@ void psys_get_birth_coords( r_rot[3] = 2.0f * (psys_frand(psys, p + 19) - 0.5f); normalize_qt(r_rot); - mat4_to_quat(rot, ob->object_to_world); + mat4_to_quat(rot, ob->object_to_world().ptr()); mul_qt_qtqt(r_rot, r_rot, rot); } @@ -831,7 +831,7 @@ void psys_get_birth_coords( /* boids store direction in ave */ if (fabsf(nor[2]) == 1.0f) { - sub_v3_v3v3(state->ave, loc, ob->object_to_world[3]); + sub_v3_v3v3(state->ave, loc, ob->object_to_world().location()); normalize_v3(state->ave); } else { @@ -877,15 +877,15 @@ void psys_get_birth_coords( /* *emitter object orientation */ if (part->ob_vel[0] != 0.0f) { - normalize_v3_v3(vec, ob->object_to_world[0]); + normalize_v3_v3(vec, ob->object_to_world().ptr()[0]); madd_v3_v3fl(vel, vec, part->ob_vel[0]); } if (part->ob_vel[1] != 0.0f) { - normalize_v3_v3(vec, ob->object_to_world[1]); + normalize_v3_v3(vec, ob->object_to_world().ptr()[1]); madd_v3_v3fl(vel, vec, part->ob_vel[1]); } if (part->ob_vel[2] != 0.0f) { - normalize_v3_v3(vec, ob->object_to_world[2]); + normalize_v3_v3(vec, ob->object_to_world().ptr()[2]); madd_v3_v3fl(vel, vec, part->ob_vel[2]); } @@ -933,7 +933,7 @@ void psys_get_birth_coords( case PART_ROT_OB_X: case PART_ROT_OB_Y: case PART_ROT_OB_Z: - copy_v3_v3(rot_vec, ob->object_to_world[part->rotmode - PART_ROT_OB_X]); + copy_v3_v3(rot_vec, ob->object_to_world().ptr()[part->rotmode - PART_ROT_OB_X]); use_global_space = false; break; default: @@ -960,7 +960,7 @@ void psys_get_birth_coords( float q_obmat[4]; float q_imat[4]; - mat4_to_quat(q_obmat, ob->object_to_world); + mat4_to_quat(q_obmat, ob->object_to_world().ptr()); invert_qt_qt_normalized(q_imat, q_obmat); if (part->rotmode != PART_ROT_NOR_TAN) { @@ -3384,7 +3384,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim, use_hair = psys_hair_use_simulation(pa, max_length); psys_mat_hair_to_object(sim->ob, sim->psmd->mesh_final, psys->part->from, pa, hairmat); - mul_m4_m4m4(root_mat, sim->ob->object_to_world, hairmat); + mul_m4_m4m4(root_mat, sim->ob->object_to_world().ptr(), hairmat); normalize_m4(root_mat); bending_stiffness = std::clamp( @@ -3580,7 +3580,7 @@ static void save_hair(ParticleSimulationData *sim, float /*cfra*/) HairKey *key, *root; PARTICLE_P; - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); if (psys->totpart == 0) { return; @@ -3603,7 +3603,7 @@ static void save_hair(ParticleSimulationData *sim, float /*cfra*/) /* convert from global to geometry space */ copy_v3_v3(key->co, pa->state.co); - mul_m4_v3(ob->world_to_object, key->co); + mul_m4_v3(ob->world_to_object().ptr(), key->co); if (pa->totkey) { sub_v3_v3(key->co, root->co); @@ -4414,7 +4414,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, mul_v3_v3(pa->state.co, scaleAbs); /* Match domain scale. */ - mul_m4_v3(ob->object_to_world, pa->state.co); + mul_m4_v3(ob->object_to_world().ptr(), pa->state.co); /* Add origin offset to particle position. */ zero_v3(tmp); @@ -5001,7 +5001,7 @@ void particle_system_update(Depsgraph *depsgraph, /* Save matrix for duplicators, * at render-time the actual dupli-object's matrix is used so don't update! */ - invert_m4_m4(psys->imat, ob->object_to_world); + invert_m4_m4(psys->imat, ob->object_to_world().ptr()); BKE_particle_batch_cache_dirty_tag(psys, BKE_PARTICLE_BATCH_DIRTY_ALL); } diff --git a/source/blender/blenkernel/intern/rigidbody.cc b/source/blender/blenkernel/intern/rigidbody.cc index f40e0b57491..ac8aa5cd2eb 100644 --- a/source/blender/blenkernel/intern/rigidbody.cc +++ b/source/blender/blenkernel/intern/rigidbody.cc @@ -685,7 +685,7 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol) corner_verts.data(), &volume, nullptr); - const float volume_scale = mat4_to_volume_scale(ob->object_to_world); + const float volume_scale = mat4_to_volume_scale(ob->object_to_world().ptr()); volume *= fabsf(volume_scale); } } @@ -811,7 +811,7 @@ static void rigidbody_validate_sim_object(RigidBodyWorld *rbw, Object *ob, bool return; } - mat4_to_loc_quat(loc, rot, ob->object_to_world); + mat4_to_loc_quat(loc, rot, ob->object_to_world().ptr()); rbo->shared->physics_object = RB_body_new( static_cast(rbo->shared->physics_shape), loc, rot); @@ -1032,7 +1032,7 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b rbc->physics_constraint = nullptr; } - mat4_to_loc_quat(loc, rot, ob->object_to_world); + mat4_to_loc_quat(loc, rot, ob->object_to_world().ptr()); if (rb1 && rb2) { switch (rbc->type) { @@ -1345,7 +1345,7 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, Object *ob, short type) rbo->mesh_source = RBO_MESH_DEFORM; /* set initial transform */ - mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world); + mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world().ptr()); /* flag cache as outdated */ BKE_rigidbody_cache_reset(rbw); @@ -1782,7 +1782,7 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Object *ob, RigidBodyO if (!(rbo->flag & RBO_FLAG_KINEMATIC)) { /* update scale for all non kinematic objects */ float new_scale[3], old_scale[3]; - mat4_to_size(new_scale, ob->object_to_world); + mat4_to_size(new_scale, ob->object_to_world().ptr()); RB_body_get_scale(static_cast(rbo->shared->physics_object), old_scale); /* Avoid updating collision shape AABBs if scale didn't change. */ @@ -1983,7 +1983,7 @@ static ListBase rigidbody_create_substep_data(RigidBodyWorld *rbw) copy_v4_v4(data->old_rot, rot); copy_v3_v3(data->old_scale, scale); - mat4_decompose(loc, rot, scale, ob->object_to_world); + mat4_decompose(loc, rot, scale, ob->object_to_world().ptr()); copy_v3_v3(data->new_pos, loc); copy_v4_v4(data->new_rot, rot); @@ -2158,15 +2158,15 @@ void BKE_rigidbody_sync_transforms(RigidBodyWorld *rbw, Object *ob, float ctime) quat_to_mat4(mat, rbo->orn); copy_v3_v3(mat[3], rbo->pos); - mat4_to_size(size, ob->object_to_world); + mat4_to_size(size, ob->object_to_world().ptr()); size_to_mat4(size_mat, size); mul_m4_m4m4(mat, mat, size_mat); - copy_m4_m4(ob->object_to_world, mat); + copy_m4_m4(ob->runtime->object_to_world.ptr(), mat); } /* otherwise set rigid body transform to current obmat */ else { - mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world); + mat4_to_loc_quat(rbo->pos, rbo->orn, ob->object_to_world().ptr()); } } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 63f61f82a6f..049a64c322d 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -2167,13 +2167,13 @@ int BKE_scene_base_iter_next( if (iter->dupli_refob != *ob) { if (iter->dupli_refob) { /* Restore previous object's real matrix. */ - copy_m4_m4(iter->dupli_refob->object_to_world, iter->omat); + copy_m4_m4(iter->dupli_refob->runtime->object_to_world.ptr(), iter->omat); } /* Backup new object's real matrix. */ iter->dupli_refob = *ob; - copy_m4_m4(iter->omat, iter->dupli_refob->object_to_world); + copy_m4_m4(iter->omat, iter->dupli_refob->object_to_world().ptr()); } - copy_m4_m4((*ob)->object_to_world, iter->dupob->mat); + copy_m4_m4((*ob)->runtime->object_to_world.ptr(), iter->dupob->mat); iter->dupob = iter->dupob->next; } @@ -2183,7 +2183,7 @@ int BKE_scene_base_iter_next( if (iter->dupli_refob) { /* Restore last object's real matrix. */ - copy_m4_m4(iter->dupli_refob->object_to_world, iter->omat); + copy_m4_m4(iter->dupli_refob->runtime->object_to_world.ptr(), iter->omat); iter->dupli_refob = nullptr; } diff --git a/source/blender/blenkernel/intern/softbody.cc b/source/blender/blenkernel/intern/softbody.cc index a96cfbdb59c..3c2974078e5 100644 --- a/source/blender/blenkernel/intern/softbody.cc +++ b/source/blender/blenkernel/intern/softbody.cc @@ -2658,7 +2658,7 @@ static void springs_from_mesh(Object *ob) bp = ob->soft->bpoint; for (a = 0; a < mesh->verts_num; a++, bp++) { copy_v3_v3(bp->origS, positions[a]); - mul_m4_v3(ob->object_to_world, bp->origS); + mul_m4_v3(ob->object_to_world().ptr(), bp->origS); } } /* recalculate spring length for meshes here */ @@ -2821,9 +2821,9 @@ static float globallen(float *v1, float *v2, Object *ob) { float p1[3], p2[3]; copy_v3_v3(p1, v1); - mul_m4_v3(ob->object_to_world, p1); + mul_m4_v3(ob->object_to_world().ptr(), p1); copy_v3_v3(p2, v2); - mul_m4_v3(ob->object_to_world, p2); + mul_m4_v3(ob->object_to_world().ptr(), p2); return len_v3v3(p1, p2); } @@ -3085,13 +3085,13 @@ static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, SB_estimate_transform(ob, sb->lcom, sb->lrot, sb->lscale); } /* Inverse matrix is not up to date. */ - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); for (a = 0; a < numVerts; a++, bp++) { copy_v3_v3(vertexCos[a], bp->pos); if (local == 0) { - mul_m4_v3(ob->world_to_object, - vertexCos[a]); /* softbody is in global coords, baked optionally not */ + /* softbody is in global coords, baked optionally not */ + mul_m4_v3(ob->world_to_object().ptr(), vertexCos[a]); } } } @@ -3238,7 +3238,7 @@ static void softbody_update_positions(Object *ob, /* copy the position of the goals at desired end time */ copy_v3_v3(bp->origE, vertexCos[a]); /* vertexCos came from local world, go global */ - mul_m4_v3(ob->object_to_world, bp->origE); + mul_m4_v3(ob->object_to_world().ptr(), bp->origE); /* just to be save give bp->origT a defined value * will be calculated in interpolate_exciter() */ copy_v3_v3(bp->origT, bp->origE); @@ -3295,7 +3295,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int for (a = 0, bp = sb->bpoint; a < numVerts; a++, bp++) { copy_v3_v3(bp->pos, vertexCos[a]); - mul_m4_v3(ob->object_to_world, bp->pos); /* Yep, soft-body is global coords. */ + mul_m4_v3(ob->object_to_world().ptr(), bp->pos); /* Yep, soft-body is global coords. */ copy_v3_v3(bp->origS, bp->pos); copy_v3_v3(bp->origE, bp->pos); copy_v3_v3(bp->origT, bp->pos); diff --git a/source/blender/blenkernel/intern/sound.cc b/source/blender/blenkernel/intern/sound.cc index 8908f1a0cfc..f330abf460c 100644 --- a/source/blender/blenkernel/intern/sound.cc +++ b/source/blender/blenkernel/intern/sound.cc @@ -1157,9 +1157,10 @@ static void sound_update_base(Scene *scene, Object *object, void *new_set) AUD_SequenceEntry_setConeAngleInner(strip->speaker_handle, speaker->cone_angle_inner); AUD_SequenceEntry_setConeVolumeOuter(strip->speaker_handle, speaker->cone_volume_outer); - mat4_to_quat(quat, object->object_to_world); + mat4_to_quat(quat, object->object_to_world().ptr()); + blender::float3 location = object->object_to_world().location(); AUD_SequenceEntry_setAnimationData( - strip->speaker_handle, AUD_AP_LOCATION, scene->r.cfra, object->object_to_world[3], 1); + strip->speaker_handle, AUD_AP_LOCATION, scene->r.cfra, location, 1); AUD_SequenceEntry_setAnimationData( strip->speaker_handle, AUD_AP_ORIENTATION, scene->r.cfra, quat, 1); AUD_SequenceEntry_setAnimationData( @@ -1199,9 +1200,9 @@ void BKE_sound_update_scene(Depsgraph *depsgraph, Scene *scene) } if (scene->camera) { - mat4_to_quat(quat, scene->camera->object_to_world); - AUD_Sequence_setAnimationData( - scene->sound_scene, AUD_AP_LOCATION, scene->r.cfra, scene->camera->object_to_world[3], 1); + mat4_to_quat(quat, scene->camera->object_to_world().ptr()); + blender::float3 location = scene->camera->object_to_world().location(); + AUD_Sequence_setAnimationData(scene->sound_scene, AUD_AP_LOCATION, scene->r.cfra, location, 1); AUD_Sequence_setAnimationData(scene->sound_scene, AUD_AP_ORIENTATION, scene->r.cfra, quat, 1); } diff --git a/source/blender/blenkernel/intern/vfont.cc b/source/blender/blenkernel/intern/vfont.cc index 112670f0f3a..445566be346 100644 --- a/source/blender/blenkernel/intern/vfont.cc +++ b/source/blender/blenkernel/intern/vfont.cc @@ -1423,14 +1423,14 @@ static bool vfont_to_curve(Object *ob, float timeofs, sizefac; if (ob != nullptr) { - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); } else { unit_m4(imat); } copy_m3_m4(imat3, imat); - copy_m3_m4(cmat, cu->textoncurve->object_to_world); + copy_m3_m4(cmat, cu->textoncurve->object_to_world().ptr()); mul_m3_m3m3(cmat, cmat, imat3); sizefac = normalize_v3(cmat[0]) / font_size; diff --git a/source/blender/blenkernel/particle_private.h b/source/blender/blenkernel/particle_private.h index 551d89e4d47..144c67ef449 100644 --- a/source/blender/blenkernel/particle_private.h +++ b/source/blender/blenkernel/particle_private.h @@ -38,7 +38,7 @@ void do_kink(ParticleKey *state, float flat, short type, short axis, - float obmat[4][4], + const float obmat[4][4], int smooth_start); float do_clump(ParticleKey *state, const float par_co[3], diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 2846d315db4..2b6eb7c5c90 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -621,7 +621,8 @@ void BLI_space_transform_apply_normal(const struct SpaceTransform *data, float n void BLI_space_transform_invert_normal(const struct SpaceTransform *data, float no[3]); #define BLI_SPACE_TRANSFORM_SETUP(data, local, target) \ - BLI_space_transform_from_matrices((data), (local)->object_to_world, (target)->object_to_world) + BLI_space_transform_from_matrices( \ + (data), (local)->object_to_world().ptr(), (target)->object_to_world().ptr()) /** \} */ diff --git a/source/blender/blenlib/BLI_uvproject.h b/source/blender/blenlib/BLI_uvproject.h index 1ee807813c2..06c34bd09a7 100644 --- a/source/blender/blenlib/BLI_uvproject.h +++ b/source/blender/blenlib/BLI_uvproject.h @@ -17,11 +17,11 @@ struct ProjCameraInfo; /** * Create UV info from the camera, needs to be freed. * - * \param rotmat: can be `obedit->object_to_world` when uv project is used. + * \param rotmat: can be `obedit->object_to_world().ptr()` when uv project is used. * \param winx, winy: can be from `scene->r.xsch / ysch`. */ struct ProjCameraInfo *BLI_uvproject_camera_info(struct Object *ob, - float rotmat[4][4], + const float rotmat[4][4], float winx, float winy); diff --git a/source/blender/blenlib/intern/uvproject.cc b/source/blender/blenlib/intern/uvproject.cc index e15f517cdf2..5ef767f4648 100644 --- a/source/blender/blenlib/intern/uvproject.cc +++ b/source/blender/blenlib/intern/uvproject.cc @@ -121,7 +121,10 @@ void BLI_uvproject_from_view(float target[2], target[1] = (y + target[1]) / winy; } -ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float rotmat[4][4], float winx, float winy) +ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, + const float rotmat[4][4], + float winx, + float winy) { ProjCameraInfo uci; Camera *camera = static_cast(ob->data); @@ -133,7 +136,7 @@ ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float rotmat[4][4], float uci.camsize = uci.do_persp ? tanf(uci.camangle) : camera->ortho_scale; /* account for scaled cameras */ - copy_m4_m4(uci.caminv, ob->object_to_world); + copy_m4_m4(uci.caminv, ob->object_to_world().ptr()); normalize_m4(uci.caminv); if (invert_m4(uci.caminv)) { diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index c7665dccfc0..0e2c865356d 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -180,8 +180,9 @@ bool deg_iterator_duplis_step(DEGObjectIterData *data) bool is_neg_scale = is_negative_m4(dob->mat); SET_FLAG_FROM_TEST(data->temp_dupli_object.transflag, is_neg_scale, OB_NEG_SCALE); - copy_m4_m4(data->temp_dupli_object.object_to_world, dob->mat); - invert_m4_m4(data->temp_dupli_object.world_to_object, data->temp_dupli_object.object_to_world); + copy_m4_m4(data->temp_dupli_object.runtime->object_to_world.ptr(), dob->mat); + invert_m4_m4(data->temp_dupli_object.runtime->world_to_object.ptr(), + data->temp_dupli_object.object_to_world().ptr()); data->next_object = &data->temp_dupli_object; BLI_assert(deg::deg_validate_copy_on_write_datablock(&data->temp_dupli_object.id)); return true; diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 13a766a31ec..7b9d81a7ca2 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -262,7 +262,7 @@ void invalidate_tagged_evaluated_transform(ID *id) switch (id_type) { case ID_OB: { Object *object = (Object *)id; - copy_vn_fl((float *)object->object_to_world, 16, NAN); + copy_vn_fl((float *)object->object_to_world().ptr(), 16, NAN); break; } default: diff --git a/source/blender/draw/engines/basic/basic_engine.cc b/source/blender/draw/engines/basic/basic_engine.cc index d3b1ed4235b..07c77f9c5ea 100644 --- a/source/blender/draw/engines/basic/basic_engine.cc +++ b/source/blender/draw/engines/basic/basic_engine.cc @@ -233,7 +233,7 @@ static void basic_cache_populate(void *vedata, Object *ob) if (G.debug_value == 889 && ob->sculpt && BKE_object_sculpt_pbvh_get(ob)) { int debug_node_nr = 0; - DRW_debug_modelmat(ob->object_to_world); + DRW_debug_modelmat(ob->object_to_world().ptr()); BKE_pbvh_draw_debug_cb(BKE_object_sculpt_pbvh_get(ob), DRW_sculpt_debug_cb, &debug_node_nr); } } diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.cc b/source/blender/draw/engines/eevee/eevee_lightprobes.cc index fed51350578..6bb442c89f0 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.cc +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.cc @@ -424,7 +424,7 @@ static bool eevee_lightprobes_culling_test(Object *ob) const float max[3] = {1.0f, 1.0f, 1.0f}; BKE_boundbox_init_from_minmax(&bbox, min, max); - copy_m4_m4(tmp, ob->object_to_world); + copy_m4_m4(tmp, ob->object_to_world().ptr()); normalize_v3(tmp[2]); mul_v3_fl(tmp[2], probe->distinf); @@ -467,7 +467,7 @@ void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata /* Debug Display */ DRWCallBuffer *grp = vedata->stl->g_data->planar_display_shgrp; if (grp && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) { - DRW_buffer_add_entry(grp, &pinfo->num_planar, ob->object_to_world); + DRW_buffer_add_entry(grp, &pinfo->num_planar, ob->object_to_world().ptr()); } pinfo->num_planar++; @@ -510,30 +510,30 @@ void EEVEE_lightprobes_grid_data_from_object(Object *ob, EEVEE_LightGrid *egrid, mul_v3_v3fl(half_cell_dim, cell_dim, 0.5f); /* Matrix converting world space to cell ranges. */ - invert_m4_m4(egrid->mat, ob->object_to_world); + invert_m4_m4(egrid->mat, ob->object_to_world().ptr()); /* First cell. */ copy_v3_fl(egrid->corner, -1.0f); add_v3_v3(egrid->corner, half_cell_dim); - mul_m4_v3(ob->object_to_world, egrid->corner); + mul_m4_v3(ob->object_to_world().ptr(), egrid->corner); /* Opposite neighbor cell. */ copy_v3_fl3(egrid->increment_x, cell_dim[0], 0.0f, 0.0f); add_v3_v3(egrid->increment_x, half_cell_dim); add_v3_fl(egrid->increment_x, -1.0f); - mul_m4_v3(ob->object_to_world, egrid->increment_x); + mul_m4_v3(ob->object_to_world().ptr(), egrid->increment_x); sub_v3_v3(egrid->increment_x, egrid->corner); copy_v3_fl3(egrid->increment_y, 0.0f, cell_dim[1], 0.0f); add_v3_v3(egrid->increment_y, half_cell_dim); add_v3_fl(egrid->increment_y, -1.0f); - mul_m4_v3(ob->object_to_world, egrid->increment_y); + mul_m4_v3(ob->object_to_world().ptr(), egrid->increment_y); sub_v3_v3(egrid->increment_y, egrid->corner); copy_v3_fl3(egrid->increment_z, 0.0f, 0.0f, cell_dim[2]); add_v3_v3(egrid->increment_z, half_cell_dim); add_v3_fl(egrid->increment_z, -1.0f); - mul_m4_v3(ob->object_to_world, egrid->increment_z); + mul_m4_v3(ob->object_to_world().ptr(), egrid->increment_z); sub_v3_v3(egrid->increment_z, egrid->corner); /* Visibility bias */ @@ -549,7 +549,7 @@ void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprob LightProbe *probe = (LightProbe *)ob->data; /* Update transforms */ - copy_v3_v3(eprobe->position, ob->object_to_world[3]); + copy_v3_v3(eprobe->position, ob->object_to_world().location()); /* Attenuation */ eprobe->attenuation_type = probe->attenuation_type; @@ -557,7 +557,7 @@ void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprob unit_m4(eprobe->attenuationmat); scale_m4_fl(eprobe->attenuationmat, probe->distinf); - mul_m4_m4m4(eprobe->attenuationmat, ob->object_to_world, eprobe->attenuationmat); + mul_m4_m4m4(eprobe->attenuationmat, ob->object_to_world().ptr(), eprobe->attenuationmat); invert_m4(eprobe->attenuationmat); /* Parallax */ @@ -572,7 +572,7 @@ void EEVEE_lightprobes_cube_data_from_object(Object *ob, EEVEE_LightProbe *eprob scale_m4_fl(eprobe->parallaxmat, probe->distinf); } - mul_m4_m4m4(eprobe->parallaxmat, ob->object_to_world, eprobe->parallaxmat); + mul_m4_m4m4(eprobe->parallaxmat, ob->object_to_world().ptr(), eprobe->parallaxmat); invert_m4(eprobe->parallaxmat); } @@ -588,8 +588,8 @@ void EEVEE_lightprobes_planar_data_from_object(Object *ob, vis_test->cached = false; /* Computing mtx : matrix that mirror position around object's XY plane. */ - normalize_m4_m4(normat, ob->object_to_world); /* object > world */ - invert_m4_m4(imat, normat); /* world > object */ + normalize_m4_m4(normat, ob->object_to_world().ptr()); /* object > world */ + invert_m4_m4(imat, normat); /* world > object */ /* XY reflection plane */ imat[0][2] = -imat[0][2]; imat[1][2] = -imat[1][2]; @@ -598,38 +598,39 @@ void EEVEE_lightprobes_planar_data_from_object(Object *ob, mul_m4_m4m4(eplanar->mtx, normat, imat); /* world > object > mirrored obj > world */ /* Compute clip plane equation / normal. */ - copy_v3_v3(eplanar->plane_equation, ob->object_to_world[2]); + copy_v3_v3(eplanar->plane_equation, ob->object_to_world().ptr()[2]); normalize_v3(eplanar->plane_equation); /* plane normal */ - eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, ob->object_to_world[3]); + eplanar->plane_equation[3] = -dot_v3v3(eplanar->plane_equation, + ob->object_to_world().location()); eplanar->clipsta = probe->clipsta; /* Compute XY clip planes. */ - normalize_v3_v3(eplanar->clip_vec_x, ob->object_to_world[0]); - normalize_v3_v3(eplanar->clip_vec_y, ob->object_to_world[1]); + normalize_v3_v3(eplanar->clip_vec_x, ob->object_to_world().ptr()[0]); + normalize_v3_v3(eplanar->clip_vec_y, ob->object_to_world().ptr()[1]); float vec[3] = {0.0f, 0.0f, 0.0f}; vec[0] = 1.0f; vec[1] = 0.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ eplanar->clip_edge_x_pos = dot_v3v3(eplanar->clip_vec_x, vec); vec[0] = 0.0f; vec[1] = 1.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ eplanar->clip_edge_y_pos = dot_v3v3(eplanar->clip_vec_y, vec); vec[0] = -1.0f; vec[1] = 0.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ eplanar->clip_edge_x_neg = dot_v3v3(eplanar->clip_vec_x, vec); vec[0] = 0.0f; vec[1] = -1.0f; vec[2] = 0.0f; - mul_m4_v3(ob->object_to_world, vec); /* Point on the edge */ + mul_m4_v3(ob->object_to_world().ptr(), vec); /* Point on the edge */ eplanar->clip_edge_y_neg = dot_v3v3(eplanar->clip_vec_y, vec); /* Facing factors */ diff --git a/source/blender/draw/engines/eevee/eevee_lights.cc b/source/blender/draw/engines/eevee/eevee_lights.cc index b4fdc7bfa0f..cb21b6c4b2a 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.cc +++ b/source/blender/draw/engines/eevee/eevee_lights.cc @@ -144,7 +144,7 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli) const float light_threshold = draw_ctx->scene->eevee.light_threshold; /* Position */ - copy_v3_v3(evli->position, ob->object_to_world[3]); + copy_v3_v3(evli->position, ob->object_to_world().location()); /* Color */ copy_v3_v3(evli->color, &la->r); @@ -165,7 +165,7 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli) evli->invsqrdist_volume = 1.0f / max_ff(1e-4f, square_f(att_radius_volume)); /* Vectors */ - normalize_m4_m4_ex(mat, ob->object_to_world, scale); + normalize_m4_m4_ex(mat, ob->object_to_world().ptr(), scale); copy_v3_v3(evli->forwardvec, mat[2]); normalize_v3(evli->forwardvec); negate_v3(evli->forwardvec); diff --git a/source/blender/draw/engines/eevee/eevee_materials.cc b/source/blender/draw/engines/eevee/eevee_materials.cc index 2ab9765cbe6..0664301f9f4 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.cc +++ b/source/blender/draw/engines/eevee/eevee_materials.cc @@ -904,7 +904,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, if (G.debug_value == 889 && ob->sculpt && BKE_object_sculpt_pbvh_get(ob)) { int debug_node_nr = 0; - DRW_debug_modelmat(ob->object_to_world); + DRW_debug_modelmat(ob->object_to_world().ptr()); BKE_pbvh_draw_debug_cb( BKE_object_sculpt_pbvh_get(ob), DRW_sculpt_debug_cb, &debug_node_nr); } diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.cc b/source/blender/draw/engines/eevee/eevee_motion_blur.cc index 5aaf3457197..cdf74268314 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.cc +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.cc @@ -296,7 +296,7 @@ void EEVEE_motion_blur_curves_cache_populate(EEVEE_ViewLayerData * /*sldata*/, int mb_step = effects->motion_blur_step; /* Store transform. */ - copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world); + copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world().ptr()); EEVEE_HairMotionData *mb_curves = EEVEE_motion_blur_curves_data_get(mb_data); @@ -367,7 +367,7 @@ void EEVEE_motion_blur_cache_populate(EEVEE_ViewLayerData * /*sldata*/, if (mb_data) { int mb_step = effects->motion_blur_step; /* Store transform. */ - copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world); + copy_m4_m4(mb_data->obmat[mb_step], ob->object_to_world().ptr()); EEVEE_GeometryMotionData *mb_geom = EEVEE_motion_blur_geometry_data_get(mb_data); diff --git a/source/blender/draw/engines/eevee/eevee_shadows.cc b/source/blender/draw/engines/eevee/eevee_shadows.cc index 5c21a8cceee..1b875eace72 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.cc +++ b/source/blender/draw/engines/eevee/eevee_shadows.cc @@ -163,7 +163,7 @@ void EEVEE_shadows_caster_register(EEVEE_ViewLayerData *sldata, Object *ob) for (int i = 0; i < 8; i++) { float vec[3]; copy_v3_v3(vec, bb.vec[i]); - mul_m4_v3(ob->object_to_world, vec); + mul_m4_v3(ob->object_to_world().ptr(), vec); minmax_v3v3_v3(min, max, vec); } diff --git a/source/blender/draw/engines/eevee/eevee_volumes.cc b/source/blender/draw/engines/eevee/eevee_volumes.cc index 791ec1f7a6f..ef942a2e0b8 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.cc +++ b/source/blender/draw/engines/eevee/eevee_volumes.cc @@ -305,7 +305,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata, } float size[3]; - mat4_to_size(size, ob->object_to_world); + mat4_to_size(size, ob->object_to_world().ptr()); /* Check if any of the axes have 0 length. (see #69070) */ const float epsilon = 1e-8f; if ((size[0] < epsilon) || (size[1] < epsilon) || (size[2] < epsilon)) { diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index 6a9f1e04292..695db83bbb5 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -239,7 +239,7 @@ void Instance::object_sync(Object *ob) if (partsys_is_visible && ob != DRW_context_state_get()->object_edit) { auto sync_hair = [&](ObjectHandle hair_handle, ModifierData &md, ParticleSystem &particle_sys) { - ResourceHandle _res_handle = manager->resource_handle(float4x4(ob->object_to_world)); + ResourceHandle _res_handle = manager->resource_handle(ob->object_to_world()); sync.sync_curves(ob, hair_handle, _res_handle, ob_ref, &md, &particle_sys); }; foreach_hair_particle_handle(ob, ob_handle, sync_hair); diff --git a/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc b/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc index f42525ddfb7..5ce1336846a 100644 --- a/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc +++ b/source/blender/draw/engines/eevee_next/eevee_irradiance_cache.cc @@ -814,7 +814,7 @@ void IrradianceBake::surfels_create(const Object &probe_object) const ::LightProbe *lightprobe = static_cast<::LightProbe *>(probe_object.data); int3 grid_resolution = int3(&lightprobe->grid_resolution_x); - float4x4 grid_local_to_world = invert(float4x4(probe_object.world_to_object)); + float4x4 grid_local_to_world = invert(probe_object.world_to_object()); /* TODO(fclem): Options. */ capture_info_buf_.capture_world_direct = capture_world_; @@ -831,7 +831,7 @@ void IrradianceBake::surfels_create(const Object &probe_object) dispatch_per_grid_sample_ = math::divide_ceil(grid_resolution, int3(IRRADIANCE_GRID_GROUP_SIZE)); capture_info_buf_.irradiance_grid_size = grid_resolution; capture_info_buf_.irradiance_grid_local_to_world = grid_local_to_world; - capture_info_buf_.irradiance_grid_world_to_local = float4x4(probe_object.world_to_object); + capture_info_buf_.irradiance_grid_world_to_local = probe_object.world_to_object(); capture_info_buf_.irradiance_grid_world_to_local_rotation = float4x4( invert(normalize(float3x3(grid_local_to_world)))); @@ -927,7 +927,7 @@ void IrradianceBake::surfels_create(const Object &probe_object) float epsilon = 1.0f / surfel_density_; scene_min -= epsilon; scene_max += epsilon; - surfel_raster_views_sync(scene_min, scene_max, float4x4(probe_object.object_to_world)); + surfel_raster_views_sync(scene_min, scene_max, probe_object.object_to_world()); DRW_stats_group_end(); diff --git a/source/blender/draw/engines/eevee_next/eevee_light.cc b/source/blender/draw/engines/eevee_next/eevee_light.cc index 26ee49d5e45..4a9d8d09321 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.cc +++ b/source/blender/draw/engines/eevee_next/eevee_light.cc @@ -62,7 +62,7 @@ void Light::sync(ShadowModule &shadows, const Object *ob, float threshold) this->influence_radius_invsqr_volume = 1.0f / square_f(max_ff(influence_radius_volume, 1e-8f)); this->color = float3(&la->r) * la->energy; - normalize_m4_m4_ex(this->object_mat.ptr(), ob->object_to_world, scale); + normalize_m4_m4_ex(this->object_mat.ptr(), ob->object_to_world().ptr(), scale); /* Make sure we have consistent handedness (in case of negatively scaled Z axis). */ float3 cross = math::cross(float3(this->_right), float3(this->_up)); if (math::dot(cross, float3(this->_back)) < 0.0f) { diff --git a/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc b/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc index 66483323fac..82e1bbde9d6 100644 --- a/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc +++ b/source/blender/draw/engines/eevee_next/eevee_lightprobe.cc @@ -83,7 +83,7 @@ void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle) grid.initialized = true; grid.updated = true; grid.surfel_density = static_cast(ob->data)->surfel_density; - grid.object_to_world = float4x4(ob->object_to_world); + grid.object_to_world = ob->object_to_world(); grid.world_to_object = float4x4( math::normalize(math::transpose(float3x3(grid.object_to_world)))); @@ -143,8 +143,7 @@ void LightProbeModule::sync_sphere(const Object *ob, ObjectHandle &handle) cube.influence_shape = to_eevee_shape(light_probe.attenuation_type); cube.parallax_shape = to_eevee_shape(light_probe.parallax_type); - float4x4 object_to_world = math::scale(float4x4(ob->object_to_world), - float3(influence_distance)); + float4x4 object_to_world = math::scale(ob->object_to_world(), float3(influence_distance)); cube.location = object_to_world.location(); cube.volume = math::abs(math::determinant(object_to_world)); cube.world_to_probe_transposed = float3x4(math::transpose(math::invert(object_to_world))); @@ -167,7 +166,7 @@ void LightProbeModule::sync_planar(const Object *ob, ObjectHandle &handle) plane.initialized = true; plane.updated = true; - plane.plane_to_world = float4x4(ob->object_to_world); + plane.plane_to_world = ob->object_to_world(); plane.plane_to_world.z_axis() = math::normalize(plane.plane_to_world.z_axis()) * light_probe->distinf; plane.world_to_plane = math::invert(plane.plane_to_world); diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index 90b0c0e75d8..95c66a4eb21 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -368,7 +368,7 @@ PassMain::Sub *ForwardPipeline::prepass_transparent_add(const Object *ob, state |= DRW_STATE_CULL_BACK; } has_transparent_ = true; - float sorting_value = math::dot(float3(ob->object_to_world[3]), camera_forward_); + float sorting_value = math::dot(float3(ob->object_to_world().location()), camera_forward_); PassMain::Sub *pass = &transparent_ps_.sub(GPU_material_get_name(gpumat), sorting_value); pass->state_set(state); pass->material_set(*inst_.manager, gpumat); @@ -384,7 +384,7 @@ PassMain::Sub *ForwardPipeline::material_transparent_add(const Object *ob, state |= DRW_STATE_CULL_BACK; } has_transparent_ = true; - float sorting_value = math::dot(float3(ob->object_to_world[3]), camera_forward_); + float sorting_value = math::dot(float3(ob->object_to_world().location()), camera_forward_); PassMain::Sub *pass = &transparent_ps_.sub(GPU_material_get_name(gpumat), sorting_value); pass->state_set(state); pass->material_set(*inst_.manager, gpumat); @@ -1040,7 +1040,7 @@ GridAABB VolumePipeline::grid_aabb_from_object(Object *ob) BoundBox bb; BKE_boundbox_init_from_minmax(&bb, bounds.min, bounds.max); for (float3 l_corner : bb.vec) { - float3 w_corner = math::transform_point(float4x4(ob->object_to_world), l_corner); + float3 w_corner = math::transform_point(ob->object_to_world(), l_corner); /* Note that this returns the nearest cell corner coordinate. * So sub-froxel AABB will effectively return the same coordinate * for each corner (making it empty and skipped) unless it diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index df6541d09f3..bf44a428ecd 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -154,18 +154,17 @@ bool VelocityModule::step_object_sync(Object *ob, vel.obj.ofs[step_] = object_steps_usage[step_]++; vel.obj.resource_id = resource_handle.resource_index(); vel.id = object_key.hash(); - object_steps[step_]->get_or_resize(vel.obj.ofs[step_]) = float4x4_view(ob->object_to_world); + object_steps[step_]->get_or_resize(vel.obj.ofs[step_]) = ob->object_to_world(); if (step_ == STEP_CURRENT) { /* Replace invalid steps. Can happen if object was hidden in one of those steps. */ if (vel.obj.ofs[STEP_PREVIOUS] == -1) { vel.obj.ofs[STEP_PREVIOUS] = object_steps_usage[STEP_PREVIOUS]++; - object_steps[STEP_PREVIOUS]->get_or_resize(vel.obj.ofs[STEP_PREVIOUS]) = float4x4_view( - ob->object_to_world); + object_steps[STEP_PREVIOUS]->get_or_resize( + vel.obj.ofs[STEP_PREVIOUS]) = ob->object_to_world(); } if (vel.obj.ofs[STEP_NEXT] == -1) { vel.obj.ofs[STEP_NEXT] = object_steps_usage[STEP_NEXT]++; - object_steps[STEP_NEXT]->get_or_resize(vel.obj.ofs[STEP_NEXT]) = float4x4_view( - ob->object_to_world); + object_steps[STEP_NEXT]->get_or_resize(vel.obj.ofs[STEP_NEXT]) = ob->object_to_world(); } } diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc index 906dc37a07e..dd7c151b93e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.cc @@ -44,9 +44,9 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) tgp_ob->layers.first = tgp_ob->layers.last = nullptr; tgp_ob->vfx.first = tgp_ob->vfx.last = nullptr; - tgp_ob->camera_z = dot_v3v3(pd->camera_z_axis, ob->object_to_world[3]); + tgp_ob->camera_z = dot_v3v3(pd->camera_z_axis, ob->object_to_world().location()); tgp_ob->is_drawmode3d = (gpd->draw_mode == GP_DRAWMODE_3D) || pd->draw_depth_only; - tgp_ob->object_scale = mat4_to_scale(ob->object_to_world); + tgp_ob->object_scale = mat4_to_scale(ob->object_to_world().ptr()); /* Check if any material with holdout flag enabled. */ tgp_ob->do_mat_holdout = false; @@ -78,7 +78,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) add_v3_fl(size, 1e-8f); rescale_m4(mat, size); /* BBox space to World. */ - mul_m4_m4m4(mat, ob->object_to_world, mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); if (DRW_view_is_persp_get(nullptr)) { /* BBox center to camera vector. */ sub_v3_v3v3(tgp_ob->plane_normal, pd->camera_pos, mat[3]); @@ -103,9 +103,9 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) unit_m4(tgp_ob->plane_mat); copy_v3_v3(tgp_ob->plane_mat[2], tgp_ob->plane_normal); orthogonalize_m4(tgp_ob->plane_mat, 2); - mul_mat3_m4_v3(ob->object_to_world, size); + mul_mat3_m4_v3(ob->object_to_world().ptr(), size); float radius = len_v3(size); - mul_m4_v3(ob->object_to_world, center); + mul_m4_v3(ob->object_to_world().ptr(), center); rescale_m4(tgp_ob->plane_mat, blender::float3{radius, radius, radius}); copy_v3_v3(tgp_ob->plane_mat[3], center); diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc index 4b45b53e355..d84dfc44612 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc @@ -378,27 +378,27 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob) float(*mat)[4] = reinterpret_cast(&gp_light->right); if (la->type == LA_SPOT) { - copy_m4_m4(mat, ob->world_to_object); + copy_m4_m4(mat, ob->world_to_object().ptr()); gp_light->type = GP_LIGHT_TYPE_SPOT; gp_light->spot_size = cosf(la->spotsize * 0.5f); gp_light->spot_blend = (1.0f - gp_light->spot_size) * la->spotblend; } else if (la->type == LA_AREA) { /* Simulate area lights using a spot light. */ - normalize_m4_m4(mat, ob->object_to_world); + normalize_m4_m4(mat, ob->object_to_world().ptr()); invert_m4(mat); gp_light->type = GP_LIGHT_TYPE_SPOT; gp_light->spot_size = cosf(M_PI_2); gp_light->spot_blend = (1.0f - gp_light->spot_size) * 1.0f; } else if (la->type == LA_SUN) { - normalize_v3_v3(gp_light->forward, ob->object_to_world[2]); + normalize_v3_v3(gp_light->forward, ob->object_to_world().ptr()[2]); gp_light->type = GP_LIGHT_TYPE_SUN; } else { gp_light->type = GP_LIGHT_TYPE_POINT; } - copy_v4_v4(gp_light->position, ob->object_to_world[3]); + copy_v4_v4(gp_light->position, ob->object_to_world().location()); copy_v3_v3(gp_light->color, &la->r); mul_v3_fl(gp_light->color, la->energy * light_power_get(la)); diff --git a/source/blender/draw/engines/gpencil/gpencil_light.hh b/source/blender/draw/engines/gpencil/gpencil_light.hh index 7b4f4cc2308..45eb0434513 100644 --- a/source/blender/draw/engines/gpencil/gpencil_light.hh +++ b/source/blender/draw/engines/gpencil/gpencil_light.hh @@ -78,25 +78,25 @@ class LightModule { light.type = GP_LIGHT_TYPE_SPOT; light.spot_size = cosf(la->spotsize * 0.5f); light.spot_blend = (1.0f - light.spot_size) * la->spotblend; - mat = float4x4(ob->world_to_object); + mat = ob->world_to_object(); break; case LA_AREA: /* Simulate area lights using a spot light. */ light.type = GP_LIGHT_TYPE_SPOT; light.spot_size = cosf(M_PI_2); light.spot_blend = (1.0f - light.spot_size) * 1.0f; - normalize_m4_m4(mat.ptr(), ob->object_to_world); + normalize_m4_m4(mat.ptr(), ob->object_to_world().ptr()); invert_m4(mat.ptr()); break; case LA_SUN: - light.forward = math::normalize(float3(ob->object_to_world[2])); + light.forward = math::normalize(float3(ob->object_to_world().ptr()[2])); light.type = GP_LIGHT_TYPE_SUN; break; default: light.type = GP_LIGHT_TYPE_POINT; break; } - light.position = float3(object_ref.object->object_to_world[3]); + light.position = float3(object_ref.object->object_to_world().location()); light.color = float3(la->r, la->g, la->b) * (la->energy * light_power); lights_buf_.append(light); diff --git a/source/blender/draw/engines/gpencil/gpencil_object.hh b/source/blender/draw/engines/gpencil/gpencil_object.hh index dc172957694..71f3963cdad 100644 --- a/source/blender/draw/engines/gpencil/gpencil_object.hh +++ b/source/blender/draw/engines/gpencil/gpencil_object.hh @@ -139,7 +139,7 @@ class ObjectModule { } /* Order rendering using camera Z distance. */ - float3 position = float3(object->object_to_world[3]); + float3 position = float3(object->object_to_world().location()); float camera_z = math::dot(position, camera_forward_); PassMain::Sub &object_subpass = main_ps.sub("GPObject", camera_z); @@ -292,7 +292,7 @@ class ObjectModule { const float3 center = midpoint(bounds->min, bounds->max); /* BBox space to World. */ - const float4x4 object_to_world = float4x4(object.object_to_world); + const float4x4 object_to_world = object.object_to_world(); float4x4 bbox_mat = object_to_world * from_loc_rot_scale(center, Quaternion::identity(), size); float3 plane_normal; diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc index 8de719e3517..65fa3a1ccfc 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.cc @@ -100,7 +100,7 @@ static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *ob, gpIterVfxData *it float winmat[4][4], persmat[4][4]; float blur_size[2] = {fx->radius[0], fx->radius[1]}; DRW_view_persmat_get(nullptr, persmat, false); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); if (fx->flag & FX_BLUR_DOF_MODE) { /* Compute circle of confusion size. */ @@ -112,7 +112,7 @@ static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *ob, gpIterVfxData *it DRW_view_winmat_get(nullptr, winmat, false); const float *vp_size = DRW_viewport_size_get(); float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world); + float scale = mat4_to_scale(ob->object_to_world().ptr()); float distance_factor = world_pixel_scale * scale * winmat[1][1] * vp_size[1] / w; mul_v2_fl(blur_size, distance_factor); } @@ -181,11 +181,11 @@ static void gpencil_vfx_rim(RimShaderFxData *fx, Object *ob, gpIterVfxData *iter const float *vp_size = DRW_viewport_size_get(); const float *vp_size_inv = DRW_viewport_invert_size_get(); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world); + float scale = mat4_to_scale(ob->object_to_world().ptr()); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(offset, distance_factor); mul_v2_v2(offset, vp_size_inv); @@ -256,8 +256,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat mul_v2_v2(pixel_size, vp_size_inv); /* Fixed pixelisation center from object center. */ - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); - mul_v3_m4v3(ob_center, persmat, ob->object_to_world[3]); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); + mul_v3_m4v3(ob_center, persmat, ob->object_to_world().location()); mul_v3_fl(ob_center, 1.0f / w); const bool use_antialiasing = ((fx->flag & FX_PIXEL_FILTER_NEAREST) == 0); @@ -268,7 +268,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world); + float scale = mat4_to_scale(ob->object_to_world().ptr()); mul_v2_fl(pixel_size, (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w); /* Center to texel */ @@ -324,8 +324,8 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData const float ratio = vp_size_inv[1] / vp_size_inv[0]; copy_v3_v3(rot_center, - (use_obj_pivot && fx->object) ? fx->object->object_to_world[3] : - ob->object_to_world[3]); + (use_obj_pivot && fx->object) ? fx->object->object_to_world().location() : + ob->object_to_world().location()); const float w = fabsf(mul_project_m4_v3_zfac(persmat, rot_center)); mul_v3_m4v3(rot_center, persmat, rot_center); @@ -333,7 +333,7 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world); + float scale = mat4_to_scale(ob->object_to_world().ptr()); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(offset, distance_factor); mul_v2_v2(offset, vp_size_inv); @@ -501,13 +501,13 @@ static void gpencil_vfx_wave(WaveShaderFxData *fx, Object *ob, gpIterVfxData *it const float *vp_size = DRW_viewport_size_get(); const float *vp_size_inv = DRW_viewport_invert_size_get(); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world[3])); - mul_v3_m4v3(wave_center, persmat, ob->object_to_world[3]); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->object_to_world().location())); + mul_v3_m4v3(wave_center, persmat, ob->object_to_world().location()); mul_v3_fl(wave_center, 1.0f / w); /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(ob->object_to_world); + float scale = mat4_to_scale(ob->object_to_world().ptr()); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; wave_center[0] = wave_center[0] * 0.5f + 0.5f; @@ -558,7 +558,7 @@ static void gpencil_vfx_swirl(SwirlShaderFxData *fx, Object * /*ob*/, gpIterVfxD DRW_view_persmat_get(nullptr, persmat, false); const float *vp_size = DRW_viewport_size_get(); - copy_v3_v3(swirl_center, fx->object->object_to_world[3]); + copy_v3_v3(swirl_center, fx->object->object_to_world().location()); const float w = fabsf(mul_project_m4_v3_zfac(persmat, swirl_center)); mul_v3_m4v3(swirl_center, persmat, swirl_center); @@ -566,7 +566,7 @@ static void gpencil_vfx_swirl(SwirlShaderFxData *fx, Object * /*ob*/, gpIterVfxD /* Modify by distance to camera and object scale. */ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(fx->object->object_to_world); + float scale = mat4_to_scale(fx->object->object_to_world().ptr()); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(swirl_center, 0.5f); diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.hh b/source/blender/draw/engines/gpencil/gpencil_vfx.hh index 2b22173f974..eacbc8617f1 100644 --- a/source/blender/draw/engines/gpencil/gpencil_vfx.hh +++ b/source/blender/draw/engines/gpencil/gpencil_vfx.hh @@ -217,7 +217,7 @@ class VfxModule { /* TODO(fclem): Replace by draw::View. */ DRW_view_persmat_get(nullptr, persmat, false); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, object->object_to_world[3])); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, object->object_to_world().location())); if (fx.flag & FX_BLUR_DOF_MODE) { /* Compute circle of confusion size. */ @@ -232,7 +232,7 @@ class VfxModule { const float *vp_size = DRW_viewport_size_get(); float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; - float scale = mat4_to_scale(object->object_to_world); + float scale = mat4_to_scale(object->object_to_world().ptr()); float distance_factor = world_pixel_scale * scale * winmat[1][1] * vp_size[1] / w; blur_size *= distance_factor; } diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index c1a3771f544..0d2350bf0c6 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -653,7 +653,7 @@ static void drw_shgroup_bone_octahedral(const ArmatureDrawContext *ctx, const float outline_color[4]) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); if (ctx->solid) { OVERLAY_bone_instance_data_set_color(&inst_data, bone_color); OVERLAY_bone_instance_data_set_color_hint(&inst_data, hint_color); @@ -673,7 +673,7 @@ static void drw_shgroup_bone_box(const ArmatureDrawContext *ctx, const float outline_color[4]) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); if (ctx->solid) { OVERLAY_bone_instance_data_set_color(&inst_data, bone_color); OVERLAY_bone_instance_data_set_color_hint(&inst_data, hint_color); @@ -691,9 +691,9 @@ static void drw_shgroup_bone_wire(const ArmatureDrawContext *ctx, const float color[4]) { float head[3], tail[3]; - mul_v3_m4v3(head, ctx->ob->object_to_world, bone_mat[3]); + mul_v3_m4v3(head, ctx->ob->object_to_world().ptr(), bone_mat[3]); add_v3_v3v3(tail, bone_mat[3], bone_mat[1]); - mul_m4_v3(ctx->ob->object_to_world, tail); + mul_m4_v3(ctx->ob->object_to_world().ptr(), tail); DRW_buffer_add_entry(ctx->wire, head, color); DRW_buffer_add_entry(ctx->wire, tail, color); @@ -708,9 +708,9 @@ static void drw_shgroup_bone_stick(const ArmatureDrawContext *ctx, const float col_tail[4]) { float head[3], tail[3]; - mul_v3_m4v3(head, ctx->ob->object_to_world, bone_mat[3]); + mul_v3_m4v3(head, ctx->ob->object_to_world().ptr(), bone_mat[3]); add_v3_v3v3(tail, bone_mat[3], bone_mat[1]); - mul_m4_v3(ctx->ob->object_to_world, tail); + mul_m4_v3(ctx->ob->object_to_world().ptr(), tail); DRW_buffer_add_entry(ctx->stick, head, tail, col_wire, col_bone, col_head, col_tail); } @@ -729,11 +729,11 @@ static void drw_shgroup_bone_envelope_distance(const ArmatureDrawContext *ctx, mul_m4_v4(bone_mat, head_sph); mul_m4_v4(bone_mat, tail_sph); mul_m4_v4(bone_mat, xaxis); - mul_m4_v4(ctx->ob->object_to_world, head_sph); - mul_m4_v4(ctx->ob->object_to_world, tail_sph); - mul_m4_v4(ctx->ob->object_to_world, xaxis); + mul_m4_v4(ctx->ob->object_to_world().ptr(), head_sph); + mul_m4_v4(ctx->ob->object_to_world().ptr(), tail_sph); + mul_m4_v4(ctx->ob->object_to_world().ptr(), xaxis); sub_v3_v3(xaxis, head_sph); - float obscale = mat4_to_scale(ctx->ob->object_to_world); + float obscale = mat4_to_scale(ctx->ob->object_to_world().ptr()); head_sph[3] = *radius_head * obscale; head_sph[3] += *distance * obscale; tail_sph[3] = *radius_tail * obscale; @@ -756,10 +756,10 @@ static void drw_shgroup_bone_envelope(const ArmatureDrawContext *ctx, mul_m4_v4(bone_mat, head_sph); mul_m4_v4(bone_mat, tail_sph); mul_m4_v4(bone_mat, xaxis); - mul_m4_v4(ctx->ob->object_to_world, head_sph); - mul_m4_v4(ctx->ob->object_to_world, tail_sph); - mul_m4_v4(ctx->ob->object_to_world, xaxis); - float obscale = mat4_to_scale(ctx->ob->object_to_world); + mul_m4_v4(ctx->ob->object_to_world().ptr(), head_sph); + mul_m4_v4(ctx->ob->object_to_world().ptr(), tail_sph); + mul_m4_v4(ctx->ob->object_to_world().ptr(), xaxis); + float obscale = mat4_to_scale(ctx->ob->object_to_world().ptr()); head_sph[3] = *radius_head * obscale; tail_sph[3] = *radius_tail * obscale; @@ -861,7 +861,7 @@ static void drw_shgroup_bone_custom_solid_mesh(const ArmatureDrawContext *ctx, DRWCallBuffer *buf; if (surf || edges || loose_edges) { - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); } if (surf && ctx->custom_solid) { @@ -903,7 +903,7 @@ static void drw_shgroup_bone_custom_mesh_wire(const ArmatureDrawContext *ctx, if (geom) { DRWCallBuffer *buf = custom_bone_instance_shgroup(ctx, ctx->custom_wire, geom); BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); OVERLAY_bone_instance_data_set_color_hint(&inst_data, color); OVERLAY_bone_instance_data_set_color(&inst_data, color); DRW_buffer_add_entry_struct(buf, inst_data.mat); @@ -936,7 +936,7 @@ static void drw_shgroup_custom_bone_curve(const ArmatureDrawContext *ctx, if (loose_edges) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); DRWCallBuffer *buf = custom_bone_instance_shgroup(ctx, ctx->custom_wire, loose_edges); OVERLAY_bone_instance_data_set_color_hint(&inst_data, outline_color); @@ -997,7 +997,7 @@ static void drw_shgroup_bone_custom_empty(const ArmatureDrawContext *ctx, { const float final_color[4] = {color[0], color[1], color[2], 1.0f}; float mat[4][4]; - mul_m4_m4m4(mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(mat, ctx->ob->object_to_world().ptr(), bone_mat); switch (custom->empty_drawtype) { case OB_PLAINAXES: @@ -1023,7 +1023,7 @@ static void drw_shgroup_bone_point(const ArmatureDrawContext *ctx, const float outline_color[4]) { BoneInstanceData inst_data; - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), bone_mat); if (ctx->point_solid) { OVERLAY_bone_instance_data_set_color(&inst_data, bone_color); OVERLAY_bone_instance_data_set_color_hint(&inst_data, hint_color); @@ -1041,7 +1041,7 @@ static void drw_shgroup_bone_axes(const ArmatureDrawContext *ctx, const float color[4]) { float mat[4][4]; - mul_m4_m4m4(mat, ctx->ob->object_to_world, bone_mat); + mul_m4_m4m4(mat, ctx->ob->object_to_world().ptr(), bone_mat); /* Move to bone tail. */ add_v3_v3(mat[3], mat[1]); OVERLAY_empty_shape(ctx->extras, mat, 0.25f, OB_ARROWS, color); @@ -1054,8 +1054,8 @@ static void drw_shgroup_bone_relationship_lines_ex(const ArmatureDrawContext *ct const float color[4]) { float s[3], e[3]; - mul_v3_m4v3(s, ctx->ob->object_to_world, start); - mul_v3_m4v3(e, ctx->ob->object_to_world, end); + mul_v3_m4v3(s, ctx->ob->object_to_world().ptr(), start); + mul_v3_m4v3(e, ctx->ob->object_to_world().ptr(), end); /* reverse order to have less stipple overlap */ OVERLAY_extra_line_dashed(ctx->extras, s, e, color); } @@ -1763,7 +1763,7 @@ static void draw_bone_degrees_of_freedom(const ArmatureDrawContext *ctx, const b mul_m4_m4m4(posetrans, posetrans, tmp); /* into world space. */ - mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world, posetrans); + mul_m4_m4m4(inst_data.mat, ctx->ob->object_to_world().ptr(), posetrans); if ((pchan->ikflag & BONE_IK_XLIMIT) && (pchan->ikflag & BONE_IK_ZLIMIT)) { bone_instance_data_set_angle_minmax( @@ -1944,7 +1944,7 @@ static void draw_bone_name(const ArmatureDrawContext *ctx, const float *head = is_pose ? pchan->pose_head : eBone->head; const float *tail = is_pose ? pchan->pose_tail : eBone->tail; mid_v3_v3v3(vec, head, tail); - mul_m4_v3(ctx->ob->object_to_world, vec); + mul_m4_v3(ctx->ob->object_to_world().ptr(), vec); DRW_text_cache_add(dt, vec, @@ -2284,13 +2284,13 @@ class ArmatureBoneDrawStrategyBBone : public ArmatureBoneDrawStrategy { const bArmature *arm = static_cast(ob->data); BLI_assert(arm->drawtype == ARM_B_BONE); UNUSED_VARS_NDEBUG(arm); - const float ob_scale = mat4_to_size_max_axis(ob->object_to_world); + const float ob_scale = mat4_to_size_max_axis(ob->object_to_world().ptr()); const Mat4 *bbones_mat = (const Mat4 *)pchan->draw_data->bbone_matrix; for (int i = pchan->bone->segments; i--; bbones_mat++) { BoundSphere bsphere; float size[3]; mat4_to_size(size, bbones_mat->mat); - mul_v3_m4v3(bsphere.center, ob->object_to_world, bbones_mat->mat[3]); + mul_v3_m4v3(bsphere.center, ob->object_to_world().ptr(), bbones_mat->mat[3]); bsphere.radius = len_v3(size) * ob_scale; if (DRW_culling_sphere_test(view, &bsphere)) { return true; @@ -2365,7 +2365,7 @@ class ArmatureBoneDrawStrategyEnvelope : public ArmatureBoneDrawStrategy { BoundSphere bsphere; pchan_culling_calc_bsphere(ob, pchan, &bsphere); bsphere.radius += max_ff(pchan->bone->rad_head, pchan->bone->rad_tail) * - mat4_to_size_max_axis(ob->object_to_world) * + mat4_to_size_max_axis(ob->object_to_world().ptr()) * mat4_to_size_max_axis(pchan->disp_mat); return DRW_culling_sphere_test(view, &bsphere); } diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.cc b/source/blender/draw/engines/overlay/overlay_edit_text.cc index adc3478b1be..8b83db20235 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_text.cc @@ -123,7 +123,7 @@ static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) add_v2_v2(box[3], &sb->x); } v2_quad_corners_to_mat4(box, final_mat); - mul_m4_m4m4(final_mat, ob->object_to_world, final_mat); + mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), final_mat); DRW_shgroup_call_obmat(pd->edit_text_selection_grp, geom, final_mat); } @@ -138,7 +138,7 @@ static void edit_text_cache_populate_cursor(OVERLAY_Data *vedata, Object *ob) float mat[4][4]; v2_quad_corners_to_mat4(cursor, mat); - mul_m4_m4m4(mat, ob->object_to_world, mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); GPUBatch *geom = DRW_cache_quad_get(); DRW_shgroup_call_obmat(pd->edit_text_cursor_grp, geom, mat); @@ -166,7 +166,7 @@ static void edit_text_cache_populate_boxes(OVERLAY_Data *vedata, Object *ob) vecs[3][1] -= tb->h; for (int j = 0; j < 4; j++) { - mul_v3_m4v3(vecs[j], ob->object_to_world, vecs[j]); + mul_v3_m4v3(vecs[j], ob->object_to_world().ptr(), vecs[j]); } for (int j = 0; j < 4; j++) { OVERLAY_extra_line_dashed(cb, vecs[j], vecs[(j + 1) % 4], color); diff --git a/source/blender/draw/engines/overlay/overlay_extra.cc b/source/blender/draw/engines/overlay/overlay_extra.cc index 3a6b4218e54..09fe549d8a1 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.cc +++ b/source/blender/draw/engines/overlay/overlay_extra.cc @@ -342,7 +342,8 @@ void OVERLAY_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) case OB_EMPTY_CONE: case OB_ARROWS: DRW_object_wire_theme_get(ob, view_layer, &color); - OVERLAY_empty_shape(cb, ob->object_to_world, ob->empty_drawsize, ob->empty_drawtype, color); + OVERLAY_empty_shape( + cb, ob->object_to_world().ptr(), ob->empty_drawsize, ob->empty_drawtype, color); break; case OB_EMPTY_IMAGE: OVERLAY_image_empty_cache_populate(vedata, ob); @@ -373,7 +374,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, case OB_BOUND_BOX: size_to_mat4(tmp, size); copy_v3_v3(tmp[3], center); - mul_m4_m4m4(tmp, ob->object_to_world, tmp); + mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_cube, color, tmp); break; case OB_BOUND_SPHERE: @@ -381,7 +382,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, size[1] = size[2] = size[0]; size_to_mat4(tmp, size); copy_v3_v3(tmp[3], center); - mul_m4_m4m4(tmp, ob->object_to_world, tmp); + mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_sphere, color, tmp); break; case OB_BOUND_CYLINDER: @@ -389,7 +390,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, size[1] = size[0]; size_to_mat4(tmp, size); copy_v3_v3(tmp[3], center); - mul_m4_m4m4(tmp, ob->object_to_world, tmp); + mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_cylinder, color, tmp); break; case OB_BOUND_CONE: @@ -400,7 +401,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, /* Cone batch has base at 0 and is pointing towards +Y. */ swap_v3_v3(tmp[1], tmp[2]); tmp[3][2] -= size[2]; - mul_m4_m4m4(tmp, ob->object_to_world, tmp); + mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_cone, color, tmp); break; case OB_BOUND_CAPSULE: @@ -409,14 +410,14 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, scale_m4_fl(tmp, size[0]); copy_v2_v2(tmp[3], center); tmp[3][2] = center[2] + max_ff(0.0f, size[2] - size[0]); - mul_m4_m4m4(final_mat, ob->object_to_world, tmp); + mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_capsule_cap, color, final_mat); negate_v3(tmp[2]); tmp[3][2] = center[2] - max_ff(0.0f, size[2] - size[0]); - mul_m4_m4m4(final_mat, ob->object_to_world, tmp); + mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_capsule_cap, color, final_mat); tmp[2][2] = max_ff(0.0f, size[2] * 2.0f - size[0] * 2.0f); - mul_m4_m4m4(final_mat, ob->object_to_world, tmp); + mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp); DRW_buffer_add_entry(cb->empty_capsule_body, color, final_mat); break; } @@ -490,7 +491,7 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons unit_m4(mat); } - mul_m4_m4m4(mat, ob->object_to_world, mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); DRW_buffer_add_entry(cb->empty_cube, color, mat); } @@ -512,7 +513,7 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay }; } instdata; - copy_m4_m4(instdata.mat, ob->object_to_world); + copy_m4_m4(instdata.mat, ob->object_to_world().ptr()); instdata.size_x = instdata.size_y = instdata.size_z = ob->empty_drawsize; switch (pd->forcefield) { @@ -532,16 +533,16 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength; float pos[4]; BKE_where_on_path(ob, 0.0f, pos, nullptr, nullptr, nullptr, nullptr); - copy_v3_v3(instdata.pos, ob->object_to_world[3]); + copy_v3_v3(instdata.pos, ob->object_to_world().location()); translate_m4(instdata.mat, pos[0], pos[1], pos[2]); DRW_buffer_add_entry(cb->field_curve, color, &instdata); BKE_where_on_path(ob, 1.0f, pos, nullptr, nullptr, nullptr, nullptr); - copy_v3_v3(instdata.pos, ob->object_to_world[3]); + copy_v3_v3(instdata.pos, ob->object_to_world().location()); translate_m4(instdata.mat, pos[0], pos[1], pos[2]); DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata); /* Restore */ - copy_v3_v3(instdata.pos, ob->object_to_world[3]); + copy_v3_v3(instdata.pos, ob->object_to_world().location()); } break; } @@ -627,7 +628,7 @@ void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) }; } instdata; - copy_m4_m4(instdata.mat, ob->object_to_world); + copy_m4_m4(instdata.mat, ob->object_to_world().ptr()); /* FIXME / TODO: clip_end has no meaning nowadays. * In EEVEE, Only clip_sta is used shadow-mapping. * Clip end is computed automatically based on light power. @@ -726,7 +727,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) }; } instdata; - copy_m4_m4(instdata.mat, ob->object_to_world); + copy_m4_m4(instdata.mat, ob->object_to_world().ptr()); switch (prb->type) { case LIGHTPROBE_TYPE_SPHERE: @@ -738,15 +739,15 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) if (show_influence) { char shape = (prb->attenuation_type == LIGHTPROBE_SHAPE_BOX) ? OB_CUBE : OB_EMPTY_SPHERE; float f = 1.0f - prb->falloff; - OVERLAY_empty_shape(cb, ob->object_to_world, prb->distinf, shape, color_p); - OVERLAY_empty_shape(cb, ob->object_to_world, prb->distinf * f, shape, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), prb->distinf, shape, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), prb->distinf * f, shape, color_p); } if (show_parallax) { char shape = (prb->parallax_type == LIGHTPROBE_SHAPE_BOX) ? OB_CUBE : OB_EMPTY_SPHERE; float dist = ((prb->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) ? prb->distpar : prb->distinf; - OVERLAY_empty_shape(cb, ob->object_to_world, dist, shape, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), dist, shape, color_p); } break; case LIGHTPROBE_TYPE_VOLUME: @@ -756,8 +757,9 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) if (show_influence) { float f = 1.0f - prb->falloff; - OVERLAY_empty_shape(cb, ob->object_to_world, 1.0 + prb->distinf, OB_CUBE, color_p); - OVERLAY_empty_shape(cb, ob->object_to_world, 1.0 + prb->distinf * f, OB_CUBE, color_p); + OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), 1.0 + prb->distinf, OB_CUBE, color_p); + OVERLAY_empty_shape( + cb, ob->object_to_world().ptr(), 1.0 + prb->distinf * f, OB_CUBE, color_p); } /* Data dots */ @@ -795,7 +797,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) zero_v3(instdata.mat[2]); DRW_buffer_add_entry(cb->empty_cube, color_p, &instdata); - normalize_m4_m4(instdata.mat, ob->object_to_world); + normalize_m4_m4(instdata.mat, ob->object_to_world().ptr()); OVERLAY_empty_shape(cb, instdata.mat, ob->empty_drawsize, OB_SINGLE_ARROW, color_p); break; } @@ -815,7 +817,7 @@ void OVERLAY_speaker_cache_populate(OVERLAY_Data *vedata, Object *ob) float *color_p; DRW_object_wire_theme_get(ob, view_layer, &color_p); - DRW_buffer_add_entry(cb->speaker, color_p, ob->object_to_world); + DRW_buffer_add_entry(cb->speaker, color_p, ob->object_to_world().ptr()); } /** \} */ @@ -908,7 +910,7 @@ static void camera_view3d_reconstruction( float object_imat[4][4]; invert_m4_m4(object_imat, object_mat); - mul_m4_m4m4(tracking_object_mat, ob->object_to_world, object_imat); + mul_m4_m4m4(tracking_object_mat, ob->object_to_world().ptr(), object_imat); } LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) { @@ -1151,7 +1153,7 @@ void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_object_wire_theme_get(ob, view_layer, &color_p); copy_v4_v4(instdata.color, color_p); - normalize_m4_m4(instdata.mat, ob->object_to_world); + normalize_m4_m4(instdata.mat, ob->object_to_world().ptr()); /* BKE_camera_multiview_model_matrix already accounts for scale, don't do it here. */ if (is_selection_camera_stereo) { @@ -1159,9 +1161,9 @@ void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) } else { copy_v3_fl3(scale, - len_v3(ob->object_to_world[0]), - len_v3(ob->object_to_world[1]), - len_v3(ob->object_to_world[2])); + len_v3(ob->object_to_world().ptr()[0]), + len_v3(ob->object_to_world().ptr()[1]), + len_v3(ob->object_to_world().ptr()[2])); /* Avoid division by 0. */ if (ELEM(0.0f, scale[0], scale[1], scale[2])) { return; @@ -1277,7 +1279,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, if (ob->parent && (DRW_object_visibility_in_active_context(ob->parent) & OB_VISIBLE_SELF)) { float *parent_pos = ob->runtime->parent_display_origin; - OVERLAY_extra_line_dashed(cb, parent_pos, ob->object_to_world[3], relation_color); + OVERLAY_extra_line_dashed(cb, parent_pos, ob->object_to_world().location(), relation_color); } /* Drawing the hook lines. */ @@ -1285,9 +1287,10 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, if (md->type == eModifierType_Hook) { HookModifierData *hmd = (HookModifierData *)md; float center[3]; - mul_v3_m4v3(center, ob->object_to_world, hmd->cent); + mul_v3_m4v3(center, ob->object_to_world().ptr(), hmd->cent); if (hmd->object) { - OVERLAY_extra_line_dashed(cb, hmd->object->object_to_world[3], center, relation_color); + OVERLAY_extra_line_dashed( + cb, hmd->object->object_to_world().location(), center, relation_color); } OVERLAY_extra_point(cb, center, relation_color); } @@ -1296,9 +1299,10 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, if (md->type == eGpencilModifierType_Hook) { HookGpencilModifierData *hmd = (HookGpencilModifierData *)md; float center[3]; - mul_v3_m4v3(center, ob->object_to_world, hmd->cent); + mul_v3_m4v3(center, ob->object_to_world().ptr(), hmd->cent); if (hmd->object) { - OVERLAY_extra_line_dashed(cb, hmd->object->object_to_world[3], center, relation_color); + OVERLAY_extra_line_dashed( + cb, hmd->object->object_to_world().location(), center, relation_color); } OVERLAY_extra_point(cb, center, relation_color); } @@ -1308,12 +1312,16 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, Object *rbc_ob1 = ob->rigidbody_constraint->ob1; Object *rbc_ob2 = ob->rigidbody_constraint->ob2; if (rbc_ob1 && (DRW_object_visibility_in_active_context(rbc_ob1) & OB_VISIBLE_SELF)) { - OVERLAY_extra_line_dashed( - cb, rbc_ob1->object_to_world[3], ob->object_to_world[3], relation_color); + OVERLAY_extra_line_dashed(cb, + rbc_ob1->object_to_world().location(), + ob->object_to_world().location(), + relation_color); } if (rbc_ob2 && (DRW_object_visibility_in_active_context(rbc_ob2) & OB_VISIBLE_SELF)) { - OVERLAY_extra_line_dashed( - cb, rbc_ob2->object_to_world[3], ob->object_to_world[3], relation_color); + OVERLAY_extra_line_dashed(cb, + rbc_ob2->object_to_world().location(), + ob->object_to_world().location(), + relation_color); } } @@ -1340,8 +1348,10 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, } if (camob) { - OVERLAY_extra_line_dashed( - cb, camob->object_to_world[3], ob->object_to_world[3], constraint_color); + OVERLAY_extra_line_dashed(cb, + camob->object_to_world().location(), + ob->object_to_world().location(), + constraint_color); } } else { @@ -1362,7 +1372,8 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, else { unit_m4(ct->matrix); } - OVERLAY_extra_line_dashed(cb, ct->matrix[3], ob->object_to_world[3], constraint_color); + OVERLAY_extra_line_dashed( + cb, ct->matrix[3], ob->object_to_world().location(), constraint_color); } BKE_constraint_targets_flush(curcon, &targets, true); @@ -1419,7 +1430,7 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, copy_v3_v3(voxel_cubemat[3], min); /* move small cube into the domain (otherwise its centered on vertex of domain object) */ translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f); - mul_m4_m4m4(voxel_cubemat, ob->object_to_world, voxel_cubemat); + mul_m4_m4m4(voxel_cubemat, ob->object_to_world().ptr(), voxel_cubemat); DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat); } @@ -1525,15 +1536,15 @@ static void OVERLAY_object_center(OVERLAY_ExtraCallBuffers *cb, const bool is_library = ID_REAL_USERS(&ob->id) > 1 || ID_IS_LINKED(ob); BKE_view_layer_synced_ensure(scene, view_layer); if (ob == BKE_view_layer_active_object_get(view_layer)) { - DRW_buffer_add_entry(cb->center_active, ob->object_to_world[3]); + DRW_buffer_add_entry(cb->center_active, ob->object_to_world().location()); } else if (ob->base_flag & BASE_SELECTED) { DRWCallBuffer *cbuf = (is_library) ? cb->center_selected_lib : cb->center_selected; - DRW_buffer_add_entry(cbuf, ob->object_to_world[3]); + DRW_buffer_add_entry(cbuf, ob->object_to_world().location()); } else if (pd->v3d_flag & V3D_DRAW_CENTERS) { DRWCallBuffer *cbuf = (is_library) ? cb->center_deselected_lib : cb->center_deselected; - DRW_buffer_add_entry(cbuf, ob->object_to_world[3]); + DRW_buffer_add_entry(cbuf, ob->object_to_world().location()); } } @@ -1545,7 +1556,7 @@ static void OVERLAY_object_name(Object *ob, int theme_id) UI_GetThemeColor4ubv(theme_id, color); DRW_text_cache_add(dt, - ob->object_to_world[3], + ob->object_to_world().location(), ob->id.name + 2, strlen(ob->id.name + 2), 10, @@ -1604,7 +1615,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) /* Helpers for when we're transforming origins. */ if (draw_xform) { const float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f}; - DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->object_to_world); + DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->object_to_world().ptr()); } /* don't show object extras in set's */ if (!from_dupli) { @@ -1624,7 +1635,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) OVERLAY_collision(cb, ob, color); } if (ob->dtx & OB_AXIS) { - DRW_buffer_add_entry(cb->empty_axes, color, ob->object_to_world); + DRW_buffer_add_entry(cb->empty_axes, color, ob->object_to_world().ptr()); } if (draw_volume) { OVERLAY_volume_extra(cb, vedata, ob, md, scene, color); diff --git a/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc b/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc index 745b759285e..d18c8731564 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc +++ b/source/blender/draw/engines/overlay/overlay_gpencil_legacy.cc @@ -246,7 +246,7 @@ void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata) copy_v3_v3(col_grid, gpd->grid.color); col_grid[3] = max_ff(v3d->overlay.gpencil_grid_opacity, 0.01f); - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); /* Rotate and scale except align to cursor. */ bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -289,7 +289,7 @@ void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata) copy_v3_v3(mat[3], cursor->location); } else if (ts->gpencil_v3d_align & GP_PROJECT_VIEWSPACE) { - copy_v3_v3(mat[3], ob->object_to_world[3]); + copy_v3_v3(mat[3], ob->object_to_world().location()); } translate_m4(mat, gpd->grid.offset[0], gpd->grid.offset[1], 0.0f); @@ -401,7 +401,7 @@ static void overlay_gpencil_draw_stroke_color_name(bGPDlayer * /*gpl*/, UI_GetThemeColor4ubv(theme_id, color); float fpt[3]; - mul_v3_m4v3(fpt, ob->object_to_world, &pt->x); + mul_v3_m4v3(fpt, ob->object_to_world().ptr(), &pt->x); DRWTextStore *dt = DRW_text_cache_ensure(); DRW_text_cache_add(dt, diff --git a/source/blender/draw/engines/overlay/overlay_image.cc b/source/blender/draw/engines/overlay/overlay_image.cc index 60d14bdbb10..bc00980ebf7 100644 --- a/source/blender/draw/engines/overlay/overlay_image.cc +++ b/source/blender/draw/engines/overlay/overlay_image.cc @@ -386,7 +386,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) float image_aspect[2]; overlay_image_calc_aspect(ima, size, image_aspect); - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); mul_v3_fl(mat[0], image_aspect[0] * 0.5f * ob->empty_drawsize); mul_v3_fl(mat[1], image_aspect[1] * 0.5f * ob->empty_drawsize); madd_v3_v3fl(mat[3], mat[0], ob->ima_ofs[0] * 2.0f + 1.0f); diff --git a/source/blender/draw/engines/overlay/overlay_lattice.cc b/source/blender/draw/engines/overlay/overlay_lattice.cc index 7359bf9a955..c9c70cc20c2 100644 --- a/source/blender/draw/engines/overlay/overlay_lattice.cc +++ b/source/blender/draw/engines/overlay/overlay_lattice.cc @@ -53,7 +53,7 @@ void OVERLAY_lattice_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); GPUBatch *geom = DRW_cache_lattice_wire_get(ob, false); - OVERLAY_extra_wire(cb, geom, ob->object_to_world, color); + OVERLAY_extra_wire(cb, geom, ob->object_to_world().ptr(), color); } void OVERLAY_edit_lattice_draw(OVERLAY_Data *vedata) diff --git a/source/blender/draw/engines/overlay/overlay_metaball.cc b/source/blender/draw/engines/overlay/overlay_metaball.cc index 56ce3d5ec05..bc6c5b64ce2 100644 --- a/source/blender/draw/engines/overlay/overlay_metaball.cc +++ b/source/blender/draw/engines/overlay/overlay_metaball.cc @@ -47,10 +47,10 @@ static void metaball_instance_data_set( BoneInstanceData *data, Object *ob, const float *pos, const float radius, const float color[4]) { /* Bone point radius is 0.05. Compensate for that. */ - mul_v3_v3fl(data->mat[0], ob->object_to_world[0], radius / 0.05f); - mul_v3_v3fl(data->mat[1], ob->object_to_world[1], radius / 0.05f); - mul_v3_v3fl(data->mat[2], ob->object_to_world[2], radius / 0.05f); - mul_v3_m4v3(data->mat[3], ob->object_to_world, pos); + mul_v3_v3fl(data->mat[0], ob->object_to_world().ptr()[0], radius / 0.05f); + mul_v3_v3fl(data->mat[1], ob->object_to_world().ptr()[1], radius / 0.05f); + mul_v3_v3fl(data->mat[2], ob->object_to_world().ptr()[2], radius / 0.05f); + mul_v3_m4v3(data->mat[3], ob->object_to_world().ptr(), pos); /* WATCH: Reminder, alpha is wire-size. */ OVERLAY_bone_instance_data_set_color(data, color); } diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.cc b/source/blender/draw/engines/overlay/overlay_motion_path.cc index 4b4f845c981..62ae88800eb 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.cc +++ b/source/blender/draw/engines/overlay/overlay_motion_path.cc @@ -150,7 +150,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, Object *motion_path_camera = get_camera_for_motion_path( draw_ctx, eMotionPath_BakeFlag(avs->path_bakeflag)); if (motion_path_camera) { - copy_m4_m4(camera_matrix, motion_path_camera->object_to_world); + copy_m4_m4(camera_matrix, motion_path_camera->object_to_world().ptr()); } else { unit_m4(camera_matrix); @@ -205,9 +205,8 @@ static void motion_path_cache(OVERLAY_Data *vedata, float3 vert_coordinate; copy_v3_v3(vert_coordinate, mpv->co); if (cam_eval) { - /* Projecting the point into world space from the cameras POV. */ - vert_coordinate = math::transform_point(float4x4(cam_eval->object_to_world), - vert_coordinate); + /* Projecting the point into world space from the camera's POV. */ + vert_coordinate = math::transform_point(cam_eval->object_to_world(), vert_coordinate); } if ((show_keyframes && show_keyframes_no && is_keyframe) || (show_frame_no && (i == 0))) { diff --git a/source/blender/draw/engines/overlay/overlay_next_empty.hh b/source/blender/draw/engines/overlay/overlay_next_empty.hh index b97ba0025e2..ab9f42c8d76 100644 --- a/source/blender/draw/engines/overlay/overlay_next_empty.hh +++ b/source/blender/draw/engines/overlay/overlay_next_empty.hh @@ -55,8 +55,7 @@ class Empties { CallBuffers &call_bufs = call_buffers_[int((ob_ref.object->dtx & OB_DRAW_IN_FRONT) != 0)]; float4 color = res.object_wire_color(ob_ref, state); - ExtraInstanceData data( - float4x4(ob_ref.object->object_to_world), color, ob_ref.object->empty_drawsize); + ExtraInstanceData data(ob_ref.object->object_to_world(), color, ob_ref.object->empty_drawsize); const select::ID select_id = res.select_id(ob_ref); diff --git a/source/blender/draw/engines/overlay/overlay_next_instance.cc b/source/blender/draw/engines/overlay/overlay_next_instance.cc index ceefef9cb95..e991978b352 100644 --- a/source/blender/draw/engines/overlay/overlay_next_instance.cc +++ b/source/blender/draw/engines/overlay/overlay_next_instance.cc @@ -269,10 +269,10 @@ BoneInstanceData::BoneInstanceData(Object *ob, const float color[4]) { /* TODO(fclem): Use C++ math API. */ - mul_v3_v3fl(this->mat[0], ob->object_to_world[0], radius); - mul_v3_v3fl(this->mat[1], ob->object_to_world[1], radius); - mul_v3_v3fl(this->mat[2], ob->object_to_world[2], radius); - mul_v3_m4v3(this->mat[3], ob->object_to_world, pos); + mul_v3_v3fl(this->mat[0], ob->object_to_world().ptr()[0], radius); + mul_v3_v3fl(this->mat[1], ob->object_to_world().ptr()[1], radius); + mul_v3_v3fl(this->mat[2], ob->object_to_world().ptr()[2], radius); + mul_v3_m4v3(this->mat[3], ob->object_to_world().ptr(), pos); /* WATCH: Reminder, alpha is wire-size. */ OVERLAY_bone_instance_data_set_color(this, color); } diff --git a/source/blender/draw/engines/overlay/overlay_outline.cc b/source/blender/draw/engines/overlay/overlay_outline.cc index eba1ec30274..ca7be6f6ff6 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.cc +++ b/source/blender/draw/engines/overlay/overlay_outline.cc @@ -48,7 +48,7 @@ static void gpencil_depth_plane(Object *ob, float r_plane[4]) add_v3_fl(size, 1e-8f); rescale_m4(mat, size); /* BBox space to World. */ - mul_m4_m4m4(mat, ob->object_to_world, mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat); /* BBox center in world space. */ copy_v3_v3(center, mat[3]); /* View Vector. */ @@ -194,7 +194,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl, const bool is_screenspace = (gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS) != 0; const bool is_stroke_order_3d = (gpd->draw_mode == GP_DRAWMODE_3D); - float object_scale = mat4_to_scale(iter->ob->object_to_world); + float object_scale = mat4_to_scale(iter->ob->object_to_world().ptr()); /* Negate thickness sign to tag that strokes are in screen space. * Convert to world units (by default, 1 meter = 2000 pixels). */ float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / 2000.0f); diff --git a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc index 37d80f3a173..b49b069109f 100644 --- a/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc +++ b/source/blender/draw/engines/overlay/overlay_viewer_attribute.cc @@ -92,7 +92,7 @@ static void populate_cache_for_instance(Object &object, DRWShadingGroup *sub_grp = DRW_shgroup_create_sub(pd.viewer_attribute_instance_grp); DRW_shgroup_uniform_vec4_copy(sub_grp, "ucolor", color); GPUBatch *batch = DRW_cache_curve_edge_wire_get(&object); - DRW_shgroup_call_obmat(sub_grp, batch, object.object_to_world); + DRW_shgroup_call_obmat(sub_grp, batch, object.object_to_world().ptr()); break; } case OB_CURVES: { @@ -139,7 +139,8 @@ static void populate_cache_for_geometry(Object &object, if (curves.attributes().contains(".viewer")) { GPUBatch *batch = DRW_cache_curve_edge_wire_viewer_attribute_get(&object); DRW_shgroup_uniform_float_copy(pd.viewer_attribute_curve_grp, "opacity", opacity); - DRW_shgroup_call_obmat(pd.viewer_attribute_curve_grp, batch, object.object_to_world); + DRW_shgroup_call_obmat( + pd.viewer_attribute_curve_grp, batch, object.object_to_world().ptr()); } } break; diff --git a/source/blender/draw/engines/overlay/overlay_viewer_text.cc b/source/blender/draw/engines/overlay/overlay_viewer_text.cc index 8e56d309c5f..ad4b2e7f861 100644 --- a/source/blender/draw/engines/overlay/overlay_viewer_text.cc +++ b/source/blender/draw/engines/overlay/overlay_viewer_text.cc @@ -122,7 +122,7 @@ void OVERLAY_viewer_attribute_text(const Object &object) { using namespace blender; using namespace blender::draw::overlay; - const float4x4 object_to_world = float4x4(object.object_to_world); + const float4x4 &object_to_world = object.object_to_world(); DupliObject *dupli_object = DRW_object_get_dupli(&object); if (dupli_object->preview_instance_index >= 0) { diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.cc b/source/blender/draw/engines/overlay/overlay_wireframe.cc index d1422970dbf..b5938ced60d 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.cc +++ b/source/blender/draw/engines/overlay/overlay_wireframe.cc @@ -141,12 +141,12 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part if (collection != nullptr) { sub_v3_v3(dupli_mat[3], collection->instance_offset); } - mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world, dupli_mat); + mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world().ptr(), dupli_mat); } else { - copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world); + copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world().ptr()); invert_m4(dupli_mat); - mul_m4_m4m4(dupli_mat, ob->object_to_world, dupli_mat); + mul_m4_m4m4(dupli_mat, ob->object_to_world().ptr(), dupli_mat); } } else { @@ -227,7 +227,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, } if (geom) { - OVERLAY_extra_wire(cb, geom, ob->object_to_world, color); + OVERLAY_extra_wire(cb, geom, ob->object_to_world().ptr(), color); } } @@ -240,12 +240,12 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, if (dupli->wire_shgrp == cb->extra_loose_points) { float *color; DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); - OVERLAY_extra_loose_points(cb, dupli->wire_geom, ob->object_to_world, color); + OVERLAY_extra_loose_points(cb, dupli->wire_geom, ob->object_to_world().ptr(), color); } else if (dupli->wire_shgrp == cb->extra_wire) { float *color; DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); - OVERLAY_extra_wire(cb, dupli->wire_geom, ob->object_to_world, color); + OVERLAY_extra_wire(cb, dupli->wire_geom, ob->object_to_world().ptr(), color); } else { DRW_shgroup_call(dupli->wire_shgrp, dupli->wire_geom, ob); @@ -274,7 +274,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, GPUBatch *geom = DRW_cache_object_face_wireframe_get(ob); if (geom) { - OVERLAY_extra_loose_points(cb, geom, ob->object_to_world, color); + OVERLAY_extra_loose_points(cb, geom, ob->object_to_world().ptr(), color); } return; } @@ -328,14 +328,14 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, if (is_mesh_verts_only) { geom = DRW_cache_mesh_all_verts_get(ob); if (geom) { - OVERLAY_extra_loose_points(cb, geom, ob->object_to_world, color); + OVERLAY_extra_loose_points(cb, geom, ob->object_to_world().ptr(), color); shgrp = cb->extra_loose_points; } } else { geom = DRW_cache_mesh_loose_edges_get(ob); if (geom) { - OVERLAY_extra_wire(cb, geom, ob->object_to_world, color); + OVERLAY_extra_wire(cb, geom, ob->object_to_world().ptr(), color); shgrp = cb->extra_wire; } } diff --git a/source/blender/draw/engines/select/select_engine.cc b/source/blender/draw/engines/select/select_engine.cc index ce497a7fa92..3a3900f8c88 100644 --- a/source/blender/draw/engines/select/select_engine.cc +++ b/source/blender/draw/engines/select/select_engine.cc @@ -217,7 +217,7 @@ static void select_cache_populate(void *vedata, Object *ob) /* This object is not in the array. It is here to participate in the depth buffer. */ if (ob->dt >= OB_SOLID) { GPUBatch *geom_faces = DRW_mesh_batch_cache_get_surface(static_cast(ob->data)); - DRW_shgroup_call_obmat(stl->g_data->shgrp_occlude, geom_faces, ob->object_to_world); + DRW_shgroup_call_obmat(stl->g_data->shgrp_occlude, geom_faces, ob->object_to_world().ptr()); } } else if (!sel_data->in_pass) { diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index cadb75bf32a..016667d7114 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -157,7 +157,7 @@ class Instance { if (object_state.sculpt_pbvh) { /* Disable frustum culling for sculpt meshes. */ /* TODO(@pragma37): Implement a cleaner way to disable frustum culling. */ - ResourceHandle handle = manager.resource_handle(float4x4(ob_ref.object->object_to_world)); + ResourceHandle handle = manager.resource_handle(ob_ref.object->object_to_world()); handle = ResourceHandle(handle.resource_index(), ob_ref.object->transflag & OB_NEG_SCALE); sculpt_sync(ob_ref, handle, object_state); emitter_handle = handle; @@ -385,7 +385,7 @@ class Instance { ModifierData *md) { /* Skip frustum culling. */ - ResourceHandle handle = manager.resource_handle(float4x4(ob_ref.object->object_to_world)); + ResourceHandle handle = manager.resource_handle(ob_ref.object->object_to_world()); Material mat = get_material(ob_ref, object_state.color_type, psys->part->omat - 1); ::Image *image = nullptr; @@ -410,7 +410,7 @@ class Instance { void curves_sync(Manager &manager, ObjectRef &ob_ref, const ObjectState &object_state) { /* Skip frustum culling. */ - ResourceHandle handle = manager.resource_handle(float4x4(ob_ref.object->object_to_world)); + ResourceHandle handle = manager.resource_handle(ob_ref.object->object_to_world()); Material mat = get_material(ob_ref, object_state.color_type); resources.material_buf.append(mat); diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc b/source/blender/draw/engines/workbench/workbench_shadow.cc index 4fa7db65bc8..c8ba56067e1 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.cc +++ b/source/blender/draw/engines/workbench/workbench_shadow.cc @@ -181,7 +181,7 @@ bool ShadowPass::ShadowView::debug_object_culling(Object *ob) float4 plane = extruded_frustum_.planes[p]; bool separating_axis = true; for (float3 corner : bb.vec) { - corner = math::transform_point(float4x4(ob->object_to_world), corner); + corner = math::transform_point(ob->object_to_world(), corner); float signed_distance = math::dot(corner, float3(plane)) - plane.w; if (signed_distance <= 0) { separating_axis = false; diff --git a/source/blender/draw/engines/workbench/workbench_volume.cc b/source/blender/draw/engines/workbench/workbench_volume.cc index 697824d7b58..b05173a984b 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.cc +++ b/source/blender/draw/engines/workbench/workbench_volume.cc @@ -54,7 +54,7 @@ void VolumePass::object_sync_volume(Manager &manager, sub_ps.push_constant("do_depth_test", scene_state.shading.type >= OB_SOLID); const float density_scale = volume->display.density * - BKE_volume_density_scale(volume, ob->object_to_world); + BKE_volume_density_scale(volume, ob->object_to_world().ptr()); sub_ps.bind_texture("depthBuffer", &resources.depth_tx); sub_ps.bind_texture("stencil_tx", &stencil_tx_); @@ -71,7 +71,7 @@ void VolumePass::object_sync_volume(Manager &manager, manager, sub_ps, ob_ref, volume->display.slice_axis, volume->display.slice_depth); } else { - float4x4 texture_to_world = float4x4(ob->object_to_world) * float4x4(grid->texture_to_object); + float4x4 texture_to_world = ob->object_to_world() * float4x4(grid->texture_to_object); float3 world_size = math::to_scale(texture_to_world); int3 resolution; diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc b/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc index a7a89d7aed1..01b9bf378a7 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc +++ b/source/blender/draw/intern/draw_cache_impl_gpencil_legacy.cc @@ -615,7 +615,7 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_fill) for (int i = 0; i < vert_len; i++) { ED_gpencil_tpoint_to_point(region, origin, &tpoints[i], &gps->points[i]); - mul_m4_v3(ob->world_to_object, &gps->points[i].x); + mul_m4_v3(ob->world_to_object().ptr(), &gps->points[i].x); bGPDspoint *pt = &gps->points[i]; copy_v4_v4(pt->vert_color, tpoints[i].vert_color); } diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc b/source/blender/draw/intern/draw_cache_impl_mesh.cc index d78916dc14e..a968dba97b6 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.cc +++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc @@ -1868,7 +1868,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world, + ob->object_to_world().ptr(), false, true, scene, @@ -1885,7 +1885,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world, + ob->object_to_world().ptr(), false, false, scene, @@ -1901,7 +1901,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world, + ob->object_to_world().ptr(), true, false, do_cage, @@ -1922,7 +1922,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph, is_editmode, is_paint_mode, is_mode_active, - ob->object_to_world, + ob->object_to_world().ptr(), true, false, scene, diff --git a/source/blender/draw/intern/draw_curves.cc b/source/blender/draw/intern/draw_curves.cc index f9182ff215f..c05a8373078 100644 --- a/source/blender/draw/intern/draw_curves.cc +++ b/source/blender/draw/intern/draw_curves.cc @@ -314,7 +314,7 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object, DRW_shgroup_uniform_int(shgrp, "hairStrandsRes", &curves_cache->final[subdiv].strands_res, 1); DRW_shgroup_uniform_int_copy(shgrp, "hairThicknessRes", thickness_res); DRW_shgroup_uniform_float_copy(shgrp, "hairRadShape", hair_rad_shape); - DRW_shgroup_uniform_mat4_copy(shgrp, "hairDupliMatrix", object->object_to_world); + DRW_shgroup_uniform_mat4_copy(shgrp, "hairDupliMatrix", object->object_to_world().ptr()); DRW_shgroup_uniform_float_copy(shgrp, "hairRadRoot", hair_rad_root); DRW_shgroup_uniform_float_copy(shgrp, "hairRadTip", hair_rad_tip); DRW_shgroup_uniform_bool_copy(shgrp, "hairCloseTip", hair_close_tip); @@ -540,7 +540,7 @@ GPUBatch *curves_sub_pass_setup_implementation(PassT &sub_ps, sub_ps.push_constant("hairStrandsRes", &curves_cache->final[subdiv].strands_res, 1); sub_ps.push_constant("hairThicknessRes", thickness_res); sub_ps.push_constant("hairRadShape", hair_rad_shape); - sub_ps.push_constant("hairDupliMatrix", float4x4(ob->object_to_world)); + sub_ps.push_constant("hairDupliMatrix", ob->object_to_world()); sub_ps.push_constant("hairRadRoot", hair_rad_root); sub_ps.push_constant("hairRadTip", hair_rad_tip); sub_ps.push_constant("hairCloseTip", hair_close_tip); diff --git a/source/blender/draw/intern/draw_hair.cc b/source/blender/draw/intern/draw_hair.cc index 5c0539c75cb..15119c6952d 100644 --- a/source/blender/draw/intern/draw_hair.cc +++ b/source/blender/draw/intern/draw_hair.cc @@ -161,12 +161,12 @@ void DRW_hair_duplimat_get(Object *object, if (collection != nullptr) { sub_v3_v3(dupli_mat[3], collection->instance_offset); } - mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world, dupli_mat); + mul_m4_m4m4(dupli_mat, dupli_parent->object_to_world().ptr(), dupli_mat); } else { - copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world); + copy_m4_m4(dupli_mat, dupli_object->ob->object_to_world().ptr()); invert_m4(dupli_mat); - mul_m4_m4m4(dupli_mat, object->object_to_world, dupli_mat); + mul_m4_m4m4(dupli_mat, object->object_to_world().ptr(), dupli_mat); } } else { diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index 3918c834709..555af2e63b5 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -2854,7 +2854,7 @@ void DRW_draw_depth_object( GPU_matrix_projection_set(rv3d->winmat); GPU_matrix_set(rv3d->viewmat); - GPU_matrix_mul(object->object_to_world); + GPU_matrix_mul(object->object_to_world().ptr()); /* Setup frame-buffer. */ GPUTexture *depth_tx = GPU_viewport_depth_texture(viewport); @@ -2874,11 +2874,11 @@ void DRW_draw_depth_object( const bool use_clipping_planes = RV3D_CLIPPING_ENABLED(v3d, rv3d); if (use_clipping_planes) { GPU_clip_distances(6); - ED_view3d_clipping_local(rv3d, object->object_to_world); + ED_view3d_clipping_local(rv3d, object->object_to_world().ptr()); for (int i = 0; i < 6; i++) { copy_v4_v4(planes.world[i], rv3d->clip_local[i]); } - copy_m4_m4(planes.ClipModelMatrix.ptr(), object->object_to_world); + copy_m4_m4(planes.ClipModelMatrix.ptr(), object->object_to_world().ptr()); } drw_batch_cache_validate(object); diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 1dfba112acd..13553143fea 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -698,7 +698,7 @@ BLI_INLINE void drw_call_matrix_init(DRWObjectMatrix *ob_mats, { copy_m4_m4(ob_mats->model, obmat); if (ob) { - copy_m4_m4(ob_mats->modelinverse, ob->world_to_object); + copy_m4_m4(ob_mats->modelinverse, ob->world_to_object().ptr()); } else { /* WATCH: Can be costly. */ @@ -745,8 +745,8 @@ static void drw_call_culling_init(DRWCullingState *cull, const Object *ob) float corner[3]; /* Get BoundSphere center and radius from the BoundBox. */ mid_v3_v3v3(cull->bsphere.center, bounds->max, bounds->min); - mul_v3_m4v3(corner, ob->object_to_world, bounds->max); - mul_m4_v3(ob->object_to_world, cull->bsphere.center); + mul_v3_m4v3(corner, ob->object_to_world().ptr(), bounds->max); + mul_m4_v3(ob->object_to_world().ptr(), cull->bsphere.center); cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner); /* Bypass test for very large objects (see #67319). */ @@ -1038,7 +1038,8 @@ void DRW_shgroup_call_ex(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : obmat, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : obmat, ob); drw_command_draw(shgroup, geom, handle); /* Culling data. */ @@ -1063,7 +1064,8 @@ void DRW_shgroup_call_range( if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); drw_command_draw_range(shgroup, geom, handle, v_sta, v_num); } @@ -1074,7 +1076,8 @@ void DRW_shgroup_call_instance_range( if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); drw_command_draw_intance_range(shgroup, geom, handle, i_sta, i_num); } @@ -1120,7 +1123,8 @@ static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); drw_command_draw_procedural(shgroup, geom, handle, vert_count); } @@ -1174,7 +1178,8 @@ void DRW_shgroup_call_procedural_indirect(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); drw_command_draw_indirect(shgroup, geom, handle, indirect_buf); } @@ -1187,7 +1192,8 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); drw_command_draw_instance(shgroup, geom, handle, count, false); } @@ -1201,7 +1207,8 @@ void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, if (G.f & G_FLAG_PICKSEL) { drw_command_set_select_id(shgroup, nullptr, DST.select_id); } - DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->object_to_world : nullptr, ob); + DRWResourceHandle handle = drw_resource_handle( + shgroup, ob ? ob->object_to_world().ptr() : nullptr, ob); GPUBatch *batch = DRW_temp_batch_instance_request( DST.vmempool->idatalist, nullptr, inst_attributes, geom); drw_command_draw_instance(shgroup, batch, handle, 0, true); @@ -1305,7 +1312,7 @@ static void drw_sculpt_get_frustum_planes(const Object *ob, float planes[6][4]) * 4x4 matrix is done by multiplying with the transpose inverse. * The inverse cancels out here since we transform by inverse(obmat). */ float tmat[4][4]; - transpose_m4_m4(tmat, ob->object_to_world); + transpose_m4_m4(tmat, ob->object_to_world().ptr()); for (int i = 0; i < 6; i++) { mul_m4_v4(tmat, planes[i]); } @@ -1383,7 +1390,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd) if (SCULPT_DEBUG_BUFFERS) { int debug_node_nr = 0; - DRW_debug_modelmat(scd->ob->object_to_world); + DRW_debug_modelmat(scd->ob->object_to_world().ptr()); BKE_pbvh_draw_debug_cb( pbvh, (void (*)(PBVHNode *n, void *d, const float min[3], const float max[3], PBVHNodeFlags f)) diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index 153155cfdde..234c82972da 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -340,11 +340,11 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { mid_v3_v3v3(vmid, v1_clip, v2_clip); - mul_m4_v3(ob->object_to_world, vmid); + mul_m4_v3(ob->object_to_world().ptr(), vmid); if (do_global) { - mul_mat3_m4_v3(ob->object_to_world, v1); - mul_mat3_m4_v3(ob->object_to_world, v2); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v1); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v2); } if (unit->system) { @@ -408,7 +408,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, float angle; mid_v3_v3v3(vmid, v1_clip, v2_clip); - mul_m4_v3(ob->object_to_world, vmid); + mul_m4_v3(ob->object_to_world().ptr(), vmid); if (use_coords) { copy_v3_v3(no_a, face_normals[BM_elem_index_get(l_a->f)]); @@ -420,8 +420,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, } if (do_global) { - mul_mat3_m4_v3(ob->world_to_object, no_a); - mul_mat3_m4_v3(ob->world_to_object, no_b); + mul_mat3_m4_v3(ob->world_to_object().ptr(), no_a); + mul_mat3_m4_v3(ob->world_to_object().ptr(), no_b); normalize_v3(no_a); normalize_v3(no_b); } @@ -477,16 +477,16 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, n += 3; if (do_global) { - mul_mat3_m4_v3(ob->object_to_world, v1); - mul_mat3_m4_v3(ob->object_to_world, v2); - mul_mat3_m4_v3(ob->object_to_world, v3); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v1); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v2); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v3); } area += area_tri_v3(v1, v2, v3); } mul_v3_fl(vmid, 1.0f / float(n)); - mul_m4_v3(ob->object_to_world, vmid); + mul_m4_v3(ob->object_to_world().ptr(), vmid); if (unit->system) { numstr_len = BKE_unit_value_as_string( @@ -557,9 +557,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, copy_v3_v3(v2_local, v2); if (do_global) { - mul_mat3_m4_v3(ob->object_to_world, v1); - mul_mat3_m4_v3(ob->object_to_world, v2); - mul_mat3_m4_v3(ob->object_to_world, v3); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v1); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v2); + mul_mat3_m4_v3(ob->object_to_world().ptr(), v3); } float angle = angle_v3v3v3(v1, v2, v3); @@ -569,7 +569,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, (is_rad) ? angle : RAD2DEGF(angle), (is_rad) ? "r" : BLI_STR_UTF8_DEGREE_SIGN); interp_v3_v3v3(fvec, vmid, v2_local, 0.8f); - mul_m4_v3(ob->object_to_world, fvec); + mul_m4_v3(ob->object_to_world().ptr(), fvec); DRW_text_cache_add(dt, fvec, numstr, numstr_len, 0, 0, txt_flag, col); } } @@ -600,7 +600,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, copy_v3_v3(v1, v->co); } - mul_m4_v3(ob->object_to_world, v1); + mul_m4_v3(ob->object_to_world().ptr(), v1); numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); @@ -629,7 +629,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, if (clip_segment_v3_plane_n(v1, v2, clip_planes, 4, v1_clip, v2_clip)) { mid_v3_v3v3(vmid, v1_clip, v2_clip); - mul_m4_v3(ob->object_to_world, vmid); + mul_m4_v3(ob->object_to_world().ptr(), vmid); numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add( @@ -663,7 +663,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, BM_face_calc_center_median(f, v1); } - mul_m4_v3(ob->object_to_world, v1); + mul_m4_v3(ob->object_to_world().ptr(), v1); numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh index 56520094adc..60cb33c173a 100644 --- a/source/blender/draw/intern/draw_resource.hh +++ b/source/blender/draw/intern/draw_resource.hh @@ -34,8 +34,8 @@ inline void ObjectMatrices::sync(const Object &object) { - model.view() = blender::float4x4_view(object.object_to_world); - model_inverse.view() = blender::float4x4_view(object.world_to_object); + model = object.object_to_world(); + model_inverse = object.world_to_object(); } inline void ObjectMatrices::sync(const float4x4 &model_matrix) diff --git a/source/blender/draw/intern/draw_sculpt.cc b/source/blender/draw/intern/draw_sculpt.cc index 0559879dab4..869eefd77a1 100644 --- a/source/blender/draw/intern/draw_sculpt.cc +++ b/source/blender/draw/intern/draw_sculpt.cc @@ -68,7 +68,7 @@ static Vector sculpt_batches_get_ex(const Object *ob, /* Transform clipping planes to object space. Transforming a plane with a * 4x4 matrix is done by multiplying with the transpose inverse. * The inverse cancels out here since we transform by inverse(obmat). */ - float4x4 tmat = math::transpose(float4x4(ob->object_to_world)); + float4x4 tmat = math::transpose(ob->object_to_world()); for (int i : IndexRange(6)) { draw_planes[i] = tmat * draw_planes[i]; update_planes[i] = draw_planes[i]; diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index b0c92e05060..efb6ddf1365 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -129,7 +129,7 @@ static DRWShadingGroup *drw_volume_object_grids_init(Object *ob, grp = DRW_shgroup_create_sub(grp); - volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world); + volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world().ptr()); volume_infos.color_mul = float4(1.0f); volume_infos.temperature_mul = 1.0f; volume_infos.temperature_bias = 0.0f; @@ -305,7 +305,7 @@ PassType *volume_object_grids_init(PassType &ps, Volume *volume = (Volume *)ob->data; BKE_volume_load(volume, G.main); - volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world); + volume_infos.density_scale = BKE_volume_density_scale(volume, ob->object_to_world().ptr()); volume_infos.color_mul = float4(1.0f); volume_infos.temperature_mul = 1.0f; volume_infos.temperature_bias = 0.0f; diff --git a/source/blender/editors/animation/anim_motion_paths.cc b/source/blender/editors/animation/anim_motion_paths.cc index 14e9e661eeb..be5fe2c4d9e 100644 --- a/source/blender/editors/animation/anim_motion_paths.cc +++ b/source/blender/editors/animation/anim_motion_paths.cc @@ -168,18 +168,17 @@ static void motionpaths_calc_bake_targets(ListBase *targets, } /* Result must be in world-space. */ - mul_m4_v3(ob_eval->object_to_world, mpv->co); + mul_m4_v3(ob_eval->object_to_world().ptr(), mpv->co); } else { /* World-space object location. */ - copy_v3_v3(mpv->co, ob_eval->object_to_world[3]); + copy_v3_v3(mpv->co, ob_eval->object_to_world().location()); } if (mpath->flag & MOTIONPATH_FLAG_BAKE_CAMERA && camera) { Object *cam_eval = DEG_get_evaluated_object(depsgraph, camera); /* Convert point to camera space. */ - float3 co_camera_space = math::transform_point(float4x4(cam_eval->world_to_object), - float3(mpv->co)); + float3 co_camera_space = math::transform_point(cam_eval->world_to_object(), float3(mpv->co)); copy_v3_v3(mpv->co, co_camera_space); } diff --git a/source/blender/editors/armature/armature_add.cc b/source/blender/editors/armature/armature_add.cc index 86a2b6d669f..8d309177621 100644 --- a/source/blender/editors/armature/armature_add.cc +++ b/source/blender/editors/armature/armature_add.cc @@ -32,6 +32,7 @@ #include "BKE_idprop.h" #include "BKE_layer.hh" #include "BKE_lib_id.hh" +#include "BKE_object_types.hh" #include "RNA_access.hh" #include "RNA_define.hh" @@ -196,13 +197,13 @@ static int armature_click_extrude_exec(bContext *C, wmOperator * /*op*/) const View3DCursor *curs = &scene->cursor; copy_v3_v3(newbone->tail, curs->location); - sub_v3_v3v3(newbone->tail, newbone->tail, obedit->object_to_world[3]); + sub_v3_v3v3(newbone->tail, newbone->tail, obedit->object_to_world().location()); if (a == 1) { newbone->tail[0] = -newbone->tail[0]; } - copy_m3_m4(mat, obedit->object_to_world); + copy_m3_m4(mat, obedit->object_to_world().ptr()); invert_m3_m3(imat, mat); mul_m3_v3(imat, newbone->tail); @@ -1638,8 +1639,8 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) copy_v3_v3(curs, CTX_data_scene(C)->cursor.location); /* Get inverse point for head and orientation for tail */ - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); - mul_m4_v3(obedit->world_to_object, curs); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + mul_m4_v3(obedit->world_to_object().ptr(), curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) { copy_m3_m4(obmat, rv3d->viewmat); @@ -1648,7 +1649,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) unit_m3(obmat); } - copy_m3_m4(viewmat, obedit->object_to_world); + copy_m3_m4(viewmat, obedit->object_to_world().ptr()); mul_m3_m3m3(totmat, obmat, viewmat); invert_m3_m3(imat, totmat); diff --git a/source/blender/editors/armature/armature_edit.cc b/source/blender/editors/armature/armature_edit.cc index 36d5a340673..233bea92607 100644 --- a/source/blender/editors/armature/armature_edit.cc +++ b/source/blender/editors/armature/armature_edit.cc @@ -30,6 +30,7 @@ #include "BKE_layer.hh" #include "BKE_main.hh" #include "BKE_object.hh" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "RNA_access.hh" @@ -118,8 +119,8 @@ void ED_armature_origin_set( /* Find the center-point. */ if (centermode == 2) { copy_v3_v3(cent, cursor); - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_v3(ob->world_to_object, cent); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_v3(ob->world_to_object().ptr(), cent); } else { if (around == V3D_AROUND_CENTER_BOUNDS) { @@ -159,7 +160,7 @@ void ED_armature_origin_set( /* Adjust object location for new center-point. */ if (centermode && (is_editmode == false)) { - mul_mat3_m4_v3(ob->object_to_world, cent); /* omit translation part */ + mul_mat3_m4_v3(ob->object_to_world().ptr(), cent); /* omit translation part */ add_v3_v3(ob->loc, cent); } } @@ -285,16 +286,16 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) axis_flip = true; } - copy_m3_m4(imat, ob->object_to_world); + copy_m3_m4(imat, ob->object_to_world().ptr()); invert_m3(imat); if (type == CALC_ROLL_CURSOR) { /* Cursor */ float cursor_local[3]; const View3DCursor *cursor = &scene->cursor; - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); copy_v3_v3(cursor_local, cursor->location); - mul_m4_v3(ob->world_to_object, cursor_local); + mul_m4_v3(ob->world_to_object().ptr(), cursor_local); /* cursor */ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -730,8 +731,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) ebp = static_cast(points.first); /* Get points - cursor (tail) */ - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); - mul_v3_m4v3(curs, obedit->world_to_object, scene->cursor.location); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + mul_v3_m4v3(curs, obedit->world_to_object().ptr(), scene->cursor.location); /* Create a bone */ newbone = add_points_bone(obedit, ebp->vec, curs); @@ -768,8 +769,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) float dist_sq_a, dist_sq_b; /* get cursor location */ - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); - mul_v3_m4v3(curs, obedit->world_to_object, scene->cursor.location); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + mul_v3_m4v3(curs, obedit->world_to_object().ptr(), scene->cursor.location); /* get distances */ dist_sq_a = len_squared_v3v3(ebp_a->vec, curs); diff --git a/source/blender/editors/armature/armature_relations.cc b/source/blender/editors/armature/armature_relations.cc index 57d59304bc4..349733e9db7 100644 --- a/source/blender/editors/armature/armature_relations.cc +++ b/source/blender/editors/armature/armature_relations.cc @@ -340,7 +340,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) /* Inverse transform for all selected armatures in this object, * See #object_join_exec for detailed comment on why the safe version is used. */ - invert_m4_m4_safe_ortho(oimat, ob_active->object_to_world); + invert_m4_m4_safe_ortho(oimat, ob_active->object_to_world().ptr()); /* Index bone collections by name. This is also used later to keep track * of collections added from other armatures. */ @@ -391,7 +391,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) // BASACT->flag &= ~OB_MODE_POSE; /* Find the difference matrix */ - mul_m4_m4m4(mat, oimat, ob_iter->object_to_world); + mul_m4_m4m4(mat, oimat, ob_iter->object_to_world().ptr()); /* Copy bones and posechannels from the object to the edit armature */ for (pchan = static_cast(opose->chanbase.first); pchan; pchan = pchann) { diff --git a/source/blender/editors/armature/armature_select.cc b/source/blender/editors/armature/armature_select.cc index 37a64a4fc36..f27972cf1ca 100644 --- a/source/blender/editors/armature/armature_select.cc +++ b/source/blender/editors/armature/armature_select.cc @@ -1580,8 +1580,8 @@ static const EnumPropertyItem prop_similar_types[] = { static float bone_length_squared_worldspace_get(Object *ob, EditBone *ebone) { float v1[3], v2[3]; - mul_v3_mat3_m4v3(v1, ob->object_to_world, ebone->head); - mul_v3_mat3_m4v3(v2, ob->object_to_world, ebone->tail); + mul_v3_mat3_m4v3(v1, ob->object_to_world().ptr(), ebone->head); + mul_v3_mat3_m4v3(v2, ob->object_to_world().ptr(), ebone->tail); return len_squared_v3v3(v1, v2); } @@ -1626,8 +1626,8 @@ static void bone_direction_worldspace_get(Object *ob, EditBone *ebone, float *r_ copy_v3_v3(v1, ebone->head); copy_v3_v3(v2, ebone->tail); - mul_m4_v3(ob->object_to_world, v1); - mul_m4_v3(ob->object_to_world, v2); + mul_m4_v3(ob->object_to_world().ptr(), v1); + mul_m4_v3(ob->object_to_world().ptr(), v2); sub_v3_v3v3(r_dir, v1, v2); normalize_v3(r_dir); diff --git a/source/blender/editors/armature/armature_skinning.cc b/source/blender/editors/armature/armature_skinning.cc index 29f8542a8f2..1c0d2674929 100644 --- a/source/blender/editors/armature/armature_skinning.cc +++ b/source/blender/editors/armature/armature_skinning.cc @@ -376,8 +376,8 @@ static void add_verts_to_dgroups(ReportList *reports, copy_v3_v3(tip[j], bone->arm_tail); } - mul_m4_v3(par->object_to_world, root[j]); - mul_m4_v3(par->object_to_world, tip[j]); + mul_m4_v3(par->object_to_world().ptr(), root[j]); + mul_m4_v3(par->object_to_world().ptr(), tip[j]); /* set selected */ if (wpmode) { @@ -426,7 +426,7 @@ static void add_verts_to_dgroups(ReportList *reports, if (!vertsfilled) { copy_v3_v3(verts[i], positions[i]); } - mul_m4_v3(ob->object_to_world, verts[i]); + mul_m4_v3(ob->object_to_world().ptr(), verts[i]); } /* compute the weights based on gathered vertices and bones */ @@ -450,7 +450,7 @@ static void add_verts_to_dgroups(ReportList *reports, root, tip, selected, - mat4_to_scale(par->object_to_world)); + mat4_to_scale(par->object_to_world().ptr())); } /* only generated in some cases but can call anyway */ diff --git a/source/blender/editors/armature/meshlaplacian.cc b/source/blender/editors/armature/meshlaplacian.cc index 98edbe7017d..cfb777e833d 100644 --- a/source/blender/editors/armature/meshlaplacian.cc +++ b/source/blender/editors/armature/meshlaplacian.cc @@ -1795,11 +1795,11 @@ void ED_mesh_deform_bind_callback(Object *object, mmd_orig->bindcagecos = (float *)mdb.cagecos; mmd_orig->verts_num = mdb.verts_num; mmd_orig->cage_verts_num = mdb.cage_verts_num; - copy_m4_m4(mmd_orig->bindmat, mmd_orig->object->object_to_world); + copy_m4_m4(mmd_orig->bindmat, mmd_orig->object->object_to_world().ptr()); /* transform bindcagecos to world space */ for (a = 0; a < mdb.cage_verts_num; a++) { - mul_m4_v3(mmd_orig->object->object_to_world, mmd_orig->bindcagecos + a * 3); + mul_m4_v3(mmd_orig->object->object_to_world().ptr(), mmd_orig->bindcagecos + a * 3); } /* free */ diff --git a/source/blender/editors/armature/pose_transform.cc b/source/blender/editors/armature/pose_transform.cc index 9db8e91fd86..5e3af8f446c 100644 --- a/source/blender/editors/armature/pose_transform.cc +++ b/source/blender/editors/armature/pose_transform.cc @@ -94,10 +94,10 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec /* apply current transform from parent (not yet destroyed), * then calculate new parent inverse matrix */ - BKE_object_apply_mat4(ob, ob->object_to_world, false, false); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } } } diff --git a/source/blender/editors/curve/editcurve.cc b/source/blender/editors/curve/editcurve.cc index 7f2e22a8e70..582a505dcf5 100644 --- a/source/blender/editors/curve/editcurve.cc +++ b/source/blender/editors/curve/editcurve.cc @@ -5016,7 +5016,7 @@ bool ed_editnurb_spin( invert_m3_m3(persinv, persmat); /* imat and center and size */ - copy_m3_m4(bmat, obedit->object_to_world); + copy_m3_m4(bmat, obedit->object_to_world().ptr()); invert_m3_m3(imat, bmat); axis_angle_to_mat3(cmat, axis, M_PI_4); @@ -5110,8 +5110,8 @@ static int spin_exec(bContext *C, wmOperator *op) continue; } - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); - mul_m4_v3(obedit->world_to_object, cent); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + mul_m4_v3(obedit->world_to_object().ptr(), cent); if (!ed_editnurb_spin(viewmat, v3d, obedit, axis, cent)) { count_failed += 1; @@ -5589,7 +5589,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "location", location); - invert_m4_m4(imat, obedit->object_to_world); + invert_m4_m4(imat, obedit->object_to_world().ptr()); mul_m4_v3(imat, location); if (ed_editcurve_addvert(cu, editnurb, v3d, location)) { @@ -5628,10 +5628,10 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) ED_curve_nurb_vert_selected_find(cu, vc.v3d, &nu, &bezt, &bp); if (bezt) { - mul_v3_m4v3(location, vc.obedit->object_to_world, bezt->vec[1]); + mul_v3_m4v3(location, vc.obedit->object_to_world().ptr(), bezt->vec[1]); } else if (bp) { - mul_v3_m4v3(location, vc.obedit->object_to_world, bp->vec); + mul_v3_m4v3(location, vc.obedit->object_to_world().ptr(), bp->vec); } else { copy_v3_v3(location, vc.scene->cursor.location); @@ -5672,10 +5672,10 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) ED_view3d_global_to_vector(vc.rv3d, location, view_dir); /* get the plane */ - const float *plane_co = vc.obedit->object_to_world[3]; + const float *plane_co = vc.obedit->object_to_world().location(); float plane_no[3]; /* only normalize to avoid precision errors */ - normalize_v3_v3(plane_no, vc.obedit->object_to_world[2]); + normalize_v3_v3(plane_no, vc.obedit->object_to_world()[2]); if (fabsf(dot_v3v3(view_dir, plane_no)) < eps) { /* can't project on an aligned plane. */ @@ -6922,7 +6922,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) /* Inverse transform for all selected curves in this object, * See object_join_exec for detailed comment on why the safe version is used. */ - invert_m4_m4_safe_ortho(imat, ob_active->object_to_world); + invert_m4_m4_safe_ortho(imat, ob_active->object_to_world().ptr()); Curve *cu_active = static_cast(ob_active->data); @@ -6934,7 +6934,7 @@ int ED_curve_join_objects_exec(bContext *C, wmOperator *op) if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ - mul_m4_m4m4(cmat, imat, ob_iter->object_to_world); + mul_m4_m4m4(cmat, imat, ob_iter->object_to_world().ptr()); /* Compensate for different bevel depth. */ bool do_radius = false; diff --git a/source/blender/editors/curve/editcurve_paint.cc b/source/blender/editors/curve/editcurve_paint.cc index 794819705bf..a44314f33cf 100644 --- a/source/blender/editors/curve/editcurve_paint.cc +++ b/source/blender/editors/curve/editcurve_paint.cc @@ -18,6 +18,7 @@ #include "BKE_context.hh" #include "BKE_curve.hh" #include "BKE_fcurve.h" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "DEG_depsgraph.hh" @@ -152,7 +153,8 @@ static void stroke_elem_pressure_set(const CurveDrawData *cdd, StrokeElem *selem const float adjust = stroke_elem_radius_from_pressure(cdd, pressure) - stroke_elem_radius_from_pressure(cdd, selem->pressure); madd_v3_v3fl(selem->location_local, selem->normal_local, adjust); - mul_v3_m4v3(selem->location_world, cdd->vc.obedit->object_to_world, selem->location_local); + mul_v3_m4v3( + selem->location_world, cdd->vc.obedit->object_to_world().ptr(), selem->location_local); } selem->pressure = pressure; } @@ -249,11 +251,11 @@ static bool stroke_elem_project_fallback(const CurveDrawData *cdd, cdd->vc.v3d, cdd->vc.region, location_fallback_depth, mval_fl, r_location_world); zero_v3(r_normal_local); } - mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object, r_location_world); + mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object().ptr(), r_location_world); if (!is_zero_v3(r_normal_world)) { copy_v3_v3(r_normal_local, r_normal_world); - mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world, r_normal_local); + mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world().ptr(), r_normal_local); normalize_v3(r_normal_local); } else { @@ -308,7 +310,8 @@ static void curve_draw_stroke_from_operator_elem(wmOperator *op, PointerRNA *ite RNA_float_get_array(itemptr, "mouse", selem->mval); RNA_float_get_array(itemptr, "location", selem->location_world); - mul_v3_m4v3(selem->location_local, cdd->vc.obedit->world_to_object, selem->location_world); + mul_v3_m4v3( + selem->location_local, cdd->vc.obedit->world_to_object().ptr(), selem->location_world); selem->pressure = RNA_float_get(itemptr, "pressure"); } @@ -371,7 +374,7 @@ static void curve_draw_stroke_3d(const bContext * /*C*/, ARegion * /*region*/, v /* scale to edit-mode space */ GPU_matrix_push(); - GPU_matrix_mul(obedit->object_to_world); + GPU_matrix_mul(obedit->object_to_world().ptr()); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = static_cast(BLI_mempool_iterstep(&iter)); selem; @@ -453,7 +456,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event) CurveDrawData *cdd = static_cast(op->customdata); Object *obedit = cdd->vc.obedit; - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); StrokeElem *selem = static_cast(BLI_mempool_calloc(cdd->stroke_elem_pool)); @@ -776,7 +779,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); const bool is_3d = (cu->flag & CU_3D) != 0; - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); if (BLI_mempool_len(cdd->stroke_elem_pool) == 0) { curve_draw_stroke_from_operator(op); @@ -1095,8 +1098,8 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (CU_IS_2D(cu)) { /* 2D overrides other options */ - plane_co = obedit->object_to_world[3]; - plane_no = obedit->object_to_world[2]; + plane_co = obedit->object_to_world().location(); + plane_no = obedit->object_to_world().ptr()[2]; cdd->project.use_plane = true; } else { diff --git a/source/blender/editors/curve/editcurve_pen.cc b/source/blender/editors/curve/editcurve_pen.cc index 3b6405dde39..cb1d2b72982 100644 --- a/source/blender/editors/curve/editcurve_pen.cc +++ b/source/blender/editors/curve/editcurve_pen.cc @@ -151,10 +151,10 @@ static void update_location_for_2d_curve(const ViewContext *vc, float location[3 ED_view3d_global_to_vector(vc->rv3d, location, view_dir); /* Get the plane. */ - const float *plane_co = vc->obedit->object_to_world[3]; + const float *plane_co = vc->obedit->object_to_world().location(); float plane_no[3]; /* Only normalize to avoid precision errors. */ - normalize_v3_v3(plane_no, vc->obedit->object_to_world[2]); + normalize_v3_v3(plane_no, vc->obedit->object_to_world()[2]); if (fabsf(dot_v3v3(view_dir, plane_no)) < eps) { /* Can't project on an aligned plane. */ @@ -175,7 +175,7 @@ static void update_location_for_2d_curve(const ViewContext *vc, float location[3 } float imat[4][4]; - invert_m4_m4(imat, vc->obedit->object_to_world); + invert_m4_m4(imat, vc->obedit->object_to_world().ptr()); mul_m4_v3(imat, location); if (CU_IS_2D(cu)) { @@ -188,7 +188,7 @@ static void screenspace_to_worldspace(const ViewContext *vc, const float depth[3], float r_pos_3d[3]) { - mul_v3_m4v3(r_pos_3d, vc->obedit->object_to_world, depth); + mul_v3_m4v3(r_pos_3d, vc->obedit->object_to_world().ptr(), depth); ED_view3d_win_to_3d(vc->v3d, vc->region, r_pos_3d, pos_2d, r_pos_3d); update_location_for_2d_curve(vc, r_pos_3d); } @@ -1102,7 +1102,7 @@ static void extrude_points_from_selected_vertices(const ViewContext *vc, float location[3]; if (sel_exists) { - mul_v3_m4v3(location, vc->obedit->object_to_world, center); + mul_v3_m4v3(location, vc->obedit->object_to_world().ptr(), center); } else { copy_v3_v3(location, vc->scene->cursor.location); diff --git a/source/blender/editors/curve/editcurve_select.cc b/source/blender/editors/curve/editcurve_select.cc index 931141739ef..e0cf34b5e78 100644 --- a/source/blender/editors/curve/editcurve_select.cc +++ b/source/blender/editors/curve/editcurve_select.cc @@ -1508,7 +1508,7 @@ static void nurb_bezt_direction_worldspace_get(Object *ob, { float rsmat[3][3]; BKE_nurb_bezt_calc_normal(nu, bezt, r_dir); - copy_m3_m4(rsmat, ob->object_to_world); + copy_m3_m4(rsmat, ob->object_to_world().ptr()); mul_m3_v3(rsmat, r_dir); normalize_v3(r_dir); } @@ -1517,7 +1517,7 @@ static void nurb_bpoint_direction_worldspace_get(Object *ob, Nurb *nu, BPoint *b { float rsmat[3][3]; BKE_nurb_bpoint_calc_normal(nu, bp, r_dir); - copy_m3_m4(rsmat, ob->object_to_world); + copy_m3_m4(rsmat, ob->object_to_world().ptr()); mul_m3_v3(rsmat, r_dir); normalize_v3(r_dir); } diff --git a/source/blender/editors/curve/editfont.cc b/source/blender/editors/curve/editfont.cc index 509976ada46..9494f0c8e76 100644 --- a/source/blender/editors/curve/editfont.cc +++ b/source/blender/editors/curve/editfont.cc @@ -1956,7 +1956,8 @@ static int font_cursor_text_index_from_event(bContext *C, Object *obedit, const { /* Calculate a plane from the text object's orientation. */ float plane[4]; - plane_from_point_normal_v3(plane, obedit->object_to_world[3], obedit->object_to_world[2]); + plane_from_point_normal_v3( + plane, obedit->object_to_world().location(), obedit->object_to_world().ptr()[2]); /* Convert Mouse location in region to 3D location in world space. */ float mal_fl[2] = {float(event->mval[0]), float(event->mval[1])}; @@ -1964,7 +1965,7 @@ static int font_cursor_text_index_from_event(bContext *C, Object *obedit, const ED_view3d_win_to_3d_on_plane(CTX_wm_region(C), plane, mal_fl, true, mouse_loc); /* Convert to object space and scale by font size. */ - mul_m4_v3(obedit->world_to_object, mouse_loc); + mul_m4_v3(obedit->world_to_object().ptr(), mouse_loc); float curs_loc[2] = {mouse_loc[0], mouse_loc[1]}; return BKE_vfont_cursor_to_text_index(obedit, curs_loc); diff --git a/source/blender/editors/curves/intern/curves_draw.cc b/source/blender/editors/curves/intern/curves_draw.cc index 51cfc28a771..ff440721594 100644 --- a/source/blender/editors/curves/intern/curves_draw.cc +++ b/source/blender/editors/curves/intern/curves_draw.cc @@ -12,6 +12,7 @@ #include "BKE_attribute.hh" #include "BKE_context.hh" #include "BKE_curves.hh" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "DEG_depsgraph.hh" @@ -140,7 +141,8 @@ static void stroke_elem_pressure_set(const CurveDrawData *cdd, StrokeElem *selem const float adjust = stroke_elem_radius_from_pressure(cdd, pressure) - stroke_elem_radius_from_pressure(cdd, selem->pressure); madd_v3_v3fl(selem->location_local, selem->normal_local, adjust); - mul_v3_m4v3(selem->location_world, cdd->vc.obedit->object_to_world, selem->location_local); + mul_v3_m4v3( + selem->location_world, cdd->vc.obedit->object_to_world().ptr(), selem->location_local); } selem->pressure = pressure; } @@ -237,11 +239,11 @@ static bool stroke_elem_project_fallback(const CurveDrawData *cdd, cdd->vc.v3d, cdd->vc.region, location_fallback_depth, mval_fl, r_location_world); zero_v3(r_normal_local); } - mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object, r_location_world); + mul_v3_m4v3(r_location_local, cdd->vc.obedit->world_to_object().ptr(), r_location_world); if (!is_zero_v3(r_normal_world)) { copy_v3_v3(r_normal_local, r_normal_world); - mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world, r_normal_local); + mul_transposed_mat3_m4_v3(cdd->vc.obedit->object_to_world().ptr(), r_normal_local); normalize_v3(r_normal_local); } else { @@ -296,7 +298,8 @@ static void curve_draw_stroke_from_operator_elem(wmOperator *op, PointerRNA *ite RNA_float_get_array(itemptr, "mouse", selem->mval); RNA_float_get_array(itemptr, "location", selem->location_world); - mul_v3_m4v3(selem->location_local, cdd->vc.obedit->world_to_object, selem->location_world); + mul_v3_m4v3( + selem->location_local, cdd->vc.obedit->world_to_object().ptr(), selem->location_world); selem->pressure = RNA_float_get(itemptr, "pressure"); } @@ -354,7 +357,7 @@ static void curve_draw_stroke_3d(const bContext * /*C*/, ARegion * /*region*/, v /* scale to edit-mode space */ GPU_matrix_push(); - GPU_matrix_mul(obedit->object_to_world); + GPU_matrix_mul(obedit->object_to_world().ptr()); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = static_cast(BLI_mempool_iterstep(&iter)); selem; @@ -436,7 +439,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event) CurveDrawData *cdd = static_cast(op->customdata); Object *obedit = cdd->vc.obedit; - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); StrokeElem *selem = static_cast(BLI_mempool_calloc(cdd->stroke_elem_pool)); @@ -740,7 +743,7 @@ static int curves_draw_exec(bContext *C, wmOperator *op) int stroke_len = BLI_mempool_len(cdd->stroke_elem_pool); - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); if (BLI_mempool_len(cdd->stroke_elem_pool) == 0) { curve_draw_stroke_from_operator(op); @@ -1040,8 +1043,8 @@ static int curves_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (cdd->is_curve_2d) { /* 2D overrides other options */ - plane_co = obedit->object_to_world[3]; - plane_no = obedit->object_to_world[2]; + plane_co = obedit->object_to_world().location(); + plane_no = obedit->object_to_world().ptr()[2]; cdd->project.use_plane = true; } else { diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index d9bbd48ac01..4325305d033 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -479,7 +479,7 @@ static bke::CurvesGeometry particles_to_curves(Object &object, ParticleSystem &p bke::CurvesGeometry curves(points_num, curves_num); curves.offsets_for_write().copy_from(curve_offsets); - const float4x4 object_to_world_mat(object.object_to_world); + const float4x4 object_to_world_mat = object.object_to_world(); const float4x4 world_to_object_mat = math::invert(object_to_world_mat); MutableSpan positions = curves.positions_for_write(); @@ -542,7 +542,7 @@ static int curves_convert_from_particle_system_exec(bContext *C, wmOperator * /* Object *ob_new = BKE_object_add(&bmain, &scene, &view_layer, OB_CURVES, psys_eval->name); Curves *curves_id = static_cast(ob_new->data); - BKE_object_apply_mat4(ob_new, ob_from_orig->object_to_world, true, false); + BKE_object_apply_mat4(ob_new, ob_from_orig->object_to_world().ptr(), true, false); curves_id->geometry.wrap() = particles_to_curves(*ob_from_eval, *psys_eval); DEG_relations_tag_update(&bmain); diff --git a/source/blender/editors/gpencil_legacy/gpencil_armature.cc b/source/blender/editors/gpencil_legacy/gpencil_armature.cc index 22081000843..3d818b9416f 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_armature.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_armature.cc @@ -338,8 +338,8 @@ static void gpencil_add_verts_to_dgroups( copy_v3_v3(tip[j], bone->arm_tail); } - mul_m4_v3(ob_arm->object_to_world, root[j]); - mul_m4_v3(ob_arm->object_to_world, tip[j]); + mul_m4_v3(ob_arm->object_to_world().ptr(), root[j]); + mul_m4_v3(ob_arm->object_to_world().ptr(), tip[j]); selected[j] = 1; @@ -374,7 +374,7 @@ static void gpencil_add_verts_to_dgroups( /* transform stroke points to global space */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { copy_v3_v3(verts[i], &pt->x); - mul_m4_v3(ob->object_to_world, verts[i]); + mul_m4_v3(ob->object_to_world().ptr(), verts[i]); } /* loop groups and assign weight */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc index 1f948a398bc..0bf65293cbf 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_bake_animation.cc @@ -216,7 +216,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0; ob_gpencil = ED_gpencil_add_object(C, scene->cursor.location, local_view_bits); float invmat[4][4]; - invert_m4_m4(invmat, ob_gpencil->object_to_world); + invert_m4_m4(invmat, ob_gpencil->object_to_world().ptr()); bGPdata *gpd_dst = (bGPdata *)ob_gpencil->data; gpd_dst->draw_mode = GP_DRAWMODE_2D; @@ -317,7 +317,7 @@ static int gpencil_bake_grease_pencil_animation_exec(bContext *C, wmOperator *op bGPDspoint *pt = &gps->points[j]; pt->runtime.idx_orig = 0; pt->runtime.pt_orig = nullptr; - mul_m4_v3(ob_eval->object_to_world, &pt->x); + mul_m4_v3(ob_eval->object_to_world().ptr(), &pt->x); mul_m4_v3(invmat, &pt->x); } diff --git a/source/blender/editors/gpencil_legacy/gpencil_data.cc b/source/blender/editors/gpencil_legacy/gpencil_data.cc index eac23dd2e71..312c8bd2f08 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_data.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_data.cc @@ -2972,8 +2972,8 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) float offset_global[3]; float offset_local[3]; - sub_v3_v3v3(offset_global, ob_active->loc, ob_iter->object_to_world[3]); - copy_m3_m4(bmat, ob_active->object_to_world); + sub_v3_v3v3(offset_global, ob_active->loc, ob_iter->object_to_world().location()); + copy_m3_m4(bmat, ob_active->object_to_world().ptr()); /* Inverse transform for all selected curves in this object, * See #object_join_exec for detailed comment on why the safe version is used. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit.cc b/source/blender/editors/gpencil_legacy/gpencil_edit.cc index aa0e4ba7a16..43b10639880 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_edit.cc @@ -4184,7 +4184,7 @@ static int gpencil_stroke_outline_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *cam_ob = scene->camera; if (cam_ob != nullptr) { - invert_m4_m4(viewmat, cam_ob->object_to_world); + invert_m4_m4(viewmat, cam_ob->object_to_world().ptr()); } break; } @@ -4252,7 +4252,7 @@ static int gpencil_stroke_outline_exec(bContext *C, wmOperator *op) /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world); + gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world().ptr()); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Stroke. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_mesh.cc b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc index 2d6a1248f12..8b1fdf53779 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_mesh.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_mesh.cc @@ -296,7 +296,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op) angle, thickness, offset, - ob_eval->object_to_world, + ob_eval->object_to_world().ptr(), frame_offset, use_seams, use_faces, diff --git a/source/blender/editors/gpencil_legacy/gpencil_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_paint.cc index c833fe61771..05c3db3fbe2 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_paint.cc @@ -937,7 +937,7 @@ static bGPDstroke *gpencil_stroke_to_outline(tGPsdata *p, bGPDstroke *gps) /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - gps_duplicate->thickness *= mat4_to_scale(p->ob->object_to_world); + gps_duplicate->thickness *= mat4_to_scale(p->ob->object_to_world().ptr()); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Stroke. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc index 9d6b396d513..6aff2e38186 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.cc @@ -677,7 +677,7 @@ static bool gpencil_brush_pinch_apply(tGP_BrushEditData *gso, /* 1) Make this point relative to the cursor/midpoint (dvec) */ float fpt[3]; - mul_v3_m4v3(fpt, gso->object->object_to_world, &pt->x); + mul_v3_m4v3(fpt, gso->object->object_to_world().ptr(), &pt->x); sub_v3_v3v3(vec, fpt, gso->dvec); /* 2) Shrink the distance by pulling the point towards the midpoint @@ -697,7 +697,7 @@ static bool gpencil_brush_pinch_apply(tGP_BrushEditData *gso, /* 3) Translate back to original space, with the shrinkage applied */ add_v3_v3v3(fpt, gso->dvec, vec); - mul_v3_m4v3(&pt->x, gso->object->world_to_object, fpt); + mul_v3_m4v3(&pt->x, gso->object->world_to_object().ptr(), fpt); /* compute lock axis */ gpencil_sculpt_compute_lock_axis(gso, pt, save_pt); @@ -749,12 +749,12 @@ static bool gpencil_brush_twist_apply(tGP_BrushEditData *gso, /* Rotate point */ float fpt[3]; - mul_v3_m4v3(fpt, gso->object->object_to_world, &pt->x); + mul_v3_m4v3(fpt, gso->object->object_to_world().ptr(), &pt->x); sub_v3_v3v3(vec, fpt, gso->dvec); /* make relative to center * (center is stored in dvec) */ mul_m3_v3(rmat, vec); add_v3_v3v3(fpt, vec, gso->dvec); /* restore */ - mul_v3_m4v3(&pt->x, gso->object->world_to_object, fpt); + mul_v3_m4v3(&pt->x, gso->object->world_to_object().ptr(), fpt); /* compute lock axis */ gpencil_sculpt_compute_lock_axis(gso, pt, save_pt); @@ -1045,11 +1045,11 @@ static void gpencil_brush_clone_add(bContext *C, tGP_BrushEditData *gso) */ for (i = 0, pt = new_stroke->points; i < new_stroke->totpoints; i++, pt++) { /* Rotate around center new position */ - mul_mat3_m4_v3(gso->object->object_to_world, &pt->x); /* only rotation component */ + mul_mat3_m4_v3(gso->object->object_to_world().ptr(), &pt->x); /* only rotation component */ /* assume that the delta can just be applied, and then everything works */ add_v3_v3(&pt->x, delta); - mul_m4_v3(gso->object->world_to_object, &pt->x); + mul_m4_v3(gso->object->world_to_object().ptr(), &pt->x); } /* Store ref for later */ @@ -1180,7 +1180,7 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op) gso->object = ob; if (ob) { float matrix[4][4]; - copy_m4_m4(matrix, ob->object_to_world); + copy_m4_m4(matrix, ob->object_to_world().ptr()); zero_axis_bias_m4(matrix); invert_m4_m4(gso->inv_mat, matrix); gso->vrgroup = gso->gpd->vertex_group_active_index - 1; diff --git a/source/blender/editors/gpencil_legacy/gpencil_select.cc b/source/blender/editors/gpencil_legacy/gpencil_select.cc index 5be74daa068..a64d525802b 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_select.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_select.cc @@ -2052,7 +2052,7 @@ static bool gpencil_generic_stroke_select(bContext *C, Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = depsgraph != nullptr ? DEG_get_evaluated_object(depsgraph, ob) : ob; float select_mat[4][4]; - copy_m4_m4(select_mat, ob_eval->object_to_world); + copy_m4_m4(select_mat, ob_eval->object_to_world().ptr()); /* deselect all strokes first? */ if (SEL_OP_USE_PRE_DESELECT(sel_op)) { diff --git a/source/blender/editors/gpencil_legacy/gpencil_utils.cc b/source/blender/editors/gpencil_legacy/gpencil_utils.cc index 2176d7540ea..8502621460c 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_utils.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_utils.cc @@ -906,7 +906,7 @@ void ED_gpencil_drawing_reference_get(const Scene *scene, } else { /* use object location */ - copy_v3_v3(r_vec, ob->object_to_world[3]); + copy_v3_v3(r_vec, ob->object_to_world().location()); /* Apply layer offset. */ bGPdata *gpd = static_cast(ob->data); bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); @@ -990,7 +990,7 @@ void ED_gpencil_project_stroke_to_plane(const Scene *scene, /* if object, apply object rotation */ if (ob && (ob->type == OB_GPENCIL_LEGACY)) { float mat[4][4]; - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); /* move origin to cursor */ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { @@ -1213,7 +1213,7 @@ void ED_gpencil_project_point_to_plane(const Scene *scene, /* if object, apply object rotation */ if (ob && (ob->type == OB_GPENCIL_LEGACY)) { float mat[4][4]; - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { if (gpl != nullptr) { add_v3_v3(mat[3], gpl->location); @@ -1240,7 +1240,7 @@ void ED_gpencil_project_point_to_plane(const Scene *scene, /* move origin to object */ if ((ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { - copy_v3_v3(mat[3], ob->object_to_world[3]); + copy_v3_v3(mat[3], ob->object_to_world().location()); } mul_mat3_m4_v3(mat, plane_normal); @@ -1374,16 +1374,16 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata if (gpl->parent != nullptr) { /* calculate new matrix */ if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { - invert_m4_m4(cur_mat, gpl->parent->object_to_world); - copy_v3_v3(gpl_loc, obact->object_to_world[3]); + invert_m4_m4(cur_mat, gpl->parent->object_to_world().ptr()); + copy_v3_v3(gpl_loc, obact->object_to_world().location()); } else if (gpl->partype == PARBONE) { bPoseChannel *pchan = BKE_pose_channel_find_name(gpl->parent->pose, gpl->parsubstr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, gpl->parent->object_to_world, pchan->pose_mat); + mul_m4_m4m4(tmp_mat, gpl->parent->object_to_world().ptr(), pchan->pose_mat); invert_m4_m4(cur_mat, tmp_mat); - copy_v3_v3(gpl_loc, obact->object_to_world[3]); + copy_v3_v3(gpl_loc, obact->object_to_world().location()); } } diff --git a/source/blender/editors/gpencil_legacy/gpencil_uv.cc b/source/blender/editors/gpencil_legacy/gpencil_uv.cc index 522f8824d3d..527d7133452 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_uv.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_uv.cc @@ -143,7 +143,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op) opdata->array_loc = nullptr; opdata->array_rot = nullptr; opdata->array_scale = nullptr; - opdata->ob_scale = mat4_to_scale(opdata->ob->object_to_world); + opdata->ob_scale = mat4_to_scale(opdata->ob->object_to_world().ptr()); opdata->vinit_rotation[0] = 1.0f; opdata->vinit_rotation[1] = 0.0f; @@ -163,7 +163,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op) float r_center[3]; gpencil_stroke_center(gps, r_center); /* Add object location. */ - add_v3_v3(r_center, opdata->ob->object_to_world[3]); + add_v3_v3(r_center, opdata->ob->object_to_world().location()); add_v3_v3(center, r_center); i++; } diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc index face51ccd0a..e7a80eb41e0 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc @@ -163,7 +163,8 @@ static void depthdropper_depth_sample_pt(bContext *C, View3D *v3d = static_cast(area->spacedata.first); RegionView3D *rv3d = static_cast(region->regiondata); /* weak, we could pass in some reference point */ - const float *view_co = v3d->camera ? v3d->camera->object_to_world[3] : rv3d->viewinv[3]; + const float *view_co = v3d->camera ? v3d->camera->object_to_world().location() : + rv3d->viewinv[3]; const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin}; copy_v2_v2_int(ddr->name_pos, mval); diff --git a/source/blender/editors/mesh/editface.cc b/source/blender/editors/mesh/editface.cc index 82909a8e45d..cfdf9e51022 100644 --- a/source/blender/editors/mesh/editface.cc +++ b/source/blender/editors/mesh/editface.cc @@ -725,7 +725,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) return ok; } - copy_m3_m4(bmat, ob->object_to_world); + copy_m3_m4(bmat, ob->object_to_world().ptr()); const Span positions = mesh->vert_positions(); const OffsetIndices faces = mesh->faces(); @@ -743,7 +743,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) for (const int vert : corner_verts.slice(faces[i])) { mul_v3_m3v3(vec, bmat, positions[vert]); - add_v3_v3v3(vec, vec, ob->object_to_world[3]); + add_v3_v3v3(vec, vec, ob->object_to_world().location()); minmax_v3v3_v3(r_min, r_max, vec); } diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.cc b/source/blender/editors/mesh/editmesh_add_gizmo.cc index e02af0ac588..0b13e4d090b 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.cc +++ b/source/blender/editors/mesh/editmesh_add_gizmo.cc @@ -15,6 +15,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" +#include "BKE_object_types.hh" #include "BKE_scene.hh" #include "BLI_math_geom.h" @@ -316,8 +317,8 @@ static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op) PropertyRNA *prop_matrix = RNA_struct_find_property(op->ptr, "matrix"); if (RNA_property_is_set(op->ptr, prop_matrix)) { RNA_property_float_get_array(op->ptr, prop_matrix, &matrix[0][0]); - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); - mul_m4_m4m4(matrix, obedit->world_to_object, matrix); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + mul_m4_m4m4(matrix, obedit->world_to_object().ptr(), matrix); } else { /* For the first update the widget may not set the matrix. */ diff --git a/source/blender/editors/mesh/editmesh_bevel.cc b/source/blender/editors/mesh/editmesh_bevel.cc index 9fb6317c53d..85624c9aab5 100644 --- a/source/blender/editors/mesh/editmesh_bevel.cc +++ b/source/blender/editors/mesh/editmesh_bevel.cc @@ -236,7 +236,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) const Vector objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( scene, view_layer, v3d); for (Object *obedit : objects) { - float scale = mat4_to_scale(obedit->object_to_world); + float scale = mat4_to_scale(obedit->object_to_world().ptr()); opdata->max_obj_scale = max_ff(opdata->max_obj_scale, scale); BMEditMesh *em = BKE_editmesh_from_object(obedit); if (em->bm->totvertsel > 0) { diff --git a/source/blender/editors/mesh/editmesh_bisect.cc b/source/blender/editors/mesh/editmesh_bisect.cc index ccdb4582c95..410227a0514 100644 --- a/source/blender/editors/mesh/editmesh_bisect.cc +++ b/source/blender/editors/mesh/editmesh_bisect.cc @@ -320,9 +320,9 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) copy_v3_v3(plane_co_local, plane_co); copy_v3_v3(plane_no_local, plane_no); - invert_m4_m4(imat, obedit->object_to_world); + invert_m4_m4(imat, obedit->object_to_world().ptr()); mul_m4_v3(imat, plane_co_local); - mul_transposed_mat3_m4_v3(obedit->object_to_world, plane_no_local); + mul_transposed_mat3_m4_v3(obedit->object_to_world().ptr(), plane_no_local); BMOperator bmop; EDBM_op_init( diff --git a/source/blender/editors/mesh/editmesh_extrude.cc b/source/blender/editors/mesh/editmesh_extrude.cc index f79fded44da..f58ff0c0699 100644 --- a/source/blender/editors/mesh/editmesh_extrude.cc +++ b/source/blender/editors/mesh/editmesh_extrude.cc @@ -17,6 +17,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "RNA_access.hh" @@ -59,8 +60,8 @@ static void edbm_extrude_edge_exclude_mirror( float mtx[4][4]; if (mmd->mirror_ob) { float imtx[4][4]; - invert_m4_m4(imtx, mmd->mirror_ob->object_to_world); - mul_m4_m4m4(mtx, imtx, obedit->object_to_world); + invert_m4_m4(imtx, mmd->mirror_ob->object_to_world().ptr()); + mul_m4_m4m4(mtx, imtx, obedit->object_to_world().ptr()); } BM_ITER_MESH (edge, &iter, bm, BM_EDGES_OF_MESH) { @@ -297,7 +298,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); - copy_m3_m4(tmat, obedit->object_to_world); + copy_m3_m4(tmat, obedit->object_to_world().ptr()); invert_m3(tmat); mul_v3_m3v3(offset_local, tmat, offset); @@ -723,7 +724,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w } mul_v3_fl(local_center, 1.0f / float(local_verts_len)); - mul_m4_v3(vc.obedit->object_to_world, local_center); + mul_m4_v3(vc.obedit->object_to_world().ptr(), local_center); mul_v3_fl(local_center, float(local_verts_len)); add_v3_v3(center, local_center); @@ -747,11 +748,11 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w continue; } - invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); + invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); float local_center[3]; - mul_v3_m4v3(local_center, vc.obedit->world_to_object, center); + mul_v3_m4v3(local_center, vc.obedit->world_to_object().ptr(), center); /* call extrude? */ if (verts_len != 0) { @@ -797,11 +798,11 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w float view_vec[3], cross[3]; /* convert the 2D normal into 3D */ - mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* World-space. */ - mul_mat3_m4_v3(vc.obedit->world_to_object, nor); /* Local-space. */ + mul_mat3_m4_v3(vc.rv3d->viewinv, nor); /* World-space. */ + mul_mat3_m4_v3(vc.obedit->world_to_object().ptr(), nor); /* Local-space. */ /* correct the normal to be aligned on the view plane */ - mul_v3_mat3_m4v3(view_vec, vc.obedit->world_to_object, vc.rv3d->viewinv[2]); + mul_v3_mat3_m4v3(view_vec, vc.obedit->world_to_object().ptr(), vc.rv3d->viewinv[2]); cross_v3_v3v3(cross, nor, view_vec); cross_v3_v3v3(nor, view_vec, cross); normalize_v3(nor); @@ -810,9 +811,9 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w /* center */ copy_v3_v3(ofs, local_center); - mul_m4_v3(vc.obedit->object_to_world, ofs); /* view space */ + mul_m4_v3(vc.obedit->object_to_world().ptr(), ofs); /* view space */ ED_view3d_win_to_3d_int(vc.v3d, vc.region, ofs, event->mval, ofs); - mul_m4_v3(vc.obedit->world_to_object, ofs); /* back in object space */ + mul_m4_v3(vc.obedit->world_to_object().ptr(), ofs); /* back in object space */ sub_v3_v3(ofs, local_center); @@ -863,7 +864,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w copy_v3_v3(local_center, cursor); ED_view3d_win_to_3d_int(vc.v3d, vc.region, local_center, event->mval, local_center); - mul_m4_v3(vc.obedit->world_to_object, local_center); /* back in object space */ + mul_m4_v3(vc.obedit->world_to_object().ptr(), local_center); /* back in object space */ EDBM_op_init(vc.em, &bmop, op, "create_vert co=%v", local_center); BMO_op_exec(vc.em->bm, &bmop); diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.cc b/source/blender/editors/mesh/editmesh_extrude_screw.cc index 253f033df51..eb3dbff238e 100644 --- a/source/blender/editors/mesh/editmesh_extrude_screw.cc +++ b/source/blender/editors/mesh/editmesh_extrude_screw.cc @@ -105,11 +105,11 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) continue; } - copy_v3_v3(nor, obedit->object_to_world[2]); + copy_v3_v3(nor, obedit->object_to_world().ptr()[2]); /* calculate dvec */ - mul_v3_m4v3(v1_co_global, obedit->object_to_world, v1->co); - mul_v3_m4v3(v2_co_global, obedit->object_to_world, v2->co); + mul_v3_m4v3(v1_co_global, obedit->object_to_world().ptr(), v1->co); + mul_v3_m4v3(v2_co_global, obedit->object_to_world().ptr(), v2->co); sub_v3_v3v3(dvec, v1_co_global, v2_co_global); mul_v3_fl(dvec, 1.0f / steps); @@ -129,7 +129,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) dvec, turns * steps, DEG2RADF(360.0f * turns), - obedit->object_to_world, + obedit->object_to_world().ptr(), false)) { continue; diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.cc b/source/blender/editors/mesh/editmesh_extrude_spin.cc index 8b84d6a876a..03e92109dca 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.cc +++ b/source/blender/editors/mesh/editmesh_extrude_spin.cc @@ -79,7 +79,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) d, steps, -angle, - obedit->object_to_world, + obedit->object_to_world().ptr(), use_normal_flip, dupli, use_auto_merge)) diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc index d4b95e5dc94..d5eb42a608a 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc @@ -367,7 +367,7 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou } if (totsel) { mul_v3_fl(select_center, 1.0f / totsel); - mul_m4_v3(obedit->object_to_world, select_center); + mul_m4_v3(obedit->object_to_world().ptr(), select_center); copy_v3_v3(ggd->data.select_center, select_center); ggd->data.use_select_center = true; } diff --git a/source/blender/editors/mesh/editmesh_inset.cc b/source/blender/editors/mesh/editmesh_inset.cc index f4419d49502..ded43533212 100644 --- a/source/blender/editors/mesh/editmesh_inset.cc +++ b/source/blender/editors/mesh/editmesh_inset.cc @@ -141,7 +141,7 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) MEM_malloc_arrayN(objects.size(), sizeof(*opdata->ob_store), __func__)); for (uint ob_index = 0; ob_index < objects.size(); ob_index++) { Object *obedit = objects[ob_index]; - float scale = mat4_to_scale(obedit->object_to_world); + float scale = mat4_to_scale(obedit->object_to_world().ptr()); opdata->max_obj_scale = max_ff(opdata->max_obj_scale, scale); BMEditMesh *em = BKE_editmesh_from_object(obedit); if (em->bm->totvertsel > 0) { diff --git a/source/blender/editors/mesh/editmesh_knife.cc b/source/blender/editors/mesh/editmesh_knife.cc index c36ef30d862..9a0ccff84a0 100644 --- a/source/blender/editors/mesh/editmesh_knife.cc +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -592,9 +592,9 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, float axis[3]; float arc_angle; - const float inverse_average_scale = 1 / (kcd->curr.ob->object_to_world[0][0] + - kcd->curr.ob->object_to_world[1][1] + - kcd->curr.ob->object_to_world[2][2]); + const float inverse_average_scale = 1 / (kcd->curr.ob->object_to_world().ptr()[0][0] + + kcd->curr.ob->object_to_world().ptr()[1][1] + + kcd->curr.ob->object_to_world().ptr()[2][2]); const float px_scale = 3.0f * inverse_average_scale * @@ -1192,7 +1192,7 @@ static void knife_bm_tri_cagecos_get_worldspace(const KnifeTool_OpData *kcd, knife_bm_tri_cagecos_get(kcd, ob_index, tri_index, cos); const Object *ob = kcd->objects[ob_index]; for (int i = 0; i < 3; i++) { - mul_m4_v3(ob->object_to_world, cos[i]); + mul_m4_v3(ob->object_to_world().ptr(), cos[i]); } } @@ -1735,7 +1735,7 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v, Object *ob } float cageco_ws[3]; - mul_v3_m4v3(cageco_ws, ob->object_to_world, cageco); + mul_v3_m4v3(cageco_ws, ob->object_to_world().ptr(), cageco); kfv = new_knife_vert(kcd, v->co, cageco_ws); kfv->v = v; @@ -2638,14 +2638,14 @@ static void calc_ortho_extent(KnifeTool_OpData *kcd) if (cagecos) { for (int i = 0; i < em->bm->totvert; i++) { copy_v3_v3(ws, cagecos[i]); - mul_m4_v3(ob->object_to_world, ws); + mul_m4_v3(ob->object_to_world().ptr(), ws); minmax_v3v3_v3(min, max, ws); } } else { BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { copy_v3_v3(ws, v->co); - mul_m4_v3(ob->object_to_world, ws); + mul_m4_v3(ob->object_to_world().ptr(), ws); minmax_v3v3_v3(min, max, ws); } } @@ -3683,7 +3683,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) /* Use normal global direction. */ float no_global[3]; copy_v3_v3(no_global, fprev->no); - mul_transposed_mat3_m4_v3(kcd->curr.ob->world_to_object, no_global); + mul_transposed_mat3_m4_v3(kcd->curr.ob->world_to_object().ptr(), no_global); normalize_v3(no_global); if (isect_ray_plane_v3_factor(curr_origin, curr_ray_normal, kcd->prev.cage, no_global, &lambda)) @@ -5010,7 +5010,7 @@ void EDBM_mesh_knife( BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) { float cent[3], cent_ss[2]; BM_face_calc_point_in_face(f, cent); - mul_m4_v3(ob->object_to_world, cent); + mul_m4_v3(ob->object_to_world().ptr(), cent); knife_project_v2(kcd, cent, cent_ss); if (edbm_mesh_knife_point_isect(polys, cent_ss)) { BM_elem_flag_enable(f, BM_ELEM_TAG); @@ -5051,7 +5051,7 @@ void EDBM_mesh_knife( if (found) { float cent[3], cent_ss[2]; BM_face_calc_point_in_face(f, cent); - mul_m4_v3(ob->object_to_world, cent); + mul_m4_v3(ob->object_to_world().ptr(), cent); knife_project_v2(kcd, cent, cent_ss); if ((kcd->cut_through || point_is_visible(kcd, cent, cent_ss, (BMElem *)f)) && edbm_mesh_knife_point_isect(polys, cent_ss)) diff --git a/source/blender/editors/mesh/editmesh_loopcut.cc b/source/blender/editors/mesh/editmesh_loopcut.cc index cdd85815df9..7aefc404337 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.cc +++ b/source/blender/editors/mesh/editmesh_loopcut.cc @@ -88,7 +88,7 @@ struct RingSelOpData { static void ringsel_draw(const bContext * /*C*/, ARegion * /*region*/, void *arg) { RingSelOpData *lcd = static_cast(arg); - EDBM_preselect_edgering_draw(lcd->presel_edgering, lcd->ob->object_to_world); + EDBM_preselect_edgering_draw(lcd->presel_edgering, lcd->ob->object_to_world().ptr()); } static void edgering_select(RingSelOpData *lcd) diff --git a/source/blender/editors/mesh/editmesh_polybuild.cc b/source/blender/editors/mesh/editmesh_polybuild.cc index e93a00b2b96..76592ff17fc 100644 --- a/source/blender/editors/mesh/editmesh_polybuild.cc +++ b/source/blender/editors/mesh/editmesh_polybuild.cc @@ -18,6 +18,7 @@ #include "BKE_context.hh" #include "BKE_editmesh.hh" #include "BKE_layer.hh" +#include "BKE_object_types.hh" #include "BLI_math_geom.h" #include "BLI_math_matrix.h" @@ -123,7 +124,7 @@ static int edbm_polybuild_transform_at_cursor_invoke(bContext *C, BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); + invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); if (!ele_act) { @@ -188,7 +189,7 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C, BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); + invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); if (!ele_act) { @@ -281,7 +282,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); + invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); @@ -289,9 +290,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con if (ele_act == nullptr || ele_act->head.htype == BM_FACE) { /* Just add vert */ copy_v3_v3(center, vc.scene->cursor.location); - mul_v3_m4v3(center, vc.obedit->object_to_world, center); + mul_v3_m4v3(center, vc.obedit->object_to_world().ptr(), center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object, center); + mul_m4_v3(vc.obedit->world_to_object().ptr(), center); BMVert *v_new = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); edbm_flag_disable_all_multi(vc.scene, vc.view_layer, vc.v3d, BM_ELEM_SELECT); @@ -304,9 +305,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMFace *f_reference = e_act->l ? e_act->l->f : nullptr; mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); - mul_m4_v3(vc.obedit->object_to_world, center); + mul_m4_v3(vc.obedit->object_to_world().ptr(), center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object, center); + mul_m4_v3(vc.obedit->world_to_object().ptr(), center); if (f_reference->len == 3 && RNA_boolean_get(op->ptr, "create_quads")) { const float fac = line_point_factor_v3(center, e_act->v1->co, e_act->v2->co); BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, nullptr, std::clamp(fac, 0.0f, 1.0f)); @@ -360,9 +361,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMFace *f_reference = e_pair[0]->l ? e_pair[0]->l->f : nullptr; - mul_v3_m4v3(center, vc.obedit->object_to_world, v_act->co); + mul_v3_m4v3(center, vc.obedit->object_to_world().ptr(), v_act->co); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object, center); + mul_m4_v3(vc.obedit->world_to_object().ptr(), center); BMVert *v_quad[4]; v_quad[0] = v_act; @@ -382,9 +383,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con } else { /* Just add edge */ - mul_m4_v3(vc.obedit->object_to_world, center); + mul_m4_v3(vc.obedit->object_to_world().ptr(), center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, v_act->co, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object, center); + mul_m4_v3(vc.obedit->world_to_object().ptr(), center); BMVert *v_new = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); @@ -458,7 +459,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, BMEditMesh *em = vc.em; BMesh *bm = em->bm; - invert_m4_m4(vc.obedit->world_to_object, vc.obedit->object_to_world); + invert_m4_m4(vc.obedit->runtime->world_to_object.ptr(), vc.obedit->object_to_world().ptr()); ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); @@ -469,9 +470,9 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, if (ele_act->head.htype == BM_EDGE) { BMEdge *e_act = (BMEdge *)ele_act; mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); - mul_m4_v3(vc.obedit->object_to_world, center); + mul_m4_v3(vc.obedit->object_to_world().ptr(), center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); - mul_m4_v3(vc.obedit->world_to_object, center); + mul_m4_v3(vc.obedit->world_to_object().ptr(), center); const float fac = line_point_factor_v3(center, e_act->v1->co, e_act->v2->co); BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, nullptr, std::clamp(fac, 0.0f, 1.0f)); diff --git a/source/blender/editors/mesh/editmesh_preselect_elem.cc b/source/blender/editors/mesh/editmesh_preselect_elem.cc index b09c5611807..651c2052f2a 100644 --- a/source/blender/editors/mesh/editmesh_preselect_elem.cc +++ b/source/blender/editors/mesh/editmesh_preselect_elem.cc @@ -243,9 +243,9 @@ static void view3d_preselect_update_preview_triangle_from_vert( } if (e_pair[1] != nullptr) { - mul_v3_m4v3(center, vc->obedit->object_to_world, v_act->co); + mul_v3_m4v3(center, vc->obedit->object_to_world().ptr(), v_act->co); ED_view3d_win_to_3d_int(vc->v3d, vc->region, center, mval, center); - mul_m4_v3(vc->obedit->world_to_object, center); + mul_m4_v3(vc->obedit->world_to_object().ptr(), center); psel->preview_tris = static_cast( MEM_mallocN(sizeof(*psel->preview_tris) * 2, __func__)); @@ -313,9 +313,9 @@ static void view3d_preselect_update_preview_triangle_from_edge( psel->preview_lines = static_cast( MEM_mallocN(sizeof(*psel->preview_lines) * 3, __func__)); mid_v3_v3v3(center, eed->v1->co, eed->v2->co); - mul_m4_v3(vc->obedit->object_to_world, center); + mul_m4_v3(vc->obedit->object_to_world().ptr(), center); ED_view3d_win_to_3d_int(vc->v3d, vc->region, center, mval, center); - mul_m4_v3(vc->obedit->world_to_object, center); + mul_m4_v3(vc->obedit->world_to_object().ptr(), center); copy_v3_v3(psel->preview_tris[0][0], eed->v1->co); copy_v3_v3(psel->preview_tris[0][1], eed->v2->co); diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index 109863a8a8e..cc67963312a 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -1076,7 +1076,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, float imat3[3][3]; ED_view3d_viewcontext_init_object(vc, obedit); - copy_m3_m4(imat3, obedit->object_to_world); + copy_m3_m4(imat3, obedit->object_to_world().ptr()); invert_m3(imat3); const float(*coords)[3] = nullptr; @@ -1101,8 +1101,9 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, for (uint j = 0; j < 2; j++) { BMVert *v = *((&e->v1) + j); float point[3]; - mul_v3_m4v3( - point, obedit->object_to_world, coords ? coords[BM_elem_index_get(v)] : v->co); + mul_v3_m4v3(point, + obedit->object_to_world().ptr(), + coords ? coords[BM_elem_index_get(v)] : v->co); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_vert) { @@ -1131,7 +1132,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, else { mid_v3_v3v3(point, e->v1->co, e->v2->co); } - mul_m4_v3(obedit->object_to_world, point); + mul_m4_v3(obedit->object_to_world().ptr(), point); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_edge) { @@ -1156,8 +1157,9 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_HIDDEN) == false) { float point[3]; - mul_v3_m4v3( - point, obedit->object_to_world, coords ? coords[BM_elem_index_get(v)] : v->co); + mul_v3_m4v3(point, + obedit->object_to_world().ptr(), + coords ? coords[BM_elem_index_get(v)] : v->co); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_vert) { @@ -1187,7 +1189,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, else { mid_v3_v3v3(point, e->v1->co, e->v2->co); } - mul_m4_v3(obedit->object_to_world, point); + mul_m4_v3(obedit->object_to_world().ptr(), point); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_edge) { @@ -1216,7 +1218,7 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, else { BM_face_calc_center_median(f, point); } - mul_m4_v3(obedit->object_to_world, point); + mul_m4_v3(obedit->object_to_world().ptr(), point); const float dist_sq_test = dist_squared_to_ray_v3_normalized( ray_origin, ray_direction, point); if (dist_sq_test < dist_sq_best_face) { @@ -4869,7 +4871,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) { float vertex_world[3]; - mul_v3_m4v3(vertex_world, obedit->object_to_world, v_act->co); + mul_v3_m4v3(vertex_world, obedit->object_to_world().ptr(), v_act->co); value = dot_v3v3(axis_vector, vertex_world); } @@ -4897,7 +4899,7 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN | BM_ELEM_SELECT)) { float v_iter_world[3]; - mul_v3_m4v3(v_iter_world, obedit_iter->object_to_world, v->co); + mul_v3_m4v3(v_iter_world, obedit_iter->object_to_world().ptr(), v->co); const float value_iter = dot_v3v3(axis_vector, v_iter_world); switch (sign) { case SELECT_AXIS_ALIGN: diff --git a/source/blender/editors/mesh/editmesh_select_similar.cc b/source/blender/editors/mesh/editmesh_select_similar.cc index b3f5459ad38..ab7b64a2755 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.cc +++ b/source/blender/editors/mesh/editmesh_select_similar.cc @@ -23,6 +23,7 @@ #include "BKE_editmesh.hh" #include "BKE_layer.hh" #include "BKE_material.h" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "DNA_meshdata_types.h" @@ -137,9 +138,9 @@ static void face_to_plane(const Object *ob, BMFace *face, float r_plane[4]) { float normal[3], co[3]; copy_v3_v3(normal, face->no); - mul_transposed_mat3_m4_v3(ob->world_to_object, normal); + mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); normalize_v3(normal); - mul_v3_m4v3(co, ob->object_to_world, BM_FACE_FIRST_LOOP(face)->v->co); + mul_v3_m4v3(co, ob->object_to_world().ptr(), BM_FACE_FIRST_LOOP(face)->v->co); plane_from_point_normal_v3(r_plane, co, normal); } @@ -199,14 +200,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; Material ***material_array = nullptr; - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); if (bm->totfacesel == 0) { continue; } float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); switch (type) { case SIMFACE_MATERIAL: { @@ -254,7 +255,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) case SIMFACE_NORMAL: { float normal[3]; copy_v3_v3(normal, face->no); - mul_transposed_mat3_m4_v3(ob->world_to_object, normal); + mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); normalize_v3(normal); BLI_kdtree_3d_insert(tree_3d, tree_index++, normal); break; @@ -313,7 +314,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) Material ***material_array = nullptr; float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); bool has_custom_data_layer = false; switch (type) { @@ -390,7 +391,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) case SIMFACE_NORMAL: { float normal[3]; copy_v3_v3(normal, face->no); - mul_transposed_mat3_m4_v3(ob->world_to_object, normal); + mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); normalize_v3(normal); /* We are treating the normals as coordinates, the "nearest" one will @@ -510,8 +511,8 @@ static void edge_pos_direction_worldspace_get(Object *ob, BMEdge *edge, float *r copy_v3_v3(v1, edge->v1->co); copy_v3_v3(v2, edge->v2->co); - mul_m4_v3(ob->object_to_world, v1); - mul_m4_v3(ob->object_to_world, v2); + mul_m4_v3(ob->object_to_world().ptr(), v1); + mul_m4_v3(ob->object_to_world().ptr(), v2); sub_v3_v3v3(r_dir, v1, v2); normalize_v3(r_dir); @@ -521,8 +522,8 @@ static float edge_length_squared_worldspace_get(Object *ob, BMEdge *edge) { float v1[3], v2[3]; - mul_v3_mat3_m4v3(v1, ob->object_to_world, edge->v1->co); - mul_v3_mat3_m4v3(v2, ob->object_to_world, edge->v2->co); + mul_v3_mat3_m4v3(v1, ob->object_to_world().ptr(), edge->v1->co); + mul_v3_mat3_m4v3(v2, ob->object_to_world().ptr(), edge->v2->co); return len_squared_v3v3(v1, v2); } @@ -645,7 +646,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } float ob_m3[3][3], ob_m3_inv[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); invert_m3_m3(ob_m3_inv, ob_m3); BMEdge *edge; /* Mesh edge. */ @@ -769,7 +770,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } float ob_m3[3][3], ob_m3_inv[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); invert_m3_m3(ob_m3_inv, ob_m3); int custom_data_offset; @@ -996,7 +997,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BLI_bitmap *defbase_selected = nullptr; int defbase_len = 0; - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); if (bm->totvertsel == 0) { continue; @@ -1037,7 +1038,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) case SIMVERT_NORMAL: { float normal[3]; copy_v3_v3(normal, vert->no); - mul_transposed_mat3_m4_v3(ob->world_to_object, normal); + mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); normalize_v3(normal); BLI_kdtree_3d_insert(tree_3d, normal_tree_index++, normal); @@ -1189,7 +1190,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) case SIMVERT_NORMAL: { float normal[3]; copy_v3_v3(normal, vert->no); - mul_transposed_mat3_m4_v3(ob->world_to_object, normal); + mul_transposed_mat3_m4_v3(ob->world_to_object().ptr(), normal); normalize_v3(normal); /* We are treating the normals as coordinates, the "nearest" one will diff --git a/source/blender/editors/mesh/editmesh_tools.cc b/source/blender/editors/mesh/editmesh_tools.cc index d1e0d0a875b..6cd047ae369 100644 --- a/source/blender/editors/mesh/editmesh_tools.cc +++ b/source/blender/editors/mesh/editmesh_tools.cc @@ -43,6 +43,7 @@ #include "BKE_material.h" #include "BKE_mesh.hh" #include "BKE_object.hh" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "DEG_depsgraph.hh" @@ -3304,8 +3305,8 @@ static bool merge_target(BMEditMesh *em, if (use_cursor) { vco = scene->cursor.location; copy_v3_v3(co, vco); - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_v3(ob->world_to_object, co); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_v3(ob->world_to_object().ptr(), co); } else { float fac; @@ -6601,7 +6602,7 @@ static void sort_bmelem_flag(bContext *C, int coidx = (action == SRT_VIEW_ZAXIS) ? 2 : 0; /* Apply the view matrix to the object matrix. */ - mul_m4_m4m4(mat, rv3d->viewmat, ob->object_to_world); + mul_m4_m4m4(mat, rv3d->viewmat, ob->object_to_world().ptr()); if (totelem[0]) { pb = pblock[0] = static_cast(MEM_callocN(sizeof(char) * totelem[0], __func__)); @@ -6673,7 +6674,7 @@ static void sort_bmelem_flag(bContext *C, copy_v3_v3(cur, scene->cursor.location); - invert_m4_m4(mat, ob->object_to_world); + invert_m4_m4(mat, ob->object_to_world().ptr()); mul_m4_v3(mat, cur); if (totelem[0]) { diff --git a/source/blender/editors/mesh/editmesh_utils.cc b/source/blender/editors/mesh/editmesh_utils.cc index a3a2f43bc78..ac73fca05f4 100644 --- a/source/blender/editors/mesh/editmesh_utils.cc +++ b/source/blender/editors/mesh/editmesh_utils.cc @@ -1858,7 +1858,7 @@ bool BMBVH_EdgeVisible( ED_view3d_win_to_segment_clipped(depsgraph, region, v3d, mval_f, origin, end, false); - invert_m4_m4(invmat, obedit->object_to_world); + invert_m4_m4(invmat, obedit->object_to_world().ptr()); mul_m4_v3(invmat, origin); copy_v3_v3(co1, e->v1->co); @@ -1953,7 +1953,7 @@ void EDBM_project_snap_verts( co_proj, nullptr)) { - mul_v3_m4v3(eve->co, obedit->world_to_object, co_proj); + mul_v3_m4v3(eve->co, obedit->world_to_object().ptr(), co_proj); } } } diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index c6c742165f9..5e5d2becab1 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -137,7 +137,7 @@ static void join_mesh_single(Depsgraph *depsgraph, float cmat[4][4]; /* Watch this: switch matrix multiplication order really goes wrong. */ - mul_m4_m4m4(cmat, imat, ob_src->object_to_world); + mul_m4_m4m4(cmat, imat, ob_src->object_to_world().ptr()); /* transform vertex coordinates into new space */ for (a = 0; a < mesh->verts_num; a++) { @@ -374,7 +374,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) * NOTE: This doesn't apply recursive parenting. */ if (join_parent) { ob->parent = nullptr; - BKE_object_apply_mat4_ex(ob, ob->object_to_world, ob->parent, ob->parentinv, false); + BKE_object_apply_mat4_ex(ob, ob->object_to_world().ptr(), ob->parent, ob->parentinv, false); } /* that way the active object is always selected */ @@ -567,7 +567,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) /* Inverse transform for all selected meshes in this object, * See #object_join_exec for detailed comment on why the safe version is used. */ - invert_m4_m4_safe_ortho(imat, ob->object_to_world); + invert_m4_m4_safe_ortho(imat, ob->object_to_world().ptr()); /* Add back active mesh first. * This allows to keep things similar as they were, as much as possible diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 72ae0f72fbb..114c1a270b5 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -334,7 +334,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->object_to_world); + BKE_object_to_mat4(object, object->runtime->object_to_world.ptr()); } float ED_object_new_primitive_matrix(bContext *C, @@ -354,14 +354,14 @@ float ED_object_new_primitive_matrix(bContext *C, invert_m3(rmat); /* inverse transform for initial rotation and object */ - copy_m3_m4(mat, obedit->object_to_world); + copy_m3_m4(mat, obedit->object_to_world().ptr()); 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->object_to_world[3]); + sub_v3_v3v3(r_primmat[3], r_primmat[3], obedit->object_to_world().location()); invert_m3_m3(imat, mat); mul_m3_v3(imat, r_primmat[3]); @@ -2227,7 +2227,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->object_to_world, false, false); + BKE_object_apply_mat4(curves_ob, surface_ob->object_to_world().ptr(), false, false); /* Set surface object. */ Curves *curves_id = static_cast(curves_ob->data); @@ -2711,8 +2711,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->object_to_world, dob->mat); - BKE_object_apply_mat4(ob_dst, ob_dst->object_to_world, false, false); + copy_m4_m4(ob_dst->runtime->object_to_world.ptr(), dob->mat); + BKE_object_apply_mat4(ob_dst, ob_dst->object_to_world().ptr(), false, false); BLI_ghash_insert(dupli_gh, dob, ob_dst); if (parent_gh) { @@ -3177,7 +3177,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uid : 0; float loc[3], size[3], rot[3][3], eul[3]; float matrix[4][4]; - mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world); + mat4_to_loc_rot_size(loc, rot, size, ob->object_to_world().ptr()); mat3_to_eul(eul, rot); Object *ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits); @@ -4102,8 +4102,9 @@ 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->object_to_world[0][0]); - BKE_object_apply_mat4(ob_add, ob_add->object_to_world, true, true); + RNA_property_float_get_array( + op->ptr, prop_matrix, ob_add->runtime->object_to_world.base_ptr()); + BKE_object_apply_mat4(ob_add, ob_add->object_to_world().ptr(), true, true); DEG_id_tag_update(&ob_add->id, ID_RECALC_TRANSFORM); } @@ -4199,7 +4200,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->object_to_world); + normalize_m4_m4(mat_src_unit, ob->object_to_world().ptr()); normalize_m4_m4(mat_dst_unit, matrix); invert_m4(mat_src_unit); mul_m4_m4m4(final_delta, mat_dst_unit, mat_src_unit); @@ -4353,7 +4354,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->object_to_world)) { + if (!invert_m4_m4(imat_test, ob->object_to_world().ptr())) { 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.cc b/source/blender/editors/object/object_bake_api.cc index adaf255b3a7..c4be875f7d8 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -1578,10 +1578,10 @@ static int bake(const BakeAPIRender *bkr, highpoly[i].mesh = BKE_mesh_new_from_object(nullptr, highpoly[i].ob_eval, false, false); /* Low-poly to high-poly transformation matrix. */ - copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world); + copy_m4_m4(highpoly[i].obmat, highpoly[i].ob->object_to_world().ptr()); invert_m4_m4(highpoly[i].imat, highpoly[i].obmat); - highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world); + highpoly[i].is_flip_object = is_negative_m4(highpoly[i].ob->object_to_world().ptr()); i++; } @@ -1610,8 +1610,8 @@ static int bake(const BakeAPIRender *bkr, ob_cage != nullptr, 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), + ob_low_eval->object_to_world().ptr(), + (ob_cage ? ob_cage->object_to_world().ptr() : ob_low_eval->object_to_world().ptr()), me_cage_eval)) { BKE_report(reports, RPT_ERROR, "Error handling selected objects"); @@ -1692,7 +1692,7 @@ static int bake(const BakeAPIRender *bkr, targets.result, me_low_eval, bkr->normal_swizzle, - ob_low_eval->object_to_world); + ob_low_eval->object_to_world().ptr()); } else { /* From multi-resolution. */ @@ -1718,7 +1718,7 @@ static int bake(const BakeAPIRender *bkr, targets.result, (me_nores) ? me_nores : me_low_eval, bkr->normal_swizzle, - ob_low_eval->object_to_world); + ob_low_eval->object_to_world().ptr()); if (md) { BKE_id_free(nullptr, &me_nores->id); diff --git a/source/blender/editors/object/object_constraint.cc b/source/blender/editors/object/object_constraint.cc index 4de276c114b..0ba189059a3 100644 --- a/source/blender/editors/object/object_constraint.cc +++ b/source/blender/editors/object/object_constraint.cc @@ -2324,14 +2324,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->object_to_world, pchanact->pose_tail); + mul_v3_m4v3(obt->loc, obact->object_to_world().ptr(), pchanact->pose_tail); } else { - mul_v3_m4v3(obt->loc, obact->object_to_world, pchanact->pose_head); + mul_v3_m4v3(obt->loc, obact->object_to_world().ptr(), pchanact->pose_head); } } else { - copy_v3_v3(obt->loc, obact->object_to_world[3]); + copy_v3_v3(obt->loc, obact->object_to_world().location()); } /* restore, BKE_object_add sets active */ diff --git a/source/blender/editors/object/object_hook.cc b/source/blender/editors/object/object_hook.cc index 34f7ce1e22f..6a13c3f77d9 100644 --- a/source/blender/editors/object/object_hook.cc +++ b/source/blender/editors/object/object_hook.cc @@ -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->object_to_world, cent); + mul_v3_m4v3(ob->loc, obedit->object_to_world().ptr(), cent); } md = static_cast(obedit->modifiers.first); @@ -558,13 +558,13 @@ static int add_hook_object(const bContext *C, unit_m4(pose_mat); - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); if (mode == OBJECT_ADDHOOK_NEWOB) { /* pass */ } else { /* may overwrite with pose-bone location, below */ - mul_v3_m4v3(cent, obedit->world_to_object, ob->object_to_world[3]); + mul_v3_m4v3(cent, obedit->world_to_object().ptr(), ob->object_to_world().location()); } if (mode == OBJECT_ADDHOOK_SELOB_BONE) { @@ -578,8 +578,8 @@ static int add_hook_object(const bContext *C, pchan_act = BKE_pose_channel_active_if_bonecoll_visible(ob); if (LIKELY(pchan_act)) { invert_m4_m4(pose_mat, pchan_act->pose_mat); - mul_v3_m4v3(cent, ob->object_to_world, pchan_act->pose_mat[3]); - mul_v3_m4v3(cent, obedit->world_to_object, cent); + mul_v3_m4v3(cent, ob->object_to_world().ptr(), pchan_act->pose_mat[3]); + mul_v3_m4v3(cent, obedit->world_to_object().ptr(), cent); } } else { @@ -590,16 +590,20 @@ static int add_hook_object(const bContext *C, copy_v3_v3(hmd->cent, cent); /* matrix calculus */ - /* vert x (obmat x hook->world_to_object) x hook->object_to_world x ob->world_to_object */ + /* vert x (obmat x hook->world_to_object) x hook->object_to_world().ptr() x ob->world_to_object + */ /* (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->world_to_object, object_eval->object_to_world); + invert_m4_m4(object_eval->runtime->world_to_object.ptr(), object_eval->object_to_world().ptr()); /* apparently this call goes from right to left... */ - mul_m4_series(hmd->parentinv, pose_mat, object_eval->world_to_object, obedit->object_to_world); + mul_m4_series(hmd->parentinv, + pose_mat, + object_eval->world_to_object().ptr(), + obedit->object_to_world().ptr()); DEG_id_tag_update(&obedit->id, ID_RECALC_GEOMETRY); DEG_relations_tag_update(bmain); @@ -842,10 +846,10 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) } /* recenter functionality */ - copy_m3_m4(bmat, ob->object_to_world); + copy_m3_m4(bmat, ob->object_to_world().ptr()); invert_m3_m3(imat, bmat); - sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->object_to_world[3]); + sub_v3_v3v3(hmd->cent, scene->cursor.location, ob->object_to_world().location()); mul_m3_v3(imat, hmd->cent); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); diff --git a/source/blender/editors/object/object_relations.cc b/source/blender/editors/object/object_relations.cc index 2f708730028..5214cecb0db 100644 --- a/source/blender/editors/object/object_relations.cc +++ b/source/blender/editors/object/object_relations.cc @@ -265,7 +265,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.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } else { ob->partype = PARVERT1; @@ -273,7 +273,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.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } } } @@ -395,7 +395,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 = nullptr; - BKE_object_apply_mat4(ob, ob->object_to_world, true, false); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), true, false); /* Don't recalculate the animation because it would change the transform * instead of keeping it. */ flags &= ~ID_RECALC_ANIMATION; @@ -581,7 +581,7 @@ bool ED_object_parent_set(ReportList *reports, if (keep_transform) { /* Was removed because of bug #23577, * but this can be handy in some cases too #32616, so * make optional. */ - BKE_object_apply_mat4(ob, ob->object_to_world, false, false); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), 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, nullptr, cmat, scene->r.cfra); - sub_v3_v3v3(vec, ob->object_to_world[3], cmat[3]); + sub_v3_v3v3(vec, ob->object_to_world().location(), 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.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } else if (is_armature_parent && (ob->type == OB_GPENCIL_LEGACY) && (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.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } else if ((ob->type == OB_GPENCIL_LEGACY) && (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.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } else { /* calculate inverse parent matrix */ BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.object_to_world); + invert_m4_m4(ob->parentinv, workob.object_to_world().ptr()); } 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->object_to_world[3]; + const float *co_find = child->object_to_world().location(); if (is_tri) { KDTreeNearest_3d nearest[3]; int tot; @@ -1190,7 +1190,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } if (type == CLEAR_TRACK_KEEP_TRANSFORM) { - BKE_object_apply_mat4(ob, ob->object_to_world, true, true); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), true, true); } } CTX_DATA_END; diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index a2ad1037e26..be7a6488b0d 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -33,6 +33,7 @@ #include "BKE_mesh_remesh_voxel.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" +#include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_report.hh" #include "BKE_shrinkwrap.hh" @@ -270,7 +271,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion * /*region*/, void * 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->object_to_world); + GPU_matrix_mul(cd->active_object->object_to_world().ptr()); /* Draw Rect */ immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f); @@ -472,10 +473,11 @@ 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->world_to_object, active_object->object_to_world); + invert_m4_m4(active_object->runtime->world_to_object.ptr(), + active_object->object_to_world().ptr()); copy_m3_m4(mat, rv3d->viewinv); mul_m3_v3(mat, view_normal); - copy_m3_m4(mat, active_object->world_to_object); + copy_m3_m4(mat, active_object->world_to_object().ptr()); mul_m3_v3(mat, view_normal); normalize_v3(view_normal); @@ -513,7 +515,8 @@ 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->object_to_world, cd->preview_plane[i]); + mul_v3_m4v3( + preview_plane_world_space, active_object->object_to_world().ptr(), cd->preview_plane[i]); ED_view3d_project_v2(region, preview_plane_world_space, preview_plane_proj[i]); } @@ -560,7 +563,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->object_to_world); + mat4_to_size(scale, active_object->object_to_world().ptr()); invert_v3(scale); size_to_mat4(scale_mat, scale); @@ -571,7 +574,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->object_to_world, text_pos); + mul_v3_m4v3(text_pos_word_space, active_object->object_to_world().ptr(), 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 5787be96571..75ec8c90579 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -536,9 +536,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->object_to_world, true, false); + BKE_object_apply_mat4(ob_child_eval, ob_child_eval->object_to_world().ptr(), true, false); BKE_object_workob_calc_parent(depsgraph, scene, ob_child_eval, &workob); - invert_m4_m4(ob_child->parentinv, workob.object_to_world); + invert_m4_m4(ob_child->parentinv, workob.object_to_world().ptr()); /* 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. @@ -681,11 +681,11 @@ static int apply_objects_internal(bContext *C, if (do_multi_user) { obact = CTX_data_active_object(C); - invert_m4_m4(obact_invmat, obact->object_to_world); + invert_m4_m4(obact_invmat, obact->object_to_world().ptr()); Object workob; BKE_object_workob_calc_parent(depsgraph, scene, obact, &workob); - copy_m4_m4(obact_parent, workob.object_to_world); + copy_m4_m4(obact_parent, workob.object_to_world().ptr()); copy_m4_m4(obact_parentinv, obact->parentinv); if (apply_objects_internal_need_single_user(C)) { @@ -1019,7 +1019,7 @@ static int apply_objects_internal(bContext *C, float _obmat[4][4], _iobmat[4][4]; float _mat[4][4]; - copy_m4_m4(_obmat, ob->object_to_world); + copy_m4_m4(_obmat, ob->object_to_world().ptr()); invert_m4_m4(_iobmat, _obmat); copy_m4_m4(_mat, _obmat); @@ -1105,7 +1105,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->object_to_world, true, true); + BKE_object_apply_mat4(ob_eval, ob_eval->object_to_world().ptr(), true, true); BKE_object_transform_copy(ob, ob_eval); /* update for any children that may get moved */ @@ -1325,8 +1325,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); - mul_m4_v3(obedit->world_to_object, cent); + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); + mul_m4_v3(obedit->world_to_object().ptr(), cent); } else { if (around == V3D_AROUND_CENTER_BOUNDS) { @@ -1393,8 +1393,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_v3(ob->world_to_object, cent); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_v3(ob->world_to_object().ptr(), cent); } if (ob->data == nullptr) { @@ -1415,8 +1415,8 @@ 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->world_to_object, ob->object_to_world); - mul_m4_v3(ob->world_to_object, cent); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_v3(ob->world_to_object().ptr(), cent); } add_v3_v3(ob->instance_collection->instance_offset, cent); @@ -1612,7 +1612,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->object_to_world[3]); + add_v3_v3(gpcenter, ob->object_to_world().location()); } if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(gpcenter, cursor); @@ -1624,8 +1624,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) float offset_local[3]; int i; - sub_v3_v3v3(offset_global, gpcenter, ob->object_to_world[3]); - copy_m3_m4(bmat, obact->object_to_world); + sub_v3_v3v3(offset_global, gpcenter, ob->object_to_world().location()); + copy_m3_m4(bmat, obact->object_to_world().ptr()); invert_m3_m3(imat, bmat); mul_m3_v3(imat, offset_global); mul_v3_m3v3(offset_local, imat, offset_global); @@ -1784,7 +1784,8 @@ 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->object_to_world, cent); /* omit translation part */ + mul_v3_mat3_m4v3( + centn, ob_other->object_to_world().ptr(), cent); /* omit translation part */ add_v3_v3(ob_other->loc, centn); Object *ob_other_eval = DEG_get_evaluated_object(depsgraph, ob_other); @@ -1958,9 +1959,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->object_to_world[3]; + const float *ob_co_a = ob->object_to_world().location(); float ob_co_b[3]; - add_v3_v3v3(ob_co_b, ob->object_to_world[3], ob->object_to_world[2]); + add_v3_v3v3(ob_co_b, ob->object_to_world().location(), ob->object_to_world().ptr()[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); @@ -2031,7 +2032,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->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); copy_v3_v3(mat[3], loc); BKE_object_apply_mat4(ob, mat, true, true); copy_v3_v3(mat[3], ob->loc); @@ -2046,7 +2047,7 @@ static bool object_orient_to_location(Object *ob, const bool z_flip) { float delta[3]; - sub_v3_v3v3(delta, ob->object_to_world[3], location); + sub_v3_v3v3(delta, ob->object_to_world().location(), location); if (normalize_v3(delta) != 0.0f) { if (z_flip) { negate_v3(delta); @@ -2223,7 +2224,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->object_to_world); + copy_m3_m4(item.xform_rot_offset, item.ob->object_to_world().ptr()); normalize_m3(item.xform_rot_offset); if (i == 0) { @@ -2242,8 +2243,9 @@ 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->object_to_world[3], location_world); - normalize_v3_v3(ob_axis, item.ob->object_to_world[2]); + item.xform_dist = len_v3v3(item.ob->object_to_world().location(), + location_world); + normalize_v3_v3(ob_axis, item.ob->object_to_world().ptr()[2]); /* Scale to avoid adding distance when moving between surfaces. */ if (normal_found) { float scale = fabsf(dot_v3v3(ob_axis, normal)); @@ -2257,7 +2259,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->object_to_world[2]); + normalize_v3_v3(target_normal, item.ob->object_to_world().ptr()[2]); } #ifdef USE_RELATIVE_ROTATION @@ -2274,7 +2276,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->object_to_world[3], loc); + copy_v3_v3(item.ob->runtime->object_to_world.location(), loc); } object_orient_to_location( diff --git a/source/blender/editors/object/object_utils.cc b/source/blender/editors/object/object_utils.cc index a603110ea62..998a6e3b133 100644 --- a/source/blender/editors/object/object_utils.cc +++ b/source/blender/editors/object/object_utils.cc @@ -113,20 +113,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->object_to_world, r_center); + mul_m4_v3(ob->object_to_world().ptr(), 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->object_to_world, r_center); + mul_m4_v3(ob->object_to_world().ptr(), r_center); return true; } return false; } if (!select_only || (ob->base_flag & BASE_SELECTED)) { - copy_v3_v3(r_center, ob->object_to_world[3]); + copy_v3_v3(r_center, ob->object_to_world().location()); return true; } return false; @@ -246,11 +246,11 @@ void ED_object_xform_skip_child_container_item_ensure(XFormObjectSkipChild_Conta XFormObjectSkipChild *xf = static_cast( MEM_mallocN(sizeof(*xf), __func__)); copy_m4_m4(xf->parentinv_orig, ob->parentinv); - 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); + copy_m4_m4(xf->obmat_orig, ob->object_to_world().ptr()); + copy_m4_m4(xf->parent_obmat_orig, ob->parent->object_to_world().ptr()); + invert_m4_m4(xf->parent_obmat_inv_orig, ob->parent->object_to_world().ptr()); if (ob_parent_recurse) { - copy_m4_m4(xf->parent_recurse_obmat_orig, ob_parent_recurse->object_to_world); + copy_m4_m4(xf->parent_recurse_obmat_orig, ob_parent_recurse->object_to_world().ptr()); } xf->mode = mode; xf->ob_parent_recurse = ob_parent_recurse; @@ -276,14 +276,14 @@ void ED_object_xform_skip_child_container_update_all(XFormObjectSkipChild_Contai 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->object_to_world); + mul_m4_m4m4(dmat, xf->parent_obmat_inv_orig, ob_parent_eval->object_to_world().ptr()); 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->object_to_world); + invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world().ptr()); mul_m4_m4m4(dmat, xf->parent_recurse_obmat_orig, parent_recurse_obmat_inv); invert_m4(dmat); float parent_obmat_calc[4][4]; @@ -298,7 +298,7 @@ void ED_object_xform_skip_child_container_update_all(XFormObjectSkipChild_Contai /* 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->object_to_world); + invert_m4_m4(parent_recurse_obmat_inv, ob_parent_recurse_eval->object_to_world().ptr()); mul_m4_m4m4(dmat, xf->parent_recurse_obmat_orig, parent_recurse_obmat_inv); invert_m4(dmat); float obmat_calc[4][4]; @@ -353,7 +353,7 @@ void ED_object_data_xform_container_item_ensure(XFormObjectData_Container *xds, if (!BLI_ghash_ensure_p(xds->obdata_in_obmode_map, ob->data, &xf_p)) { XFormObjectData_Extra *xf = static_cast( MEM_mallocN(sizeof(*xf), __func__)); - copy_m4_m4(xf->obmat_orig, ob->object_to_world); + copy_m4_m4(xf->obmat_orig, ob->object_to_world().ptr()); xf->ob = ob; /* Result may be nullptr, that's OK. */ xf->xod = ED_object_data_xform_create(static_cast(ob->data)); @@ -382,7 +382,7 @@ void ED_object_data_xform_container_update_all(XFormObjectData_Container *xds, 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->object_to_world); + mul_m4_m4m4(dmat, imat, ob_eval->object_to_world().ptr()); invert_m4(dmat); ED_object_data_xform_by_mat4(xf->xod, dmat); diff --git a/source/blender/editors/object/object_warp.cc b/source/blender/editors/object/object_warp.cc index dd70ad1993c..00cd0583cb8 100644 --- a/source/blender/editors/object/object_warp.cc +++ b/source/blender/editors/object/object_warp.cc @@ -42,7 +42,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->object_to_world); + mul_m4_m4m4(r_mat_view, viewmat_roll, obedit->object_to_world().ptr()); /* get the view-space cursor */ mul_v3_m4v3(r_center_view, viewmat_roll, center); diff --git a/source/blender/editors/physics/particle_edit.cc b/source/blender/editors/physics/particle_edit.cc index ddf0c13d5e6..eda89db317c 100644 --- a/source/blender/editors/physics/particle_edit.cc +++ b/source/blender/editors/physics/particle_edit.cc @@ -3940,7 +3940,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance) /* Use `kco` as the object space version of world-space `co`, * `ob->world_to_object` is set before calling. */ - mul_v3_m4v3(kco, data->ob->world_to_object, co); + mul_v3_m4v3(kco, data->ob->world_to_object().ptr(), co); point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, nullptr); if (point_index == -1) { @@ -3949,7 +3949,7 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance) copy_v3_v3(co_root, co); copy_v3_v3(no_root, &edit->emitter_cosnos[point_index * 6 + 3]); - mul_mat3_m4_v3(data->ob->object_to_world, no_root); /* normal into global-space */ + mul_mat3_m4_v3(data->ob->object_to_world().ptr(), no_root); /* normal into global-space */ normalize_v3(no_root); if (puff_volume) { @@ -4030,12 +4030,13 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance) /* Use `kco` as the object space version of world-space `co`, * `ob->world_to_object` is set before calling. */ - mul_v3_m4v3(kco, data->ob->world_to_object, oco); + mul_v3_m4v3(kco, data->ob->world_to_object().ptr(), oco); point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, nullptr); if (point_index != -1) { copy_v3_v3(onor, &edit->emitter_cosnos[point_index * 6 + 3]); - mul_mat3_m4_v3(data->ob->object_to_world, onor); /* Normal into world-space. */ + mul_mat3_m4_v3(data->ob->object_to_world().ptr(), + onor); /* Normal into world-space. */ mul_mat3_m4_v3(imat, onor); /* World-space into particle-space. */ normalize_v3(onor); } @@ -4431,7 +4432,7 @@ static int brush_add(const bContext *C, PEData *data, short number) short size = pset->brush[PE_BRUSH_ADD].size; RNG *rng; - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); if (psys->flag & PSYS_GLOBAL_HAIR) { return 0; @@ -4820,7 +4821,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.combfac = 1.0f - data.combfac; } - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); ED_view3d_win_to_delta(region, xy_delta, bedit->zfac, vec); data.dvec = vec; @@ -4888,7 +4889,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } data.invert = (brush->invert ^ flip); - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); foreach_mouse_hit_point(&data, brush_puff, selected); } @@ -4918,7 +4919,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.smoothfac = brush->strength; - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); foreach_mouse_hit_key(&data, brush_smooth_get, selected); @@ -5135,7 +5136,7 @@ static bool shape_cut_test_point(PEData *data, ParticleEditSettings *pset, Parti userdata.num_hits = 0; float co_shape[3]; - mul_v3_m4v3(co_shape, pset->shape_object->world_to_object, key->co); + mul_v3_m4v3(co_shape, pset->shape_object->world_to_object().ptr(), key->co); BLI_bvhtree_ray_cast_all( shape_bvh->tree, co_shape, dir, 0.0f, BVH_RAYCAST_DIST_MAX, point_inside_bvh_cb, &userdata); @@ -5176,8 +5177,8 @@ static void shape_cut(PEData *data, int pa_index) float dir_shape[3]; float len_shape; - mul_v3_m4v3(co_curr_shape, pset->shape_object->world_to_object, key->co); - mul_v3_m4v3(co_next_shape, pset->shape_object->world_to_object, (key + 1)->co); + mul_v3_m4v3(co_curr_shape, pset->shape_object->world_to_object().ptr(), key->co); + mul_v3_m4v3(co_next_shape, pset->shape_object->world_to_object().ptr(), (key + 1)->co); sub_v3_v3v3(dir_shape, co_next_shape, co_curr_shape); len_shape = normalize_v3(dir_shape); diff --git a/source/blender/editors/physics/particle_object.cc b/source/blender/editors/physics/particle_object.cc index c53d74f8158..0b498b59cca 100644 --- a/source/blender/editors/physics/particle_object.cc +++ b/source/blender/editors/physics/particle_object.cc @@ -721,8 +721,8 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, edit_point = target_edit ? target_edit->points : nullptr; - invert_m4_m4(from_ob_imat, ob->object_to_world); - invert_m4_m4(to_ob_imat, target_ob->object_to_world); + invert_m4_m4(from_ob_imat, ob->object_to_world().ptr()); + invert_m4_m4(to_ob_imat, target_ob->object_to_world().ptr()); invert_m4_m4(from_imat, from_mat); invert_m4_m4(to_imat, to_mat); @@ -840,7 +840,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, float offset[3]; if (to_global) { - copy_m4_m4(imat, target_ob->object_to_world); + copy_m4_m4(imat, target_ob->object_to_world().ptr()); } else { /* NOTE: using target_dm here, which is in target_ob object space and has full modifiers. @@ -921,8 +921,8 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl ob, psys, psys->edit, - ob->object_to_world, - ob->object_to_world, + ob->object_to_world().ptr(), + ob->object_to_world().ptr(), psys->flag & PSYS_GLOBAL_HAIR, false); if (ok) { @@ -1171,7 +1171,7 @@ static bool copy_particle_systems_to_object(const bContext *C, for (psys = psys_start, psys_from = PSYS_FROM_FIRST, i = 0; psys; psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), i++) { - float(*from_mat)[4], (*to_mat)[4]; + const float(*from_mat)[4], (*to_mat)[4]; switch (space) { case PAR_COPY_SPACE_OBJECT: @@ -1179,8 +1179,8 @@ static bool copy_particle_systems_to_object(const bContext *C, to_mat = I; break; case PAR_COPY_SPACE_WORLD: - from_mat = ob_from->object_to_world; - to_mat = ob_to->object_to_world; + from_mat = ob_from->object_to_world().ptr(); + to_mat = ob_to->object_to_world().ptr(); break; default: /* should not happen */ diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 66ecf22822c..aada0c80c49 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -793,7 +793,7 @@ static Object *object_preview_camera_create(Main *preview_main, float rotmat[3][3]; float dummy_scale[3]; - mat4_to_loc_rot_size(camera->loc, rotmat, dummy_scale, preview_object->object_to_world); + mat4_to_loc_rot_size(camera->loc, rotmat, dummy_scale, preview_object->object_to_world().ptr()); /* Camera is Y up, so needs additional rotations to obliquely face the front. */ float drotmat[3][3]; diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index abb8f81ccdc..4bf3e0103e0 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -186,7 +186,7 @@ std::optional sample_curves_3d_brush(const Depsgraph &depsgraph, /* Shorten ray when the surface object is hit. */ if (surface_object_eval != nullptr) { - const float4x4 surface_to_world_mat(surface_object->object_to_world); + const float4x4 surface_to_world_mat(surface_object->object_to_world().ptr()); const float4x4 world_to_surface_mat = math::invert(surface_to_world_mat); Mesh *surface_eval = BKE_object_get_evaluated_mesh(surface_object_eval); @@ -221,7 +221,7 @@ std::optional sample_curves_3d_brush(const Depsgraph &depsgraph, } } - const float4x4 curves_to_world_mat(curves_object.object_to_world); + const float4x4 curves_to_world_mat = curves_object.object_to_world(); const float4x4 world_to_curves_mat = math::invert(curves_to_world_mat); const float3 center_ray_start_cu = math::transform_point(world_to_curves_mat, diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index b7aea67600d..babf2d2c4cd 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -679,7 +679,7 @@ static void select_grow_invoke_per_curve(const Curves &curves_id, }); }); - float4x4 curves_to_world_mat = float4x4(curves_ob.object_to_world); + float4x4 curves_to_world_mat = curves_ob.object_to_world(); float4x4 world_to_curves_mat = math::invert(curves_to_world_mat); const float4x4 projection = ED_view3d_ob_project_mat_get(&rv3d, &curves_ob); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.cc b/source/blender/editors/sculpt_paint/paint_cursor.cc index 8c5a37aece4..ca9db0a0c16 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.cc +++ b/source/blender/editors/sculpt_paint/paint_cursor.cc @@ -1098,7 +1098,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr, for (int dim = 0; dim < 3; dim++) { location[dim] = cur[dim] * step[dim] + orgLoc[dim]; } - cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world, 3); + cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world().ptr(), 3); } } } @@ -1120,7 +1120,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, /* Axis Symmetry. */ flip_v3_v3(location, true_location, ePaintSymmetryFlags(i)); - cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world, 3); + cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world().ptr(), 3); /* Tiling. */ cursor_draw_tiling_preview(gpuattr, region, location, sd, ob, radius); @@ -1135,7 +1135,8 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, mul_m4_v3(symm_rot_mat, location); cursor_draw_tiling_preview(gpuattr, region, location, sd, ob, radius); - cursor_draw_point_screen_space(gpuattr, region, location, ob->object_to_world, 3); + cursor_draw_point_screen_space( + gpuattr, region, location, ob->object_to_world().ptr(), 3); } } } @@ -1376,7 +1377,7 @@ static void paint_cursor_update_pixel_radius(PaintCursorContext *pcontext) } copy_v3_v3(pcontext->scene_space_location, pcontext->location); - mul_m4_v3(pcontext->vc.obact->object_to_world, pcontext->scene_space_location); + mul_m4_v3(pcontext->vc.obact->object_to_world().ptr(), pcontext->scene_space_location); } else { Sculpt *sd = CTX_data_tool_settings(pcontext->C)->sculpt; @@ -1657,7 +1658,7 @@ static void paint_cursor_drawing_setup_cursor_space(PaintCursorContext *pcontext float cursor_trans[4][4], cursor_rot[4][4]; const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; float quat[4]; - copy_m4_m4(cursor_trans, pcontext->vc.obact->object_to_world); + copy_m4_m4(cursor_trans, pcontext->vc.obact->object_to_world().ptr()); translate_m4(cursor_trans, pcontext->location[0], pcontext->location[1], pcontext->location[2]); rotation_between_vecs_to_quat(quat, z_axis, pcontext->normal); quat_to_mat4(cursor_rot, quat); @@ -1701,7 +1702,7 @@ static void paint_cursor_pose_brush_origins_draw(PaintCursorContext *pcontext) cursor_draw_point_screen_space(pcontext->pos, pcontext->region, ss->pose_ik_chain_preview->segments[i].initial_orig, - pcontext->vc.obact->object_to_world, + pcontext->vc.obact->object_to_world().ptr(), 3); } } @@ -1719,7 +1720,7 @@ static void paint_cursor_preview_boundary_data_pivot_draw(PaintCursorContext *pc pcontext->pos, pcontext->region, SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->boundary_preview->pivot_vertex), - pcontext->vc.obact->object_to_world, + pcontext->vc.obact->object_to_world().ptr(), 3); } @@ -1828,7 +1829,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * pcontext->pos, pcontext->region, SCULPT_vertex_co_get(pcontext->ss, pcontext->ss->expand_cache->initial_active_vertex), - pcontext->vc.obact->object_to_world, + pcontext->vc.obact->object_to_world().ptr(), 2); } @@ -1850,7 +1851,7 @@ static void paint_cursor_draw_3d_view_brush_cursor_inactive(PaintCursorContext * nullptr); GPU_matrix_push(); - GPU_matrix_mul(pcontext->vc.obact->object_to_world); + GPU_matrix_mul(pcontext->vc.obact->object_to_world().ptr()); /* Drawing Cursor overlays in 3D object space. */ if (is_brush_tool && brush->sculpt_tool == SCULPT_TOOL_GRAB && @@ -1944,7 +1945,7 @@ static void paint_cursor_cursor_draw_3d_view_brush_cursor_active(PaintCursorCont nullptr, nullptr); GPU_matrix_push(); - GPU_matrix_mul(pcontext->vc.obact->object_to_world); + GPU_matrix_mul(pcontext->vc.obact->object_to_world().ptr()); /* Draw the special active cursors different tools may have. */ diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index d07320ca577..f6b79b5bd27 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -859,7 +859,7 @@ void paint_init_pivot(Object *ob, Scene *scene) return; } - mul_m4_v3(ob->object_to_world, location); + mul_m4_v3(ob->object_to_world().ptr(), location); ups->last_stroke_valid = true; ups->average_stroke_counter = 1; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 50e3e84228f..3876ec8c77e 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -3690,7 +3690,7 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet ps->viewDir[1] = 0.0f; ps->viewDir[2] = 1.0f; - copy_m4_m4(ps->obmat, ps->ob->object_to_world); + copy_m4_m4(ps->obmat, ps->ob->object_to_world().ptr()); if (symmetry_flag) { int i; @@ -3750,7 +3750,7 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet CameraParams params; /* viewmat & viewinv */ - copy_m4_m4(viewinv, cam_ob_eval->object_to_world); + copy_m4_m4(viewinv, cam_ob_eval->object_to_world().ptr()); normalize_m4(viewinv); invert_m4_m4(viewmat, viewinv); @@ -4495,7 +4495,7 @@ static void project_paint_begin(const bContext *C, if (ps->source == PROJ_SRC_VIEW) { /* faster clipping lookups */ - ED_view3d_clipping_local(ps->rv3d, ps->ob->object_to_world); + ED_view3d_clipping_local(ps->rv3d, ps->ob->object_to_world().ptr()); } ps->do_face_sel = ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) != 0); diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index ba48152609a..9bed9f898e8 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -695,7 +695,7 @@ static void sculpt_gesture_context_init_common(bContext *C, copy_m3_m4(mat, sgcontext->vc.rv3d->viewinv); mul_m3_v3(mat, view_dir); normalize_v3_v3(sgcontext->world_space_view_normal, view_dir); - copy_m3_m4(mat, ob->world_to_object); + copy_m3_m4(mat, ob->world_to_object().ptr()); mul_m3_v3(mat, view_dir); normalize_v3_v3(sgcontext->true_view_normal, view_dir); @@ -807,12 +807,12 @@ static void sculpt_gesture_line_plane_from_tri(float *r_plane, { float normal[3]; normal_tri_v3(normal, p1, p2, p3); - mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->world_to_object, normal); + mul_v3_mat3_m4v3(normal, sgcontext->vc.obact->world_to_object().ptr(), normal); if (flip) { mul_v3_fl(normal, -1.0f); } float plane_point_object_space[3]; - mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->world_to_object, p1); + mul_v3_m4v3(plane_point_object_space, sgcontext->vc.obact->world_to_object().ptr(), p1); plane_from_point_normal_v3(r_plane, plane_point_object_space, normal); } @@ -1422,18 +1422,20 @@ static void sculpt_gesture_trim_shape_origin_normal_get(SculptGestureContext *sg */ switch (trim_operation->orientation) { case SCULPT_GESTURE_TRIM_ORIENTATION_VIEW: - mul_v3_m4v3( - r_origin, sgcontext->vc.obact->object_to_world, sgcontext->ss->gesture_initial_location); + mul_v3_m4v3(r_origin, + sgcontext->vc.obact->object_to_world().ptr(), + sgcontext->ss->gesture_initial_location); copy_v3_v3(r_normal, sgcontext->world_space_view_normal); negate_v3(r_normal); break; case SCULPT_GESTURE_TRIM_ORIENTATION_SURFACE: - mul_v3_m4v3( - r_origin, sgcontext->vc.obact->object_to_world, sgcontext->ss->gesture_initial_location); + mul_v3_m4v3(r_origin, + sgcontext->vc.obact->object_to_world().ptr(), + sgcontext->ss->gesture_initial_location); /* Transforming the normal does not take non uniform scaling into account. Sculpt mode is not * expected to work on object with non uniform scaling. */ copy_v3_v3(r_normal, sgcontext->ss->gesture_initial_normal); - mul_mat3_m4_v3(sgcontext->vc.obact->object_to_world, r_normal); + mul_mat3_m4_v3(sgcontext->vc.obact->object_to_world().ptr(), r_normal); break; } } @@ -1464,7 +1466,7 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext) * mesh, coordinates are first calculated in world space, then converted to object space to * store them. */ float world_space_vco[3]; - mul_v3_m4v3(world_space_vco, vc->obact->object_to_world, vco); + mul_v3_m4v3(world_space_vco, vc->obact->object_to_world().ptr(), vco); const float dist = dist_signed_to_plane_v3(world_space_vco, shape_plane); trim_operation->depth_front = min_ff(dist, trim_operation->depth_front); trim_operation->depth_back = max_ff(dist, trim_operation->depth_back); @@ -1473,7 +1475,7 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext) if (trim_operation->use_cursor_depth) { float world_space_gesture_initial_location[3]; mul_v3_m4v3(world_space_gesture_initial_location, - vc->obact->object_to_world, + vc->obact->object_to_world().ptr(), ss->gesture_initial_location); float mid_point_depth; @@ -1557,7 +1559,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex sculpt_gesture_trim_shape_origin_normal_get(sgcontext, shape_origin, shape_normal); plane_from_point_normal_v3(shape_plane, shape_origin, shape_normal); - const float(*ob_imat)[4] = vc->obact->world_to_object; + const float(*ob_imat)[4] = vc->obact->world_to_object().ptr(); /* Write vertices coordinatesSCULPT_GESTURE_TRIM_DIFFERENCE for the front face. */ MutableSpan positions = trim_operation->mesh->vert_positions_for_write(); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.cc b/source/blender/editors/sculpt_paint/paint_stroke.cc index b9b6d7bd8a7..6bde9707c8b 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.cc +++ b/source/blender/editors/sculpt_paint/paint_stroke.cc @@ -550,7 +550,7 @@ static void paint_brush_stroke_add_step( C, world_space_position, stroke->last_mouse_position, stroke->original)) { copy_v3_v3(stroke->last_world_space_position, world_space_position); - mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), stroke->last_world_space_position); } else { add_v3_v3(stroke->last_world_space_position, stroke->last_scene_spacing_delta); @@ -668,7 +668,7 @@ static float paint_space_stroke_spacing(bContext *C, if (!BKE_brush_use_locked_size(scene, brush)) { float last_object_space_position[3]; mul_v3_m4v3(last_object_space_position, - stroke->vc.obact->world_to_object, + stroke->vc.obact->world_to_object().ptr(), stroke->last_world_space_position); size_clamp = paint_calc_object_space_radius(&stroke->vc, last_object_space_position, size); } @@ -818,7 +818,7 @@ static int paint_space_stroke(bContext *C, if (use_scene_spacing) { float world_space_position[3]; bool hit = SCULPT_stroke_get_location(C, world_space_position, final_mouse, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world, world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), world_space_position); if (hit && stroke->stroke_over_mesh) { sub_v3_v3v3(d_world_space_position, world_space_position, stroke->last_world_space_position); length = len_v3(d_world_space_position); @@ -1224,8 +1224,8 @@ static void paint_line_strokes_spacing(bContext *C, C, world_space_position_old, old_pos, stroke->original); bool hit_new = SCULPT_stroke_get_location( C, world_space_position_new, new_pos, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world, world_space_position_old); - mul_m4_v3(stroke->vc.obact->object_to_world, world_space_position_new); + mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), world_space_position_old); + mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), world_space_position_new); if (hit_old && hit_new && stroke->stroke_over_mesh) { sub_v3_v3v3(d_world_space_position, world_space_position_new, world_space_position_old); length = len_v3(d_world_space_position); @@ -1369,7 +1369,8 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str if (paint_stroke_use_scene_spacing(br, BKE_paintmode_get_active_from_context(C))) { stroke->stroke_over_mesh = SCULPT_stroke_get_location( C, stroke->last_world_space_position, data + 2 * j, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), + stroke->last_world_space_position); } stroke->stroke_started = stroke->test_start(C, op, stroke->last_mouse_position); @@ -1503,7 +1504,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintS if (paint_stroke_use_scene_spacing(br, mode)) { stroke->stroke_over_mesh = SCULPT_stroke_get_location( C, stroke->last_world_space_position, sample_average.mouse, stroke->original); - mul_m4_v3(stroke->vc.obact->object_to_world, stroke->last_world_space_position); + mul_m4_v3(stroke->vc.obact->object_to_world().ptr(), stroke->last_world_space_position); } stroke->stroke_started = stroke->test_start(C, op, sample_average.mouse); diff --git a/source/blender/editors/sculpt_paint/paint_utils.cc b/source/blender/editors/sculpt_paint/paint_utils.cc index 89a7d96bbdb..3b3f5e7f512 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.cc +++ b/source/blender/editors/sculpt_paint/paint_utils.cc @@ -133,12 +133,12 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3], flo float delta[3], scale, loc[3]; const float xy_delta[2] = {pixel_radius, 0.0f}; - mul_v3_m4v3(loc, ob->object_to_world, center); + mul_v3_m4v3(loc, ob->object_to_world().ptr(), center); const float zfac = ED_view3d_calc_zfac(vc->rv3d, loc); ED_view3d_win_to_delta(vc->region, xy_delta, zfac, delta); - scale = fabsf(mat4_to_scale(ob->object_to_world)); + scale = fabsf(mat4_to_scale(ob->object_to_world().ptr())); scale = (scale == 0.0f) ? 1.0f : scale; return len_v3(delta) / scale; @@ -284,7 +284,7 @@ static void imapaint_pick_uv(const Mesh *me_eval, GPU_matrix_model_view_get(matrix); GPU_matrix_projection_get(proj); view[0] = view[1] = 0; - mul_m4_m4m4(matrix, matrix, ob_eval->object_to_world); + mul_m4_m4m4(matrix, matrix, ob_eval->object_to_world().ptr()); mul_m4_m4m4(matrix, proj, matrix); minabsw = 1e10; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index d8e11b5c502..9527dc6091e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -47,6 +47,7 @@ #include "BKE_mesh_mapping.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" +#include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_report.hh" @@ -486,10 +487,10 @@ void update_cache_invariants( /* cache projection matrix */ cache->projection_mat = ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob); - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); copy_m3_m4(mat, cache->vc->rv3d->viewinv); mul_m3_v3(mat, view_dir); - copy_m3_m4(mat, ob->world_to_object); + copy_m3_m4(mat, ob->world_to_object().ptr()); mul_m3_v3(mat, view_dir); normalize_v3_v3(cache->true_view_normal, view_dir); @@ -1921,7 +1922,7 @@ static void vpaint_stroke_update_step(bContext *C, ED_view3d_init_mats_rv3d(ob, vc->rv3d); /* load projection matrix */ - mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world); + mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world().ptr()); swap_m4m4(vc->rv3d->persmat, mat); @@ -1938,7 +1939,7 @@ static void vpaint_stroke_update_step(bContext *C, /* Calculate pivot for rotation around selection if needed. * also needed for "Frame Selected" on last stroke. */ float loc_world[3]; - mul_v3_m4v3(loc_world, ob->object_to_world, ss->cache->true_location); + mul_v3_m4v3(loc_world, ob->object_to_world().ptr(), ss->cache->true_location); vwpaint::last_stroke_update(scene, loc_world); ED_region_tag_redraw(vc->region); diff --git a/source/blender/editors/sculpt_paint/paint_weight.cc b/source/blender/editors/sculpt_paint/paint_weight.cc index 73f1b32bf91..2cfec9434dd 100644 --- a/source/blender/editors/sculpt_paint/paint_weight.cc +++ b/source/blender/editors/sculpt_paint/paint_weight.cc @@ -1849,7 +1849,7 @@ static void wpaint_stroke_update_step(bContext *C, ED_view3d_init_mats_rv3d(ob, vc->rv3d); /* load projection matrix */ - mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world); + mul_m4_m4m4(mat, vc->rv3d->persmat, ob->object_to_world().ptr()); Mesh *mesh = static_cast(ob->data); @@ -1887,7 +1887,7 @@ static void wpaint_stroke_update_step(bContext *C, /* Calculate pivot for rotation around selection if needed. * also needed for "Frame Selected" on last stroke. */ float loc_world[3]; - mul_v3_m4v3(loc_world, ob->object_to_world, ss->cache->true_location); + mul_v3_m4v3(loc_world, ob->object_to_world().ptr(), ss->cache->true_location); vwpaint::last_stroke_update(scene, loc_world); BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL); diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 0dc62d73dc3..13c1a1baa21 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -2686,14 +2686,14 @@ static void calc_local_from_screen(ViewContext *vc, Object *ob = vc->obact; float loc[3]; - mul_v3_m4v3(loc, ob->object_to_world, center); + mul_v3_m4v3(loc, ob->object_to_world().ptr(), center); const float zfac = ED_view3d_calc_zfac(vc->rv3d, loc); ED_view3d_win_to_delta(vc->region, screen_dir, zfac, r_local_dir); normalize_v3(r_local_dir); add_v3_v3(r_local_dir, ob->loc); - mul_m4_v3(ob->world_to_object, r_local_dir); + mul_m4_v3(ob->world_to_object().ptr(), r_local_dir); } static void calc_brush_local_mat(const float rotation, @@ -2708,7 +2708,7 @@ static void calc_brush_local_mat(const float rotation, float angle, v[3]; /* Ensure `ob->world_to_object` is up to date. */ - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); /* Initialize last column of matrix. */ mat[0][3] = 0.0f; @@ -2772,13 +2772,13 @@ void SCULPT_tilt_apply_to_normal(float r_normal[3], return; } const float rot_max = M_PI_2 * tilt_strength * SCULPT_TILT_SENSITIVITY; - mul_v3_mat3_m4v3(r_normal, cache->vc->obact->object_to_world, r_normal); + mul_v3_mat3_m4v3(r_normal, cache->vc->obact->object_to_world().ptr(), r_normal); float normal_tilt_y[3]; rotate_v3_v3v3fl(normal_tilt_y, r_normal, cache->vc->rv3d->viewinv[0], cache->y_tilt * rot_max); float normal_tilt_xy[3]; rotate_v3_v3v3fl( normal_tilt_xy, normal_tilt_y, cache->vc->rv3d->viewinv[1], cache->x_tilt * rot_max); - mul_v3_mat3_m4v3(r_normal, cache->vc->obact->world_to_object, normal_tilt_xy); + mul_v3_mat3_m4v3(r_normal, cache->vc->obact->world_to_object().ptr(), normal_tilt_xy); normalize_v3(r_normal); } @@ -3239,7 +3239,7 @@ static void sculpt_topology_update(Sculpt *sd, /* Update average stroke position. */ copy_v3_v3(location, ss->cache->true_location); - mul_m4_v3(ob->object_to_world, location); + mul_m4_v3(ob->object_to_world().ptr(), location); } static void do_brush_action_task(Object *ob, const Brush *brush, PBVHNode *node) @@ -3570,7 +3570,7 @@ static void do_brush_action(Sculpt *sd, /* Update average stroke position. */ copy_v3_v3(location, ss->cache->true_location); - mul_m4_v3(ob->object_to_world, location); + mul_m4_v3(ob->object_to_world().ptr(), location); add_v3_v3(ups->average_stroke_accum, location); ups->average_stroke_counter++; @@ -4102,8 +4102,8 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) /* Store matrix for mirror object clipping. */ if (mmd->mirror_ob) { float imtx_mirror_ob[4][4]; - invert_m4_m4(imtx_mirror_ob, mmd->mirror_ob->object_to_world); - mul_m4_m4m4(ss->cache->clip_mirror_mtx.ptr(), imtx_mirror_ob, ob->object_to_world); + invert_m4_m4(imtx_mirror_ob, mmd->mirror_ob->object_to_world().ptr()); + mul_m4_m4m4(ss->cache->clip_mirror_mtx.ptr(), imtx_mirror_ob, ob->object_to_world().ptr()); } } } @@ -4270,10 +4270,10 @@ static void sculpt_update_cache_invariants( /* Cache projection matrix. */ cache->projection_mat = ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob); - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); copy_m3_m4(mat, cache->vc->rv3d->viewinv); mul_m3_v3(mat, viewDir); - copy_m3_m4(mat, ob->world_to_object); + copy_m3_m4(mat, ob->world_to_object().ptr()); mul_m3_v3(mat, viewDir); normalize_v3_v3(cache->true_view_normal, viewDir); @@ -4289,7 +4289,7 @@ static void sculpt_update_cache_invariants( if (sd->gravity_object) { Object *gravity_object = sd->gravity_object; - copy_v3_v3(cache->true_gravity_direction, gravity_object->object_to_world[2]); + copy_v3_v3(cache->true_gravity_direction, gravity_object->object_to_world().ptr()[2]); } else { cache->true_gravity_direction[0] = cache->true_gravity_direction[1] = 0.0f; @@ -4449,27 +4449,27 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru } /* Compute 3d coordinate at same z from original location + mval. */ - mul_v3_m4v3(loc, ob->object_to_world, cache->orig_grab_location); + mul_v3_m4v3(loc, ob->object_to_world().ptr(), cache->orig_grab_location); ED_view3d_win_to_3d(cache->vc->v3d, cache->vc->region, loc, mval, grab_location); /* Compute delta to move verts by. */ if (!SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) { if (sculpt_needs_delta_from_anchored_origin(brush)) { sub_v3_v3v3(delta, grab_location, cache->old_grab_location); - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); mul_mat3_m4_v3(imat, delta); add_v3_v3(cache->grab_delta, delta); } else if (sculpt_needs_delta_for_tip_orientation(brush)) { if (brush->flag & BRUSH_ANCHORED) { float orig[3]; - mul_v3_m4v3(orig, ob->object_to_world, cache->orig_grab_location); + mul_v3_m4v3(orig, ob->object_to_world().ptr(), cache->orig_grab_location); sub_v3_v3v3(cache->grab_delta, grab_location, orig); } else { sub_v3_v3v3(cache->grab_delta, grab_location, cache->old_grab_location); } - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); mul_mat3_m4_v3(imat, cache->grab_delta); } else { @@ -4514,7 +4514,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru /* Handle 'rake' */ cache->is_rake_rotation_valid = false; - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); mul_mat3_m4_v3(imat, grab_location); if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache)) { @@ -4851,7 +4851,7 @@ float SCULPT_raycast_init(ViewContext *vc, ED_view3d_win_to_segment_clipped( vc->depsgraph, vc->region, vc->v3d, mval, ray_start, ray_end, true); - invert_m4_m4(obimat, ob->object_to_world); + invert_m4_m4(obimat, ob->object_to_world().ptr()); mul_m4_v3(obimat, ray_start); mul_m4_v3(obimat, ray_end); @@ -4976,10 +4976,10 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, float radius; /* Update cursor data in SculptSession. */ - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); copy_m3_m4(mat, vc.rv3d->viewinv); mul_m3_v3(mat, viewDir); - copy_m3_m4(mat, ob->world_to_object); + copy_m3_m4(mat, ob->world_to_object().ptr()); mul_m3_v3(mat, viewDir); normalize_v3_v3(ss->cursor_view_normal, viewDir); copy_v3_v3(ss->cursor_normal, srd.face_normal); @@ -5513,7 +5513,7 @@ static void sculpt_stroke_update_step(bContext *C, if (sd->flags & (SCULPT_DYNTOPO_DETAIL_CONSTANT | SCULPT_DYNTOPO_DETAIL_MANUAL)) { float object_space_constant_detail = 1.0f / (sd->constant_detail * - mat4_to_scale(ob->object_to_world)); + mat4_to_scale(ob->object_to_world().ptr())); BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail); } else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) { diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index c4397e63f1f..77baeb354c6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -669,14 +669,15 @@ static void cloth_brush_solve_collision(Object *object, SimulationData *cloth_si BVHTreeRayHit hit; float obmat_inv[4][4]; - invert_m4_m4(obmat_inv, object->object_to_world); + invert_m4_m4(obmat_inv, object->object_to_world().ptr()); LISTBASE_FOREACH (ColliderCache *, collider_cache, cloth_sim->collider_list) { float ray_start[3], ray_normal[3]; float pos_world_space[3], prev_pos_world_space[3]; - mul_v3_m4v3(pos_world_space, object->object_to_world, cloth_sim->pos[i]); - mul_v3_m4v3(prev_pos_world_space, object->object_to_world, cloth_sim->last_iteration_pos[i]); + mul_v3_m4v3(pos_world_space, object->object_to_world().ptr(), cloth_sim->pos[i]); + mul_v3_m4v3( + prev_pos_world_space, object->object_to_world().ptr(), cloth_sim->last_iteration_pos[i]); sub_v3_v3v3(ray_normal, pos_world_space, prev_pos_world_space); copy_v3_v3(ray_start, prev_pos_world_space); hit.index = -1; @@ -1388,7 +1389,7 @@ static void cloth_filter_apply_forces_task(Object *ob, float sculpt_gravity[3] = {0.0f}; if (sd->gravity_object) { - copy_v3_v3(sculpt_gravity, sd->gravity_object->object_to_world[2]); + copy_v3_v3(sculpt_gravity, sd->gravity_object->object_to_world().ptr()[2]); } else { sculpt_gravity[2] = -1.0f; diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.cc b/source/blender/editors/sculpt_paint/sculpt_detail.cc index e8c39b77afe..5bbe6b26b48 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.cc +++ b/source/blender/editors/sculpt_paint/sculpt_detail.cc @@ -109,8 +109,8 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op) const float size = math::reduce_max(dim); /* Update topology size. */ - float object_space_constant_detail = 1.0f / - (sd->constant_detail * mat4_to_scale(ob->object_to_world)); + float object_space_constant_detail = 1.0f / (sd->constant_detail * + mat4_to_scale(ob->object_to_world().ptr())); BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail); undo::push_begin(ob, op); @@ -240,7 +240,7 @@ static void sample_detail_dyntopo(bContext *C, ViewContext *vc, const int mval[2 if (srd.hit && srd.edge_length > 0.0f) { /* Convert edge length to world space detail resolution. */ - sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->object_to_world)); + sd->constant_detail = 1 / (srd.edge_length * mat4_to_scale(ob->object_to_world().ptr())); } } @@ -495,8 +495,9 @@ static void dyntopo_detail_size_parallel_lines_draw(uint pos3d, bool flip, const float angle) { - float object_space_constant_detail = 1.0f / (cd->detail_size * - mat4_to_scale(cd->active_object->object_to_world)); + float object_space_constant_detail = 1.0f / + (cd->detail_size * + mat4_to_scale(cd->active_object->object_to_world().ptr())); /* The constant detail represents the maximum edge length allowed before subdividing it. If the * triangle grid preview is created with this value it will represent an ideal mesh density where @@ -613,8 +614,8 @@ static void dyntopo_detail_size_sample_from_surface(Object *ob, if (num_neighbors > 0) { const float avg_edge_len = len_accum / num_neighbors; /* Use 0.7 as the average of min and max dyntopo edge length. */ - const float detail_size = 0.7f / - (avg_edge_len * mat4_to_scale(cd->active_object->object_to_world)); + const float detail_size = 0.7f / (avg_edge_len * + mat4_to_scale(cd->active_object->object_to_world().ptr())); cd->detail_size = clamp_f(detail_size, 1.0f, 500.0f); } } @@ -740,7 +741,7 @@ static int dyntopo_detail_size_edit_invoke(bContext *C, wmOperator *op, const wm float cursor_trans[4][4], cursor_rot[4][4]; const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; float quat[4]; - copy_m4_m4(cursor_trans, active_object->object_to_world); + copy_m4_m4(cursor_trans, active_object->object_to_world().ptr()); translate_m4( cursor_trans, ss->cursor_location[0], ss->cursor_location[1], ss->cursor_location[2]); diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 31bc14f506f..629a4be41ef 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -1102,7 +1102,7 @@ static int sculpt_face_set_change_visibility_exec(bContext *C, wmOperator *op) UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; float location[3]; copy_v3_v3(location, SCULPT_active_vertex_co_get(ss)); - mul_m4_v3(object.object_to_world, location); + mul_m4_v3(object.object_to_world().ptr(), location); copy_v3_v3(ups->average_stroke_accum, location); ups->average_stroke_counter = 1; ups->last_stroke_valid = true; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index e743f44c91f..cc0adff706e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -24,6 +24,7 @@ #include "BKE_brush.hh" #include "BKE_context.hh" +#include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pbvh_api.hh" @@ -131,8 +132,8 @@ void cache_init(bContext *C, } /* Setup orientation matrices. */ - copy_m4_m4(ss->filter_cache->obmat.ptr(), ob->object_to_world); - invert_m4_m4(ss->filter_cache->obmat_inv.ptr(), ob->object_to_world); + copy_m4_m4(ss->filter_cache->obmat.ptr(), ob->object_to_world().ptr()); + invert_m4_m4(ss->filter_cache->obmat_inv.ptr(), ob->object_to_world().ptr()); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc = ED_view3d_viewcontext_init(C, depsgraph); @@ -184,7 +185,7 @@ void cache_init(bContext *C, /* Update last stroke location */ - mul_m4_v3(ob->object_to_world, co); + mul_m4_v3(ob->object_to_world().ptr(), co); add_v3_v3(ups->average_stroke_accum, co); ups->average_stroke_counter++; @@ -199,10 +200,10 @@ void cache_init(bContext *C, float mat[3][3]; float viewDir[3] = {0.0f, 0.0f, 1.0f}; if (vc.rv3d) { - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); copy_m3_m4(mat, vc.rv3d->viewinv); mul_m3_v3(mat, viewDir); - copy_m3_m4(mat, ob->world_to_object); + copy_m3_m4(mat, ob->world_to_object().ptr()); mul_m3_v3(mat, viewDir); normalize_v3_v3(ss->filter_cache->view_normal, viewDir); } diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index 8e93dc349be..113e67997d7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -319,7 +319,7 @@ void ensure_valid_pivot(const Object *ob, Scene *scene) if (ups->average_stroke_counter == 0 || !ups->last_stroke_valid) { const Bounds bounds = BKE_pbvh_bounding_box(ob->sculpt->pbvh); const float3 center = math::midpoint(bounds.min, bounds.max); - const float3 location = math::transform_point(float4x4(ob->object_to_world), center); + const float3 location = math::transform_point(ob->object_to_world(), center); copy_v3_v3(ups->average_stroke_accum, location); ups->average_stroke_counter = 1; @@ -352,7 +352,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain, BKE_report( reports, RPT_WARNING, "Object has non-uniform scale, sculpting may be unpredictable"); } - else if (is_negative_m4(ob->object_to_world)) { + else if (is_negative_m4(ob->object_to_world().ptr())) { BKE_report(reports, RPT_WARNING, "Object has negative scale, sculpting may be unpredictable"); } diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index b331c3dfe07..138fe99c718 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -126,11 +126,11 @@ bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion void ED_view3d_init_mats_rv3d(const Object *ob, RegionView3D *rv3d) { /* local viewmat and persmat, to calculate projections */ - mul_m4_m4m4(rv3d->viewmatob, rv3d->viewmat, ob->object_to_world); - mul_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->object_to_world); + mul_m4_m4m4(rv3d->viewmatob, rv3d->viewmat, ob->object_to_world().ptr()); + mul_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->object_to_world().ptr()); /* initializes object space clipping, speeds up clip tests */ - ED_view3d_clipping_local(rv3d, ob->object_to_world); + ED_view3d_clipping_local(rv3d, ob->object_to_world().ptr()); } void ED_view3d_init_mats_rv3d_gl(const Object *ob, RegionView3D *rv3d) @@ -140,7 +140,7 @@ void ED_view3d_init_mats_rv3d_gl(const Object *ob, RegionView3D *rv3d) /* We have to multiply instead of loading `viewmatob` to make * it work with duplis using display-lists, otherwise it will * override the dupli-matrix. */ - GPU_matrix_mul(ob->object_to_world); + GPU_matrix_mul(ob->object_to_world().ptr()); } #ifndef NDEBUG @@ -737,7 +737,7 @@ static void view3d_ob_drop_matrix_from_snap(V3DSnapCursorState *snap_state, copy_v3_v3(obmat_final[3], snap_data->loc); float scale[3]; - mat4_to_size(scale, ob->object_to_world); + mat4_to_size(scale, ob->object_to_world().ptr()); rescale_m4(obmat_final, scale); if (const std::optional> bb = BKE_object_boundbox_get(ob)) { diff --git a/source/blender/editors/space_view3d/view3d_buttons.cc b/source/blender/editors/space_view3d/view3d_buttons.cc index 5e8615ada0c..2a424afa035 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.cc +++ b/source/blender/editors/space_view3d/view3d_buttons.cc @@ -42,6 +42,7 @@ #include "BKE_layer.hh" #include "BKE_object.hh" #include "BKE_object_deform.h" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "BKE_screen.hh" @@ -489,7 +490,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float /* Location, X/Y/Z */ mul_v3_fl(median_basis.generic.location, 1.0f / float(tot)); if (v3d->flag & V3D_GLOBAL_STATS) { - mul_m4_v3(ob->object_to_world, median_basis.generic.location); + mul_m4_v3(ob->object_to_world().ptr(), median_basis.generic.location); } if (has_meshdata) { @@ -928,9 +929,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float memcpy(&ve_median_basis, &tfp->ve_median, sizeof(tfp->ve_median)); if (v3d->flag & V3D_GLOBAL_STATS) { - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_v3(ob->world_to_object, median_basis.generic.location); - mul_m4_v3(ob->world_to_object, ve_median_basis.generic.location); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_v3(ob->world_to_object().ptr(), median_basis.generic.location); + mul_m4_v3(ob->world_to_object().ptr(), ve_median_basis.generic.location); } sub_vn_vnvn((float *)&median_basis, (float *)&ve_median_basis, @@ -1201,7 +1202,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d BKE_object_dimensions_eval_cached_get(ob, tfp->ob_dims); copy_v3_v3(tfp->ob_dims_orig, tfp->ob_dims); copy_v3_v3(tfp->ob_scale_orig, ob->scale); - copy_m4_m4(tfp->ob_obmat_orig, ob->object_to_world); + copy_m4_m4(tfp->ob_obmat_orig, ob->object_to_world().ptr()); uiDefBut(block, UI_BTYPE_LABEL, diff --git a/source/blender/editors/space_view3d/view3d_camera_control.cc b/source/blender/editors/space_view3d/view3d_camera_control.cc index 5788419169d..eb159e42ef4 100644 --- a/source/blender/editors/space_view3d/view3d_camera_control.cc +++ b/source/blender/editors/space_view3d/view3d_camera_control.cc @@ -152,7 +152,7 @@ View3DCameraControl *ED_view3d_cameracontrol_acquire(Depsgraph *depsgraph, vctrl->obtfm = BKE_object_tfm_backup(ob_back); BKE_object_where_is_calc(depsgraph, scene, v3d->camera); - negate_v3_v3(rv3d->ofs, v3d->camera->object_to_world[3]); + negate_v3_v3(rv3d->ofs, v3d->camera->object_to_world().location()); rv3d->dist = 0.0; } @@ -260,7 +260,7 @@ void ED_view3d_cameracontrol_update(View3DCameraControl *vctrl, /* args for keyf invert_m4_m4(prev_view_imat, vctrl->view_mat_prev); mul_m4_m4m4(diff_mat, view_mat, prev_view_imat); - mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->object_to_world); + mul_m4_m4m4(parent_mat, diff_mat, vctrl->root_parent->object_to_world().ptr()); if (object_apply_mat4_with_protect(vctrl->root_parent, parent_mat, false, rv3d, view_mat)) { /* Calculate again since the view locking changes the matrix. */ diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 2721178d95c..258b9282c17 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -2104,7 +2104,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph, rv3d.persp = RV3D_CAMOB; - copy_m4_m4(rv3d.viewinv, v3d.camera->object_to_world); + copy_m4_m4(rv3d.viewinv, v3d.camera->object_to_world().ptr()); normalize_m4(rv3d.viewinv); invert_m4_m4(rv3d.viewmat, rv3d.viewinv); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.cc b/source/blender/editors/space_view3d/view3d_gizmo_armature.cc index efc455d539f..23f8b3c4077 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_armature.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.cc @@ -184,7 +184,8 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup bspline_group->handles[i].index = i; float mat[4][4]; - mul_m4_m4m4(mat, ob->object_to_world, (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); + mul_m4_m4m4( + mat, ob->object_to_world().ptr(), (i == 0) ? pchan->disp_mat : pchan->disp_tail_mat); copy_m4_m4(gz->matrix_space, mat); /* need to set property here for undo. TODO: would prefer to do this in _init. */ diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.cc b/source/blender/editors/space_view3d/view3d_gizmo_camera.cc index dec1da7b4b7..5daeab00a3a 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.cc @@ -87,7 +87,7 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup) MEM_callocN(sizeof(CameraWidgetGroup), __func__)); gzgroup->customdata = cagzgroup; - negate_v3_v3(dir, ob->object_to_world[2]); + negate_v3_v3(dir, ob->object_to_world().ptr()[2]); /* dof distance */ { @@ -139,11 +139,12 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) PointerRNA camera_ptr = RNA_pointer_create(&ca->id, &RNA_Camera, ca); - negate_v3_v3(dir, ob->object_to_world[2]); + negate_v3_v3(dir, ob->object_to_world().ptr()[2]); if ((ca->flag & CAM_SHOWLIMITS) && (v3d->gizmo_show_camera & V3D_GIZMO_SHOW_CAMERA_DOF_DIST)) { - WM_gizmo_set_matrix_location(cagzgroup->dop_dist, ob->object_to_world[3]); - WM_gizmo_set_matrix_rotation_from_yz_axis(cagzgroup->dop_dist, ob->object_to_world[1], dir); + WM_gizmo_set_matrix_location(cagzgroup->dop_dist, ob->object_to_world().location()); + WM_gizmo_set_matrix_rotation_from_yz_axis( + cagzgroup->dop_dist, ob->object_to_world().ptr()[1], dir); WM_gizmo_set_scale(cagzgroup->dop_dist, ca->drawsize); WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, false); @@ -183,17 +184,17 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f; unit_m4(widget->matrix_basis); - WM_gizmo_set_matrix_location(widget, ob->object_to_world[3]); - WM_gizmo_set_matrix_rotation_from_yz_axis(widget, ob->object_to_world[1], dir); + WM_gizmo_set_matrix_location(widget, ob->object_to_world().location()); + WM_gizmo_set_matrix_rotation_from_yz_axis(widget, ob->object_to_world().ptr()[1], dir); if (is_ortho) { scale_matrix = ca->ortho_scale * 0.5f; } else { const float ob_scale_inv[3] = { - 1.0f / len_v3(ob->object_to_world[0]), - 1.0f / len_v3(ob->object_to_world[1]), - 1.0f / len_v3(ob->object_to_world[2]), + 1.0f / len_v3(ob->object_to_world().ptr()[0]), + 1.0f / len_v3(ob->object_to_world().ptr()[1]), + 1.0f / len_v3(ob->object_to_world().ptr()[2]), }; const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.cc b/source/blender/editors/space_view3d/view3d_gizmo_empty.cc index d194c0df0cd..db8cb670457 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.cc @@ -141,7 +141,7 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmGizmoGroup *gzg BKE_view_layer_synced_ensure(scene, view_layer); Object *ob = BKE_view_layer_active_object_get(view_layer); - copy_m4_m4(gz->matrix_basis, ob->object_to_world); + copy_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); RNA_enum_set(gz->ptr, "transform", diff --git a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc index d228c5a5aea..b78afae0857 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_forcefield.cc @@ -87,8 +87,8 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmGizmoGroup *gzgr const float ofs[3] = {0.0f, -size, 0.0f}; PointerRNA field_ptr = RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd); - WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); - WM_gizmo_set_matrix_rotation_from_z_axis(gz, ob->object_to_world[2]); + WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); + WM_gizmo_set_matrix_rotation_from_z_axis(gz, ob->object_to_world().ptr()[2]); WM_gizmo_set_matrix_offset_location(gz, ofs); WM_gizmo_set_flag(gz, WM_GIZMO_HIDDEN, false); WM_gizmo_target_property_def_rna(gz, "offset", &field_ptr, "strength", -1); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_light.cc b/source/blender/editors/space_view3d/view3d_gizmo_light.cc index c91402ed829..da7d0c92bbd 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_light.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_light.cc @@ -231,9 +231,9 @@ static void WIDGETGROUP_light_spot_refresh(const bContext *C, wmGizmoGroup *gzgr wmGizmo *gz = ls_gzgroup->spot_angle; float dir[3]; - negate_v3_v3(dir, ob->object_to_world[2]); + negate_v3_v3(dir, ob->object_to_world().ptr()[2]); WM_gizmo_set_matrix_rotation_from_z_axis(gz, dir); - WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); + WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); const char *propname = "spot_size"; WM_gizmo_target_property_def_rna(gz, "offset", &lamp_ptr, propname, -1); @@ -243,11 +243,11 @@ static void WIDGETGROUP_light_spot_refresh(const bContext *C, wmGizmoGroup *gzgr { wmGizmo *gz = ls_gzgroup->spot_blend; - copy_m4_m4(gz->matrix_basis, ob->object_to_world); + copy_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); /* Move center to the cone base plane. */ float dir[3]; - negate_v3_v3(dir, ob->object_to_world[2]); + negate_v3_v3(dir, ob->object_to_world().ptr()[2]); mul_v3_fl(dir, CONE_SCALE * cosf(0.5f * la->spotsize)); add_v3_v3(gz->matrix_basis[3], dir); } @@ -267,7 +267,7 @@ static void WIDGETGROUP_light_spot_draw_prepare(const bContext *C, wmGizmoGroup RegionView3D *rv3d = static_cast(CTX_wm_region(C)->regiondata); WM_gizmo_set_matrix_rotation_from_z_axis(gz, rv3d->viewinv[2]); - WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); + WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); } void VIEW3D_GGT_light_spot(wmGizmoGroupType *gzgt) @@ -353,7 +353,7 @@ static void WIDGETGROUP_light_point_draw_prepare(const bContext *C, wmGizmoGroup const RegionView3D *rv3d = static_cast(CTX_wm_region(C)->regiondata); WM_gizmo_set_matrix_rotation_from_z_axis(gz, rv3d->viewinv[2]); - WM_gizmo_set_matrix_location(gz, ob->object_to_world[3]); + WM_gizmo_set_matrix_location(gz, ob->object_to_world().location()); } void VIEW3D_GGT_light_point(wmGizmoGroupType *gzgt) @@ -459,7 +459,7 @@ static void WIDGETGROUP_light_area_refresh(const bContext *C, wmGizmoGroup *gzgr Light *la = static_cast(ob->data); wmGizmo *gz = wwrapper->gizmo; - copy_m4_m4(gz->matrix_basis, ob->object_to_world); + copy_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); int flag = ED_GIZMO_CAGE_XFORM_FLAG_SCALE; if (ELEM(la->area_shape, LA_AREA_SQUARE, LA_AREA_DISK)) { @@ -555,7 +555,7 @@ static void WIDGETGROUP_light_target_draw_prepare(const bContext *C, wmGizmoGrou Object *ob = BKE_view_layer_active_object_get(view_layer); wmGizmo *gz = wwrapper->gizmo; - normalize_m4_m4(gz->matrix_basis, ob->object_to_world); + normalize_m4_m4(gz->matrix_basis, ob->object_to_world().ptr()); unit_m4(gz->matrix_offset); if (ob->type == OB_LAMP) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc index 23df20521d4..e2611bdb575 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc @@ -102,7 +102,7 @@ static void gizmo_preselect_elem_draw(const bContext *C, wmGizmo *gz) MeshElemGizmo3D *gz_ele = (MeshElemGizmo3D *)gz; if (gz_ele->base_index != -1) { Object *ob = gz_ele->bases[gz_ele->base_index]->object; - EDBM_preselect_elem_draw(gz_ele->psel, ob->object_to_world); + EDBM_preselect_elem_draw(gz_ele->psel, ob->object_to_world().ptr()); } } @@ -188,7 +188,8 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int BMVert *vert = (BMVert *)eve_test; float vert_p_co[2], vert_co[3]; const float mval_f[2] = {float(vc.mval[0]), float(vc.mval[1])}; - mul_v3_m4v3(vert_co, gz_ele->bases[base_index_vert]->object->object_to_world, vert->co); + mul_v3_m4v3( + vert_co, gz_ele->bases[base_index_vert]->object->object_to_world().ptr(), vert->co); ED_view3d_project_v2(vc.region, vert_co, vert_p_co); float len = len_v2v2(vert_p_co, mval_f); if (len < 35) { @@ -335,7 +336,7 @@ static void gizmo_preselect_edgering_draw(const bContext *C, wmGizmo *gz) MeshEdgeRingGizmo3D *gz_ring = (MeshEdgeRingGizmo3D *)gz; if (gz_ring->base_index != -1) { Object *ob = gz_ring->bases[gz_ring->base_index]->object; - EDBM_preselect_edgering_draw(gz_ring->psel, ob->object_to_world); + EDBM_preselect_edgering_draw(gz_ring->psel, ob->object_to_world().ptr()); } } diff --git a/source/blender/editors/space_view3d/view3d_iterators.cc b/source/blender/editors/space_view3d/view3d_iterators.cc index fe973b6c389..0de0efa3071 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.cc +++ b/source/blender/editors/space_view3d/view3d_iterators.cc @@ -308,7 +308,7 @@ void meshobject_foreachScreenVert(ViewContext *vc, data.hide_vert = *attributes.lookup(".hide_vert", bke::AttrDomain::Point); if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { - ED_view3d_clipping_local(vc->rv3d, vc->obact->object_to_world); + ED_view3d_clipping_local(vc->rv3d, vc->obact->object_to_world().ptr()); } BKE_mesh_foreach_mapped_vert( @@ -357,7 +357,7 @@ void mesh_foreachScreenVert( if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world); /* for local clipping lookups */ + vc->obedit->object_to_world().ptr()); /* for local clipping lookups */ } BM_mesh_elem_table_ensure(vc->em->bm, BM_VERT); @@ -428,7 +428,7 @@ void mesh_foreachScreenEdge(ViewContext *vc, if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world); /* for local clipping lookups */ + vc->obedit->object_to_world().ptr()); /* for local clipping lookups */ } if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { @@ -527,8 +527,8 @@ void mesh_foreachScreenEdge_clip_bb_segment(ViewContext *vc, BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE); if ((clip_flag & V3D_PROJ_TEST_CLIP_BB) && (vc->rv3d->clipbb != nullptr)) { - ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world); /* for local clipping lookups. */ + ED_view3d_clipping_local( + vc->rv3d, vc->obedit->object_to_world().ptr()); /* for local clipping lookups. */ BKE_mesh_foreach_mapped_edge( mesh, vc->em->bm->totedge, mesh_foreachScreenEdge_clip_bb_segment__mapFunc, &data); } @@ -624,7 +624,7 @@ void nurbs_foreachScreenVert(ViewContext *vc, if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, - vc->obedit->object_to_world); /* for local clipping lookups */ + vc->obedit->object_to_world().ptr()); /* for local clipping lookups */ } LISTBASE_FOREACH (Nurb *, nu, nurbs) { @@ -746,7 +746,8 @@ void lattice_foreachScreenVert(ViewContext *vc, ED_view3d_check_mats_rv3d(vc->rv3d); if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { - ED_view3d_clipping_local(vc->rv3d, obedit->object_to_world); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, + obedit->object_to_world().ptr()); /* for local clipping lookups */ } for (i = 0; i < N; i++, bp++, co += 3) { diff --git a/source/blender/editors/space_view3d/view3d_navigate.cc b/source/blender/editors/space_view3d/view3d_navigate.cc index 50bd77f5bfa..b4e9e95cd82 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.cc +++ b/source/blender/editors/space_view3d/view3d_navigate.cc @@ -808,7 +808,7 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) } mul_v2_fl(lastofs, 1.0f / 4.0f); - mul_m4_v3(ob_act_eval->object_to_world, lastofs); + mul_m4_v3(ob_act_eval->object_to_world().ptr(), lastofs); is_set = true; } @@ -826,11 +826,11 @@ bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) if (ob_eval->runtime->bounds_eval) { blender::float3 cent = blender::math::midpoint(ob_eval->runtime->bounds_eval->min, ob_eval->runtime->bounds_eval->max); - mul_m4_v3(ob_eval->object_to_world, cent); + mul_m4_v3(ob_eval->object_to_world().ptr(), cent); add_v3_v3(select_center, cent); } else { - add_v3_v3(select_center, ob_eval->object_to_world[3]); + add_v3_v3(select_center, ob_eval->object_to_world().location()); } tot++; } diff --git a/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc b/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc index 94ecacb1709..f488ca5b502 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.cc @@ -262,7 +262,7 @@ void ED_view3d_smooth_view_ex( Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera); if (sview->ofs != nullptr) { sms.dst.dist = ED_view3d_offset_distance( - ob_camera_eval->object_to_world, sview->ofs, VIEW3D_DIST_FALLBACK); + ob_camera_eval->object_to_world().ptr(), sview->ofs, VIEW3D_DIST_FALLBACK); } ED_view3d_from_object(ob_camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens); sms.to_camera = true; /* restore view3d values in end */ @@ -287,7 +287,7 @@ void ED_view3d_smooth_view_ex( Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old); if (sview->ofs != nullptr) { sms.src.dist = ED_view3d_offset_distance( - ob_camera_old_eval->object_to_world, sview->ofs, 0.0f); + ob_camera_old_eval->object_to_world().ptr(), sview->ofs, 0.0f); } ED_view3d_from_object( ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens); diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_all.cc b/source/blender/editors/space_view3d/view3d_navigate_view_all.cc index a3982aec798..a6db2f9a77d 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_all.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_all.cc @@ -74,7 +74,7 @@ static void view3d_object_calc_minmax(Depsgraph *depsgraph, if (BKE_object_minmax_dupli(depsgraph, scene, ob_eval, min, max, false) == 0) { /* Use if duplis aren't found. */ if (only_center) { - minmax_v3v3_v3(min, max, ob_eval->object_to_world[3]); + minmax_v3v3_v3(min, max, ob_eval->object_to_world().location()); } else { BKE_object_minmax(ob_eval, min, max); @@ -379,8 +379,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) CTX_DATA_END; if ((ob_eval) && (ok)) { - mul_m4_v3(ob_eval->object_to_world, min); - mul_m4_v3(ob_eval->object_to_world, max); + mul_m4_v3(ob_eval->object_to_world().ptr(), min); + mul_m4_v3(ob_eval->object_to_world().ptr(), max); } } else if (is_face_map) { diff --git a/source/blender/editors/space_view3d/view3d_project.cc b/source/blender/editors/space_view3d/view3d_project.cc index 8119981a654..d0d29f0e7e8 100644 --- a/source/blender/editors/space_view3d/view3d_project.cc +++ b/source/blender/editors/space_view3d/view3d_project.cc @@ -83,7 +83,7 @@ void ED_view3d_project_float_v3_m4(const ARegion *region, eV3DProjStatus ED_view3d_project_base(const ARegion *region, Base *base, float r_co[2]) { eV3DProjStatus ret = ED_view3d_project_float_global( - region, base->object->object_to_world[3], r_co, V3D_PROJ_TEST_CLIP_DEFAULT); + region, base->object->object_to_world().location(), r_co, V3D_PROJ_TEST_CLIP_DEFAULT); /* Prevent uninitialized values when projection fails, * although the callers should check the return value. */ @@ -701,7 +701,7 @@ blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const O float vmat[4][4]; blender::float4x4 r_pmat; - mul_m4_m4m4(vmat, rv3d->viewmat, ob->object_to_world); + mul_m4_m4m4(vmat, rv3d->viewmat, ob->object_to_world().ptr()); mul_m4_m4m4(r_pmat.ptr(), rv3d->winmat, vmat); return r_pmat; } diff --git a/source/blender/editors/space_view3d/view3d_select.cc b/source/blender/editors/space_view3d/view3d_select.cc index d76202c4eb2..e32faeac4b6 100644 --- a/source/blender/editors/space_view3d/view3d_select.cc +++ b/source/blender/editors/space_view3d/view3d_select.cc @@ -2394,9 +2394,10 @@ static Base *mouse_select_object_center(ViewContext *vc, Base *startbase, const while (base) { if (BASE_SELECTABLE(v3d, base)) { float screen_co[2]; - if (ED_view3d_project_float_global( - region, base->object->object_to_world[3], screen_co, V3D_PROJ_TEST_CLIP_DEFAULT) == - V3D_PROJ_RET_OK) + if (ED_view3d_project_float_global(region, + base->object->object_to_world().location(), + screen_co, + V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) { float dist_test = len_manhattan_v2v2(mval_fl, screen_co); if (base == oldbasact) { @@ -5223,7 +5224,7 @@ static bool object_circle_select(ViewContext *vc, if (BASE_SELECTABLE(v3d, base) && ((base->flag & BASE_SELECTED) != select_flag)) { float screen_co[2]; if (ED_view3d_project_float_global(vc->region, - base->object->object_to_world[3], + base->object->object_to_world().location(), screen_co, V3D_PROJ_TEST_CLIP_DEFAULT) == V3D_PROJ_RET_OK) { diff --git a/source/blender/editors/space_view3d/view3d_snap.cc b/source/blender/editors/space_view3d/view3d_snap.cc index a88b3dcfb27..5e60f422dda 100644 --- a/source/blender/editors/space_view3d/view3d_snap.cc +++ b/source/blender/editors/space_view3d/view3d_snap.cc @@ -99,18 +99,18 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) } if (tvs.transverts_tot != 0) { - copy_m3_m4(bmat, obedit->object_to_world); + copy_m3_m4(bmat, obedit->object_to_world().ptr()); invert_m3_m3(imat, bmat); tv = tvs.transverts; for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); - add_v3_v3(vec, obedit->object_to_world[3]); + add_v3_v3(vec, obedit->object_to_world().location()); vec[0] = gridf * floorf(0.5f + vec[0] / gridf); vec[1] = gridf * floorf(0.5f + vec[1] / gridf); vec[2] = gridf * floorf(0.5f + vec[2] / gridf); - sub_v3_v3(vec, obedit->object_to_world[3]); + sub_v3_v3(vec, obedit->object_to_world().location()); mul_m3_v3(imat, vec); copy_v3_v3(tv->loc, vec); @@ -127,7 +127,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) Object *ob = DEG_get_original_object(ob_eval); bArmature *arm_eval = static_cast(ob_eval->data); - invert_m4_m4(ob_eval->world_to_object, ob_eval->object_to_world); + invert_m4_m4(ob_eval->runtime->world_to_object.ptr(), ob_eval->object_to_world().ptr()); LISTBASE_FOREACH (bPoseChannel *, pchan_eval, &ob_eval->pose->chanbase) { if (pchan_eval->bone->flag & BONE_SELECTED) { @@ -138,12 +138,12 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) /* get nearest grid point to snap to */ copy_v3_v3(nLoc, pchan_eval->pose_mat[3]); /* We must operate in world space! */ - mul_m4_v3(ob_eval->object_to_world, nLoc); + mul_m4_v3(ob_eval->object_to_world().ptr(), nLoc); vec[0] = gridf * floorf(0.5f + nLoc[0] / gridf); vec[1] = gridf * floorf(0.5f + nLoc[1] / gridf); vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf); /* Back in object space... */ - mul_m4_v3(ob_eval->world_to_object, vec); + mul_m4_v3(ob_eval->world_to_object().ptr(), vec); /* Get location of grid point in pose space. */ BKE_armature_loc_pose_to_bone(pchan_eval, vec, vec); @@ -215,12 +215,12 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *op) for (Object *ob_eval : objects_eval) { Object *ob = DEG_get_original_object(ob_eval); - vec[0] = -ob_eval->object_to_world[3][0] + - gridf * floorf(0.5f + ob_eval->object_to_world[3][0] / gridf); - vec[1] = -ob_eval->object_to_world[3][1] + - gridf * floorf(0.5f + ob_eval->object_to_world[3][1] / gridf); - vec[2] = -ob_eval->object_to_world[3][2] + - gridf * floorf(0.5f + ob_eval->object_to_world[3][2] / gridf); + vec[0] = -ob_eval->object_to_world().location()[0] + + gridf * floorf(0.5f + ob_eval->object_to_world().location()[0] / gridf); + vec[1] = -ob_eval->object_to_world().location()[1] + + gridf * floorf(0.5f + ob_eval->object_to_world().location()[1] / gridf); + vec[2] = -ob_eval->object_to_world().location()[2] + + gridf * floorf(0.5f + ob_eval->object_to_world().location()[2] / gridf); if (ob->parent) { float originmat[3][3]; @@ -347,11 +347,11 @@ static bool snap_selected_to_location(bContext *C, } if (tvs.transverts_tot != 0) { - copy_m3_m4(bmat, obedit->object_to_world); + copy_m3_m4(bmat, obedit->object_to_world().ptr()); invert_m3_m3(imat, bmat); /* get the cursor in object space */ - sub_v3_v3v3(snap_target_local, snap_target_global, obedit->object_to_world[3]); + sub_v3_v3v3(snap_target_local, snap_target_global, obedit->object_to_world().location()); mul_m3_v3(imat, snap_target_local); if (use_offset) { @@ -384,8 +384,8 @@ static bool snap_selected_to_location(bContext *C, bArmature *arm = static_cast(ob->data); float snap_target_local[3]; - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_v3_m4v3(snap_target_local, ob->world_to_object, snap_target_global); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_v3_m4v3(snap_target_local, ob->world_to_object().ptr(), snap_target_global); LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if ((pchan->bone->flag & BONE_SELECTED) && PBONE_VISIBLE(arm, pchan->bone) && @@ -411,10 +411,10 @@ static bool snap_selected_to_location(bContext *C, float cursor_pose[3]; if (use_offset) { - mul_v3_m4v3(cursor_pose, ob->object_to_world, pchan->pose_mat[3]); + mul_v3_m4v3(cursor_pose, ob->object_to_world().ptr(), pchan->pose_mat[3]); add_v3_v3(cursor_pose, offset_global); - mul_m4_v3(ob->world_to_object, cursor_pose); + mul_m4_v3(ob->world_to_object().ptr(), cursor_pose); BKE_armature_loc_pose_to_bone(pchan, cursor_pose, cursor_pose); } else { @@ -508,13 +508,13 @@ static bool snap_selected_to_location(bContext *C, float cursor_parent[3]; /* parent-relative */ if (use_offset) { - add_v3_v3v3(cursor_parent, ob->object_to_world[3], offset_global); + add_v3_v3v3(cursor_parent, ob->object_to_world().location(), offset_global); } else { copy_v3_v3(cursor_parent, snap_target_global); } - sub_v3_v3(cursor_parent, ob->object_to_world[3]); + sub_v3_v3(cursor_parent, ob->object_to_world().location()); if (ob->parent) { float originmat[3][3], parentmat[4][4]; @@ -723,7 +723,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3]) MovieTracking *tracking = &clip->tracking; - copy_m4_m4(cammat, ob->object_to_world); + copy_m4_m4(cammat, ob->object_to_world().ptr()); BKE_tracking_get_camera_object_matrix(ob, mat); @@ -798,13 +798,13 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs count += tvs.transverts_tot; if (tvs.transverts_tot != 0) { Object *obedit_eval = DEG_get_evaluated_object(depsgraph, obedit); - copy_m3_m4(bmat, obedit_eval->object_to_world); + copy_m3_m4(bmat, obedit_eval->object_to_world().ptr()); tv = tvs.transverts; for (int i = 0; i < tvs.transverts_tot; i++, tv++) { copy_v3_v3(vec, tv->loc); mul_m3_v3(bmat, vec); - add_v3_v3(vec, obedit_eval->object_to_world[3]); + add_v3_v3(vec, obedit_eval->object_to_world().location()); add_v3_v3(centroid, vec); minmax_v3v3_v3(min, max, vec); } @@ -822,7 +822,7 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs if (ANIM_bonecoll_is_visible_pchan(arm, pchan)) { if (pchan->bone->flag & BONE_SELECTED) { copy_v3_v3(vec, pchan->pose_head); - mul_m4_v3(obact_eval->object_to_world, vec); + mul_m4_v3(obact_eval->object_to_world().ptr(), vec); add_v3_v3(centroid, vec); minmax_v3v3_v3(min, max, vec); count++; @@ -832,7 +832,7 @@ static bool snap_curs_to_sel_ex(bContext *C, const int pivot_point, float r_curs } else { FOREACH_SELECTED_OBJECT_BEGIN (view_layer_eval, v3d, ob_eval) { - copy_v3_v3(vec, ob_eval->object_to_world[3]); + copy_v3_v3(vec, ob_eval->object_to_world().location()); /* special case for camera -- snap to bundles */ if (ob_eval->type == OB_CAMERA) { @@ -1022,7 +1022,7 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) changed = BKE_mball_minmax_ex(static_cast(obedit->data), ob_min, ob_max, - obedit->object_to_world, + obedit->object_to_world().ptr(), SELECT); if (changed) { minmax_v3v3_v3(r_min, r_max, ob_min); @@ -1042,7 +1042,7 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) bke::crazyspace::get_evaluated_curves_deformation(obedit, ob_orig); const std::optional> curves_bounds = bounds_min_max_with_transform( - float4x4(obedit->object_to_world), deformation.positions, mask); + obedit->object_to_world(), deformation.positions, mask); if (curves_bounds) { minmax_v3v3_v3(r_min, r_max, curves_bounds->min); @@ -1060,13 +1060,13 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) return false; } - copy_m3_m4(bmat, obedit->object_to_world); + copy_m3_m4(bmat, obedit->object_to_world().ptr()); tv = tvs.transverts; for (int a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc); mul_m3_v3(bmat, vec); - add_v3_v3(vec, obedit->object_to_world[3]); + add_v3_v3(vec, obedit->object_to_world().location()); add_v3_v3(centroid, vec); minmax_v3v3_v3(r_min, r_max, vec); } diff --git a/source/blender/editors/space_view3d/view3d_utils.cc b/source/blender/editors/space_view3d/view3d_utils.cc index 2c14305540a..742487dd290 100644 --- a/source/blender/editors/space_view3d/view3d_utils.cc +++ b/source/blender/editors/space_view3d/view3d_utils.cc @@ -284,7 +284,7 @@ void ED_view3d_clipping_calc( /* optionally transform to object space */ if (ob) { float imat[4][4]; - invert_m4_m4(imat, ob->object_to_world); + invert_m4_m4(imat, ob->object_to_world().ptr()); for (int val = 0; val < 8; val++) { mul_m4_v3(imat, bb->vec[val]); @@ -294,7 +294,7 @@ void ED_view3d_clipping_calc( /* verify if we have negative scale. doing the transform before cross * product flips the sign of the vector compared to doing cross product * before transform then, so we correct for that. */ - int flip_sign = (ob) ? is_negative_m4(ob->object_to_world) : false; + int flip_sign = (ob) ? is_negative_m4(ob->object_to_world().ptr()) : false; ED_view3d_clipping_calc_from_boundbox(planes, bb, flip_sign); } @@ -472,7 +472,7 @@ void ED_view3d_persp_switch_from_camera(const Depsgraph *depsgraph, if (v3d->camera) { Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera); rv3d->dist = ED_view3d_offset_distance( - ob_camera_eval->object_to_world, rv3d->ofs, VIEW3D_DIST_FALLBACK); + ob_camera_eval->object_to_world().ptr(), rv3d->ofs, VIEW3D_DIST_FALLBACK); ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, nullptr); } @@ -564,7 +564,7 @@ void ED_view3d_camera_lock_init_ex(const Depsgraph *depsgraph, if (calc_dist) { /* using a fallback dist is OK here since ED_view3d_from_object() compensates for it */ rv3d->dist = ED_view3d_offset_distance( - ob_camera_eval->object_to_world, rv3d->ofs, VIEW3D_DIST_FALLBACK); + ob_camera_eval->object_to_world().ptr(), rv3d->ofs, VIEW3D_DIST_FALLBACK); } ED_view3d_from_object(ob_camera_eval, rv3d->ofs, rv3d->viewquat, &rv3d->dist, nullptr); } @@ -599,12 +599,12 @@ bool ED_view3d_camera_lock_sync(const Depsgraph *depsgraph, View3D *v3d, RegionV ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - normalize_m4_m4(tmat, ob_camera_eval->object_to_world); + normalize_m4_m4(tmat, ob_camera_eval->object_to_world().ptr()); invert_m4_m4(imat, tmat); mul_m4_m4m4(diff_mat, view_mat, imat); - mul_m4_m4m4(parent_mat, diff_mat, root_parent_eval->object_to_world); + mul_m4_m4m4(parent_mat, diff_mat, root_parent_eval->object_to_world().ptr()); BKE_object_tfm_protected_backup(root_parent, &obtfm); BKE_object_apply_mat4(root_parent, parent_mat, true, false); @@ -1579,7 +1579,7 @@ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], c void ED_view3d_from_object(const Object *ob, float ofs[3], float quat[4], float *dist, float *lens) { - ED_view3d_from_m4(ob->object_to_world, ofs, quat, dist); + ED_view3d_from_m4(ob->object_to_world().ptr(), ofs, quat, dist); if (lens) { CameraParams params; @@ -1628,7 +1628,7 @@ static bool view3d_camera_to_view_selected_impl(Main *bmain, is_ortho_camera = true; } - copy_m4_m4(obmat_new, camera_ob_eval->object_to_world); + copy_m4_m4(obmat_new, camera_ob_eval->object_to_world().ptr()); copy_v3_v3(obmat_new[3], co); /* only touch location */ diff --git a/source/blender/editors/space_view3d/view3d_view.cc b/source/blender/editors/space_view3d/view3d_view.cc index 9d34ca926d7..b9763e0e087 100644 --- a/source/blender/editors/space_view3d/view3d_view.cc +++ b/source/blender/editors/space_view3d/view3d_view.cc @@ -370,7 +370,7 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob) rv3d->view = RV3D_VIEW_USER; /* don't show the grid */ - normalize_m4_m4(bmat, ob->object_to_world); + normalize_m4_m4(bmat, ob->object_to_world().ptr()); invert_m4_m4(rv3d->viewmat, bmat); /* view quat calculation, needed for add object */ @@ -409,12 +409,12 @@ void view3d_viewmatrix_set(Depsgraph *depsgraph, Object *ob_eval = DEG_get_evaluated_object(depsgraph, v3d->ob_center); float vec[3]; - copy_v3_v3(vec, ob_eval->object_to_world[3]); + copy_v3_v3(vec, ob_eval->object_to_world().location()); if (ob_eval->type == OB_ARMATURE && v3d->ob_center_bone[0]) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob_eval->pose, v3d->ob_center_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); - mul_m4_v3(ob_eval->object_to_world, vec); + mul_m4_v3(ob_eval->object_to_world().ptr(), vec); } } translate_m4(rv3d->viewmat, -vec[0], -vec[1], -vec[2]); diff --git a/source/blender/editors/transform/transform.hh b/source/blender/editors/transform/transform.hh index 22b5a35f53c..dd496e1ca01 100644 --- a/source/blender/editors/transform/transform.hh +++ b/source/blender/editors/transform/transform.hh @@ -474,8 +474,8 @@ struct TransDataContainer { /** * Store matrix, this avoids having to have duplicate check all over - * Typically: 'obedit->object_to_world' or 'poseobj->object_to_world', but may be used elsewhere - * too. + * Typically: 'obedit->object_to_world().ptr()' or 'poseobj->object_to_world().ptr()', but may be + * used elsewhere too. */ bool use_local_mat; diff --git a/source/blender/editors/transform/transform_convert.cc b/source/blender/editors/transform/transform_convert.cc index 7c26541ad77..ad049113205 100644 --- a/source/blender/editors/transform/transform_convert.cc +++ b/source/blender/editors/transform/transform_convert.cc @@ -860,7 +860,7 @@ static void init_TransDataContainers(TransInfo *t, Object *obact, Span if (tc->use_local_mat) { BLI_assert((t->flag & T_2D_EDIT) == 0); - copy_m4_m4(tc->mat, objects[i]->object_to_world); + copy_m4_m4(tc->mat, objects[i]->object_to_world().ptr()); copy_m3_m4(tc->mat3, tc->mat); /* for non-invertible scale matrices, invert_m4_m4_fallback() * can still provide a valid pivot */ @@ -1113,8 +1113,8 @@ void transform_convert_clip_mirror_modifier_apply(TransDataContainer *tc) if (mmd->mirror_ob) { float obinv[4][4]; - invert_m4_m4(obinv, mmd->mirror_ob->object_to_world); - mul_m4_m4m4(mtx, obinv, ob->object_to_world); + invert_m4_m4(obinv, mmd->mirror_ob->object_to_world().ptr()); + mul_m4_m4m4(mtx, obinv, ob->object_to_world().ptr()); invert_m4_m4(imtx, mtx); } diff --git a/source/blender/editors/transform/transform_convert_armature.cc b/source/blender/editors/transform/transform_convert_armature.cc index d226e7b3861..e79ddb25d8d 100644 --- a/source/blender/editors/transform/transform_convert_armature.cc +++ b/source/blender/editors/transform/transform_convert_armature.cc @@ -436,7 +436,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->rotOrder = pchan->rotmode; /* proper way to get parent transform + own transform + constraints transform */ - copy_m3_m4(omat, ob->object_to_world); + copy_m3_m4(omat, ob->object_to_world().ptr()); /* New code, using "generic" BKE_bone_parent_transform_calc_from_pchan(). */ { @@ -800,7 +800,7 @@ static void createTransArmatureVerts(bContext * /*C*/, TransInfo *t) bool mirror = ((arm->flag & ARM_MIRROR_EDIT) != 0); BoneInitData *bid = static_cast(tc->custom.type.data); - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); td = tc->data = static_cast( diff --git a/source/blender/editors/transform/transform_convert_curve.cc b/source/blender/editors/transform/transform_convert_curve.cc index 4715ff0865b..27e9676be57 100644 --- a/source/blender/editors/transform/transform_convert_curve.cc +++ b/source/blender/editors/transform/transform_convert_curve.cc @@ -177,7 +177,7 @@ static void createTransCurveVerts(bContext * /*C*/, TransInfo *t) transform_mode_use_local_origins(t)); float mtx[3][3], smtx[3][3]; - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); TransData *td = tc->data; diff --git a/source/blender/editors/transform/transform_convert_curves.cc b/source/blender/editors/transform/transform_convert_curves.cc index 23c28562012..06916da105b 100644 --- a/source/blender/editors/transform/transform_convert_curves.cc +++ b/source/blender/editors/transform/transform_convert_curves.cc @@ -118,7 +118,7 @@ static void createTransCurvesVerts(bContext * /*C*/, TransInfo *t) curve_populate_trans_data_structs(tc, curves, - float4x4(object->object_to_world), + object->object_to_world(), value_attribute, selection_per_object[i], use_proportional_edit, diff --git a/source/blender/editors/transform/transform_convert_lattice.cc b/source/blender/editors/transform/transform_convert_lattice.cc index aa921c4b0b5..e0c232d2c7c 100644 --- a/source/blender/editors/transform/transform_convert_lattice.cc +++ b/source/blender/editors/transform/transform_convert_lattice.cc @@ -78,7 +78,7 @@ static void createTransLatticeVerts(bContext * /*C*/, TransInfo *t) tc->data = static_cast( MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)")); - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); td = tc->data; diff --git a/source/blender/editors/transform/transform_convert_mball.cc b/source/blender/editors/transform/transform_convert_mball.cc index ba692e15352..37cad7ad64d 100644 --- a/source/blender/editors/transform/transform_convert_mball.cc +++ b/source/blender/editors/transform/transform_convert_mball.cc @@ -65,7 +65,7 @@ static void createTransMBallVerts(bContext * /*C*/, TransInfo *t) tx = tc->data_ext = static_cast( MEM_callocN(tc->data_len * sizeof(TransDataExtension), "MetaElement_TransExtension")); - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { diff --git a/source/blender/editors/transform/transform_convert_mesh.cc b/source/blender/editors/transform/transform_convert_mesh.cc index a2fe2f1ec63..f095106159f 100644 --- a/source/blender/editors/transform/transform_convert_mesh.cc +++ b/source/blender/editors/transform/transform_convert_mesh.cc @@ -1566,7 +1566,7 @@ static void createTransEditVerts(bContext * /*C*/, TransInfo *t) em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data); } - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); /* we use a pseudo-inverse so that when one of the axes is scaled to 0, * matrix inversion still works and we can still moving along the other */ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_mesh_edge.cc b/source/blender/editors/transform/transform_convert_mesh_edge.cc index 411bf258a4e..74b16f44adc 100644 --- a/source/blender/editors/transform/transform_convert_mesh_edge.cc +++ b/source/blender/editors/transform/transform_convert_mesh_edge.cc @@ -62,7 +62,7 @@ static void createTransEdge(bContext * /*C*/, TransInfo *t) td = tc->data = static_cast( MEM_callocN(tc->data_len * sizeof(TransData), "TransCrease")); - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); /* create data we need */ diff --git a/source/blender/editors/transform/transform_convert_mesh_skin.cc b/source/blender/editors/transform/transform_convert_mesh_skin.cc index 046b76337d0..15d9963373d 100644 --- a/source/blender/editors/transform/transform_convert_mesh_skin.cc +++ b/source/blender/editors/transform/transform_convert_mesh_skin.cc @@ -127,7 +127,7 @@ static void createTransMeshSkin(bContext * /*C*/, TransInfo *t) em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data); } - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); /* we use a pseudo-inverse so that when one of the axes is scaled to 0, * matrix inversion still works and we can still moving along the other */ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc b/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc index ec91c64f57f..b46a1d969ad 100644 --- a/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc +++ b/source/blender/editors/transform/transform_convert_mesh_vert_cdata.cc @@ -122,7 +122,7 @@ static void createTransMeshVertCData(bContext * /*C*/, TransInfo *t) em, calc_single_islands, calc_island_center, calc_island_axismtx, &island_data); } - copy_m3_m4(mtx, tc->obedit->object_to_world); + copy_m3_m4(mtx, tc->obedit->object_to_world().ptr()); /* we use a pseudo-inverse so that when one of the axes is scaled to 0, * matrix inversion still works and we can still moving along the other */ pseudoinverse_m3_m3(smtx, mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_object.cc b/source/blender/editors/transform/transform_convert_object.cc index 139f1512f13..77239c982bb 100644 --- a/source/blender/editors/transform/transform_convert_object.cc +++ b/source/blender/editors/transform/transform_convert_object.cc @@ -158,14 +158,14 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) copy_qt_qt(td->ext->oquat, ob->quat); } /* update object's loc/rot to get current rigid body transform */ - mat4_to_loc_rot_size(ob->loc, rot, scale, ob->object_to_world); + mat4_to_loc_rot_size(ob->loc, rot, scale, ob->object_to_world().ptr()); sub_v3_v3(ob->loc, ob->dloc); BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */ } } /* axismtx has the real orientation */ - transform_orientations_create_from_axis(td->axismtx, UNPACK3(ob->object_to_world)); + transform_orientations_create_from_axis(td->axismtx, UNPACK3(ob->object_to_world().ptr())); if (t->orient_type_mask & (1 << V3D_ORIENT_GIMBAL)) { if (!gimbal_axis_object(ob, td->ext->axismtx_gimbal)) { copy_m3_m3(td->ext->axismtx_gimbal, td->axismtx); @@ -192,7 +192,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * More proper solution would be to make a shallow copy of the object and * evaluate that, and access matrix of that evaluated copy of the object. * Might be more tricky than it sounds, if some logic later on accesses the - * object matrix via td->ob->object_to_world. */ + * object matrix via td->ob->object_to_world().ptr(). */ Object *object_eval = DEG_get_evaluated_object(t->depsgraph, ob); if (skip_invert == false && constinv == false) { object_eval->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc checks this */ @@ -208,7 +208,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) } /* Copy newly evaluated fields to the original object, similar to how * active dependency graph will do it. */ - copy_m4_m4(ob->object_to_world, object_eval->object_to_world); + copy_m4_m4(ob->runtime->object_to_world.ptr(), object_eval->object_to_world().ptr()); /* Only copy negative scale flag, this is the only flag which is modified by * the BKE_object_where_is_calc(). The rest of the flags we need to keep, * otherwise we might lose dupli flags (see #61787). */ @@ -258,9 +258,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) copy_v3_v3(td->ext->isize, ob->scale); copy_v3_v3(td->ext->dscale, ob->dscale); - copy_v3_v3(td->center, ob->object_to_world[3]); + copy_v3_v3(td->center, ob->object_to_world().location()); - copy_m4_m4(td->ext->obmat, ob->object_to_world); + copy_m4_m4(td->ext->obmat, ob->object_to_world().ptr()); /* is there a need to set the global<->data space conversion matrices? */ if (ob->parent || constinv) { @@ -271,7 +271,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * done, as it doesn't work well. */ BKE_object_to_mat3(ob, obmtx); - copy_m3_m4(totmat, ob->object_to_world); + copy_m3_m4(totmat, ob->object_to_world().ptr()); /* If the object scale is zero on any axis, this might result in a zero matrix. * In this case, the transformation would not do anything, see: #50103. */ diff --git a/source/blender/editors/transform/transform_convert_object_texspace.cc b/source/blender/editors/transform/transform_convert_object_texspace.cc index d34f357613f..5142e07efac 100644 --- a/source/blender/editors/transform/transform_convert_object_texspace.cc +++ b/source/blender/editors/transform/transform_convert_object_texspace.cc @@ -68,8 +68,8 @@ static void createTransTexspace(bContext * /*C*/, TransInfo *t) td->flag = TD_SELECTED; td->ob = ob; - copy_m3_m4(td->mtx, ob->object_to_world); - copy_m3_m4(td->axismtx, ob->object_to_world); + copy_m3_m4(td->mtx, ob->object_to_world().ptr()); + copy_m3_m4(td->axismtx, ob->object_to_world().ptr()); normalize_m3(td->axismtx); pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON); diff --git a/source/blender/editors/transform/transform_convert_particle.cc b/source/blender/editors/transform/transform_convert_particle.cc index 7db5afdb4ae..3129cade2a4 100644 --- a/source/blender/editors/transform/transform_convert_particle.cc +++ b/source/blender/editors/transform/transform_convert_particle.cc @@ -15,6 +15,7 @@ #include "BLI_math_vector.h" #include "BKE_layer.hh" +#include "BKE_object_types.hh" #include "BKE_particle.h" #include "BKE_pointcache.h" @@ -97,7 +98,7 @@ static void createTransParticleVerts(bContext * /*C*/, TransInfo *t) unit_m4(mat); - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) { TransData *head, *tail; diff --git a/source/blender/editors/transform/transform_convert_sculpt.cc b/source/blender/editors/transform/transform_convert_sculpt.cc index 14baf58ce16..e6b3060071f 100644 --- a/source/blender/editors/transform/transform_convert_sculpt.cc +++ b/source/blender/editors/transform/transform_convert_sculpt.cc @@ -57,7 +57,7 @@ static void createTransSculpt(bContext *C, TransInfo *t) td->flag = TD_SELECTED; copy_v3_v3(td->center, ss->pivot_pos); - mul_m4_v3(ob->object_to_world, td->center); + mul_m4_v3(ob->object_to_world().ptr(), td->center); td->ob = ob; td->loc = ss->pivot_pos; @@ -68,16 +68,16 @@ static void createTransSculpt(bContext *C, TransInfo *t) } float obmat_inv[3][3]; - copy_m3_m4(obmat_inv, ob->object_to_world); + copy_m3_m4(obmat_inv, ob->object_to_world().ptr()); invert_m3(obmat_inv); td->ext->rot = nullptr; td->ext->rotAxis = nullptr; td->ext->rotAngle = nullptr; td->ext->quat = ss->pivot_rot; - copy_m4_m4(td->ext->obmat, ob->object_to_world); + copy_m4_m4(td->ext->obmat, ob->object_to_world().ptr()); copy_m3_m3(td->ext->l_smtx, obmat_inv); - copy_m3_m4(td->ext->r_mtx, ob->object_to_world); + copy_m3_m4(td->ext->r_mtx, ob->object_to_world().ptr()); copy_m3_m3(td->ext->r_smtx, obmat_inv); copy_qt_qt(td->ext->iquat, ss->pivot_rot); @@ -91,8 +91,8 @@ static void createTransSculpt(bContext *C, TransInfo *t) copy_v3_v3(td->ext->isize, ss->init_pivot_scale); copy_m3_m3(td->smtx, obmat_inv); - copy_m3_m4(td->mtx, ob->object_to_world); - copy_m3_m4(td->axismtx, ob->object_to_world); + copy_m3_m4(td->mtx, ob->object_to_world().ptr()); + copy_m3_m4(td->axismtx, ob->object_to_world().ptr()); BLI_assert(!(t->options & CTX_PAINT_CURVE)); ED_sculpt_init_transform(C, ob, t->mval, t->undo_name); diff --git a/source/blender/editors/transform/transform_generics.cc b/source/blender/editors/transform/transform_generics.cc index 5fb74452edf..05c7d0eb065 100644 --- a/source/blender/editors/transform/transform_generics.cc +++ b/source/blender/editors/transform/transform_generics.cc @@ -1093,7 +1093,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) } if (tc->obedit) { if (ED_object_calc_active_center_for_editmode(tc->obedit, select_only, r_center)) { - mul_m4_v3(tc->obedit->object_to_world, r_center); + mul_m4_v3(tc->obedit->object_to_world().ptr(), r_center); return true; } } @@ -1101,7 +1101,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) BKE_view_layer_synced_ensure(t->scene, t->view_layer); Object *ob = BKE_view_layer_active_object_get(t->view_layer); if (ED_object_calc_active_center_for_posemode(ob, select_only, r_center)) { - mul_m4_v3(ob->object_to_world, r_center); + mul_m4_v3(ob->object_to_world().ptr(), r_center); return true; } } @@ -1118,7 +1118,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) BKE_view_layer_synced_ensure(t->scene, t->view_layer); Base *base = BKE_view_layer_active_base_get(t->view_layer); if (base && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) { - copy_v3_v3(r_center, base->object->object_to_world[3]); + copy_v3_v3(r_center, base->object->object_to_world().location()); return true; } } diff --git a/source/blender/editors/transform/transform_gizmo_3d.cc b/source/blender/editors/transform/transform_gizmo_3d.cc index 01a997e299f..ed2597bbe43 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.cc +++ b/source/blender/editors/transform/transform_gizmo_3d.cc @@ -30,6 +30,7 @@ #include "BKE_grease_pencil.hh" #include "BKE_layer.hh" #include "BKE_object.hh" +#include "BKE_object_types.hh" #include "BKE_paint.hh" #include "BKE_pointcache.h" #include "BKE_scene.hh" @@ -606,7 +607,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, #define FOREACH_EDIT_OBJECT_BEGIN(ob_iter, use_mat_local) \ { \ - invert_m4_m4(obedit->world_to_object, obedit->object_to_world); \ + invert_m4_m4(obedit->runtime->world_to_object.ptr(), obedit->object_to_world().ptr()); \ Vector objects = BKE_view_layer_array_from_objects_in_edit_mode( \ scene, view_layer, CTX_wm_view3d(C)); \ for (Object * ob_iter : objects) { \ @@ -632,7 +633,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); + mul_m4_m4m4( + mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); } BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { @@ -652,7 +654,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); + mul_m4_m4m4( + mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); } LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { if (EBONE_VISIBLE(arm, ebo)) { @@ -691,7 +694,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); + mul_m4_m4m4( + mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); } Nurb *nu = static_cast(nurbs->first); @@ -751,7 +755,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); + mul_m4_m4m4( + mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); } LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { @@ -771,7 +776,8 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, obedit->world_to_object, ob_iter->object_to_world); + mul_m4_m4m4( + mat_local, obedit->world_to_object().ptr(), ob_iter->object_to_world().ptr()); } while (a--) { @@ -793,7 +799,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float4x4 mat_local; if (use_mat_local) { - mat_local = float4x4(obedit->world_to_object) * float4x4(ob_iter->object_to_world); + mat_local = obedit->world_to_object() * ob_iter->object_to_world(); } IndexMaskMemory memory; @@ -812,7 +818,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float4x4 mat_local; if (use_mat_local) { - mat_local = float4x4(obedit->world_to_object) * float4x4(ob_iter->object_to_world); + mat_local = obedit->world_to_object() * ob_iter->object_to_world(); } const Vector drawings = @@ -842,7 +848,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, #undef FOREACH_EDIT_OBJECT_END } else if (ob && (ob->mode & OB_MODE_POSE)) { - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); Vector objects = BKE_object_pose_array_get(scene, view_layer, v3d); @@ -855,7 +861,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, float mat_local[4][4]; if (use_mat_local) { - mul_m4_m4m4(mat_local, ob->world_to_object, ob_iter->object_to_world); + mul_m4_m4m4(mat_local, ob->world_to_object().ptr(), ob_iter->object_to_world().ptr()); } /* Use channels to get stats. */ @@ -879,7 +885,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { if (ob->mode & OB_MODE_SCULPT) { totsel = 1; - run_coord_with_matrix(ob->sculpt->pivot_pos, false, ob->object_to_world); + run_coord_with_matrix(ob->sculpt->pivot_pos, false, ob->object_to_world().ptr()); } } else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { @@ -934,12 +940,12 @@ static int gizmo_3d_foreach_selected(const bContext *C, } if (use_only_center || !bb) { - user_fn(base->object->object_to_world[3]); + user_fn(base->object->object_to_world().location()); } else { for (uint j = 0; j < 8; j++) { float co[3]; - mul_v3_m4v3(co, base->object->object_to_world, bb->vec[j]); + mul_v3_m4v3(co, base->object->object_to_world().ptr(), bb->vec[j]); user_fn(co); } } @@ -959,7 +965,7 @@ static int gizmo_3d_foreach_selected(const bContext *C, } if (r_mat && ob) { - *r_mat = ob->object_to_world; + *r_mat = ob->object_to_world().ptr(); } return totsel; @@ -1006,14 +1012,14 @@ int ED_transform_calc_gizmo_stats(const bContext *C, if (params->use_local_axis && (ob && ob->mode & (OB_MODE_EDIT | OB_MODE_POSE))) { float diff_mat[3][3]; - copy_m3_m4(diff_mat, ob->object_to_world); + copy_m3_m4(diff_mat, ob->object_to_world().ptr()); normalize_m3(diff_mat); invert_m3(diff_mat); mul_m3_m3_pre(tbounds->axis, diff_mat); normalize_m3(tbounds->axis); tbounds->use_matrix_space = true; - copy_m4_m4(tbounds->matrix_space, ob->object_to_world); + copy_m4_m4(tbounds->matrix_space, ob->object_to_world().ptr()); } const auto gizmo_3d_tbounds_calc_fn = [&](const float3 &co) { calc_tw_center(tbounds, co); }; @@ -1033,11 +1039,11 @@ int ED_transform_calc_gizmo_stats(const bContext *C, const bool is_gp_edit = GPENCIL_ANY_MODE(gpd); if (!is_gp_edit && (obedit || (ob && (ob->mode & (OB_MODE_POSE | OB_MODE_SCULPT))))) { if (ob->mode & OB_MODE_POSE) { - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); } - mul_m4_v3(ob->object_to_world, tbounds->center); - mul_m4_v3(ob->object_to_world, tbounds->min); - mul_m4_v3(ob->object_to_world, tbounds->max); + mul_m4_v3(ob->object_to_world().ptr(), tbounds->center); + mul_m4_v3(ob->object_to_world().ptr(), tbounds->min); + mul_m4_v3(ob->object_to_world().ptr(), tbounds->max); } } diff --git a/source/blender/editors/transform/transform_mode.cc b/source/blender/editors/transform/transform_mode.cc index a664f2202e0..02fafa27b2e 100644 --- a/source/blender/editors/transform/transform_mode.cc +++ b/source/blender/editors/transform/transform_mode.cc @@ -1064,7 +1064,7 @@ void ElementResize(const TransInfo *t, if (t->options & CTX_POSE_BONE) { /* Without this, the resulting location of scaled bones aren't correct, * especially noticeable scaling root or disconnected bones around the cursor, see #92515. */ - mul_mat3_m4_v3(tc->poseobj->object_to_world, vec); + mul_mat3_m4_v3(tc->poseobj->object_to_world().ptr(), vec); } mul_m3_v3(td->smtx, vec); } diff --git a/source/blender/editors/transform/transform_mode_edge_slide.cc b/source/blender/editors/transform/transform_mode_edge_slide.cc index 895b416c00a..a5ffa431660 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.cc +++ b/source/blender/editors/transform/transform_mode_edge_slide.cc @@ -1134,7 +1134,7 @@ static void drawEdgeSlide(TransInfo *t) GPU_blend(GPU_BLEND_ALPHA); GPU_matrix_push(); - GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr()); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); diff --git a/source/blender/editors/transform/transform_mode_vert_slide.cc b/source/blender/editors/transform/transform_mode_vert_slide.cc index fb937de7129..f6d8081fb17 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.cc +++ b/source/blender/editors/transform/transform_mode_vert_slide.cc @@ -14,6 +14,7 @@ #include "BLI_string.h" #include "BKE_editmesh.hh" +#include "BKE_object_types.hh" #include "BKE_unit.hh" #include "GPU_immediate.h" @@ -165,7 +166,7 @@ static void calcVertSlideMouseActiveEdges(TransInfo *t, const float2 &mval_fl) float dir_dot; sub_v3_v3v3(tdir, sv->co_orig_3d, sv->co_link_orig_3d[j]); - mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world, tdir); + mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr(), tdir); project_plane_v3_v3v3(tdir, tdir, t->viewinv[2]); normalize_v3(tdir); @@ -368,7 +369,7 @@ static void drawVertSlide(TransInfo *t) GPU_blend(GPU_BLEND_ALPHA); GPU_matrix_push(); - GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world); + GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr()); GPU_line_width(line_size); @@ -422,16 +423,17 @@ static void drawVertSlide(TransInfo *t) float2 xy_delta = t->mval - t->mouse.imval; mul_v3_m4v3(co_orig_3d, - TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world, + TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr(), curr_sv->co_orig_3d); zfac = ED_view3d_calc_zfac(static_cast(t->region->regiondata), co_orig_3d); ED_view3d_win_to_delta(t->region, xy_delta, zfac, co_dest_3d); - invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->world_to_object, - TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world); - mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->world_to_object, co_dest_3d); + invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->runtime->world_to_object.ptr(), + TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->object_to_world().ptr()); + mul_mat3_m4_v3(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->world_to_object().ptr(), + co_dest_3d); add_v3_v3(co_dest_3d, curr_sv->co_orig_3d); diff --git a/source/blender/editors/transform/transform_orientations.cc b/source/blender/editors/transform/transform_orientations.cc index 3f767f7a71e..e3353a3105d 100644 --- a/source/blender/editors/transform/transform_orientations.cc +++ b/source/blender/editors/transform/transform_orientations.cc @@ -134,7 +134,7 @@ static TransformOrientation *createObjectSpace(bContext *C, ob = base->object; - copy_m3_m4(mat, ob->object_to_world); + copy_m3_m4(mat, ob->object_to_world().ptr()); normalize_m3(mat); /* use object name if no name is given */ @@ -299,12 +299,12 @@ bool gimbal_axis_pose(Object *ob, const bPoseChannel *pchan, float gmat[3][3]) mul_m3_m3m3(mat, parent_mat, tmat); /* needed if object transformation isn't identity */ - copy_m3_m4(obmat, ob->object_to_world); + copy_m3_m4(obmat, ob->object_to_world().ptr()); mul_m3_m3m3(gmat, obmat, mat); } else { /* needed if object transformation isn't identity */ - copy_m3_m4(obmat, ob->object_to_world); + copy_m3_m4(obmat, ob->object_to_world().ptr()); mul_m3_m3m3(gmat, obmat, tmat); } @@ -326,7 +326,7 @@ bool gimbal_axis_object(Object *ob, float gmat[3][3]) if (ob->parent) { float parent_mat[3][3]; - copy_m3_m4(parent_mat, ob->parent->object_to_world); + copy_m3_m4(parent_mat, ob->parent->object_to_world().ptr()); normalize_m3(parent_mat); mul_m3_m3m3(gmat, parent_mat, gmat); } @@ -597,20 +597,21 @@ static void handle_armature_parent_orientation(Object *ob, float r_mat[3][3]) /* For child, show parent local regardless if "local location" is set for parent bone. */ transform_orientations_create_from_axis(r_mat, UNPACK3(active_pchan->parent->pose_mat)); float ob_orientations_mat[3][3]; - transform_orientations_create_from_axis(ob_orientations_mat, UNPACK3(ob->object_to_world)); + transform_orientations_create_from_axis(ob_orientations_mat, + UNPACK3(ob->object_to_world().ptr())); mul_m3_m3_pre(r_mat, ob_orientations_mat); return; } /* For root, use local transform of armature object. */ - transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world)); + transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world().ptr())); } static void handle_object_parent_orientation(Object *ob, float r_mat[3][3]) { /* If object has parent, then orient to parent. */ if (ob->parent) { - transform_orientations_create_from_axis(r_mat, UNPACK3(ob->parent->object_to_world)); + transform_orientations_create_from_axis(r_mat, UNPACK3(ob->parent->object_to_world().ptr())); } else { /* If object doesn't have parent, then orient to world. */ @@ -677,7 +678,7 @@ short ED_transform_calc_orientation_from_type_ex(const Scene *scene, ED_getTransformOrientationMatrix(scene, view_layer, v3d, ob, obedit, pivot_point, r_mat); } else { - transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world)); + transform_orientations_create_from_axis(r_mat, UNPACK3(ob->object_to_world().ptr())); } break; } @@ -910,7 +911,7 @@ int getTransformOrientation_ex(const Scene *scene, float imat[3][3], mat[3][3]; /* we need the transpose of the inverse for a normal... */ - copy_m3_m4(imat, ob->object_to_world); + copy_m3_m4(imat, ob->object_to_world().ptr()); invert_m3_m3(mat, imat); transpose_m3(mat); @@ -1340,8 +1341,8 @@ int getTransformOrientation_ex(const Scene *scene, if (result == ORIENTATION_EDGE) { float tvec[3]; - mul_mat3_m4_v3(ob->object_to_world, normal); - mul_mat3_m4_v3(ob->object_to_world, plane); + mul_mat3_m4_v3(ob->object_to_world().ptr(), normal); + mul_mat3_m4_v3(ob->object_to_world().ptr(), plane); /* align normal to edge direction (so normal is perpendicular to the plane). * 'ORIENTATION_EDGE' will do the other way around. @@ -1383,7 +1384,7 @@ int getTransformOrientation_ex(const Scene *scene, /* use for both active & all */ if (ok) { /* we need the transpose of the inverse for a normal... */ - copy_m3_m4(imat, ob->object_to_world); + copy_m3_m4(imat, ob->object_to_world().ptr()); invert_m3_m3(mat, imat); transpose_m3(mat); @@ -1415,8 +1416,8 @@ int getTransformOrientation_ex(const Scene *scene, } if (ok) { - copy_v3_v3(normal, ob->object_to_world[2]); - copy_v3_v3(plane, ob->object_to_world[1]); + copy_v3_v3(normal, ob->object_to_world().ptr()[2]); + copy_v3_v3(plane, ob->object_to_world().ptr()[1]); } } result = ORIENTATION_NORMAL; diff --git a/source/blender/editors/transform/transform_snap.cc b/source/blender/editors/transform/transform_snap.cc index a2a7a38b61e..534bc6b90f4 100644 --- a/source/blender/editors/transform/transform_snap.cc +++ b/source/blender/editors/transform/transform_snap.cc @@ -395,7 +395,7 @@ static bool applyFaceProject(TransInfo *t, TransDataContainer *tc, TransData *td } else if (t->options & CTX_OBJECT) { BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob); - copy_v3_v3(iloc, td->ob->object_to_world[3]); + copy_v3_v3(iloc, td->ob->object_to_world().location()); } if (ED_view3d_project_float_global(t->region, iloc, mval_fl, V3D_PROJ_TEST_NOP) != @@ -464,7 +464,7 @@ static void applyFaceNearest(TransInfo *t, TransDataContainer *tc, TransData *td } else if (t->options & CTX_OBJECT) { BKE_object_eval_transform_all(t->depsgraph, t->scene, td->ob); - copy_v3_v3(init_loc, td->ob->object_to_world[3]); + copy_v3_v3(init_loc, td->ob->object_to_world().location()); } SnapObjectParams snap_object_params{}; diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 4a8bb1aebc4..afb4fc53a6a 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -513,12 +513,9 @@ static eSnapMode iter_snap_objects(SnapObjectContext *sctx, IterSnapObjsCallback bool use_hide = false; ID *ob_data = data_for_snap(obj_eval, sctx->runtime.params.edit_mode_type, &use_hide); - if ((tmp = sob_callback(sctx, - obj_eval, - ob_data, - float4x4(obj_eval->object_to_world), - is_object_active, - use_hide)) != SCE_SNAP_TO_NONE) + if ((tmp = sob_callback( + sctx, obj_eval, ob_data, obj_eval->object_to_world(), is_object_active, use_hide)) != + SCE_SNAP_TO_NONE) { ret = tmp; } diff --git a/source/blender/editors/uvedit/uvedit_select.cc b/source/blender/editors/uvedit/uvedit_select.cc index 07cf317ff2d..20091ab5cd1 100644 --- a/source/blender/editors/uvedit/uvedit_select.cc +++ b/source/blender/editors/uvedit/uvedit_select.cc @@ -4712,7 +4712,7 @@ static int uv_select_similar_vert_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); BMFace *face; BMIter iter; @@ -4748,7 +4748,7 @@ static int uv_select_similar_vert_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); BMFace *face; BMIter iter; @@ -4819,7 +4819,7 @@ static int uv_select_similar_edge_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); BMFace *face; BMIter iter; @@ -4857,7 +4857,7 @@ static int uv_select_similar_edge_exec(bContext *C, wmOperator *op) bool changed = false; const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); BMFace *face; BMIter iter; @@ -4919,7 +4919,7 @@ static int uv_select_similar_face_exec(bContext *C, wmOperator *op) BMesh *bm = em->bm; float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); @@ -4954,7 +4954,7 @@ static int uv_select_similar_face_exec(bContext *C, wmOperator *op) const BMUVOffsets offsets = BM_uv_map_get_offsets(bm); float ob_m3[3][3]; - copy_m3_m4(ob_m3, ob->object_to_world); + copy_m3_m4(ob_m3, ob->object_to_world().ptr()); BMFace *face; BMIter iter; @@ -5037,7 +5037,7 @@ static int uv_select_similar_island_exec(bContext *C, wmOperator *op) } float ob_m3[3][3]; - copy_m3_m4(ob_m3, obedit->object_to_world); + copy_m3_m4(ob_m3, obedit->object_to_world().ptr()); int index; LISTBASE_FOREACH_INDEX (FaceIsland *, island, &island_list_ptr[ob_index], index) { @@ -5066,7 +5066,7 @@ static int uv_select_similar_island_exec(bContext *C, wmOperator *op) continue; } float ob_m3[3][3]; - copy_m3_m4(ob_m3, obedit->object_to_world); + copy_m3_m4(ob_m3, obedit->object_to_world().ptr()); bool changed = false; int index; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc index 201a214fca5..3fa81d9042a 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc @@ -41,6 +41,7 @@ #include "BKE_layer.hh" #include "BKE_lib_id.hh" #include "BKE_mesh.hh" +#include "BKE_object_types.hh" #include "BKE_report.hh" #include "BKE_subdiv.hh" #include "BKE_subdiv_mesh.hh" @@ -1931,8 +1932,8 @@ static void uv_map_transform_center(const Scene *scene, } case V3D_AROUND_CURSOR: /* cursor center */ { - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_v3_m4v3(r_center, ob->world_to_object, scene->cursor.location); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_v3_m4v3(r_center, ob->world_to_object().ptr(), scene->cursor.location); break; } case V3D_AROUND_ACTIVE: { @@ -1982,7 +1983,7 @@ static void uv_map_rotation_matrix_ex(float result[4][4], zero_v3(viewmatrix[3]); /* get rotation of the current object matrix */ - copy_m4_m4(rotobj, ob->object_to_world); + copy_m4_m4(rotobj, ob->object_to_world().ptr()); zero_v3(rotobj[3]); /* but shifting */ @@ -2473,7 +2474,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) continue; } - mat4_to_size(obsize, obedit->object_to_world); + mat4_to_size(obsize, obedit->object_to_world().ptr()); if (!(fabsf(obsize[0] - obsize[1]) < 1e-4f && fabsf(obsize[1] - obsize[2]) < 1e-4f)) { if ((reported_errors & UNWRAP_ERROR_NONUNIFORM) == 0) { BKE_report(op->reports, @@ -2483,7 +2484,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) reported_errors |= UNWRAP_ERROR_NONUNIFORM; } } - else if (is_negative_m4(obedit->object_to_world)) { + else if (is_negative_m4(obedit->object_to_world().ptr())) { if ((reported_errors & UNWRAP_ERROR_NEGATIVE) == 0) { BKE_report( op->reports, @@ -3050,7 +3051,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) float objects_pos_avg[4] = {0}; for (Object *object : objects) { - add_v4_v4(objects_pos_avg, object->object_to_world[3]); + add_v4_v4(objects_pos_avg, object->object_to_world().location()); } mul_v4_fl(objects_pos_avg, 1.0f / objects.size()); @@ -3089,7 +3090,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) const bool camera_bounds = RNA_boolean_get(op->ptr, "camera_bounds"); ProjCameraInfo *uci = BLI_uvproject_camera_info( v3d->camera, - obedit->object_to_world, + obedit->object_to_world().ptr(), camera_bounds ? (scene->r.xsch * scene->r.xasp) : 1.0f, camera_bounds ? (scene->r.ysch * scene->r.yasp) : 1.0f); @@ -3110,7 +3111,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) } } else { - copy_m4_m4(rotmat, obedit->object_to_world); + copy_m4_m4(rotmat, obedit->object_to_world().ptr()); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 429d010d776..6079d410619 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -444,7 +444,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id) // Compute matrix including camera transform float obmat[4][4], nmat[4][4]; - mul_m4_m4m4(obmat, viewmat, ob->object_to_world); + mul_m4_m4m4(obmat, viewmat, ob->object_to_world().ptr()); invert_m4_m4(nmat, obmat); transpose_m4(nmat); diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index 4ef9974573d..ca060082ef9 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -470,8 +470,7 @@ static void foreach_geometry_in_reference( int index = 0; FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (&collection, object) { const bke::GeometrySet object_geometry = bke::object_get_evaluated_geometry_set(*object); - const float4x4 matrix = base_transform * offset_matrix * - float4x4_view(object->object_to_world); + const float4x4 matrix = base_transform * offset_matrix * object->object_to_world(); const int sub_id = noise::hash(id, index); fn(object_geometry, matrix, sub_id); index++; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc index a0448114750..06937979d59 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_array.cc @@ -102,9 +102,9 @@ static void BKE_gpencil_instance_modifier_instance_tfm(Object *ob, if (mmd->flag & GP_ARRAY_USE_OFFSET) { add_v3_v3(mat_offset[3], mmd->offset); } - invert_m4_m4(obinv, ob->object_to_world); + invert_m4_m4(obinv, ob->object_to_world().ptr()); - mul_m4_series(r_offset, mat_offset, obinv, mmd->object->object_to_world); + mul_m4_series(r_offset, mat_offset, obinv, mmd->object->object_to_world().ptr()); copy_m4_m4(mat_offset, r_offset); /* clear r_mat locations to avoid double transform */ diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc index 3855cebc5f0..797059210e4 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc @@ -318,8 +318,8 @@ static void build_sequential(Object *ob, /* Compute distance to control object if set, and build according to that order. */ if (mmd->object) { float sv1[3], sv2[3]; - mul_v3_m4v3(sv1, ob->object_to_world, &gps->points[0].x); - mul_v3_m4v3(sv2, ob->object_to_world, &gps->points[gps->totpoints - 1].x); + mul_v3_m4v3(sv1, ob->object_to_world().ptr(), &gps->points[0].x); + mul_v3_m4v3(sv2, ob->object_to_world().ptr(), &gps->points[gps->totpoints - 1].x); float dist_l = len_v3v3(sv1, mmd->object->loc); float dist_r = len_v3v3(sv2, mmd->object->loc); if (dist_r < dist_l) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc index c10703643e0..582c9cd6b72 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_hook.cc @@ -31,6 +31,7 @@ #include "BKE_gpencil_modifier_legacy.h" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_object_types.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -227,14 +228,14 @@ static void deform_stroke(GpencilModifierData *md, /* get world-space matrix of target, corrected for the space the verts are in */ if (mmd->subtarget[0] && pchan) { /* bone target if there's a matching pose-channel */ - mul_m4_m4m4(dmat, mmd->object->object_to_world, pchan->pose_mat); + mul_m4_m4m4(dmat, mmd->object->object_to_world().ptr(), pchan->pose_mat); } else { /* just object target */ - copy_m4_m4(dmat, mmd->object->object_to_world); + copy_m4_m4(dmat, mmd->object->object_to_world().ptr()); } - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_series(tData.mat, ob->world_to_object, dmat, mmd->parentinv); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_series(tData.mat, ob->world_to_object().ptr(), dmat, mmd->parentinv); /* loop points and apply deform */ for (int i = 0; i < gps->totpoints; i++) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc index 092c50ca341..bd4ce1bb6e1 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_mirror.cc @@ -79,8 +79,8 @@ static void update_mirror_object(Object *ob, float tmp[4][4]; float itmp[4][4]; - invert_m4_m4(tmp, mmd->object->object_to_world); - mul_m4_m4m4(tmp, tmp, ob->object_to_world); + invert_m4_m4(tmp, mmd->object->object_to_world().ptr()); + mul_m4_m4m4(tmp, tmp, ob->object_to_world().ptr()); invert_m4_m4(itmp, tmp); mul_m4_series(mtx, itmp, mtx, tmp); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc index a3594e73da8..d254a430922 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_multiply.cc @@ -106,7 +106,7 @@ static void duplicateStroke(Object *ob, float opacity_factor; /* Apply object scale to offset distance. */ - offset *= mat4_to_scale(ob->object_to_world); + offset *= mat4_to_scale(ob->object_to_world().ptr()); BKE_gpencil_stroke_normal(gps, stroke_normal); if (len_v3(stroke_normal) < FLT_EPSILON) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc index 96ef211dd17..93e35fcb068 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_outline.cc @@ -116,7 +116,7 @@ static void convert_stroke(GpencilModifierData *md, /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world); + gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world().ptr()); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Stroke. */ @@ -197,7 +197,7 @@ static void generate_strokes(GpencilModifierData *md, Depsgraph *depsgraph, Obje } Object *cam_ob = scene->camera; float viewmat[4][4]; - invert_m4_m4(viewmat, cam_ob->object_to_world); + invert_m4_m4(viewmat, cam_ob->object_to_world().ptr()); LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { bGPDframe *gpf = BKE_gpencil_frame_retime_get(depsgraph, scene, ob, gpl); @@ -240,7 +240,7 @@ static void bake_modifier(Main * /*bmain*/, BKE_scene_graph_update_for_newframe(depsgraph); /* Ensure the camera is the right one. */ BKE_scene_camera_switch_update(scene); - invert_m4_m4(viewmat, cam_ob->object_to_world); + invert_m4_m4(viewmat, cam_ob->object_to_world().ptr()); /* Prepare transform matrix. */ float diff_mat[4][4]; diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc index b0734ad522e..01e8c34b164 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_tint.cc @@ -139,7 +139,7 @@ static void deform_stroke(GpencilModifierData *md, float coba_res[4]; float matrix[4][4]; if (is_gradient) { - mul_m4_m4m4(matrix, mmd->object->world_to_object, ob->object_to_world); + mul_m4_m4m4(matrix, mmd->object->world_to_object().ptr(), ob->object_to_world().ptr()); } /* loop points and apply color. */ diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc index 565fbbf3f6b..3de6bed8ef6 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_angle.cc @@ -93,7 +93,7 @@ static void deform_stroke(GpencilModifierData *md, /* Apply the rotation of the object. */ if (mmd->space == GP_SPACE_LOCAL) { - mul_mat3_m4_v3(ob->object_to_world, vec_ref); + mul_mat3_m4_v3(ob->object_to_world().ptr(), vec_ref); } /* Ensure there is a vertex group. */ @@ -118,8 +118,8 @@ static void deform_stroke(GpencilModifierData *md, bGPDspoint *pt1 = (i > 0) ? &gps->points[i] : &gps->points[i + 1]; bGPDspoint *pt2 = (i > 0) ? &gps->points[i - 1] : &gps->points[i]; float fpt1[3], fpt2[3]; - mul_v3_m4v3(fpt1, ob->object_to_world, &pt1->x); - mul_v3_m4v3(fpt2, ob->object_to_world, &pt2->x); + mul_v3_m4v3(fpt1, ob->object_to_world().ptr(), &pt1->x); + mul_v3_m4v3(fpt2, ob->object_to_world().ptr(), &pt2->x); float vec[3]; sub_v3_v3v3(vec, fpt1, fpt2); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc index edd60a3972d..4e5ad0db6d1 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc @@ -60,8 +60,8 @@ static float calc_point_weight_by_distance(Object *ob, { float weight; float gvert[3]; - mul_v3_m4v3(gvert, ob->object_to_world, &pt->x); - float dist = len_v3v3(mmd->object->object_to_world[3], gvert); + mul_v3_m4v3(gvert, ob->object_to_world().ptr(), &pt->x); + float dist = len_v3v3(mmd->object->object_to_world().location(), gvert); if (dist > dist_max) { weight = 1.0f; diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc index 92bf9522d10..e3ded88fecf 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc @@ -2454,7 +2454,7 @@ static void lineart_object_load_single_instance(LineartData *ld, Scene *scene, Object *ob, Object *ref_ob, - float use_mat[4][4], + const float use_mat[4][4], bool is_render, LineartObjectLoadTaskInfo *olti, int thread_count, @@ -2616,7 +2616,7 @@ void lineart_main_load_geometries(Depsgraph *depsgraph, scene, eval_ob, eval_ob, - eval_ob->object_to_world, + eval_ob->object_to_world().ptr(), is_render, olti, thread_count, @@ -3592,11 +3592,11 @@ static LineartData *lineart_create_render_buffer(Scene *scene, clipping_offset = 0.0001; } - copy_v3db_v3fl(ld->conf.camera_pos, camera->object_to_world[3]); + copy_v3db_v3fl(ld->conf.camera_pos, camera->object_to_world().location()); if (active_camera) { - copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->object_to_world[3]); + copy_v3db_v3fl(ld->conf.active_camera_pos, active_camera->object_to_world().location()); } - copy_m4_m4(ld->conf.cam_obmat, camera->object_to_world); + copy_m4_m4(ld->conf.cam_obmat, camera->object_to_world().ptr()); /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and * lights. */ normalize_v3(ld->conf.cam_obmat[0]); @@ -3628,8 +3628,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, if (lmd->light_contour_object) { Object *light_obj = lmd->light_contour_object; - copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->object_to_world[3]); - copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->object_to_world); + copy_v3db_v3fl(ld->conf.camera_pos_secondary, light_obj->object_to_world().location()); + copy_m4_m4(ld->conf.cam_obmat_secondary, light_obj->object_to_world().ptr()); /* Make sure none of the scaling factor makes in, line art expects no scaling on cameras and * lights. */ normalize_v3(ld->conf.cam_obmat_secondary[0]); @@ -5458,7 +5458,7 @@ void MOD_lineart_gpencil_generate(LineartCache *cache, } float gp_obmat_inverse[4][4]; - invert_m4_m4(gp_obmat_inverse, ob->object_to_world); + invert_m4_m4(gp_obmat_inverse, ob->object_to_world().ptr()); lineart_gpencil_generate(cache, depsgraph, ob, diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc index c7641bb52f8..99d63d3aa18 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc @@ -1175,7 +1175,7 @@ bool lineart_main_try_generate_shadow(Depsgraph *depsgraph, copy_v3_v3_db(ld->conf.camera_pos_secondary, ld->conf.camera_pos); copy_m4_m4(ld->conf.cam_obmat_secondary, ld->conf.cam_obmat); - copy_m4_m4(ld->conf.cam_obmat, lmd->light_contour_object->object_to_world); + copy_m4_m4(ld->conf.cam_obmat, lmd->light_contour_object->object_to_world().ptr()); copy_v3db_v3fl(ld->conf.camera_pos, ld->conf.cam_obmat[3]); ld->conf.cam_is_persp_secondary = ld->conf.cam_is_persp; ld->conf.cam_is_persp = is_persp; diff --git a/source/blender/ikplugin/intern/iksolver_plugin.cc b/source/blender/ikplugin/intern/iksolver_plugin.cc index 4a658cffa62..a490a8391a0 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.cc +++ b/source/blender/ikplugin/intern/iksolver_plugin.cc @@ -428,7 +428,7 @@ static void execute_posetree(Depsgraph *depsgraph, Scene *scene, Object *ob, Pos } copy_v3_v3(rootmat[3], pchan->pose_head); - mul_m4_m4m4(imat, ob->object_to_world, rootmat); + mul_m4_m4m4(imat, ob->object_to_world().ptr(), rootmat); invert_m4_m4(goalinv, imat); LISTBASE_FOREACH (PoseTarget *, target, &tree->targets) { @@ -487,7 +487,7 @@ static void execute_posetree(Depsgraph *depsgraph, Scene *scene, Object *ob, Pos /* end effector in world space */ copy_m4_m4(end_pose, pchan->pose_mat); copy_v3_v3(end_pose[3], pchan->pose_tail); - mul_m4_series(world_pose, goalinv, ob->object_to_world, end_pose); + mul_m4_series(world_pose, goalinv, ob->object_to_world().ptr(), end_pose); /* blend position */ goalpos[0] = fac * goalpos[0] + mfac * world_pose[3][0]; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cc b/source/blender/ikplugin/intern/itasc_plugin.cc index c61408d6586..89217f2134b 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cc +++ b/source/blender/ikplugin/intern/itasc_plugin.cc @@ -589,10 +589,10 @@ static bool target_callback(const iTaSC::Timestamp ×tamp, float chanmat[4][4]; copy_m4_m4(chanmat, pchan->pose_mat); copy_v3_v3(chanmat[3], pchan->pose_tail); - mul_m4_series(restmat, target->owner->object_to_world, chanmat, target->eeRest); + mul_m4_series(restmat, target->owner->object_to_world().ptr(), chanmat, target->eeRest); } else { - mul_m4_m4m4(restmat, target->owner->object_to_world, target->eeRest); + mul_m4_m4m4(restmat, target->owner->object_to_world().ptr(), target->eeRest); } /* blend the target */ blend_m4_m4m4(tarmat, restmat, tarmat, constraint->enforce); @@ -623,10 +623,10 @@ static bool base_callback(const iTaSC::Timestamp ×tamp, ikscene->baseFrame.setValue(&chanmat[0][0]); /* iTaSC armature is scaled to object scale, scale the base frame too */ ikscene->baseFrame.p *= ikscene->blScale; - mul_m4_m4m4(rootmat, ikscene->blArmature->object_to_world, chanmat); + mul_m4_m4m4(rootmat, ikscene->blArmature->object_to_world().ptr(), chanmat); } else { - copy_m4_m4(rootmat, ikscene->blArmature->object_to_world); + copy_m4_m4(rootmat, ikscene->blArmature->object_to_world().ptr()); ikscene->baseFrame = iTaSC::F_identity; } next.setValue(&rootmat[0][0]); @@ -1068,7 +1068,7 @@ static void convert_pose(IK_Scene *ikscene) int a, joint; /* assume uniform scaling and take Y scale as general scale for the armature */ - scale = len_v3(ikscene->blArmature->object_to_world[1]); + scale = len_v3(ikscene->blArmature->object_to_world().ptr()[1]); rot = ikscene->jointArray(0); for (joint = a = 0, ikchan = ikscene->channels; a < ikscene->numchan && joint < ikscene->numjoint; @@ -1109,7 +1109,7 @@ static void BKE_pose_rest(IK_Scene *ikscene) int a, joint; /* assume uniform scaling and take Y scale as general scale for the armature */ - scale = len_v3(ikscene->blArmature->object_to_world[1]); + scale = len_v3(ikscene->blArmature->object_to_world().ptr()[1]); /* rest pose is 0 */ SetToZero(ikscene->jointArray); /* except for transY joints */ @@ -1188,7 +1188,7 @@ static IK_Scene *convert_tree( } ikscene->blArmature = ob; /* assume uniform scaling and take Y scale as general scale for the armature */ - ikscene->blScale = len_v3(ob->object_to_world[1]); + ikscene->blScale = len_v3(ob->object_to_world().ptr()[1]); ikscene->blInvScale = (ikscene->blScale < KDL::epsilon) ? 0.0f : 1.0f / ikscene->blScale; std::string joint; @@ -1676,7 +1676,7 @@ static void create_scene(Depsgraph *depsgraph, Scene *scene, Object *ob, float c static int init_scene(Object *ob) { /* check also if scaling has changed */ - float scale = len_v3(ob->object_to_world[1]); + float scale = len_v3(ob->object_to_world().ptr()[1]); IK_Scene *scene; if (ob->pose->ikdata) { diff --git a/source/blender/io/alembic/exporter/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc index 1e2ee7109d6..12219898277 100644 --- a/source/blender/io/alembic/exporter/abc_writer_hair.cc +++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc @@ -127,7 +127,7 @@ void ABCHairWriter::write_hair_sample(const HierarchyContext &context, { /* Get untransformed vertices, there's a xform under the hair. */ float inv_mat[4][4]; - invert_m4_m4_safe(inv_mat, context.object->object_to_world); + invert_m4_m4_safe(inv_mat, context.object->object_to_world().ptr()); MTFace *mtface = (MTFace *)CustomData_get_layer_for_write( &mesh->fdata_legacy, CD_MTFACE, mesh->totface_legacy); @@ -252,7 +252,7 @@ void ABCHairWriter::write_hair_child_sample(const HierarchyContext &context, { /* Get untransformed vertices, there's a xform under the hair. */ float inv_mat[4][4]; - invert_m4_m4_safe(inv_mat, context.object->object_to_world); + invert_m4_m4_safe(inv_mat, context.object->object_to_world().ptr()); const MFace *mface = (const MFace *)CustomData_get_layer(&mesh->fdata_legacy, CD_MFACE); MTFace *mtface = (MTFace *)CustomData_get_layer_for_write( diff --git a/source/blender/io/alembic/exporter/abc_writer_points.cc b/source/blender/io/alembic/exporter/abc_writer_points.cc index 6d974ace7bf..fca1bd78274 100644 --- a/source/blender/io/alembic/exporter/abc_writer_points.cc +++ b/source/blender/io/alembic/exporter/abc_writer_points.cc @@ -101,7 +101,7 @@ void ABCPointsWriter::do_write(HierarchyContext &context) } /* location */ - mul_v3_m4v3(pos, context.object->world_to_object, state.co); + mul_v3_m4v3(pos, context.object->world_to_object().ptr(), state.co); /* velocity */ sub_v3_v3v3(vel, state.co, psys->particles[p].prev_state.co); diff --git a/source/blender/io/alembic/intern/abc_axis_conversion.cc b/source/blender/io/alembic/intern/abc_axis_conversion.cc index e2be5b20632..3970f14f27b 100644 --- a/source/blender/io/alembic/intern/abc_axis_conversion.cc +++ b/source/blender/io/alembic/intern/abc_axis_conversion.cc @@ -14,6 +14,8 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "BKE_object_types.hh" + #include "DNA_object_types.h" namespace blender::io::alembic { @@ -139,15 +141,16 @@ void create_transform_matrix(Object *obj, if (mode == ABC_MATRIX_LOCAL && obj->parent) { /* Note that this produces another matrix than the local matrix, due to * constraints and modifiers as well as the obj->parentinv matrix. */ - invert_m4_m4(obj->parent->world_to_object, obj->parent->object_to_world); - mul_m4_m4m4(zup_mat, obj->parent->world_to_object, obj->object_to_world); + invert_m4_m4(obj->parent->runtime->world_to_object.ptr(), + obj->parent->object_to_world().ptr()); + mul_m4_m4m4(zup_mat, obj->parent->world_to_object().ptr(), obj->object_to_world().ptr()); } else { - copy_m4_m4(zup_mat, obj->object_to_world); + copy_m4_m4(zup_mat, obj->object_to_world().ptr()); } if (proxy_from) { - mul_m4_m4m4(zup_mat, proxy_from->object_to_world, zup_mat); + mul_m4_m4m4(zup_mat, proxy_from->object_to_world().ptr(), zup_mat); } copy_m44_axis_swap(r_yup_mat, zup_mat, ABC_YUP_FROM_ZUP); diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index 2aa79042356..f412221d7a6 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -19,6 +19,7 @@ #include "BKE_lib_id.hh" #include "BKE_modifier.hh" #include "BKE_object.hh" +#include "BKE_object_types.hh" #include "BLI_listbase.h" #include "BLI_math_geom.h" @@ -174,7 +175,7 @@ void AbcObjectReader::setupObjectTransform(const chrono_t time) /* Apply the matrix to the object. */ BKE_object_apply_mat4(m_object, transform_from_alembic, true, false); - BKE_object_to_mat4(m_object, m_object->object_to_world); + BKE_object_to_mat4(m_object, m_object->runtime->object_to_world.ptr()); if (!is_constant || m_settings->always_add_cache_reader) { bConstraint *con = BKE_constraint_add_for_object( diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 67ad7608cde..2ecae8b85b7 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -339,8 +339,8 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob) float mat[4][4]; TransformReader::get_node_mat(mat, node, &uid_animated_map, ob); if (ob) { - copy_m4_m4(ob->object_to_world, mat); - BKE_object_apply_mat4(ob, ob->object_to_world, false, false); + copy_m4_m4(ob->runtime->object_to_world.ptr(), mat); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); } } @@ -2107,7 +2107,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, if (par_job) { float temp[4][4], ipar[4][4]; - invert_m4_m4(ipar, par_job->object_to_world); + invert_m4_m4(ipar, par_job->object_to_world().ptr()); copy_m4_m4(temp, mat); mul_m4_m4m4(mat, ipar, temp); } diff --git a/source/blender/io/collada/ArmatureImporter.cpp b/source/blender/io/collada/ArmatureImporter.cpp index 51c2f4bb934..05ef8f81566 100644 --- a/source/blender/io/collada/ArmatureImporter.cpp +++ b/source/blender/io/collada/ArmatureImporter.cpp @@ -119,7 +119,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, Object *ob_arm = skin->BKE_armature_from_object(); if (ob_arm) { float invmat[4][4]; - invert_m4_m4(invmat, ob_arm->object_to_world); + invert_m4_m4(invmat, ob_arm->object_to_world().ptr()); mul_m4_m4m4(mat, invmat, mat); } @@ -715,7 +715,7 @@ void ArmatureImporter::set_pose(Object *ob_arm, copy_m4_m4(mat, obmat); float invObmat[4][4]; - invert_m4_m4(invObmat, ob_arm->object_to_world); + invert_m4_m4(invObmat, ob_arm->object_to_world().ptr()); mul_m4_m4m4(pchan->pose_mat, invObmat, mat); } diff --git a/source/blender/io/collada/ControllerExporter.cpp b/source/blender/io/collada/ControllerExporter.cpp index 04beb11c2af..8e7b5b4c05e 100644 --- a/source/blender/io/collada/ControllerExporter.cpp +++ b/source/blender/io/collada/ControllerExporter.cpp @@ -408,7 +408,7 @@ void ControllerExporter::add_bind_shape_mat(Object *ob) bc_add_global_transform(f_obmat, export_settings.get_global_transform()); } - // UnitConverter::mat4_to_dae_double(bind_mat, ob->object_to_world); + // UnitConverter::mat4_to_dae_double(bind_mat, ob->object_to_world().ptr()); UnitConverter::mat4_to_dae_double(bind_mat, f_obmat); if (this->export_settings.get_limit_precision()) { BCMatrix::sanitize(bind_mat, LIMITTED_PRECISION); @@ -524,7 +524,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, } /* make world-space matrix (bind_mat is armature-space) */ - mul_m4_m4m4(world, ob_arm->object_to_world, bind_mat); + mul_m4_m4m4(world, ob_arm->object_to_world().ptr(), bind_mat); if (!has_bindmat) { if (export_settings.get_apply_global_orientation()) { diff --git a/source/blender/io/collada/DocumentImporter.cpp b/source/blender/io/collada/DocumentImporter.cpp index 9ea7f7edd76..f066468ab7e 100644 --- a/source/blender/io/collada/DocumentImporter.cpp +++ b/source/blender/io/collada/DocumentImporter.cpp @@ -412,8 +412,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, } } /* calc new matrix and apply */ - mul_m4_m4m4(obn->object_to_world, obn->object_to_world, mat); - BKE_object_apply_mat4(obn, obn->object_to_world, false, false); + mul_m4_m4m4(obn->runtime->object_to_world.ptr(), obn->object_to_world().ptr(), mat); + BKE_object_apply_mat4(obn, obn->object_to_world().ptr(), false, false); } } else { diff --git a/source/blender/io/collada/SkinInfo.cpp b/source/blender/io/collada/SkinInfo.cpp index a884bfe2fb1..fa696f60e3d 100644 --- a/source/blender/io/collada/SkinInfo.cpp +++ b/source/blender/io/collada/SkinInfo.cpp @@ -218,8 +218,8 @@ void SkinInfo::link_armature(bContext *C, DEG_id_tag_update(&obn->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); #endif - copy_m4_m4(ob->object_to_world, bind_shape_matrix); - BKE_object_apply_mat4(ob, ob->object_to_world, false, false); + copy_m4_m4(ob->runtime->object_to_world.ptr(), bind_shape_matrix); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); amd->deformflag = ARM_DEF_VGROUP; diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index fe356489a3c..95c42990830 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -135,7 +135,9 @@ bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) const bool keep_transform = false; if (par && is_parent_space) { - mul_m4_m4m4(ob->object_to_world, par->object_to_world, ob->object_to_world); + mul_m4_m4m4(ob->runtime->object_to_world.ptr(), + par->object_to_world().ptr(), + ob->object_to_world().ptr()); } bool ok = ED_object_parent_set( @@ -391,10 +393,12 @@ std::string bc_replace_string(std::string data, void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene) { if (scale_to_scene) { - mul_m4_m4m4(ob->object_to_world, bc_unit.get_scale(), ob->object_to_world); + mul_m4_m4m4( + ob->runtime->object_to_world.ptr(), bc_unit.get_scale(), ob->object_to_world().ptr()); } - mul_m4_m4m4(ob->object_to_world, bc_unit.get_rotation(), ob->object_to_world); - BKE_object_apply_mat4(ob, ob->object_to_world, false, false); + mul_m4_m4m4( + ob->runtime->object_to_world.ptr(), bc_unit.get_rotation(), ob->object_to_world().ptr()); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, false); } void bc_match_scale(std::vector *objects_done, diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index 09ccf47f58f..0ba57df311f 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -413,7 +413,7 @@ void AbstractHierarchyIterator::visit_object(Object *object, context->original_export_path = ""; context->higher_up_export_path = ""; - copy_m4_m4(context->matrix_world, object->object_to_world); + copy_m4_m4(context->matrix_world, object->object_to_world().ptr()); ExportGraph::key_type graph_index = determine_graph_index_object(context); context_update_for_graph_index(context, graph_index); diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc index a7732622905..d487c9045ef 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_base.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc @@ -79,7 +79,7 @@ void GpencilIO::prepare_camera_params(Scene *scene, const GpencilIOParams *ipara BKE_camera_params_compute_viewplane(¶ms, rd->xsch, rd->ysch, rd->xasp, rd->yasp); BKE_camera_params_compute_matrix(¶ms); - float4x4 viewmat = math::invert(float4x4(cam_ob->object_to_world)); + float4x4 viewmat = math::invert(cam_ob->object_to_world()); persmat_ = float4x4(params.winmat) * viewmat; } @@ -149,7 +149,7 @@ void GpencilIO::create_object_list() continue; } - float3 object_position = float3(object->object_to_world[3]); + float3 object_position = float3(object->object_to_world().location()); /* Save z-depth from view to sort from back to front. */ if (is_camera_) { diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index 93c28885af7..9dbce4e7664 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -186,7 +186,7 @@ void GpencilExporterPDF::export_gpencil_layers() /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - const float scalef = mat4_to_scale(ob->object_to_world); + const float scalef = mat4_to_scale(ob->object_to_world().ptr()); gps_duplicate->thickness = ceilf(float(gps_duplicate->thickness) * scalef); CLAMP_MIN(gps_duplicate->thickness, 1.0f); /* Fill. */ diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index 6ecb1c40167..6f7e41cdb3d 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -202,7 +202,7 @@ void GpencilExporterSVG::export_gpencil_layers() /* Apply layer thickness change. */ gps_duplicate->thickness += gpl->line_change; /* Apply object scale to thickness. */ - const float scalef = mat4_to_scale(ob->object_to_world); + const float scalef = mat4_to_scale(ob->object_to_world().ptr()); gps_duplicate->thickness = ceilf(float(gps_duplicate->thickness) * scalef); CLAMP_MIN(gps_duplicate->thickness, 1.0f); diff --git a/source/blender/io/ply/exporter/ply_export_load_plydata.cc b/source/blender/io/ply/exporter/ply_export_load_plydata.cc index fee0d99d35d..51132a80135 100644 --- a/source/blender/io/ply/exporter/ply_export_load_plydata.cc +++ b/source/blender/io/ply/exporter/ply_export_load_plydata.cc @@ -55,10 +55,10 @@ static void set_world_axes_transform(const Object &object, unit_m3(axes_transform); /* +Y-forward and +Z-up are the default Blender axis settings. */ mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform); - mul_m4_m3m4(r_world_and_axes_transform, axes_transform, object.object_to_world); + mul_m4_m3m4(r_world_and_axes_transform, axes_transform, object.object_to_world().ptr()); /* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */ - mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform, object.object_to_world[3]); - r_world_and_axes_transform[3][3] = object.object_to_world[3][3]; + mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform, object.object_to_world().location()); + r_world_and_axes_transform[3][3] = object.object_to_world()[3][3]; /* Normals need inverse transpose of the regular matrix to handle non-uniform scale. */ float normal_matrix[3][3]; diff --git a/source/blender/io/stl/exporter/stl_export.cc b/source/blender/io/stl/exporter/stl_export.cc index df2295fc168..14242bc90a4 100644 --- a/source/blender/io/stl/exporter/stl_export.cc +++ b/source/blender/io/stl/exporter/stl_export.cc @@ -85,10 +85,10 @@ void export_frame(Depsgraph *depsgraph, /* +Y-forward and +Z-up are the default Blender axis settings. */ mat3_from_axis_conversion( export_params.forward_axis, export_params.up_axis, IO_AXIS_Y, IO_AXIS_Z, axes_transform); - mul_m4_m3m4(xform, axes_transform, obj_eval->object_to_world); + mul_m4_m3m4(xform, axes_transform, obj_eval->object_to_world().ptr()); /* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */ - mul_v3_m3v3(xform[3], axes_transform, obj_eval->object_to_world[3]); - xform[3][3] = obj_eval->object_to_world[3][3]; + mul_v3_m3v3(xform[3], axes_transform, obj_eval->object_to_world().location()); + xform[3][3] = obj_eval->object_to_world().location()[3]; /* Write triangles. */ const Span positions = mesh->vert_positions(); diff --git a/source/blender/io/usd/hydra/curves.cc b/source/blender/io/usd/hydra/curves.cc index be9f39735e6..5e10dcc3f8b 100644 --- a/source/blender/io/usd/hydra/curves.cc +++ b/source/blender/io/usd/hydra/curves.cc @@ -234,9 +234,9 @@ void HairData::write_curves() Object *object = (Object *)id; float scale = particle_system_->part->rad_scale * - (std::abs(object->object_to_world[0][0]) + - std::abs(object->object_to_world[1][1]) + - std::abs(object->object_to_world[2][2])) / + (std::abs(object->object_to_world().ptr()[0][0]) + + std::abs(object->object_to_world().ptr()[1][1]) + + std::abs(object->object_to_world().ptr()[2][2])) / 3; float root = scale * particle_system_->part->rad_root; float tip = scale * particle_system_->part->rad_tip; diff --git a/source/blender/io/usd/hydra/object.cc b/source/blender/io/usd/hydra/object.cc index 5349022a219..a1b26796f34 100644 --- a/source/blender/io/usd/hydra/object.cc +++ b/source/blender/io/usd/hydra/object.cc @@ -121,7 +121,7 @@ void ObjectData::available_materials(Set & /*paths*/) const {} void ObjectData::write_transform() { - transform = gf_matrix_from_transform(((const Object *)id)->object_to_world); + transform = gf_matrix_from_transform(((const Object *)id)->object_to_world().ptr()); } void ObjectData::write_materials() {} diff --git a/source/blender/io/usd/hydra/volume_modifier.cc b/source/blender/io/usd/hydra/volume_modifier.cc index 04da4c78cce..023b3dfcff0 100644 --- a/source/blender/io/usd/hydra/volume_modifier.cc +++ b/source/blender/io/usd/hydra/volume_modifier.cc @@ -120,7 +120,7 @@ void VolumeModifierData::write_transform() pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(texspace_loc)); /* applying object transform */ - transform *= gf_matrix_from_transform(object->object_to_world); + transform *= gf_matrix_from_transform(object->object_to_world().ptr()); } std::string VolumeModifierData::get_cached_file_path(std::string directory, int frame) diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index 2f552532909..e3e261fb331 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -154,7 +154,7 @@ void OBJMesh::set_world_axes_transform(const Object &obj_eval, /* +Y-forward and +Z-up are the default Blender axis settings. */ mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform.ptr()); - const float4x4 object_to_world(obj_eval.object_to_world); + const float4x4 object_to_world = obj_eval.object_to_world(); const float3x3 transform = axes_transform * float3x3(object_to_world); world_and_axes_transform_ = float4x4(transform); diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc b/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc index 8c848a0da17..fc5bc8a346b 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_nurbs.cc @@ -35,10 +35,11 @@ void OBJCurve::set_world_axes_transform(const eIOAxis forward, const eIOAxis up) unit_m3(axes_transform); /* +Y-forward and +Z-up are the Blender's default axis settings. */ mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform); - mul_m4_m3m4(world_axes_transform_, axes_transform, export_object_eval_->object_to_world); + mul_m4_m3m4(world_axes_transform_, axes_transform, export_object_eval_->object_to_world().ptr()); /* #mul_m4_m3m4 does not transform last row of #Object.object_to_world, i.e. location data. */ - mul_v3_m3v3(world_axes_transform_[3], axes_transform, export_object_eval_->object_to_world[3]); - world_axes_transform_[3][3] = export_object_eval_->object_to_world[3][3]; + mul_v3_m3v3( + world_axes_transform_[3], axes_transform, export_object_eval_->object_to_world().location()); + world_axes_transform_[3][3] = export_object_eval_->object_to_world().location()[3]; } const char *OBJCurve::get_curve_name() const diff --git a/source/blender/makesdna/DNA_object_defaults.h b/source/blender/makesdna/DNA_object_defaults.h index 6797e76b2cf..878750b57ef 100644 --- a/source/blender/makesdna/DNA_object_defaults.h +++ b/source/blender/makesdna/DNA_object_defaults.h @@ -25,7 +25,6 @@ \ .constinv = _DNA_DEFAULT_UNIT_M4, \ .parentinv = _DNA_DEFAULT_UNIT_M4, \ - .object_to_world = _DNA_DEFAULT_UNIT_M4, \ \ .scale = {1, 1, 1}, \ .dscale = {1, 1, 1}, \ diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index db110cbb2c0..5af3f2f9e91 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -24,6 +24,10 @@ #include "DNA_defs.h" #include "DNA_listBase.h" +#ifdef __cplusplus +# include "BLI_math_matrix_types.hh" +#endif + #ifdef __cplusplus namespace blender::bke { struct ObjectRuntime; @@ -274,9 +278,6 @@ typedef struct Object { float rotAxis[3], drotAxis[3]; /** Axis angle rotation - angle part. */ float rotAngle, drotAngle; - /** Final transformation matrices with constraints & animsys applied. */ - float object_to_world[4][4]; - float world_to_object[4][4]; /** Inverse result of parent, so that object doesn't 'stick' to parent. */ float parentinv[4][4]; /** Inverse result of constraints. @@ -399,6 +400,11 @@ typedef struct Object { struct LightProbeObjectCache *lightprobe_cache; ObjectRuntimeHandle *runtime; + +#ifdef __cplusplus + const blender::float4x4 &object_to_world() const; + const blender::float4x4 &world_to_object() const; +#endif } Object; /** DEPRECATED: this is not used anymore because hooks are now modifiers. */ diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index 6d641b22f6c..b5b2f845b8f 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -149,8 +149,6 @@ DNA_STRUCT_RENAME_ELEM(NodesModifierData, simulation_bake_directory, bake_direct DNA_STRUCT_RENAME_ELEM(Object, col, color) DNA_STRUCT_RENAME_ELEM(Object, dup_group, instance_collection) DNA_STRUCT_RENAME_ELEM(Object, dupfacesca, instance_faces_scale) -DNA_STRUCT_RENAME_ELEM(Object, imat, world_to_object) -DNA_STRUCT_RENAME_ELEM(Object, obmat, object_to_world) DNA_STRUCT_RENAME_ELEM(Object, restrictflag, visibility_flag) DNA_STRUCT_RENAME_ELEM(Object, size, scale) DNA_STRUCT_RENAME_ELEM(OpacityGpencilModifierData, hardeness, hardness) diff --git a/source/blender/makesrna/intern/rna_depsgraph.cc b/source/blender/makesrna/intern/rna_depsgraph.cc index 3a6e7bdc9ec..cefa4d82078 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.cc +++ b/source/blender/makesrna/intern/rna_depsgraph.cc @@ -174,7 +174,7 @@ static void rna_DepsgraphObjectInstance_matrix_world_get(PointerRNA *ptr, float /* We can return actual object's matrix here, no reason to return identity matrix * when this is not actually an instance... */ Object *ob = (Object *)di->iter.current; - copy_m4_m4((float(*)[4])mat, ob->object_to_world); + copy_m4_m4((float(*)[4])mat, ob->object_to_world().ptr()); } } diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy.cc b/source/blender/makesrna/intern/rna_gpencil_legacy.cc index c9c2b690f16..6c738c351f8 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy.cc +++ b/source/blender/makesrna/intern/rna_gpencil_legacy.cc @@ -340,13 +340,13 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr, const char ** static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char *substr) { if (type == PAROBJECT) { - invert_m4_m4(gpl->inverse, par->object_to_world); + invert_m4_m4(gpl->inverse, par->object_to_world().ptr()); gpl->parent = par; gpl->partype |= PAROBJECT; gpl->parsubstr[0] = 0; } else if (type == PARSKEL) { - invert_m4_m4(gpl->inverse, par->object_to_world); + invert_m4_m4(gpl->inverse, par->object_to_world().ptr()); gpl->parent = par; gpl->partype |= PARSKEL; gpl->parsubstr[0] = 0; @@ -355,7 +355,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * bPoseChannel *pchan = BKE_pose_channel_find_name(par->pose, substr); if (pchan) { float tmp_mat[4][4]; - mul_m4_m4m4(tmp_mat, par->object_to_world, pchan->pose_mat); + mul_m4_m4m4(tmp_mat, par->object_to_world().ptr(), pchan->pose_mat); invert_m4_m4(gpl->inverse, tmp_mat); gpl->parent = par; @@ -363,7 +363,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * STRNCPY(gpl->parsubstr, substr); } else { - invert_m4_m4(gpl->inverse, par->object_to_world); + invert_m4_m4(gpl->inverse, par->object_to_world().ptr()); gpl->parent = par; gpl->partype |= PAROBJECT; gpl->parsubstr[0] = 0; diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index 47fcae1d984..bc0f0a304bd 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -367,7 +367,7 @@ static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA { /* Don't use compatibility so we get predictable rotation. */ Object *ob = reinterpret_cast(ptr->owner_id); - BKE_object_apply_mat4(ob, ob->object_to_world, false, true); + BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, true); rna_Object_internal_update(bmain, scene, ptr); } @@ -407,6 +407,18 @@ static void rna_GPencil_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA * } } +static void rna_Object_matrix_world_get(PointerRNA *ptr, float *values) +{ + Object *ob = static_cast(ptr->data); + std::copy_n(ob->object_to_world().base_ptr(), 16, values); +} + +static void rna_Object_matrix_world_set(PointerRNA *ptr, const float *values) +{ + Object *ob = static_cast(ptr->data); + ob->runtime->object_to_world = blender::float4x4(values); +} + static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16]) { Object *ob = reinterpret_cast(ptr->owner_id); @@ -3339,11 +3351,12 @@ static void rna_def_object(BlenderRNA *brna) /* matrix */ prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX); - RNA_def_property_float_sdna(prop, nullptr, "object_to_world"); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_float_funcs( + prop, "rna_Object_matrix_world_get", "rna_Object_matrix_world_set", nullptr); RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix"); RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update"); diff --git a/source/blender/makesrna/intern/rna_particle.cc b/source/blender/makesrna/intern/rna_particle.cc index 21c330c48a7..88eb2b0e951 100644 --- a/source/blender/makesrna/intern/rna_particle.cc +++ b/source/blender/makesrna/intern/rna_particle.cc @@ -474,7 +474,7 @@ static void rna_ParticleSystem_co_hair( if (step >= 0 && step <= max_k) { copy_v3_v3(n_co, (cache + step)->co); mul_m4_v3(particlesystem->imat, n_co); - mul_m4_v3(object->object_to_world, n_co); + mul_m4_v3(object->object_to_world().ptr(), n_co); } } diff --git a/source/blender/modifiers/intern/MOD_array.cc b/source/blender/modifiers/intern/MOD_array.cc index df8b137533c..da46104560f 100644 --- a/source/blender/modifiers/intern/MOD_array.cc +++ b/source/blender/modifiers/intern/MOD_array.cc @@ -479,13 +479,13 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, float result_mat[4][4]; if (ctx->object) { - invert_m4_m4(obinv, ctx->object->object_to_world); + invert_m4_m4(obinv, ctx->object->object_to_world().ptr()); } else { unit_m4(obinv); } - mul_m4_series(result_mat, offset, obinv, amd->offset_ob->object_to_world); + mul_m4_series(result_mat, offset, obinv, amd->offset_ob->object_to_world().ptr()); copy_m4_m4(offset, result_mat); } @@ -497,7 +497,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd, Object *curve_ob = amd->curve_ob; CurveCache *curve_cache = curve_ob->runtime->curve_cache; if (curve_cache != nullptr && curve_cache->anim_path_accum_length != nullptr) { - float scale_fac = mat4_to_scale(curve_ob->object_to_world); + float scale_fac = mat4_to_scale(curve_ob->object_to_world().ptr()); length = scale_fac * BKE_anim_path_get_length(curve_cache); } } diff --git a/source/blender/modifiers/intern/MOD_boolean.cc b/source/blender/modifiers/intern/MOD_boolean.cc index 5f5396e3ffe..ce3f53b68d4 100644 --- a/source/blender/modifiers/intern/MOD_boolean.cc +++ b/source/blender/modifiers/intern/MOD_boolean.cc @@ -135,8 +135,8 @@ static Mesh *get_quick_mesh( float imat[4][4]; float omat[4][4]; - invert_m4_m4(imat, ob_self->object_to_world); - mul_m4_m4m4(omat, imat, ob_operand_ob->object_to_world); + invert_m4_m4(imat, ob_self->object_to_world().ptr()); + mul_m4_m4m4(omat, imat, ob_operand_ob->object_to_world().ptr()); MutableSpan positions = result->vert_positions_for_write(); for (const int i : positions.index_range()) { @@ -223,8 +223,8 @@ static BMesh *BMD_mesh_bm_create( SCOPED_TIMER(__func__); #endif - *r_is_flip = (is_negative_m4(object->object_to_world) != - is_negative_m4(operand_ob->object_to_world)); + *r_is_flip = (is_negative_m4(object->object_to_world().ptr()) != + is_negative_m4(operand_ob->object_to_world().ptr())); const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_operand_ob); @@ -291,8 +291,8 @@ static void BMD_mesh_intersection(BMesh *bm, float imat[4][4]; float omat[4][4]; - invert_m4_m4(imat, object->object_to_world); - mul_m4_m4m4(omat, imat, operand_ob->object_to_world); + invert_m4_m4(imat, object->object_to_world().ptr()); + mul_m4_m4m4(omat, imat, operand_ob->object_to_world().ptr()); BMVert *eve; i = 0; @@ -420,7 +420,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, } meshes.append(mesh); - obmats.append(float4x4(ctx->object->object_to_world)); + obmats.append(ctx->object->object_to_world()); material_remaps.append({}); const BooleanModifierMaterialMode material_mode = BooleanModifierMaterialMode( @@ -443,7 +443,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, } BKE_mesh_wrapper_ensure_mdata(mesh_operand); meshes.append(mesh_operand); - obmats.append(float4x4(bmd->object->object_to_world)); + obmats.append(bmd->object->object_to_world()); if (material_mode == eBooleanModifierMaterialMode_Index) { material_remaps.append(get_material_remap_index_based(ctx->object, bmd->object)); } @@ -463,7 +463,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, } BKE_mesh_wrapper_ensure_mdata(collection_mesh); meshes.append(collection_mesh); - obmats.append(float4x4(ob->object_to_world)); + obmats.append(ob->object_to_world()); if (material_mode == eBooleanModifierMaterialMode_Index) { material_remaps.append(get_material_remap_index_based(ctx->object, ob)); } @@ -478,15 +478,14 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd, const bool use_self = (bmd->flag & eBooleanModifierFlag_Self) != 0; const bool hole_tolerant = (bmd->flag & eBooleanModifierFlag_HoleTolerant) != 0; - Mesh *result = blender::meshintersect::direct_mesh_boolean( - meshes, - obmats, - float4x4(ctx->object->object_to_world), - material_remaps, - use_self, - hole_tolerant, - bmd->operation, - nullptr); + Mesh *result = blender::meshintersect::direct_mesh_boolean(meshes, + obmats, + ctx->object->object_to_world(), + material_remaps, + use_self, + hole_tolerant, + bmd->operation, + nullptr); if (material_mode == eBooleanModifierMaterialMode_Transfer) { MEM_SAFE_FREE(result->mat); diff --git a/source/blender/modifiers/intern/MOD_cast.cc b/source/blender/modifiers/intern/MOD_cast.cc index 4e688ee8a61..d065dd82735 100644 --- a/source/blender/modifiers/intern/MOD_cast.cc +++ b/source/blender/modifiers/intern/MOD_cast.cc @@ -20,6 +20,7 @@ #include "BKE_deform.hh" #include "BKE_lib_query.hh" #include "BKE_modifier.hh" +#include "BKE_object_types.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -114,13 +115,13 @@ static void sphere_do(CastModifierData *cmd, * we use its location, transformed to ob's local space. */ if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { - invert_m4_m4(imat, ctrl_ob->object_to_world); - mul_m4_m4m4(mat, imat, ob->object_to_world); + invert_m4_m4(imat, ctrl_ob->object_to_world().ptr()); + mul_m4_m4m4(mat, imat, ob->object_to_world().ptr()); invert_m4_m4(imat, mat); } - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_v3_m4v3(center, ob->world_to_object, ctrl_ob->object_to_world[3]); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_v3_m4v3(center, ob->world_to_object().ptr(), ctrl_ob->object_to_world().location()); } /* now we check which options the user wants */ @@ -262,13 +263,13 @@ static void cuboid_do(CastModifierData *cmd, if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { - invert_m4_m4(imat, ctrl_ob->object_to_world); - mul_m4_m4m4(mat, imat, ob->object_to_world); + invert_m4_m4(imat, ctrl_ob->object_to_world().ptr()); + mul_m4_m4m4(mat, imat, ob->object_to_world().ptr()); invert_m4_m4(imat, mat); } - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_v3_m4v3(center, ob->world_to_object, ctrl_ob->object_to_world[3]); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_v3_m4v3(center, ob->world_to_object().ptr(), ctrl_ob->object_to_world().location()); } if ((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) { diff --git a/source/blender/modifiers/intern/MOD_collision.cc b/source/blender/modifiers/intern/MOD_collision.cc index 3ea68f101a3..5ad7d88c501 100644 --- a/source/blender/modifiers/intern/MOD_collision.cc +++ b/source/blender/modifiers/intern/MOD_collision.cc @@ -131,7 +131,7 @@ static void deform_verts(ModifierData *md, for (uint i = 0; i < mvert_num; i++) { /* we save global positions */ - mul_m4_v3(ob->object_to_world, collmd->x[i]); + mul_m4_v3(ob->object_to_world().ptr(), collmd->x[i]); } collmd->xnew = static_cast(MEM_dupallocN(collmd->x)); /* Frame end position. */ @@ -176,7 +176,7 @@ static void deform_verts(ModifierData *md, for (uint i = 0; i < mvert_num; i++) { /* we save global positions */ - mul_m4_v3(ob->object_to_world, collmd->xnew[i]); + mul_m4_v3(ob->object_to_world().ptr(), collmd->xnew[i]); /* detect motion */ is_static = is_static && equals_v3v3(collmd->x[i], collmd->xnew[i]); diff --git a/source/blender/modifiers/intern/MOD_displace.cc b/source/blender/modifiers/intern/MOD_displace.cc index e6aa5922ffc..9ee636ed448 100644 --- a/source/blender/modifiers/intern/MOD_displace.cc +++ b/source/blender/modifiers/intern/MOD_displace.cc @@ -317,7 +317,7 @@ static void displaceModifier_do(DisplaceModifierData *dmd, else if (ELEM(direction, MOD_DISP_DIR_X, MOD_DISP_DIR_Y, MOD_DISP_DIR_Z, MOD_DISP_DIR_RGB_XYZ) && use_global_direction) { - copy_m4_m4(local_mat, ob->object_to_world); + copy_m4_m4(local_mat, ob->object_to_world().ptr()); } DisplaceUserdata data = {nullptr}; diff --git a/source/blender/modifiers/intern/MOD_explode.cc b/source/blender/modifiers/intern/MOD_explode.cc index dae906a4483..2ed5cdca584 100644 --- a/source/blender/modifiers/intern/MOD_explode.cc +++ b/source/blender/modifiers/intern/MOD_explode.cc @@ -973,7 +973,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd, &explode->fdata_legacy, CD_MTFACE, emd->uvname, explode->totface_legacy)); /* getting back to object space */ - invert_m4_m4(imat, ctx->object->object_to_world); + invert_m4_m4(imat, ctx->object->object_to_world().ptr()); psys_sim_data_init(&sim); @@ -1001,7 +1001,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd, psys_get_particle_state(&sim, ed_v2, &state, true); vertco = explode_positions[v]; - mul_m4_v3(ctx->object->object_to_world, vertco); + mul_m4_v3(ctx->object->object_to_world().ptr(), vertco); sub_v3_v3(vertco, birth.co); diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc b/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc index a1f291794c4..ee29e1af183 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_mirror.cc @@ -89,8 +89,7 @@ static float4x4 get_mirror_matrix(const Object &ob, if (mmd.object) { /* Transforms from parent object space to target object space. */ - const float4x4 to_target = math::invert(float4x4(mmd.object->object_to_world)) * - float4x4(ob.object_to_world); + const float4x4 to_target = math::invert(mmd.object->object_to_world()) * ob.object_to_world(); /* Mirror points in the target object space. */ matrix = math::invert(to_target) * matrix * to_target; } diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc index 6215a114b5d..70d13bfcd9a 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_tint.cc @@ -217,8 +217,7 @@ static void modify_stroke_color(Object &ob, const OffsetIndices points_by_curve = curves.points_by_curve(); const Span positions = curves.positions(); /* Transforms points to the gradient object space. */ - const float4x4 matrix = float4x4_view(tmd.object->world_to_object) * - float4x4_view(ob.object_to_world); + const float4x4 matrix = tmd.object->world_to_object() * ob.object_to_world(); curves_mask.foreach_index(GrainSize(512), [&](const int64_t curve_i) { const ColorGeometry4f material_color = get_material_color(curve_i); @@ -297,8 +296,7 @@ static void modify_fill_color(Object &ob, const OffsetIndices points_by_curve = curves.points_by_curve(); const Span positions = curves.positions(); /* Transforms points to the gradient object space. */ - const float4x4 matrix = float4x4_view(tmd.object->world_to_object) * - float4x4_view(ob.object_to_world); + const float4x4 matrix = tmd.object->world_to_object() * ob.object_to_world(); curves_mask.foreach_index(GrainSize(512), [&](int64_t curve_i) { const ColorGeometry4f material_color = get_material_color(curve_i); diff --git a/source/blender/modifiers/intern/MOD_hook.cc b/source/blender/modifiers/intern/MOD_hook.cc index 1c9702240fc..a2d3ae6e45f 100644 --- a/source/blender/modifiers/intern/MOD_hook.cc +++ b/source/blender/modifiers/intern/MOD_hook.cc @@ -27,6 +27,7 @@ #include "BKE_lib_query.hh" #include "BKE_mesh.hh" #include "BKE_modifier.hh" +#include "BKE_object_types.hh" #include "UI_interface.hh" #include "UI_resources.hh" @@ -331,14 +332,14 @@ static void deformVerts_do(HookModifierData *hmd, /* get world-space matrix of target, corrected for the space the verts are in */ if (hmd->subtarget[0] && pchan) { /* bone target if there's a matching pose-channel */ - mul_m4_m4m4(dmat, ob_target->object_to_world, pchan->pose_mat); + mul_m4_m4m4(dmat, ob_target->object_to_world().ptr(), pchan->pose_mat); } else { /* just object target */ - copy_m4_m4(dmat, ob_target->object_to_world); + copy_m4_m4(dmat, ob_target->object_to_world().ptr()); } - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_series(hd.mat, ob->world_to_object, dmat, hmd->parentinv); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_series(hd.mat, ob->world_to_object().ptr(), dmat, hmd->parentinv); /* --- done with 'hd' init --- */ /* Regarding index range checking below. diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc index 01c1b268f10..831d41d5133 100644 --- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc +++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc @@ -122,8 +122,8 @@ static Volume *mesh_to_volume(ModifierData *md, return input_volume; } - const float4x4 mesh_to_own_object_space_transform = float4x4(ctx->object->world_to_object) * - float4x4(object_to_convert->object_to_world); + const float4x4 mesh_to_own_object_space_transform = ctx->object->world_to_object() * + object_to_convert->object_to_world(); geometry::MeshToVolumeResolution resolution; resolution.mode = (MeshToVolumeModifierResolutionMode)mvmd->resolution_mode; if (resolution.mode == MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT) { diff --git a/source/blender/modifiers/intern/MOD_meshdeform.cc b/source/blender/modifiers/intern/MOD_meshdeform.cc index 838643bf4e9..709d7e6a305 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.cc +++ b/source/blender/modifiers/intern/MOD_meshdeform.cc @@ -349,8 +349,8 @@ static void meshdeformModifier_do(ModifierData *md, } /* compute matrices to go in and out of cage object space */ - invert_m4_m4(imat, ob_target->object_to_world); - mul_m4_m4m4(cagemat, imat, ob->object_to_world); + invert_m4_m4(imat, ob_target->object_to_world().ptr()); + mul_m4_m4m4(cagemat, imat, ob->object_to_world().ptr()); mul_m4_m4m4(cmat, mmd->bindmat, cagemat); invert_m4_m4(iobmat, cmat); copy_m3_m4(icagemat, iobmat); diff --git a/source/blender/modifiers/intern/MOD_normal_edit.cc b/source/blender/modifiers/intern/MOD_normal_edit.cc index 6ea371d6f42..fb8c8091b03 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.cc +++ b/source/blender/modifiers/intern/MOD_normal_edit.cc @@ -95,8 +95,8 @@ static void generate_vert_coordinates(Mesh *mesh, /* Translate our coordinates so that center of ob_center is at (0, 0, 0). */ /* Get ob_center (world) coordinates in ob local coordinates. * No need to take into account ob_center's space here, see #44027. */ - invert_m4_m4(inv_obmat, ob->object_to_world); - mul_v3_m4v3(diff, inv_obmat, ob_center->object_to_world[3]); + invert_m4_m4(inv_obmat, ob->object_to_world().ptr()); + mul_v3_m4v3(diff, inv_obmat, ob_center->object_to_world().location()); negate_v3(diff); do_diff = true; @@ -369,8 +369,8 @@ static void normalEditModifier_do_directional(NormalEditModifierData *enmd, /* Get target's center coordinates in ob local coordinates. */ float mat[4][4]; - invert_m4_m4(mat, ob->object_to_world); - mul_m4_m4m4(mat, mat, ob_target->object_to_world); + invert_m4_m4(mat, ob->object_to_world().ptr()); + mul_m4_m4m4(mat, mat, ob_target->object_to_world().ptr()); copy_v3_v3(target_co, mat[3]); if (use_parallel_normals) { diff --git a/source/blender/modifiers/intern/MOD_particleinstance.cc b/source/blender/modifiers/intern/MOD_particleinstance.cc index e58583b9ca5..ef1faeaeb17 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.cc +++ b/source/blender/modifiers/intern/MOD_particleinstance.cc @@ -268,7 +268,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh break; case eParticleInstanceSpace_Local: /* get particle states in the particle object's local space */ - invert_m4_m4(spacemat, pimd->ob->object_to_world); + invert_m4_m4(spacemat, pimd->ob->object_to_world().ptr()); break; default: /* should not happen */ diff --git a/source/blender/modifiers/intern/MOD_screw.cc b/source/blender/modifiers/intern/MOD_screw.cc index 99e4d006311..7410cbf280a 100644 --- a/source/blender/modifiers/intern/MOD_screw.cc +++ b/source/blender/modifiers/intern/MOD_screw.cc @@ -286,8 +286,8 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh if (ob_axis != nullptr) { /* Calculate the matrix relative to the axis object. */ - invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world); - copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world); + invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world().ptr()); + copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world().ptr()); mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv); /* Calculate the axis vector. */ diff --git a/source/blender/modifiers/intern/MOD_surface.cc b/source/blender/modifiers/intern/MOD_surface.cc index cb14f764623..f553c3b9f44 100644 --- a/source/blender/modifiers/intern/MOD_surface.cc +++ b/source/blender/modifiers/intern/MOD_surface.cc @@ -138,7 +138,7 @@ static void deform_verts(ModifierData *md, surmd->runtime.mesh->vert_positions_for_write(); for (i = 0; i < mesh_verts_num; i++) { float *vec = positions[i]; - mul_m4_v3(ctx->object->object_to_world, vec); + mul_m4_v3(ctx->object->object_to_world().ptr(), vec); if (init) { zero_v3(surmd->runtime.vert_velocities[i]); diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.cc b/source/blender/modifiers/intern/MOD_surfacedeform.cc index 92da9c9cb1b..72d9e957a78 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.cc +++ b/source/blender/modifiers/intern/MOD_surfacedeform.cc @@ -1462,8 +1462,8 @@ static void surfacedeformModifier_do(ModifierData *md, ob, md); float tmp_mat[4][4]; - invert_m4_m4(tmp_mat, ob->object_to_world); - mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->object_to_world); + invert_m4_m4(tmp_mat, ob->object_to_world().ptr()); + mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->object_to_world().ptr()); /* Avoid converting edit-mesh data, binding is an exception. */ BKE_mesh_wrapper_ensure_mdata(target); diff --git a/source/blender/modifiers/intern/MOD_util.cc b/source/blender/modifiers/intern/MOD_util.cc index 17a5a1e987f..1e7fea67056 100644 --- a/source/blender/modifiers/intern/MOD_util.cc +++ b/source/blender/modifiers/intern/MOD_util.cc @@ -71,15 +71,15 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, bPoseChannel *pchan = BKE_pose_channel_find_name(map_object->pose, dmd->map_bone); if (pchan) { float mat_bone_world[4][4]; - mul_m4_m4m4(mat_bone_world, map_object->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat_bone_world, map_object->object_to_world().ptr(), pchan->pose_mat); invert_m4_m4(mapref_imat, mat_bone_world); } else { - invert_m4_m4(mapref_imat, map_object->object_to_world); + invert_m4_m4(mapref_imat, map_object->object_to_world().ptr()); } } else { - invert_m4_m4(mapref_imat, map_object->object_to_world); + invert_m4_m4(mapref_imat, map_object->object_to_world().ptr()); } } else { /* if there is no map object, default to local */ @@ -129,10 +129,10 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd, copy_v3_v3(*r_texco, cos != nullptr ? *cos : positions[i]); break; case MOD_DISP_MAP_GLOBAL: - mul_v3_m4v3(*r_texco, ob->object_to_world, cos != nullptr ? *cos : positions[i]); + mul_v3_m4v3(*r_texco, ob->object_to_world().ptr(), cos != nullptr ? *cos : positions[i]); break; case MOD_DISP_MAP_OBJECT: - mul_v3_m4v3(*r_texco, ob->object_to_world, cos != nullptr ? *cos : positions[i]); + mul_v3_m4v3(*r_texco, ob->object_to_world().ptr(), cos != nullptr ? *cos : positions[i]); mul_m4_v3(mapref_imat, *r_texco); break; } diff --git a/source/blender/modifiers/intern/MOD_uvproject.cc b/source/blender/modifiers/intern/MOD_uvproject.cc index 612abeb7c42..5d7363d5735 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.cc +++ b/source/blender/modifiers/intern/MOD_uvproject.cc @@ -141,7 +141,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, float offsetmat[4][4]; Camera *cam = nullptr; /* calculate projection matrix */ - invert_m4_m4(projectors[i].projmat, projectors[i].ob->object_to_world); + invert_m4_m4(projectors[i].projmat, projectors[i].ob->object_to_world().ptr()); projectors[i].uci = nullptr; @@ -187,7 +187,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, projectors[i].normal[0] = 0; projectors[i].normal[1] = 0; projectors[i].normal[2] = 1; - mul_mat3_m4_v3(projectors[i].ob->object_to_world, projectors[i].normal); + mul_mat3_m4_v3(projectors[i].ob->object_to_world().ptr(), projectors[i].normal); } const Span positions = mesh->vert_positions(); @@ -198,7 +198,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, /* Convert coords to world-space. */ Array coords(positions.size()); for (int64_t i = 0; i < positions.size(); i++) { - mul_v3_m4v3(coords[i], ob->object_to_world, positions[i]); + mul_v3_m4v3(coords[i], ob->object_to_world().ptr(), positions[i]); } /* if only one projector, project coords to UVs */ diff --git a/source/blender/modifiers/intern/MOD_uvwarp.cc b/source/blender/modifiers/intern/MOD_uvwarp.cc index 308632d7f81..ad021bba805 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.cc +++ b/source/blender/modifiers/intern/MOD_uvwarp.cc @@ -72,10 +72,10 @@ static void matrix_from_obj_pchan(float mat[4][4], Object *ob, const char *bonen { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename); if (pchan) { - mul_m4_m4m4(mat, ob->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat, ob->object_to_world().ptr(), pchan->pose_mat); } else { - copy_m4_m4(mat, ob->object_to_world); + copy_m4_m4(mat, ob->object_to_world().ptr()); } } diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc index b316c4192a8..6d1ec283f5f 100644 --- a/source/blender/modifiers/intern/MOD_volume_displace.cc +++ b/source/blender/modifiers/intern/MOD_volume_displace.cc @@ -250,16 +250,18 @@ struct DisplaceGridOp { return index_to_object; } case MOD_VOLUME_DISPLACE_MAP_GLOBAL: { - const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->object_to_world); + const openvdb::Mat4s object_to_world = matrix_to_openvdb( + ctx.object->object_to_world().ptr()); return index_to_object * object_to_world; } case MOD_VOLUME_DISPLACE_MAP_OBJECT: { if (vdmd.texture_map_object == nullptr) { return index_to_object; } - const openvdb::Mat4s object_to_world = matrix_to_openvdb(ctx.object->object_to_world); + const openvdb::Mat4s object_to_world = matrix_to_openvdb( + ctx.object->object_to_world().ptr()); const openvdb::Mat4s world_to_texture = matrix_to_openvdb( - vdmd.texture_map_object->world_to_object); + vdmd.texture_map_object->world_to_object().ptr()); return index_to_object * object_to_world * world_to_texture; } } diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index bf6dbfb8637..f3fae579511 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -157,8 +157,8 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh const openvdb::GridBase &local_grid = volume_grid->grid(tree_token); openvdb::math::Transform::Ptr transform = local_grid.transform().copy(); - transform->postMult(openvdb::Mat4d((float *)vmmd->object->object_to_world)); - openvdb::Mat4d imat = openvdb::Mat4d((float *)ctx->object->world_to_object); + transform->postMult(openvdb::Mat4d(vmmd->object->object_to_world().base_ptr())); + openvdb::Mat4d imat = openvdb::Mat4d(ctx->object->world_to_object().base_ptr()); /* `imat` had floating point issues and wasn't affine. */ imat.setCol(3, openvdb::Vec4d(0, 0, 0, 1)); transform->postMult(imat); diff --git a/source/blender/modifiers/intern/MOD_warp.cc b/source/blender/modifiers/intern/MOD_warp.cc index c9998628bee..2ece8e61716 100644 --- a/source/blender/modifiers/intern/MOD_warp.cc +++ b/source/blender/modifiers/intern/MOD_warp.cc @@ -85,11 +85,11 @@ static void matrix_from_obj_pchan(float mat[4][4], bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename); if (pchan) { float mat_bone_world[4][4]; - mul_m4_m4m4(mat_bone_world, ob->object_to_world, pchan->pose_mat); + mul_m4_m4m4(mat_bone_world, ob->object_to_world().ptr(), pchan->pose_mat); mul_m4_m4m4(mat, obinv, mat_bone_world); } else { - mul_m4_m4m4(mat, obinv, ob->object_to_world); + mul_m4_m4m4(mat, obinv, ob->object_to_world().ptr()); } } @@ -205,7 +205,7 @@ static void warpModifier_do(WarpModifierData *wmd, BKE_curvemapping_init(wmd->curfalloff); } - invert_m4_m4(obinv, ob->object_to_world); + invert_m4_m4(obinv, ob->object_to_world().ptr()); /* Checks that the objects/bones are available. */ matrix_from_obj_pchan(mat_from, obinv, wmd->object_from, wmd->bone_from); diff --git a/source/blender/modifiers/intern/MOD_wave.cc b/source/blender/modifiers/intern/MOD_wave.cc index eaa4acdc7cc..f540cefaaff 100644 --- a/source/blender/modifiers/intern/MOD_wave.cc +++ b/source/blender/modifiers/intern/MOD_wave.cc @@ -144,8 +144,8 @@ static void waveModifier_do(WaveModifierData *md, if (wmd->objectcenter != nullptr) { float mat[4][4]; /* get the control object's location in local coordinates */ - invert_m4_m4(ob->world_to_object, ob->object_to_world); - mul_m4_m4m4(mat, ob->world_to_object, wmd->objectcenter->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); + mul_m4_m4m4(mat, ob->world_to_object().ptr(), wmd->objectcenter->object_to_world().ptr()); wmd->startx = mat[3][0]; wmd->starty = mat[3][1]; diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.cc b/source/blender/modifiers/intern/MOD_weightvgproximity.cc index b91897a5789..6e100634a5c 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.cc +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.cc @@ -228,9 +228,9 @@ static void get_vert2ob_distance(int verts_num, while (i-- > 0) { /* Get world-coordinates of the vertex (constraints and anim included). */ - mul_v3_m4v3(v_wco, ob->object_to_world, positions[indices ? indices[i] : i]); + mul_v3_m4v3(v_wco, ob->object_to_world().ptr(), positions[indices ? indices[i] : i]); /* Return distance between both coordinates. */ - dist[i] = len_v3v3(v_wco, obr->object_to_world[3]); + dist[i] = len_v3v3(v_wco, obr->object_to_world().location()); } } @@ -240,7 +240,7 @@ static void get_vert2ob_distance(int verts_num, */ static float get_ob2ob_distance(const Object *ob, const Object *obr) { - return len_v3v3(ob->object_to_world[3], obr->object_to_world[3]); + return len_v3v3(ob->object_to_world().location(), obr->object_to_world().location()); } /** diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index 2cdbf1ffda4..78ffb9b705a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -96,7 +96,7 @@ static void node_geo_exec(GeoNodeExecParams params) if (!reset_children) { transform.location() += float3(child_collection->instance_offset); if (use_relative_transform) { - transform = float4x4(self_object->world_to_object) * transform; + transform = self_object->world_to_object() * transform; } else { transform.location() -= float3(collection->instance_offset); @@ -110,12 +110,12 @@ static void node_geo_exec(GeoNodeExecParams params) float4x4 transform = float4x4::identity(); if (!reset_children) { if (use_relative_transform) { - transform = float4x4(self_object->world_to_object); + transform = self_object->world_to_object(); } else { transform.location() -= float3(collection->instance_offset); } - transform *= float4x4(child_object->object_to_world); + transform *= child_object->object_to_world(); } entries.append({handle, &(child_object->id.name[2]), transform}); } @@ -133,7 +133,7 @@ static void node_geo_exec(GeoNodeExecParams params) float4x4 transform = float4x4::identity(); if (use_relative_transform) { transform.location() = collection->instance_offset; - transform = float4x4_view(self_object->world_to_object) * transform; + transform = self_object->world_to_object() * transform; } const int handle = instances->add_reference(*collection); diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index 35bd7c607c2..281c1e182ab 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -54,8 +54,8 @@ static void node_geo_exec(GeoNodeExecParams params) return; } - const float4x4 object_matrix = float4x4(object->object_to_world); - const float4x4 transform = float4x4(self_object->world_to_object) * object_matrix; + const float4x4 object_matrix = object->object_to_world(); + const float4x4 transform = self_object->world_to_object() * object_matrix; float3 location, scale; math::Quaternion rotation; diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc index ac99e1ecfbe..705386a919b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_3d_cursor.cc @@ -30,8 +30,8 @@ static void node_geo_exec(GeoNodeExecParams params) } const View3DCursor &cursor = params.user_data()->call_data->operator_data->scene->cursor; - const float4x4 world_to_object( - params.user_data()->call_data->operator_data->self_object->world_to_object); + const float4x4 world_to_object = + params.user_data()->call_data->operator_data->self_object->world_to_object(); const float3 location_global(cursor.location); params.set_output("Location", math::transform_point(world_to_object, location_global)); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc index 17df7d14fa3..841a5997750 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc @@ -39,7 +39,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, /* Use special matrix to let the shader branch to using the render object's matrix. */ float dummy_matrix[4][4]; dummy_matrix[3][3] = 0.0f; - GPUNodeLink *inv_obmat = (ob != nullptr) ? GPU_uniform(&ob->world_to_object[0][0]) : + GPUNodeLink *inv_obmat = (ob != nullptr) ? GPU_uniform(&ob->world_to_object()[0][0]) : GPU_uniform(&dummy_matrix[0][0]); /* Optimization: don't request orco if not needed. */ diff --git a/source/blender/render/RE_bake.h b/source/blender/render/RE_bake.h index 47c8810dda2..9670ff0d017 100644 --- a/source/blender/render/RE_bake.h +++ b/source/blender/render/RE_bake.h @@ -94,8 +94,8 @@ bool RE_bake_pixels_populate_from_objects(struct Mesh *me_low, bool is_custom_cage, float cage_extrusion, float max_ray_distance, - float mat_low[4][4], - float mat_cage[4][4], + const float mat_low[4][4], + const float mat_cage[4][4], struct Mesh *me_cage); void RE_bake_pixels_populate(struct Mesh *mesh, @@ -130,7 +130,7 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], float result[], struct Mesh *mesh, const eBakeNormalSwizzle normal_swizzle[3], - float mat[4][4]); + const float mat[4][4]); void RE_bake_normal_world_to_world(const BakePixel pixel_array[], size_t pixels_num, int depth, diff --git a/source/blender/render/hydra/camera.cc b/source/blender/render/hydra/camera.cc index 0fcf2c88c63..a62319461b0 100644 --- a/source/blender/render/hydra/camera.cc +++ b/source/blender/render/hydra/camera.cc @@ -80,7 +80,7 @@ pxr::GfCamera gf_camera(const Object *camera_obj, BKE_camera_params_from_object(¶ms, camera_obj); pxr::GfCamera camera = gf_camera(params, res, border); - camera.SetTransform(io::hydra::gf_matrix_from_transform(camera_obj->object_to_world)); + camera.SetTransform(io::hydra::gf_matrix_from_transform(camera_obj->object_to_world().ptr())); return camera; } diff --git a/source/blender/render/hydra/viewport_engine.cc b/source/blender/render/hydra/viewport_engine.cc index 10395ba3cde..c6dcbf5b094 100644 --- a/source/blender/render/hydra/viewport_engine.cc +++ b/source/blender/render/hydra/viewport_engine.cc @@ -65,7 +65,7 @@ ViewSettings::ViewSettings(bContext *context) for (int i = 0; i < 4; i++) { float world_location[] = { camera_points[i][0], camera_points[i][1], camera_points[i][2], 1.0f}; - mul_m4_v4(camera_obj->object_to_world, world_location); + mul_m4_v4(camera_obj->object_to_world().ptr(), world_location); mul_m4_v4(region_data->persmat, world_location); if (world_location[3] > 0.0) { diff --git a/source/blender/render/intern/bake.cc b/source/blender/render/intern/bake.cc index 5466b60680d..1e818968781 100644 --- a/source/blender/render/intern/bake.cc +++ b/source/blender/render/intern/bake.cc @@ -550,8 +550,8 @@ bool RE_bake_pixels_populate_from_objects(Mesh *me_low, const bool is_custom_cage, const float cage_extrusion, const float max_ray_distance, - float mat_low[4][4], - float mat_cage[4][4], + const float mat_low[4][4], + const float mat_cage[4][4], Mesh *me_cage) { size_t i; @@ -855,7 +855,7 @@ void RE_bake_normal_world_to_tangent(const BakePixel pixel_array[], float result[], Mesh *mesh, const eBakeNormalSwizzle normal_swizzle[3], - float mat[4][4]) + const float mat[4][4]) { size_t i; @@ -984,7 +984,7 @@ void RE_bake_normal_world_to_object(const BakePixel pixel_array[], size_t i; float iobmat[4][4]; - invert_m4_m4(iobmat, ob->object_to_world); + invert_m4_m4(iobmat, ob->object_to_world().ptr()); for (i = 0; i < pixels_num; i++) { size_t offset; diff --git a/source/blender/render/intern/texture_pointdensity.cc b/source/blender/render/intern/texture_pointdensity.cc index 1943e990510..903fa01f108 100644 --- a/source/blender/render/intern/texture_pointdensity.cc +++ b/source/blender/render/intern/texture_pointdensity.cc @@ -181,7 +181,7 @@ static void pointdensity_cache_psys( sim.psmd = psys_get_modifier(ob, psys); /* in case ob->world_to_object isn't up-to-date */ - invert_m4_m4(ob->world_to_object, ob->object_to_world); + invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr()); total_particles = psys->totpart + psys->totchild; psys_sim_data_init(&sim); @@ -241,7 +241,7 @@ static void pointdensity_cache_psys( copy_v3_v3(partco, state.co); if (pd->psys_cache_space == TEX_PD_OBJECTSPACE) { - mul_m4_v3(ob->world_to_object, partco); + mul_m4_v3(ob->world_to_object().ptr(), partco); } else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { sub_v3_v3(partco, ob->loc); @@ -404,12 +404,12 @@ static void pointdensity_cache_object(PointDensity *pd, Object *ob) case TEX_PD_OBJECTSPACE: break; case TEX_PD_OBJECTLOC: - mul_m4_v3(ob->object_to_world, co); + mul_m4_v3(ob->object_to_world().ptr(), co); sub_v3_v3(co, ob->loc); break; case TEX_PD_WORLDSPACE: default: - mul_m4_v3(ob->object_to_world, co); + mul_m4_v3(ob->object_to_world().ptr(), co); break; } @@ -785,7 +785,7 @@ static void particle_system_minmax(Depsgraph *depsgraph, sim.psys = psys; sim.psmd = psys_get_modifier(object, psys); - invert_m4_m4(imat, object->object_to_world); + invert_m4_m4(imat, object->object_to_world().ptr()); total_particles = psys->totpart + psys->totchild; psys_sim_data_init(&sim); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.cc b/source/blender/windowmanager/xr/intern/wm_xr_session.cc index 0098d36bcec..4d21d374b67 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.cc +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.cc @@ -180,7 +180,7 @@ static void wm_xr_session_base_pose_calc(const Scene *scene, float tmp_quat[4]; float tmp_eul[3]; - mat4_to_loc_quat(r_base_pose->position, tmp_quat, base_pose_object->object_to_world); + mat4_to_loc_quat(r_base_pose->position, tmp_quat, base_pose_object->object_to_world().ptr()); /* Only use rotation around Z-axis to align view with floor. */ quat_to_eul(tmp_eul, tmp_quat);