SoftBodyGravityFactorTest.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2023 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <TestFramework.h>
  5. #include <Tests/SoftBody/SoftBodyGravityFactorTest.h>
  6. #include <Jolt/Physics/SoftBody/SoftBodyCreationSettings.h>
  7. #include <Utils/SoftBodyCreator.h>
  8. #include <Layers.h>
  9. JPH_IMPLEMENT_RTTI_VIRTUAL(SoftBodyGravityFactorTest)
  10. {
  11. JPH_ADD_BASE_CLASS(SoftBodyGravityFactorTest, Test)
  12. }
  13. void SoftBodyGravityFactorTest::Initialize()
  14. {
  15. // Floor
  16. CreateFloor();
  17. // Bodies with increasing gravity factor
  18. SoftBodyCreationSettings sphere(SoftBodyCreator::CreateSphere());
  19. sphere.mObjectLayer = Layers::MOVING;
  20. sphere.mPressure = 2000.0f;
  21. for (int i = 0; i <= 10; ++i)
  22. {
  23. sphere.mPosition = RVec3(-50.0f + i * 10.0f, 10.0f, 0);
  24. sphere.mGravityFactor = 0.1f * i;
  25. mBodyInterface->CreateAndAddSoftBody(sphere, EActivation::Activate);
  26. }
  27. SoftBodyCreationSettings cube(SoftBodyCreator::CreateCube());
  28. cube.mObjectLayer = Layers::MOVING;
  29. for (int i = 0; i <= 10; ++i)
  30. {
  31. cube.mPosition = RVec3(-50.0f + i * 10.0f, 10.0f, -5.0f);
  32. cube.mGravityFactor = 0.1f * i;
  33. mBodyInterface->CreateAndAddSoftBody(cube, EActivation::Activate);
  34. }
  35. }