public class CollisionManager extends RenderableCompositeBase implements ScalableUnits, Constrainer, HasAuxState
Because collision handling can be expensive, and also because it is not as accurate as other aspects of the simulation (due largely to its discontinuous nature), it is important to be able to control very precisely how it is applied. The CollisionManager allows collision behavior to be specified through
(a) default collision behaviors between generic collidable groups, and
(b) specific behaviors between pairs of collidables which override the default behaviors.
The CollisionManager maintains:
(1) A set of default behaviors;
(2) A set of override behaviors, which are stored as invisible model components;
(3) A behavior map which describes the collision behavior for every CollidableBody in the MechModel and which is updated on demand;
(4) A set of CollisionHandlers which provides a collision handler for every active collision behavior in the behavior map and which is also updated on demand;
Collidable components can be arranged hierarchically. Any component which is a descendant of a Collidable A is known as a sub-collidable of A (a sub-collidable does not need to be an immediate child; it only need to be a descendant). Within a hierarchy, only the leaf nodes do that actual colliding, and these should be instances of the sub-interface CollidableBody.
Normally collidables within a hierarchy do not collide with each other. The
exception is when either (a) self-collision is specified for one of the
ancestor nodes in the hierarchy, or (b) an explicit collision behavior is
set between members of the hierarchy. If a self-collision behavior is
specified for an ancestor node A, and A is deformable (i.e., its
isDeformable() method returns true
), then that behavior will be
passed on to all pairs of sub-collidables of A for which A's method
allowSelfCollisions() returns true.
When a collision behavior is specified between two collidables A and B that are *not* part of the same hierarchy, then that behavior is imparted to all pairs of leaf-nodes located at or below A and B.
Modifier and Type | Class and Description |
---|---|
static class |
CollisionManager.ColliderType
Specifies the collider that generates contact information between the
two meshes.
|
HasAuxState.StateContext
ModelComponent.NavpanelVisibility
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
static PropertyList |
myProps |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
CollisionManager(MechModel mech) |
Modifier and Type | Method and Description |
---|---|
int |
addBilateralConstraints(SparseBlockMatrix GT,
VectorNd dg,
int numb) |
int |
addFrictionConstraints(SparseBlockMatrix DT,
MechSystem.FrictionInfo[] finfo,
int numf) |
int |
addUnilateralConstraints(SparseBlockMatrix NT,
VectorNd dn,
int numu) |
void |
advanceAuxState(double t0,
double t1)
Called at the very beginning of the time step (in the system's
preadvance() method) to perform any required updating of the component's
state before the application in input probes or controllers.
|
CollisionBehaviorList |
behaviors() |
void |
clear() |
boolean |
clearBehavior(Collidable c0,
Collidable c1)
Implements
MechModel.clearCollisionBehavior(c0,c1) . |
void |
clearBehaviors()
Implements
MechModel.clearCollisionBehaviors() . |
void |
clearCachedData() |
boolean |
clearResponse(Collidable c0,
Collidable c1)
Implements
MechModel.clearCollisionResponse(c0,c1) . |
void |
clearResponses()
Implements
MechModel.clearCollisionResponses() . |
void |
componentChanged(ComponentChangeEvent e)
Notifies this composite component that a change has occured within one or
more of its descendants.
|
RenderProps |
createRenderProps()
Factory method to create render properties appropriate to this object.
|
double |
getAcceleration()
Returns the desired collision acceleration.
|
PropertyMode |
getAccelerationMode() |
CollisionBehavior |
getActingBehavior(Collidable c0,
Collidable c1)
Implements
MechModel.getActingCollisionBehavior() . |
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
void |
getAuxState(DataBuffer data)
Saves state information for this component by adding data to the
supplied DataBuffer.
|
CollisionBehavior |
getBehavior(Collidable c0,
Collidable c1)
Implements
MechModel.getCollisionBehavior(c0,c1) . |
CollisionBehavior |
getBehavior(int idx) |
int |
getBilateralImpulses(VectorNd lam,
int idx) |
int |
getBilateralInfo(MechSystem.ConstraintInfo[] ginfo,
int idx) |
void |
getBilateralSizes(VectorNi sizes) |
boolean |
getBodyFaceContact()
Queries whether body face contact is enabled.
|
PropertyMode |
getBodyFaceContactMode() |
CollisionManager.ColliderType |
getColliderType()
Returns the collider type to be used for determining.
|
PropertyMode |
getColliderTypeMode() |
double |
getCollisionArenaRadius() |
CollisionResponse |
getCollisionResponse(Collidable c0,
Collidable c1)
Implements
MechModel.getCollisionResponse(c0,c1) . |
ColorMapBase |
getColorMap() |
double |
getCompliance()
Gets the contact compliance associated with this behavior.
|
PropertyMode |
getComplianceMode() |
void |
getConstrainedComponents(java.util.List<DynamicComponent> list) |
double |
getContactNormalLen() |
double |
getDamping()
Gets the contact damping associated with this behavior.
|
PropertyMode |
getDampingMode() |
CollisionBehavior |
getDefaultBehavior(Collidable.Group groupA,
Collidable.Group groupB)
Implements for
MechModel#getDefaultCollisionBehavior(groupA,groupB) ; see documentation
for that method. |
static CollisionManager.ColliderType |
getDefaultColliderType() |
double |
getDefaultContactNormalLen() |
double |
getDefaultRigidPointTol() |
double |
getDefaultRigidRegionTol() |
boolean |
getDrawContactNormals() |
PropertyMode |
getDrawContactNormalsMode() |
boolean |
getDrawIntersectionContours() |
PropertyMode |
getDrawIntersectionContoursMode() |
boolean |
getDrawIntersectionFaces() |
PropertyMode |
getDrawIntersectionFacesMode() |
boolean |
getDrawIntersectionPoints() |
PropertyMode |
getDrawIntersectionPointsMode() |
ContactForceBehavior |
getForceBehavior() |
double |
getFriction()
Gets the Coulomb friction coefficient
|
PropertyMode |
getFrictionMode() |
void |
getInitialAuxState(DataBuffer newData,
DataBuffer oldData)
Saves initial state information data for this component by adding data
to the supplied data buffer.
|
ScalarRange |
getPenetrationDepthRange() |
boolean |
getReduceConstraints()
Queries whether constraint reduction is enabled.
|
PropertyMode |
getReduceConstraintsMode() |
CollisionResponse |
getResponse(Collidable c0,
Collidable c1)
Implements
MechModel.getCollisionResponse(c0,c1) . |
CollisionResponse |
getResponse(int idx) |
double |
getRigidPointTol()
Gets the rigid point tolerance associated with this behavior.
|
PropertyMode |
getRigidPointTolMode() |
double |
getRigidRegionTol()
Gets the rigid region tolerance associated with this behavior.
|
PropertyMode |
getRigidRegionTolMode() |
void |
getTopCollidables(java.util.List<Collidable> list) |
int |
getUnilateralImpulses(VectorNd the,
int idx) |
int |
getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo,
int idx) |
void |
getUnilateralSizes(VectorNi sizes) |
void |
initialize() |
int |
maxFrictionConstraintSets() |
int |
numBehaviors() |
int |
numDefaultPairs() |
int |
numResponses() |
void |
prerender(RenderList list)
Called prior to rendering to allow this object to update the internal
state required for rendering (such as by caching rendering coordinates).
|
void |
reduceBilateralConstraints(java.util.ArrayList<CollisionHandler> handlers,
int idx0) |
void |
render(Renderer renderer,
int flags)
Render this object using the functionality of the supplied
Renderer . |
CollisionResponseList |
responses() |
void |
scaleDistance(double s)
Scales all distance coordinates.
|
void |
scaleMass(double s)
Scales all mass units.
|
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
void |
setAcceleration(double acc)
Sets a desired acceleration for collision response which will be used to
automatically compute collision compliance if the specified compliance
(as returned by
getCompliance() ) is zero. |
void |
setAccelerationMode(PropertyMode mode) |
void |
setAuxState(DataBuffer data)
Restores the state for this component by reading from the supplied
data buffer, starting at the current buffer offsets.
|
void |
setBehavior(Collidable c0,
Collidable c1,
CollisionBehavior behavior)
Implements
MechModel.setCollisionBehavior(c0,c1,behavior) ; see documentation for that
method. |
int |
setBilateralImpulses(VectorNd lam,
double h,
int idx) |
void |
setBodyFaceContact(boolean enable)
Enables or disables body face contact.
|
void |
setBodyFaceContactMode(PropertyMode mode) |
void |
setColliderType(CollisionManager.ColliderType ctype)
Set the collider type to be used for determining collisions.
|
void |
setColliderTypeMode(PropertyMode mode) |
void |
setCollisionArenaRadius(double rad) |
void |
setColorMap(ColorMapBase map) |
void |
setCompliance(double c)
Sets the contact compliance associated with this behavior.
|
void |
setComplianceMode(PropertyMode mode) |
void |
setContactNormalLen(double len) |
void |
setDamping(double d)
Sets the contact damping associated with this behavior.
|
void |
setDampingMode(PropertyMode mode) |
void |
setDefaultBehavior(Collidable.Group groupA,
Collidable.Group groupB,
CollisionBehavior behavior)
Implements
MechModel.setDefaultCollisionBehavior(groupA,groupB,behavior) ; see
documentation for that method. |
static void |
setDefaultColliderType(CollisionManager.ColliderType type) |
void |
setDrawContactNormals(boolean enable) |
void |
setDrawContactNormalsMode(PropertyMode mode) |
void |
setDrawIntersectionContours(boolean enable) |
void |
setDrawIntersectionContoursMode(PropertyMode mode) |
void |
setDrawIntersectionFaces(boolean enable) |
void |
setDrawIntersectionFacesMode(PropertyMode mode) |
void |
setDrawIntersectionPoints(boolean enable) |
void |
setDrawIntersectionPointsMode(PropertyMode mode) |
void |
setForceBehavior(ContactForceBehavior fb) |
void |
setFriction(double mu)
Sets the Coulomb friction coefficent
|
void |
setFrictionMode(PropertyMode mode) |
void |
setPenetrationDepthRange(ScalarRange range) |
void |
setReduceConstraints(boolean enable)
Sets whether or not constraint reduction is enabled.
|
void |
setReduceConstraintsMode(PropertyMode mode) |
void |
setResponse(Collidable c0,
Collidable c1,
CollisionResponse response)
Implements
MechModel.setCollisionResponse(c0,c1,response) ; see documentation for that
method. |
void |
setRigidPointTol(double tol)
Sets the rigid point tolerance associated with this behavior.
|
void |
setRigidPointTolMode(PropertyMode mode) |
void |
setRigidRegionTol(double tol)
Sets the rigid region tolerance associated with this behavior.
|
void |
setRigidRegionTolMode(PropertyMode mode) |
int |
setUnilateralImpulses(VectorNd the,
double h,
int idx) |
void |
skipAuxState(DataBuffer data)
Skips over the state information for this component contained
in the supplied data buffer, starting at the current buffer offsets.
|
void |
updateBounds(Vector3d pmin,
Vector3d pmax)
Update the minimum and maximum points for this object.
|
double |
updateConstraints(double t,
int flags) |
void |
zeroImpulses() |
copy, getRenderHints, getRenderProps, getSelection, isSelectable, numSelectionQueriesNeeded, setRenderProps
findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNumberLimit, hasChildren, hasState, hierarchyContainsReferences, indexOf, iterator, numComponents, postscan, setDisplayMode, updateNameMap
checkFlag, checkName, checkNameUniqueness, clearFlag, clone, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, isConnectedToHierarchy, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
getProperty
getChildren, hasChildren
isWritable, write
public static PropertyList myProps
public CollisionManager(MechModel mech)
public static void setDefaultColliderType(CollisionManager.ColliderType type)
public static CollisionManager.ColliderType getDefaultColliderType()
public int numDefaultPairs()
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class ModelComponentBase
public void clear()
public double getCollisionArenaRadius()
public void setCollisionArenaRadius(double rad)
public void setContactNormalLen(double len)
public double getContactNormalLen()
public double getDefaultContactNormalLen()
public double getFriction()
public void setFriction(double mu)
mu
- friction coefficientpublic void setFrictionMode(PropertyMode mode)
public PropertyMode getFrictionMode()
public double getRigidRegionTol()
public void setRigidRegionTol(double tol)
tol
- new rigid region tolerancepublic void setRigidRegionTolMode(PropertyMode mode)
public PropertyMode getRigidRegionTolMode()
public double getDefaultRigidRegionTol()
public double getRigidPointTol()
public void setRigidPointTol(double tol)
tol
- new rigid point tolerancepublic void setRigidPointTolMode(PropertyMode mode)
public PropertyMode getRigidPointTolMode()
public double getDefaultRigidPointTol()
public boolean getReduceConstraints()
public void setReduceConstraints(boolean enable)
enable
- true if constraint reduction should be enabledpublic void setReduceConstraintsMode(PropertyMode mode)
public PropertyMode getReduceConstraintsMode()
public boolean getBodyFaceContact()
setBodyFaceContact(boolean)
for details.public void setBodyFaceContact(boolean enable)
false
, since such contacts can result
in an overconstrained system.enable
- true if body face contact should be enabledpublic void setBodyFaceContactMode(PropertyMode mode)
public PropertyMode getBodyFaceContactMode()
public double getCompliance()
public void setCompliance(double c)
c
- new contact compliancepublic void setComplianceMode(PropertyMode mode)
public PropertyMode getComplianceMode()
public double getDamping()
public void setDamping(double d)
d
- new contact dampingpublic void setDampingMode(PropertyMode mode)
public PropertyMode getDampingMode()
public double getAcceleration()
setAcceleration(double)
.public void setAcceleration(double acc)
getCompliance()
) is zero.
This property is currently experimental and not guaranteed to produce reliable results.
acc
- desired collision accelerationpublic void setAccelerationMode(PropertyMode mode)
public PropertyMode getAccelerationMode()
public boolean getDrawIntersectionContours()
public void setDrawIntersectionContours(boolean enable)
public void setDrawIntersectionContoursMode(PropertyMode mode)
public PropertyMode getDrawIntersectionContoursMode()
public boolean getDrawIntersectionFaces()
public void setDrawIntersectionFaces(boolean enable)
public void setDrawIntersectionFacesMode(PropertyMode mode)
public PropertyMode getDrawIntersectionFacesMode()
public boolean getDrawIntersectionPoints()
public void setDrawIntersectionPoints(boolean enable)
public void setDrawIntersectionPointsMode(PropertyMode mode)
public PropertyMode getDrawIntersectionPointsMode()
public boolean getDrawContactNormals()
public void setDrawContactNormals(boolean enable)
public void setDrawContactNormalsMode(PropertyMode mode)
public PropertyMode getDrawContactNormalsMode()
public void setColorMap(ColorMapBase map)
public ColorMapBase getColorMap()
public void setPenetrationDepthRange(ScalarRange range)
public ScalarRange getPenetrationDepthRange()
public ContactForceBehavior getForceBehavior()
public void setForceBehavior(ContactForceBehavior fb)
public CollisionManager.ColliderType getColliderType()
public void setColliderType(CollisionManager.ColliderType ctype)
ctype
- type new collider typepublic void setColliderTypeMode(PropertyMode mode)
public PropertyMode getColliderTypeMode()
public CollisionBehaviorList behaviors()
public int numBehaviors()
public CollisionBehavior getBehavior(int idx)
public CollisionResponseList responses()
public int numResponses()
public CollisionResponse getResponse(int idx)
public void setDefaultBehavior(Collidable.Group groupA, Collidable.Group groupB, CollisionBehavior behavior)
MechModel.setDefaultCollisionBehavior(groupA,groupB,behavior)
; see
documentation for that method.groupA
- first generic collidable groupgroupB
- second generic collidable groupbehavior
- desired collision behaviorpublic CollisionBehavior getDefaultBehavior(Collidable.Group groupA, Collidable.Group groupB)
MechModel#getDefaultCollisionBehavior(groupA,groupB)
; see documentation
for that method.groupA
- first generic collidable groupgroupB
- second generic collidable grouppublic void setBehavior(Collidable c0, Collidable c1, CollisionBehavior behavior)
MechModel.setCollisionBehavior(c0,c1,behavior)
; see documentation for that
method.c0
- first collidablec1
- second collidablebehavior
- desired collision behaviorpublic CollisionBehavior getBehavior(Collidable c0, Collidable c1)
MechModel.getCollisionBehavior(c0,c1)
. See documentation for that method.c0
- first collidablec1
- second collidablepublic boolean clearBehavior(Collidable c0, Collidable c1)
MechModel.clearCollisionBehavior(c0,c1)
. See documentation for that method.c0
- first collidablec1
- second collidabletrue
if the specific behavior had been set
and was removed for the indicated collidable pair.public void clearBehaviors()
MechModel.clearCollisionBehaviors()
. See documentation for that method.public void setResponse(Collidable c0, Collidable c1, CollisionResponse response)
MechModel.setCollisionResponse(c0,c1,response)
; see documentation for that
method.c0
- first collidablec1
- second collidableresponse
- desired collision responsepublic CollisionResponse getResponse(Collidable c0, Collidable c1)
MechModel.getCollisionResponse(c0,c1)
. See documentation for that method.c0
- first collidablec1
- second collidablepublic boolean clearResponse(Collidable c0, Collidable c1)
MechModel.clearCollisionResponse(c0,c1)
. See documentation for that method.c0
- first collidablec1
- second collidabletrue
if the specific response had been set
and was removed for the indicated collidable pair.public void clearResponses()
MechModel.clearCollisionResponses()
. See documentation for that method.public void getTopCollidables(java.util.List<Collidable> list)
public CollisionBehavior getActingBehavior(Collidable c0, Collidable c1)
MechModel.getActingCollisionBehavior()
.
See documentation for that method.c0
- first collidablec1
- second collidablenull
if no common behavior is found.public CollisionResponse getCollisionResponse(Collidable c0, Collidable c1)
MechModel.getCollisionResponse(c0,c1)
.
See documentation for that method.c0
- first collidable. Must be a specific collidable.c1
- second collidable(s). May be a specific collidable
or a colliable group.public void componentChanged(ComponentChangeEvent e)
CompositeComponentBase
This method should propagate the notification up the component hierarchy
by calling notifyParentOfChange
.
componentChanged
in interface ComponentChangeListener
componentChanged
in interface CompositeComponent
componentChanged
in class CompositeComponentBase
e
- optional argument giving specific information about the changepublic void initialize()
public void clearCachedData()
public void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
write
.scan
in interface ModelComponent
scan
in interface Scannable
scan
in class CompositeComponentBase
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objectsjava.io.IOException
- if an I/O or formatting error occuredpublic void scaleDistance(double s)
ScalableUnits
scaleDistance
in interface ScalableUnits
s
- scaling factorpublic void scaleMass(double s)
ScalableUnits
scaleMass
in interface ScalableUnits
s
- scaling factorpublic void reduceBilateralConstraints(java.util.ArrayList<CollisionHandler> handlers, int idx0)
public double updateConstraints(double t, int flags)
updateConstraints
in interface Constrainer
public void getBilateralSizes(VectorNi sizes)
getBilateralSizes
in interface Constrainer
public int addBilateralConstraints(SparseBlockMatrix GT, VectorNd dg, int numb)
addBilateralConstraints
in interface Constrainer
public int getBilateralInfo(MechSystem.ConstraintInfo[] ginfo, int idx)
getBilateralInfo
in interface Constrainer
public int setBilateralImpulses(VectorNd lam, double h, int idx)
setBilateralImpulses
in interface Constrainer
public int getBilateralImpulses(VectorNd lam, int idx)
getBilateralImpulses
in interface Constrainer
public void zeroImpulses()
zeroImpulses
in interface Constrainer
public void getUnilateralSizes(VectorNi sizes)
getUnilateralSizes
in interface Constrainer
public int addUnilateralConstraints(SparseBlockMatrix NT, VectorNd dn, int numu)
addUnilateralConstraints
in interface Constrainer
public int getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo, int idx)
getUnilateralInfo
in interface Constrainer
public int setUnilateralImpulses(VectorNd the, double h, int idx)
setUnilateralImpulses
in interface Constrainer
public int getUnilateralImpulses(VectorNd the, int idx)
getUnilateralImpulses
in interface Constrainer
public int maxFrictionConstraintSets()
maxFrictionConstraintSets
in interface Constrainer
public int addFrictionConstraints(SparseBlockMatrix DT, MechSystem.FrictionInfo[] finfo, int numf)
addFrictionConstraints
in interface Constrainer
public void getConstrainedComponents(java.util.List<DynamicComponent> list)
getConstrainedComponents
in interface Constrainer
public RenderProps createRenderProps()
HasRenderProps
createRenderProps
in interface HasRenderProps
createRenderProps
in class RenderableCompositeBase
public void updateBounds(Vector3d pmin, Vector3d pmax)
IsRenderable
updateBounds
in interface IsRenderable
updateBounds
in class RenderableCompositeBase
pmin
- minimum pointpmax
- maximum pointpublic void prerender(RenderList list)
IsRenderable
list.addIfVisible (obj);
for each of the objects in question.prerender
in interface IsRenderable
prerender
in class RenderableCompositeBase
list
- list of objects to be renderedpublic void render(Renderer renderer, int flags)
IsRenderable
Renderer
.render
in interface IsRenderable
render
in class RenderableCompositeBase
renderer
- provides the functionality used to perform the rendering.flags
- flags that may be used to control different
aspects of the rendering. Flags are defined in Renderer
and currently include
Renderer.HIGHLIGHT
and
Renderer.SORT_FACES
.public void advanceAuxState(double t0, double t1)
HasAuxState
advanceAuxState
in interface HasAuxState
t0
- beginning time associated with the time step advancet1
- end time associated with the time step advancepublic void skipAuxState(DataBuffer data)
HasAuxState
skipAuxState
in interface HasAuxState
data
- buffer containing the state informationpublic void getAuxState(DataBuffer data)
HasAuxState
getAuxState
in interface HasAuxState
data
- buffer for storing the state values.public void getInitialAuxState(DataBuffer newData, DataBuffer oldData)
HasAuxState
If oldData
is non-null, then this contains
previously stored initial state information (starting at its current
buffer offsets), which should be stored into
newData
in place of the current component state data.
This may only be partially possible if the component's state structure
has changed since oldData
was written.
getInitialAuxState
in interface HasAuxState
newData
- buffer for storing the state values.oldData
- if non-null, contains old state information that should be
written into newData
in place of the current state
information.public void setAuxState(DataBuffer data)
HasAuxState
setAuxState
in interface HasAuxState
data
- buffer containing the state information