Reversed raytest results when needed
In some cases, native-bullet returns the ray results on a reversed order so it leads to unexpected bugs.
This commit is contained in:
parent
008768f18c
commit
2a44aa4aec
@ -49,6 +49,7 @@ import com.jme3.scene.Spatial;
|
|||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -788,6 +789,11 @@ public class PhysicsSpace {
|
|||||||
public List rayTest(Vector3f from, Vector3f to) {
|
public List rayTest(Vector3f from, Vector3f to) {
|
||||||
List results = new LinkedList();
|
List results = new LinkedList();
|
||||||
rayTest(from, to, results);
|
rayTest(from, to, results);
|
||||||
|
|
||||||
|
if(results.getFirst().getHitFraction() > results.getLast().getHitFraction()) {
|
||||||
|
Collections.reverse(results);
|
||||||
|
}
|
||||||
|
|
||||||
return (List<PhysicsRayTestResult>) results;
|
return (List<PhysicsRayTestResult>) results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user