{"id":1521,"date":"2010-09-06T23:49:28","date_gmt":"2010-09-06T12:49:28","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=1521"},"modified":"2010-09-06T23:49:28","modified_gmt":"2010-09-06T12:49:28","slug":"little-bits-of-speed","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2010\/09\/06\/little-bits-of-speed\/","title":{"rendered":"Little bits of speed"},"content":{"rendered":"
Not a lot of coding time today, so I just tackled a few speed issues that had arisen in the last few days.<\/p>\n
The major one is that now that full procedural objects are being baked together into a single mesh (instead of lots of individual sub-meshes), the process of optimising those super-meshes was very slow. \u00a0The worst-cast situation at the moment is undoubtedly the starting area<\/em> building, which is made up of about 600 triangles in total, or 1800 vertices, before being optimised down for rendering. \u00a0(I know, this doesn’t sound like a lot of triangles or vertices. \u00a0But due to its focus on procedural geometry, MT2 has to do a lot of model processing during runtime which other games can do outside of the game)<\/p>\n Optimising these procedural models mostly consists of checking all those generated vertices, to see if any of them are close enough together to be \u00a0merged together. \u00a0This means that for every element in the list, you need to check it against every other element in the list. \u00a0And when you have 1800 vertices, that’s an awful lot of checking. \u00a0Computer science folks call this O(n^2)<\/em>. \u00a0I just call it “really, painfully slow”. \u00a0Building that model freezes MT2 for about three seconds, on my computer.<\/p>\n What I’ve done is to add a simple cell structure to the mesh optimisation step. \u00a0Basically, imagine that the model is being built inside an 8x8x8 grid of cubes. \u00a0This way, vertices don’t have to be checked against every other vertex in the model — they only need to be checked against other vertices which are located in the same cell that they are. \u00a0This optimisation has sped up the creation of the “starting point” model from about three seconds to about half a second. \u00a0Which is still much too long, but it’s an awful lot better! \u00a0I’m going to have to think more about how to improve the speed further.<\/p>\n","protected":false},"excerpt":{"rendered":" Not a lot of coding time today, so I just tackled a few speed issues that had arisen in the last few days. The major one is that now that full procedural objects are being baked together into a single mesh (instead of lots of individual sub-meshes), the process of optimising those super-meshes was very…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[24,25],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-ox","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1521"}],"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=1521"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1521\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=1521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=1521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=1521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}