Jump to content
  • Advertisement
Sign in to follow this  
paul23

Better container

This topic is 2915 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,

I was building a "collision" system for my 2d game today... However I notice it's very inefficient.

What I do is create a dynamic bitset (using boost dynamic_bitset).. Of size w*h. (or actually I create a class which has this bitset..). The slow part however are the things I do with the set: I do a lot of "copying a part" (ie cell 2,2 to 4,5).. And adding these parts to other maps (and comparing etc).

The problem is that I'm doing this is an inefficient matter (I think), for each "subset" I use a double for-loop to loop through all cells.. And check them 1-by-1.

Isn't there a faster way? - Maybe using a better container so I can copy, compare & add these sub-sets in a faster way? - Without doing a manual copy of the bitset for each operation?

Share this post


Link to post
Share on other sites
Advertisement
Step back - you're micro optimising.

I assume this is pixel perfect collision detection? Are you doing any high-level culling to reject collisions early if objects are not overlapping? What about spatial partioning?

Quote:

However I notice it's very inefficient.

How are you measuring this?

Share this post


Link to post
Share on other sites
Well the class itself is dependent for checking wether a collision is possible (it does a basic rectangle check). And yes it's for pixel perfect collisions..

As for noticing: well it's a feeling.. I'm just feeling like "this isn't right, this can't be the best way to solve this problem". I'm having a bitstream which represents a number, then there ought to be ways to get a sub-stream with a "simple" (for a computer, I myself am not able to make it hence I'm asking here) calculation.

Especially since I want to use this "map" for a destructable terrain (and thus have to be able to "remove" parts of the grid).

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!