WallTest.cpp 869 B

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/WallTest.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(WallTest)
  10. {
  11. JPH_ADD_BASE_CLASS(WallTest, Test)
  12. }
  13. void WallTest::Initialize()
  14. {
  15. // Floor
  16. CreateFloor();
  17. RefConst<Shape> box_shape = new BoxShape(Vec3(1.0f, 1.0f, 1.0f));
  18. // Wall
  19. for (int i = 0; i < 10; ++i)
  20. for (int j = i / 2; j < 50 - (i + 1) / 2; ++j)
  21. {
  22. RVec3 position(-50 + j * 2.0f + (i & 1? 1.0f : 0.0f), 1.0f + i * 3.0f, 0);
  23. mBodyInterface->CreateAndAddBody(BodyCreationSettings(box_shape, position, Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  24. }
  25. }