Working out of a vertex array for destrucible objects
- by bobobobo
I have diamond-shaped polygonal bullets. There are lots of them on the screen.
I did not want to create a vertex array for each, so I packed them into a single vertex array and they're all drawn at once.
| bullet1.xyz | bullet1.rgb | bullet2.xyz | bullet2.rgb
This is great for performance.. there is
struct Bullet
{
vector<Vector3f*> verts ; // pointers into the vertex buffer
} ;
This works fine, the bullets can move and do collision detection, all while having their data in one place.
Except when a bullet "dies"
Then you have to clear a slot, and pack all the bullets towards the beginning of the array.
Is this a good approach to handling lots of low poly objects? How else would you do it?