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
This commit is contained in:
Hans Goudey 2024-02-14 16:14:49 +01:00 committed by Hans Goudey
parent bdd15e827f
commit 1c0f374ec3
282 changed files with 1450 additions and 1329 deletions

View File

@ -211,11 +211,11 @@ Vector<float> visualkey_get_values(PointerRNA *ptr, PropertyRNA *prop)
Object *ob = static_cast<Object *>(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) {

View File

@ -319,7 +319,7 @@ blender::Vector<Base *> 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(

View File

@ -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.

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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<bPoseChannel *>(pose->chanbase.first); pchan != nullptr;

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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<float(*)[3]>(
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;

View File

@ -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;

View File

@ -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());
}
}

View File

@ -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<Light *>(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) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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()))

View File

@ -338,10 +338,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
BKE_displist_free(&ltOb->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;

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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::optional<Bound
if (!bounds) {
return float3(0);
}
const float3 scale = math::to_scale(float4x4(ob->object_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<float3>> 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 (&deg_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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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());
}
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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<rbCollisionShape *>(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<rbRigidBody *>(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());
}
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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],

View File

@ -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())
/** \} */

View File

@ -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);

View File

@ -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<Camera *>(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)) {

View File

@ -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;

View File

@ -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:

View File

@ -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);
}
}

View File

@ -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 */

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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)) {

View File

@ -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);

View File

@ -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();

View File

@ -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) {

View File

@ -83,7 +83,7 @@ void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle)
grid.initialized = true;
grid.updated = true;
grid.surfel_density = static_cast<const ::LightProbe *>(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);

View File

@ -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

View File

@ -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();
}
}

View File

@ -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);

View File

@ -378,27 +378,27 @@ void gpencil_light_pool_populate(GPENCIL_LightPool *lightpool, Object *ob)
float(*mat)[4] = reinterpret_cast<float(*)[4]>(&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));

View File

@ -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);

View File

@ -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<float4x4>(center, Quaternion::identity(), size);
float3 plane_normal;

View File

@ -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);

View File

@ -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;
}

View File

@ -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<bArmature *>(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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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)

View File

@ -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);
}

View File

@ -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))) {

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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<Mesh *>(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) {

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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,

View File

@ -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);

View File

@ -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 {

View File

@ -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);

View File

@ -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))

View File

@ -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);

View File

@ -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)

View File

@ -68,7 +68,7 @@ static Vector<SculptBatch> 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];

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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<EditBonePoint *>(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);

View File

@ -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<bPoseChannel *>(opose->chanbase.first); pchan; pchan = pchann) {

View File

@ -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);

View File

@ -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 */

View File

@ -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 */

View File

@ -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());
}
}
}

View File

@ -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<Curve *>(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;

View File

@ -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<const StrokeElem *>(BLI_mempool_iterstep(&iter)); selem;
@ -453,7 +456,7 @@ static void curve_draw_event_add(wmOperator *op, const wmEvent *event)
CurveDrawData *cdd = static_cast<CurveDrawData *>(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<StrokeElem *>(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 {

View File

@ -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);

Some files were not shown because too many files have changed in this diff Show More