Demo: Green Dragon

Articles with the tag: Optimisation

Framework: checking memory leaks with Valgrind

Profiling with Valgrind memcheck and gprof to check for memory leaks and performance problems. Could things be sped up by not using so much C++ standard library things (which I used copiously for educational purposes, instead of clobbering everything together in C)? One mustn't assume so, sez Stroustrup - testing is needed.

Loading could be drastically improved by saving JSON and COLLADA model formats in a form suitable for my game environment. The vertex indexer currently involves a triple-nested for-loop!

[29/06/14 23:13]

All the valgrind warnings are gone apart from one about the OpenGL library. That can't be my fault, right?

Read More »

IK solver: Bézier curve method

B-spline IK method outline

Make a B-spline (a composition of Bézier curves) of length equal to armature length. Place bones at lengths down the spline. Blender offers it as an option and the Blender documentation suggests it as being apt for organic bone structures such as spines. It would work well for my demo dragon character's long neck.

Definition of a parameterised curve in the 3D environment:
p = P(s) where p is 3D point in space where the curve lies at that distance, s.

Of course the bone distance would be defined by short jumps, not curved distances (it is discrete). It would seem that it is more complicated to map it to the continuous curve function, then, unless the curve can be discretised too.

Armature curve-following method outline

If each bone's reach can be thought of as being contained within a sphere of a certain radius ...

Read More »

Performance profiling

CPU is taking up 100%. Profiling.

[28/03/14 15:42]

Used gprof to profile function call times.

The game loop runs at a maximum 60 hz to prevent overloading the CPU, but it still checks whether or not the time is correct as fast as it can, as shown by the code:

while (true)
    new_time = glfwGetTime();

    if (new_time - last_time >= (1.0 / 60.0))
        // Update, Render...

The checking and conditional for the correct time must be integrated in the 60 hz loop.

Bool flags might be a less taxing option.

Using bool flag method:
Function time: 190 ms or 30 ms...
Using old method:
1.5 seconds.

Well it's better, but it cuts the FPS by a tiny amount which might lead to syncing problems in the future.

[28/03/14 16:09]

Changing conditional's predicate (1.0 / 60.0) to a pre-calculated variable shows that it was ...

Read More »

Read More »

Framework development: Composition versus Inheritance

Speed of calls

Tutorial framework's SceneNode object inherits from Mesh, Texture and other objects. This intuitively seems like a bad idea as one has to make sure different classes don't share member names.

It should speed things up, though, as it doesn't have to make pointer calls to owned Material object.

Solution: elements contain local non-pointer Material object member and copy the passed Material's data.


This can then be called from inside the game loop for real-time material changes.

This does make objects larger, however, whereas before they would simply contain a reference to the same material object and could be all changed by changing the material. This way they'd all have to be set individually.

Composition versus Inheritance

Apparently inheritance of implementation-only things is bad, and composition should be used.

i.e. TestWorld invokes GameEngine object. Is this composition, and is ...

Read More »

Page 1 / 1