Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-12-22 20:04:03 +0300
committerHans Goudey <h.goudey@me.com>2021-12-22 20:04:03 +0300
commit6a71b2af66cf10556b21361cc609d54e45be5e3b (patch)
tree24997a97577fe287f008e5be532610ef88b35ac4 /source/blender/blenlib
parent3579a9e0fcf2f1d8adf0fca17ad829d1b1375d1e (diff)
Mesh: Parallelize bounding box calculation (WIP)
This replaces the single-threaded calculation of mesh min and max positions with a `parallel_reduce` loop. Since the bounding box of a mesh is retrieved quite often (at the end of each evaluation, currently 2(?!) times when leaving edit mode, etc.), this makes for a quite noticeable speedup actually. On my Ryzen 3700x and a 4.2 million vertex mesh, I observed a 4.4x performance increase, from 14 ms to 4.4 ms. I added some methods to `float3` so they would be inlined, but they're also a nice addition, since they're used often anyway. Differential Revision: https://developer.blender.org/D13572
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_float3.hh16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_float3.hh b/source/blender/blenlib/BLI_float3.hh
index 6ee0c4b973b..765f524fb31 100644
--- a/source/blender/blenlib/BLI_float3.hh
+++ b/source/blender/blenlib/BLI_float3.hh
@@ -228,6 +228,22 @@ struct float3 {
return result;
}
+ static float3 min(const float3 &a, const float3 &b)
+ {
+ return {a.x < b.x ? a.x : b.x, a.y < b.y ? a.y : b.y, a.z < b.z ? a.z : b.z};
+ }
+
+ static float3 max(const float3 &a, const float3 &b)
+ {
+ return {a.x > b.x ? a.x : b.x, a.y > b.y ? a.y : b.y, a.z > b.z ? a.z : b.z};
+ }
+
+ static void min_max(const float3 &vector, float3 &min, float3 &max)
+ {
+ min = float3::min(vector, min);
+ max = float3::max(vector, max);
+ }
+
static float3 safe_divide(const float3 &a, const float b)
{
return (b != 0.0f) ? a / b : float3(0.0f);