StackTest.cpp 899 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #include <TestFramework.h>
  4. #include <Tests/General/StackTest.h>
  5. #include <Jolt/Physics/Collision/Shape/BoxShape.h>
  6. #include <Jolt/Physics/Body/BodyCreationSettings.h>
  7. #include <Layers.h>
  8. JPH_IMPLEMENT_RTTI_VIRTUAL(StackTest)
  9. {
  10. JPH_ADD_BASE_CLASS(StackTest, Test)
  11. }
  12. void StackTest::Initialize()
  13. {
  14. // Floor
  15. CreateFloor();
  16. RefConst<Shape> box_shape = new BoxShape(Vec3(0.5f, 1.0f, 2.0f));
  17. // Dynamic body stack
  18. for (int i = 0; i < 10; ++i)
  19. {
  20. Quat rotation;
  21. if ((i & 1) != 0)
  22. rotation = Quat::sRotation(Vec3::sAxisY(), 0.5f * JPH_PI);
  23. else
  24. rotation = Quat::sIdentity();
  25. Body &stack = *mBodyInterface->CreateBody(BodyCreationSettings(box_shape, Vec3(10, 1.0f + i * 2.1f, 0), rotation, EMotionType::Dynamic, Layers::MOVING));
  26. mBodyInterface->AddBody(stack.GetID(), EActivation::Activate);
  27. }
  28. }