27 #include <QScopedPointer> 35 #include "IsisBullet.h" 38 #include "BulletCollision/NarrowPhaseCollision/btRaycastCallback.h" 48 btCollisionWorld::ClosestRayResultCallback(btVector3(0,0,0), btVector3(0,0,0)),
49 m_point(0.0, 0.0, 0.0), m_normal(0.0, 0.0, 0.0),
50 m_triangleIndex(-1), m_partId(-1) {
67 const btVector3 &point,
68 const btVector3 &normal) :
69 btCollisionWorld::ClosestRayResultCallback(result.observer(), result.lookdir()) {
84 const btVector3 &lookdir) :
85 btCollisionWorld::ClosestRayResultCallback(observer, lookdir),
86 m_point(0.0, 0.0, 0.0), m_normal(0.0, 0.0, 0.0),
87 m_triangleIndex(-1), m_partId(-1) {
111 const btVector3 &lookdir,
112 const btCollisionWorld::RayResultCallback &source,
113 btCollisionWorld::LocalRayResult &rayResult,
114 bool normalInWorldSpace) :
115 btCollisionWorld::ClosestRayResultCallback(observer, lookdir),
116 m_point(0.0, 0.0, 0.0), m_normal(0.0, 0.0, 0.0),
117 m_triangleIndex(-1), m_partId(-1) {
147 return ( ClosestRayResultCallback::m_rayFromWorld );
157 return ( ClosestRayResultCallback::m_rayToWorld );
174 return ( RayResultCallback::m_closestHitFraction );
188 "No hits in ray trace so no surface point!",
190 return ( btVector3(0.0, 0.0, 0.0) );
205 "No hits in ray trace so no normal!",
207 return btVector3(0.0, 0.0, 0.0);
238 if ( !
isValid() )
return (DBL_MAX);
269 if ( !
isValid() )
return (DBL_MAX);
308 const btScalar tolerance)
const {
314 if (
distance( other ) > tolerance )
return (
false );
331 return ( static_cast<const BulletTargetShape *> (m_collisionObject->getUserPointer()) );
350 bool normalInWorldSpace) {
351 btScalar hitFraction = ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
353 m_point = m_hitPointWorld;
358 m_partId = rayResult.m_localShapeInfo->m_shapePart;
359 return (hitFraction);
370 return ( (btTriangleRaycastCallback::kF_FilterBackfaces |
371 btTriangleRaycastCallback::kF_KeepUnflippedNormal |
372 btTriangleRaycastCallback::kF_UseGjkConvexCastRaytest) );
382 const btCollisionWorld::RayResultCallback &source) {
btScalar distance() const
Returns the distance from the intersection point to the beginning of the ray.
virtual ~BulletClosestRayCallback()
Destory a callback.
unsigned int defaultFlags() const
Return the default ray cast flags.
const BulletTargetShape * body() const
Return pointer to target shape
int m_partId
! The 0-based index of the intersected triangle.
int m_triangleIndex
! The local surface normal at the intersection point in body fixed (x, y, z).
bool operator==(const BulletClosestRayCallback &other) const
Equality operator to check if this callback is equivalent to another callback.
This error is for when a programmer made an API call that was illegal.
int partId() const
Return the Bullet ID of the intersected collision object.
btVector3 m_normal
! The intersection point in body fixed (x, y, z) kilometers.
btVector3 point() const
Return the intersection point, if one exists.
int triangleIndex() const
Return the 0-based index of the intersected triangle.
btVector3 normal() const
Return the local surface normal at the intersection, if an intersection exists.
#define _FILEINFO_
Macro for the filename and line number.
Bullet ray tracing callback for closest hit on target surface.
void copyRayResult(btCollisionWorld::RayResultCallback &dest, const btCollisionWorld::RayResultCallback &source)
Easy way to copy one callback into another.
btVector3 observer() const
Return the beginning of the ray.
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
! The Bullet ID of the intersected collision object.
btVector3 lookdir() const
Return the end of the ray.
bool isVisible(const BulletClosestRayCallback &other, const btScalar tolerance=DBL_MAX) const
Check if the intersection in this is visible based on another callback.
Namespace for ISIS/Bullet specific routines.
btScalar fraction() const
Return the intersection hit fraction or fractional distance along the ray of the intersection.
bool isValid() const
Checks if the callback is valid/has a valid intersection.
Bullet Target Shape for planetary bodies.
BulletClosestRayCallback()
Default constructor.