From 43c9cba7ddc9372e4c16a47ccbe10785606c15f3 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Wed, 3 Jan 2018 15:12:35 -0600 Subject: [PATCH] Reduce Vector::Element calls in SKdNode::SnapToVertex. NFC. --- src/mesh.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mesh.cpp b/src/mesh.cpp index f7427294..c0304732 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -580,16 +580,20 @@ void SKdNode::SnapToVertex(Vector v, SMesh *extras) { bool mightHit = true; for(k = 0; k < 3; k++) { - if((tr->a).Element(k) < v.Element(k) - KDTREE_EPS && - (tr->b).Element(k) < v.Element(k) - KDTREE_EPS && - (tr->c).Element(k) < v.Element(k) - KDTREE_EPS) + double trA = (tr->a).Element(k); + double trB = (tr->b).Element(k); + double trC = (tr->c).Element(k); + double vk = v.Element(k); + if(trA < vk - KDTREE_EPS && + trB < vk - KDTREE_EPS && + trC < vk - KDTREE_EPS) { mightHit = false; break; } - if((tr->a).Element(k) > v.Element(k) + KDTREE_EPS && - (tr->b).Element(k) > v.Element(k) + KDTREE_EPS && - (tr->c).Element(k) > v.Element(k) + KDTREE_EPS) + if(trA > vk + KDTREE_EPS && + trB > vk + KDTREE_EPS && + trC > vk + KDTREE_EPS) { mightHit = false; break;