GetIntersection BitMasking


photo

Recommended Posts

Hi

I need the Intersection to be ignored if the intersected object has a certain bit masks set to true, how would someone do this ? let's say for example I have a cube that has the collision 0 and 1 layer checked and an intersection start point is set to be the at center of that cube (inside it) and points down to check for intersection, I still want the cube to collide with the ground (using layer 0) but tell the intersection to ignore this cube if it has a certain collision masks (layer 0 & 1 ) while still intersecting with the ground which has only layer 0 checked.

 

Demonstration:

ref.png

Link to post
2 hours ago, silent said:

LouMatalka

You definitely can do it, please check the examples in Bit Masking configuration article (the principle is the same for all the bit masks):

From what I understand from the article, If two masks have at least one matching bit, the masks match. Values of other bits won't affect the result, In my case what I am trying to achieve is that if a certain mask bit is found in the intersected object, this object should be ignored regardless of other bits, can this be achieved ?

Edited by LouMatalka
Link to post

Hi, you are trying to achieve the opposite of how the masks work.

You should set a single bit for each object. Let's say MASK_GROUND (only check layer 0) for your ground objects and MASK_CUBE (only check layer 1) for the cube object.
Then, when you cast your intersection, you should use MASK_GROUND as intersection mask. This will make all objects with MASK_GROUND checked to be tested for intersection and all others will be skipped. As you didn't set MASK_GROUND for your cube, intersection cast won't check it.

When you need an intersection for both kind of objects, use MASK_GROUND | MASK_CUBE as intersection mask in cast.

If you need to skip just a certain set of nodes, you can store them in a Vector and pass it as an exclude list in World::getIntersection

Hope this helps you

Edited by javier.serrano
Link to post
45 minutes ago, javier.serrano said:

Hi, you are trying to achieve the opposite of how the masks work.

You should set a single bit for each object. Let's say MASK_GROUND (only check layer 0) for your ground objects and MASK_CUBE (only check layer 1) for the cube object.
Then, when you cast your intersection, you should use MASK_GROUND as intersection mask. This will make all objects with MASK_GROUND checked to be tested for intersection and all others will be skipped. As you didn't set MASK_GROUND for your cube, intersection cast won't check it.

When you need an intersection for both kind of objects, use MASK_GROUND | MASK_CUBE as intersection mask in cast.

If you need to skip just a certain set of nodes, you can store them in a Vector and pass it as an exclude list in World::getIntersection

Hope this helps you

I knew what I was trying to do the is the opposite of it and wanted to look for a workarounds, the execlude overload for the intersection method looks promissing and should solve my issue, I'll give it a try.

Thanks!

Edited by LouMatalka
Link to post

Hello!

LouMatalka, could you please tell us what you want to achive with Collision and Intersection masks?

If you realy need to achieve something specific, take a look at the Exclusion Mask.

Based on your original post, I also suggest you don't try to mix Collision and Intersection masks logic.

Hope this helps.

Link to post
3 hours ago, stockyspark said:

Hello!

LouMatalka, could you please tell us what you want to achive with Collision and Intersection masks?

If you realy need to achieve something specific, take a look at the Exclusion Mask.

Based on your original post, I also suggest you don't try to mix Collision and Intersection masks logic.

Hope this helps.

What I wanted to achieve was something sismilar to the exclusion mask but for world intersections, from what I've read the execlusion mask works in reverse, which is to execlude an object with certain bit mask regardless of other bits, but it seems that this is only availble for collisions and not intersections. The execlude nodes parameter in the GetIntersection method solved my issue but would prefer if I can apply execlusion mask for Intersections for performance reasons, is this available ?

Thank you.

Edited by LouMatalka
Link to post