FlingEngine
FlingEngine copied to clipboard
Integrate bullet physics
Integrate bullet physics with our entity component system. https://github.com/bulletphysics/bullet3
Basic rough draft of the physic system
// Add a 3D rigidbody component
entt::entitty e = reg.create();
Rigidbody& c = reg.assign<Rigidbody>(e, transform, force, velocity, acceleration, mass, etc....);
// Add collision body component for collision detection
entt::entitty e = reg.create();
SphereCollider& c = reg.assign<SphereCollider>(e, transform, radius);
// Add
entt::entitty e = reg.create();
Transform& c = reg.assign<Transform>(e, Transform{});
Rigidbody& c = reg.assign<Rigidbody>(e, transform, force, velocity, acceleration, mass, etc....);
SphereCollider& c = reg.assign<SphereCollider>(e, transform, radius);
class PhysicSystem
{
// Update all active physics component
void Update(entt::registry reg);
};
That outline looks good. This article explains how we can make relationships with Entt: https://skypjack.github.io/2019-04-12-entt-tips-and-tricks-part-1/
(i.e. rigidbody HAS A transform)