Reduce Vector::Element calls in SKdNode::SnapToVertex. NFC.

pull/420/head
Ryan Pavlik 2018-01-03 15:12:35 -06:00 committed by whitequark
parent f885daf752
commit 43c9cba7dd
1 changed files with 10 additions and 6 deletions

View File

@ -580,16 +580,20 @@ void SKdNode::SnapToVertex(Vector v, SMesh *extras) {
bool mightHit = true; bool mightHit = true;
for(k = 0; k < 3; k++) { for(k = 0; k < 3; k++) {
if((tr->a).Element(k) < v.Element(k) - KDTREE_EPS && double trA = (tr->a).Element(k);
(tr->b).Element(k) < v.Element(k) - KDTREE_EPS && double trB = (tr->b).Element(k);
(tr->c).Element(k) < v.Element(k) - KDTREE_EPS) 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; mightHit = false;
break; break;
} }
if((tr->a).Element(k) > v.Element(k) + KDTREE_EPS && if(trA > vk + KDTREE_EPS &&
(tr->b).Element(k) > v.Element(k) + KDTREE_EPS && trB > vk + KDTREE_EPS &&
(tr->c).Element(k) > v.Element(k) + KDTREE_EPS) trC > vk + KDTREE_EPS)
{ {
mightHit = false; mightHit = false;
break; break;