Improved player movement/block collision

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Just wanted to right up some thoughts/experiment results on improving character movement and block collision.

Features that I think are desirable:
- Character collision as a cylinder or capsule. Avoids some oddities in how close you can get to a block being dependant on angle of approach
- Slope support - not just AABBs. Players could walk up and down slopes of a certain angle, and slide down steeper slopes.
- Stepping up half blocks without jumping
- Movement collision checks easily repeatable - this is necessary to support client side prediction of movement smoothly.
- Character -> Entity and Character -> Character collision
- Blocks having either a collection of shapes or simple convex collision hulls that describe their collision, allowing for a wider variety of block shapes.

Generally think it would be worth exploiting jBullet's collision algorithms if possible. There are a couple of options here:
- Use it in the traditional sense. Maintain a collision world with mesh colliders for each generated chunk. The good part is we are doing this already. The bad is that it takes a while for the mesh to update, would need to be a separate mesh to the one used for display (to exclude non-blocking mesh bits) and we'ld be restricted to worlds of a size that a simple float can support as that is what jBullet uses internally. (Well, there is probably some way to work around that, but a bit tricky with multiple players).

- I did a bit of experimenting with dynamically creating a small collision world around each character for movement, only including the collision shapes for the blocks they might touch during the current movement calculations. This has the advantage of not requiring any mesh generation (or at most one mesh per block if not using the primitive shapes), and the temporary collision world can be centered on the character's location. The performance seems reasonable even without optimising it much.

What I haven't worked out is how to properly use the jBullet for character movement - had some basic walking working using convex sweeps, but jittered or fell through the world a fair bit. Probably need to attack this methodically with unit tests.

- Should be noted that using jBullet's character controllers is not a good option, because they aren't fully implemented. May be educational to look at though.

I've gone back to working on Entity System stuff for the moment, but if someone is interested in picking this up I can float the code their way (or put it up a in branch)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Good stuff, thanks for the write-up :)

Blocks having either a collection of shapes or simple convex collision hulls that describe their collision, allowing for a wider variety of block shapes.
How does that bit interact with the current shape definition objects? Vague recollection that they include some degree of collision data.

Feel free to throw a prototype branch out there somewhere if you have it handy anyway - might make for good reading/tinkering material
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Cervator said:
How does that bit interact with the current shape definition objects? Vague recollection that they include some degree of collision data.
Yes, at the moment block shape definitions contain a list of AABBs for the block to use for collision. These can be defined in Blender by adding extra meshes and marking them to be used to generate a collision AABB. This would basically be extended to a list of supported collision shapes.
 
Top