Skip to main content

Animation bottleneck and map rewrites.

I recently found a bottleneck that was causing some slowdown in the game. I've been using a single flexible rig for humanoids which incorporates 2 arms, 2 legs (with extra back cantered versions), a tail, two possible head locations, hair, antennas, a cape, weapons hooks including animated bow, a helmet hook so helmets can be removed during a cut scene or special animation if needed as well as wings.

This is a very flexible rig, but it has a problem. Multiple inverse kinematics solvers, multiple copy rotation and location constraints and lots of redundant bones when used for most types of agent. For example bird men have wings and back cantered legs and use the lower head bones, but they don't use hair or capes. One the other hand humans use hair and capes, but not wings or tails.

The humanoid armature.

With all those extra bones and constraints to calculate, animation time was double what it should be. Once you start adding a lot of enemies to the scene (more than 4) it results in a serious slowdown.

The solution is simple, duplicate the rig in to two rigs, then go through and prune the bones which are redundant in each case. The two rigs can continue to share the same animations, bones that don't exist a simply not calculated. The result is a noticeable improvement in frame rate under stress conditions.


The two armature types.

I will keep the armatures combined for now. There are several extra animations to do for the game yet which can be shared as long as the rigs are combined. Once I split the rigs it becomes much more difficult for them to share an animation, which can increase my workload. Near to release I'll go a head and split the rigs to get the speed improvement.

In other news I'm reworking my map generation to make use of BSP trees, but keeping the tunneling corridors. I'm also adding a extra style of map which will use 4x4 rooms rather than the current 10x10 rooms. When generating a level the game will decide whether to use type A or type B rooms and will go on from there. The result will be two very different styles of dungeon. I already included flexibility about tile size in the dungeon generation and placement code when i was first writing it, so implementation shouldn't be too painful.

 The new 4x4 tile room prefabs.

I'm considering keeping my old style "brute force" placement of rooms algorithm to be used as an occasional alternative to the BSP one. It does generate some interesting sparse tunnel like layouts, but I think I can get a similar result for tweaking the BPS generation to have more pruned branches. It would be better to have one flexible algorithm than two fixed ones.


Comments

Popular posts from this blog

Advice needed on tilesets...

I need some advice on which is the best way to handle building the dungeon. Right now I'm using prefabs for my dungeon, they have a north south east and west section for each "room": The basic tileset. This has several advantages, and also several disadvantages. Firstly I can have curved rooms, I can have tunnels and other interesting shapes. The tilesets can look quite nice with a little work. On the other hand I can't easily get the navigation data before building the map and once the map has been built I can't make changes to the layout, like having active pit traps or believable secret doors. Although the rooms are interesting, they are quite repetitive, and it takes a lot of effort to make even a few different variations. Also rooms are constrained to one size. A newer version of the tileset with a lot of variant parts for making more interesting rooms. To create a tile set is a real headache too. Planning how to lay out the UVs, trying to cra...

Upstairs / Downstairs.

I've decided to make my prefabs multilevel. Later this should allow me to add pit traps and other great stuff. It also makes it easier to line up stairs so that you can exit them on the same co-ordinates where you entered them. The prefab editor is pretty much finished, it just needs some code for loading up prefabs from a saved dictionary, so that they can be checked or edited. The entries will need to be forwards compatible, so I'll be loading each tile and then translating the indexes to a new array, that way if I add extra indexes or extra info (like traps or puzzles) I'll be able to update existing prefabs to work with the new standard. Click for a video.

Video Diary 8

Things are moving along well, there's been a lot of progress on the action manager side of things. Actions have finally moved to the UI, so you can initiate actions by clicking the appropriate button. I've set up some dummy actions to show what happens visually when actions are taken, but the actual dice rolls and such are yet to be integrated. The UI objects are also being added, though some are non functional or empty at the moment. Click on the image to see this week's development video. Every time I add something big I also add about a dozen small things. Like the selection box visualization. Previously this was using render.drawline, and old fashioned Blender function which can be impossible to see at certain resolutions, or at certain frequencies. I replaced it with a function that adds planes of the right size and scale in the right location. I also made all characters a little bigger. I still need to do some work with vectors and final target locations t...