Perry Rylance

Personal & Professional blog

DataTables and REST Cache

I’ve broken my DataTables library into two parts. The server side package no longer includes any JavaScript or client side assets, and is still available on Packagist. The new client side package is available and has been refactored as an ES6 class, it’s available via NPM.

My REST Cache plugin for WordPress makes heavy use of DataTables and makes use of a DOM tree, which was my motivation for writing these two modules and my DOMDocument extension. Now that these components are fully complete, and issues relating to the initial release milestone are almost done with, I’m hopeful to release the plugin on WordPress.org within a matter of days.

I’ve found a little time to play with Payload and am please to report good progress with that project. The ES6 refactor is complete, and I believe the issues with the physics engine are solved. I’ve done a lot of work with Box2D, collision detection and response, and geometry in general, and had a hunch that degenerate triangles were causing the JavaScript port of Box2D which Payload uses to fail.

Payload is a take on a very old space artillery game which features destructible planets. Traditionally these games would use pixel bitmaps to represent the planet terrain. I wanted to move away from pixel based physics and into vector based physics as they’re more accurate and many, many more tools and libraries exist for working with vectors. I needed a way to break planets (circles) up into smaller parts so that when they’re struck, chunks can be removed giving a nice, destructible feel to the game whilst being able to take advantage of vector based physics.

The old Delaunay triangulation meshes which caused issues with Box2D.

My initial setup was a circle of vertices, or “sites”, and then random, evenly distributed points within the circles radius, which was then run through Delaunay triangulation to produce a triangular mesh for the physics engine. The idea is to allow parts of the model to be broken off without using expensive techniques like CSG. Unfortunately, it appeared that the triangulation was sometimes creating very, very small area triangles or even degenerate triangles. I used a PRNG to make seedable game worlds in order to have a means of consistently reproducing these stalls. From there I was able to add functions to test for triangles with colinear vertices or tiny areas, reject those triangles and establish that those were the cause of the stalls.

Unfortunately this makes the Delaunay triangulation approach pretty much unusable, so I’ve switched to a Voronoi set instead, which produces more consistent results in terms of polygon area.

Voronoi sets, the left is a canvas for debugging, the right is Box2D’s debug draw.

This gives much more consistent results, and so far hasn’t given me any issues. I’m somewhat busy getting the REST cache to release and learning Laravel, as well as doing a few freelance jobs, but I’m really hopeful to make some progress with this project soon. I’m considering learning Vue.js, or possibly re-visiting React. Payload would be an excellent environment in which to learn such a framework!