SoftBodyPressureTest.cpp 855 B

1234567891011121314151617181920212223242526272829303132
  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));
  19. sphere.mObjectLayer = Layers::MOVING;
  20. for (int i = 0; i <= 10; ++i)
  21. {
  22. sphere.mPosition = RVec3(-50.0f + i * 10.0f, 10.0f, 0);
  23. sphere.mPressure = 1000.0f * i;
  24. mBodyInterface->CreateAndAddSoftBody(sphere, EActivation::Activate);
  25. }
  26. }