<\/a>Short post today.\u00a0 After the latest round of profiling, I’ve tracked down a few more performance problems and squashed them.<\/p>\nThe screenshot is looking across a single MMO region, peppered with 1000 trees.\u00a0 1000, because it’s a silly number of objects.\u00a0 Trees, because they’re by far the most expensive model in the game right now.\u00a0 The screenshot was taken on my almost-five-year-old laptop, and with all these trees being rendered, it’s still holding 30fps.\u00a0 So I call that a victory.<\/p>\n
There were two big slow bits to fix:<\/p>\n
First, the material batching system was using templated container classes to store its batching information, and wrangling that data via the template implementation was much slower than it needed to be.\u00a0 I switched to a hardcoded linked list implementation, and performance improved a lot.<\/p>\n
But far bigger than that was the expense of collision testing.\u00a0 Previously, every object in the region was being tested for collisions — both for the GraveShip and also for the user’s cursor.\u00a0 With a thousand highly complicated tree models in the scene, that’s a lot of ray-vs-triangle testing.\u00a0 So I’ve modified the collision testing to be performed using the region’s quadtree, so only the objects which are vaguely along the path being tested will actually do polygon-level collision checking.\u00a0 So even in this absurdly busy scene, collision testing doesn’t show up at all in the profiling any more.<\/p>\n
There’s still a little more that I could do.\u00a0 For the most part, level placements (such as trees, buildings, etc) don’t move around, and so I could merge them together when they’re not being moved.\u00a0 That might make a big difference.\u00a0 Or it might not.<\/p>\n
I’ve also played with doing level-of-detail calculations on the terrain, but reducing the number of terrain triangles doesn’t seem to actually lead to a faster render time.\u00a0 I’d really like to get the frame rate up to 60 on this old laptop, but I’m happy enough with a solid 30 that maybe it’s not worth really fussing over too much.<\/p>\n","protected":false},"excerpt":{"rendered":"
Short post today.\u00a0 After the latest round of profiling, I’ve tracked down a few more performance problems and squashed them. The screenshot is looking across a single MMO region, peppered with 1000 trees.\u00a0 1000, because it’s a silly number of objects.\u00a0 Trees, because they’re by far the most expensive model in the game right now.\u00a0…<\/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,3],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-CO","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/2406"}],"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=2406"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/2406\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=2406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=2406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=2406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}