Isis 3 Programmer Reference
Isis::BulletClosestRayCallback Class Reference

Bullet ray tracing callback for closest hit on target surface. More...

#include <BulletClosestRayCallback.h>

Inheritance diagram for Isis::BulletClosestRayCallback:
Inheritance graph
Collaboration diagram for Isis::BulletClosestRayCallback:
Collaboration graph

Public Member Functions

 BulletClosestRayCallback ()
 Default constructor.
 
 BulletClosestRayCallback (const BulletClosestRayCallback &result, const btVector3 &point, const btVector3 &normal)
 Construct a callback from another callback, an intersection point, and a surface normal.
 
 BulletClosestRayCallback (const btVector3 &observer, const btVector3 &lookdir)
 Construct a callback from a ray start and end.
 
 BulletClosestRayCallback (const btVector3 &observer, const btVector3 &lookdir, const btCollisionWorld::RayResultCallback &source, btCollisionWorld::LocalRayResult &rayResult, bool nornmalInWorldSpace)
 This constructor is used to create a single ray hit.
 
virtual ~BulletClosestRayCallback ()
 Destory a callback.
 
bool isValid () const
 Checks if the callback is valid/has a valid intersection.
 
btVector3 observer () const
 Return the beginning of the ray.
 
btVector3 lookdir () const
 Return the end of the ray.
 
btScalar fraction () const
 Return the intersection hit fraction or fractional distance along the ray of the intersection.
 
btVector3 point () const
 Return the intersection point, if one exists.
 
btVector3 normal () const
 Return the local surface normal at the intersection, if an intersection exists.
 
int triangleIndex () const
 Return the 0-based index of the intersected triangle.
 
int partId () const
 Return the Bullet ID of the intersected collision object.
 
btScalar distance () const
 Returns the distance from the intersection point to the beginning of the ray.
 
btScalar distance (const BulletClosestRayCallback &other) const
 Returns the distance from the intersection point of this callback to the intersection point of another callback.
 
btScalar distance (const btVector3 &other) const
 Returns the distance from the intersection point to another point.
 
bool operator== (const BulletClosestRayCallback &other) const
 Equality operator to check if this callback is equivalent to another callback.
 
bool isVisible (const BulletClosestRayCallback &other, const btScalar tolerance=DBL_MAX) const
 Check if the intersection in this is visible based on another callback.
 
const BulletTargetShapebody () const
 @breif Return pointer to target shape
 

Protected Member Functions

virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace)
 ! The Bullet ID of the intersected collision object.
 

Protected Attributes

btVector3 m_point
 
btVector3 m_normal
 ! The intersection point in body fixed (x, y, z) kilometers.
 
int m_triangleIndex
 ! The local surface normal at the intersection point in body fixed (x, y, z).
 
int m_partId
 ! The 0-based index of the intersected triangle.
 

Private Member Functions

unsigned int defaultFlags () const
 Return the default ray cast flags.
 
void copyRayResult (btCollisionWorld::RayResultCallback &dest, const btCollisionWorld::RayResultCallback &source)
 Easy way to copy one callback into another.
 

Detailed Description

Bullet ray tracing callback for closest hit on target surface.

Stores the results of a raycast to find the closest intersection to the start of a ray. If no raycast has been preformed, or a raycast was unsuccessful, then the callback will be flagged as invalid.

Author
2017-03-17 Kris Becker
History
2017-03-17 Kris Becker Original Version

Definition at line 33 of file BulletClosestRayCallback.h.

Constructor & Destructor Documentation

◆ BulletClosestRayCallback() [1/4]

Isis::BulletClosestRayCallback::BulletClosestRayCallback ( )

Default constructor.

The ray beginning and end, intersection point, and normal default to the origin. The triangle index and part ID default to -1.

Definition at line 31 of file BulletClosestRayCallback.cpp.

References defaultFlags().

◆ BulletClosestRayCallback() [2/4]

Isis::BulletClosestRayCallback::BulletClosestRayCallback ( const BulletClosestRayCallback & result,
const btVector3 & point,
const btVector3 & normal )

Construct a callback from another callback, an intersection point, and a surface normal.

Parameters
resultThe callback to to construct a copy of. The intersection point and normal will not be copied.
pointThe intersection point to store.
normalThe surface normal to store.

Definition at line 50 of file BulletClosestRayCallback.cpp.

References m_normal, normal(), and point().

◆ BulletClosestRayCallback() [3/4]

Isis::BulletClosestRayCallback::BulletClosestRayCallback ( const btVector3 & observer,
const btVector3 & lookdir )

Construct a callback from a ray start and end.

Parameters
observerThe beginning of the ray.
lookdirThe end of the ray.

Definition at line 67 of file BulletClosestRayCallback.cpp.

References defaultFlags().

◆ BulletClosestRayCallback() [4/4]

Isis::BulletClosestRayCallback::BulletClosestRayCallback ( const btVector3 & observer,
const btVector3 & lookdir,
const btCollisionWorld::RayResultCallback & source,
btCollisionWorld::LocalRayResult & rayResult,
bool normalInWorldSpace )

This constructor is used to create a single ray hit.

This constructor is intended to be used in a multi-ray hit environment such as the BulletAllRayHitsRayCallback object to provide the same features provided in this single hit object.

Author
2017-03-17 Kris Becker
Parameters
observerThe beginning of the ray.
lookdirThe end of the ray.
sourceThe original callback this is being created from.
rayResultThe local intersection result.
normalInWorldSpaceIs the normal in the local result in the local coordinate system or the world coordinate system?

Definition at line 94 of file BulletClosestRayCallback.cpp.

References addSingleResult(), and copyRayResult().

◆ ~BulletClosestRayCallback()

Isis::BulletClosestRayCallback::~BulletClosestRayCallback ( )
virtual

Destory a callback.

Definition at line 110 of file BulletClosestRayCallback.cpp.

Member Function Documentation

◆ addSingleResult()

btScalar Isis::BulletClosestRayCallback::addSingleResult ( btCollisionWorld::LocalRayResult & rayResult,
bool normalInWorldSpace )
protectedvirtual

! The Bullet ID of the intersected collision object.

Add a local intersection result to this callback during ray casting.

Because this callback only stores the single closest result, this overwrites any currently stored result.

Note
This method is called automatically by btCollisionWorld::rayTest.
Parameters
rayResultThe local intersection result for the ray cast.
normalInWorldSpaceIf the normal stored in the local result is in local coordinates or world coordinates.
Returns
btScalar The hit fraction, fractional distance along the ray, of the intersections

Definition at line 333 of file BulletClosestRayCallback.cpp.

References m_normal, m_partId, and m_triangleIndex.

Referenced by BulletClosestRayCallback().

◆ body()

const BulletTargetShape * Isis::BulletClosestRayCallback::body ( ) const

@breif Return pointer to target shape

This method assumes the creators have properly set the user pointer in (at least) the btCollisionObject.

Author
2017-03-17 Kris Becker
Returns
const BulletClosestRayCallback::BulletTargetShape*

Definition at line 313 of file BulletClosestRayCallback.cpp.

References isValid().

◆ copyRayResult()

void Isis::BulletClosestRayCallback::copyRayResult ( btCollisionWorld::RayResultCallback & dest,
const btCollisionWorld::RayResultCallback & source )
private

Easy way to copy one callback into another.

Parameters
destThe callback to copy over.
sourceThe callback to copy from.

Definition at line 365 of file BulletClosestRayCallback.cpp.

Referenced by BulletClosestRayCallback().

◆ defaultFlags()

unsigned int Isis::BulletClosestRayCallback::defaultFlags ( ) const
private

Return the default ray cast flags.

The flags come from the EFlags enumeration in the Bullet class btTriangleRaycastCallback.

Returns
int The bitwise default flags.

Definition at line 353 of file BulletClosestRayCallback.cpp.

Referenced by BulletClosestRayCallback(), and BulletClosestRayCallback().

◆ distance() [1/3]

btScalar Isis::BulletClosestRayCallback::distance ( ) const

Returns the distance from the intersection point to the beginning of the ray.

Returns
btScalar Distance between observer and point in kilometers. If no intersection exists, then DBL_MAX is returned.

Definition at line 221 of file BulletClosestRayCallback.cpp.

References distance(), isValid(), observer(), and point().

Referenced by distance(), distance(), distance(), isVisible(), and Isis::BulletShapeModel::sortHits().

◆ distance() [2/3]

btScalar Isis::BulletClosestRayCallback::distance ( const btVector3 & other) const

Returns the distance from the intersection point to another point.

Parameters
otherThe point to calculate the distance to.
Returns
btScalar Distance between intersection and point in kilometers. If no intersection exists, then DBL_MAX is returned.

Definition at line 252 of file BulletClosestRayCallback.cpp.

References distance(), isValid(), and point().

◆ distance() [3/3]

btScalar Isis::BulletClosestRayCallback::distance ( const BulletClosestRayCallback & other) const

Returns the distance from the intersection point of this callback to the intersection point of another callback.

Parameters
otherThe other callback to find the distance to.
Returns
btScalar Distance between the intersection point and the other callback's intersection point in kilometers. If this callback or the other callback does not have an intersection, then DBL_MAX is returned.

Definition at line 238 of file BulletClosestRayCallback.cpp.

References distance(), isValid(), and point().

◆ fraction()

btScalar Isis::BulletClosestRayCallback::fraction ( ) const

Return the intersection hit fraction or fractional distance along the ray of the intersection.

This is where along the ray the intersection was found. If the hit fraction is 0, then the intersection was found at the very beginning of the ray. If the hit fraction is 1, then the intersection was found at the very end of the ray. The intersection point can be calculates as:

(1 - hitFraction) * rayStart + hitFraction * rayEnd

Returns
@btScalar The closest intersection hit fraction.

Definition at line 157 of file BulletClosestRayCallback.cpp.

◆ isValid()

bool Isis::BulletClosestRayCallback::isValid ( ) const

Checks if the callback is valid/has a valid intersection.

Returns
bool If there is a valid intersection.
See also
ClosestRayResultCallback::hasHit()

Definition at line 120 of file BulletClosestRayCallback.cpp.

Referenced by body(), distance(), distance(), distance(), Isis::BulletShapeModel::isOccluded(), isVisible(), Isis::BulletShapeModel::isVisibleFrom(), operator==(), and Isis::BulletShapeModel::updateShapeModel().

◆ isVisible()

bool Isis::BulletClosestRayCallback::isVisible ( const BulletClosestRayCallback & other,
const btScalar tolerance = DBL_MAX ) const

Check if the intersection in this is visible based on another callback.

Three things are checked to confirm visibility. First, both callbacks must intersect the same triangle on the same collision object. Second, the angle between this callback's local normal and the vector from the other callback's beginning to this callback's intersection must be less than or equal to 90 degrees. Finally, the distance between the intersections of the two callbacks must be less than the tolerance.

Parameters
otherThe callback for checking visibility. This should represent the observer's look ray.
toleranceThe tolerance for the final check of the distance between intersection points.
Returns
bool If the intersection in this callback is visible.

Definition at line 291 of file BulletClosestRayCallback.cpp.

References distance(), isValid(), partId(), and triangleIndex().

Referenced by Isis::BulletShapeModel::isVisibleFrom().

◆ lookdir()

btVector3 Isis::BulletClosestRayCallback::lookdir ( ) const

Return the end of the ray.

Returns
btVector3 The end of the ray.

Definition at line 140 of file BulletClosestRayCallback.cpp.

◆ normal()

btVector3 Isis::BulletClosestRayCallback::normal ( ) const

Return the local surface normal at the intersection, if an intersection exists.

Returns
btVector3 The local surface normal in body fixed (x, y, z).

Definition at line 183 of file BulletClosestRayCallback.cpp.

References m_normal, and Isis::IException::Programmer.

Referenced by BulletClosestRayCallback(), Isis::BulletShapeModel::isOccluded(), Isis::BulletShapeModel::isVisibleFrom(), Isis::BulletShapeModel::setLocalNormalFromIntercept(), and Isis::BulletShapeModel::updateShapeModel().

◆ observer()

btVector3 Isis::BulletClosestRayCallback::observer ( ) const

Return the beginning of the ray.

Returns
btVector3 The beginning of the ray.

Definition at line 130 of file BulletClosestRayCallback.cpp.

Referenced by distance().

◆ operator==()

bool Isis::BulletClosestRayCallback::operator== ( const BulletClosestRayCallback & other) const

Equality operator to check if this callback is equivalent to another callback.

Parameters
otherThe callback to compare with.
Returns
bool If both callbacks are valid and intersected the same triangle on the same collision body.

Definition at line 266 of file BulletClosestRayCallback.cpp.

References isValid(), partId(), and triangleIndex().

◆ partId()

int Isis::BulletClosestRayCallback::partId ( ) const

Return the Bullet ID of the intersected collision object.

Returns
int The Bullet ID of the intersected collision object.

Definition at line 210 of file BulletClosestRayCallback.cpp.

References m_partId.

Referenced by isVisible(), and operator==().

◆ point()

btVector3 Isis::BulletClosestRayCallback::point ( ) const

Return the intersection point, if one exists.

Returns
btVector3 The intersection point in body fixed (x, y, z) kilometers.

Definition at line 167 of file BulletClosestRayCallback.cpp.

References Isis::IException::Programmer.

Referenced by BulletClosestRayCallback(), distance(), distance(), distance(), Isis::BulletShapeModel::isOccluded(), Isis::BulletShapeModel::isVisibleFrom(), Isis::BulletShapeModel::localRadius(), and Isis::BulletShapeModel::updateShapeModel().

◆ triangleIndex()

int Isis::BulletClosestRayCallback::triangleIndex ( ) const

Return the 0-based index of the intersected triangle.

Returns
int The 0-based index of the intersected triangle.

Definition at line 200 of file BulletClosestRayCallback.cpp.

References m_triangleIndex.

Referenced by isVisible(), and operator==().

Member Data Documentation

◆ m_normal

btVector3 Isis::BulletClosestRayCallback::m_normal
protected

! The intersection point in body fixed (x, y, z) kilometers.

Definition at line 68 of file BulletClosestRayCallback.h.

Referenced by addSingleResult(), BulletClosestRayCallback(), and normal().

◆ m_partId

int Isis::BulletClosestRayCallback::m_partId
protected

! The 0-based index of the intersected triangle.

Definition at line 71 of file BulletClosestRayCallback.h.

Referenced by addSingleResult(), and partId().

◆ m_point

btVector3 Isis::BulletClosestRayCallback::m_point
protected

Definition at line 67 of file BulletClosestRayCallback.h.

◆ m_triangleIndex

int Isis::BulletClosestRayCallback::m_triangleIndex
protected

! The local surface normal at the intersection point in body fixed (x, y, z).

Definition at line 70 of file BulletClosestRayCallback.h.

Referenced by addSingleResult(), and triangleIndex().


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