The first version of Bounce has been pushed to the following git repository: https://github.com/irlanrobson/bounce. Bounce is a 3D physics engine for games and interactive applications and hopefully will be a fun project to work on.

# Bounce Update

Here is a compilation of a few physics demos using Bounce physics engine. It’s possible to visualize in these demos state-of-the art solutions for rigid body dynamics for games and interactive applications. In particular large block solvers and one-shot persistent contact manifolds. The camera controls are the same as in Maya, and continuous collision is disabled.

# Bounce Update

This post is somewhat a description of what I’ve been doing recently. This week I’ve been searching for cloth simulation papers to get a bit out of rigid body dynamics since it is a well solved problem as discussed by the community. Last week I ended up finishing an implementation of contact point clustering using k-means. My experiments have shown that the optimization described in the excelent GPG4 article is available just to show how things got started. However, it can generate good results even if implemented naively, still leaving open doors for more optimization, such as the use of hysteresis to avoid jittering and the like. The video below was one of the first tests that showed some acceptable, still not plausable though, results.

We basically cluster contact points by the normals using k-means and reproject them on an average plane built from the contact points of a cluster. I call this the cluster plane. As opposed to maximizing contact point distance as was told in the GPG4 article, we build an approximate convex hull using the contact points for each cluster. I call this the cluster polygon. I used an algorithm similar to the convex pair contact point reduction. There can be a maximum of three manifolds. Roughly speaking, the optimization improved the simulation performance by an order of magnitude. For collisions between spheres and (potential) triangles I implemented and can recommend the holistic algorithm described in this paper simply because is direct and easy enough to implement in a week. Ideally my plan is to disregard the algorithm when a solution to the problem of collision between the other shapes and the internal edges of the potential triangles is implemented, leaving all mesh contacts generated by a single code path.

Cheers.

# Building a Half-Edge Mesh from a Triangle List

The problem is to build a polygonal mesh from a triangle list efficiently. A solution is important specially when building or testing physics engines. The method below shows a possible solution. This can be done without needing the additional storage and processing cost of keeping a list of half-edges for a given face during its addition which would be linked at the end of the addition in that case.

# Distance Constraint Derivation

Sometimes it’s desired to have a distance constraint. That constraint assumes a choosen separation distance for two points fixed in two bodies. I’ve written a derivation for it in 3D and shared here. An implementation should be pretty simple since we have minimally one Jacobian and solve a 1D linear system. Here is an example which you can use in your own projects.

# Fast Segment-AABB Collision Detection

Let’s say we need to compute the intersection point and normal from a line segment to an axis-aligned bounding box (AABB) bounds, and we neither want to perform expensive plane computations nor keep the AABB boundaries as an intersection of 6 axis-aligned planes (as it is a waste of memory). A quick way to do that is by evaluating the slab plane equation for each axis-aligned plane of the AABB.

# Keyboard Input for Fixed-Time Step Games

Suppose we’re using a fixed-time step to update the game and we’re at the begin of a new frame. Then, the keyboard input events that were fired are requested and handled via callbacks or similar, making a character to jump or shoot in an enemy. What is the problem with that?