diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-30 06:15:07 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-30 06:15:07 +0300 |
commit | d037fef3bd1dc2e7cbcc2ca40f4164f4e147751f (patch) | |
tree | 4765b33158e164fde6fc1a993f14772f1fe73690 /source | |
parent | f9eaf93d37957fb29eefb720022edd988c540369 (diff) |
Cleanup: Use float4x4 type and constructor
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_point_instance.cc | 5 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_transform.cc | 26 |
2 files changed, 13 insertions, 18 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc index dbbb73bd36d..5d8f0a76719 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc @@ -188,9 +188,8 @@ static void add_instances_from_geometry_component(InstancesComponent &instances, for (const int i : IndexRange(domain_size)) { if (instances_data[i].has_value()) { - float transform[4][4]; - loc_eul_size_to_mat4(transform, positions[i], rotations[i], scales[i]); - instances.add_instance(*instances_data[i], transform, ids[i]); + const float4x4 matrix = float4x4::from_loc_eul_scale(positions[i], rotations[i], scales[i]); + instances.add_instance(*instances_data[i], matrix, ids[i]); } } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_transform.cc b/source/blender/nodes/geometry/nodes/node_geo_transform.cc index d680991cdc2..6213e4ff7d2 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_transform.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_transform.cc @@ -18,7 +18,7 @@ # include <openvdb/openvdb.h> #endif -#include "BLI_math_matrix.h" +#include "BLI_float4x4.hh" #include "DNA_pointcloud_types.h" #include "DNA_volume_types.h" @@ -69,9 +69,8 @@ void transform_mesh(Mesh *mesh, } } else { - float mat[4][4]; - loc_eul_size_to_mat4(mat, translation, rotation, scale); - BKE_mesh_transform(mesh, mat, false); + const float4x4 matrix = float4x4::from_loc_eul_scale(translation, rotation, scale); + BKE_mesh_transform(mesh, matrix.values, false); BKE_mesh_calc_normals(mesh); } } @@ -83,15 +82,15 @@ static void transform_pointcloud(PointCloud *pointcloud, { /* Use only translation if rotation and scale don't apply. */ if (use_translate(rotation, scale)) { - for (int i = 0; i < pointcloud->totpoint; i++) { + for (const int i : IndexRange(pointcloud->totpoint)) { add_v3_v3(pointcloud->co[i], translation); } } else { - float mat[4][4]; - loc_eul_size_to_mat4(mat, translation, rotation, scale); - for (int i = 0; i < pointcloud->totpoint; i++) { - mul_m4_v3(mat, pointcloud->co[i]); + const float4x4 matrix = float4x4::from_loc_eul_scale(translation, rotation, scale); + for (const int i : IndexRange(pointcloud->totpoint)) { + float3 &co = *(float3 *)pointcloud->co[i]; + co = matrix * co; } } } @@ -110,11 +109,9 @@ static void transform_instances(InstancesComponent &instances, } } else { - float mat[4][4]; - - loc_eul_size_to_mat4(mat, translation, rotation, scale); + const float4x4 matrix = float4x4::from_loc_eul_scale(translation, rotation, scale); for (float4x4 &transform : transforms) { - mul_m4_m4_pre(transform.ptr(), mat); + transform = transform * matrix; } } } @@ -136,8 +133,7 @@ static void transform_volume(Volume *volume, Main *bmain = DEG_get_bmain(params.depsgraph()); BKE_volume_load(volume, bmain); - float matrix[4][4]; - loc_eul_size_to_mat4(matrix, translation, rotation, limited_scale); + const float4x4 matrix = float4x4::from_loc_eul_scale(translation, rotation, scale); openvdb::Mat4s vdb_matrix; memcpy(vdb_matrix.asPointer(), matrix, sizeof(float[4][4])); |