ScaledTaperedCylinderShapeTest.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2024 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <TestFramework.h>
  5. #include <Tests/ScaledShapes/ScaledTaperedCylinderShapeTest.h>
  6. #include <Jolt/Physics/Collision/Shape/TaperedCylinderShape.h>
  7. #include <Jolt/Physics/Collision/Shape/ScaledShape.h>
  8. #include <Jolt/Physics/Body/BodyCreationSettings.h>
  9. #include <Layers.h>
  10. JPH_IMPLEMENT_RTTI_VIRTUAL(ScaledTaperedCylinderShapeTest)
  11. {
  12. JPH_ADD_BASE_CLASS(ScaledTaperedCylinderShapeTest, Test)
  13. }
  14. void ScaledTaperedCylinderShapeTest::Initialize()
  15. {
  16. // Floor
  17. CreateFloor();
  18. // Create tapered cylinder
  19. RefConst<Shape> tapered_cylinder_shape = TaperedCylinderShapeSettings(2.0f, 0.75f, 1.25f).Create().Get();
  20. // Original shape
  21. mBodyInterface->CreateAndAddBody(BodyCreationSettings(tapered_cylinder_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  22. // Uniformly scaled shape
  23. mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3::sReplicate(0.25f)), RVec3(-10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  24. // Non-uniform scaled shape
  25. mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3(0.25f, 0.5f, 0.25f)), RVec3(0, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  26. // Flipped in 2 axis
  27. mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3(-1.5f, -0.5f, 1.5f)), RVec3(10, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  28. // Inside out
  29. mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(tapered_cylinder_shape, Vec3(-0.25f, 1.5f, 0.25f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  30. }