Tweaking Physics

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Name: Physics Arc
Summary: A series of improvements to Terasology's handling of collisions and physics
Scope: Engine
Current Goal: Kinematic rigid bodies
Phase: Implementation
Curator: Immortius
Related:

The Physics Arc covers a range of improvements to how collision and physics is done within Terasology:
  • Direct integration of JBullet with the world, removing the need to generate and update per-chunk collision hulls.
  • Removal of existing AABB system, instead having all raytracing and convex sweeping happening through JBullet.
  • Support for non-AABB block shape collision, via shapes and simple collision hulls - including in the Blender exporter.
  • Improved Character Movement through swept capsule or cylinder (or ghost collision object).
  • Addition of physics and collision components to entity system, fully integrated with JBullet. This will allow raytrace and collision support directly with entities in addition to the world, enabling entity interaction.
  • Handle dropped blocks as entities.
  • Steep slope support (blocking movement up a steep slope, sliding down a steep slope)
  • Mantling support.
  • Physics System interface improvements
  • Interpolate Character movement
Current State:
  • Spun out a modified JBullet Library called TeraBullet. Uses maven build system. Licensed under ZLib License at the moment, as that is JBullet's license. This is all open to suggestions.
  • Added basic voxel world support from proof of concept.
  • Added low-level convex sweep and raytrace support. This still needs some optimisation.
  • Terasology world raytracing now done through TeraBullet.
  • Fixed up waking sleeping rigid bodies when the world changes.
  • Block shapes and blocks now include TeraBullet collision shapes, with single and compound AABBs supported. This needs to be extended to support simple collision hulls, spheres, boxes and any other collision shape we might desire.
  • Character movement now done via swept cylinders.
  • Cleaned up the previous AABB system.
  • Added a rough system for doing AABB tests through JBullet.
  • Some entity system integration, with dropped blocks as entities now.
  • Integrated CameraTarget system, now reports focused entities.
  • Integrated CollisionGroups for collision filtering.
TODO:
  • Need to sort out a maven repository for the TeraBullet project.
  • Various optimisations for TeraBullet
  • Need to better encapsulate physics - hiding the jbullet implementation.
  • Investigate adding the aabbTest method from newer versions of bullet to TeraBullet
  • Kinematic rigid bodies
  • Handle changes to physics components settings
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Cool stuff.

I think there are ways (plugins) to use Jenkins build artifacts stored in jobs as a Maven repo. Which you could also do with Gradle for that matter :)

If we need to we can throw an Artifactory / Nexus instance on the build server too.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
The one tricky point is there is this one library, JStackAlloc, which is a dependency we don't have to build but which is not available in any repository I can see. We could still set it up as a project and build it though, just seems a little unnecessary.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
I've pushed my changes to date into the main develop branch - functionally things are about the same as before, but the chunk collision hull generation overhead is gone, so net improvement. There are a couple of library changes, so the IntelliJ project needs to be regenerated. Also I think I broke saved games again by refactoring some packages - need to change how worlds are saved so it is more robust at some point.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
JBullet based character movement is proceeding nicely. I tracked down a change to Bullet that fixed up some behaviour around allowed penetration during convex sweeps - this is designed to provide a way to allow a small amount of penetration due to floating point errors and such. Without the fix the player would move through walls at low speeds, or if you turned off allowed penetration you couldn't slide against walls reliably. With the fix and some tweaking of how it was used everything seems to be behaving nicely.

Additionally, walking up stairs works now. :) Later I'll add some sloped blocks and see how they behave.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Woot! Physics wizardry :)

Any clue how much of a performance boost it yields?
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
The character movement changes? It is probably more expensive than before, AABB collision is really simple and cheap while convex sweep based movement is somewhat more complex. This change is more around adding functionality than performance.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Oh okay. I think I got stuck on removing the generation of collision hulls - wasn't thinking big picture. Said big picture does contain neat new stuff, so me likey :)
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Dropped blocks are now done via Entities in the physics branch. Players have a trigger component that uses a shape to detect when dropped blocks enter the player's area, and when this occurs they are given the block.

At the moment blocks don't get sucked into the player any more, and they aren't given any impulse from explosions. However all dropped blocks, from explosions, railguns and normal mining, can be picked up.

Behind all this, all entities can now have a rigid body + shape component to be moved by physics, or a trigger + shape component to detect things entering their space. Component systems can now subscribe to the collision events to take action.

The big issue performance-wise now seems to be rendering all of the dropped blocks. Probably need to add some batched rendering for the blocks (rendering all of them as a single mesh rather than individually)
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Character movement now correctly handles slopes, particularly steep slopes and sliding down them.

This are is nearing completion over all. Still want to add in kinematic rigid body support, optimise terabullet and clean up the physics code in Terasology, but we're nearly feature complete.
 
Top