HDK
|
#include <SIM_Impacts.h>
Public Member Functions | |
int | getNumImpacts () const |
Get the number of contacts. More... | |
const UT_Vector3 & | getPosition (int index) const |
const UT_Vector3 & | getNormal (int index) const |
fpreal | getImpulse (int index) const |
Get the collision impulse. More... | |
void | setImpulse (int index, fpreal impulse) |
Set the collision impulse. More... | |
void | removeLastImpact () |
Remove the last impact. More... | |
int | getFlags (int index) const |
Get flags associated with the impact. More... | |
GA_Index | getPointNumber (int index) const |
int | getPrimitiveNumber (int index) const |
fpreal | getPrimitiveU (int index) const |
Get the u coordinate of the primitive where the impact occurred. More... | |
fpreal | getPrimitiveV (int index) const |
Get the v coordinate of the primitive where the impact occurred. More... | |
fpreal | getPrimitiveW (int index) const |
Get the w coordinate of the primitive where the impact occurred. More... | |
int | getOtherObjId (int index) const |
Get the unique id of the other object involved in a contact. More... | |
int | getOtherObjPointNumber (int index) const |
int | getOtherObjPrimitiveNumber (int index) const |
fpreal | getOtherObjPrimitiveU (int index) const |
fpreal | getOtherObjPrimitiveV (int index) const |
fpreal | getOtherObjPrimitiveW (int index) const |
SIM_Time | getTime (int index) const |
Get the estimated time of the collision. More... | |
void | addPositionImpact (const UT_Vector3 &pos, const UT_Vector3 &normal, fpreal impulse, int otherobjid, int otherobjptnum, int otherobjprimnum, fpreal otherobjprimu, fpreal otherobjprimv, fpreal otherobjprimw, const SIM_Time &time, int flags) |
This function adds a new impact at a position in space. More... | |
void | addPointImpact (const UT_Vector3 &pos, const UT_Vector3 &normal, fpreal impulse, int ptnum, int otherobjid, int otherobjptnum, int otherobjprimnum, fpreal otherobjprimu, fpreal otherobjprimv, fpreal otherobjprimw, const SIM_Time &time, int flags) |
void | addPrimitiveImpact (const UT_Vector3 &pos, const UT_Vector3 &normal, fpreal impulse, int primnum, fpreal primu, fpreal primv, fpreal primw, int otherobjid, int otherobjptnum, int otherobjprimnum, fpreal otherobjprimu, fpreal otherobjprimv, fpreal otherobjprimw, const SIM_Time &time, int flags) |
void | mergeImpacts (const SIM_Impacts &src) |
Merge the impacts from another SIM_Impacts data into this one. More... | |
void | mergeImpactsInTimeRange (const SIM_Impacts &src, const SIM_Time &startTime, const SIM_Time &endTime) |
void | keepOnlyImpactsForAffectors (const SIM_ObjectArray &affectors, int thisobjectid, int startindex) |
Public Member Functions inherited from SIM_Data | |
const UT_StringHolder & | getDataType () 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 void * | getConstPointerToType (const UT_StringRef &datatype) const |
void * | getPointerToType (const UT_StringRef &datatype) |
int | getNumSubData () const |
Get the number of sub-data items attached to this data. More... | |
const UT_StringHolder & | getSubDataName (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_Query & | getQueryObject () const |
SIM_Options * | getUserOptions () |
const SIM_Options * | getConstUserOptions () 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_Data * | getSubData (int index) |
const SIM_Data * | getConstSubData (int index) const |
SIM_Data * | getNamedSubData (const char *dataname) |
const SIM_Data * | getConstNamedSubData (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_Data * | getNthSubData (UT_String *name, const SIM_DataFilter &filter, int n, const char *startfrom, const SIM_DataFilter &recurseFilter) |
const SIM_Data * | getNthConstSubData (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_Data * | createNamedSubData (const char *dataname, const char *datatype, int creationflags, UT_String *newdatanameptr=NULL) |
SIM_Data * | getOrCreateAlternateRepresentation (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_Guid & | getUniqueId () const |
long | getReferenceCount () const |
int | getCreatorId () const |
Get the ID of the node that created this data. More... | |
OP_Node * | getCreatorNode () const |
Use the creator ID to look up the OP_Node that created this data. More... | |
OP_Node * | getOwnerNetwork () const |
Look up the owner node of our engine to get the DOP Network pointer. More... | |
const SIM_Engine & | getEngine () 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_Time & | getCreationTime () 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_Node & | getNodePathsRelativeTo () const |
OP_Node * | getOPNode (const char *path, bool addinterest) const |
Given a path relative to our creator node, return an OBJ_Node. More... | |
OBJ_Node * | getOBJNode (const char *path, bool addinterest) const |
Given a path relative to our creator node, return an OBJ_Node. More... | |
SOP_Node * | getSOPNode (const char *path, bool addinterest) const |
Given a path relative to our creator node, return a SOP_Node. More... | |
DOP_Node * | getDOPNode (const char *path, bool addinterest) const |
Given a path relative to our creator node, return a DOP_Node. More... | |
COP2_Node * | getCOP2Node (const char *path, bool addinterest) const |
Given a path relative to our creator node, return a COP2_Node. More... | |
CHOP_Node * | getCHOPNode (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 () |
Static Public Member Functions | |
static UT_Vector3 | getRequiredImpulse (const UT_Vector3 &worldspacepos, const UT_Vector3 &nml, const SIM_Object *obja, GA_Index ptnuma, bool objainfinitemass, const SIM_Object *objb, GA_Index ptnumb, bool objbinfinitemass, fpreal bounce, fpreal friction, fpreal dynamicfrictionmultiplier, fpreal bounceforward, bool usesdfvelocitya=false, bool usepointvelocitya=true, bool usesdfvelocityb=false, bool usepointvelocityb=true) |
static UT_Vector3 | getRequiredImpulse (const UT_DMatrix3 &Ka, const UT_Vector3 &vela, const UT_Vector3 &worldspacepos, const UT_Vector3 &nml, const SIM_Object *objb, GA_Index ptnumb, bool objbinfinitemass, fpreal bounce, fpreal friction, fpreal dynamicfrictionmultiplier, fpreal bounceforward, bool usesdfvelocityb=false, bool usepointvelocityb=true) |
static UT_Vector3 | getRequiredImpulse (const UT_Vector3 &desiredrelvel, const UT_DMatrix3 &Ka, const UT_Vector3 &vela, const UT_DMatrix3 &Kb, const UT_Vector3 &velb, const UT_Vector3 &worldspacepos, const UT_Vector3 &nml, fpreal friction, fpreal dynamicfrictionmultiplier, fpreal bounceforward) |
static void | splitImpulse (const UT_Vector3 &impulse, const UT_Vector3 &normal, fpreal &normalImpulseLength, UT_Vector3 &tangentImpulse) |
Split an impulse into normal and tangential (friction) components. More... | |
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) |
Protected Member Functions | |
SIM_Impacts (const SIM_DataFactory *factory) | |
The SIM_Impacts constructor. More... | |
~SIM_Impacts () override | |
The SIM_Impacts destructor. More... | |
void | initializeSubclass () override |
Clears out all contact information. More... | |
void | makeEqualSubclass (const SIM_Data *source) override |
Copies the contact information from another SIM_Impacts. More... | |
void | saveSubclass (std::ostream &os) const override |
Saves the contact information to a stream. More... | |
bool | loadSubclass (UT_IStream &is) override |
Loads contact information from a stream. More... | |
int64 | getMemorySizeSubclass () const override |
Returns the total memory used by this object. More... | |
SIM_Query * | createQueryObjectSubclass () const override |
Creates a SIM_QueryArrays object to treat impact as a record. More... | |
void | resizeArrays (int numimpacts) |
void | removeImpact (int index) |
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 | saveIOSubclass (std::ostream &os, SIM_DataThreadedIO *io) const |
virtual bool | loadIOSubclass (UT_IStream &is, SIM_DataThreadedIO *io) |
virtual long | getGuideParmVersionSubclass () const |
virtual SIM_Guide * | createGuideObjectSubclass () 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 void | handleModificationSubclass (int code) |
virtual bool | getIsAlternateRepresentationSubclass () const |
virtual void | initAlternateRepresentationSubclass (const SIM_Data &) |
virtual void * | getCastToType (const UT_StringRef &datatype) const |
virtual const UT_StringHolder & | getDataTypeSubclass () const |
const SIM_Data * | getAlternateRepresentationOf () const |
Additional Inherited Members | |
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 class defines a SIM_Data subclass for holding collision information. Each contact is represented by a position in simulation space, a normal to the collision surface, the ids of the objects involved in the contact, and the strength of the impact impulse. Optionally, a friction impulse can also be included with the impact.
Remember your basic physics and the definition of "impulse": I = F * dt = m * dv
Definition at line 85 of file SIM_Impacts.h.
|
explicitprotected |
The SIM_Impacts constructor.
|
overrideprotected |
The SIM_Impacts destructor.
void SIM_Impacts::addPointImpact | ( | const UT_Vector3 & | pos, |
const UT_Vector3 & | normal, | ||
fpreal | impulse, | ||
int | ptnum, | ||
int | otherobjid, | ||
int | otherobjptnum, | ||
int | otherobjprimnum, | ||
fpreal | otherobjprimu, | ||
fpreal | otherobjprimv, | ||
fpreal | otherobjprimw, | ||
const SIM_Time & | time, | ||
int | flags | ||
) |
This function adds a new impact at a position in space and associates it with a particular point.
void SIM_Impacts::addPositionImpact | ( | const UT_Vector3 & | pos, |
const UT_Vector3 & | normal, | ||
fpreal | impulse, | ||
int | otherobjid, | ||
int | otherobjptnum, | ||
int | otherobjprimnum, | ||
fpreal | otherobjprimu, | ||
fpreal | otherobjprimv, | ||
fpreal | otherobjprimw, | ||
const SIM_Time & | time, | ||
int | flags | ||
) |
This function adds a new impact at a position in space.
void SIM_Impacts::addPrimitiveImpact | ( | const UT_Vector3 & | pos, |
const UT_Vector3 & | normal, | ||
fpreal | impulse, | ||
int | primnum, | ||
fpreal | primu, | ||
fpreal | primv, | ||
fpreal | primw, | ||
int | otherobjid, | ||
int | otherobjptnum, | ||
int | otherobjprimnum, | ||
fpreal | otherobjprimu, | ||
fpreal | otherobjprimv, | ||
fpreal | otherobjprimw, | ||
const SIM_Time & | time, | ||
int | flags | ||
) |
This function adds a new impact at a position in space and associates it with a particular primitive and UV coordinate.
|
overrideprotectedvirtual |
Creates a SIM_QueryArrays object to treat impact as a record.
Reimplemented from SIM_Data.
|
overrideprotectedvirtual |
Returns the total memory used by this object.
Reimplemented from SIM_Data.
const UT_Vector3& SIM_Impacts::getNormal | ( | int | index | ) | const |
Get the normal for a particular contact, pointing away from the first object. This value generally represents the normal of the surface at the point of contact. This value is used to determine the direction of the impact force at this contact point.
int SIM_Impacts::getNumImpacts | ( | ) | const |
Get the number of contacts.
Get the unique id of the other object involved in a contact.
Get the point number on the other object involved in the collision. This function may return -1 if the point number is unknown.
Get the primitive number on the other object involved in the collision. This function may return -1 if the primitive number is unknown.
Get the u coordinate of the primitive where the impact occurred on the other object.
Get the v coordinate of the primitive where the impact occurred on the other object.
Get the w coordinate of the primitive where the impact occurred on the other object.
Get the point number involved in the collision. This function may return -1 if the point number is unknown.
const UT_Vector3& SIM_Impacts::getPosition | ( | int | index | ) | const |
Get the position for a particular contact. The position is stored in simulation space.
Get the primitive number involved in the collision. This function may return -1 if the primitive number is unknown.
Get the u coordinate of the primitive where the impact occurred.
Get the v coordinate of the primitive where the impact occurred.
Get the w coordinate of the primitive where the impact occurred.
|
static |
Calculates the impulses that should be applied on objects a and b. The resulting velocity of the specified points on the two objects after applying the impulse should be (-relvel * bounce). Either or both of obja and objb can be null in which case the mass of those objects is considered to be infinite. The ptnum values can be -1 if the world space position should be used to fetch the impulse mass matrix. The dynamicfrictionmultiplier is multiplied by the friction value to get the dynamic friction value. The returned impulse should be applied equally to both objects. Note that the returned impulse may have a normal different than nml. The normal of the returned impulse should be used, as the impact normal, not the original nml. Otherwise the impulse magnitude will be wrong. Also, the output normal properly accounts for friction. However, the returned normal direction will be in the same hemisphere as the passed in normal, so it can be used directly as the impact normal for object a (the passed in normal is the normal on objb).
|
static |
|
static |
|
overrideprotectedvirtual |
Clears out all contact information.
Reimplemented from SIM_Data.
void SIM_Impacts::keepOnlyImpactsForAffectors | ( | const SIM_ObjectArray & | affectors, |
int | thisobjectid, | ||
int | startindex | ||
) |
This is a very special-purpose function used by SIM_Engine. It removes any impacts that are self-impacts or that involve other objects that are not in the supplied object array. It starts the search for removal at the supplied index. This is used to eliminate impact data during feedback iteration so that we don't end up multiply applying impacts on non-feedback objects.
|
overrideprotectedvirtual |
Loads contact information from a stream.
Reimplemented from SIM_Data.
Copies the contact information from another SIM_Impacts.
Reimplemented from SIM_Data.
void SIM_Impacts::mergeImpacts | ( | const SIM_Impacts & | src | ) |
Merge the impacts from another SIM_Impacts data into this one.
void SIM_Impacts::mergeImpactsInTimeRange | ( | const SIM_Impacts & | src, |
const SIM_Time & | startTime, | ||
const SIM_Time & | endTime | ||
) |
Merge only the impacts in the given time range. This is useful for feedback and substepping: it allows merging of feedback impacts from the fullstep end object to a substep object.
Remove a impact! O(n) operation. This is protected because the use of this method is discouraged.
void SIM_Impacts::removeLastImpact | ( | ) |
Remove the last impact.
Helper method for the loadSubclass method to resize all of our member variable arrays.
|
overrideprotectedvirtual |
Saves the contact information to a stream.
Reimplemented from SIM_Data.
|
static |
Split an impulse into normal and tangential (friction) components.