LightsprintSDK 2021.08.08
|
#include <RRCollider.h>
Public Types | |
enum | Flags { FILL_DISTANCE =(1<<0) , FILL_POINT3D =(1<<1) , FILL_POINT2D =(1<<2) , FILL_PLANE =(1<<3) , FILL_TRIANGLE =(1<<4) , FILL_SIDE =(1<<5) } |
Public Member Functions | |
RRRay () | |
bool | convertHitFromMultiToSingleObject (const class RRSolver *solver) |
Public Member Functions inherited from rr::RRAligned | |
void * | operator new (std::size_t n) |
void * | operator new[] (std::size_t n) |
void | operator delete (void *p, std::size_t n) |
void | operator delete[] (void *p, std::size_t n) |
Public Member Functions inherited from rr::RRUniformlyAllocated | |
void * | operator new (std::size_t n) |
void * | operator new[] (std::size_t n) |
void | operator delete (void *p, std::size_t n) |
void | operator delete[] (void *p, std::size_t n) |
Static Public Member Functions | |
static RRRay * | create () |
static RRRay * | create (unsigned n) |
Public Attributes | |
RRVec3p | rayOrigin |
RRVec3p | rayDir |
RRReal | rayLengthMin |
RRReal | rayLengthMax |
unsigned | rayFlags |
RRReal | hitDistance |
unsigned | hitTriangle |
RRVec2 | hitPoint2d |
RRVec4 | hitPlane |
RRVec3 | hitPoint3d |
bool | hitFrontSide |
RRVec3 | hitPadding1 |
RRVec2 | hitPadding2 |
RRVec2 | hitPadding3 |
const class RRObject * | hitObject |
RRCollisionHandler * | collisionHandler |
Ray to intersect with object.
Contains all inputs and outputs for RRCollider::intersect(), with all RRVec3/4 aligned for SIMD instructions. Alignment is automatic for all static and local instances on stack (thanks to RR_ALIGNED) and for instances on heap (thanks to RRAligned). If you add ray into your class as a member variable, either dynamically allocate ray (with create()) or statically allocate instances of your class or derive your class from RRAligned, otherwise program might crash due to unaligned data access.
Thread safe: no, holds state, may be accessed by one thread at moment.
enum rr::RRRay::Flags |
rr::RRRay::RRRay | ( | ) |
Initializes 1 RRRay. All is zeroed, all FILL flags on.
|
static |
Creates 1 RRRay. All is zeroed, all FILL flags on. Use delete when no longer needed.
|
static |
Creates array of RRRays. Use delete[] when no longer needed.
bool rr::RRRay::convertHitFromMultiToSingleObject | ( | const class RRSolver * | solver | ) |
If hitObject points to solver's multiobject, this function changes it to individual object. hitTriangle is modified accordingly.
After successful solver->getCollider()->intersect(this), hitObject might point to solver's multiobject. This function checks if it is the case, and modifies hitObject and hitTriangle to point to singleobject, using code similar to hitObject = solver->getStaticObjects()[hitObject->getCollider()->getMesh()->getPreImportTriangle(hitTriangle).object] It is not done automatically, because it is often unnecessary, not doing it makes collider faster.
RRVec3p rr::RRRay::rayOrigin |
In. (-Inf,Inf), ray origin. Never modify last component, it must stay 1.
RRVec3p rr::RRRay::rayDir |
In. <-Inf,Inf>, ray direction. Must be normalized.
RRReal rr::RRRay::rayLengthMin |
In. <0,Inf), test intersection in distances from range <rayLengthMin,rayLengthMax>.
RRReal rr::RRRay::rayLengthMax |
In. <0,Inf), test intersection in distances from range <rayLengthMin,rayLengthMax>.
unsigned rr::RRRay::rayFlags |
InOut. Flags that specify what to find. Additional flags may be set by collision handler.
RRReal rr::RRRay::hitDistance |
Out. Hit distance in object space.
unsigned rr::RRRay::hitTriangle |
Out. Index of triangle (postImport) within object that was hit.
RRVec2 rr::RRRay::hitPoint2d |
Out. Hit coordinate in triangle space defined so that vertex[0]=0,0 vertex[1]=1,0 vertex[2]=0,1. Barycentric/areal coordinates of hit point are 1-hitPoint2d[0]-hitPoint2d[1],hitPoint2d[0],hitPoint2d[1].
RRVec4 rr::RRRay::hitPlane |
Out. Plane of hitTriangle in object space. RRVec3 part is normal, normalized. Result is based on vertex positions rather than normals provided by mesh, so plane is constant for whole triangle.
RRVec3 rr::RRRay::hitPoint3d |
Out. Hit coordinate in object space.
bool rr::RRRay::hitFrontSide |
Out. True = face was hit from the front side.
RRVec3 rr::RRRay::hitPadding1 |
Out. Undefined, never modify.
RRVec2 rr::RRRay::hitPadding2 |
Out. Undefined, never modify.
RRVec2 rr::RRRay::hitPadding3 |
Out. Undefined, never modify.
const class RRObject* rr::RRRay::hitObject |
(In/)Out. If collider was created from RRObjects, intersected object is stored here. If collider was created from RRMesh, hitObject is not modified (but it's good practise to set it before calling intersect(), so that your collision handlers and other code can rely on hitObject being always set). If pointer to multiObject is returned, hitTriangle also points to triangle within multiObject; you can translate both to singleObject using convertHitFromMultiToSingleObject().
RRCollisionHandler* rr::RRRay::collisionHandler |
In. Optional collision handler for user-defined surface behaviour.