TriangleShapeTest.cpp 1.1 KB

12345678910111213141516171819202122232425262728
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #include <TestFramework.h>
  4. #include <Tests/Shapes/TriangleShapeTest.h>
  5. #include <Jolt/Physics/Collision/Shape/TriangleShape.h>
  6. #include <Jolt/Physics/Collision/Shape/BoxShape.h>
  7. #include <Jolt/Physics/Body/BodyCreationSettings.h>
  8. #include <Layers.h>
  9. JPH_IMPLEMENT_RTTI_VIRTUAL(TriangleShapeTest)
  10. {
  11. JPH_ADD_BASE_CLASS(TriangleShapeTest, Test)
  12. }
  13. void TriangleShapeTest::Initialize()
  14. {
  15. // Single triangle
  16. RefConst<TriangleShape> triangle_shape = new TriangleShape(Vec3(-10, -1, 0), Vec3(0, 1, 10), Vec3(10, -2, -10), 0.01f);
  17. Body &body1 = *mBodyInterface->CreateBody(BodyCreationSettings(triangle_shape, Vec3::sZero(), Quat::sIdentity(), EMotionType::Static, Layers::NON_MOVING));
  18. mBodyInterface->AddBody(body1.GetID(), EActivation::DontActivate);
  19. // Create a box above the triangle
  20. RefConst<Shape> box_shape = new BoxShape(Vec3(0.2f, 0.2f, 0.4f), 0.01f);
  21. Body &dynamic = *mBodyInterface->CreateBody(BodyCreationSettings(box_shape, Vec3(0, 5, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
  22. mBodyInterface->AddBody(dynamic.GetID(), EActivation::Activate);
  23. }