fixes in raycasting
authorErwin Coumans <blender@erwincoumans.com>
Mon, 24 Apr 2006 04:58:37 +0000 (04:58 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Mon, 24 Apr 2006 04:58:37 +0000 (04:58 +0000)
extern/bullet/Bullet/NarrowPhaseCollision/SubSimplexConvexCast.cpp
extern/bullet/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsEnvironment.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index a71272552da6d6015c3cf6fd55a97866da8053d2..019b4c3bfcb0a15f3759f7adbf8b016d9f0c94f8 100644 (file)
@@ -54,8 +54,11 @@ bool SubsimplexConvexCast::calcTimeOfImpact(
        //float radius = 0.01f;
 
        SimdScalar lambda = 0.f;
-       SimdVector3 s = rayFromLocalA.getOrigin();
-       SimdVector3 r = rayToLocalA.getOrigin()-rayFromLocalA.getOrigin();
+       //todo: need to verify this:
+       //because of minkowski difference, we need the inverse direction
+       
+       SimdVector3 s = -rayFromLocalA.getOrigin();
+       SimdVector3 r = -(rayToLocalA.getOrigin()-rayFromLocalA.getOrigin());
        SimdVector3 x = s;
        SimdVector3 v;
        SimdVector3 arbitraryPoint = convex->LocalGetSupportingVertex(r);
@@ -120,7 +123,7 @@ bool        SubsimplexConvexCast::calcTimeOfImpact(
        //int numiter = MAX_ITERATIONS - maxIter;
 //     printf("number of iterations: %d", numiter);
        result.m_fraction = lambda;
-       result.m_normal = -n;
+       result.m_normal = n;
 
        return true;
 }
index 4359eeffffeab888d36e9881d9bc6d387d71e0ce..fd4bca40e7fec781c25c4818767740e4087e4ff8 100644 (file)
@@ -508,6 +508,7 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
 
 
 
+
        if (!SimdFuzzyZero(timeStep))
        {
 
@@ -1300,9 +1301,9 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
 
                                ConvexShape* convexShape = (ConvexShape*) body->GetCollisionShape();
                                VoronoiSimplexSolver    simplexSolver;
-                               //SubsimplexConvexCast convexCaster(&pointShape,convexShape,&simplexSolver);
+                               SubsimplexConvexCast convexCaster(&pointShape,convexShape,&simplexSolver);
                                //GjkConvexCast convexCaster(&pointShape,convexShape,&simplexSolver);
-                               ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
+                               //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
                                
                                if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,body->getCenterOfMassTransform(),body->getCenterOfMassTransform(),rayResult))
                                {
index 4359eeffffeab888d36e9881d9bc6d387d71e0ce..fd4bca40e7fec781c25c4818767740e4087e4ff8 100644 (file)
@@ -508,6 +508,7 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
 
 
 
+
        if (!SimdFuzzyZero(timeStep))
        {
 
@@ -1300,9 +1301,9 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
 
                                ConvexShape* convexShape = (ConvexShape*) body->GetCollisionShape();
                                VoronoiSimplexSolver    simplexSolver;
-                               //SubsimplexConvexCast convexCaster(&pointShape,convexShape,&simplexSolver);
+                               SubsimplexConvexCast convexCaster(&pointShape,convexShape,&simplexSolver);
                                //GjkConvexCast convexCaster(&pointShape,convexShape,&simplexSolver);
-                               ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
+                               //ContinuousConvexCollision convexCaster(&pointShape,convexShape,&simplexSolver,0);
                                
                                if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,body->getCenterOfMassTransform(),body->getCenterOfMassTransform(),rayResult))
                                {