HDK
|
#include <SIM_Collider.h>
Public Types | |
enum | SIM_ImpactApplyType { SIM_IMPACTAPPLY_NONE, SIM_IMPACTAPPLY_ONEWAY, SIM_IMPACTAPPLY_MUTUAL, SIM_IMPACTAPPLY_FEEDBACK } |
Defines the possible affector types when doing collision detection. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from SIM_Data | |
static bool | getDataTypeFromFile (const char *filename, UT_String &datatype) |
static bool | getDataTypeFromStream (UT_IStream &is, UT_String &datatype) |
static const void * | castConstPointerToType (const SIM_Data *data, const UT_StringRef &datatype) |
static void * | castPointerToType (SIM_Data *data, const UT_StringRef &datatype) |
Static Protected Member Functions inherited from SIM_Data | |
static const PRM_Template * | getEmptyTemplateList () |
static const SIM_DopDescription * | getEmptyDopDescription () |
A DOP description that says not to create an automatic DOP. More... | |
static void | getDataTypeSuperclasses (UT_StringArray &) |
This is an abstract base class for all colliders. A collider is any class that takes a pair of objects and generated information about how those two objects intersect. See the SIM_Object::getCollider() function for a description of how a solver should determine the right SIM_Collider class to use for a given pair of objects.
Definition at line 34 of file SIM_Collider.h.
Defines the possible affector types when doing collision detection.
Definition at line 56 of file SIM_Collider.h.
|
explicitprotected |
The SIM_Collider constructor.
|
overrideprotected |
The SIM_Collider destructor.
bool SIM_Collider::collideObjects | ( | SIM_Engine & | engine, |
SIM_Object & | object, | ||
SIM_Object & | affector, | ||
const SIM_Time & | starttime, | ||
const SIM_Time & | endtime, | ||
SIM_ImpactApplyType | impactapplytype, | ||
int | impactflags | ||
) | const |
Perform the collision detection for a pair of objects. This function calls the collideObjectsSubclass() function. This also attempts to do collision response.
Preconditions: collideObjects expects that getEngine.getObjectAtTime(object, starttime, true) results in the object that holds the correct geometry and transform for starttime. Similarly, passing in endtime must give an object that holds the correct geometry and transformation for endtime. The same principle applies to the affector. Please note that starttime and endtime may be substep times.
The solver that calls collideObjects may have to create substep objects at t_start and t_end to ensure that these preconditions are met. This is is not always needed for the affector, the affector may belong to a solver that isn't substepping. In that case collideObjects will use the linear interpolations for the affector's geometry and transform.
bool SIM_Collider::collideObjects | ( | SIM_Engine & | engine, |
SIM_Object & | object, | ||
SIM_Object & | affector, | ||
const SIM_Time & | starttime, | ||
const SIM_Time & | endtime, | ||
SIM_ImpactApplyType | impactapplytype, | ||
int | impactflags, | ||
UT_ValArray< SIM_ColliderCacheData * > & | objcachedata, | ||
UT_ValArray< SIM_ColliderCacheData * > & | affectorcachedata | ||
) | const |
This variant of the collider lets you specify a list of cache data. The collider subclasses will search for a cache data they like and use it. If none exists, they will build one and add it to the list. The caller is expected to delete any allocated cachedata.
|
protectedvirtual |
This version will default to invoking the non-cached version of the collider. If this is overridden, you do not need to override collideObjectSubclass.
Reimplemented in SIM_ColliderPoint.
|
protectedvirtual |
Override this method to implement your custom collision detection. This function can access any data on the main object or affector object. It can also add any extra data structures it needs to the object for efficiency (rather than recalculating the extra data each time this function is called).
Reimplemented in RBD_ColliderSDF, and SIM_ColliderNone.
|
protected |
Finds or creates the impact data on the affector that is appropriate for the given affector type. It also takes into account the value of the ReverseObjectRoles flag.
|
protected |
Returns true if the collideObjects function should always be called with the affector object interpolated to the endtime. This function just calls getAffectorInterpolatedToEndTimeSubclass().
|
protectedvirtual |
Returns true if the collideObjects function should always be called with the affector object interpolated to the endtime. The default implementation returns true.
Reimplemented in SIM_ColliderNone.
|
protected |
Finds or creates the impact data on the affector that is appropriate for the given affector type. It also takes into account the value of the ReverseObjectRoles flag.
SIM_Collider::GETSET_DATA_FUNCS_B | ( | SIM_NAME_REVERSEOBJECTROLES | , |
ReverseObjectRoles | |||
) |
Specifies whether the object and affector need to be reversed to perform collision detection. This flag is useful for colliders that make assumptions about the makeup of the object and affector are in the call to collideObjectsSubclass(). For example, the point collider (SIM_ColliderPoint) always treats the object as a particle system, using ray casting to follow the trajectory of each particle. But suppose an RBD Solver has a particle system as an affector object. The RBD Solver would find that the best collider to use is a point collider. Rather than requiring that the RBD Solver then somehow discover that the particle object must always be sent as the "object" parameter, the collider can have the reverse object roles flag turned on. Then when the RBD Solver calls the collider with the RBD object first and the particle object second, the collider itself will reverse the objects before passing them on to collideObjectSubclass().