HDK
|
#include <SIM_Impacts.h>
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) |
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.