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:
Diffstat (limited to 'source/blender/blenlib/intern/quadric.c')
-rw-r--r--source/blender/blenlib/intern/quadric.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c
index 0a1ff9f8116..3ad1844cfe1 100644
--- a/source/blender/blenlib/intern/quadric.c
+++ b/source/blender/blenlib/intern/quadric.c
@@ -141,9 +141,14 @@ void BLI_quadric_mul(Quadric *a, const double scalar)
double BLI_quadric_evaluate(const Quadric *q, const double v[3])
{
- return ((q->a2 * v[0] * v[0]) + (q->ab * 2 * v[0] * v[1]) + (q->ac * 2 * v[0] * v[2]) +
- (q->ad * 2 * v[0]) + (q->b2 * v[1] * v[1]) + (q->bc * 2 * v[1] * v[2]) +
- (q->bd * 2 * v[1]) + (q->c2 * v[2] * v[2]) + (q->cd * 2 * v[2]) + (q->d2));
+ const double v00 = v[0] * v[0], v01 = v[0] * v[1], v02 = v[0] * v[2];
+ const double v11 = v[1] * v[1], v12 = v[1] * v[2];
+ const double v22 = v[2] * v[2];
+ return ((q->a2 * v00) + (q->ab * 2 * v01) + (q->ac * 2 * v02) + (q->ad * 2 * v[0]) + /* a */
+ (q->b2 * v11) + (q->bc * 2 * v12) + (q->bd * 2 * v[1]) + /* b */
+ (q->c2 * v22) + (q->cd * 2 * v[2]) + /* c */
+ (q->d2) /* d */
+ );
}
bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon)