TP_CollisionInterface Struct Reference

#include <c4d_particles.h>

Detailed Description

Callback interface for nodes that register collisions.
The easiest way to create this is to implement the TP_BaseCollision class:
This class is only forward-declared in c4d_particles.h, so as long as the linker approves this is fine.
Example:

{
public:
TP_BaseCollision() { ci.base = this; }
Vector &pos, Vector &vel, TP_Spin &spin, Float dt, Float &ct)
{
// ...
}
};

In the TP_MSG_GET_COLLISIONINTERFACE message then simply set the passed TP_CollisionInterface pointer to &basecol.ci, for a global TP_BaseCollision basecol object that was previously created.
Thinking Particles will then call CheckCollision() as needed.

Public Attributes

TP_BaseCollisionbase
 
Bool(TP_BaseCollision::* CheckCollision )(Int32 collision, TP_MasterSystem *msys, Int32 pid, Float t, Vector &pos, Vector &vel, TP_Spin &spin, Float dt, Float &ct)
 

Member Data Documentation

◆ base

Base class pointer.

◆ CheckCollision

Bool(TP_BaseCollision::* CheckCollision) (Int32 collision, TP_MasterSystem *msys, Int32 pid, Float t, Vector &pos, Vector &vel, TP_Spin &spin, Float dt, Float &ct)

Called by Thinking Particles when a collision handle is registered with TP_MasterSystem::SetCollision(), and provided Thinking Particles with a TP_CollisionInterface in the TP_MSG_GET_COLLISIONINTERFACE message.
Evaluate the passed collision parameters and set the output parameters. Thinking Particles will then update the particle values.

Parameters
[in]collisionThe collision ID. This is GvNode::GetOperatorID() for the node responsible for the collision.
[in]msysThe master system. The caller owns the pointed TP_MasterSystem.
[in]pidThe particle ID: 0 <= pid < msys->NumParticles()
[in]tThe time to evaluate the collision at. Collisions are detected between t - dt and tt.
[out]posAssign the new position of the object if there is a collision.
[out]velAssign the new velocity of the object if there is a collision.
[out]spinAssign the new spin of the object if there is a collision.
[in]dtThe time since the last evaluation, i.e. the time to look backwards for collisions.
[in]ctAssign the collision time, if there was a collision. This will generally be less than t.
Returns
true if there was a collision, otherwise false.