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:
authorErick Abrahammson <ecke101@gmail.com>2021-06-01 00:03:48 +0300
committerHoward Trickey <howard.trickey@gmail.com>2021-06-01 00:03:48 +0300
commit8180d478e1aefbbe538bd54b42dda388b482abf5 (patch)
tree4574fb0daaaa720a04ed37b9cff119932589f84a /source/blender/blenlib/BLI_mpq3.hh
parent73967e2047b7d46168355a7158cd1c40d20afc4e (diff)
Speedup exact boolean by avoiding some mallocs and frees.
This is from patch D11432 from Erik Abrahamsson. He found that in some mpq3 functions called frequently from loops, passing in buffers for termporary mpq3 values can save substantial time. On my machine, his example in that patch went from 9.48s to 7.50s for the boolean part of the calculation. On his machine, a running time went from 17s to 10.3s.
Diffstat (limited to 'source/blender/blenlib/BLI_mpq3.hh')
-rw-r--r--source/blender/blenlib/BLI_mpq3.hh16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_mpq3.hh b/source/blender/blenlib/BLI_mpq3.hh
index fb5e2b61cdb..b9eda2ad7e1 100644
--- a/source/blender/blenlib/BLI_mpq3.hh
+++ b/source/blender/blenlib/BLI_mpq3.hh
@@ -218,6 +218,15 @@ struct mpq3 {
return a.x * b.x + a.y * b.y + a.z * b.z;
}
+ static mpq_class dot_with_buffer(const mpq3 &a, const mpq3 &b, mpq3 &buffer)
+ {
+ buffer = a;
+ buffer *= b;
+ buffer.x += buffer.y;
+ buffer.x += buffer.z;
+ return buffer.x;
+ }
+
static mpq3 cross(const mpq3 &a, const mpq3 &b)
{
return mpq3(a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]);
@@ -246,6 +255,13 @@ struct mpq3 {
return mpq3::dot(diff, diff);
}
+ static mpq_class distance_squared_with_buffer(const mpq3 &a, const mpq3 &b, mpq3 &buffer)
+ {
+ buffer = a;
+ buffer -= b;
+ return mpq3::dot(buffer, buffer);
+ }
+
static mpq3 interpolate(const mpq3 &a, const mpq3 &b, mpq_class t)
{
mpq_class s = 1 - t;