Shape.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Jolt/Physics/Body/MassProperties.h>
  5. #include <Jolt/Physics/Collision/BackFaceMode.h>
  6. #include <Jolt/Physics/Collision/CollisionCollector.h>
  7. #include <Jolt/Physics/Collision/ShapeFilter.h>
  8. #include <Jolt/Geometry/AABox.h>
  9. #include <Jolt/Core/Reference.h>
  10. #include <Jolt/Core/Color.h>
  11. #include <Jolt/Core/Result.h>
  12. #include <Jolt/Core/NonCopyable.h>
  13. #include <Jolt/Core/UnorderedMap.h>
  14. #include <Jolt/Core/UnorderedSet.h>
  15. #include <Jolt/ObjectStream/SerializableObject.h>
  16. JPH_NAMESPACE_BEGIN
  17. struct RayCast;
  18. class RayCastSettings;
  19. struct ShapeCast;
  20. class ShapeCastSettings;
  21. class RayCastResult;
  22. class ShapeCastResult;
  23. class CollidePointResult;
  24. class CollideShapeResult;
  25. class SubShapeIDCreator;
  26. class SubShapeID;
  27. class PhysicsMaterial;
  28. class TransformedShape;
  29. class Plane;
  30. class Shape;
  31. class StreamOut;
  32. class StreamIn;
  33. #ifdef JPH_DEBUG_RENDERER
  34. class DebugRenderer;
  35. #endif // JPH_DEBUG_RENDERER
  36. using CastRayCollector = CollisionCollector<RayCastResult, CollisionCollectorTraitsCastRay>;
  37. using CastShapeCollector = CollisionCollector<ShapeCastResult, CollisionCollectorTraitsCastShape>;
  38. using CollidePointCollector = CollisionCollector<CollidePointResult, CollisionCollectorTraitsCollidePoint>;
  39. using CollideShapeCollector = CollisionCollector<CollideShapeResult, CollisionCollectorTraitsCollideShape>;
  40. using TransformedShapeCollector = CollisionCollector<TransformedShape, CollisionCollectorTraitsCollideShape>;
  41. using ShapeRefC = RefConst<Shape>;
  42. using ShapeList = Array<ShapeRefC>;
  43. using PhysicsMaterialRefC = RefConst<PhysicsMaterial>;
  44. using PhysicsMaterialList = Array<PhysicsMaterialRefC>;
  45. /// Shapes are categorized in groups, each shape can return which group it belongs to through its Shape::GetType function.
  46. enum class EShapeType : uint8
  47. {
  48. Convex, ///< Used by ConvexShape, all shapes that use the generic convex vs convex collision detection system (box, sphere, capsule, tapered capsule, cylinder, triangle)
  49. Compound, ///< Used by CompoundShape
  50. Decorated, ///< Used by DecoratedShape
  51. Mesh, ///< Used by MeshShape
  52. HeightField, ///< Used by HeightFieldShape
  53. // User defined shapes
  54. User1,
  55. User2,
  56. User3,
  57. User4,
  58. };
  59. /// This enumerates all shape types, each shape can return its type through Shape::GetSubType
  60. enum class EShapeSubType : uint8
  61. {
  62. // Convex shapes
  63. Sphere,
  64. Box,
  65. Triangle,
  66. Capsule,
  67. TaperedCapsule,
  68. Cylinder,
  69. ConvexHull,
  70. // Compound shapes
  71. StaticCompound,
  72. MutableCompound,
  73. // Decorated shapes
  74. RotatedTranslated,
  75. Scaled,
  76. OffsetCenterOfMass,
  77. // Other shapes
  78. Mesh,
  79. HeightField,
  80. // User defined shapes
  81. User1,
  82. User2,
  83. User3,
  84. User4,
  85. User5,
  86. User6,
  87. User7,
  88. User8,
  89. };
  90. // Sets of shape sub types
  91. static constexpr EShapeSubType sAllSubShapeTypes[] = { EShapeSubType::Sphere, EShapeSubType::Box, EShapeSubType::Triangle, EShapeSubType::Capsule, EShapeSubType::TaperedCapsule, EShapeSubType::Cylinder, EShapeSubType::ConvexHull, EShapeSubType::StaticCompound, EShapeSubType::MutableCompound, EShapeSubType::RotatedTranslated, EShapeSubType::Scaled, EShapeSubType::OffsetCenterOfMass, EShapeSubType::Mesh, EShapeSubType::HeightField, EShapeSubType::User1, EShapeSubType::User2, EShapeSubType::User3, EShapeSubType::User4, EShapeSubType::User5, EShapeSubType::User6, EShapeSubType::User7, EShapeSubType::User8 };
  92. static constexpr EShapeSubType sConvexSubShapeTypes[] = { EShapeSubType::Sphere, EShapeSubType::Box, EShapeSubType::Triangle, EShapeSubType::Capsule, EShapeSubType::TaperedCapsule, EShapeSubType::Cylinder, EShapeSubType::ConvexHull };
  93. static constexpr EShapeSubType sCompoundSubShapeTypes[] = { EShapeSubType::StaticCompound, EShapeSubType::MutableCompound };
  94. static constexpr EShapeSubType sDecoratorSubShapeTypes[] = { EShapeSubType::RotatedTranslated, EShapeSubType::Scaled, EShapeSubType::OffsetCenterOfMass };
  95. /// How many shape types we support
  96. static constexpr uint NumSubShapeTypes = (uint)size(sAllSubShapeTypes);
  97. /// Names of sub shape types
  98. static constexpr const char *sSubShapeTypeNames[] = { "Sphere", "Box", "Triangle", "Capsule", "TaperedCapsule", "Cylinder", "ConvexHull", "StaticCompound", "MutableCompound", "RotatedTranslated", "Scaled", "OffsetCenterOfMass", "Mesh", "HeightField", "User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8" };
  99. static_assert(size(sSubShapeTypeNames) == NumSubShapeTypes);
  100. /// Class that can construct shapes and that is serializable using the ObjectStream system.
  101. /// Can be used to store shape data in 'uncooked' form (i.e. in a form that is still human readable and authorable).
  102. /// Once the shape has been created using the Create() function, the data will be moved into the Shape class
  103. /// in a form that is optimized for collision detection. After this, the ShapeSettings object is no longer needed
  104. /// and can be destroyed. Each shape class has a derived class of the ShapeSettings object to store shape specific
  105. /// data.
  106. class ShapeSettings : public SerializableObject, public RefTarget<ShapeSettings>
  107. {
  108. public:
  109. JPH_DECLARE_SERIALIZABLE_ABSTRACT(ShapeSettings)
  110. using ShapeResult = Result<Ref<Shape>>;
  111. /// Create a shape according to the settings specified by this object.
  112. virtual ShapeResult Create() const = 0;
  113. /// User data (to be used freely by the application)
  114. uint64 mUserData = 0;
  115. protected:
  116. mutable ShapeResult mCachedResult;
  117. };
  118. /// Function table for functions on shapes
  119. class ShapeFunctions
  120. {
  121. public:
  122. /// Construct a shape
  123. Shape * (*mConstruct)() = nullptr;
  124. /// Color of the shape when drawing
  125. Color mColor = Color::sBlack;
  126. /// Get an entry in the registry for a particular sub type
  127. static inline ShapeFunctions & sGet(EShapeSubType inSubType) { return sRegistry[(int)inSubType]; }
  128. private:
  129. static ShapeFunctions sRegistry[NumSubShapeTypes];
  130. };
  131. /// Base class for all shapes (collision volume of a body). Defines a virtual interface for collision detection.
  132. class Shape : public RefTarget<Shape>, public NonCopyable
  133. {
  134. public:
  135. JPH_OVERRIDE_NEW_DELETE
  136. using ShapeResult = ShapeSettings::ShapeResult;
  137. /// Constructor
  138. Shape(EShapeType inType, EShapeSubType inSubType) : mShapeType(inType), mShapeSubType(inSubType) { }
  139. Shape(EShapeType inType, EShapeSubType inSubType, const ShapeSettings &inSettings, [[maybe_unused]] ShapeResult &outResult) : mUserData(inSettings.mUserData), mShapeType(inType), mShapeSubType(inSubType) { }
  140. /// Destructor
  141. virtual ~Shape() = default;
  142. /// Get type
  143. inline EShapeType GetType() const { return mShapeType; }
  144. inline EShapeSubType GetSubType() const { return mShapeSubType; }
  145. /// User data (to be used freely by the application)
  146. uint64 GetUserData() const { return mUserData; }
  147. void SetUserData(uint64 inUserData) { mUserData = inUserData; }
  148. /// Check if this shape can only be used to create a static body or if it can also be dynamic/kinematic
  149. virtual bool MustBeStatic() const { return false; }
  150. /// All shapes are centered around their center of mass. This function returns the center of mass position that needs to be applied to transform the shape to where it was created.
  151. virtual Vec3 GetCenterOfMass() const { return Vec3::sZero(); }
  152. /// Get local bounding box including convex radius, this box is centered around the center of mass rather than the world transform
  153. virtual AABox GetLocalBounds() const = 0;
  154. /// Get the max number of sub shape ID bits that are needed to be able to address any leaf shape in this shape. Used mainly for checking that it is smaller or equal than SubShapeID::MaxBits.
  155. virtual uint GetSubShapeIDBitsRecursive() const = 0;
  156. /// Get world space bounds including convex radius.
  157. /// This shape is scaled by inScale in local space first.
  158. /// This function can be overridden to return a closer fitting world space bounding box, by default it will just transform what GetLocalBounds() returns.
  159. virtual AABox GetWorldSpaceBounds(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale) const { return GetLocalBounds().Scaled(inScale).Transformed(inCenterOfMassTransform); }
  160. /// Returns the radius of the biggest sphere that fits entirely in the shape. In case this shape consists of multiple sub shapes, it returns the smallest sphere of the parts.
  161. /// This can be used as a measure of how far the shape can be moved without risking going through geometry.
  162. virtual float GetInnerRadius() const = 0;
  163. /// Calculate the mass and inertia of this shape
  164. virtual MassProperties GetMassProperties() const = 0;
  165. /// Get the material assigned to a particular sub shape ID
  166. virtual const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const = 0;
  167. /// Get the surface normal of a particular sub shape ID and point on surface (all vectors are relative to center of mass for this shape).
  168. /// Note: When you have a CollideShapeResult or ShapeCastResult you should use -mPenetrationAxis.Normalized() as contact normal as GetSurfaceNormal will only return face normals (and not vertex or edge normals).
  169. virtual Vec3 GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const = 0;
  170. /// Type definition for a supporting face
  171. using SupportingFace = StaticArray<Vec3, 32>;
  172. /// Get the vertices of the face that faces inDirection the most (includes any convex radius). Note that this function can only return faces of
  173. /// convex shapes or triangles, which is why a sub shape ID to get to that leaf must be provided.
  174. /// @param inSubShapeID Sub shape ID of target shape
  175. /// @param inDirection Direction that the face should be facing (in local space to this shape)
  176. /// @param inCenterOfMassTransform Transform to transform outVertices with
  177. /// @param inScale Scale of this shape
  178. /// @param outVertices Resulting face. The returned face can be empty if the shape doesn't have polygons to return (e.g. because it's a sphere). The face will be returned in world space.
  179. virtual void GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDirection, Vec3Arg inScale, Mat44Arg inCenterOfMassTransform, SupportingFace &outVertices) const { /* Nothing */ }
  180. /// Get the user data of a particular sub shape ID
  181. virtual uint64 GetSubShapeUserData(const SubShapeID &inSubShapeID) const { return mUserData; }
  182. /// Get the direct child sub shape and its transform for a sub shape ID.
  183. /// @param inSubShapeID Sub shape ID that indicates the path to the leaf shape
  184. /// @param inPositionCOM The position of the center of mass of this shape
  185. /// @param inRotation The orientation of this shape
  186. /// @param inScale Scale of this shape
  187. /// @param outRemainder The remainder of the sub shape ID after removing the sub shape
  188. /// @return Direct child sub shape and its transform, note that the body ID and sub shape ID will be invalid
  189. virtual TransformedShape GetSubShapeTransformedShape(const SubShapeID &inSubShapeID, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale, SubShapeID &outRemainder) const;
  190. /// Gets the properties needed to do buoyancy calculations for a body using this shape
  191. /// @param inCenterOfMassTransform Transform that takes this shape (centered around center of mass) to world space
  192. /// @param inScale Scale in local space of the shape
  193. /// @param inSurface The surface plane of the liquid in world space
  194. /// @param outTotalVolume On return this contains the total volume of the shape
  195. /// @param outSubmergedVolume On return this contains the submerged volume of the shape
  196. /// @param outCenterOfBuoyancy On return this contains the world space center of mass of the submerged volume
  197. virtual void GetSubmergedVolume(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const Plane &inSurface, float &outTotalVolume, float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy) const = 0;
  198. #ifdef JPH_DEBUG_RENDERER
  199. /// Draw the shape at a particular location with a particular color (debugging purposes)
  200. virtual void Draw(DebugRenderer *inRenderer, Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, ColorArg inColor, bool inUseMaterialColors, bool inDrawWireframe) const = 0;
  201. /// Draw the results of the GetSupportFunction with the convex radius added back on to show any errors introduced by this process (only relevant for convex shapes)
  202. virtual void DrawGetSupportFunction(DebugRenderer *inRenderer, Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, ColorArg inColor, bool inDrawSupportDirection) const { /* Only implemented for convex shapes */ }
  203. /// Draw the results of the GetSupportingFace function to show any errors introduced by this process (only relevant for convex shapes)
  204. virtual void DrawGetSupportingFace(DebugRenderer *inRenderer, Mat44Arg inCenterOfMassTransform, Vec3Arg inScale) const { /* Only implemented for convex shapes */ }
  205. #endif // JPH_DEBUG_RENDERER
  206. /// Cast a ray against this shape, returns true if it finds a hit closer than ioHit.mFraction and updates that fraction. Otherwise ioHit is left untouched and the function returns false.
  207. /// Note that the ray should be relative to the center of mass of this shape (i.e. subtract Shape::GetCenterOfMass() from RayCast::mOrigin if you want to cast against the shape in the space it was created).
  208. /// Convex objects will be treated as solid (meaning if the ray starts inside, you'll get a hit fraction of 0) and back face hits against triangles are returned.
  209. /// If you want the surface normal of the hit use GetSurfaceNormal(ioHit.mSubShapeID2, inRay.GetPointOnRay(ioHit.mFraction)).
  210. virtual bool CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const = 0;
  211. /// Cast a ray against this shape. Allows returning multiple hits through ioCollector. Note that this version is more flexible but also slightly slower than the CastRay function that returns only a single hit.
  212. /// If you want the surface normal of the hit use GetSurfaceNormal(collected sub shape ID, inRay.GetPointOnRay(collected faction)).
  213. virtual void CastRay(const RayCast &inRay, const RayCastSettings &inRayCastSettings, const SubShapeIDCreator &inSubShapeIDCreator, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter = { }) const = 0;
  214. /// Check if inPoint is inside this shape. For this tests all shapes are treated as if they were solid.
  215. /// Note that inPoint should be relative to the center of mass of this shape (i.e. subtract Shape::GetCenterOfMass() from inPoint if you want to test against the shape in the space it was created).
  216. /// For a mesh shape, this test will only provide sensible information if the mesh is a closed manifold.
  217. /// For each shape that collides, ioCollector will receive a hit.
  218. virtual void CollidePoint(Vec3Arg inPoint, const SubShapeIDCreator &inSubShapeIDCreator, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter = { }) const = 0;
  219. /// Collect the leaf transformed shapes of all leaf shapes of this shape.
  220. /// inBox is the world space axis aligned box which leaf shapes should collide with.
  221. /// inPositionCOM/inRotation/inScale describes the transform of this shape.
  222. /// inSubShapeIDCeator represents the current sub shape ID of this shape.
  223. virtual void CollectTransformedShapes(const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale, const SubShapeIDCreator &inSubShapeIDCreator, TransformedShapeCollector &ioCollector, const ShapeFilter &inShapeFilter) const;
  224. /// Transforms this shape and all of its children with inTransform, resulting shape(s) are passed to ioCollector.
  225. /// Note that not all shapes support all transforms (especially true for scaling), the resulting shape will try to match the transform as accurately as possible.
  226. /// @param inCenterOfMassTransform The transform (rotation, translation, scale) that the center of mass of the shape should get
  227. /// @param ioCollector The transformed shapes will be passed to this collector
  228. virtual void TransformShape(Mat44Arg inCenterOfMassTransform, TransformedShapeCollector &ioCollector) const;
  229. /// Scale this shape. Note that not all shapes support all scales, this will return a shape that matches the scale as accurately as possible.
  230. /// @param inScale The scale to use for this shape (note: this scale is applied to the entire shape in the space it was created, most function apply the scale in the space of the leaf shapes and from the center of mass!)
  231. ShapeResult ScaleShape(Vec3Arg inScale) const;
  232. /// An opaque buffer that holds shape specific information during GetTrianglesStart/Next.
  233. struct alignas(16) GetTrianglesContext { uint8 mData[4288]; };
  234. /// This is the minimum amount of triangles that should be requested through GetTrianglesNext.
  235. static constexpr int cGetTrianglesMinTrianglesRequested = 32;
  236. /// To start iterating over triangles, call this function first.
  237. /// ioContext is a temporary buffer and should remain untouched until the last call to GetTrianglesNext.
  238. /// inBox is the world space bounding in which you want to get the triangles.
  239. /// inPositionCOM/inRotation/inScale describes the transform of this shape.
  240. /// To get the actual triangles call GetTrianglesNext.
  241. virtual void GetTrianglesStart(GetTrianglesContext &ioContext, const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale) const = 0;
  242. /// Call this repeatedly to get all triangles in the box.
  243. /// outTriangleVertices should be large enough to hold 3 * inMaxTriangleRequested entries.
  244. /// outMaterials (if it is not null) should contain inMaxTrianglesRequested entries.
  245. /// The function returns the amount of triangles that it found (which will be <= inMaxTrianglesRequested), or 0 if there are no more triangles.
  246. /// Note that the function can return a value < inMaxTrianglesRequested and still have more triangles to process (triangles can be returned in blocks).
  247. /// Note that the function may return triangles outside of the requested box, only coarse culling is performed on the returned triangles.
  248. virtual int GetTrianglesNext(GetTrianglesContext &ioContext, int inMaxTrianglesRequested, Float3 *outTriangleVertices, const PhysicsMaterial **outMaterials = nullptr) const = 0;
  249. ///@name Binary serialization of the shape. Note that this saves the 'cooked' shape in a format which will not be backwards compatible for newer library versions.
  250. /// In this case you need to recreate the shape from the ShapeSettings object and save it again. The user is expected to call SaveBinaryState followed by SaveMaterialState and SaveSubShapeState.
  251. /// The stream should be stored as is and the material and shape list should be saved using the applications own serialization system (e.g. by assigning an ID to each pointer).
  252. /// When restoring data, call sRestoreFromBinararyState to get the shape and then call RestoreMaterialState and RestoreSubShapeState to restore the pointers to the external objects.
  253. ///@{
  254. /// Saves the contents of the shape in binary form to inStream.
  255. virtual void SaveBinaryState(StreamOut &inStream) const;
  256. /// Creates a Shape of the correct type and restores its contents from the binary stream inStream.
  257. static ShapeResult sRestoreFromBinaryState(StreamIn &inStream);
  258. /// Outputs the material references that this shape has to outMaterials.
  259. virtual void SaveMaterialState(PhysicsMaterialList &outMaterials) const { /* By default do nothing */ }
  260. /// Restore the material references after calling sRestoreFromBinaryState. Note that the exact same materials need to be provided in the same order as returned by SaveMaterialState.
  261. virtual void RestoreMaterialState(const PhysicsMaterialRefC *inMaterials, uint inNumMaterials) { JPH_ASSERT(inNumMaterials == 0); }
  262. /// Outputs the shape references that this shape has to outSubShapes.
  263. virtual void SaveSubShapeState(ShapeList &outSubShapes) const { /* By default do nothing */ }
  264. /// Restore the shape references after calling sRestoreFromBinaryState. Note that the exact same shapes need to be provided in the same order as returned by SaveSubShapeState.
  265. virtual void RestoreSubShapeState(const ShapeRefC *inSubShapes, uint inNumShapes) { JPH_ASSERT(inNumShapes == 0); }
  266. using ShapeToIDMap = UnorderedMap<const Shape *, uint32>;
  267. using MaterialToIDMap = UnorderedMap<const PhysicsMaterial *, uint32>;
  268. using IDToShapeMap = Array<Ref<Shape>>;
  269. using IDToMaterialMap = Array<Ref<PhysicsMaterial>>;
  270. /// Save this shape, all its children and its materials. Pass in an empty map in ioShapeMap / ioMaterialMap or reuse the same map while saving multiple shapes to the same stream in order to avoid writing duplicates.
  271. void SaveWithChildren(StreamOut &inStream, ShapeToIDMap &ioShapeMap, MaterialToIDMap &ioMaterialMap) const;
  272. /// Restore a shape, all its children and materials. Pass in an empty map in ioShapeMap / ioMaterialMap or reuse the same map while reading multiple shapes from the same stream in order to restore duplicates.
  273. static ShapeResult sRestoreWithChildren(StreamIn &inStream, IDToShapeMap &ioShapeMap, IDToMaterialMap &ioMaterialMap);
  274. ///@}
  275. /// Class that holds information about the shape that can be used for logging / data collection purposes
  276. struct Stats
  277. {
  278. Stats(size_t inSizeBytes, uint inNumTriangles) : mSizeBytes(inSizeBytes), mNumTriangles(inNumTriangles) { }
  279. size_t mSizeBytes; ///< Amount of memory used by this shape (size in bytes)
  280. uint mNumTriangles; ///< Number of triangles in this shape (when applicable)
  281. };
  282. /// Get stats of this shape. Use for logging / data collection purposes only. Does not add values from child shapes, use GetStatsRecursive for this.
  283. virtual Stats GetStats() const = 0;
  284. using VisitedShapes = UnorderedSet<const Shape *>;
  285. /// Get the combined stats of this shape and its children.
  286. /// @param ioVisitedShapes is used to track which shapes have already been visited, to avoid calculating the wrong memory size.
  287. virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes) const;
  288. ///< Volume of this shape (m^3). Note that for compound shapes the volume may be incorrect since child shapes can overlap which is not accounted for.
  289. virtual float GetVolume() const = 0;
  290. /// Test if inScale is a valid scale for this shape. Some shapes can only be scaled uniformly, compound shapes cannot handle shapes
  291. /// being rotated and scaled (this would cause shearing). In this case this function will return false.
  292. virtual bool IsValidScale(Vec3Arg inScale) const { return !inScale.IsNearZero(); }
  293. #ifdef JPH_DEBUG_RENDERER
  294. /// Debug helper which draws the intersection between water and the shapes, the center of buoyancy and the submerged volume
  295. static bool sDrawSubmergedVolumes;
  296. #endif // JPH_DEBUG_RENDERER
  297. protected:
  298. /// This function should not be called directly, it is used by sRestoreFromBinaryState.
  299. virtual void RestoreBinaryState(StreamIn &inStream);
  300. private:
  301. uint64 mUserData = 0;
  302. EShapeType mShapeType;
  303. EShapeSubType mShapeSubType;
  304. };
  305. JPH_NAMESPACE_END