public abstract class CollisionShape extends NativePhysicsObject
btCollisionShape.
Subclasses include ConvexShape and MeshCollisionShape. As
suggested in the Bullet manual, a single collision shape can be shared among
multiple collision objects.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
enableContactFilter
copy of the contact-filter enable flag
|
static java.util.logging.Logger |
logger
message logger for this class
|
protected float |
margin
copy of collision margin (in physics-space units, >0, default=0.04)
|
protected Vector3f |
scale
copy of the scale factors, one for each local axis
|
loggerN| Modifier | Constructor and Description |
|---|---|
protected |
CollisionShape()
Instantiate a collision shape with no tracker and no assigned native
object.
|
| Modifier and Type | Method and Description |
|---|---|
Vector3f |
aabbCenter(Vector3f storeResult)
Return the center of the shape's axis-aligned bounding box in local
coordinates.
|
BoundingBox |
boundingBox(Vector3f translation,
Matrix3f rotation,
BoundingBox storeResult)
Calculate an axis-aligned bounding box with the specified translation and
rotation applied.
|
BoundingBox |
boundingBox(Vector3f translation,
Quaternion rotation,
BoundingBox storeResult)
Calculate an axis-aligned bounding box with the specified translation and
rotation applied.
|
boolean |
canScale(Vector3f scale)
Test whether the specified scale factors can be applied to the shape.
|
boolean |
canSplit()
Test whether the shape can be split by an arbitrary plane.
|
static float |
getDefaultMargin()
Return the default margin for new shapes that are neither capsules nor
spheres.
|
float |
getMargin()
Return the collision margin for this shape.
|
Vector3f |
getScale(Vector3f storeResult)
Copy the scale factors.
|
Vec3d |
getScaleDp(Vec3d storeResult)
Copy the scale factors.
|
int |
getShapeType()
Return the encoded type of the shape.
|
protected static int |
getShapeType(long shapeId)
Return the type of this shape.
|
boolean |
isConcave()
Test whether the shape has concave type.
|
boolean |
isContactFilterEnabled()
Test whether contact filtering is enabled for this shape.
|
boolean |
isConvex()
Test whether the shape has convex type.
|
boolean |
isInfinite()
Test whether the shape's type is infinite.
|
boolean |
isNonMoving()
Test whether the shape can be applied to a dynamic rigid body.
|
boolean |
isPolyhedral()
Test whether this shape is convex and defined by polygons.
|
float |
maxRadius()
Estimate how far the scaled shape extends from its center, including
margin.
|
protected float |
nativeMargin()
Return the native collision margin of this shape.
|
protected void |
recalculateAabb()
Recalculate this shape's bounding box if necessary.
|
float |
scaledVolume()
Estimate the volume of this shape, including scale and margin.
|
void |
setContactFilterEnabled(boolean setting)
Enable/disable contact filtering for this shape.
|
static void |
setDefaultMargin(float margin)
Alter the default margin for new shapes that are neither capsules nor
spheres.
|
void |
setMargin(float margin)
Alter the collision margin of this shape.
|
protected void |
setNativeId(long shapeId)
Initialize the native ID.
|
void |
setScale(float factor)
Alter the scale of this shape to a uniform factor.
|
void |
setScale(Vector3f scale)
Alter the scale of this shape.
|
void |
setUserIndex(int index)
Alter the primary user index.
|
void |
setUserIndex2(int index)
Alter the secondary user index.
|
CollisionShape |
toSplittableShape()
Approximate this shape with a splittable shape.
|
java.lang.String |
toString()
Represent this CollisionShape as a String.
|
protected void |
updateScale()
Synchronize the copied scale factors with the
btCollisionShape. |
int |
userIndex()
Return the primary user index (native field: m_userIndex).
|
int |
userIndex2()
Return the secondary user index (native field: m_userIndex2).
|
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeIdNotTracked, unassignNativeObjectpublic static final java.util.logging.Logger logger
protected boolean enableContactFilter
protected float margin
protected Vector3f scale
protected CollisionShape()
This no-arg constructor was made explicit to avoid javadoc warnings from JDK 18+.
public Vector3f aabbCenter(Vector3f storeResult)
storeResult - storage for the result (modified if not null)storeResult or a new vector)public BoundingBox boundingBox(Vector3f translation, Matrix3f rotation, BoundingBox storeResult)
translation - the translation to apply (not null, unaffected)rotation - the rotation to apply (not null, unaffected)storeResult - storage for the result (modified if not null)public BoundingBox boundingBox(Vector3f translation, Quaternion rotation, BoundingBox storeResult)
translation - the translation to apply (not null, unaffected)rotation - the rotation to apply (not null, unaffected)storeResult - storage for the result (modified if not null)public boolean canScale(Vector3f scale)
scale - the desired scale factor for each local axis (may be null,
unaffected)public boolean canSplit()
public static float getDefaultMargin()
public float getMargin()
public Vector3f getScale(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public Vec3d getScaleDp(Vec3d storeResult)
storeResult - storage for the result (modified if not null)storeResult
or a new vector, not null, no negative component)public int getShapeType()
enum BroadphaseNativeTypes)public boolean isConcave()
The only concave types are the empty, gimpact, heightfield, mesh, and plane shapes. Note that compound shapes are neither concave nor convex.
public boolean isContactFilterEnabled()
public boolean isConvex()
Convex types include the box2d, box, capsule, cone, convex2d, cylinder, hull, multi-sphere, simplex, and sphere shapes. Note that compound shapes are neither concave nor convex.
public boolean isInfinite()
PlaneCollisionShape is
the only type of shape that's infinite.public boolean isNonMoving()
public boolean isPolyhedral()
public float maxRadius()
public float scaledVolume()
public void setContactFilterEnabled(boolean setting)
setting - the desired setting (default=false)public static void setDefaultMargin(float margin)
margin - the desired margin thickness (in physics-space units,
>0, default=0.04)public void setMargin(float margin)
From Bullet manual:
It is best not to modify the default collision margin, and if you do use
a positive value: zero margin might introduce problems.
Note that if the shape is shared (between collision objects and/or compound shapes) changes can have unintended consequences.
margin - the desired margin thickness (in physics-space units,
>0, default=0.04)public void setScale(float factor)
Note that if the shape is shared (between collision objects and/or compound shapes) changes can have unintended consequences.
factor - the desired scale factor for all axes (≥0, default=1)public void setScale(Vector3f scale)
Note that if the shape is shared (between collision objects and/or compound shapes) changes can have unintended consequences.
scale - the desired scale factor for each local axis (not null, no
negative component, unaffected, default=(1,1,1))public void setUserIndex(int index)
index - the desired value (default=-1)public void setUserIndex2(int index)
index - the desired value (default=-1)public CollisionShape toSplittableShape()
public int userIndex()
public int userIndex2()
protected static final int getShapeType(long shapeId)
shapeId - the ID of the btCollisionShape (not zero)enum BroadphaseNativeTypes)protected final float nativeMargin()
protected void recalculateAabb()
protected void updateScale()
btCollisionShape.protected void setNativeId(long shapeId)
setNativeId in class NativePhysicsObjectshapeId - the identifier of the btCollisionShape (not zero)public java.lang.String toString()
toString in class NativePhysicsObject