short little video demonstrating lunar's newest addition: the BVH
21 seconds, 2.43 MB
http://binarydemons.com/~strike/files/lunar_bvh_demo.wmv
framerate was capped to 30 fps due to recording the video with Fraps.
video playback is slowed to 1/4th speed on impact, then reset back to normal speed shortly after (just clarifying that slowdown is not due to game engine :P)
to put the alleged performance increase to some actual numbers:
on my computer i get approx 40 FPS with 200 objects with OLD collision method
on my computer i get approx 40 FPS with 1000 objects with NEW collision method
"wtf is a bvh?"
heres a little bit of how it works..
the easiest way to perform collision detection between objects in the game world is simply by checking each object for collision to every other object. in pseudocode, this looks like
although this is an extremely easy way to do it, it has horrible performance, because it is indiscriminate. there are a lot of pointless checks between objects that could not possibly collide; like those that are on either side of the level from each other.
a BVH (Bounding Volume Hierarchy) substantially improves performance for collision detection by only checking for collisions between objects that are more likely to collide. virtually every computer or console game you have played uses a tree structure like this to speed up collision detection and rendering; even graphics editing programs use these!
although it sounds simple in theory, "just checking for objects near each other" is pretty hard to achieve in a straightforward sense without using a horrendous double for() loop like the bad example above.
so what actually is the bvh? it is a tree structure where the root node represents a box that encapsulates every object in the game. from there it splits into two boxes that contain roughly half the game's objects each. and it keeps splitting down and down until there is just 1 box per object.
the BVH tree nodes are shown in RED in the video. brighter red boxes represent deeper tree nodes.
the BVH tree leaves are shown in YELLOW in the video and contain 1 object each.
collision bounds are expanded to represent the velocity of the object, so this works hand in hand with collision prediction (most evident by the elongated yellow boxes after the collision)
21 seconds, 2.43 MB
http://binarydemons.com/~strike/files/lunar_bvh_demo.wmv
framerate was capped to 30 fps due to recording the video with Fraps.
video playback is slowed to 1/4th speed on impact, then reset back to normal speed shortly after (just clarifying that slowdown is not due to game engine :P)
to put the alleged performance increase to some actual numbers:
on my computer i get approx 40 FPS with 200 objects with OLD collision method
on my computer i get approx 40 FPS with 1000 objects with NEW collision method
"wtf is a bvh?"
heres a little bit of how it works..
the easiest way to perform collision detection between objects in the game world is simply by checking each object for collision to every other object. in pseudocode, this looks like
Code:
for(x = 0; x < (numObjects-1); x++) for(y = (x+1); y < numObjects; y++) checkCollision( object[x], object[y] );
although this is an extremely easy way to do it, it has horrible performance, because it is indiscriminate. there are a lot of pointless checks between objects that could not possibly collide; like those that are on either side of the level from each other.
a BVH (Bounding Volume Hierarchy) substantially improves performance for collision detection by only checking for collisions between objects that are more likely to collide. virtually every computer or console game you have played uses a tree structure like this to speed up collision detection and rendering; even graphics editing programs use these!
although it sounds simple in theory, "just checking for objects near each other" is pretty hard to achieve in a straightforward sense without using a horrendous double for() loop like the bad example above.
so what actually is the bvh? it is a tree structure where the root node represents a box that encapsulates every object in the game. from there it splits into two boxes that contain roughly half the game's objects each. and it keeps splitting down and down until there is just 1 box per object.
the BVH tree nodes are shown in RED in the video. brighter red boxes represent deeper tree nodes.
the BVH tree leaves are shown in YELLOW in the video and contain 1 object each.
collision bounds are expanded to represent the velocity of the object, so this works hand in hand with collision prediction (most evident by the elongated yellow boxes after the collision)
[ B A H ]
Bad *** by nature,
Hackers by choice
Bad *** by nature,
Hackers by choice