Back to index

supertuxkart  0.5+dfsg1
Defines | Functions
SphereTriangleDetector.cpp File Reference
#include "LinearMath/btScalar.h"
#include "SphereTriangleDetector.h"
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
#include "BulletCollision/CollisionShapes/btSphereShape.h"

Go to the source code of this file.

Defines

#define MAX_OVERLAP   btScalar(0.)

Functions

btScalar SegmentSqrDistance (const btVector3 &from, const btVector3 &to, const btVector3 &p, btVector3 &nearest)

Define Documentation

#define MAX_OVERLAP   btScalar(0.)

Definition at line 50 of file SphereTriangleDetector.cpp.


Function Documentation

btScalar SegmentSqrDistance ( const btVector3 from,
const btVector3 to,
const btVector3 p,
btVector3 nearest 
)

Definition at line 56 of file SphereTriangleDetector.cpp.

                                                                                                               {
       btVector3 diff = p - from;
       btVector3 v = to - from;
       btScalar t = v.dot(diff);
       
       if (t > 0) {
              btScalar dotVV = v.dot(v);
              if (t < dotVV) {
                     t /= dotVV;
                     diff -= t*v;
              } else {
                     t = 1;
                     diff -= v;
              }
       } else
              t = 0;

       nearest = from + t*v;
       return diff.dot(diff);      
}

Here is the call graph for this function:

Here is the caller graph for this function: