Sign in to follow this  

[D3D10] Having vertex buffers with empty space inside.

This topic is 2395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone.

I'm trying to learn Direct3D by making a simple engine, I've come across a small issue regarding deleting instances of blocks. Currently, I have two vertex buffers, one which stores the 24 vertices of a cube, and the other which stores the position of the cube with a simple D3DXVECTOR3. (There is also an index buffer for the individual cubes.)

As I have everything now, the 24 vertices and the index buffer are completely static (although each buffer is using default usage). However, I don't know how to remove instances of blocks if the instance data for that block is in the middle of the buffer. I can use UpdateSubresource to update the positions of cubes in the middle, but as far as I know I can't remove an instance which is in the middle. Is there any way to quickly and painlessly remove one of the instances without completely rebuilding the buffer? I want to handle hundreds of thousands of instances.

However, I might not end up using instances, but I still need a technique for removing vertices in the middle of a buffer. Whenever a block is removed, I'd remove the appropriate vertices from the buffer, or add them if need be. But yet again, I don't know how to deal with the empty space. Any suggestions?

Share this post


Link to post
Share on other sites
the Vertex buffer is an array of data, so unfortunately, you have to shift all of the elements down. You do not need to rebuild the buffer, but just move the data that needs to be moved. Another thing you could do is if there are only a couple of cubes that you do not want to draw, and they are inexpensive to draw, you can just change the position of the cube so it is extremely far away so it will be culled when the entire batch is instanced.

Those are your only two options really.

Share this post


Link to post
Share on other sites

This topic is 2395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this