Thursday, 31 December 2015

Stop recycling game objects

Many consider object pools a staple of game development. Here's a few examples:

Although Wikipedia does hint at potential pitfalls, there is a much greater problem than having (or forgetting) to reset pooled objects: how do you ensure that references to your objects are cleared before pooling them?

Your object may have registered to receive events.
Or it may be added to a list somewhere.
Or it may be assigned to a field in about a couple dozen places
...
Yes, there are possibly hundreds of objects in your runtime which may hold references to an object you'd like to recycle.

In languages like C++, it is your responsibility to clear these references. Not clearing references before destroying an object leads to wild pointers. Wild pointers lead to intermittent crashes and bugs.

In C#, Unwanted references to pooled objects fail subtly: your application won't crash but a (usually unknown) number of objects will continue to talk to your object without knowing that it's been recycled.

Pooling is an optimisation technique. If you have to use it, know that just resetting these objects is the easy part.

Tuesday, 29 December 2015

Visualising C++ #1 - A quick look at Visual Paradigm

I've been wanting to visualise one of the C++ projects I'm working on for a while. First I tried Visual Paradigm

Surprisingly, VP choked on irrelevant files ( git meta, makefiles, ... ). At the time of writing (Dec. 2015) their help-desk confirmed practical limitations in this area.

Anyways. I somehow got rid of the gits then processed caffe through the so-called 'instant reverse' feature. Selected all output and generated a diagram. Output didn't look great. Here is a second attempt displaying only the 'caffe' namespace:



Not excluding the possibility that this can be configured to produce decent output.