[Bf-blender-cvs] [d037fef3bd1] master: Cleanup: Use float4x4 type and constructor

Hans Goudey noreply at git.blender.org
Tue Mar 30 05:15:28 CEST 2021


Commit: d037fef3bd1dc2e7cbcc2ca40f4164f4e147751f
Author: Hans Goudey
Date:   Mon Mar 29 22:15:07 2021 -0500
Branches: master
https://developer.blender.org/rBd037fef3bd1dc2e7cbcc2ca40f4164f4e147751f

Cleanup: Use float4x4 type and constructor

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

M	source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
M	source/blender/nodes/geometry/nodes/node_geo_transform.cc

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

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



More information about the Bf-blender-cvs mailing list