ReactPhysics3D lua bindings for the Defold Game Engine.
This project based on ReactPhysics3D
ReactPhysics3D is an open source C++ physics engine library that can be used in 3D simulations and games.
I tried to keep the lua api the same as the c++ api when possible.
If you like the extension you can support me on patreon. It will help me make more libraries for defold.
Try the demo
-
This is c++ library. I add some function parameters checks but you can crash it in some cases.
-
Call destroy. Or you will have memory leaks.
-
rp3d.destroyPhysicsWorld will destroy and free all used memory by world objects. But for example shapes will not be free.
-
Destroy shapes after destroy all objects that use shape or you will get crash.
--CRASH
rp3d.destroyBoxShape(self.shape)
self.world:destroyCollisionBody(self.body)
--GOOD
self.world:destroyCollisionBody(self.body)
rp3d.destroyBoxShape(self.shape)
-
In most places used 0 index.
-
You can crash physics engine in Hinge Chain test scene.
Assertion failed: length() > MACHINE_EPSILON, at: upload/reactphysics3d/src/reactphysics3d/mathematics/Vector3.cpp,48,getOneUnitOrthogonalVector)
1)Defold vector instead of rp3d::Vector
2)Defold quaternion instead of rp3d::Quat
3)no Transform userdata. Use table with vector3 and quaternion
You can use the rp3d extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:
https://github.com/d954mas/defold-reactphysics3d/archive/master.zip
Or point to the ZIP file of a specific release.
Make lua file with Emmylua annotations. Use it for autocomplete.
User manual and api for c++ library. Read it first
2.Lua API
3.Examples
Look at examples. You can download this repository and run them.
4.Tests
Every function have a test. You can use test as example.
AABB
BallAndSocketJoint
BallAndSocketJointInfo
BoxShape
CapsuleShape
Collider
CollisionBody
CollisionShape
ConcaveMeshShape
ConcaveShape
ConvexMeshShape
ConvexPolyhedronShape
ConvexShape
DebugRenderer
EventListener
FixedJoint
FixedJointInfo
HalfEdgeStructure
HeightFieldShape
HingeJoint
HingeJointInfo
Joint
JointInfo
Material
PhysicsCommon rp3d in lua
PhysicsWorld
PolyhedronMesh
Ray
RaycastCallback
RaycastInfo
RigidBody
SliderJoint
SliderJointInfo
SphereShape
Transform
TriangleMesh
TriangleVertexArray