BigVsSmallTest.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <TestFramework.h>
  5. #include <Tests/General/BigVsSmallTest.h>
  6. #include <Jolt/Physics/Collision/Shape/BoxShape.h>
  7. #include <Jolt/Physics/Collision/Shape/MeshShape.h>
  8. #include <Jolt/Physics/Body/BodyCreationSettings.h>
  9. #include <Jolt/Geometry/Triangle.h>
  10. #include <Layers.h>
  11. JPH_IMPLEMENT_RTTI_VIRTUAL(BigVsSmallTest)
  12. {
  13. JPH_ADD_BASE_CLASS(BigVsSmallTest, Test)
  14. }
  15. void BigVsSmallTest::Initialize()
  16. {
  17. // Create a big triangle
  18. TriangleList triangles;
  19. triangles.push_back(Triangle(Float3(-100, 0, 0), Float3(0, 0, 100), Float3(100, 0, -100)));
  20. Body &triangle = *mBodyInterface->CreateBody(BodyCreationSettings(new MeshShapeSettings(triangles), RVec3::sZero(), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
  21. mBodyInterface->AddBody(triangle.GetID(), EActivation::DontActivate);
  22. // A small box
  23. Body &body = *mBodyInterface->CreateBody(BodyCreationSettings(new BoxShape(Vec3(0.1f, 0.1f, 0.1f)), RVec3(0, 1.0f, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
  24. body.SetAllowSleeping(false);
  25. mBodyInterface->AddBody(body.GetID(), EActivation::Activate);
  26. }