{"id":1054,"date":"2010-01-06T23:02:37","date_gmt":"2010-01-06T12:02:37","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=1054"},"modified":"2010-01-06T23:02:37","modified_gmt":"2010-01-06T12:02:37","slug":"today-3","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2010\/01\/06\/today-3\/","title":{"rendered":"Today"},"content":{"rendered":"

Small bugfixes today, mostly. \u00a0Biggest one was finally fixing a bug which was resulting in monsters, devs, and characters seemingly randomly not being drawn, depending on which direction the camera was facing.<\/p>\n

Turns out that I’d inserted them into the octree incorrectly, and it was treating all of them as though they were sitting at the center of the world. \u00a0If you happened to be looking roughly in that direction, then the game would draw them, regardless of where in the world they actually were. \u00a0If you were looking away from the middle of the world, it wouldn’t draw them no matter where they actually were. \u00a0This was often leading to situations where these objects would seemingly randomly pop in and out of existence, as you slowly turned the camera.<\/p>\n

(quick tech explanation: \u00a0An “octree” is a method of dividing up space, commonly used in some types of 3D video games. \u00a0The basic idea is to think of your 3D world as a big cube, with stuff inside it. \u00a0Now, mentally divide up your cube into eight smaller cubes; one in each corner of that larger cube, and all touching at the very middle. \u00a0Now mentally divide up each of those<\/em> cubes into eight more cubes. \u00a0Repeat until you’re dizzy.<\/p>\n

When you move an object around in the world, you check those cubes to find the smallest one which completely surrounds the object, and store the object inside that cube. \u00a0The benefit of doing this is that if you have (for example) 10,000 objects moving around in your world, each stored inside the smallest cube which surrounds it, you don’t actually need to draw all 10,000 objects (very expensive for the graphics card!), and you don’t have to check whether \u00a0each of the 10,000 objects can be seen by the camera and thus needs to be drawn (very expensive for the CPU!); \u00a0instead, you can just check whether the camera could see the individual cubes. \u00a0If a cube is within the camera’s field of view, then you draw all of the objects inside it. \u00a0If a cube is outside the camera’s field of view, then you know that all the objects (and other cubes!) inside that cube are also outside the camera’s field of view, and so don’t need to be drawn.<\/p>\n

2D games will sometimes use a “quadtree” approach, which is very much like this, except using squares which are each made up of four smaller squares, instead of cubes which are each made up of eight smaller cubes.)<\/p>\n","protected":false},"excerpt":{"rendered":"

Small bugfixes today, mostly. \u00a0Biggest one was finally fixing a bug which was resulting in monsters, devs, and characters seemingly randomly not being drawn, depending on which direction the camera was facing. Turns out that I’d inserted them into the octree incorrectly, and it was treating all of them as though they were sitting at…<\/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-h0","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1054"}],"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=1054"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1054\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=1054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=1054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=1054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}