2
0

IslandTest.cpp 977 B

123456789101112131415161718192021222324252627282930313233
  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/IslandTest.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(IslandTest)
  10. {
  11. JPH_ADD_BASE_CLASS(IslandTest, Test)
  12. }
  13. void IslandTest::Initialize()
  14. {
  15. // Floor
  16. CreateFloor();
  17. RefConst<Shape> box_shape = new BoxShape(Vec3(1.0f, 1.0f, 1.0f));
  18. // Walls
  19. for (int i = 0; i < 10; ++i)
  20. for (int j = i / 2; j < 10 - (i + 1) / 2; ++j)
  21. for (int k = 0; k < 8; ++k)
  22. {
  23. RVec3 position(-10 + j * 2.0f + (i & 1? 1.0f : 0.0f), 1.0f + i * 2.0f, 8.0f * (k - 4));
  24. Body &wall = *mBodyInterface->CreateBody(BodyCreationSettings(box_shape, position, Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING));
  25. mBodyInterface->AddBody(wall.GetID(), EActivation::Activate);
  26. }
  27. }