Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Public Attributes
btTriangleRaycastCallback Class Reference

#include <btRaycastCallback.h>

Inheritance diagram for btTriangleRaycastCallback:
Inheritance graph
Collaboration diagram for btTriangleRaycastCallback:
Collaboration graph

List of all members.

Public Member Functions

 btTriangleRaycastCallback (const btVector3 &from, const btVector3 &to)
virtual void processTriangle (btVector3 *triangle, int partId, int triangleIndex)
virtual btScalar reportHit (const btVector3 &hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex)=0

Public Attributes

btVector3 m_from
btVector3 m_to
btScalar m_hitFraction

Detailed Description

Definition at line 24 of file btRaycastCallback.h.

Constructor & Destructor Documentation

Definition at line 25 of file btRaycastCallback.cpp.



Member Function Documentation

void btTriangleRaycastCallback::processTriangle ( btVector3 triangle,
int  partId,
int  triangleIndex 
) [virtual]

Implements btTriangleCallback.

Definition at line 36 of file btRaycastCallback.cpp.

       const btVector3 &vert0=triangle[0];
       const btVector3 &vert1=triangle[1];
       const btVector3 &vert2=triangle[2];

       btVector3 v10; v10 = vert1 - vert0 ;
       btVector3 v20; v20 = vert2 - vert0 ;

       btVector3 triangleNormal; triangleNormal = v10.cross( v20 );
       const btScalar dist =;
       btScalar dist_a = ;
       dist_a-= dist;
       btScalar dist_b =;
       dist_b -= dist;

       if ( dist_a * dist_b >= btScalar(0.0) )
              return ; // same sign
       const btScalar proj_length=dist_a-dist_b;
       const btScalar distance = (dist_a)/(proj_length);
       // Now we have the intersection point on the plane, we'll see if it's inside the triangle
       // Add an epsilon as a tolerance for the raycast,
       // in case the ray hits exacly on the edge of the triangle.
       // It must be scaled for the triangle size.
       if(distance < m_hitFraction)

              btScalar edge_tolerance =triangleNormal.length2();             
              edge_tolerance *= btScalar(-0.0001);
              btVector3 point; point.setInterpolate3( m_from, m_to, distance);
                     btVector3 v0p; v0p = vert0 - point;
                     btVector3 v1p; v1p = vert1 - point;
                     btVector3 cp0; cp0 = v0p.cross( v1p );

                     if ( (btScalar)( >=edge_tolerance) 

                            btVector3 v2p; v2p = vert2 -  point;
                            btVector3 cp1;
                            cp1 = v1p.cross( v2p);
                            if ( (btScalar)( >=edge_tolerance) 
                                   btVector3 cp2;
                                   cp2 = v2p.cross(v0p);
                                   if ( (btScalar)( >=edge_tolerance) 

                                          if ( dist_a > 0 )
                                                 m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
                                                 m_hitFraction = reportHit(-triangleNormal,distance,partId,triangleIndex);

Here is the call graph for this function:

virtual btScalar btTriangleRaycastCallback::reportHit ( const btVector3 hitNormalLocal,
btScalar  hitFraction,
int  partId,
int  triangleIndex 
) [pure virtual]

Here is the caller graph for this function:

Member Data Documentation

Definition at line 29 of file btRaycastCallback.h.

Definition at line 32 of file btRaycastCallback.h.

Definition at line 30 of file btRaycastCallback.h.

The documentation for this class was generated from the following files: