24 #ifdef OPC_RAYHIT_CALLBACK 39 static void AllContacts(
const CollisionFace& hit,
void* user_data)
56 static void ClosestContact(
const CollisionFace& hit,
void* user_data)
103 static void RenderCullingCallback(
const CollisionFace& hit,
void* user_data)
105 CullData* Data = (CullData*)user_data;
108 if(hit.
mDistance>=Data->Closest->mDistance)
return;
113 if(hit.
mDistance<=Data->MinLimit)
return;
122 CullMode CM = (Data->Callback)(StabbedFaceIndex, Data->UserData);
129 Data->IMesh->GetTriangle(VP, StabbedFaceIndex);
140 if(KeepIt) *Data->Closest = hit;
153 picked_face.
mU = 0.0f;
154 picked_face.
mV = 0.0f;
156 Local::CullData Data;
157 Data.Closest = &picked_face;
158 Data.MinLimit = min_dist;
159 Data.Callback = callback;
160 Data.UserData = user_data;
161 Data.ViewPoint = view_point;
171 Data.ViewPoint *= InvWorld;
175 if(RC.
Collide(world_ray, model, world))
OPCODE_API bool SetupAllHits(RayCollider &collider, CollisionFaces &contacts)
#define null
our own NULL pointer
bool Collide(const Ray &world_ray, const Model &model, const Matrix4x4 *world=null, udword *cache=null)
inline_ void SetHitCallback(HitCallback cb)
inline_ void SetMaxDist(float max_dist=MAX_FLOAT)
CullMode(* CullModeCallback)(udword triangle_index, void *user_data)
inline_ void SetTemporalCoherence(bool flag)
OPCODE_API bool SetupShadowFeeler(RayCollider &collider)
OPCODE_API bool SetupClosestHit(RayCollider &collider, CollisionFace &closest_contact)
inline_ void SetFirstContact(bool flag)
unsigned int udword
sizeof(udword) must be 4
OPCODE_API bool SetupInOutTest(RayCollider &collider)
inline_ void AddFace(const CollisionFace &face)
#define MAX_FLOAT
max possible float value
inline_ void SetUserData(void *user_data)
float mV
Impact barycentric coordinates.
float mDistance
Distance from collider to hitpoint.
bool BackfaceCulling(const Point &source)
ICEMATHS_API void InvertPRMatrix(Matrix4x4 &dest, const Matrix4x4 &src)
OPCODE_API bool Picking(CollisionFace &picked_face, const Ray &world_ray, const Model &model, const Matrix4x4 *world, float min_dist, float max_dist, const Point &view_point, CullModeCallback callback, void *user_data)
udword mFaceID
Index of touched face.
#define INVALID_ID
Invalid dword ID (counterpart of null pointers)
inline_ void SetCulling(bool flag)
inline_ const MeshInterface * GetMeshInterface() const