From 2a44aa4aecccabec6d96ed5f7ea0d4614b967c89 Mon Sep 17 00:00:00 2001 From: NemesisMate Date: Tue, 5 Apr 2016 08:39:53 +0100 Subject: [PATCH] Reversed raytest results when needed In some cases, native-bullet returns the ray results on a reversed order so it leads to unexpected bugs. --- jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index f3575bcdf..88f0fdd6f 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -49,6 +49,7 @@ import com.jme3.scene.Spatial; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -788,6 +789,11 @@ public class PhysicsSpace { public List rayTest(Vector3f from, Vector3f to) { List results = new LinkedList(); rayTest(from, to, results); + + if(results.getFirst().getHitFraction() > results.getLast().getHitFraction()) { + Collections.reverse(results); + } + return (List) results; }