Browse Source

added OptimizedCollider.checkInside

Nicolas Cannasse 2 years ago
parent
commit
f5f67c60c5
1 changed files with 7 additions and 2 deletions
  1. 7 2
      h3d/col/Collider.hx

+ 7 - 2
h3d/col/Collider.hx

@@ -21,6 +21,7 @@ class OptimizedCollider extends Collider {
 
 	public var a : Collider;
 	public var b : Collider;
+	public var checkInside : Bool;
 
 	public function new(a, b) {
 		this.a = a;
@@ -28,8 +29,12 @@ class OptimizedCollider extends Collider {
 	}
 
 	public function rayIntersection( r : Ray, bestMatch : Bool ) : Float {
-		if( a.rayIntersection(r, bestMatch) < 0 )
-			return -1;
+		if( a.rayIntersection(r, bestMatch) < 0 ) {
+			if( !checkInside )
+				return -1;
+			if( !a.contains(r.getPoint(0)) )
+				return -1;
+		}
 		return b.rayIntersection(r, bestMatch);
 	}