|
@@ -24,9 +24,9 @@ public:
|
|
/// This shape is optimized for adding / removing and changing the rotation / translation of sub shapes but is less efficient in querying.
|
|
/// This shape is optimized for adding / removing and changing the rotation / translation of sub shapes but is less efficient in querying.
|
|
/// Shifts all child objects so that they're centered around the center of mass (which needs to be kept up to date by calling AdjustCenterOfMass).
|
|
/// Shifts all child objects so that they're centered around the center of mass (which needs to be kept up to date by calling AdjustCenterOfMass).
|
|
///
|
|
///
|
|
-/// Note: If you're using MutableCompoundShapes and are querying data while modifying the shape you'll have a race condition.
|
|
|
|
-/// In this case it is best to create a new MutableCompoundShape and set the new shape on the body using BodyInterface::SetShape. If a
|
|
|
|
-/// query is still working on the old shape, it will have taken a reference and keep the old shape alive until the query finishes.
|
|
|
|
|
|
+/// Note: If you're using MutableCompoundShape and are querying data while modifying the shape you'll have a race condition.
|
|
|
|
+/// In this case it is best to create a new MutableCompoundShape using the Clone function. You replace the shape on a body using BodyInterface::SetShape.
|
|
|
|
+/// If a query is still working on the old shape, it will have taken a reference and keep the old shape alive until the query finishes.
|
|
class JPH_EXPORT MutableCompoundShape final : public CompoundShape
|
|
class JPH_EXPORT MutableCompoundShape final : public CompoundShape
|
|
{
|
|
{
|
|
public:
|
|
public:
|
|
@@ -36,6 +36,9 @@ public:
|
|
MutableCompoundShape() : CompoundShape(EShapeSubType::MutableCompound) { }
|
|
MutableCompoundShape() : CompoundShape(EShapeSubType::MutableCompound) { }
|
|
MutableCompoundShape(const MutableCompoundShapeSettings &inSettings, ShapeResult &outResult);
|
|
MutableCompoundShape(const MutableCompoundShapeSettings &inSettings, ShapeResult &outResult);
|
|
|
|
|
|
|
|
+ /// Clone this shape. Can be used to avoid race conditions. See the documentation of this class for more information.
|
|
|
|
+ Ref<MutableCompoundShape> Clone() const;
|
|
|
|
+
|
|
// See Shape::CastRay
|
|
// See Shape::CastRay
|
|
virtual bool CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const override;
|
|
virtual bool CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const override;
|
|
virtual void CastRay(const RayCast &inRay, const RayCastSettings &inRayCastSettings, const SubShapeIDCreator &inSubShapeIDCreator, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter = { }) const override;
|
|
virtual void CastRay(const RayCast &inRay, const RayCastSettings &inRayCastSettings, const SubShapeIDCreator &inSubShapeIDCreator, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter = { }) const override;
|
|
@@ -61,20 +64,25 @@ public:
|
|
///@{
|
|
///@{
|
|
/// @name Mutating shapes. Note that this is not thread safe, so you need to ensure that any bodies that use this shape are locked at the time of modification using BodyLockWrite. After modification you need to call BodyInterface::NotifyShapeChanged to update the broadphase and collision caches.
|
|
/// @name Mutating shapes. Note that this is not thread safe, so you need to ensure that any bodies that use this shape are locked at the time of modification using BodyLockWrite. After modification you need to call BodyInterface::NotifyShapeChanged to update the broadphase and collision caches.
|
|
|
|
|
|
- /// Adding a new shape
|
|
|
|
|
|
+ /// Adding a new shape.
|
|
|
|
+ /// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
|
|
/// @return The index of the newly added shape
|
|
/// @return The index of the newly added shape
|
|
uint AddShape(Vec3Arg inPosition, QuatArg inRotation, const Shape *inShape, uint32 inUserData = 0);
|
|
uint AddShape(Vec3Arg inPosition, QuatArg inRotation, const Shape *inShape, uint32 inUserData = 0);
|
|
|
|
|
|
- /// Remove a shape by index
|
|
|
|
|
|
+ /// Remove a shape by index.
|
|
|
|
+ /// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
|
|
void RemoveShape(uint inIndex);
|
|
void RemoveShape(uint inIndex);
|
|
|
|
|
|
- /// Modify the position / orientation of a shape
|
|
|
|
|
|
+ /// Modify the position / orientation of a shape.
|
|
|
|
+ /// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
|
|
void ModifyShape(uint inIndex, Vec3Arg inPosition, QuatArg inRotation);
|
|
void ModifyShape(uint inIndex, Vec3Arg inPosition, QuatArg inRotation);
|
|
|
|
|
|
- /// Modify the position / orientation and shape at the same time
|
|
|
|
|
|
+ /// Modify the position / orientation and shape at the same time.
|
|
|
|
+ /// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
|
|
void ModifyShape(uint inIndex, Vec3Arg inPosition, QuatArg inRotation, const Shape *inShape);
|
|
void ModifyShape(uint inIndex, Vec3Arg inPosition, QuatArg inRotation, const Shape *inShape);
|
|
|
|
|
|
/// @brief Batch set positions / orientations, this avoids duplicate work due to bounding box calculation.
|
|
/// @brief Batch set positions / orientations, this avoids duplicate work due to bounding box calculation.
|
|
|
|
+ /// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
|
|
/// @param inStartIndex Index of first shape to update
|
|
/// @param inStartIndex Index of first shape to update
|
|
/// @param inNumber Number of shapes to update
|
|
/// @param inNumber Number of shapes to update
|
|
/// @param inPositions A list of positions with arbitrary stride
|
|
/// @param inPositions A list of positions with arbitrary stride
|
|
@@ -86,6 +94,7 @@ public:
|
|
/// Recalculate the center of mass and shift all objects so they're centered around it
|
|
/// Recalculate the center of mass and shift all objects so they're centered around it
|
|
/// (this needs to be done of dynamic bodies and if the center of mass changes significantly due to adding / removing / repositioning sub shapes or else the simulation will look unnatural)
|
|
/// (this needs to be done of dynamic bodies and if the center of mass changes significantly due to adding / removing / repositioning sub shapes or else the simulation will look unnatural)
|
|
/// Note that after adjusting the center of mass of an object you need to call BodyInterface::NotifyShapeChanged and Constraint::NotifyShapeChanged on the relevant bodies / constraints.
|
|
/// Note that after adjusting the center of mass of an object you need to call BodyInterface::NotifyShapeChanged and Constraint::NotifyShapeChanged on the relevant bodies / constraints.
|
|
|
|
+ /// Beware this can create a race condition if you're running collision queries in parallel. See class documentation for more information.
|
|
void AdjustCenterOfMass();
|
|
void AdjustCenterOfMass();
|
|
|
|
|
|
///@}
|
|
///@}
|