SoftBodyUpdatePositionTest.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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), Layers::MOVING);
  19. for (int update_position = 0; update_position < 2; ++update_position)
  20. for (int make_rotation_identity = 0; make_rotation_identity < 2; ++make_rotation_identity)
  21. {
  22. sphere.mPosition = RVec3(update_position * 10.0f, 10.0f, make_rotation_identity * 10.0f);
  23. sphere.mUpdatePosition = update_position != 0;
  24. sphere.mMakeRotationIdentity = make_rotation_identity != 0;
  25. mBodyInterface->CreateAndAddSoftBody(sphere, EActivation::Activate);
  26. }
  27. }