Skip to content

Commit 43c9cba

Browse files
rpavlikwhitequark
authored andcommittedMay 21, 2019
Reduce Vector::Element calls in SKdNode::SnapToVertex. NFC.
1 parent f885daf commit 43c9cba

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎src/mesh.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -580,16 +580,20 @@ void SKdNode::SnapToVertex(Vector v, SMesh *extras) {
580580
bool mightHit = true;
581581

582582
for(k = 0; k < 3; k++) {
583-
if((tr->a).Element(k) < v.Element(k) - KDTREE_EPS &&
584-
(tr->b).Element(k) < v.Element(k) - KDTREE_EPS &&
585-
(tr->c).Element(k) < v.Element(k) - KDTREE_EPS)
583+
double trA = (tr->a).Element(k);
584+
double trB = (tr->b).Element(k);
585+
double trC = (tr->c).Element(k);
Has comments. Original line has comments.
586+
double vk = v.Element(k);
587+
if(trA < vk - KDTREE_EPS &&
588+
trB < vk - KDTREE_EPS &&
589+
trC < vk - KDTREE_EPS)
586590
{
587591
mightHit = false;
588592
break;
589593
}
590-
if((tr->a).Element(k) > v.Element(k) + KDTREE_EPS &&
591-
(tr->b).Element(k) > v.Element(k) + KDTREE_EPS &&
592-
(tr->c).Element(k) > v.Element(k) + KDTREE_EPS)
594+
if(trA > vk + KDTREE_EPS &&
595+
trB > vk + KDTREE_EPS &&
596+
trC > vk + KDTREE_EPS)
593597
{
594598
mightHit = false;
595599
break;

0 commit comments

Comments
 (0)
Please sign in to comment.