StackTest.cpp 959 B

1234567891011121314151617181920212223242526272829303132333435
  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/StackTest.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(StackTest)
  10. {
  11. JPH_ADD_BASE_CLASS(StackTest, Test)
  12. }
  13. void StackTest::Initialize()
  14. {
  15. // Floor
  16. CreateFloor();
  17. RefConst<Shape> box_shape = new BoxShape(Vec3(0.5f, 1.0f, 2.0f));
  18. // Dynamic body stack
  19. for (int i = 0; i < 10; ++i)
  20. {
  21. Quat rotation;
  22. if ((i & 1) != 0)
  23. rotation = Quat::sRotation(Vec3::sAxisY(), 0.5f * JPH_PI);
  24. else
  25. rotation = Quat::sIdentity();
  26. Body &stack = *mBodyInterface->CreateBody(BodyCreationSettings(box_shape, RVec3(10, 1.0f + i * 2.1f, 0), rotation, EMotionType::Dynamic, Layers::MOVING));
  27. mBodyInterface->AddBody(stack.GetID(), EActivation::Activate);
  28. }
  29. }