SoftBodyPressureTest.cpp 867 B

12345678910111213141516171819202122232425262728293031
  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/SoftBodyPressureTest.h>
  6. #include <Jolt/Physics/SoftBody/SoftBodyCreationSettings.h>
  7. #include <Utils/SoftBodyCreator.h>
  8. #include <Layers.h>
  9. JPH_IMPLEMENT_RTTI_VIRTUAL(SoftBodyPressureTest)
  10. {
  11. JPH_ADD_BASE_CLASS(SoftBodyPressureTest, Test)
  12. }
  13. void SoftBodyPressureTest::Initialize()
  14. {
  15. // Floor
  16. CreateFloor();
  17. // Bodies with increasing pressure
  18. SoftBodyCreationSettings sphere(SoftBodyCreator::CreateSphere(2.0f), RVec3::sZero(), Quat::sIdentity(), Layers::MOVING);
  19. for (int i = 0; i <= 10; ++i)
  20. {
  21. sphere.mPosition = RVec3(-50.0f + i * 10.0f, 10.0f, 0);
  22. sphere.mPressure = 1000.0f * i;
  23. mBodyInterface->CreateAndAddSoftBody(sphere, EActivation::Activate);
  24. }
  25. }