├── .clang_complete
├── .coveralls.yml
├── Documentation
├── .gitignore
├── images
│ ├── Chain1.png
│ ├── Tunnel1.png
│ ├── missed.png
│ ├── modules.png
│ ├── raycast.png
│ ├── testbed.gif
│ ├── winding.png
│ ├── DebugDraw.png
│ ├── captured.png
│ ├── distance.png
│ ├── gearJoint.gif
│ ├── manifolds.png
│ ├── tunneling.png
│ ├── Testbed
│ │ ├── Car.png
│ │ ├── Web.png
│ │ ├── Bridge.png
│ │ ├── Chain.png
│ │ ├── Gears.png
│ │ ├── Mobile.png
│ │ ├── Tiles.png
│ │ ├── BodyTypes.png
│ │ ├── Breakable.png
│ │ ├── Confined.png
│ │ ├── Dominos.png
│ │ ├── DumpShell.png
│ │ ├── EdgeTest.png
│ │ ├── HalfPipe.png
│ │ ├── Orbiter.png
│ │ ├── Pinball.png
│ │ ├── Prismatic.png
│ │ ├── Pulleys.png
│ │ ├── Pyramid.png
│ │ ├── RayCast.png
│ │ ├── Revolute.png
│ │ ├── RopeJoint.png
│ │ ├── Tumbler.png
│ │ ├── ApplyForce.png
│ │ ├── BagOfDisks.png
│ │ ├── BulletTest.png
│ │ ├── Cantilever.png
│ │ ├── ConvexHull.png
│ │ ├── EdgeShapes.png
│ │ ├── JointsTest.png
│ │ ├── MotorJoint.png
│ │ ├── PolyShapes.png
│ │ ├── SensorTest.png
│ │ ├── SliderCrank.png
│ │ ├── SphereStack.png
│ │ ├── TheoJansens.png
│ │ ├── BreakableTwo.png
│ │ ├── CompoundShapes.png
│ │ ├── ContinuousTest.png
│ │ ├── ConveyorBelt.png
│ │ ├── DistanceTest.png
│ │ ├── FifteenPuzzle.png
│ │ ├── HeavyOnLight.png
│ │ ├── MobileBalanced.png
│ │ ├── NewtonsCradle.png
│ │ ├── PolyCollision.png
│ │ ├── ShapeEditing.png
│ │ ├── SpinningCircle.png
│ │ ├── TimeOfImpact.png
│ │ ├── VerticalStack.png
│ │ ├── BasicSliderCrank.png
│ │ ├── HeavyOnLightTwo.png
│ │ ├── OneSidedPlatform.png
│ │ ├── VaryingFriction.png
│ │ ├── AddPairStressTest.png
│ │ ├── CharacterCollision.png
│ │ ├── CollisionFiltering.png
│ │ ├── CollisionProcessing.png
│ │ ├── VaryingRestitution.png
│ │ ├── iforce2d_TopdownCar.png
│ │ └── iforce2d_Trajectories.png
│ ├── WheelJoint.png
│ ├── bodyOrigin.gif
│ ├── pulleyJoint.gif
│ ├── regionquery.png
│ ├── GhostCollision.png
│ ├── GhostVertices.png
│ ├── SelfIntersect.png
│ ├── SkinCollision.png
│ ├── SkinnedPolygon.png
│ ├── convex_concave.gif
│ ├── distanceJoint.gif
│ ├── prismaticJoint.gif
│ ├── revoluteJoint.gif
│ ├── RoundedCornerShapes.png
│ ├── OriginalRectRectCollision.png
│ ├── ThresholdRectRectCollision.png
│ └── RoundCornerRectRectCollision.png
├── extra-words.dic
├── README.md
├── CMakeLists.txt
└── PhysicalUnits.md
├── Testbed
├── Data
│ └── DroidSans.ttf
├── Framework
│ ├── README.md
│ ├── UiState.hpp
│ ├── Drawer.cpp
│ ├── TestEntry.hpp
│ └── ExtensionsForImgui.cpp
└── Tests
│ ├── HalfPipe.cpp
│ ├── VaryingRestitution.cpp
│ ├── Chain.cpp
│ ├── SphereStack.cpp
│ └── Pyramid.cpp
├── Library
├── PlayRhoConfig.cmake.in
├── source
│ └── playrho
│ │ ├── d2
│ │ ├── DiskShapeConf.cpp
│ │ ├── part
│ │ │ └── Compositor.cpp
│ │ ├── UnitVec.cpp
│ │ ├── Sweep.cpp
│ │ ├── DistanceConf.cpp
│ │ ├── ContactImpulsesList.cpp
│ │ ├── Shape.cpp
│ │ ├── WorldMisc.cpp
│ │ ├── Velocity.cpp
│ │ ├── World.cpp
│ │ ├── JointConf.cpp
│ │ └── BodyConf.cpp
│ │ ├── MovementConf.cpp
│ │ ├── StepConf.cpp
│ │ ├── ToiConf.cpp
│ │ ├── LimitState.cpp
│ │ ├── StepStats.cpp
│ │ ├── Version.cpp
│ │ ├── Contact.cpp
│ │ ├── ConstraintSolverConf.cpp
│ │ ├── DynamicMemory.cpp
│ │ ├── pmr
│ │ └── StatsResource.cpp
│ │ └── ToiOutput.cpp
├── include
│ └── playrho
│ │ ├── WiderType.hpp
│ │ ├── Intervals.hpp
│ │ ├── d2
│ │ ├── RayCastInput.hpp
│ │ ├── ContactManifoldFunction.hpp
│ │ ├── ContactImpulsesFunction.hpp
│ │ ├── PositionConstraint.hpp
│ │ ├── PositionSolution.hpp
│ │ └── DistanceConf.hpp
│ │ ├── JointFunction.hpp
│ │ ├── ShapeFunction.hpp
│ │ ├── ContactFunction.hpp
│ │ ├── KeyedContactID.hpp
│ │ ├── WrongState.hpp
│ │ ├── LengthError.hpp
│ │ ├── BodyShapeFunction.hpp
│ │ ├── PointState.hpp
│ │ ├── to_underlying.hpp
│ │ ├── Finite.hpp
│ │ ├── OutOfRange.hpp
│ │ ├── MovementConf.hpp
│ │ ├── Defines.hpp
│ │ ├── Negative.hpp
│ │ ├── NonPositive.hpp
│ │ ├── UnitInterval.hpp
│ │ ├── ZeroToUnderOne.hpp
│ │ ├── LimitState.hpp
│ │ ├── Defines.hpp.in
│ │ ├── detail
│ │ ├── RayCastInput.hpp
│ │ ├── PositiveChecker.hpp
│ │ ├── NonZeroChecker.hpp
│ │ ├── NegativeChecker.hpp
│ │ ├── NonNegativeChecker.hpp
│ │ ├── NonPositiveChecker.hpp
│ │ └── UnitMagnitudeChecker.hpp
│ │ ├── RayCastOpcode.hpp
│ │ └── Vector3.hpp
└── README.md
├── Build
└── vs2017
│ ├── HelloWorld.vcxproj.filters
│ └── Testbed.vcxproj.filters
├── .gitmodules
├── .github
├── notes.md
├── PULL_REQUEST_TEMPLATE.md
├── workflows
│ ├── clang-tidy-review.yml
│ └── macos.yml
└── issue_template.md
├── HelloWorld
├── CMakeLists.txt
├── ExpectedOutput.txt
└── README.md
├── UnitTests
├── README.md
├── Angle.cpp
├── UnitTests.hpp
├── main.cpp
├── WorldFixture.cpp
├── BodyType.cpp
├── functional.cpp
├── BodyConstraint.cpp
├── PositionConstraint.cpp
├── double.cpp
├── IndexPair.cpp
├── BaseShapeConf.cpp
├── IslandStats.cpp
├── BodyID.cpp
├── FlagGuard.cpp
├── SimplexEdge.cpp
├── TypeInfo.cpp
├── polymorphic_allocator.cpp
└── Span.cpp
├── .editorconfig
├── LICENSE.txt
└── cmake
├── FindGLFW3.cmake
└── GetGitVersion.cmake
/.clang_complete:
--------------------------------------------------------------------------------
1 | -I.
2 |
--------------------------------------------------------------------------------
/.coveralls.yml:
--------------------------------------------------------------------------------
1 | service_name: travis-ci
2 |
--------------------------------------------------------------------------------
/Documentation/.gitignore:
--------------------------------------------------------------------------------
1 | API/
2 | en_US.aff
3 | en_US.dic
4 |
--------------------------------------------------------------------------------
/Testbed/Data/DroidSans.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Testbed/Data/DroidSans.ttf
--------------------------------------------------------------------------------
/Library/PlayRhoConfig.cmake.in:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include("${CMAKE_CURRENT_LIST_DIR}/PlayRho-targets.cmake")
4 |
--------------------------------------------------------------------------------
/Documentation/images/Chain1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Chain1.png
--------------------------------------------------------------------------------
/Documentation/images/Tunnel1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Tunnel1.png
--------------------------------------------------------------------------------
/Documentation/images/missed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/missed.png
--------------------------------------------------------------------------------
/Documentation/images/modules.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/modules.png
--------------------------------------------------------------------------------
/Documentation/images/raycast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/raycast.png
--------------------------------------------------------------------------------
/Documentation/images/testbed.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/testbed.gif
--------------------------------------------------------------------------------
/Documentation/images/winding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/winding.png
--------------------------------------------------------------------------------
/Documentation/images/DebugDraw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/DebugDraw.png
--------------------------------------------------------------------------------
/Documentation/images/captured.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/captured.png
--------------------------------------------------------------------------------
/Documentation/images/distance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/distance.png
--------------------------------------------------------------------------------
/Documentation/images/gearJoint.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/gearJoint.gif
--------------------------------------------------------------------------------
/Documentation/images/manifolds.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/manifolds.png
--------------------------------------------------------------------------------
/Documentation/images/tunneling.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/tunneling.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Car.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Web.png
--------------------------------------------------------------------------------
/Documentation/images/WheelJoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/WheelJoint.png
--------------------------------------------------------------------------------
/Documentation/images/bodyOrigin.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/bodyOrigin.gif
--------------------------------------------------------------------------------
/Documentation/images/pulleyJoint.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/pulleyJoint.gif
--------------------------------------------------------------------------------
/Documentation/images/regionquery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/regionquery.png
--------------------------------------------------------------------------------
/Documentation/images/GhostCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/GhostCollision.png
--------------------------------------------------------------------------------
/Documentation/images/GhostVertices.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/GhostVertices.png
--------------------------------------------------------------------------------
/Documentation/images/SelfIntersect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/SelfIntersect.png
--------------------------------------------------------------------------------
/Documentation/images/SkinCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/SkinCollision.png
--------------------------------------------------------------------------------
/Documentation/images/SkinnedPolygon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/SkinnedPolygon.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Bridge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Bridge.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Chain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Chain.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Gears.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Gears.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Mobile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Mobile.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Tiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Tiles.png
--------------------------------------------------------------------------------
/Documentation/images/convex_concave.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/convex_concave.gif
--------------------------------------------------------------------------------
/Documentation/images/distanceJoint.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/distanceJoint.gif
--------------------------------------------------------------------------------
/Documentation/images/prismaticJoint.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/prismaticJoint.gif
--------------------------------------------------------------------------------
/Documentation/images/revoluteJoint.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/revoluteJoint.gif
--------------------------------------------------------------------------------
/Documentation/images/Testbed/BodyTypes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/BodyTypes.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Breakable.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Breakable.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Confined.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Confined.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Dominos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Dominos.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/DumpShell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/DumpShell.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/EdgeTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/EdgeTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/HalfPipe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/HalfPipe.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Orbiter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Orbiter.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Pinball.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Pinball.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Prismatic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Prismatic.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Pulleys.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Pulleys.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Pyramid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Pyramid.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/RayCast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/RayCast.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Revolute.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Revolute.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/RopeJoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/RopeJoint.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Tumbler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Tumbler.png
--------------------------------------------------------------------------------
/Documentation/images/RoundedCornerShapes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/RoundedCornerShapes.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/ApplyForce.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/ApplyForce.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/BagOfDisks.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/BagOfDisks.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/BulletTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/BulletTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/Cantilever.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/Cantilever.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/ConvexHull.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/ConvexHull.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/EdgeShapes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/EdgeShapes.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/JointsTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/JointsTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/MotorJoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/MotorJoint.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/PolyShapes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/PolyShapes.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/SensorTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/SensorTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/SliderCrank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/SliderCrank.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/SphereStack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/SphereStack.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/TheoJansens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/TheoJansens.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/BreakableTwo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/BreakableTwo.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/CompoundShapes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/CompoundShapes.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/ContinuousTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/ContinuousTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/ConveyorBelt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/ConveyorBelt.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/DistanceTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/DistanceTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/FifteenPuzzle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/FifteenPuzzle.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/HeavyOnLight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/HeavyOnLight.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/MobileBalanced.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/MobileBalanced.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/NewtonsCradle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/NewtonsCradle.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/PolyCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/PolyCollision.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/ShapeEditing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/ShapeEditing.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/SpinningCircle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/SpinningCircle.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/TimeOfImpact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/TimeOfImpact.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/VerticalStack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/VerticalStack.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/BasicSliderCrank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/BasicSliderCrank.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/HeavyOnLightTwo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/HeavyOnLightTwo.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/OneSidedPlatform.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/OneSidedPlatform.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/VaryingFriction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/VaryingFriction.png
--------------------------------------------------------------------------------
/Documentation/images/OriginalRectRectCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/OriginalRectRectCollision.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/AddPairStressTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/AddPairStressTest.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/CharacterCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/CharacterCollision.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/CollisionFiltering.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/CollisionFiltering.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/CollisionProcessing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/CollisionProcessing.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/VaryingRestitution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/VaryingRestitution.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/iforce2d_TopdownCar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/iforce2d_TopdownCar.png
--------------------------------------------------------------------------------
/Documentation/images/ThresholdRectRectCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/ThresholdRectRectCollision.png
--------------------------------------------------------------------------------
/Documentation/images/RoundCornerRectRectCollision.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/RoundCornerRectRectCollision.png
--------------------------------------------------------------------------------
/Documentation/images/Testbed/iforce2d_Trajectories.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/louis-langholtz/PlayRho/HEAD/Documentation/images/Testbed/iforce2d_Trajectories.png
--------------------------------------------------------------------------------
/Build/vs2017/HelloWorld.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "UnitTests/googletest"]
2 | path = UnitTests/googletest
3 | url = https://github.com/google/googletest.git
4 | [submodule "Testbed/Framework/imgui"]
5 | path = Testbed/Framework/imgui
6 | url = https://github.com/louis-langholtz/imgui.git
7 | [submodule "Benchmark/googlebench"]
8 | path = Benchmark/googlebench
9 | url = https://github.com/google/benchmark.git
10 |
--------------------------------------------------------------------------------
/.github/notes.md:
--------------------------------------------------------------------------------
1 | # .github
2 |
3 | This directory/folder is for GitHub specific files.
4 | I.e. files which are special to GitHub, particularly its web interface.
5 |
6 | Here's some links to relevant information:
7 | - [Creating an issue template for your repository](https://help.github.com/articles/creating-an-issue-template-for-your-repository/).
8 | - [Creating a pull request template for your repository](https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/).
9 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | #### Description - What's this PR do?
2 | A few sentences describing the overall goals of the pull request's commits.
3 |
4 | #### Impacts/Risks of These Changes?
5 | List components of the library that this pull request will affect.
6 |
7 | #### Where should a reviewer start?
8 |
9 | #### How should this be tested?
10 |
11 | #### Any background context you want to provide?
12 |
13 | #### Related Issues
14 | List related issues.
15 |
16 | #### Related Pull Requests
17 | List related pull requests (if any).
18 |
19 | #### Screenshots (if appropriate)
20 |
--------------------------------------------------------------------------------
/Testbed/Framework/README.md:
--------------------------------------------------------------------------------
1 | # Testbed GUI Application Framework Directory
2 |
3 | This directory is for the Testbed's framework.
4 | You don't really need to know anything about it unless you want to add your own
5 | code to the Testbed.
6 |
7 | Subclassing `Test` is *part one* of the way to integrate code into the Testbed
8 | GUI application for demoing and visually testing code. After getting the
9 | subclass initially setup, *part two* of integrating code into the Testbed,
10 | is to add a reference to the subclass to the
11 | [TestEntry.cpp](TestEntry.cpp) file that's in this directory.
12 |
13 | See also the [Testbed README](../README.md).
14 |
--------------------------------------------------------------------------------
/HelloWorld/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Hello World examples
2 | add_executable(HelloWorld HelloWorld.cpp)
3 |
4 | target_link_libraries(HelloWorld PlayRho::PlayRho)
5 |
6 | # link with coverage library
7 | if(${PLAYRHO_ENABLE_COVERAGE})
8 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
9 | # Use -ftest-coverage to generate .gcno notes files.
10 | # Use -fprofile-arcs to generate .gcda count data files when resulting objects are run.
11 | target_link_libraries(HelloWorld -fprofile-arcs -ftest-coverage)
12 | endif()
13 | endif()
14 |
15 | if(PLAYRHO_INSTALL)
16 | include(GNUInstallDirs)
17 | install(TARGETS HelloWorld
18 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
19 | COMPONENT Applications)
20 | endif()
21 |
--------------------------------------------------------------------------------
/.github/workflows/clang-tidy-review.yml:
--------------------------------------------------------------------------------
1 | name: clang-tidy-review
2 |
3 | # You can be more specific, but it currently only works on pull requests
4 | on: [pull_request]
5 |
6 | jobs:
7 | build:
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v3
12 |
13 | # Optionally generate compile_commands.json
14 |
15 | - uses: ZedThree/clang-tidy-review@v0.10.1
16 | id: review
17 | with:
18 | clang_tidy_version: '14'
19 | config_file: 'Library/.clang-tidy'
20 | cmake_command: cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
21 | include: 'Library/*.[ch]pp'
22 |
23 | # If there are any comments, fail the check
24 | #- if: steps.review.outputs.total_comments > 0
25 | # run: exit 1
26 |
--------------------------------------------------------------------------------
/UnitTests/README.md:
--------------------------------------------------------------------------------
1 | # Unit Tests Console Application
2 |
3 | This application component provides unit testing of the PlayRho library code.
4 | It uses [Google's C++ test framework](https://github.com/google/googletest).
5 |
6 | ## Prerequisites
7 |
8 | This application currently relies on the `UnitTests/googletest` git sub module,
9 | so it has no prerequisites other than those for the [library component](../PlayRho/).
10 |
11 | ## Configuration
12 |
13 | This component needs the `PLAYRHO_BUILD_UNIT_TESTS` CMake option turned on.
14 | This can be achieved through the command line interface by adding the
15 | `-DPLAYRHO_BUILD_UNIT_TESTS=ON` argument to the CMake configuration step's list
16 | of arguments.
17 |
18 | ## Building & Installation
19 |
20 | See the project's [documented build and installation steps](../INSTALL.md).
21 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Configuration file for EditorConfig
2 | # More information is available under http://EditorConfig.org
3 |
4 | # Ignore any other files further up in the file system
5 | root = true
6 |
7 | # Configuration for all files
8 | [*]
9 | # Always end files with a blank line
10 | insert_final_newline = true
11 |
12 | [*.sln]
13 | # Enforce Windows style line endings (\n only)
14 | end_of_line = crlf
15 |
16 | [*.{txt,md}]
17 | # Enforce Unix style line endings (\n only)
18 | end_of_line = lf
19 |
20 | [*.{cpp,hpp}]
21 | # Enforce Unix style line endings (\n only)
22 | end_of_line = lf
23 | # Force space characters for indentation
24 | indent_style = space
25 | # Always indent by 4 characters
26 | indent_size = 4
27 | # Remove whitespace characters at the end of line
28 | trim_trailing_whitespace = true
29 | # Maximum allowed line length
30 | max_line_length = 100
31 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2006-2017 Erin Catto https://box2d.org
2 | Copyright (c) 2016-2023 Louis Langholtz https://github.com/louis-langholtz
3 |
4 | This software is provided 'as-is', without any express or implied
5 | warranty. In no event will the authors be held liable for any damages
6 | arising from the use of this software.
7 |
8 | Permission is granted to anyone to use this software for any purpose,
9 | including commercial applications, and to alter it and redistribute it
10 | freely, subject to the following restrictions:
11 |
12 | 1. The origin of this software must not be misrepresented; you must not
13 | claim that you wrote the original software. If you use this software
14 | in a product, an acknowledgment in the product documentation would be
15 | appreciated but is not required.
16 | 2. Altered source versions must be plainly marked as such, and must not be
17 | misrepresented as being the original software.
18 | 3. This notice may not be removed or altered from any source distribution.
19 |
--------------------------------------------------------------------------------
/Build/vs2017/Testbed.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {F5D5D9E8-9CBD-914E-B539-B995BEA73920}
6 |
7 |
8 | {CF6BC554-9DC6-4547-9F18-A1BA2F3345BF}
9 |
10 |
11 |
12 |
13 | Framework
14 |
15 |
16 | Tests
17 |
18 |
19 |
20 |
21 | Framework
22 |
23 |
24 | Tests
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.github/issue_template.md:
--------------------------------------------------------------------------------
1 | *Note: The text you see here is from the `issue_template.md` file.
2 | These are some optional guidelines for describing a new issue. If you're
3 | just looking to ask a programming question about PlayRho, consider asking
4 | on stackoverflow.com with the tag of "playrho". If you're looking to describe
5 | an issue with PlayRho however, please replace this text (the star enclosed
6 | text, i.e. the italicized text), with your own words.*
7 |
8 | ### Expected/Desired Behavior or Experience:
9 | *Replace this text with a description of the behavior that you had expected
10 | or the behavior that you would desire. For example: "I'd like to be able to
11 | use the builder pattern to state joint definitions".*
12 |
13 | ### Actual Behavior:
14 | *Replace this text with a description of the actual behavior or experience
15 | that you had.
16 | For example: "But instead of builder methods, I have to assign values line
17 | by line".*
18 |
19 | ### Steps to Reproduce the Actual Behavior:
20 | *Replace this text with a description of steps that can be used to
21 | reproduce the unexpected/undesired behavior or experience.*
22 |
--------------------------------------------------------------------------------
/UnitTests/Angle.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 |
--------------------------------------------------------------------------------
/UnitTests/UnitTests.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef UnitTests_hpp
22 | #define UnitTests_hpp
23 |
24 | #include "gtest/gtest.h"
25 |
26 | #endif /* UnitTests_hpp */
27 |
--------------------------------------------------------------------------------
/Documentation/extra-words.dic:
--------------------------------------------------------------------------------
1 | AABB
2 | AABBs
3 | accelerable
4 | algorithmically
5 | allocator
6 | arctangent
7 | barycentric
8 | bitwise
9 | CCD
10 | centi
11 | centroid
12 | chainable
13 | collinear
14 | configurability
15 | constructible
16 | CRTP
17 | deallocator
18 | deci
19 | deleter
20 | destructor
21 | functor
22 | giga
23 | gigameter
24 | gravitationally
25 | growable
26 | IEC
27 | incrementing
28 | initializer
29 | inlining
30 | intra
31 | invariants
32 | iterable
33 | Maclaurin
34 | massless
35 | misprediction
36 | mutator
37 | MSVC
38 | NaN
39 | Nathanael
40 | normals
41 | obtainer
42 | Piotr
43 | PlayRho
44 | polymorphism
45 | POSIX
46 | pre
47 | preallocated
48 | preallocation
49 | preprocessor
50 | Presson
51 | Presson's
52 | radian
53 | radians
54 | radiuses
55 | radix
56 | rebalances
57 | restitution
58 | restitutions
59 | revolute
60 | runtime
61 | simplex's
62 | simulatable
63 | Skotnicki
64 | Skotnicki's
65 | speedable
66 | squirrelly
67 | substep
68 | substeps
69 | templated
70 | TOI
71 | TOIs
72 | translational
73 | ULP
74 | unallocated
75 | unary
76 | underflows
77 | unflag
78 | unflags
79 | unregister
80 | unregisters
81 | unsets
82 | yotta
83 | yottagram
84 |
--------------------------------------------------------------------------------
/HelloWorld/ExpectedOutput.txt:
--------------------------------------------------------------------------------
1 | 0.00 4.00 0.00
2 | 0.00 3.99 0.00
3 | 0.00 3.98 0.00
4 | 0.00 3.97 0.00
5 | 0.00 3.96 0.00
6 | 0.00 3.94 0.00
7 | 0.00 3.92 0.00
8 | 0.00 3.90 0.00
9 | 0.00 3.88 0.00
10 | 0.00 3.85 0.00
11 | 0.00 3.82 0.00
12 | 0.00 3.79 0.00
13 | 0.00 3.75 0.00
14 | 0.00 3.71 0.00
15 | 0.00 3.67 0.00
16 | 0.00 3.63 0.00
17 | 0.00 3.58 0.00
18 | 0.00 3.53 0.00
19 | 0.00 3.48 0.00
20 | 0.00 3.43 0.00
21 | 0.00 3.37 0.00
22 | 0.00 3.31 0.00
23 | 0.00 3.25 0.00
24 | 0.00 3.18 0.00
25 | 0.00 3.12 0.00
26 | 0.00 3.04 0.00
27 | 0.00 2.97 0.00
28 | 0.00 2.89 0.00
29 | 0.00 2.82 0.00
30 | 0.00 2.73 0.00
31 | 0.00 2.65 0.00
32 | 0.00 2.56 0.00
33 | 0.00 2.47 0.00
34 | 0.00 2.38 0.00
35 | 0.00 2.28 0.00
36 | 0.00 2.19 0.00
37 | 0.00 2.09 0.00
38 | 0.00 1.98 0.00
39 | 0.00 1.88 0.00
40 | 0.00 1.77 0.00
41 | 0.00 1.66 0.00
42 | 0.00 1.54 0.00
43 | 0.00 1.42 0.00
44 | 0.00 1.30 0.00
45 | 0.00 1.18 0.00
46 | 0.00 1.06 0.00
47 | 0.00 1.00 0.00
48 | 0.00 1.00 0.00
49 | 0.00 1.00 0.00
50 | 0.00 1.00 0.00
51 | 0.00 1.00 0.00
52 | 0.00 1.00 0.00
53 | 0.00 1.00 0.00
54 | 0.00 1.00 0.00
55 | 0.00 1.00 0.00
56 | 0.00 1.00 0.00
57 | 0.00 1.00 0.00
58 | 0.00 1.00 0.00
59 | 0.00 1.00 0.00
60 | 0.00 1.00 0.00
61 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/DiskShapeConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 |
23 | #include
24 |
25 | namespace playrho::d2 {
26 |
27 | static_assert(detail::IsValidShapeTypeV);
28 |
29 | } // namespace playrho::d2
30 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/part/Compositor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 |
23 | #include
24 |
25 | namespace playrho::d2 {
26 |
27 | static_assert(detail::IsValidShapeTypeV>);
28 |
29 | } // namespace playrho::d2
30 |
--------------------------------------------------------------------------------
/Library/source/playrho/MovementConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 | #include
23 |
24 | namespace playrho {
25 |
26 | MovementConf GetMovementConf(const StepConf& conf) noexcept
27 | {
28 | return MovementConf{conf.maxTranslation, conf.maxRotation};
29 | }
30 |
31 | } // namespace playrho
32 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/UnitVec.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 | #include
23 |
24 | namespace playrho {
25 | namespace d2 {
26 |
27 | UnitVec UnitVec::Get(const Angle angle) noexcept
28 | {
29 | return UnitVec{cos(angle), sin(angle), {}};
30 | }
31 |
32 | } // namespace d2
33 | } // namespace playrho
34 |
35 |
--------------------------------------------------------------------------------
/UnitTests/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | int main(int argc, char** argv)
24 | {
25 | // By default, skip these tests unless overridden on command line.
26 | GTEST_FLAG_SET(filter, "-Shape.TestOverlapFasterThanCollideShapesForPolygons:Math.LengthFasterThanHypot");
27 |
28 | ::testing::InitGoogleTest(&argc, argv);
29 | return RUN_ALL_TESTS();
30 | }
31 |
--------------------------------------------------------------------------------
/UnitTests/WorldFixture.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 |
31 | using namespace playrho;
32 | using namespace playrho::d2;
33 |
--------------------------------------------------------------------------------
/Testbed/Framework/UiState.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef UiState_hpp
22 | #define UiState_hpp
23 |
24 | #include
25 |
26 | struct UiState
27 | {
28 | std::string message;
29 | bool showMenu = true;
30 | bool showAboutTest = true;
31 | bool showStats = false;
32 | bool showContactsHistory = false;
33 | bool showEntities = false;
34 | bool doExit = false;
35 | };
36 |
37 | #endif /* UiState_hpp */
38 |
--------------------------------------------------------------------------------
/Testbed/Framework/Drawer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2011 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include "Drawer.hpp"
23 |
24 | using namespace testbed;
25 |
26 | Drawer::~Drawer() noexcept
27 | {
28 | // Intentionally empty.
29 | }
30 |
31 | Color testbed::Brighten(Color color, float factor)
32 | {
33 | return Color(color.r * factor, color.g * factor, color.b * factor, color.a);
34 | }
35 |
--------------------------------------------------------------------------------
/Library/source/playrho/StepConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | namespace playrho {
27 |
28 | bool IsMaxTranslationWithinTolerance(const StepConf& conf) noexcept
29 | {
30 | const auto delta = Real{1} - nextafter(Real{1}, Real{0});
31 | return (conf.maxTranslation * delta) < Length{conf.tolerance};
32 | }
33 |
34 | } // namespace playrho
35 |
--------------------------------------------------------------------------------
/Library/source/playrho/ToiConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 | #include
23 |
24 | namespace playrho {
25 |
26 | ToiConf GetToiConf(const StepConf& conf) noexcept
27 | {
28 | return ToiConf{}
29 | .UseTimeMax(1.0f)
30 | .UseTargetDepth(conf.targetDepth)
31 | .UseTolerance(conf.tolerance)
32 | .UseMaxRootIters(conf.maxToiRootIters)
33 | .UseMaxToiIters(conf.maxToiIters)
34 | .UseMaxDistIters(conf.maxDistanceIters);
35 | }
36 |
37 | } // namespace playrho
38 |
--------------------------------------------------------------------------------
/Library/include/playrho/WiderType.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_WIDER_TYPE_HPP
22 | #define PLAYRHO_WIDER_TYPE_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c WiderType alias template.
26 |
27 | // IWYU pragma: begin_exports
28 |
29 | #include
30 |
31 | // IWYU pragma: end_exports
32 |
33 | namespace playrho {
34 |
35 | /// @brief The wider type helper.
36 | template
37 | using WiderType = typename detail::Wider::type;
38 |
39 | } // namespace playrho
40 |
41 | #endif // PLAYRHO_WIDER_TYPE_HPP
42 |
--------------------------------------------------------------------------------
/Library/include/playrho/Intervals.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_INTERVALS_HPP
22 | #define PLAYRHO_INTERVALS_HPP
23 |
24 | /// @file
25 | /// @brief Alias for an @c Interval of @c Length .
26 |
27 | // IWYU pragma: begin_exports
28 |
29 | #include
30 | #include
31 |
32 | // IWYU pragma: end_exports
33 |
34 | namespace playrho {
35 |
36 | /// @brief Length Interval alias.
37 | /// @relatedalso Interval
38 | using LengthInterval = Interval;
39 |
40 | } // namespace playrho
41 |
42 | #endif // PLAYRHO_INTERVALS_HPP
43 |
--------------------------------------------------------------------------------
/Library/include/playrho/d2/RayCastInput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_D2_RAYCASTINPUT_HPP
22 | #define PLAYRHO_D2_RAYCASTINPUT_HPP
23 |
24 | /// @file
25 | /// @brief Alias for the 2-D RayCastInput struct.
26 |
27 | // IWYU pragma: begin_exports
28 |
29 | #include
30 |
31 | // IWYU pragma: end_exports
32 |
33 | namespace playrho::d2 {
34 |
35 | /// @brief Ray cast input data for 2-dimensions.
36 | using RayCastInput = playrho::detail::RayCastInput<2>;
37 |
38 | } // namespace playrho::d2
39 |
40 | #endif // PLAYRHO_D2_RAYCASTINPUT_HPP
41 |
--------------------------------------------------------------------------------
/Library/include/playrho/JointFunction.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_JOINTFUNCTION_HPP
22 | #define PLAYRHO_JOINTFUNCTION_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the JointFunction type alias.
26 |
27 | #include // for std::function
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 |
33 | // IWYU pragma: end_exports
34 |
35 | namespace playrho {
36 |
37 | /// @brief Joints function.
38 | using JointFunction = std::function;
39 |
40 | } // namespace playrho
41 |
42 | #endif // PLAYRHO_JOINTFUNCTION_HPP
43 |
--------------------------------------------------------------------------------
/Library/include/playrho/ShapeFunction.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_SHAPEFUNCTION_HPP
22 | #define PLAYRHO_SHAPEFUNCTION_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the ShapeFunction type alias.
26 |
27 | #include // for std::function
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 |
33 | // IWYU pragma: end_exports
34 |
35 | namespace playrho {
36 |
37 | /// @brief Shapes function.
38 | using ShapeFunction = std::function;
39 |
40 | } // namespace playrho
41 |
42 | #endif // PLAYRHO_SHAPEFUNCTION_HPP
43 |
--------------------------------------------------------------------------------
/UnitTests/BodyType.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 |
27 | TEST(BodyType, IsSpeedable)
28 | {
29 | EXPECT_EQ(IsSpeedable(BodyType::Static), false);
30 | EXPECT_EQ(IsSpeedable(BodyType::Kinematic), true);
31 | EXPECT_EQ(IsSpeedable(BodyType::Dynamic), true);
32 | }
33 |
34 | TEST(BodyType, IsAccelerable)
35 | {
36 | EXPECT_EQ(IsAccelerable(BodyType::Static), false);
37 | EXPECT_EQ(IsAccelerable(BodyType::Kinematic), false);
38 | EXPECT_EQ(IsAccelerable(BodyType::Dynamic), true);
39 | }
40 |
--------------------------------------------------------------------------------
/Library/source/playrho/LimitState.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 |
23 | #include
24 |
25 | namespace playrho {
26 |
27 | const char* ToString(LimitState val) noexcept
28 | {
29 | switch (val)
30 | {
31 | case LimitState::e_atLowerLimit: return "at lower";
32 | case LimitState::e_atUpperLimit: return "at upper";
33 | case LimitState::e_equalLimits: return "equal";
34 | case LimitState::e_inactiveLimit: break;
35 | }
36 | assert(val == LimitState::e_inactiveLimit);
37 | return "inactive";
38 | }
39 |
40 | } // namespace playrho
41 |
--------------------------------------------------------------------------------
/Library/include/playrho/ContactFunction.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_CONTACTFUNCTION_HPP
22 | #define PLAYRHO_CONTACTFUNCTION_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the ContactFunction type alias.
26 |
27 | #include // for std::function
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 |
33 | // IWYU pragma: end_exports
34 |
35 | namespace playrho {
36 |
37 | /// @brief Contacts function.
38 | using ContactFunction = std::function;
39 |
40 | } // namespace playrho
41 |
42 | #endif // PLAYRHO_CONTACTFUNCTION_HPP
43 |
--------------------------------------------------------------------------------
/Library/include/playrho/KeyedContactID.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_KEYEDCONTACTID_HPP
22 | #define PLAYRHO_KEYEDCONTACTID_HPP
23 |
24 | /// @file
25 | /// @brief Declaration of the KeyedContactID alias.
26 |
27 | #include
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 | #include
33 |
34 | // IWYU pragma: end_exports
35 |
36 | namespace playrho {
37 |
38 | /// @brief Keyed contact identifier.
39 | using KeyedContactID = std::pair;
40 |
41 | } // namespace playrho
42 |
43 | #endif // PLAYRHO_KEYEDCONTACTID_HPP
44 |
--------------------------------------------------------------------------------
/Documentation/README.md:
--------------------------------------------------------------------------------
1 | # Documentation
2 |
3 | This directory contains documentation, configuration, and other resources for documentation.
4 |
5 | Here's a listing of these documentation and generated documentation resources:
6 |
7 | - [Online copy of the generated API docs](http://louis-langholtz.github.io/PlayRho/API/index.html).
8 | - [The source code style guide for the project](StyleGuide.md).
9 | - [Physical units interface insight](PhysicalUnits.md).
10 | - [Collision handling differences from Box2D 2.3.2](CollisionHandlng.md).
11 |
12 | Application Programming Interface documentation (API docs) can be manually generated from the [library source code](../Library) from some of this configuration using the [Doxygen](https://www.doxygen.nl) tool.
13 | Using CMake, this can be done using steps like these:
14 | ```sh
15 | cmake -S PlayRho -B PlayRhoBuild -DCMAKE_BUILD_TYPE=Release -DPLAYRHO_BUILD_DOC=ON -DPLAYRHO_BUILD_LIBRARY=OFF
16 | cmake --build PlayRhoBuild --config Release
17 | cmake --install PlayRhoBuild --prefix PlayRhoInstall
18 | ```
19 | This assumes you're in the parent directory of the `PlayRho` directory,
20 | that you're specifically interested in a `Release` build,
21 | that you just want to build the API documentation,
22 | that you want to build things in a separate directory called `PlayRhoBuild`,
23 | and that you want to install the documentation under the `PlayRhoInstall` directory.
24 | This is also done automatically as part of GitHub's continuous integration workflow system (see [docs.yml](../.github/workflows/docs.yml) for details).
25 | Alternatively, see the top-level [building & installation](../INSTALL.md) document.
26 |
--------------------------------------------------------------------------------
/Library/include/playrho/WrongState.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_WRONGSTATE_HPP
22 | #define PLAYRHO_WRONGSTATE_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c WrongState class.
26 |
27 | #include
28 |
29 | namespace playrho {
30 |
31 | /// @brief Wrong state logic error.
32 | /// @details Indicates that a function was called with an object in the wrong
33 | /// state for its operation.
34 | /// @ingroup ExceptionsGroup
35 | class WrongState: public std::logic_error
36 | {
37 | public:
38 | using std::logic_error::logic_error;
39 | };
40 |
41 | } // namespace playrho
42 |
43 | #endif // PLAYRHO_WRONGSTATE_HPP
44 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/Sweep.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 | #include
24 |
25 | #include // for GetPosition
26 | #include
27 |
28 | namespace playrho::d2 {
29 |
30 | Sweep Advance0(const Sweep& sweep, const ZeroToUnderOneFF alpha) noexcept
31 | {
32 | const auto beta = (alpha - sweep.alpha0) / (Real(1) - sweep.alpha0);
33 | return {GetPosition(sweep.pos0, sweep.pos1, beta), sweep.pos1, sweep.localCenter, alpha};
34 | }
35 |
36 | } // namespace playrho::d2
37 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/DistanceConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 |
23 | #include
24 |
25 | #include
26 |
27 | namespace playrho::d2 {
28 |
29 | DistanceConf GetDistanceConf(const ToiConf& conf) noexcept
30 | {
31 | auto distanceConf = DistanceConf{};
32 | distanceConf.maxIterations = conf.maxDistIters;
33 | return distanceConf;
34 | }
35 |
36 | DistanceConf GetDistanceConf(const StepConf& conf) noexcept
37 | {
38 | DistanceConf distanceConf;
39 | distanceConf.maxIterations = conf.maxDistanceIters;
40 | return distanceConf;
41 | }
42 |
43 | } // namespace playrho::d2
44 |
--------------------------------------------------------------------------------
/Library/include/playrho/LengthError.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_LENGTHERROR_HPP
22 | #define PLAYRHO_LENGTHERROR_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c LengthError class.
26 |
27 | #include
28 |
29 | namespace playrho {
30 |
31 | /// @brief Length based logic error.
32 | /// @details The exception used to indicate that an operation would produce a
33 | /// result that exceeded an object's maximum size.
34 | /// @ingroup ExceptionsGroup
35 | class LengthError: public std::length_error
36 | {
37 | public:
38 | using std::length_error::length_error;
39 | };
40 |
41 | } // namespace playrho
42 |
43 |
44 | #endif // PLAYRHO_LENGTHERROR_HPP
45 |
--------------------------------------------------------------------------------
/UnitTests/functional.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 | #include
23 |
24 | TEST(functional, FunctionSize)
25 | {
26 | #ifdef __APPLE__
27 | #if defined(__arm64__)
28 | EXPECT_EQ(sizeof(std::function), std::size_t(32));
29 | #else
30 | EXPECT_EQ(sizeof(std::function), std::size_t(48));
31 | #endif
32 | #endif
33 | #ifdef __linux__
34 | EXPECT_EQ(sizeof(std::function), std::size_t(32));
35 | #endif
36 | }
37 |
38 | TEST(functional, FunctionSizeGreaterThanFunctionPtr)
39 | {
40 | using FunctionPtr = int (*)(int);
41 | using StdFunction = std::function;
42 | EXPECT_GT(sizeof(StdFunction), sizeof(FunctionPtr));
43 | }
44 |
--------------------------------------------------------------------------------
/Library/source/playrho/StepStats.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 |
23 | #include
24 |
25 | #include // for std::min, std::max
26 |
27 | namespace playrho {
28 |
29 | RegStepStats& Update(RegStepStats& lhs, const IslandStats& rhs) noexcept
30 | {
31 | lhs.maxIncImpulse = std::max(lhs.maxIncImpulse, rhs.maxIncImpulse);
32 | lhs.minSeparation = std::min(lhs.minSeparation, rhs.minSeparation);
33 | lhs.islandsSolved += rhs.solved;
34 | lhs.sumPosIters += rhs.positionIters;
35 | lhs.sumVelIters += rhs.velocityIters;
36 | lhs.bodiesSlept += rhs.bodiesSlept;
37 | return lhs;
38 | }
39 |
40 | } // namespace playrho
41 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/ContactImpulsesList.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 | #include
23 |
24 | namespace playrho {
25 | namespace d2 {
26 |
27 | /// @brief Gets the contact impulses for the given velocity constraint.
28 | ContactImpulsesList GetContactImpulses(const VelocityConstraint& vc)
29 | {
30 | ContactImpulsesList impulse;
31 | const auto count = vc.GetPointCount();
32 | for (auto j = decltype(count){0}; j < count; ++j)
33 | {
34 | impulse.AddEntry(GetNormalImpulseAtPoint(vc, j), GetTangentImpulseAtPoint(vc, j));
35 | }
36 | return impulse;
37 | }
38 |
39 | } // namespace d2
40 | } // namespace playrho
41 |
--------------------------------------------------------------------------------
/Library/include/playrho/BodyShapeFunction.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_BODYSHAPEFUNCTION_HPP
22 | #define PLAYRHO_BODYSHAPEFUNCTION_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the BodyShapeFunction type alias.
26 |
27 | #include // for std::function
28 | #include // for std::pair
29 |
30 | // IWYU pragma: begin_exports
31 |
32 | #include
33 | #include
34 |
35 | // IWYU pragma: end_exports
36 |
37 | namespace playrho {
38 |
39 | /// @brief Body-shapes function.
40 | using BodyShapeFunction = std::function)>;
41 |
42 | } // namespace playrho
43 |
44 | #endif // PLAYRHO_BODYSHAPEFUNCTION_HPP
45 |
--------------------------------------------------------------------------------
/cmake/FindGLFW3.cmake:
--------------------------------------------------------------------------------
1 | # Locate the glfw3 library
2 | #
3 | # This module defines the following variables:
4 | #
5 | # GLFW3_LIBRARY the name of the library;
6 | # GLFW3_INCLUDE_DIR where to find glfw include files.
7 | # GLFW3_FOUND true if both the GLFW3_LIBRARY and GLFW3_INCLUDE_DIR have been found.
8 | #
9 | # To help locate the library and include file, you can define a
10 | # variable called GLFW3_ROOT which points to the root of the glfw library
11 | # installation.
12 | #
13 | # default search dirs
14 | #
15 | # Cmake file from: https://github.com/daw42/glslcookbook
16 |
17 | message(STATUS "Running custom FindGLFW3.cmake")
18 | set( _glfw3_HEADER_SEARCH_DIRS
19 | "/usr/include"
20 | "/usr/local/include"
21 | "${CMAKE_SOURCE_DIR}/includes"
22 | "C:/Program Files (x86)/glfw/include" )
23 | set( _glfw3_LIB_SEARCH_DIRS
24 | "/usr/lib"
25 | "/usr/local/lib"
26 | "${CMAKE_SOURCE_DIR}/lib"
27 | "C:/Program Files (x86)/glfw/lib-msvc110" )
28 |
29 | # Check environment for root search directory
30 | set( _glfw3_ENV_ROOT $ENV{GLFW3_ROOT} )
31 | if( NOT GLFW3_ROOT AND _glfw3_ENV_ROOT )
32 | set(GLFW3_ROOT ${_glfw3_ENV_ROOT} )
33 | endif()
34 |
35 | # Put user specified location at beginning of search
36 | if( GLFW3_ROOT )
37 | list( INSERT _glfw3_HEADER_SEARCH_DIRS 0 "${GLFW3_ROOT}/include" )
38 | list( INSERT _glfw3_LIB_SEARCH_DIRS 0 "${GLFW3_ROOT}/lib" )
39 | endif()
40 |
41 | # Search for the header
42 | FIND_PATH(GLFW3_INCLUDE_DIR "GLFW/glfw3.h"
43 | PATHS ${_glfw3_HEADER_SEARCH_DIRS} )
44 |
45 | # Search for the library
46 | FIND_LIBRARY(GLFW3_LIBRARY NAMES glfw3 glfw PATHS ${_glfw3_LIB_SEARCH_DIRS} )
47 | INCLUDE(FindPackageHandleStandardArgs)
48 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 DEFAULT_MSG GLFW3_LIBRARY GLFW3_INCLUDE_DIR)
49 |
--------------------------------------------------------------------------------
/Documentation/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(Doxygen REQUIRED dot)
2 |
3 | set(DOXYGEN_OUTPUT_DIRECTORY "API")
4 | set(DOXYGEN_EXTRACT_PRIVATE NO)
5 | set(DOXYGEN_EXTRACT_STATIC YES)
6 | set(DOXYGEN_EXAMPLE_PATH "${CMAKE_SOURCE_DIR}/HelloWorld;${CMAKE_SOURCE_DIR}/UnitTests")
7 | set(DOXYGEN_IMAGE_PATH "${CMAKE_SOURCE_DIR}/Documentation/images")
8 | set(DOXYGEN_REFERENCED_BY_RELATION YES)
9 | set(DOXYGEN_VERBATIM_HEADERS NO)
10 | set(DOXYGEN_FULL_PATH_NAMES YES)
11 | set(DOXYGEN_STRIP_FROM_PATH "${CMAKE_SOURCE_DIR}/")
12 | set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_SOURCE_DIR}/Library/include")
13 | set(DOXYGEN_SHOW_FILES YES)
14 | set(DOXYGEN_HTML_TIMESTAMP YES)
15 | set(DOXYGEN_GENERATE_TAGFILE "API/html/PlayRho.tag")
16 | set(DOXYGEN_CLASS_DIAGRAMS YES)
17 | set(DOXYGEN_TEMPLATE_RELATIONS YES)
18 | set(DOXYGEN_DISABLE_INDEX YES)
19 | set(DOXYGEN_GENERATE_TREEVIEW YES)
20 | set(DOXYGEN_DOT_IMAGE_FORMAT svg)
21 | set(DOXYGEN_INTERACTIVE_SVG YES)
22 | set(DOXYGEN_CASE_SENSE_NAMES YES)
23 | set(DOXYGEN_QUIET YES)
24 | set(DOXYGEN_SORT_BRIEF_DOCS YES)
25 | set(DOXYGEN_SORT_MEMBERS_CTORS_1ST YES)
26 | set(DOXYGEN_FILE_PATTERNS "*.cpp;*.hpp")
27 | set(DOXYGEN_ENABLE_PREPROCESSING YES)
28 |
29 | if(PLAYRHO_ENABLE_BOOST_UNITS)
30 | set(DOXYGEN_PREDEFINED "PLAYRHO_USE_BOOST_UNITS")
31 | endif()
32 |
33 | doxygen_add_docs(Documentation
34 | "${CMAKE_SOURCE_DIR}/Library"
35 | ALL
36 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Documentation"
37 | COMMENT "Generating API documentation with Doxygen"
38 | )
39 |
40 | if(PLAYRHO_INSTALL)
41 | include(GNUInstallDirs)
42 | install(DIRECTORY "${CMAKE_BINARY_DIR}/Documentation/API/html/"
43 | DESTINATION "${CMAKE_INSTALL_DOCDIR}/API"
44 | COMPONENT Documentation)
45 | endif()
46 |
--------------------------------------------------------------------------------
/Library/include/playrho/PointState.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef PLAYRHO_POINTSTATE_HPP
23 | #define PLAYRHO_POINTSTATE_HPP
24 |
25 | /// @file
26 | /// @brief Definition of the @c PointState enumeration.
27 |
28 | namespace playrho {
29 |
30 | /// @brief Point state enumeration.
31 | /// @note This is used for determining the state of contact points.
32 | enum class PointState
33 | {
34 | Null, ///< Point does not exist.
35 | Add, ///< Point was added in the update.
36 | Persist, ///< Point persisted across the update.
37 | Remove ///< Point was removed in the update.
38 | };
39 |
40 | } // namespace playrho
41 |
42 | #endif // PLAYRHO_POINTSTATE_HPP
43 |
--------------------------------------------------------------------------------
/Library/include/playrho/d2/ContactManifoldFunction.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_D2_CONTACTMANIFOLDFUNCTION_HPP
22 | #define PLAYRHO_D2_CONTACTMANIFOLDFUNCTION_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the ContactManifoldFunction type alias.
26 |
27 | #include // for std::function
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 |
33 | #include
34 |
35 | // IWYU pragma: end_exports
36 |
37 | namespace playrho::d2 {
38 |
39 | /// @brief Contact-manifolds function.
40 | using ContactManifoldFunction = std::function;
41 |
42 | } // namespace playrho::d2
43 |
44 | #endif // PLAYRHO_D2_CONTACTMANIFOLDFUNCTION_HPP
45 |
--------------------------------------------------------------------------------
/UnitTests/BodyConstraint.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 | using namespace playrho::d2;
27 |
28 | TEST(BodyConstraint, ByteSize)
29 | {
30 | // Check size at test runtime instead of compile-time via static_assert to avoid stopping
31 | // builds and to report actual size rather than just reporting that expected size is wrong.
32 | switch (sizeof(Real))
33 | {
34 | case 4: EXPECT_EQ(sizeof(BodyConstraint), std::size_t(40)); break;
35 | case 8: EXPECT_EQ(sizeof(BodyConstraint), std::size_t(80)); break;
36 | case 16: EXPECT_EQ(sizeof(BodyConstraint), std::size_t(160)); break;
37 | default: FAIL(); break;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Library/include/playrho/d2/ContactImpulsesFunction.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_D2_CONTACTIMPULSESFUNCTION_HPP
22 | #define PLAYRHO_D2_CONTACTIMPULSESFUNCTION_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the ContactImpulsesFunction type alias.
26 |
27 | #include // for std::function
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 |
33 | #include
34 |
35 | // IWYU pragma: end_exports
36 |
37 | namespace playrho::d2 {
38 |
39 | /// @brief Contact-impulses function.
40 | using ContactImpulsesFunction =
41 | std::function;
42 |
43 | } // namespace playrho::d2
44 |
45 | #endif // PLAYRHO_D2_CONTACTIMPULSESFUNCTION_HPP
46 |
--------------------------------------------------------------------------------
/UnitTests/PositionConstraint.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 | using namespace playrho::d2;
27 |
28 | TEST(PositionConstraint, ByteSize)
29 | {
30 | // Check size at test runtime instead of compile-time via static_assert to avoid stopping
31 | // builds and to report actual size rather than just reporting that expected size is wrong.
32 | switch (sizeof(Real))
33 | {
34 | case 4: EXPECT_EQ(sizeof(PositionConstraint), std::size_t(64)); break;
35 | case 8: EXPECT_EQ(sizeof(PositionConstraint), std::size_t(128)); break;
36 | case 16: EXPECT_EQ(sizeof(PositionConstraint), std::size_t(272)); break;
37 | default: FAIL(); break;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/cmake/GetGitVersion.cmake:
--------------------------------------------------------------------------------
1 | # - Returns a version string from Git tags
2 | #
3 | # This function inspects the annotated git tags for the project and returns a string
4 | # into a CMake variable
5 | #
6 | # get_git_version()
7 | #
8 | # - Example
9 | #
10 | # include(GetGitVersion)
11 | # get_git_version(GIT_VERSION)
12 | #
13 | # Requires CMake 2.8.11+
14 | find_package(Git)
15 |
16 | if(__get_git_version)
17 | return()
18 | endif()
19 | set(__get_git_version INCLUDED)
20 |
21 | function(get_git_version var)
22 | if(GIT_EXECUTABLE)
23 | execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
24 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
25 | RESULT_VARIABLE status
26 | OUTPUT_VARIABLE GIT_VERSION
27 | ERROR_QUIET)
28 | if(${status})
29 | set(GIT_VERSION "v0.0.0")
30 | else()
31 | string(STRIP ${GIT_VERSION} GIT_VERSION)
32 | string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
33 | endif()
34 |
35 | # Work out if the repository is dirty
36 | execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
37 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
38 | OUTPUT_QUIET
39 | ERROR_QUIET)
40 | execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
41 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
42 | OUTPUT_VARIABLE GIT_DIFF_INDEX
43 | ERROR_QUIET)
44 | string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
45 | if (${GIT_DIRTY})
46 | set(GIT_VERSION "${GIT_VERSION}-dirty")
47 | endif()
48 | else()
49 | set(GIT_VERSION "v0.0.0")
50 | endif()
51 |
52 | message(STATUS "git Version: ${GIT_VERSION}")
53 | set(${var} ${GIT_VERSION} PARENT_SCOPE)
54 | endfunction()
55 |
--------------------------------------------------------------------------------
/Documentation/PhysicalUnits.md:
--------------------------------------------------------------------------------
1 | # The Physical Units Interface
2 |
3 | The *Physical Units Interface* for
4 | [PlayRho](https://github.com/louis-langholtz/PlayRho), is an interface
5 | that ties physical values to their required types.
6 |
7 | The base implementation for the *physical units interface* simply uses
8 | the `Real` type. To get the interface to enforce strong typing, a `constexpr`
9 | enhanced implementation like the Boost 1.75.0 Units library has to be used.
10 | Source code for that can be downloaded from the boost website at
11 | https://www.boost.org.
12 |
13 | To build with Boost units support:
14 | 1. Download the latest Boost sources from boost.org. At the time this
15 | document was last updated, the latest was version 1.75.0. This can be
16 | downloaded from: https://www.boost.org/users/history/version\_1\_75\_0.html.
17 | 2. Extract these sources into a directory/folder of your choice.
18 | For the sake of example, let's say you chose `/usr/local`. So that after the extraction,
19 | there's now a sub-directory named `boost_1_75_0` in there.
20 | 3. Add the path to that directory to your build system's list of include paths.
21 | If using the example directory, then you'd add `/usr/local/boost_1_75_0` to your
22 | build system's include paths.
23 | 4. Go into your PlayRho project setup and add "PLAYRHO\_USE\_BOOST\_UNITS" as a
24 | C pre-processor define so that the file
25 | [`PlayRho/Common/Units.hpp`](../Library/include/PlayRho/Common/Units.hpp) can see that it's defined.
26 | This could be achieved just by uncommenting the line that appears like:
27 | `// #define PLAYRHO_USE_BOOST_UNITS`.
28 | 5. Rebuild the PlayRho library and any applications. If you've used the
29 | physical units interface correctly everywhere, you should get no units
30 | related warnings or errors.
31 |
--------------------------------------------------------------------------------
/UnitTests/double.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include // for IsValid
24 | #include // for GetTypeName
25 |
26 | using namespace playrho;
27 |
28 | TEST(double, IsValid)
29 | {
30 | EXPECT_FALSE(IsValid(std::numeric_limits::signaling_NaN()));
31 | EXPECT_FALSE(IsValid(std::numeric_limits::quiet_NaN()));
32 | EXPECT_TRUE(IsValid(0.0));
33 | }
34 |
35 | TEST(double, GetTypeName)
36 | {
37 | const auto name = playrho::GetTypeName();
38 | EXPECT_STREQ(name, "double");
39 | }
40 |
41 | TEST(double, traits)
42 | {
43 | EXPECT_TRUE((playrho::IsAddableV));
44 | EXPECT_TRUE((playrho::IsAddableV));
45 | EXPECT_TRUE((playrho::IsAddableV));
46 | EXPECT_TRUE((playrho::IsAddableV));
47 | }
48 |
--------------------------------------------------------------------------------
/Library/source/playrho/Version.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include // for std::stringstream
23 | #include
24 |
25 | #include
26 | #include // for GetTypeName
27 | #include
28 | #include // for PLAYRHO_VERSION_*
29 |
30 | namespace playrho {
31 |
32 | Version GetVersion() noexcept
33 | {
34 | return Version{PLAYRHO_VERSION_MAJOR, PLAYRHO_VERSION_MINOR, PLAYRHO_VERSION_PATCH};
35 | }
36 |
37 | std::string GetBuildDetails()
38 | {
39 | std::stringstream stream;
40 | stream << "asserts=";
41 | #ifdef NDEBUG
42 | stream << "off";
43 | #else
44 | stream << "on";
45 | #endif
46 | stream << ", Real='" << GetTypeName() << "'";
47 | return stream.str();
48 | }
49 |
50 | } // namespace playrho
51 |
--------------------------------------------------------------------------------
/Library/include/playrho/to_underlying.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_TOUNDERLYING_HPP
22 | #define PLAYRHO_TOUNDERLYING_HPP
23 |
24 | /// @file
25 | /// @brief Definition of @c to_underlying function template.
26 |
27 | // IWYU pragma: begin_exports
28 |
29 | #include
30 |
31 | // IWYU pragma: end_exports
32 |
33 | namespace playrho {
34 |
35 | /// Underlying-type convenience alias.
36 | template
37 | using underlying_type_t = typename detail::underlying_type::type;
38 |
39 | /// Converts the given value to the value as the underlying type.
40 | /// @note This is like std::to_underlying slated for C++23.
41 | template
42 | constexpr auto to_underlying(T value) noexcept -> underlying_type_t
43 | {
44 | return static_cast>(value);
45 | }
46 |
47 | } // namespace playrho
48 |
49 | #endif // PLAYRHO_TOUNDERLYING_HPP
50 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/Shape.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 |
24 | namespace playrho {
25 | namespace d2 {
26 |
27 | // Confirm that a Shape itself isn't a valid shape type in the sense of preventing what could
28 | // otherwise be an infinitely recursive configuration. Note that this doesn't prevent copy/move
29 | // construction nor copy/move assignment.
30 | static_assert(!detail::IsValidShapeTypeV);
31 |
32 | bool TestPoint(const Shape& shape, const Length2& point) noexcept
33 | {
34 | const auto childCount = GetChildCount(shape);
35 | for (auto i = decltype(childCount){0}; i < childCount; ++i) {
36 | if (playrho::d2::TestPoint(GetChild(shape, i), point)) {
37 | return true;
38 | }
39 | }
40 | return false;
41 | }
42 |
43 | } // namespace d2
44 | } // namespace playrho
45 |
--------------------------------------------------------------------------------
/UnitTests/IndexPair.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 |
27 | TEST(IndexPair, Init)
28 | {
29 | IndexPair ip{1, 2};
30 | EXPECT_EQ(std::get<0>(ip), 1);
31 | EXPECT_EQ(std::get<1>(ip), 2);
32 | }
33 |
34 | TEST(IndexPair, Equality)
35 | {
36 | IndexPair ip1{2, 3};
37 | IndexPair ip2{2, 3};
38 | EXPECT_EQ(ip1, ip1);
39 | EXPECT_EQ(ip1, ip2);
40 | EXPECT_EQ(ip2, ip1);
41 | EXPECT_EQ(ip2, ip2);
42 | }
43 |
44 | TEST(IndexPair, Inequality)
45 | {
46 | IndexPair ip1{2, 3};
47 | IndexPair ip2{1, 0};
48 | EXPECT_NE(ip1, ip2);
49 | EXPECT_NE(ip2, ip1);
50 | }
51 |
52 | TEST(IndexPair, InvalidIndex)
53 | {
54 | const auto invalid_index = InvalidVertex;
55 | IndexPair ip{invalid_index, 2};
56 | EXPECT_EQ(invalid_index, std::get<0>(ip));
57 | EXPECT_NE(invalid_index, std::get<1>(ip));
58 | }
59 |
--------------------------------------------------------------------------------
/Library/source/playrho/Contact.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 |
24 | #include // for std::is_default_constructible_v etc.
25 |
26 | namespace playrho {
27 |
28 | static_assert(std::is_default_constructible_v,
29 | "Contact must be default constructible!");
30 | static_assert(std::is_copy_constructible_v, "Contact must be copy constructible!");
31 | static_assert(std::is_move_constructible_v, "Contact must be move constructible!");
32 | static_assert(std::is_copy_assignable_v, "Contact must be copy assignable!");
33 | static_assert(std::is_move_assignable_v, "Contact must be move assignable!");
34 | static_assert(std::is_nothrow_destructible_v,
35 | "Contact must be nothrow destructible!");
36 |
37 | // Free functions...
38 |
39 | } // namespace playrho
40 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/WorldMisc.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 | #include
28 |
29 | namespace playrho::d2 {
30 |
31 | StepStats Step(World &world, Time delta, TimestepIters velocityIterations,
32 | TimestepIters positionIterations)
33 | {
34 | StepConf conf;
35 | conf.deltaTime = delta;
36 | conf.regVelocityIters = velocityIterations;
37 | conf.regPositionIters = positionIterations;
38 | conf.toiVelocityIters = velocityIterations;
39 | if (positionIterations == 0)
40 | {
41 | conf.toiPositionIters = 0;
42 | }
43 | conf.dtRatio = delta * GetInvDeltaTime(world);
44 | return Step(world, conf);
45 | }
46 |
47 | } // namespace playrho::d2
48 |
--------------------------------------------------------------------------------
/Library/include/playrho/Finite.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_FINITE_HPP
22 | #define PLAYRHO_FINITE_HPP
23 |
24 | /// @file
25 | /// @brief Aliases for checked finite types.
26 |
27 | #include // for std::is_default_constructible_v
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 | #include
33 |
34 | // IWYU pragma: end_exports
35 |
36 | namespace playrho {
37 |
38 | /// @ingroup CheckedTypes
39 | /// @brief Finite constrained value type.
40 | template
41 | using Finite = detail::Checked>;
42 |
43 | /// @ingroup CheckedTypes
44 | /// @brief Fast failing finite constrained value type.
45 | template
46 | using FiniteFF = detail::Checked, true>;
47 |
48 | static_assert(std::is_default_constructible_v>);
49 |
50 | } // namespace playrho
51 |
52 | #endif // PLAYRHO_FINITE_HPP
53 |
--------------------------------------------------------------------------------
/Library/include/playrho/OutOfRange.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_OUTOFRANGE_HPP
22 | #define PLAYRHO_OUTOFRANGE_HPP
23 |
24 | #include // for std::out_of_range
25 | #include
26 |
27 | namespace playrho {
28 |
29 | /// @brief Out-of-range exception with a range type & value.
30 | /// @see std::out_of_range.
31 | template
32 | class OutOfRange: public std::out_of_range {
33 | public:
34 | using type = T; ///< Type of the index whose value was out-of-range.
35 |
36 | using std::out_of_range::out_of_range;
37 |
38 | /// @brief Initializing constructor.
39 | OutOfRange(type v, const std::string& msg): out_of_range{msg}, value{v} {}
40 |
41 | /// @brief Initializing constructor.
42 | OutOfRange(type v, const char* msg): out_of_range{msg}, value{v} {}
43 |
44 | type value{}; ///< Value of the index that was out-of-range.
45 | };
46 |
47 | } // namespace playrho
48 |
49 | #endif // PLAYRHO_OUTOFRANGE_HPP
50 |
--------------------------------------------------------------------------------
/Library/include/playrho/MovementConf.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_MOVEMENTCONF_HPP
22 | #define PLAYRHO_MOVEMENTCONF_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c MovementConf class and closely related code.
26 |
27 | // IWYU pragma: begin_exports
28 |
29 | #include
30 |
31 | // IWYU pragma: end_exports
32 |
33 | namespace playrho {
34 |
35 | struct StepConf;
36 |
37 | /// @brief Movement configuration.
38 | struct MovementConf
39 | {
40 | Length maxTranslation; ///< Maximum translation.
41 | Angle maxRotation; ///< Maximum rotation.
42 | };
43 |
44 | /// @brief Gets the movement configuration from the given value.
45 | /// @return The maxTranslation and maxRotation fields
46 | /// of the given value respectively are returned.
47 | /// @relatedalso StepConf
48 | MovementConf GetMovementConf(const StepConf& conf) noexcept;
49 |
50 | } // namespace playrho
51 |
52 | #endif // PLAYRHO_MOVEMENTCONF_HPP
53 |
--------------------------------------------------------------------------------
/Testbed/Framework/TestEntry.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef PLAYRHO_TEST_ENTRY_HPP
23 | #define PLAYRHO_TEST_ENTRY_HPP
24 |
25 | #include
26 |
27 | #include // for std::unique_ptr
28 | #include
29 |
30 | namespace testbed {
31 |
32 | class Test;
33 |
34 | /// @brief A name and function pointer dataset for a test entry.
35 | ///
36 | struct TestEntry
37 | {
38 | typedef std::unique_ptr CreateFcn();
39 |
40 | const char *name;
41 | CreateFcn *createFcn;
42 | };
43 |
44 | /// @brief Gets the test entries array.
45 | ///
46 | /// @note This serves as a wrapper to avoid any possible startup-time dependencies issues that
47 | /// might be caused by having global data defined in a different file than it's used in.
48 | ///
49 | std::vector GetTestEntries();
50 |
51 | } // namespace testbed
52 |
53 | #endif /* PLAYRHO_TEST_ENTRY_HPP */
54 |
--------------------------------------------------------------------------------
/Library/include/playrho/Defines.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | /**
22 | * @file
23 | * @brief Miscellaneous C-preprocessor definitions.
24 | */
25 |
26 | #ifndef PLAYRHO_DEFINES_HPP
27 | #define PLAYRHO_DEFINES_HPP
28 |
29 | // Checks if platform supports 128-bit integer types and defines macros for them if so.
30 | // Note that these could use any LiteralType type that has full operator and
31 | // common mathematical function support.
32 | #ifdef __SIZEOF_INT128__
33 | #define PLAYRHO_INT128 __int128_t
34 | #define PLAYRHO_UINT128 __uint128_t
35 | #endif
36 |
37 | #ifndef PLAYRHO_VERSION_MAJOR
38 | /// @brief PlayRho major version number.
39 | #define PLAYRHO_VERSION_MAJOR 2
40 | #endif
41 |
42 | #ifndef PLAYRHO_VERSION_MINOR
43 | /// @brief PlayRho minor version number.
44 | #define PLAYRHO_VERSION_MINOR 0
45 | #endif
46 |
47 | #ifndef PLAYRHO_VERSION_PATCH
48 | /// @brief PlayRho patch version number.
49 | #define PLAYRHO_VERSION_PATCH 0
50 | #endif
51 |
52 | #endif /* PLAYRHO_DEFINES_HPP */
53 |
--------------------------------------------------------------------------------
/Library/include/playrho/Negative.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_NEGATIVE_HPP
22 | #define PLAYRHO_NEGATIVE_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c Negative value checked types.
26 |
27 | #include // for std::is_default_constructible_v
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 | #include
33 |
34 | // IWYU pragma: end_exports
35 |
36 | namespace playrho {
37 |
38 | /// @ingroup CheckedTypes
39 | /// @brief Negative constrained value type.
40 | template
41 | using Negative = detail::Checked>;
42 |
43 | /// @ingroup CheckedTypes
44 | /// @brief Fast failing negative constrained value type.
45 | template
46 | using NegativeFF = detail::Checked, true>;
47 |
48 | static_assert(!std::is_default_constructible_v>);
49 |
50 | } // namespace playrho
51 |
52 | #endif // PLAYRHO_NEGATIVE_HPP
53 |
--------------------------------------------------------------------------------
/Library/README.md:
--------------------------------------------------------------------------------
1 | # PlayRho Library
2 |
3 | This component is the base required component for the project.
4 | None of the other components are necessary if you only want to build and install the library.
5 |
6 | If you want to build any other components, see the other component folders' README.md files.
7 |
8 | ## Prerequisites
9 |
10 | This component does not have any prerequisites other than the minimum project prerequisites.
11 |
12 | ## Configuration
13 |
14 | This component doesn't need any configuration options to be specified.
15 |
16 | ## Building & Installation
17 |
18 | See the project's [documented build and installation steps](../INSTALL.md).
19 |
20 | ## Layout
21 |
22 | - [`include/playrho`](include/playrho): Files and subdirectories for the library's header files.
23 | - [`source/playrho`](source/playrho): Files and subdirectories for the library's source files.
24 |
25 | Contents under these directories are otherwise named and structured by functionality and C++ namespaces.
26 | For example, code primarily for 2-dimensional use is under a `d2` subdirectory and within the `playrho::d2` namespace.
27 |
28 | ## History
29 |
30 | This directory/folder used to be called `PlayRho`,
31 | as a subdirectory of the project directory also of the same name,
32 | i.e. `PlayRho/PlayRho`.
33 | It's always been for the library component however.
34 | Changing its name to `Library` avoids this repetition of the name,
35 | and hopefully clarifies what it's for.
36 |
37 | This component's files used to be split up into subdirectories by functionality - dynamics, collision, etc..
38 | The files have since been rearranged to more closely match their primarily associated namespaces,
39 | and header files have been separated from source files into the sub-directories of `include/playrho` and `source/playrho`.
40 | Besides hopefully making it easier for users to understand the API,
41 | this is also a more conventional layout for C++ libraries and more closely matches what the installed project's include directory looks like.
42 |
--------------------------------------------------------------------------------
/Library/source/playrho/ConstraintSolverConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 |
23 | #include
24 |
25 | namespace playrho {
26 |
27 | ConstraintSolverConf GetRegConstraintSolverConf(const StepConf& conf) noexcept
28 | {
29 | return ConstraintSolverConf{}
30 | .UseResolutionRate(conf.regResolutionRate)
31 | .UseLinearSlop(conf.linearSlop)
32 | .UseAngularSlop(conf.angularSlop)
33 | .UseMaxLinearCorrection(conf.maxLinearCorrection)
34 | .UseMaxAngularCorrection(conf.maxAngularCorrection);
35 | }
36 |
37 | ConstraintSolverConf GetToiConstraintSolverConf(const StepConf& conf) noexcept
38 | {
39 | return ConstraintSolverConf{}
40 | .UseResolutionRate(conf.toiResolutionRate)
41 | .UseLinearSlop(conf.linearSlop)
42 | .UseAngularSlop(conf.angularSlop)
43 | .UseMaxLinearCorrection(conf.maxLinearCorrection)
44 | .UseMaxAngularCorrection(conf.maxAngularCorrection);
45 | }
46 |
47 | } // namespace playrho
48 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/Velocity.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | namespace playrho::d2 {
26 |
27 | Velocity Cap(Velocity velocity, Time h, const MovementConf& conf) noexcept
28 | {
29 | const auto translation = h * velocity.linear;
30 | const auto lsquared = GetMagnitudeSquared(translation);
31 | if (lsquared > Square(conf.maxTranslation)) {
32 | // Scale back linear velocity so max translation not exceeded.
33 | const auto ratio = conf.maxTranslation / sqrt(lsquared);
34 | velocity.linear *= ratio;
35 | }
36 |
37 | const auto absRotation = abs(h * velocity.angular);
38 | if (absRotation > conf.maxRotation) {
39 | // Scale back angular velocity so max rotation not exceeded.
40 | const auto ratio = conf.maxRotation / absRotation;
41 | velocity.angular *= ratio;
42 | }
43 |
44 | return velocity;
45 | }
46 |
47 | } // namespace playrho::d2
48 |
--------------------------------------------------------------------------------
/Library/include/playrho/NonPositive.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_NONPOSITIVE_HPP
22 | #define PLAYRHO_NONPOSITIVE_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c NonPositive value checked types.
26 |
27 | #include // for std::is_default_constructible_v
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 | #include
33 |
34 | // IWYU pragma: end_exports
35 |
36 | namespace playrho {
37 |
38 | /// @ingroup CheckedTypes
39 | /// @brief Non-positive constrained value type.
40 | template
41 | using NonPositive = detail::Checked>;
42 |
43 | /// @ingroup CheckedTypes
44 | /// @brief Fast failing non-positive constrained value type.
45 | template
46 | using NonPositiveFF = detail::Checked, true>;
47 |
48 | static_assert(std::is_default_constructible_v>);
49 |
50 | } // namespace playrho
51 |
52 | #endif // PLAYRHO_NONPOSITIVE_HPP
53 |
--------------------------------------------------------------------------------
/UnitTests/BaseShapeConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | #include
26 |
27 | using namespace playrho;
28 | using namespace playrho::d2;
29 |
30 | TEST(BaseShapeConf, Traits)
31 | {
32 | EXPECT_TRUE(std::is_default_constructible_v);
33 | EXPECT_TRUE(std::is_copy_constructible_v);
34 | #ifndef PLAYRHO_USE_BOOST_UNITS
35 | EXPECT_TRUE(std::is_nothrow_default_constructible_v);
36 | EXPECT_TRUE(std::is_nothrow_copy_constructible_v);
37 | #endif
38 | }
39 |
40 | TEST(BaseShapeConf, DefaultConstruction)
41 | {
42 | EXPECT_EQ(BaseShapeConf().friction, BaseShapeConf::DefaultFriction);
43 | EXPECT_EQ(BaseShapeConf().restitution, BaseShapeConf::DefaultRestitution);
44 | EXPECT_EQ(BaseShapeConf().density, BaseShapeConf::DefaultDensity);
45 | EXPECT_EQ(BaseShapeConf().filter, BaseShapeConf::DefaultFilter);
46 | EXPECT_EQ(BaseShapeConf().isSensor, BaseShapeConf::DefaultIsSensor);
47 | }
48 |
--------------------------------------------------------------------------------
/UnitTests/IslandStats.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 |
27 | TEST(IslandStats, DefaultConstructor)
28 | {
29 | IslandStats object{};
30 | EXPECT_EQ(object.minSeparation, std::numeric_limits::infinity());
31 | EXPECT_EQ(object.maxIncImpulse, 0_Ns);
32 | EXPECT_EQ(object.bodiesSlept, 0u);
33 | EXPECT_EQ(object.contactsUpdated, 0u);
34 | EXPECT_EQ(object.contactsSkipped, 0u);
35 | EXPECT_EQ(object.solved, false);
36 | EXPECT_EQ(object.positionIters, 0u);
37 | EXPECT_EQ(object.velocityIters, 0u);
38 | }
39 |
40 | TEST(IslandStats, IncContactsUpdated)
41 | {
42 | constexpr auto expected = 42u;
43 | EXPECT_EQ(IslandStats{}.IncContactsUpdated(40u).IncContactsUpdated(2u).contactsUpdated, expected);
44 | }
45 |
46 | TEST(IslandStats, IncContactsSkipped)
47 | {
48 | constexpr auto expected = 42u;
49 | EXPECT_EQ(IslandStats{}.IncContactsSkipped(40u).IncContactsSkipped(2u).contactsSkipped, expected);
50 | }
51 |
--------------------------------------------------------------------------------
/UnitTests/BodyID.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 |
27 | TEST(BodyID, ByteSize)
28 | {
29 | EXPECT_EQ(sizeof(BodyID), 2u);
30 | }
31 |
32 | TEST(BodyID, EqualsOperator)
33 | {
34 | EXPECT_TRUE(BodyID(0u) == BodyID(0u));
35 | EXPECT_TRUE(BodyID(1u) == BodyID(1u));
36 | EXPECT_FALSE(BodyID(2u) == BodyID(1u));
37 | EXPECT_FALSE(BodyID(1u) == BodyID(2u));
38 | }
39 |
40 | TEST(BodyID, NotEqualsOperator)
41 | {
42 | EXPECT_FALSE(BodyID(0u) != BodyID(0u));
43 | EXPECT_FALSE(BodyID(1u) != BodyID(1u));
44 | EXPECT_TRUE(BodyID(2u) != BodyID(1u));
45 | EXPECT_TRUE(BodyID(1u) != BodyID(2u));
46 | }
47 |
48 | TEST(BodyID, swap)
49 | {
50 | auto b0 = BodyID(0u);
51 | auto b1 = BodyID(1u);
52 | EXPECT_NO_THROW(swap(b0, b1));
53 | EXPECT_EQ(b0, BodyID(1u));
54 | EXPECT_EQ(b1, BodyID(0u));
55 | }
56 |
57 | TEST(BodyID, IsValid)
58 | {
59 | EXPECT_TRUE(IsValid(BodyID(0u)));
60 | EXPECT_FALSE(IsValid(InvalidBodyID));
61 | }
62 |
--------------------------------------------------------------------------------
/Library/include/playrho/UnitInterval.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_UNITINTERVAL_HPP
22 | #define PLAYRHO_UNITINTERVAL_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c UnitInterval value checked types and related code.
26 |
27 | #include // for std::is_default_constructible_v
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 | #include
33 |
34 | // IWYU pragma: end_exports
35 |
36 | namespace playrho {
37 |
38 | /// @ingroup CheckedTypes
39 | /// @brief Unit interval constrained value type.
40 | template
41 | using UnitInterval = detail::Checked>;
42 |
43 | /// @ingroup CheckedTypes
44 | /// @brief Fast failing unit interval constrained value type.
45 | template
46 | using UnitIntervalFF = detail::Checked, true>;
47 |
48 | static_assert(std::is_default_constructible_v>);
49 |
50 | } // namespace playrho
51 |
52 | #endif // PLAYRHO_UNITINTERVAL_HPP
53 |
--------------------------------------------------------------------------------
/Library/include/playrho/ZeroToUnderOne.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_ZEROTOUNDERONE_HPP
22 | #define PLAYRHO_ZEROTOUNDERONE_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c ZeroToUnderOne value checked types and related code.
26 |
27 | #include // for std::is_default_constructible_v
28 |
29 | // IWYU pragma: begin_exports
30 |
31 | #include
32 | #include
33 |
34 | // IWYU pragma: end_exports
35 |
36 | namespace playrho {
37 |
38 | /// @ingroup CheckedTypes
39 | /// @brief Unit interval constrained value type.
40 | template
41 | using ZeroToUnderOne = detail::Checked>;
42 |
43 | /// @ingroup CheckedTypes
44 | /// @brief Fast failing unit interval constrained value type.
45 | template
46 | using ZeroToUnderOneFF = detail::Checked, true>;
47 |
48 | static_assert(std::is_default_constructible_v>);
49 |
50 | } // namespace playrho
51 |
52 | #endif // PLAYRHO_ZEROTOUNDERONE_HPP
53 |
--------------------------------------------------------------------------------
/Library/include/playrho/LimitState.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef PLAYRHO_LIMITSTATE_HPP
23 | #define PLAYRHO_LIMITSTATE_HPP
24 |
25 | /// @file
26 | /// @brief Definition of the @c LimitState enumeration and closely related code.
27 |
28 | namespace playrho {
29 |
30 | /// @brief Limit state.
31 | /// @note Only used by joints that implement some notion of a limited range.
32 | enum class LimitState
33 | {
34 | /// @brief Inactive limit.
35 | e_inactiveLimit,
36 |
37 | /// @brief At-lower limit.
38 | e_atLowerLimit,
39 |
40 | /// @brief At-upper limit.
41 | e_atUpperLimit,
42 |
43 | /// @brief Equal limit.
44 | /// @details Equal limit is used to indicate that a joint's upper and lower limits
45 | /// are approximately the same.
46 | e_equalLimits
47 | };
48 |
49 | /// @brief Provides a human readable C-style string uniquely identifying the given limit state.
50 | const char* ToString(LimitState val) noexcept;
51 |
52 | } // namespace playrho
53 |
54 | #endif // PLAYRHO_LIMITSTATE_HPP
55 |
--------------------------------------------------------------------------------
/Library/include/playrho/Defines.hpp.in:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | /**
22 | * @file
23 | * @brief Miscellaneous C-preprocessor definitions.
24 | * @details This file was autogenerated from the Defines.hpp.in file.
25 | */
26 |
27 | #ifndef PLAYRHO_DEFINES_HPP
28 | #define PLAYRHO_DEFINES_HPP
29 |
30 | // Checks if platform supports 128-bit integer types and defines macros for them if so.
31 | // Note that these could use any LiteralType type that has full operator and
32 | // common mathematical function support.
33 | #ifdef __SIZEOF_INT128__
34 | #define PLAYRHO_INT128 __int128_t
35 | #define PLAYRHO_UINT128 __uint128_t
36 | #endif
37 |
38 | #ifndef PLAYRHO_VERSION_MAJOR
39 | /// @brief PlayRho major version number.
40 | #define PLAYRHO_VERSION_MAJOR @PlayRho_VERSION_MAJOR@
41 | #endif
42 |
43 | #ifndef PLAYRHO_VERSION_MINOR
44 | /// @brief PlayRho minor version number.
45 | #define PLAYRHO_VERSION_MINOR @PlayRho_VERSION_MINOR@
46 | #endif
47 |
48 | #ifndef PLAYRHO_VERSION_PATCH
49 | /// @brief PlayRho patch version number.
50 | #define PLAYRHO_VERSION_PATCH @PlayRho_VERSION_PATCH@
51 | #endif
52 |
53 | #endif /* PLAYRHO_DEFINES_HPP */
54 |
--------------------------------------------------------------------------------
/UnitTests/FlagGuard.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | using namespace playrho;
29 |
30 | TEST(FlagGuard, ByteSizeOverhead)
31 | {
32 | // Check size at test runtime instead of compile-time via static_assert to avoid stopping
33 | // builds and to report actual size rather than just reporting that expected size is wrong.
34 | EXPECT_EQ(sizeof(FlagGuard), sizeof(std::uint8_t*) * 2);
35 | EXPECT_EQ(sizeof(FlagGuard), sizeof(std::uint16_t*) * 2);
36 | EXPECT_EQ(sizeof(FlagGuard), sizeof(std::uint32_t*) * 2);
37 | }
38 |
39 | TEST(FlagGuard, uint8_t)
40 | {
41 | std::uint8_t foo = 0;
42 | ASSERT_EQ(foo, 0);
43 | {
44 | FlagGuard guard(foo, 0x1u);
45 | EXPECT_EQ(foo, 0x1u);
46 | }
47 | EXPECT_EQ(foo, 0x0u);
48 | foo = 0x44u;
49 | ASSERT_EQ(foo, 0x44u);
50 | {
51 | FlagGuard guard(foo, 0x11u);
52 | EXPECT_EQ(foo, (0x11u | 0x44u));
53 | }
54 | EXPECT_EQ(foo, 0x44u);
55 | }
56 |
--------------------------------------------------------------------------------
/Library/include/playrho/d2/PositionConstraint.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef PLAYRHO_D2_POSITIONCONSTRAINT_HPP
23 | #define PLAYRHO_D2_POSITIONCONSTRAINT_HPP
24 |
25 | /// @file
26 | /// @brief Definition of the @c PositionConstraint class and closely related code.
27 |
28 | // IWYU pragma: begin_exports
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include
35 |
36 | // IWYU pragma: end_exports
37 |
38 | namespace playrho::d2 {
39 |
40 | /// @brief The per-contact position constraint data structure.
41 | struct PositionConstraint
42 | {
43 | /// @brief Copy of contact's manifold.
44 | Manifold manifold;
45 |
46 | /// @brief Identifier for body-A.
47 | BodyID bodyA;
48 |
49 | /// @brief Identifier for body-B.
50 | BodyID bodyB;
51 |
52 | /// @brief Total "Radius" distance of the associated shapes of fixture A and fixture B.
53 | NonNegativeFF totalRadius;
54 | };
55 |
56 | } // namespace playrho::d2
57 |
58 | #endif // PLAYRHO_D2_POSITIONCONSTRAINT_HPP
59 |
--------------------------------------------------------------------------------
/Library/include/playrho/detail/RayCastInput.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef PLAYRHO_DETAIL_RAYCASTINPUT_HPP
23 | #define PLAYRHO_DETAIL_RAYCASTINPUT_HPP
24 |
25 | /// @file
26 | /// @brief Declaration of the RayCastInput class template.
27 |
28 | #include // for std::size_t
29 |
30 | // IWYU pragma: begin_exports
31 |
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | // IWYU pragma: end_exports
38 |
39 | namespace playrho::detail {
40 |
41 | /// @brief Ray-cast input data for N-dimensions.
42 | /// @note The ray extends from p1 to p1 + maxFraction * (p2 - p1).
43 | template
44 | struct RayCastInput
45 | {
46 | Vector p1; ///< Point 1.
47 | Vector p2; ///< Point 2.
48 |
49 | /// @brief Max fraction.
50 | /// @details Unit interval value - a value between 0 and 1 inclusive.
51 | UnitInterval maxFraction;
52 | };
53 |
54 | } // namespace playrho::detail
55 |
56 | #endif // PLAYRHO_RAYCASTINPUT_HPP
57 |
58 |
--------------------------------------------------------------------------------
/Library/include/playrho/detail/PositiveChecker.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_DETAIL_POSITIVECHECKER_HPP
22 | #define PLAYRHO_DETAIL_POSITIVECHECKER_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c PositiveChecker class template.
26 |
27 | // IWYU pragma: private, include "playrho/Positive.hpp"
28 |
29 | namespace playrho::detail {
30 |
31 | /// @brief Positive constrained value checker.
32 | /// @note This is meant to be used as a checker with types like Checked.
33 | /// @tparam T Underlying type for this checker.
34 | /// @ingroup Checkers
35 | /// @see Checked.
36 | template
37 | struct PositiveChecker {
38 |
39 | /// @brief Value checking functor.
40 | /// @return Null string if given value is greater than zero, else
41 | /// a non-null string explanation.
42 | constexpr auto operator()(const T& v) const noexcept
43 | -> decltype(v > T{}, static_cast(nullptr))
44 | {
45 | if (!(v > T{})) {
46 | return "value not greater than zero";
47 | }
48 | return {};
49 | }
50 | };
51 |
52 | } // namespace playrho::detail
53 |
54 | #endif // PLAYRHO_DETAIL_POSITIVECHECKER_HPP
55 |
--------------------------------------------------------------------------------
/Library/source/playrho/DynamicMemory.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 |
24 | #include
25 |
26 | namespace playrho {
27 |
28 | // Memory allocators. Modify these to use your own allocator.
29 | void* Alloc(std::size_t size)
30 | {
31 | if (size) {
32 | const auto memory = std::malloc(size); // NOLINT(cppcoreguidelines-no-malloc,cppcoreguidelines-owning-memory)
33 | if (!memory) {
34 | throw std::bad_alloc{};
35 | }
36 | return memory;
37 | }
38 | return nullptr;
39 | }
40 |
41 | void* Realloc(void* ptr, std::size_t size)
42 | {
43 | if (size) {
44 | const auto memory = std::realloc(ptr, size); // NOLINT(cppcoreguidelines-no-malloc,cppcoreguidelines-owning-memory)
45 | if (!memory) {
46 | throw std::bad_alloc{};
47 | }
48 | return memory;
49 | }
50 | Free(ptr);
51 | return nullptr;
52 | }
53 |
54 | void Free(void* mem)
55 | {
56 | std::free(mem); // NOLINT(cppcoreguidelines-no-malloc,cppcoreguidelines-owning-memory)
57 | }
58 |
59 | } // namespace playrho
60 |
--------------------------------------------------------------------------------
/Library/include/playrho/detail/NonZeroChecker.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_DETAIL_NONZEROCHECKER_HPP
22 | #define PLAYRHO_DETAIL_NONZEROCHECKER_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c NonZeroChecker class template.
26 |
27 | // IWYU pragma: private, include "playrho/NonZero.hpp"
28 |
29 | namespace playrho::detail {
30 |
31 | /// @brief Non-zero constrained value checker.
32 | /// @note This is meant to be used as a checker with types like Checked.
33 | /// @tparam T Underlying type for this checker.
34 | /// @ingroup Checkers
35 | /// @see Checked.
36 | template
37 | struct NonZeroChecker {
38 |
39 | /// @brief Value checking functor.
40 | /// @return Null string if given value is not equal to zero, else
41 | /// a non-null string explanation.
42 | constexpr auto operator()(const T& v) const noexcept
43 | -> decltype(!(v != static_cast(0)), static_cast(nullptr))
44 | {
45 | if (!(v != static_cast(0))) {
46 | return "value not non-zero";
47 | }
48 | return {};
49 | }
50 | };
51 |
52 | } // namespace playrho::detail
53 |
54 | #endif // PLAYRHO_DETAIL_NONZEROCHECKER_HPP
55 |
--------------------------------------------------------------------------------
/Library/include/playrho/detail/NegativeChecker.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #ifndef PLAYRHO_DETAIL_NEGATIVECHECKER_HPP
22 | #define PLAYRHO_DETAIL_NEGATIVECHECKER_HPP
23 |
24 | /// @file
25 | /// @brief Definition of the @c NegativeChecker class template.
26 |
27 | // IWYU pragma: private, include "playrho/Negative.hpp"
28 |
29 | namespace playrho::detail {
30 |
31 | /// @brief Negative constrained value checker.
32 | /// @note This is meant to be used as a checker with types like Checked.
33 | /// @tparam T Underlying type for this checker.
34 | /// @ingroup Checkers
35 | /// @see Checked.
36 | template
37 | struct NegativeChecker {
38 |
39 | /// @brief Value checking functor.
40 | /// @return Null string if given value is less than zero, else
41 | /// a non-null string explanation.
42 | constexpr auto operator()(const T& v) const noexcept
43 | -> decltype(v < static_cast(0), static_cast(nullptr))
44 | {
45 | if (!(v < static_cast(0))) {
46 | return "value not less than zero";
47 | }
48 | return {};
49 | }
50 | };
51 |
52 | } // namespace playrho::detail
53 |
54 | #endif // PLAYRHO_DETAIL_NEGATIVECHECKER_HPP
55 |
--------------------------------------------------------------------------------
/HelloWorld/README.md:
--------------------------------------------------------------------------------
1 | # HelloWorld Console Application
2 |
3 | This application component provides a time-wise dump of a body's `X`-`Y` coordinates and angle after being dropped from a distance over a surface.
4 | Output is limited to the preconfigured number of steps of the engine, the acceleration towards the surface, and the distance from that surface.
5 | Only the `Y` coordinate value should change from line to line until the number of steps have finished or the body has come to rest on the surface,
6 | which ever may come first.
7 |
8 | ## Prerequisites
9 |
10 | This component has no prerequisites other than those for the [library component](../PlayRho/).
11 |
12 | ## Configuration
13 |
14 | This component needs the `-DPLAYRHO_BUILD_HELLOWORLD=ON` command line argument added to the CMake configuration step's list of arguments.
15 |
16 | ## Building & Installation
17 |
18 | See the project's [documented build and installation steps](../INSTALL.md).
19 |
20 | ## Sample Output
21 |
22 | ```sh
23 | $ ./HelloWorld
24 | 0.00 4.00 0.00
25 | 0.00 3.99 0.00
26 | 0.00 3.98 0.00
27 | 0.00 3.97 0.00
28 | 0.00 3.96 0.00
29 | 0.00 3.94 0.00
30 | 0.00 3.92 0.00
31 | 0.00 3.90 0.00
32 | 0.00 3.88 0.00
33 | 0.00 3.85 0.00
34 | 0.00 3.82 0.00
35 | 0.00 3.79 0.00
36 | 0.00 3.75 0.00
37 | 0.00 3.71 0.00
38 | 0.00 3.67 0.00
39 | 0.00 3.63 0.00
40 | 0.00 3.58 0.00
41 | 0.00 3.53 0.00
42 | 0.00 3.48 0.00
43 | 0.00 3.43 0.00
44 | 0.00 3.37 0.00
45 | 0.00 3.31 0.00
46 | 0.00 3.25 0.00
47 | 0.00 3.18 0.00
48 | 0.00 3.12 0.00
49 | 0.00 3.04 0.00
50 | 0.00 2.97 0.00
51 | 0.00 2.89 0.00
52 | 0.00 2.82 0.00
53 | 0.00 2.73 0.00
54 | 0.00 2.65 0.00
55 | 0.00 2.56 0.00
56 | 0.00 2.47 0.00
57 | 0.00 2.38 0.00
58 | 0.00 2.28 0.00
59 | 0.00 2.19 0.00
60 | 0.00 2.09 0.00
61 | 0.00 1.98 0.00
62 | 0.00 1.88 0.00
63 | 0.00 1.77 0.00
64 | 0.00 1.66 0.00
65 | 0.00 1.54 0.00
66 | 0.00 1.42 0.00
67 | 0.00 1.30 0.00
68 | 0.00 1.18 0.00
69 | 0.00 1.06 0.00
70 | 0.00 1.00 0.00
71 | 0.00 1.00 0.00
72 | 0.00 1.00 0.00
73 | 0.00 1.00 0.00
74 | 0.00 1.00 0.00
75 | 0.00 1.00 0.00
76 | 0.00 1.00 0.00
77 | 0.00 1.00 0.00
78 | 0.00 1.00 0.00
79 | 0.00 1.00 0.00
80 | 0.00 1.00 0.00
81 | 0.00 1.00 0.00
82 | 0.00 1.00 0.00
83 | 0.00 1.00 0.00
84 | ```
85 |
--------------------------------------------------------------------------------
/UnitTests/SimplexEdge.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | using namespace playrho;
26 | using namespace playrho::d2;
27 |
28 | TEST(SimplexEdge, ByteSize)
29 | {
30 | // Check size at test runtime instead of compile-time via static_assert to avoid stopping
31 | // builds and to report actual size rather than just reporting that expected size is wrong.
32 | switch (sizeof(Real))
33 | {
34 | case 4: EXPECT_EQ(sizeof(SimplexEdge), std::size_t(20)); break;
35 | case 8: EXPECT_EQ(sizeof(SimplexEdge), std::size_t(40)); break;
36 | case 16: EXPECT_EQ(sizeof(SimplexEdge), std::size_t(80)); break;
37 | default: FAIL(); break;
38 | }
39 | }
40 |
41 | TEST(SimplexEdge, InitializingConstructor)
42 | {
43 | const auto iA = VertexCounter{1};
44 | const auto iB = VertexCounter{2};
45 | const auto pA = Length2{2.2_m, -3.1_m};
46 | const auto pB = Length2{-9.2_m, 0.003_m};
47 |
48 | const auto sv = SimplexEdge(pA, iA, pB, iB);
49 |
50 | EXPECT_EQ(sv.GetPointA(), pA);
51 | EXPECT_EQ(sv.GetPointB(), pB);
52 | EXPECT_EQ(sv.GetIndexA(), iA);
53 | EXPECT_EQ(sv.GetIndexB(), iB);
54 | EXPECT_EQ(GetPointDelta(sv), pB - pA);
55 | }
56 |
--------------------------------------------------------------------------------
/Testbed/Tests/HalfPipe.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "../Framework/Test.hpp"
22 |
23 | namespace testbed {
24 |
25 | class HalfPipe : public Test
26 | {
27 | public:
28 | static inline const auto registered = RegisterTest("Half Pipe", MakeUniqueTest);
29 |
30 | HalfPipe()
31 | {
32 | const auto pipeBody = CreateBody(GetWorld(), BodyConf{}.UseLocation(Vec2(0, 20) * 1_m));
33 | {
34 | auto conf = ChainShapeConf{};
35 | conf.UseFriction(Real(1));
36 | conf.Set(GetCircleVertices(20_m, 90, 180_deg, Real(0.5f)));
37 | Attach(GetWorld(), pipeBody, CreateShape(GetWorld(), conf));
38 | }
39 | const auto ballBody = CreateBody(GetWorld(), BodyConf{}
40 | .Use(BodyType::Dynamic)
41 | .UseLocation(Vec2(-19, 28) * 1_m)
42 | .UseLinearAcceleration(GetGravity()));
43 | Attach(GetWorld(), ballBody,
44 | CreateShape(
45 | GetWorld(),
46 | DiskShapeConf{}.UseDensity(0.01_kgpm2).UseRadius(1_m).UseFriction(Real(1))));
47 | }
48 | };
49 |
50 | } // namespace testbed
51 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/World.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 | #include // for ResetMassData
24 | #include
25 |
26 | namespace playrho::d2 {
27 |
28 | World::World(const WorldConf& def): World{AabbTreeWorld{def}} {}
29 |
30 | World::World(const World& other): m_impl{other.m_impl? other.m_impl->Clone_(): nullptr}
31 | {
32 | // Intentionally empty.
33 | }
34 |
35 | World::~World() noexcept
36 | {
37 | if (m_impl) { // for proper handling after being moved from
38 | // Call implementation's clear while World still valid to give destruction
39 | // listening callbacks chance to run while world data is still valid.
40 | m_impl->Clear_();
41 | }
42 | }
43 |
44 | World& World::operator=(const World& other)
45 | {
46 | m_impl = other.m_impl ? other.m_impl->Clone_() : nullptr;
47 | return *this;
48 | }
49 |
50 | BodyID CreateBody(World& world, const Body& body, bool resetMassData)
51 | {
52 | const auto id = world.m_impl->CreateBody_(body);
53 | if (resetMassData) {
54 | ResetMassData(world, id);
55 | }
56 | return id;
57 | }
58 |
59 | } // namespace playrho::d2
60 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/JointConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2007 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include // for std::is_default_constructible_v
23 |
24 | #include
25 | #include
26 |
27 | namespace playrho::d2 {
28 |
29 | static_assert(std::is_default_constructible_v,
30 | "JointConf should be default constructible!");
31 | static_assert(std::is_copy_constructible_v,
32 | "JointConf should be copy constructible!");
33 | static_assert(std::is_copy_assignable_v, "JointConf should be copy assignable!");
34 | static_assert(std::is_nothrow_move_constructible_v,
35 | "JointConf should be nothrow move constructible!");
36 | static_assert(std::is_nothrow_move_assignable_v,
37 | "JointConf should be nothrow move assignable!");
38 | static_assert(std::is_nothrow_destructible_v,
39 | "JointConf should be nothrow destructible!");
40 |
41 | void Set(JointConf& def, const Joint& joint) noexcept
42 | {
43 | def.bodyA = GetBodyA(joint);
44 | def.bodyB = GetBodyB(joint);
45 | def.collideConnected = GetCollideConnected(joint);
46 | }
47 |
48 | } // namespace playrho::d2
49 |
--------------------------------------------------------------------------------
/Library/source/playrho/pmr/StatsResource.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include // for std::max
22 | #include // for assert
23 |
24 | #include
25 |
26 | namespace playrho::pmr {
27 |
28 | void *StatsResource::do_allocate(std::size_t bytes, std::size_t alignment)
29 | {
30 | assert(m_upstream != nullptr);
31 | // Don't update statistics if allocate throws.
32 | const auto p = m_upstream->allocate(bytes, alignment);
33 | auto stats = m_stats;
34 | ++stats.blocksAllocated;
35 | stats.bytesAllocated += bytes;
36 | stats.maxBlocksAllocated = std::max(stats.maxBlocksAllocated, stats.blocksAllocated);
37 | stats.maxBytesAllocated = std::max(stats.maxBytesAllocated, stats.bytesAllocated);
38 | stats.maxBytes = std::max(stats.maxBytes, bytes);
39 | stats.maxAlignment = std::max(stats.maxAlignment, alignment);
40 | m_stats = stats;
41 | return p;
42 | }
43 |
44 | void StatsResource::do_deallocate(void *p, std::size_t bytes, std::size_t alignment)
45 | {
46 | assert(m_upstream != nullptr);
47 | // Don't update statistics if deallocate throws.
48 | m_upstream->deallocate(p, bytes, alignment);
49 | auto stats = m_stats;
50 | --stats.blocksAllocated;
51 | stats.bytesAllocated -= bytes;
52 | m_stats = stats;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/Library/include/playrho/RayCastOpcode.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #ifndef PLAYRHO_RAYCASTOPCODE_HPP
23 | #define PLAYRHO_RAYCASTOPCODE_HPP
24 |
25 | /// @file
26 | /// @brief Definition of the @c RayCastOpcode enumeration.
27 |
28 | namespace playrho {
29 |
30 | /// @brief Ray cast opcode enumeration.
31 | /// @details Instructs some ray casting methods on what to do next.
32 | enum class RayCastOpcode
33 | {
34 | /// @brief End the ray-cast search for fixtures.
35 | /// @details Use this to stop searching for fixtures.
36 | Terminate,
37 |
38 | /// @brief Ignore the current fixture.
39 | /// @details Use this to continue searching for fixtures along the ray.
40 | IgnoreFixture,
41 |
42 | /// @brief Clip the ray end to the current point.
43 | /// @details Use this shorten the ray to the current point and to continue searching
44 | /// for fixtures now along the newly shortened ray.
45 | ClipRay,
46 |
47 | /// @brief Reset the ray end back to the second point.
48 | /// @details Use this to restore the ray to its full length and to continue searching
49 | /// for fixtures now along the restored full length ray.
50 | ResetRay
51 | };
52 |
53 | } // namespace playrho
54 |
55 | #endif // PLAYRHO_RAYCASTOPCODE_HPP
56 |
--------------------------------------------------------------------------------
/Testbed/Tests/VaryingRestitution.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include "../Framework/Test.hpp"
23 |
24 | namespace testbed {
25 |
26 | // Note: even with a restitution of 1.0, there is some energy change
27 | // due to position correction.
28 | class VaryingRestitution : public Test
29 | {
30 | public:
31 | static inline const auto registered =
32 | RegisterTest("Varying Restitution", MakeUniqueTest);
33 |
34 | VaryingRestitution()
35 | {
36 | const auto ground = CreateBody(GetWorld());
37 | Attach(GetWorld(), ground, CreateShape(GetWorld(), GetGroundEdgeConf()));
38 |
39 | Real restitution[7] = {0.0f, 0.1f, 0.3f, 0.5f, 0.75f, 0.9f, 1.0f};
40 | auto shape = DiskShapeConf{}.UseRadius(1_m).UseDensity(1_kgpm2);
41 | for (auto i = 0; i < 7; ++i) {
42 | BodyConf bd;
43 | bd.type = BodyType::Dynamic;
44 | bd.linearAcceleration = GetGravity();
45 | bd.UseLocation(Vec2(Real(-10 + 3 * i), 20) * 1_m);
46 | const auto body = CreateBody(GetWorld(), bd);
47 | shape.UseRestitution(restitution[i]);
48 | Attach(GetWorld(), body, CreateShape(GetWorld(), shape));
49 | }
50 | }
51 | };
52 |
53 | } // namespace testbed
54 |
--------------------------------------------------------------------------------
/Library/source/playrho/d2/BodyConf.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | namespace playrho::d2 {
28 |
29 | BodyConf GetBodyConf(const Body& body)
30 | {
31 | auto def = BodyConf{};
32 | def.type = GetType(body);
33 | def.sweep = GetSweep(body);
34 | def.invMass = GetInvMass(body);
35 | def.invRotI = GetInvRotInertia(body);
36 | def.linearVelocity = GetLinearVelocity(body);
37 | def.angularVelocity = GetAngularVelocity(body);
38 | def.linearAcceleration = GetLinearAcceleration(body);
39 | def.angularAcceleration = GetAngularAcceleration(body);
40 | def.linearDamping = GetLinearDamping(body);
41 | def.angularDamping = GetAngularDamping(body);
42 | def.underActiveTime = GetUnderActiveTime(body);
43 | def.shapes = GetShapes(body);
44 | def.allowSleep = IsSleepingAllowed(body);
45 | def.awake = IsAwake(body);
46 | def.fixedRotation = IsFixedRotation(body);
47 | def.bullet = IsAccelerable(body) && IsImpenetrable(body);
48 | def.enabled = IsEnabled(body);
49 | def.massDataDirty = IsMassDataDirty(body);
50 | return def;
51 | }
52 |
53 | } // namespace playrho::d2
54 |
--------------------------------------------------------------------------------
/Testbed/Tests/Chain.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3 | * Modified work Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4 | *
5 | * This software is provided 'as-is', without any express or implied
6 | * warranty. In no event will the authors be held liable for any damages
7 | * arising from the use of this software.
8 | *
9 | * Permission is granted to anyone to use this software for any purpose,
10 | * including commercial applications, and to alter it and redistribute it
11 | * freely, subject to the following restrictions:
12 | *
13 | * 1. The origin of this software must not be misrepresented; you must not
14 | * claim that you wrote the original software. If you use this software
15 | * in a product, an acknowledgment in the product documentation would be
16 | * appreciated but is not required.
17 | * 2. Altered source versions must be plainly marked as such, and must not be
18 | * misrepresented as being the original software.
19 | * 3. This notice may not be removed or altered from any source distribution.
20 | */
21 |
22 | #include "../Framework/Test.hpp"
23 |
24 | namespace testbed {
25 |
26 | class Chain : public Test
27 | {
28 | public:
29 | static inline const auto registered = RegisterTest("Chain", MakeUniqueTest);
30 |
31 | Chain()
32 | {
33 | const auto ground = CreateBody(GetWorld());
34 | Attach(GetWorld(), ground, CreateShape(GetWorld(), GetGroundEdgeConf()));
35 | const auto shape = CreateShape(
36 | GetWorld(), PolygonShapeConf{}.UseDensity(20_kgpm2).UseFriction(Real(0.2)).SetAsBox(
37 | 0.6_m, 0.125_m));
38 | const auto y = 25.0f;
39 | auto prevBody = ground;
40 | for (auto i = 0; i < 30; ++i) {
41 | const auto bd = BodyConf{}
42 | .Use(BodyType::Dynamic)
43 | .UseLinearAcceleration(GetGravity())
44 | .UseLocation(Vec2(0.5f + i, y) * 1_m);
45 | const auto body = CreateBody(GetWorld(), bd);
46 | Attach(GetWorld(), body, shape);
47 | CreateJoint(GetWorld(),
48 | GetRevoluteJointConf(GetWorld(), prevBody, body, Vec2(Real(i), y) * 1_m));
49 | prevBody = body;
50 | }
51 | }
52 | };
53 |
54 | } // namespace testbed
55 |
--------------------------------------------------------------------------------
/UnitTests/TypeInfo.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Louis Langholtz https://github.com/louis-langholtz/PlayRho
3 | *
4 | * This software is provided 'as-is', without any express or implied
5 | * warranty. In no event will the authors be held liable for any damages
6 | * arising from the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | #include "UnitTests.hpp"
22 |
23 | #include
24 |
25 | #include
26 |
27 | using namespace playrho;
28 |
29 | TEST(TypeInfo, DefaultConstruction)
30 | {
31 | EXPECT_EQ(TypeID(), GetTypeID());
32 | EXPECT_TRUE(std::strcmp(TypeID().GetName(), GetTypeID().GetName()) == 0);
33 | EXPECT_NE(TypeID(), GetTypeID());
34 | }
35 |
36 | TEST(TypeInfo, Equality)
37 | {
38 | EXPECT_TRUE(TypeID() == GetTypeID());
39 | EXPECT_FALSE(TypeID() == GetTypeID());
40 | EXPECT_TRUE(GetTypeID() == GetTypeID());
41 | EXPECT_FALSE(GetTypeID() == GetTypeID());
42 | }
43 |
44 | TEST(TypeInfo, InEquality)
45 | {
46 | EXPECT_FALSE(TypeID() != GetTypeID());
47 | EXPECT_TRUE(TypeID() != GetTypeID());
48 | EXPECT_FALSE(GetTypeID