Collision Layers

BlitzMax Forums/BlitzMax Beginners Area/Collision Layers

Topdecker(Posted 2005) [#1]
I have some code where I've been using collision layers for about 200 objects, however I has thus far been using the all-layers mode.

I just turned on collision layer masks which resulted in a huge delay (like longer than a second) in screen updates. For instance, changing this:

CollideImage hex_water,xpos,ypos,0,0,1

to this:

CollideImage hex_water,xpos,ypos,0,1,1

Is when I start having problems.

Once I get about 20 images that are masked, the slow down starts to get noticable on a 2.4ghz machine with a solid video card.

Anyhow, I wanted to make sure that this was normal behavior. I had not anticipated such a noticable slow-down in performance. I can hash it out pretty easily, I think, but I just wanted to make sure that this would be normal given the number of images that I am checking at a pixel level.

Tim


Dreamora(Posted 2005) [#2]
Thats not normal. Did you put a flushmem in your mainloop and the collision layer clear command?


Topdecker(Posted 2005) [#3]
Dreamora:

flushmem was the trouble maker :)

I really appreciate the accurate response! I'm new to BlitzMax and it would have been a long while before I found the solution on my own.

Tim


Dreamora(Posted 2005) [#4]
:-)

Flushmem will be needed at least in the mainloop anyway as most commands of BlitzMax create copies when you modify anything on them.

If you use it in OO way (using :Type in declaration), flushmem will clean all unneeded instances (that aren't used anywhere anymore) for you.

if you use it in procedural way (using int handles instead of type), you will have to "delete variablename" to tell the memory management, that you want to remove it, which is done on the next flushmem call as well.


I always put my flushmem just after flip in the mainloop.