SoftBodyUpdatePositionTest.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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/SoftBodyUpdatePositionTest.h>
  6. #include <Jolt/Physics/SoftBody/SoftBodyCreationSettings.h>
  7. #include <Utils/SoftBodyCreator.h>
  8. #include <Layers.h>
  9. JPH_IMPLEMENT_RTTI_VIRTUAL(SoftBodyUpdatePositionTest)
  10. {
  11. JPH_ADD_BASE_CLASS(SoftBodyUpdatePositionTest, Test)
  12. }
  13. void SoftBodyUpdatePositionTest::Initialize()
  14. {
  15. // Floor
  16. CreateFloor();
  17. // Bodies with various settings for 'make rotation identity' and 'update position'
  18. SoftBodyCreationSettings sphere(SoftBodyCreator::CreateCube(), RVec3::sZero(), Quat::sRotation(Vec3::sReplicate(1.0f / sqrt(3.0f)), 0.25f * JPH_PI));
  19. sphere.mObjectLayer = Layers::MOVING;
  20. for (int update_position = 0; update_position < 2; ++update_position)
  21. for (int make_rotation_identity = 0; make_rotation_identity < 2; ++make_rotation_identity)
  22. {
  23. sphere.mPosition = RVec3(update_position * 10.0f, 10.0f, make_rotation_identity * 10.0f);
  24. sphere.mUpdatePosition = update_position != 0;
  25. sphere.mMakeRotationIdentity = make_rotation_identity != 0;
  26. mBodyInterface->CreateAndAddSoftBody(sphere, EActivation::Activate);
  27. }
  28. }