LightsprintSDK 2021.08.08
rr::RRCollisionHandler Class Referenceabstract

#include <RRCollider.h>

Public Member Functions

virtual ~RRCollisionHandler ()
 
virtual void init (class RRRay &ray)=0
 
virtual bool collides (const class RRRay &ray)=0
 
virtual bool done ()=0
 

Detailed Description

Interface for non-trivial handling of collisions in collision test.

You can use it to

  • intersect mesh that contains singlesided faces
  • intersect mesh with layers that can be independently turned on/off
  • gather all intersections with one mesh

It's intentionally not part of RRMesh, so you can easily combine different collision handlers with one geometry.
It's intentionally not part of RRRay, so you can easily combine different collision handlers at runtime.

Thread safe: no, holds state, may be accessed by one thread at moment.

Constructor & Destructor Documentation

◆ ~RRCollisionHandler()

virtual rr::RRCollisionHandler::~RRCollisionHandler ( )
inlinevirtual

Member Function Documentation

◆ init()

virtual void rr::RRCollisionHandler::init ( class RRRay ray)
pure virtual

Prepares for single intersection test.

Is called at the beginning of RRCollider::intersect(). May set additional flags in ray.

◆ collides()

virtual bool rr::RRCollisionHandler::collides ( const class RRRay ray)
pure virtual

Handles each collision detected by single intersection test.

It is called at each triangle hit inside RRCollider::intersect(). When its result is false, collision is rejected and testing continues. When its result is true, collision is accepted, but it does not necessarily end testing, as collider can find closer itersection after testing more distant one first. In general case, intersections are reported unordered. Intersections are reported in order from the nearest one (and first positive result ends testing) only for IT_BSP techniques.

Returns
Return false if you want to discard intersection and continue testing.

◆ done()

virtual bool rr::RRCollisionHandler::done ( )
pure virtual

Cleans up after single intersection test.

Is called at the end of RRCollider::intersect(). Result is returned as result from RRCollider::intersect().