HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_Collider Class Reference

#include <SIM_Collider.h>

+ Inheritance diagram for SIM_Collider:

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...
 

Public Member Functions

 GETSET_DATA_FUNCS_B (SIM_NAME_REVERSEOBJECTROLES, ReverseObjectRoles)
 
bool collideObjects (SIM_Engine &engine, SIM_Object &object, SIM_Object &affector, const SIM_Time &starttime, const SIM_Time &endtime, SIM_ImpactApplyType impactapplytype, int impactflags) const
 
bool 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
 
- Public Member Functions inherited from SIM_Data
const UT_StringHoldergetDataType () const
 
void initialize (const SIM_SubdataBehavior &subdatabehavior)
 
void makeEqual (const SIM_Data *source, const SIM_SubdataBehavior &subdatabehavior)
 
void setParameters (const SIM_Options &parms)
 
void interpolate (const SIM_Data *source1, const SIM_Data *source2, fpreal interp)
 
int64 getMemorySize () const
 
bool getIsAlternateRepresentation () const
 
bool saveToFile (const char *filename, UT_CompressionType compressionType) const
 
bool saveToStream (std::ostream &os, UT_CompressionType compressionType) const
 
void appendFullDataPath (const SIM_Data *subdata, bool useobjectid, UT_String &datapath) const
 
bool loadFromFile (const char *filename)
 
bool loadFromStream (UT_IStream &is, bool skiptype=false)
 
bool getIsOfType (const UT_StringRef &datatype) const
 
const voidgetConstPointerToType (const UT_StringRef &datatype) const
 
voidgetPointerToType (const UT_StringRef &datatype)
 
int getNumSubData () const
 Get the number of sub-data items attached to this data. More...
 
const UT_StringHoldergetSubDataName (int index) const
 Get the name of the sub-data at a particular index location. More...
 
int getSubDataIndex (const SIM_Data *subdata) const
 
bool buildSubDataPath (const SIM_Data *subdata, UT_String &pathto) const
 
const SIM_QuerygetQueryObject () const
 
SIM_OptionsgetUserOptions ()
 
const SIM_OptionsgetConstUserOptions () const
 
long getGuideParmVersion () const
 
void addGuideDep (DEP_MicroNode &src) const
 
virtual bool getGuideGeometryList (const SIM_RootData &root, const char *datapath, const SIM_Time &t, UT_Array< GU_ConstDetailHandle > &detailArray, UT_Array< UT_DMatrix4 > &xformArray) const
 
GU_ConstDetailHandle getGuideGeometry (const SIM_RootData &root, const char *datapath, UT_DMatrix4 &xform, const SIM_Time &t) const
 
void buildGuideOptions (SIM_Options &options, const SIM_Time &time) const
 
SIM_DatagetSubData (int index)
 
const SIM_DatagetConstSubData (int index) const
 
SIM_DatagetNamedSubData (const char *dataname)
 
const SIM_DatagetConstNamedSubData (const char *dataname) const
 
void filterSubData (SIM_DataArray &ncdp, UT_StringArray *names, const SIM_DataFilter &ncfilter, const char *startfrom, const SIM_DataFilter &recursefilter)
 
void filterConstSubData (SIM_ConstDataArray &dp, UT_StringArray *names, const SIM_DataFilter &filter, const char *startfrom, const SIM_DataFilter &recurseFilter) const
 
SIM_DatagetNthSubData (UT_String *name, const SIM_DataFilter &filter, int n, const char *startfrom, const SIM_DataFilter &recurseFilter)
 
const SIM_DatagetNthConstSubData (UT_String *name, const SIM_DataFilter &filter, int n, const char *startfrom, const SIM_DataFilter &recurseFilter) const
 
void forEachSubData (SIM_EachDataCallback &cb, const SIM_DataFilter &filter, const char *startfrom, const SIM_DataFilter &recurseFilter)
 
void forEachConstSubData (SIM_EachDataCallback &cb, const SIM_DataFilter &filter, const char *startfrom, const SIM_DataFilter &recurseFilter) const
 
SIM_DatacreateNamedSubData (const char *dataname, const char *datatype, int creationflags, UT_String *newdatanameptr=NULL)
 
SIM_DatagetOrCreateAlternateRepresentation (const char *dataname, const char *datatype) const
 
void interpolateSubData (const SIM_Data &source1, const SIM_Data &source2, fpreal interp, const SIM_DataFilter &interpdata, const SIM_DataFilter &recurse)
 
void setNamedSubData (const char *dataname, const SIM_Data *data, int setflags)
 
void createUniqueSubDataName (const SIM_Data *subdata, UT_String &dataname) const
 
void removeNamedSubData (const char *dataname)
 Remove some existing sub-data by name. More...
 
void removeSubData (int index)
 Remove some existing sub-data by index. More...
 
void moveNamedSubData (const char *oldname, const char *newname)
 
const UT_GuidgetUniqueId () const
 
long getReferenceCount () const
 
int getCreatorId () const
 Get the ID of the node that created this data. More...
 
OP_NodegetCreatorNode () const
 Use the creator ID to look up the OP_Node that created this data. More...
 
OP_NodegetOwnerNetwork () const
 Look up the owner node of our engine to get the DOP Network pointer. More...
 
const SIM_EnginegetEngine () const
 Get the engine that created us (from our data factory). More...
 
int getCreatorIndex () const
 Get the output index of the creator node that generated this data. More...
 
const SIM_TimegetCreationTime () const
 Get the creation time for this data. More...
 
bool getIsSelected () const
 Get the selected flag for this data. More...
 
void setIsSelected (bool selected) const
 
bool getSelectionRepresentsObject () const
 
void copyCreationInfoFrom (const SIM_Data *source)
 
OP_NodegetNodePathsRelativeTo () const
 
OP_NodegetOPNode (const char *path, bool addinterest) const
 Given a path relative to our creator node, return an OBJ_Node. More...
 
OBJ_NodegetOBJNode (const char *path, bool addinterest) const
 Given a path relative to our creator node, return an OBJ_Node. More...
 
SOP_NodegetSOPNode (const char *path, bool addinterest) const
 Given a path relative to our creator node, return a SOP_Node. More...
 
DOP_NodegetDOPNode (const char *path, bool addinterest) const
 Given a path relative to our creator node, return a DOP_Node. More...
 
COP2_NodegetCOP2Node (const char *path, bool addinterest) const
 Given a path relative to our creator node, return a COP2_Node. More...
 
CHOP_NodegetCHOPNode (const char *path, bool addinterest) const
 Given a path relative to our creator node, return a CHOP_Node. More...
 
void addOPInterest (OP_Node *node) const
 Adds an interest in the specified node to our engine's owner node. More...
 
void addError (const SIM_RootData *root, int errorcode, const char *errorparm, UT_ErrorSeverity severity) const
 Adds an error to our SIM_Engine. More...
 
void makeMemberDataUnique ()
 
virtual void makeMemberDataUniqueSubclass ()
 
- Public Member Functions inherited from SIM_OptionsUser
 SIM_OptionsUser (SIM_Data *owner)
 
virtual ~SIM_OptionsUser ()
 
void optionChanged (const char *name)
 
const SIM_OptionsgetOptions () const
 

Protected Member Functions

 SIM_Collider (const SIM_DataFactory *factory)
 The SIM_Collider constructor. More...
 
 ~SIM_Collider () override
 The SIM_Collider destructor. More...
 
SIM_ImpactsgetObjectImpactData (SIM_Object &object, SIM_ImpactApplyType impactapplytype) const
 
SIM_ImpactsgetAffectorImpactData (SIM_Object &affector, SIM_ImpactApplyType impactapplytype) const
 
bool getAffectorInterpolatedToEndTime () const
 
virtual bool collideObjectsSubclass (SIM_Engine &engine, SIM_Object &object, SIM_Object &affector, const SIM_Time &starttime, const SIM_Time &endtime, SIM_ImpactApplyType impactapplytype, int impactflags) const
 
virtual bool collideObjectsCachedSubclass (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
 
virtual bool getAffectorInterpolatedToEndTimeSubclass () const
 
- Protected Member Functions inherited from SIM_Data
 SIM_Data (const SIM_DataFactory *factory)
 
virtual ~SIM_Data ()
 
void handleModification (int code=-1)
 
void setNeedsToRecalculateMemorySize () const
 
void deleteQueryObjectIfNotBuilding () const
 Deletes the query object for this data, if there is one. More...
 
void deleteGuideObjectIfNotBuilding () const
 Delete the guide geometry for this data, if it exists. More...
 
void initAlternateRepresentation () const
 
void setNeedsInitialization (bool needsinit) const
 Flags an alternate representation subdata as requiring initialization. More...
 
bool getNeedsInitialization () const
 Tests whether an alternate representation requires initialization. More...
 
bool saveOptionPacket (std::ostream &os, const char *name, const SIM_Options *opts) const
 
bool loadOptionPacket (UT_IStream &is, const char *name, SIM_Options *opts) const
 
bool getIsDoingSimplifiedSaveLoad () const
 
void initializeFromParmDefaults ()
 
void setSelectionRepresentsObject (bool representsobject)
 
virtual void setNeedsInitializationSubclass (bool needsinit) const
 
virtual void initializeSubclass ()
 
virtual void makeEqualSubclass (const SIM_Data *source)
 
virtual void saveSubclass (std::ostream &os) const
 
virtual void saveIOSubclass (std::ostream &os, SIM_DataThreadedIO *io) const
 
virtual bool loadSubclass (UT_IStream &is)
 
virtual bool loadIOSubclass (UT_IStream &is, SIM_DataThreadedIO *io)
 
virtual SIM_QuerycreateQueryObjectSubclass () const
 
virtual long getGuideParmVersionSubclass () const
 
virtual SIM_GuidecreateGuideObjectSubclass () const
 
virtual void buildGuideGeometrySubclass (const SIM_RootData &root, const SIM_Options &options, const GU_DetailHandle &gdh, UT_DMatrix4 *xform, const SIM_Time &t) const
 
virtual void setParametersSubclass (const SIM_Options &parms)
 
virtual void setNamedSubDataSubclass (const char *dataname, const SIM_Data *data)
 
virtual void removeNamedSubDataSubclass (const char *dataname)
 
virtual void interpolateSubclass (const SIM_Data *source1, const SIM_Data *source2, fpreal interp)
 
virtual int64 getMemorySizeSubclass () const
 
virtual void handleModificationSubclass (int code)
 
virtual bool getIsAlternateRepresentationSubclass () const
 
virtual void initAlternateRepresentationSubclass (const SIM_Data &)
 
virtual voidgetCastToType (const UT_StringRef &datatype) const
 
virtual const UT_StringHoldergetDataTypeSubclass () const
 
const SIM_DatagetAlternateRepresentationOf () const
 
- Protected Member Functions inherited from SIM_OptionsUser
SIM_OptionsgetOptions ()
 
virtual void optionChangedSubclass (const char *name)
 

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 voidcastConstPointerToType (const SIM_Data *data, const UT_StringRef &datatype)
 
static voidcastPointerToType (SIM_Data *data, const UT_StringRef &datatype)
 
- Static Protected Member Functions inherited from SIM_Data
static const PRM_TemplategetEmptyTemplateList ()
 
static const SIM_DopDescriptiongetEmptyDopDescription ()
 A DOP description that says not to create an automatic DOP. More...
 
static void getDataTypeSuperclasses (UT_StringArray &)
 

Detailed Description

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.

Member Enumeration Documentation

Defines the possible affector types when doing collision detection.

Enumerator
SIM_IMPACTAPPLY_NONE 
SIM_IMPACTAPPLY_ONEWAY 

Don't do any collision detection.

SIM_IMPACTAPPLY_MUTUAL 

Object A gets Impacts from object B.

SIM_IMPACTAPPLY_FEEDBACK 

Object A and B both get Impacts.

Object A gets Impacts, B gets Feedback.

Definition at line 56 of file SIM_Collider.h.

Constructor & Destructor Documentation

SIM_Collider::SIM_Collider ( const SIM_DataFactory factory)
explicitprotected

The SIM_Collider constructor.

SIM_Collider::~SIM_Collider ( )
overrideprotected

The SIM_Collider destructor.

Member Function Documentation

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.

virtual bool SIM_Collider::collideObjectsCachedSubclass ( 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
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.

virtual bool SIM_Collider::collideObjectsSubclass ( SIM_Engine engine,
SIM_Object object,
SIM_Object affector,
const SIM_Time starttime,
const SIM_Time endtime,
SIM_ImpactApplyType  impactapplytype,
int  impactflags 
) const
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.

SIM_Impacts* SIM_Collider::getAffectorImpactData ( SIM_Object affector,
SIM_ImpactApplyType  impactapplytype 
) const
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.

bool SIM_Collider::getAffectorInterpolatedToEndTime ( ) const
protected

Returns true if the collideObjects function should always be called with the affector object interpolated to the endtime. This function just calls getAffectorInterpolatedToEndTimeSubclass().

virtual bool SIM_Collider::getAffectorInterpolatedToEndTimeSubclass ( ) const
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.

SIM_Impacts* SIM_Collider::getObjectImpactData ( SIM_Object object,
SIM_ImpactApplyType  impactapplytype 
) const
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().


The documentation for this class was generated from the following file: