Jump to content
  • Advertisement
Sign in to follow this  
KScorp

[D3D10] Having vertex buffers with empty space inside.

This topic is 2615 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
Advertisement
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
I see, moving the data sounds much faster than rebuilding, I'll have to try that. Thanks for the reply.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!