{"id":519,"date":"2009-05-24T13:51:55","date_gmt":"2009-05-24T03:51:55","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=519"},"modified":"2009-05-24T15:57:59","modified_gmt":"2009-05-24T05:57:59","slug":"tinkering-under-the-hood","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2009\/05\/24\/tinkering-under-the-hood\/","title":{"rendered":"Tinkering Under the Hood"},"content":{"rendered":"

Apologies; the following post is kind of technical.\u00a0 Those who are uninterested in this sort of fiddly technical stuff can safely ignore this post;\u00a0 it contains nothing at all relevant to game design.\u00a0 :)<\/p>\n

A bunch of work under the hood of the VectorStorm engine, the past few days.\u00a0 It’s mostly invisible from game code, but produces better performance in general.<\/p>\n

The first big change is that I’ve created a “vsCache” class, which can handle any sort of named, reference-counted game resource (textures, files, etc).\u00a0 It’s trivial to create these for anything you might want to keep cached or otherwise reference-counted.\u00a0 I’ve reworked both the “vsTexture” and “vsMaterial” systems to use the vsCache system.\u00a0 The system is, generally, invisible from the game code;\u00a0 you still create “vsTexture” and “vsMaterial” objects from code exactly as before, but now these objects look in the cache for existing data that they can piggy-back on top of, instead of always using up extra memory for something that might be a duplicate.\u00a0 This basically means that if you create sixteen identical vsMaterials, you’re not actually storing sixteen copies of the data any more, but only one.<\/p>\n

Building on with that change, materials can now be loaded from text data files.\u00a0 To do that, you just create a vsMaterial, passing in the filename from which to load the material definition.\u00a0 Again, if that file has already been loaded into the cache, the engine won’t actually load the file, but will use the one which had previously been loaded.<\/p>\n

Finally, materials now compile themselves into OpenGL display lists, which really speeds up the process of changing from one material to another while rendering the scene.\u00a0 (Still TODO<\/em> is to consider trying to make the engine automatically batch materials together, so we don’t have to keep switching back and forth between materials.\u00a0 With the number of polygons I’m pushing through with each material right now, this would probably be a lot more work than it’s worth, so I’m not going to do it unless something easy occurs to me)<\/p>\n

I’ve also fixed a couple of engine bugs.\u00a0 One annoying bug in particular involved how the file reading classes parsed unquoted strings, which caused some strings to vanish entirely before the game code had a chance to see them.\u00a0 I’ve fixed this bug in each “Game in a Week” game since Robot Finds Ice Cream<\/em>, and keep forgetting to migrate the fix back into the core VectorStorm engine code.\u00a0 I’ll remember this time, I promise!<\/p>\n

I’ve also added some facilities to make sure that singletons created by engine code are accessible by game code.\u00a0 All I’ll say here is that the C++ standards are basically non-existant about how static templated data should work when statically linking libraries together (and this has caused problems for me in optimised OS X builds, in particular)..\u00a0 so by pairing a hash table with RTTI information, I’ve created a mechanism to make the code do what I want it to, without relying on a particular behaviour from the compiler.\u00a0 (This was a critical fix, in order to get the vsCaches working)<\/p>\n

I’ve also fixed an infinite loop bug in the vsHashTable, if there was a hash table collision.\u00a0 Silly bug, I’d overlooked it before just because I’ve never plugged enough data into one of these to make a collision happen, until now.\u00a0 And to my knowledge, nobody’s actually played with that before;\u00a0 it was just something I’d put together months ago while working on localisation support, which kind of fell by the wayside once the basics were implemented.<\/p>\n

These engine upgrades and bug fixes are all in the MMORPG 2.0 codebase now;\u00a0 they have not yet been ported back into the public VectorStorm engine repository.\u00a0 But I’ll get to that within the next few weeks (once I’m really confident with them).<\/p>\n

Also, I currently have about five essays about game design half-written.\u00a0 I should really finish one or more of those, so I can stop boring people with these painfully technical code updates.<\/p>\n","protected":false},"excerpt":{"rendered":"

Apologies; the following post is kind of technical.\u00a0 Those who are uninterested in this sort of fiddly technical stuff can safely ignore this post;\u00a0 it contains nothing at all relevant to game design.\u00a0 :) A bunch of work under the hood of the VectorStorm engine, the past few days.\u00a0 It’s mostly invisible from game code,…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[4,3],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-8n","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/519"}],"collection":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/comments?post=519"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/519\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}