|
virtual void | update ()=0 |
|
virtual bool | intersect (RRRay &ray) const =0 |
|
void | getDistancesFromPoint (const RRVec3 &point, const RRObject *object, bool shadowRays, RRVec2 &distanceMinMax, unsigned numRays=300) const |
|
void | getDistancesFromCamera (const RRCamera &camera, const RRObject *object, bool shadowRays, RRVec2 &distanceMinMax, unsigned numRays=100) const |
|
virtual const RRMesh * | getMesh () const =0 |
|
virtual IntersectTechnique | getTechnique () const =0 |
|
virtual void | setTechnique (IntersectTechnique intersectTechnique, bool &aborting) |
|
virtual size_t | getMemoryOccupied () const =0 |
|
virtual | ~RRCollider () |
|
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) |
|
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) |
|
Finds ray - trianglemesh intersections.
Thread safe: yes, stateless, may be accessed by any number of threads simultaneously.
Mesh passed to create() must stay constant for whole life of collider, otherwise collision results are undefined.
virtual void rr::RRCollider::update |
( |
| ) |
|
|
pure virtual |
Faster alternative to deleting and recreating collider.
When working with single RRMesh, default BVH collider rereads all mesh data (updates fully) while BSP colliders stay unchanged, they don't implement update() yet. When working with RRObject[s], collider rereads object's transformation matrices, but ignores possible changes in triangle meshes (you are responsible for calling collider->update() on colliders that had mesh changed).
virtual bool rr::RRCollider::intersect |
( |
RRRay & |
ray | ) |
const |
|
pure virtual |
Finds ray x mesh intersections.
- Parameters
-
ray | All inputs and outputs for search. |
- Returns
- True if intersection was found and reported into ray.
Finds nearest intersection of ray and mesh in distance <ray->rayLengthMin,ray->rayLengthMax> and fills output attributes in ray specified by ray->rayFlags.
See RRRay for more details on inputs, especially flags that further specify collision test.
When ray->collisionHandler!=nullptr, it is called and it may accept or refuse intersection.
When collisionHandler accepts intersection, true is returned. When collisionHandler rejects intersection, search continues.
False is returned when there were no accepted intersection.
There is an exception for IntersectTechnique IT_LINEAR: intersections are found in random order.
CollisionHandler
Ray->collisionHandler can be used to:
- gather all intersections instead of just first one. CollisionHandler can gather or immediately process them. This is faster and more precise approach than multiple calls of intersect() with increasing rayLengthMin to distance of last intersection.
- not collide with optional parts of mesh (layers) that are turned off at this moment.
- find pixel precise collisions with alpha keyed textures.
- collide with specific probability.
Multithreading
You are encouraged to find multiple intersections in multiple threads at the same time. This will improve your performance on multicore CPUs.
Even with Intel's hyperthreading, which is inferior to two fully-fledged cores, searching multiple intersections at the same time brings surprisingly high performance bonus.
All you need is one RRRay and optionally one RRCollisionHandler for each thread, other structures like RRMesh and RRCollider are stateless and may be accessed by arbitrary number of threads simultaneously.
If you are not familiar with OpenMP, be sure to examine it. With OpenMP, which is built-in feature of modern compilers, searching multiple intersections at the same time is matter of one or few lines of code.