Voxelyze
|
Defines a potential collision between two voxels. More...
#include <VX_Collision.h>
Public Member Functions | |
CVX_Collision (CVX_Voxel *v1, CVX_Voxel *v2) | |
Constructor taking the two voxels to watch for collision between. The order is irrelevant. | |
CVX_Collision & | operator= (const CVX_Collision &col) |
Overload "=" operator. | |
CVX_Collision (const CVX_Collision &col) | |
copy constructor. | |
Vec3D< float > const | contactForce (CVX_Voxel *pVoxel) |
Returns the repelling force acting on pVoxel from the penetration of the other voxel if their collision boundaries overlap. Otherwise returns a zero force. This force will only be accurate if updateContactForce() has been called since the voxels last moved. | |
void | updateContactForce () |
Updates the state this collision based on the current positions and properties of voxel1() and voxel2(). Call contactForce() with either voxel as the argument to obtain the repelling penetration force (if any) that exisits. | |
CVX_Voxel * | voxel1 () const |
One voxel of this potential collision pair. | |
CVX_Voxel * | voxel2 () const |
The other voxel of this potential collision pair. | |
Static Public Attributes | |
static float | envelopeRadius = 0.625f |
The collision envelope radius that these two voxels collide at. Even though voxels are cubic, a spherical collision envelope is used for computation efficiency. Values are multiplied by the length of an edge of the voxel to determine the actual collision radius. Values less than 0.5 or greater than 0.866 are probably of limited use. Prefer around 0.625 (default). |
Defines a potential collision between two voxels.
A CVX_Collision object is created for two voxels (presumably in close proximity) that are likely to self-intersect. If they don't intersect, no force is present. Otherwise, an appropriate repelling force is calculated here.
Voxels are assumed to have spherical collision boundaries with a radius of CVX_Collision::envelopeRadius * voxel edge dimension. This radius should be slightly larger than 0.5 to prevent voxels from penetrating too far between other voxels.
updateContactForce() is called to calculate the repelling force. This force is retreived by calling contactForce() with an appropriate voxel pointer to return the force (in the global coordinate system) acting on that voxel as a result of this (potential) collision.
CVX_Collision::CVX_Collision | ( | CVX_Voxel * | v1, |
CVX_Voxel * | v2 | ||
) |
Constructor taking the two voxels to watch for collision between. The order is irrelevant.
[in] | v1 | One voxel |
[in] | v2 | The other voxel |
Vec3D< float > const CVX_Collision::contactForce | ( | CVX_Voxel * | pVoxel | ) |
Returns the repelling force acting on pVoxel from the penetration of the other voxel if their collision boundaries overlap. Otherwise returns a zero force. This force will only be accurate if updateContactForce() has been called since the voxels last moved.