Is it possible to get intersected part's volume?

Hello. I’m want make my own pathfinding system. For it I’m need make “Occupancy” Property, where 1 - no any air, and 0 - only air. My sistem now work to detect terrain in 2x2x2 grid.
But I stuck in 1 problem: I need count to occupancy baseparts too. Is it possible, to get intersected volume even for rotated parts?


Green - what I want find, Grey - My 2x2x2 grid, Red - part, which detected.

I’d assume this can be done with some sort of advanced mathematical calculation. I have no doubt that it’ll be much easier if you’re only working with rectangles and cubes.

Like person above said it’s not easy. You can find an answer on other sites focused on math or other languages. I think it’s called the common part.

I’m found 1 interesting thing, which called “Mass”.
So now I have 1 another question - does unioning 2-5 baseparts together during run-time will be good practice, and does this way is good, or I should find another way anyways?
What i want try to make:
I have 2 parts (in this example ball and cube)
image
Roblox have 2 properties: Mass and Density (Density can be found in custom properties, for this example I’ll use 1)
image
image

And if I union them, but with each other NEGATIVE, I’ll receive their unioned mass without intersecting:
image
image

And after this, I should substract 1 of their mass and union:
image
33.51 - 15.682 = 17.828

And checking another part of Union:
32 - 19.983 = 12.017

And, using this volumes, I can say, that ROBLOX counts Unions weight a bit weird…
So, I’ll use median mass - (17.828 + 12.017) / 2 = 14.923 cubic studs.

So, is this’s good way?