This is not the same concept as in Physx, which is the reason I didn't really like it. In Physx there is simply PXRigidStatic and PxRigidDynamic actors. I instead went for the option of having a flag to decide at creation whether you want a static or dynamic object which I also do for kinematic objects.
At the moment I have 3 new components and one new system. the new components are:
I did try and attempt to have 1 PhysicsComponent but as Box, Sphere, Plane and eventually Capsule have such varying parameters it made it quite difficult. The main problem is that my component classes cannot very easily be polymorphic due to all the CRTP that goes on.
The alternative would be to have all the variables as part of the class i.e.
as private members and then have a Type value that would determine which values you want to look at.
** Thinking about it I might try this instead. **
I can't imagine the properties for physics objects are likely to change much, and there is likely to only be about 5/6 different physics types anyway: sphere, box, capsule, plane, mesh and trigger. That is if I even bother supporting all of those.
It would make the streaming slightly more difficult as there would be branching rather than a straight value for value copy.
Anyway I'm wobbling on, here is a simple video showing the player character hitting the invisible boundary walls that I have put in:
There are still a few things I need to think about:
- Now re-thinking whether to use 1 Component with a Shape Type value.
- Altering Physics Materials, currently all objects use the same default material.
- Collision Filtering, this is something that I have been thinking about quite a bit.
The collision filtering is really interesting. I have been wanting to come up with a nice generic solution. Currently you can add a filter group and filter mask to any actor. So you choose which group it is part of and then choose all of the groups that you would like to register collisions for.
I was thinking of creating a set number of filter groups for the engine and then have the user of the engine deal with collisions at a higher level using ECS game logic. The problem is I can't think of generic enough groups to make this useful.
Anyway I'm fairly happy with progress and I'm hoping it can continue on.