ScaledCylinderShapeTest.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #include <TestFramework.h>
  5. #include <Tests/ScaledShapes/ScaledCylinderShapeTest.h>
  6. #include <Jolt/Physics/Collision/Shape/CylinderShape.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(ScaledCylinderShapeTest)
  11. {
  12. JPH_ADD_BASE_CLASS(ScaledCylinderShapeTest, Test)
  13. }
  14. void ScaledCylinderShapeTest::Initialize()
  15. {
  16. // Floor
  17. CreateFloor();
  18. // Create cylinder
  19. RefConst<CylinderShape> cylinder_shape = new CylinderShape(3.0f, 2.0f);
  20. // Original shape
  21. mBodyInterface->CreateAndAddBody(BodyCreationSettings(cylinder_shape, RVec3(-20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  22. // Uniformly scaled shape
  23. mBodyInterface->CreateAndAddBody(BodyCreationSettings(new ScaledShape(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(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(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(cylinder_shape, Vec3(-0.25f, 1.5f, 0.25f)), RVec3(20, 10, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING), EActivation::Activate);
  30. }