Ajout de Jolt Physics + 1ere version des factory entitecomposants - camera, transform, rigidbody, collider, renderer
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/DynamicScaledShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(DynamicScaledShape)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(DynamicScaledShape, Test)
|
||||
}
|
||||
|
||||
void DynamicScaledShape::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateHeightFieldTerrain();
|
||||
|
||||
// Create scaled sphere
|
||||
RefConst<Shape> scaled_sphere_shape = new ScaledShape(new SphereShape(2.0f), Vec3::sOne());
|
||||
mBodyID = mBodyInterface->CreateAndAddBody(BodyCreationSettings(scaled_sphere_shape, RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
|
||||
void DynamicScaledShape::PrePhysicsUpdate(const PreUpdateParams &inParams)
|
||||
{
|
||||
// Update time
|
||||
mTime += inParams.mDeltaTime;
|
||||
|
||||
BodyLockWrite lock(mPhysicsSystem->GetBodyLockInterface(), mBodyID);
|
||||
if (lock.Succeeded())
|
||||
{
|
||||
Body &body = lock.GetBody();
|
||||
|
||||
// Fetch the inner shape
|
||||
// Note that we know here that the inner shape is the original shape, but if you're scaling a CompoundShape non-uniformly the inner shape
|
||||
// may be a new compound shape with the scale baked into the children. In this case you need to keep track of your original shape yourself.
|
||||
JPH_ASSERT(body.GetShape()->GetSubType() == EShapeSubType::Scaled);
|
||||
const ScaledShape *scaled_shape = static_cast<const ScaledShape *>(body.GetShape());
|
||||
const Shape *non_scaled_shape = scaled_shape->GetInnerShape();
|
||||
|
||||
// Rescale the sphere
|
||||
float new_scale = 1.0f + 0.5f * Sin(mTime);
|
||||
Shape::ShapeResult new_shape = non_scaled_shape->ScaleShape(Vec3::sReplicate(new_scale));
|
||||
JPH_ASSERT(new_shape.IsValid()); // We're uniformly scaling a sphere, this should always succeed
|
||||
|
||||
// Note: Using non-locking interface here because we already have the lock
|
||||
// Also note that scaling shapes may cause simulation issues as the bodies can get stuck when they get bigger.
|
||||
// Recalculating mass every frame can also be an expensive operation.
|
||||
mPhysicsSystem->GetBodyInterfaceNoLock().SetShape(body.GetID(), new_shape.Get(), true, EActivation::Activate);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicScaledShape::SaveState(StateRecorder &inStream) const
|
||||
{
|
||||
inStream.Write(mTime);
|
||||
}
|
||||
|
||||
void DynamicScaledShape::RestoreState(StateRecorder &inStream)
|
||||
{
|
||||
inStream.Read(mTime);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class DynamicScaledShape : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, DynamicScaledShape)
|
||||
|
||||
// Description of the test
|
||||
virtual const char *GetDescription() const override
|
||||
{
|
||||
return "Demonstrates how you can scale a shape dynamically while a body is being simulated.";
|
||||
}
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
|
||||
|
||||
// Saving / restoring state for replay
|
||||
virtual void SaveState(StateRecorder &inStream) const override;
|
||||
virtual void RestoreState(StateRecorder &inStream) override;
|
||||
|
||||
private:
|
||||
BodyID mBodyID;
|
||||
float mTime = 0.0f;
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledBoxShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledBoxShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledBoxShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledBoxShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create box
|
||||
RefConst<BoxShape> box_shape = new BoxShape(Vec3(3, 2, 1.5f));
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(box_shape, RVec3(-30, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(box_shape, Vec3::sReplicate(0.25f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(box_shape, Vec3::sReplicate(2.0f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(box_shape, Vec3(0.25f, 0.5f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(box_shape, Vec3(-0.25f, 0.5f, -1.5f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(box_shape, Vec3(-0.25f, 0.5f, 1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledBoxShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledBoxShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledCapsuleShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/CapsuleShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledCapsuleShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledCapsuleShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledCapsuleShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create capsule
|
||||
RefConst<CapsuleShape> capsule_shape = new CapsuleShape(2.0f, 0.5f);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(capsule_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(capsule_shape, Vec3::sReplicate(0.25f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(capsule_shape, Vec3::sReplicate(2.0f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(capsule_shape, Vec3(-1.5f, -1.5f, 1.5f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(capsule_shape, Vec3(-0.75f, 0.75f, 0.75f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledCapsuleShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledCapsuleShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledConvexHullShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ConvexHullShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledConvexHullShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledConvexHullShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledConvexHullShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create tetrahedron
|
||||
Array<Vec3> tetrahedron;
|
||||
tetrahedron.push_back(Vec3::sZero());
|
||||
tetrahedron.push_back(Vec3(10, 0, 12.5f));
|
||||
tetrahedron.push_back(Vec3(15, 0, 2.5f));
|
||||
tetrahedron.push_back(Vec3(10, -5, 5));
|
||||
|
||||
// Create vertices for box
|
||||
Array<Vec3> box;
|
||||
box.push_back(Vec3(1, 2, 3));
|
||||
box.push_back(Vec3(-1, 2, 3));
|
||||
box.push_back(Vec3(1, -2, 3));
|
||||
box.push_back(Vec3(-1, -2, 3));
|
||||
box.push_back(Vec3(1, 2, -3));
|
||||
box.push_back(Vec3(-1, 2, -3));
|
||||
box.push_back(Vec3(1, -2, -3));
|
||||
box.push_back(Vec3(-1, -2, -3));
|
||||
|
||||
// Rotate and translate vertices
|
||||
Mat44 m = Mat44::sTranslation(Vec3(3.0f, -2.0f, 1.0f)) * Mat44::sRotationY(0.2f * JPH_PI) * Mat44::sRotationZ(0.1f * JPH_PI);
|
||||
for (Vec3 &v : box)
|
||||
v = m * v;
|
||||
|
||||
// Create convex hulls
|
||||
RefConst<ShapeSettings> hull_shape[2] = { new ConvexHullShapeSettings(tetrahedron), new ConvexHullShapeSettings(box) };
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(hull_shape[i], RVec3(-40, 10, i * 20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(hull_shape[i], Vec3::sReplicate(0.25f)), RVec3(-20, 10, i * 20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(hull_shape[i], Vec3(0.25f, 0.5f, 1.5f)), RVec3(0, 10, i * 20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(hull_shape[i], Vec3(-0.25f, 0.5f, -1.5f)), RVec3(20, 10, i * 20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(hull_shape[i], Vec3(-0.25f, 0.5f, 1.5f)), RVec3(40, 10, i * 20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledConvexHullShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledConvexHullShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledCylinderShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/CylinderShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledCylinderShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledCylinderShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledCylinderShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create cylinder
|
||||
RefConst<CylinderShape> cylinder_shape = new CylinderShape(3.0f, 2.0f);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(cylinder_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(cylinder_shape, Vec3::sReplicate(0.25f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(cylinder_shape, Vec3(0.25f, 0.5f, 0.25f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(cylinder_shape, Vec3(-1.5f, -0.5f, 1.5f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(cylinder_shape, Vec3(-0.25f, 1.5f, 0.25f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledCylinderShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledCylinderShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledHeightFieldShapeTest.h>
|
||||
#include <External/Perlin.h>
|
||||
#include <Jolt/Physics/Collision/Shape/HeightFieldShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledHeightFieldShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledHeightFieldShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledHeightFieldShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
const int n = 64;
|
||||
const float cell_size = 0.25f;
|
||||
const float max_height = 4.0f;
|
||||
|
||||
// Create height samples
|
||||
float heights[n * n];
|
||||
for (int y = 0; y < n; ++y)
|
||||
for (int x = 0; x < n; ++x)
|
||||
heights[y * n + x] = max_height * PerlinNoise3(float(x) * 2.0f / n, 0, float(y) * 2.0f / n, 256, 256, 256);
|
||||
|
||||
// Create 'wall' around height field
|
||||
for (int x = 0; x < n; ++x)
|
||||
{
|
||||
heights[x] += 2.0f;
|
||||
heights[x + n * (n - 1)] += 2.0f;
|
||||
}
|
||||
|
||||
for (int y = 1; y < n - 1; ++y)
|
||||
{
|
||||
heights[n * y] += 2.0f;
|
||||
heights[n - 1 + n * y] += 2.0f;
|
||||
}
|
||||
|
||||
// Create height field
|
||||
RefConst<ShapeSettings> height_field = new HeightFieldShapeSettings(heights, Vec3(-0.5f * cell_size * n, 0.0f, -0.5f * cell_size * n), Vec3(cell_size, 1.0f, cell_size), n);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(height_field, RVec3(-60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(height_field, Vec3::sReplicate(0.5f)), RVec3(-40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(height_field, Vec3::sReplicate(1.5f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(height_field, Vec3(0.5f, 1.0f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(height_field, Vec3(-0.5f, 1.0f, -1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(height_field, Vec3(-0.5f, 1.0f, 1.5f)), RVec3(40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Upside down
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(height_field, Vec3(0.5f, -1.0f, 1.5f)), RVec3(60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Create a number of balls above the height fields
|
||||
RefConst<Shape> sphere_shape = new SphereShape(0.2f);
|
||||
RefConst<Shape> box_shape = new BoxShape(Vec3(0.2f, 0.2f, 0.4f), 0.01f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (int j = 0; j < 5; ++j)
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings((j & 1)? box_shape : sphere_shape, RVec3(-60.0f + 20.0f * i, 10.0f + max_height + 0.5f * j, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledHeightFieldShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledHeightFieldShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,99 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledMeshShapeTest.h>
|
||||
#include <External/Perlin.h>
|
||||
#include <Jolt/Physics/Collision/Shape/MeshShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledMeshShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledMeshShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledMeshShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
const int n = 10;
|
||||
const float cell_size = 2.0f;
|
||||
const float max_height = 4.0f;
|
||||
|
||||
// Create heights
|
||||
float heights[n + 1][n + 1];
|
||||
for (int x = 0; x <= n; ++x)
|
||||
for (int z = 0; z <= n; ++z)
|
||||
heights[x][z] = max_height * PerlinNoise3(float(x) / n, 0, float(z) / n, 256, 256, 256);
|
||||
|
||||
// Create 'wall' around grid
|
||||
for (int x = 0; x <= n; ++x)
|
||||
{
|
||||
heights[x][0] += 2.0f;
|
||||
heights[x][n] += 2.0f;
|
||||
}
|
||||
|
||||
for (int y = 1; y < n; ++y)
|
||||
{
|
||||
heights[0][y] += 2.0f;
|
||||
heights[n][y] += 2.0f;
|
||||
}
|
||||
|
||||
// Create regular grid of triangles
|
||||
TriangleList triangles;
|
||||
for (int x = 0; x < n; ++x)
|
||||
for (int z = 0; z < n; ++z)
|
||||
{
|
||||
float center = n * cell_size / 2;
|
||||
|
||||
float x1 = cell_size * x - center;
|
||||
float z1 = cell_size * z - center;
|
||||
float x2 = x1 + cell_size;
|
||||
float z2 = z1 + cell_size;
|
||||
|
||||
Float3 v1 = Float3(x1, heights[x][z], z1);
|
||||
Float3 v2 = Float3(x2, heights[x + 1][z], z1);
|
||||
Float3 v3 = Float3(x1, heights[x][z + 1], z2);
|
||||
Float3 v4 = Float3(x2, heights[x + 1][z + 1], z2);
|
||||
|
||||
triangles.push_back(Triangle(v1, v3, v4));
|
||||
triangles.push_back(Triangle(v1, v4, v2));
|
||||
}
|
||||
|
||||
RefConst<ShapeSettings> mesh_shape = new MeshShapeSettings(triangles);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(mesh_shape, RVec3(-60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(mesh_shape, Vec3::sReplicate(0.5f)), RVec3(-40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(mesh_shape, Vec3::sReplicate(1.5f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(mesh_shape, Vec3(0.5f, 1.0f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(mesh_shape, Vec3(-0.5f, 1.0f, -1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(mesh_shape, Vec3(-0.5f, 1.0f, 1.5f)), RVec3(40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Upside down
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(mesh_shape, Vec3(0.5f, -1.0f, 1.5f)), RVec3(60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Create a number of balls above the meshes
|
||||
RefConst<Shape> sphere_shape = new SphereShape(0.2f);
|
||||
RefConst<Shape> box_shape = new BoxShape(Vec3(0.2f, 0.2f, 0.4f), 0.01f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (int j = 0; j < 5; ++j)
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings((j & 1)? box_shape : sphere_shape, RVec3(-60.0f + 20.0f * i, 10.0f + max_height + 0.5f * j, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledMeshShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledMeshShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledMutableCompoundShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ConvexHullShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/MutableCompoundShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledMutableCompoundShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledMutableCompoundShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledMutableCompoundShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Left end
|
||||
Array<Vec3> end1;
|
||||
end1.push_back(Vec3(0, 0, 0));
|
||||
end1.push_back(Vec3(0, 0, 1));
|
||||
end1.push_back(Vec3(2, 0, 0));
|
||||
end1.push_back(Vec3(2, 0, 1));
|
||||
end1.push_back(Vec3(0, 1, 0));
|
||||
end1.push_back(Vec3(0, 1, 1));
|
||||
end1.push_back(Vec3(2, 1, 0));
|
||||
end1.push_back(Vec3(2, 1, 1));
|
||||
RefConst<ShapeSettings> end1_shape = new ConvexHullShapeSettings(end1);
|
||||
|
||||
// Right end
|
||||
Array<Vec3> end2;
|
||||
end2.push_back(Vec3(0, 0, 0));
|
||||
end2.push_back(Vec3(0, 0, 5));
|
||||
end2.push_back(Vec3(0, 1, 0));
|
||||
end2.push_back(Vec3(0, 1, 5));
|
||||
end2.push_back(Vec3(1, 0, 0));
|
||||
end2.push_back(Vec3(1, 0, 5));
|
||||
end2.push_back(Vec3(1, 1, 0));
|
||||
end2.push_back(Vec3(1, 1, 5));
|
||||
RefConst<ShapeSettings> end2_shape = new ConvexHullShapeSettings(end2);
|
||||
|
||||
// Central part
|
||||
Array<Vec3> center;
|
||||
center.push_back(Vec3(0, 0, 0));
|
||||
center.push_back(Vec3(0, 0, 1));
|
||||
center.push_back(Vec3(0, 1, 0));
|
||||
center.push_back(Vec3(0, 1, 1));
|
||||
center.push_back(Vec3(10, 0, 0));
|
||||
center.push_back(Vec3(10, 0, 1));
|
||||
center.push_back(Vec3(10, 1, 0));
|
||||
center.push_back(Vec3(10, 1, 1));
|
||||
RefConst<ShapeSettings> center_shape = new ConvexHullShapeSettings(center);
|
||||
|
||||
// Create compound
|
||||
Ref<MutableCompoundShapeSettings> compound_shape = new MutableCompoundShapeSettings;
|
||||
compound_shape->AddShape(Vec3(-5, -1.5f, -0.5f), Quat::sRotation(Vec3::sAxisZ(), 0.5f * JPH_PI), end1_shape);
|
||||
compound_shape->AddShape(Vec3(5, -0.5f, -0.5f), Quat::sIdentity(), end2_shape);
|
||||
compound_shape->AddShape(Vec3(-5, -0.5f, -0.5f), Quat::sIdentity(), center_shape);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(compound_shape, RVec3(-40, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3::sReplicate(0.25f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3(0.25f, 0.5f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3(-0.25f, 0.5f, -1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3(-0.25f, 0.5f, 1.5f)), RVec3(40, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledMutableCompoundShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledMutableCompoundShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledOffsetCenterOfMassShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/CylinderShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledOffsetCenterOfMassShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledOffsetCenterOfMassShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledOffsetCenterOfMassShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
Body &floor = CreateFloor();
|
||||
floor.SetFriction(1.0f);
|
||||
|
||||
Ref<ShapeSettings> cylinder = new CylinderShapeSettings(1.0f, 0.1f);
|
||||
Ref<OffsetCenterOfMassShapeSettings> top = new OffsetCenterOfMassShapeSettings(Vec3(0, 1, 0), cylinder);
|
||||
Ref<OffsetCenterOfMassShapeSettings> bottom = new OffsetCenterOfMassShapeSettings(Vec3(0, -1, 0), cylinder);
|
||||
|
||||
// Initial body rotation
|
||||
Quat rotation = Quat::sRotation(Vec3::sAxisZ(), 0.4f * JPH_PI);
|
||||
|
||||
// Cylinder with center of mass moved to the top side
|
||||
Body &body_top = *mBodyInterface->CreateBody(BodyCreationSettings(new ScaledShapeSettings(top, Vec3(2.0f, 1.0f, 2.0f)), RVec3(-5, 5, 0), rotation, EMotionType::Dynamic, Layers::MOVING));
|
||||
body_top.SetFriction(1.0f);
|
||||
mBodyInterface->AddBody(body_top.GetID(), EActivation::Activate);
|
||||
|
||||
// Cylinder with center of mass centered
|
||||
Body &body_center = *mBodyInterface->CreateBody(BodyCreationSettings(new ScaledShapeSettings(cylinder, Vec3(2.0f, 1.0f, 2.0f)), RVec3(0, 5, 0), rotation, EMotionType::Dynamic, Layers::MOVING));
|
||||
body_center.SetFriction(1.0f);
|
||||
mBodyInterface->AddBody(body_center.GetID(), EActivation::Activate);
|
||||
|
||||
// Cylinder with center of mass moved to the bottom side
|
||||
Body &body_bottom = *mBodyInterface->CreateBody(BodyCreationSettings(new ScaledShapeSettings(bottom, Vec3(2.0f, 1.0f, 2.0f)), RVec3(5, 5, 0), rotation, EMotionType::Dynamic, Layers::MOVING));
|
||||
body_bottom.SetFriction(1.0f);
|
||||
mBodyInterface->AddBody(body_bottom.GetID(), EActivation::Activate);
|
||||
|
||||
// Shape that is scaled before the offset center of mass offset is applied
|
||||
ShapeRefC pre_scaled = OffsetCenterOfMassShapeSettings(Vec3(0, 0, 5.0f), new ScaledShape(new SphereShape(1.0f), JPH::Vec3::sReplicate(2.0f))).Create().Get();
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(pre_scaled, RVec3(0, 5, -15), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Shape that is scaled after the offset center of mass offset is applied
|
||||
ShapeRefC post_scaled = new ScaledShape(OffsetCenterOfMassShapeSettings(Vec3(0, 0, 5.0f), new SphereShape(1.0f)).Create().Get(), JPH::Vec3::sReplicate(2.0f));
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(post_scaled, RVec3(5, 5, -15), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledOffsetCenterOfMassShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledOffsetCenterOfMassShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledPlaneShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/PlaneShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledPlaneShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledPlaneShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledPlaneShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
RefConst<ShapeSettings> plane_shape = new PlaneShapeSettings(Plane(Vec3(0.1f, 1.0f, 0.1f).Normalized(), -0.5f), nullptr, 5.0f);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(plane_shape, RVec3(-60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(plane_shape, Vec3::sReplicate(0.5f)), RVec3(-40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(plane_shape, Vec3::sReplicate(1.5f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(plane_shape, Vec3(0.5f, 1.0f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(plane_shape, Vec3(-0.5f, 1.0f, -1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(plane_shape, Vec3(-0.5f, 1.0f, 1.5f)), RVec3(40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Upside down
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(plane_shape, Vec3(0.5f, -1.0f, 1.5f)), RVec3(60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Create a number of balls above the planes
|
||||
RefConst<Shape> sphere_shape = new SphereShape(0.2f);
|
||||
RefConst<Shape> box_shape = new BoxShape(Vec3(0.2f, 0.2f, 0.4f), 0.01f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (int j = 0; j < 5; ++j)
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings((j & 1)? box_shape : sphere_shape, RVec3(-60.0f + 20.0f * i, 15.0f + 0.5f * j, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledPlaneShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledPlaneShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledSphereShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledSphereShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledSphereShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledSphereShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create sphere
|
||||
RefConst<SphereShape> sphere_shape = new SphereShape(2.0f);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(sphere_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(sphere_shape, Vec3::sReplicate(0.25f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(sphere_shape, Vec3::sReplicate(2.0f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(sphere_shape, Vec3(-0.25f, 0.25f, -0.25f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(sphere_shape, Vec3::sReplicate(-0.25f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledSphereShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledSphereShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledStaticCompoundShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ConvexHullShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/StaticCompoundShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledStaticCompoundShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledStaticCompoundShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledStaticCompoundShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Left end
|
||||
Array<Vec3> end1;
|
||||
end1.push_back(Vec3(0, 0, 0));
|
||||
end1.push_back(Vec3(0, 0, 1));
|
||||
end1.push_back(Vec3(2, 0, 0));
|
||||
end1.push_back(Vec3(2, 0, 1));
|
||||
end1.push_back(Vec3(0, 1, 0));
|
||||
end1.push_back(Vec3(0, 1, 1));
|
||||
end1.push_back(Vec3(2, 1, 0));
|
||||
end1.push_back(Vec3(2, 1, 1));
|
||||
RefConst<ShapeSettings> end1_shape = new ConvexHullShapeSettings(end1);
|
||||
|
||||
// Right end
|
||||
Array<Vec3> end2;
|
||||
end2.push_back(Vec3(0, 0, 0));
|
||||
end2.push_back(Vec3(0, 0, 5));
|
||||
end2.push_back(Vec3(0, 1, 0));
|
||||
end2.push_back(Vec3(0, 1, 5));
|
||||
end2.push_back(Vec3(1, 0, 0));
|
||||
end2.push_back(Vec3(1, 0, 5));
|
||||
end2.push_back(Vec3(1, 1, 0));
|
||||
end2.push_back(Vec3(1, 1, 5));
|
||||
RefConst<ShapeSettings> end2_shape = new ConvexHullShapeSettings(end2);
|
||||
|
||||
// Central part
|
||||
Array<Vec3> center;
|
||||
center.push_back(Vec3(0, 0, 0));
|
||||
center.push_back(Vec3(0, 0, 1));
|
||||
center.push_back(Vec3(0, 1, 0));
|
||||
center.push_back(Vec3(0, 1, 1));
|
||||
center.push_back(Vec3(10, 0, 0));
|
||||
center.push_back(Vec3(10, 0, 1));
|
||||
center.push_back(Vec3(10, 1, 0));
|
||||
center.push_back(Vec3(10, 1, 1));
|
||||
RefConst<ShapeSettings> center_shape = new ConvexHullShapeSettings(center);
|
||||
|
||||
// Create compound
|
||||
Ref<StaticCompoundShapeSettings> compound_shape = new StaticCompoundShapeSettings;
|
||||
compound_shape->AddShape(Vec3(-5, -1.5f, -0.5f), Quat::sRotation(Vec3::sAxisZ(), 0.5f * JPH_PI), end1_shape);
|
||||
compound_shape->AddShape(Vec3(5, -0.5f, -0.5f), Quat::sIdentity(), end2_shape);
|
||||
compound_shape->AddShape(Vec3(-5, -0.5f, -0.5f), Quat::sIdentity(), center_shape);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(compound_shape, RVec3(-40, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3::sReplicate(0.25f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3(0.25f, 0.5f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3(-0.25f, 0.5f, -1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(compound_shape, Vec3(-0.25f, 0.5f, 1.5f)), RVec3(40, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledStaticCompoundShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledStaticCompoundShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledTaperedCapsuleShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/TaperedCapsuleShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledTaperedCapsuleShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledTaperedCapsuleShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledTaperedCapsuleShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create tapered capsule
|
||||
RefConst<ShapeSettings> tapered_capsule_shape = new TaperedCapsuleShapeSettings(2.0f, 0.75f, 1.25f);
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(tapered_capsule_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(tapered_capsule_shape, Vec3::sReplicate(0.25f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(tapered_capsule_shape, Vec3::sReplicate(2.0f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(tapered_capsule_shape, Vec3(-1.5f, -1.5f, 1.5f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShapeSettings(tapered_capsule_shape, Vec3::sReplicate(-0.75f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledTaperedCapsuleShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledTaperedCapsuleShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledTaperedCylinderShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/TaperedCylinderShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledTaperedCylinderShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledTaperedCylinderShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledTaperedCylinderShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Create tapered cylinder
|
||||
RefConst<Shape> tapered_cylinder_shape = TaperedCylinderShapeSettings(2.0f, 0.75f, 1.25f).Create().Get();
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(tapered_cylinder_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Uniformly scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3::sReplicate(0.25f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3(0.25f, 0.5f, 0.25f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3(-1.5f, -0.5f, 1.5f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3(-0.25f, 1.5f, 0.25f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledTaperedCylinderShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledTaperedCylinderShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/ScaledShapes/ScaledTriangleShapeTest.h>
|
||||
#include <Jolt/Physics/Collision/Shape/TriangleShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ScaledShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/BoxShape.h>
|
||||
#include <Jolt/Physics/Collision/Shape/SphereShape.h>
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Layers.h>
|
||||
|
||||
JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledTriangleShapeTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(ScaledTriangleShapeTest, Test)
|
||||
}
|
||||
|
||||
void ScaledTriangleShapeTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
// Single triangle
|
||||
RefConst<TriangleShape> triangle_shape = new TriangleShape(Vec3(-10, -1, 0), Vec3(0, 1, 10), Vec3(10, -2, -10));
|
||||
|
||||
// Original shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(triangle_shape, RVec3(-60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape < 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(triangle_shape, Vec3::sReplicate(0.5f)), RVec3(-40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Uniformly scaled shape > 1
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(triangle_shape, Vec3::sReplicate(1.5f)), RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Non-uniform scaled shape
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(triangle_shape, Vec3(0.5f, 1.0f, 1.5f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Flipped in 2 axis
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(triangle_shape, Vec3(-0.5f, 1.0f, -1.5f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Inside out
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(triangle_shape, Vec3(-0.5f, 1.0f, 1.5f)), RVec3(40, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Upside down
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(triangle_shape, Vec3(0.5f, -1.0f, 1.5f)), RVec3(60, 10, 0), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING), EActivation::DontActivate);
|
||||
|
||||
// Create a number of balls above the triangles
|
||||
RefConst<Shape> sphere_shape = new SphereShape(0.2f);
|
||||
RefConst<Shape> box_shape = new BoxShape(Vec3(0.2f, 0.2f, 0.4f), 0.01f);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
for (int j = 0; j < 5; ++j)
|
||||
mBodyInterface->CreateAndAddBody(BodyCreationSettings((j & 1)? box_shape : sphere_shape, RVec3(-60.0f + 20.0f * i, 10.0f + 0.5f * j, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Tests/Test.h>
|
||||
|
||||
class ScaledTriangleShapeTest : public Test
|
||||
{
|
||||
public:
|
||||
JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, ScaledTriangleShapeTest)
|
||||
|
||||
// See: Test
|
||||
virtual void Initialize() override;
|
||||
};
|
||||
Reference in New Issue
Block a user