mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-09 21:54:35 +00:00
initial commit jolt
This commit is contained in:
parent
0c2aa5328c
commit
8acf7da95b
1086 changed files with 214612 additions and 4 deletions
|
|
@ -0,0 +1,44 @@
|
|||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <TestFramework.h>
|
||||
|
||||
#include <Tests/General/RestitutionTest.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(RestitutionTest)
|
||||
{
|
||||
JPH_ADD_BASE_CLASS(RestitutionTest, Test)
|
||||
}
|
||||
|
||||
void RestitutionTest::Initialize()
|
||||
{
|
||||
// Floor
|
||||
CreateFloor();
|
||||
|
||||
RefConst<Shape> sphere = new SphereShape(2.0f);
|
||||
RefConst<Shape> box = new BoxShape(Vec3(2.0f, 2.0f, 2.0f));
|
||||
|
||||
// Bodies with increasing restitution
|
||||
for (int i = 0; i <= 10; ++i)
|
||||
{
|
||||
BodyCreationSettings settings(sphere, RVec3(-50.0f + i * 10.0f, 20.0f, -20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING);
|
||||
settings.mRestitution = 0.1f * i;
|
||||
settings.mLinearDamping = 0.0f;
|
||||
BodyID id = mBodyInterface->CreateAndAddBody(settings, EActivation::Activate);
|
||||
SetBodyLabel(id, StringFormat("Restitution: %.1f", double(settings.mRestitution)));
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 10; ++i)
|
||||
{
|
||||
BodyCreationSettings settings(box, RVec3(-50.0f + i * 10.0f, 20.0f, 20.0f), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING);
|
||||
settings.mRestitution = 0.1f * i;
|
||||
settings.mLinearDamping = 0.0f;
|
||||
BodyID id = mBodyInterface->CreateAndAddBody(settings, EActivation::Activate);
|
||||
SetBodyLabel(id, StringFormat("Restitution: %.1f", double(settings.mRestitution)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue