Games [Tool] Collision Bits and Masks Calculator - Collision filtering

Gunther

Active Member
Licensed User
Longtime User
Here is an Exeltool which calculates the Masks according to the categories to which the single category shall collide.

Add your description in column A and put a '1' where the category should collide with.
Transfer the Category Bit and the Mask to the Tile properties or the programmed version:
B4X:
Fire.Body.FirstFixture.SetFilterBits( 16, 65527 )
And according to (the Box2D Manual):
B4X:
bool collide = (filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0;

For a collision to happen: (FixtureA.MaskBits & FixtureB.CategoryBits) <> 0 AND (FixtureA.CategoryBits & FixtureB.MaskBits) <> 0

So, when you fill it then start from the left to right until you reach the yellow cell, then go down. The upper triagle will be changed automatically.

The Sheet is password protected with an empty password just to save it from an intentionally changement of the formulars behind.

upload_2019-3-3_17-15-51.png
 

Attachments

  • Collision Bits and Masks Calculator.zip
    10.6 KB · Views: 532
Last edited:

Gunther

Active Member
Licensed User
Longtime User
May be you could add something similar to the IDE->Extras->Collision Filter Calculator? As you have it for Icon Picker and Color Picker.
I know I should add this to the wish section.:(
 

ilan

Expert
Licensed User
Longtime User
very nice @Gunther. i like your excel file. i still try to figure out how you wrote the text in a diagonal direction :confused:

btw, there are more details that should be mentioned according to collision and bodies in box2d (xui2d)

1, if you can, use always simple bodies. at the end, box2d is just a calculation library so as much the body is simple as less calculation it will need. simple bodies (rect, circle)
2, walls, ground, and bodies that should not be moved should be static bodies. you could use kinematic bodies without setting velocity to it BUT static bodies use much fewer calculations. this will make your game using less the processor and make it faster.
3, if you move a body very fast it can happen that no collision is detected so you need to set the body .isbullet property to true but don't do it on each body only on bodies that move very fast.

if i will remember more points i will put them here. :)
 
Top