Skip to content

Commit

Permalink
Added EmptyShape (#1262)
Browse files Browse the repository at this point in the history
See #1253
  • Loading branch information
jrouwe authored Sep 16, 2024
1 parent c7d9114 commit 2e7c64a
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 20 deletions.
1 change: 1 addition & 0 deletions Docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ For breaking API changes see [this document](https://github.com/jrouwe/JoltPhysi

* Added PlaneShape. An infinite plane. Negative half space is considered solid.
* Added TaperedCylinderShape. A cylinder with different top and bottom radii.
* Added EmptyShape. A shape that collides with nothing and that can be used as a placeholder or for dummy bodies.
* Use MeshShapeSettings::mPerTriangleUserData at about 25% memory increase to get per triangle user data through MeshShape::GetTriangleUserData
* Added Shape::GetLeafShape function to be able to get a leaf shape given a sub shape ID
* Added HeightFieldShape::GetSubShapeCoordinates to get the triangle coordinates of a particular sub shape ID
Expand Down
2 changes: 2 additions & 0 deletions Jolt/Jolt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ set(JOLT_PHYSICS_SRC_FILES
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/CylinderShape.h
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/DecoratedShape.cpp
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/DecoratedShape.h
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/EmptyShape.cpp
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/EmptyShape.h
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/GetTrianglesContext.h
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/HeightFieldShape.cpp
${JOLT_PHYSICS_ROOT}/Physics/Collision/Shape/HeightFieldShape.h
Expand Down
65 changes: 65 additions & 0 deletions Jolt/Physics/Collision/Shape/EmptyShape.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
// SPDX-License-Identifier: MIT

#include <Jolt/Jolt.h>

#include <Jolt/Physics/Collision/Shape/EmptyShape.h>
#include <Jolt/Physics/Collision/CollisionDispatch.h>
#include <Jolt/ObjectStream/TypeDeclarations.h>
#ifdef JPH_DEBUG_RENDERER
#include <Jolt/Renderer/DebugRenderer.h>
#endif // JPH_DEBUG_RENDERER

JPH_NAMESPACE_BEGIN

JPH_IMPLEMENT_SERIALIZABLE_VIRTUAL(EmptyShapeSettings)
{
JPH_ADD_BASE_CLASS(EmptyShapeSettings, ShapeSettings)

JPH_ADD_ATTRIBUTE(EmptyShapeSettings, mCenterOfMass)
}

ShapeSettings::ShapeResult EmptyShapeSettings::Create() const
{
if (mCachedResult.IsEmpty())
new EmptyShape(*this, mCachedResult);

return mCachedResult;
}

MassProperties EmptyShape::GetMassProperties() const
{
MassProperties mass_properties;
mass_properties.mMass = 1.0f;
mass_properties.mInertia = Mat44::sIdentity();
return mass_properties;
}

#ifdef JPH_DEBUG_RENDERER
void EmptyShape::Draw(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, Vec3Arg inScale, ColorArg inColor, [[maybe_unused]] bool inUseMaterialColors, [[maybe_unused]] bool inDrawWireframe) const
{
inRenderer->DrawMarker(inCenterOfMassTransform.GetTranslation(), inColor, abs(inScale.GetX()) * 0.1f);
}
#endif // JPH_DEBUG_RENDERER

void EmptyShape::sRegister()
{
ShapeFunctions &f = ShapeFunctions::sGet(EShapeSubType::Empty);
f.mConstruct = []() -> Shape * { return new EmptyShape; };
f.mColor = Color::sBlack;

auto collide_empty = []([[maybe_unused]] const Shape *inShape1, [[maybe_unused]] const Shape *inShape2, [[maybe_unused]] Vec3Arg inScale1, [[maybe_unused]] Vec3Arg inScale2, [[maybe_unused]] Mat44Arg inCenterOfMassTransform1, [[maybe_unused]] Mat44Arg inCenterOfMassTransform2, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator1, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator2, [[maybe_unused]] const CollideShapeSettings &inCollideShapeSettings, [[maybe_unused]] CollideShapeCollector &ioCollector, [[maybe_unused]] const ShapeFilter &inShapeFilter) { /* Do Nothing */ };
auto cast_empty = []([[maybe_unused]] const ShapeCast &inShapeCast, [[maybe_unused]] const ShapeCastSettings &inShapeCastSettings, [[maybe_unused]] const Shape *inShape, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] const ShapeFilter &inShapeFilter, [[maybe_unused]] Mat44Arg inCenterOfMassTransform2, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator1, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator2, [[maybe_unused]] CastShapeCollector &ioCollector) { /* Do nothing */ };

for (const EShapeSubType s : sAllSubShapeTypes)
{
CollisionDispatch::sRegisterCollideShape(EShapeSubType::Empty, s, collide_empty);
CollisionDispatch::sRegisterCollideShape(s, EShapeSubType::Empty, collide_empty);

CollisionDispatch::sRegisterCastShape(EShapeSubType::Empty, s, cast_empty);
CollisionDispatch::sRegisterCastShape(s, EShapeSubType::Empty, cast_empty);
}
}

JPH_NAMESPACE_END
67 changes: 67 additions & 0 deletions Jolt/Physics/Collision/Shape/EmptyShape.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
// SPDX-License-Identifier: MIT

#pragma once

#include <Jolt/Physics/Collision/Shape/Shape.h>
#include <Jolt/Physics/Collision/PhysicsMaterial.h>

JPH_NAMESPACE_BEGIN

/// Class that constructs an EmptyShape
class JPH_EXPORT EmptyShapeSettings final : public ShapeSettings
{
public:
JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, EmptyShapeSettings)

EmptyShapeSettings() = default;
explicit EmptyShapeSettings(Vec3Arg inCenterOfMass) : mCenterOfMass(inCenterOfMass) { }

ShapeResult Create() const override;

Vec3 mCenterOfMass = Vec3::sZero(); ///< Determines the center of mass for this shape
};

/// An empty shape that has no volume and collides with nothing.
class JPH_EXPORT EmptyShape final : public Shape
{
public:
// Constructor
EmptyShape() : Shape(EShapeType::Empty, EShapeSubType::Empty) { }
EmptyShape(const EmptyShapeSettings &inSettings, ShapeResult &outResult) : Shape(EShapeType::Empty, EShapeSubType::Empty, inSettings, outResult), mCenterOfMass(inSettings.mCenterOfMass) { outResult.Set(this); }

// See: Shape
Vec3 GetCenterOfMass() const override { return mCenterOfMass; }
AABox GetLocalBounds() const override { return { Vec3::sZero(), Vec3::sZero() }; }
uint GetSubShapeIDBitsRecursive() const override { return 0; }
float GetInnerRadius() const override { return 0.0f; }
MassProperties GetMassProperties() const override;
const PhysicsMaterial * GetMaterial([[maybe_unused]] const SubShapeID &inSubShapeID) const override { return PhysicsMaterial::sDefault; }
virtual Vec3 GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const override { return Vec3::sZero(); }
virtual void GetSubmergedVolume(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const Plane &inSurface, float &outTotalVolume, float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy
#ifdef JPH_DEBUG_RENDERER // Not using JPH_IF_DEBUG_RENDERER for Doxygen
, RVec3Arg inBaseOffset
#endif
) const override { outTotalVolume = 0.0f; outSubmergedVolume = 0.0f; outCenterOfBuoyancy = Vec3::sZero(); }
#ifdef JPH_DEBUG_RENDERER
virtual void Draw([[maybe_unused]] DebugRenderer *inRenderer, [[maybe_unused]] RMat44Arg inCenterOfMassTransform, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] ColorArg inColor, [[maybe_unused]] bool inUseMaterialColors, [[maybe_unused]] bool inDrawWireframe) const override;
#endif // JPH_DEBUG_RENDERER
virtual bool CastRay([[maybe_unused]] const RayCast &inRay, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator, [[maybe_unused]] RayCastResult &ioHit) const override { return false; }
virtual void CastRay([[maybe_unused]] const RayCast &inRay, [[maybe_unused]] const RayCastSettings &inRayCastSettings, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator, [[maybe_unused]] CastRayCollector &ioCollector, [[maybe_unused]] const ShapeFilter &inShapeFilter = { }) const override { /* Do nothing */ }
virtual void CollidePoint([[maybe_unused]] Vec3Arg inPoint, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator, [[maybe_unused]] CollidePointCollector &ioCollector, [[maybe_unused]] const ShapeFilter &inShapeFilter = { }) const override { /* Do nothing */ }
virtual void CollideSoftBodyVertices([[maybe_unused]] Mat44Arg inCenterOfMassTransform, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] SoftBodyVertex *ioVertices, [[maybe_unused]] uint inNumVertices, [[maybe_unused]] float inDeltaTime, [[maybe_unused]] Vec3Arg inDisplacementDueToGravity, [[maybe_unused]] int inCollidingShapeIndex) const override { /* Do nothing */ }
virtual void GetTrianglesStart([[maybe_unused]] GetTrianglesContext &ioContext, [[maybe_unused]] const AABox &inBox, [[maybe_unused]] Vec3Arg inPositionCOM, [[maybe_unused]] QuatArg inRotation, [[maybe_unused]] Vec3Arg inScale) const override { /* Do nothing */ }
virtual int GetTrianglesNext([[maybe_unused]] GetTrianglesContext &ioContext, [[maybe_unused]] int inMaxTrianglesRequested, [[maybe_unused]] Float3 *outTriangleVertices, [[maybe_unused]] const PhysicsMaterial **outMaterials = nullptr) const override { return 0; }
Stats GetStats() const override { return { sizeof(*this), 0 }; }
float GetVolume() const override { return 0.0f; }
bool IsValidScale([[maybe_unused]] Vec3Arg inScale) const override { return true; }

// Register shape functions with the registry
static void sRegister();

private:
Vec3 mCenterOfMass = Vec3::sZero();
};

JPH_NAMESPACE_END
6 changes: 4 additions & 2 deletions Jolt/Physics/Collision/Shape/Shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum class EShapeType : uint8
User4,

Plane, ///< Used by PlaneShape
Empty, ///< Used by EmptyShape
};

/// This enumerates all shape types, each shape can return its type through Shape::GetSubType
Expand Down Expand Up @@ -120,10 +121,11 @@ enum class EShapeSubType : uint8
// Other shapes
Plane,
TaperedCylinder,
Empty,
};

// Sets of shape sub types
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::SoftBody, EShapeSubType::User1, EShapeSubType::User2, EShapeSubType::User3, EShapeSubType::User4, EShapeSubType::User5, EShapeSubType::User6, EShapeSubType::User7, EShapeSubType::User8, EShapeSubType::UserConvex1, EShapeSubType::UserConvex2, EShapeSubType::UserConvex3, EShapeSubType::UserConvex4, EShapeSubType::UserConvex5, EShapeSubType::UserConvex6, EShapeSubType::UserConvex7, EShapeSubType::UserConvex8, EShapeSubType::Plane, EShapeSubType::TaperedCylinder };
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::SoftBody, EShapeSubType::User1, EShapeSubType::User2, EShapeSubType::User3, EShapeSubType::User4, EShapeSubType::User5, EShapeSubType::User6, EShapeSubType::User7, EShapeSubType::User8, EShapeSubType::UserConvex1, EShapeSubType::UserConvex2, EShapeSubType::UserConvex3, EShapeSubType::UserConvex4, EShapeSubType::UserConvex5, EShapeSubType::UserConvex6, EShapeSubType::UserConvex7, EShapeSubType::UserConvex8, EShapeSubType::Plane, EShapeSubType::TaperedCylinder, EShapeSubType::Empty };
static constexpr EShapeSubType sConvexSubShapeTypes[] = { EShapeSubType::Sphere, EShapeSubType::Box, EShapeSubType::Triangle, EShapeSubType::Capsule, EShapeSubType::TaperedCapsule, EShapeSubType::Cylinder, EShapeSubType::ConvexHull, EShapeSubType::TaperedCylinder, EShapeSubType::UserConvex1, EShapeSubType::UserConvex2, EShapeSubType::UserConvex3, EShapeSubType::UserConvex4, EShapeSubType::UserConvex5, EShapeSubType::UserConvex6, EShapeSubType::UserConvex7, EShapeSubType::UserConvex8 };
static constexpr EShapeSubType sCompoundSubShapeTypes[] = { EShapeSubType::StaticCompound, EShapeSubType::MutableCompound };
static constexpr EShapeSubType sDecoratorSubShapeTypes[] = { EShapeSubType::RotatedTranslated, EShapeSubType::Scaled, EShapeSubType::OffsetCenterOfMass };
Expand All @@ -132,7 +134,7 @@ static constexpr EShapeSubType sDecoratorSubShapeTypes[] = { EShapeSubType::Rota
static constexpr uint NumSubShapeTypes = uint(size(sAllSubShapeTypes));

/// Names of sub shape types
static constexpr const char *sSubShapeTypeNames[] = { "Sphere", "Box", "Triangle", "Capsule", "TaperedCapsule", "Cylinder", "ConvexHull", "StaticCompound", "MutableCompound", "RotatedTranslated", "Scaled", "OffsetCenterOfMass", "Mesh", "HeightField", "SoftBody", "User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8", "UserConvex1", "UserConvex2", "UserConvex3", "UserConvex4", "UserConvex5", "UserConvex6", "UserConvex7", "UserConvex8", "Plane", "TaperedCylinder" };
static constexpr const char *sSubShapeTypeNames[] = { "Sphere", "Box", "Triangle", "Capsule", "TaperedCapsule", "Cylinder", "ConvexHull", "StaticCompound", "MutableCompound", "RotatedTranslated", "Scaled", "OffsetCenterOfMass", "Mesh", "HeightField", "SoftBody", "User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8", "UserConvex1", "UserConvex2", "UserConvex3", "UserConvex4", "UserConvex5", "UserConvex6", "UserConvex7", "UserConvex8", "Plane", "TaperedCylinder", "Empty" };
static_assert(size(sSubShapeTypeNames) == NumSubShapeTypes);

/// Class that can construct shapes and that is serializable using the ObjectStream system.
Expand Down
20 changes: 3 additions & 17 deletions Jolt/RegisterTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,12 @@
#include <Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h>
#include <Jolt/Physics/Collision/Shape/MutableCompoundShape.h>
#include <Jolt/Physics/Collision/Shape/StaticCompoundShape.h>
#include <Jolt/Physics/Collision/Shape/EmptyShape.h>
#include <Jolt/Physics/Collision/PhysicsMaterialSimple.h>
#include <Jolt/Physics/SoftBody/SoftBodyShape.h>

JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, Skeleton)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, SkeletalAnimation)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, CompoundShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, StaticCompoundShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, MutableCompoundShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, TriangleShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, PlaneShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, SphereShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, BoxShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, CapsuleShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, TaperedCapsuleShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, CylinderShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, TaperedCylinderShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, ScaledShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, MeshShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, ConvexHullShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, HeightFieldShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, RotatedTranslatedShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, OffsetCenterOfMassShapeSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, RagdollSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, PointConstraintSettings)
JPH_DECLARE_RTTI_WITH_NAMESPACE_FOR_FACTORY(JPH_EXPORT, JPH, SixDOFConstraintSettings)
Expand Down Expand Up @@ -136,6 +120,7 @@ void RegisterTypesInternal(uint64 inVersionID)
RotatedTranslatedShape::sRegister();
OffsetCenterOfMassShape::sRegister();
ScaledShape::sRegister();
EmptyShape::sRegister();

// Create list of all types
const RTTI *types[] = {
Expand All @@ -158,6 +143,7 @@ void RegisterTypesInternal(uint64 inVersionID)
JPH_RTTI(HeightFieldShapeSettings),
JPH_RTTI(RotatedTranslatedShapeSettings),
JPH_RTTI(OffsetCenterOfMassShapeSettings),
JPH_RTTI(EmptyShapeSettings),
JPH_RTTI(RagdollSettings),
JPH_RTTI(PointConstraintSettings),
JPH_RTTI(SixDOFConstraintSettings),
Expand Down
2 changes: 2 additions & 0 deletions Samples/Samples.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ set(SAMPLES_SRC_FILES
${SAMPLES_ROOT}/Tests/Shapes/CapsuleShapeTest.h
${SAMPLES_ROOT}/Tests/Shapes/DeformedHeightFieldShapeTest.cpp
${SAMPLES_ROOT}/Tests/Shapes/DeformedHeightFieldShapeTest.h
${SAMPLES_ROOT}/Tests/Shapes/EmptyShapeTest.cpp
${SAMPLES_ROOT}/Tests/Shapes/EmptyShapeTest.h
${SAMPLES_ROOT}/Tests/Shapes/StaticCompoundShapeTest.cpp
${SAMPLES_ROOT}/Tests/Shapes/StaticCompoundShapeTest.h
${SAMPLES_ROOT}/Tests/Shapes/MutableCompoundShapeTest.cpp
Expand Down
5 changes: 4 additions & 1 deletion Samples/SamplesApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <Jolt/Physics/Collision/Shape/StaticCompoundShape.h>
#include <Jolt/Physics/Collision/Shape/MutableCompoundShape.h>
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
#include <Jolt/Physics/Collision/Shape/EmptyShape.h>
#include <Jolt/Physics/Collision/NarrowPhaseStats.h>
#include <Jolt/Physics/Constraints/DistanceConstraint.h>
#include <Jolt/Physics/Constraints/PulleyConstraint.h>
Expand Down Expand Up @@ -215,6 +216,7 @@ JPH_DECLARE_RTTI_FOR_FACTORY(JPH_NO_EXPORT, HeightFieldShapeTest)
JPH_DECLARE_RTTI_FOR_FACTORY(JPH_NO_EXPORT, DeformedHeightFieldShapeTest)
JPH_DECLARE_RTTI_FOR_FACTORY(JPH_NO_EXPORT, RotatedTranslatedShapeTest)
JPH_DECLARE_RTTI_FOR_FACTORY(JPH_NO_EXPORT, OffsetCenterOfMassShapeTest)
JPH_DECLARE_RTTI_FOR_FACTORY(JPH_NO_EXPORT, EmptyShapeTest)

static TestNameAndRTTI sShapeTests[] =
{
Expand All @@ -234,7 +236,8 @@ static TestNameAndRTTI sShapeTests[] =
{ "Triangle Shape", JPH_RTTI(TriangleShapeTest) },
{ "Plane Shape", JPH_RTTI(PlaneShapeTest) },
{ "Rotated Translated Shape", JPH_RTTI(RotatedTranslatedShapeTest) },
{ "Offset Center Of Mass Shape", JPH_RTTI(OffsetCenterOfMassShapeTest) }
{ "Offset Center Of Mass Shape", JPH_RTTI(OffsetCenterOfMassShapeTest) },
{ "Empty Shape", JPH_RTTI(EmptyShapeTest) }
};

JPH_DECLARE_RTTI_FOR_FACTORY(JPH_NO_EXPORT, ScaledSphereShapeTest)
Expand Down
2 changes: 2 additions & 0 deletions Samples/Tests/General/LoadSaveSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <Jolt/Physics/Collision/Shape/HeightFieldShape.h>
#include <Jolt/Physics/Collision/Shape/TriangleShape.h>
#include <Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h>
#include <Jolt/Physics/Collision/Shape/EmptyShape.h>
#include <Jolt/Physics/Collision/PhysicsMaterialSimple.h>
#include <Jolt/Physics/Constraints/DistanceConstraint.h>
#include <Jolt/Physics/Body/BodyCreationSettings.h>
Expand Down Expand Up @@ -151,6 +152,7 @@ Ref<PhysicsScene> LoadSaveSceneTest::sCreateScene()
scene->AddBody(BodyCreationSettings(new CylinderShapeSettings(0.5f, 0.2f, cDefaultConvexRadius, new PhysicsMaterialSimple("Cylinder Material", next_color())), next_pos(), Quat::sRotation(Vec3::sAxisX(), 0.5f * JPH_PI), EMotionType::Dynamic, Layers::MOVING));
scene->AddBody(BodyCreationSettings(new TaperedCylinderShapeSettings(0.5f, 0.2f, 0.4f, cDefaultConvexRadius, new PhysicsMaterialSimple("Tapered Cylinder Material", next_color())), next_pos(), Quat::sRotation(Vec3::sAxisX(), 0.5f * JPH_PI), EMotionType::Dynamic, Layers::MOVING));
scene->AddBody(BodyCreationSettings(new TaperedCylinderShapeSettings(0.5f, 0.4f, 0.0f, 0.0f, new PhysicsMaterialSimple("Cone Material", next_color())), next_pos(), Quat::sRotation(Vec3::sAxisX(), 0.5f * JPH_PI), EMotionType::Dynamic, Layers::MOVING));
scene->AddBody(BodyCreationSettings(new EmptyShapeSettings(), next_pos(), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));

// Compound with sub compound and rotation
StaticCompoundShapeSettings *sub_compound = new StaticCompoundShapeSettings();
Expand Down
Loading

0 comments on commit 2e7c64a

Please sign in to comment.