diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-08 20:45:06 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-08 20:45:06 +0300 |
commit | 84a4f2ae68d40830111ae41b25d76b165e37d611 (patch) | |
tree | 7139f1aa647987016ce189eecc1dba96c52c51f9 /source/blender/blenlib/intern | |
parent | fc0de69471f0e6a69ae6ffd01ca27156e524ce40 (diff) |
Geometry Nodes: Improve performance of point distribute node
This commit refactors the point distribute node to skip realizing
the instances created by the point instance node or the collection
and object info nodes. Realizing instances is not necessary here
because it copies all the mesh data and and interpolates all
attributes from the instances when this operation does not
need to modify the input geometry at all.
In the tree leaves test file this patch improves the performance of
the node by about 14%. That's not very much, the gain is likely larger
for more complicated input instances with more attributes (especially
attributes on different domains, where interpolation would be necessary
to join all of the instances). Another possible performance improvement
would be to parallelize the code in this node where possible.
The point distribution code unfortunately gets quite a bit more
complicated because it has to handle the complexity of having many
inputs instead of just one.
Note that this commit changes the randomness of the distribution
in some cases, as if the seed input had changed.
Differential Revision: https://developer.blender.org/D10596
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index b460d75d77f..2ada05d2965 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -2140,6 +2140,16 @@ void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3]) } } +void mat4_to_rot(float rot[3][3], const float wmat[4][4]) +{ + normalize_v3_v3(rot[0], wmat[0]); + normalize_v3_v3(rot[1], wmat[1]); + normalize_v3_v3(rot[2], wmat[2]); + if (UNLIKELY(is_negative_m3(rot))) { + negate_m3(rot); + } +} + void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], const float wmat[4][4]) { float mat3[3][3]; /* wmat -> 3x3 */ |