2
0

TriangleShapeTest.cpp 1.2 KB

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