Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rpavlik
Author
Contributor
|
||
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; | ||
|
Here we have to take all the elements before. Previous implementation can be faster because of lazy calculation of boolean expression. If we are faster than previous implementation, then we can be faster even more.