public class CollisionManager extends RenderableCompositeBase implements ScalableUnits, Constrainer, HasNumericState
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.
|
ModelComponent.NavpanelVisibility
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
int |
maxNumContourPoints |
static PropertyList |
myProps |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
TRANSPARENT, TWO_DIMENSIONAL
Constructor and Description |
---|
CollisionManager(MechModel mech) |
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, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getStateVersion, hasState
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
public static PropertyList myProps
public int maxNumContourPoints
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 void setContactForceLenScale(double scale)
public double getContactForceLenScale()
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 boolean getDrawContactForces()
public void setDrawContactForces(boolean enable)
public void setDrawContactForcesMode(PropertyMode mode)
public PropertyMode getDrawContactForcesMode()
public void setColorMapInterpolation(Renderer.ColorInterpolation interp)
public Renderer.ColorInterpolation getColorMapInterpolation()
public void setColorMapInterpolationMode(PropertyMode mode)
public PropertyMode getColorMapInterpolationMode()
public CollisionBehavior.ColorMapType getDrawColorMap()
public void setDrawColorMap(CollisionBehavior.ColorMapType type)
public void setDrawColorMapMode(PropertyMode mode)
public PropertyMode getDrawColorMapMode()
public int getColorMapCollidable()
public void setColorMapCollidable(int colNum)
public void setColorMapCollidableMode(PropertyMode mode)
public PropertyMode getColorMapCollidableMode()
public void setColorMap(ColorMapBase map)
public ColorMapBase getColorMap()
public void setColorMapRange(ScalarRange range)
public ScalarRange getColorMapRange()
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<ContactConstraint> bilaterals)
public double updateConstraints(double t, int flags)
Constrainer
>
0 associated with all of them. If no constraints are
presently active, returns -1.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 setBilateralForces(VectorNd lam, double s, int idx)
setBilateralForces
in interface Constrainer
public int getBilateralForces(VectorNd lam, int idx)
getBilateralForces
in interface Constrainer
public void zeroForces()
zeroForces
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 setUnilateralForces(VectorNd the, double s, int idx)
setUnilateralForces
in interface Constrainer
public int getUnilateralForces(VectorNd the, int idx)
getUnilateralForces
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 boolean usesBilateralConstraints()
true
if this collision manager may use bilateral
constraintspublic 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 advanceState(double t0, double t1)
HasNumericState
advanceState
in interface HasNumericState
t0
- beginning time associated with the time step advancet1
- end time associated with the time step advancepublic void getState(DataBuffer data)
HasNumericState
getState
in interface HasNumericState
data
- buffer for storing the state values.public void setState(DataBuffer data)
HasNumericState
setState
in interface HasNumericState
data
- buffer containing the state information