Isis 3 Programmer Reference
|
Bullet ray tracing callback for closest hit on target surface. More...
#include <BulletClosestRayCallback.h>
Public Member Functions | |
BulletClosestRayCallback () | |
Default constructor. More... | |
BulletClosestRayCallback (const BulletClosestRayCallback &result, const btVector3 &point, const btVector3 &normal) | |
Construct a callback from another callback, an intersection point, and a surface normal. More... | |
BulletClosestRayCallback (const btVector3 &observer, const btVector3 &lookdir) | |
Construct a callback from a ray start and end. More... | |
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. More... | |
virtual | ~BulletClosestRayCallback () |
Destory a callback. More... | |
bool | isValid () const |
Checks if the callback is valid/has a valid intersection. More... | |
btVector3 | observer () const |
Return the beginning of the ray. More... | |
btVector3 | lookdir () const |
Return the end of the ray. More... | |
btScalar | fraction () const |
Return the intersection hit fraction or fractional distance along the ray of the intersection. More... | |
btVector3 | point () const |
Return the intersection point, if one exists. More... | |
btVector3 | normal () const |
Return the local surface normal at the intersection, if an intersection exists. More... | |
int | triangleIndex () const |
Return the 0-based index of the intersected triangle. More... | |
int | partId () const |
Return the Bullet ID of the intersected collision object. More... | |
btScalar | distance () const |
Returns the distance from the intersection point to the beginning of the ray. More... | |
btScalar | distance (const BulletClosestRayCallback &other) const |
Returns the distance from the intersection point of this callback to the intersection point of another callback. More... | |
btScalar | distance (const btVector3 &other) const |
Returns the distance from the intersection point to another point. More... | |
bool | operator== (const BulletClosestRayCallback &other) const |
Equality operator to check if this callback is equivalent to another callback. More... | |
bool | isVisible (const BulletClosestRayCallback &other, const btScalar tolerance=DBL_MAX) const |
Check if the intersection in this is visible based on another callback. More... | |
const BulletTargetShape * | body () const |
Return pointer to target shape More... | |
Protected Member Functions | |
virtual btScalar | addSingleResult (btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace) |
! The Bullet ID of the intersected collision object. More... | |
Protected Attributes | |
btVector3 | m_point |
btVector3 | m_normal |
! The intersection point in body fixed (x, y, z) kilometers. More... | |
int | m_triangleIndex |
! The local surface normal at the intersection point in body fixed (x, y, z). More... | |
int | m_partId |
! The 0-based index of the intersected triangle. More... | |
Private Member Functions | |
unsigned int | defaultFlags () const |
Return the default ray cast flags. More... | |
void | copyRayResult (btCollisionWorld::RayResultCallback &dest, const btCollisionWorld::RayResultCallback &source) |
Easy way to copy one callback into another. More... | |
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.
Definition at line 49 of file BulletClosestRayCallback.h.
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 47 of file BulletClosestRayCallback.cpp.
References defaultFlags().
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.
result | The callback to to construct a copy of. The intersection point and normal will not be copied. |
point | The intersection point to store. |
normal | The surface normal to store. |
Definition at line 66 of file BulletClosestRayCallback.cpp.
Isis::BulletClosestRayCallback::BulletClosestRayCallback | ( | const btVector3 & | observer, |
const btVector3 & | lookdir | ||
) |
Construct a callback from a ray start and end.
observer | The beginning of the ray. |
lookdir | The end of the ray. |
Definition at line 83 of file BulletClosestRayCallback.cpp.
References defaultFlags().
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.
observer | The beginning of the ray. |
lookdir | The end of the ray. |
source | The original callback this is being created from. |
rayResult | The local intersection result. |
normalInWorldSpace | Is the normal in the local result in the local coordinate system or the world coordinate system? |
Definition at line 110 of file BulletClosestRayCallback.cpp.
References addSingleResult(), and copyRayResult().
|
virtual |
Destory a callback.
Definition at line 126 of file BulletClosestRayCallback.cpp.
|
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.
rayResult | The local intersection result for the ray cast. |
normalInWorldSpace | If the normal stored in the local result is in local coordinates or world coordinates. |
Definition at line 349 of file BulletClosestRayCallback.cpp.
References m_normal, m_partId, and m_triangleIndex.
Referenced by BulletClosestRayCallback().
const BulletTargetShape * Isis::BulletClosestRayCallback::body | ( | ) | const |
Return pointer to target shape
This method assumes the creators have properly set the user pointer in (at least) the btCollisionObject.
Definition at line 329 of file BulletClosestRayCallback.cpp.
References isValid().
|
private |
Easy way to copy one callback into another.
dest | The callback to copy over. |
source | The callback to copy from. |
Definition at line 381 of file BulletClosestRayCallback.cpp.
Referenced by BulletClosestRayCallback().
|
private |
Return the default ray cast flags.
The flags come from the EFlags enumeration in the Bullet class btTriangleRaycastCallback.
Definition at line 369 of file BulletClosestRayCallback.cpp.
Referenced by BulletClosestRayCallback().
btScalar Isis::BulletClosestRayCallback::distance | ( | ) | const |
Returns the distance from the intersection point to the beginning of the ray.
Definition at line 237 of file BulletClosestRayCallback.cpp.
References isValid(), observer(), and point().
Referenced by distance(), isVisible(), and Isis::BulletShapeModel::sortHits().
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.
other | The other callback to find the distance to. |
Definition at line 254 of file BulletClosestRayCallback.cpp.
btScalar Isis::BulletClosestRayCallback::distance | ( | const btVector3 & | other | ) | const |
Returns the distance from the intersection point to another point.
other | The point to calculate the distance to. |
Definition at line 268 of file BulletClosestRayCallback.cpp.
References distance(), isValid(), and point().
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
Definition at line 173 of file BulletClosestRayCallback.cpp.
bool Isis::BulletClosestRayCallback::isValid | ( | ) | const |
Checks if the callback is valid/has a valid intersection.
Definition at line 136 of file BulletClosestRayCallback.cpp.
Referenced by body(), distance(), Isis::BulletShapeModel::isOccluded(), isVisible(), Isis::BulletShapeModel::isVisibleFrom(), operator==(), and Isis::BulletShapeModel::updateShapeModel().
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.
other | The callback for checking visibility. This should represent the observer's look ray. |
tolerance | The tolerance for the final check of the distance between intersection points. |
Definition at line 307 of file BulletClosestRayCallback.cpp.
References distance(), isValid(), partId(), and triangleIndex().
Referenced by Isis::BulletShapeModel::isVisibleFrom().
btVector3 Isis::BulletClosestRayCallback::lookdir | ( | ) | const |
Return the end of the ray.
Definition at line 156 of file BulletClosestRayCallback.cpp.
btVector3 Isis::BulletClosestRayCallback::normal | ( | ) | const |
Return the local surface normal at the intersection, if an intersection exists.
Definition at line 199 of file BulletClosestRayCallback.cpp.
References _FILEINFO_, m_normal, and Isis::IException::Programmer.
Referenced by BulletClosestRayCallback(), Isis::BulletShapeModel::isOccluded(), Isis::BulletShapeModel::isVisibleFrom(), Isis::BulletShapeModel::setLocalNormalFromIntercept(), and Isis::BulletShapeModel::updateShapeModel().
btVector3 Isis::BulletClosestRayCallback::observer | ( | ) | const |
Return the beginning of the ray.
Definition at line 146 of file BulletClosestRayCallback.cpp.
Referenced by distance().
bool Isis::BulletClosestRayCallback::operator== | ( | const BulletClosestRayCallback & | other | ) | const |
Equality operator to check if this callback is equivalent to another callback.
other | The callback to compare with. |
Definition at line 282 of file BulletClosestRayCallback.cpp.
References isValid(), partId(), and triangleIndex().
int Isis::BulletClosestRayCallback::partId | ( | ) | const |
Return the Bullet ID of the intersected collision object.
Definition at line 226 of file BulletClosestRayCallback.cpp.
References m_partId.
Referenced by isVisible(), and operator==().
btVector3 Isis::BulletClosestRayCallback::point | ( | ) | const |
Return the intersection point, if one exists.
Definition at line 183 of file BulletClosestRayCallback.cpp.
References _FILEINFO_, and Isis::IException::Programmer.
Referenced by BulletClosestRayCallback(), distance(), Isis::BulletShapeModel::isOccluded(), Isis::BulletShapeModel::isVisibleFrom(), Isis::BulletShapeModel::localRadius(), and Isis::BulletShapeModel::updateShapeModel().
int Isis::BulletClosestRayCallback::triangleIndex | ( | ) | const |
Return the 0-based index of the intersected triangle.
Definition at line 216 of file BulletClosestRayCallback.cpp.
References m_triangleIndex.
Referenced by isVisible(), and operator==().
|
protected |
! The intersection point in body fixed (x, y, z) kilometers.
Definition at line 84 of file BulletClosestRayCallback.h.
Referenced by addSingleResult(), BulletClosestRayCallback(), and normal().
|
protected |
! The 0-based index of the intersected triangle.
Definition at line 87 of file BulletClosestRayCallback.h.
Referenced by addSingleResult(), and partId().
|
protected |
! The local surface normal at the intersection point in body fixed (x, y, z).
Definition at line 86 of file BulletClosestRayCallback.h.
Referenced by addSingleResult(), and triangleIndex().