Detecting if model or collection of model is air tight

Hi,

I’m trying to simulate a boat and I’d like to detect if my model is air tight (which will then affect the bouyancy values).

I have no trouble with the bouyancy, or the depth mask etc. My only issue is detecting whether there are any leaks in the both.

My first idea was to raycast in many directions over a number of seconds to calculate if any of those hit the water first but in my mind it seems a little over kill as a large boat may require 100-300 raycasts.

Then I was thinking about lighting and how it is able to detect which faces should receive light based on the normals and how they are facing.

Is there some way I can leverage off of this, perhaps I can shoot a light in 3 directions, from each side and the bottom then detect the normals of all faces and see if I can see faces that I shouldn’t be able to (like the other side of the boat as if I’m peering through a hole)??

*** EDITED:

Now my head is thinking of filling the hull with adjacent cubes and detecting collisions… I’m sure my head is in the right spot I just don’t have the mathematical knowledge to figure this out.

Any ideas?

the light wouldn’t help you as you can’t use the data (they only exist in the shader and hardware), also its not really lightweight either.

easiest is that you store a list of whenever you made a hole into your boat, because I don’t think they start out with holes so you made them someone :slight_smile:

Thanks for the reply.

Unfortunately the main goal of my game is to build the boat using planks of wood.

I don’t care if the boat has tiny gaps or holes I’m just worried about the large gaping holes. Is there a solution using the raycasting option?

assuming that they can’t change it all the time, easiest will be to put the boat into an all white environment, color the boat all black, use a camera in 1+ positions within the boat middle axis and capture cubemaps and then use this to find out if you find white thats enclosed by black

with raycasts you can do it too, just move through from front to back and cast rays.

as you likely only need to do it once, the time required should be rather unimportant (if 1s or 2s), as you can stealth it behind some “shit being constructed” sequence or alike.

I’ve gone down the road of raycasting but spreading it over a number of seconds and I only start the routine when the model has detected an attack powerful enough to create a hole.