Determine if brick is completely covered

Author Topic: Determine if brick is completely covered  (Read 1825 times)

Does anyone know a way to determine if a brick is completely covered? The solution should not use raycasts.

Just spitballing here, but if it were me I’d try a box container search to get everything covering the brick, getting the world box of those bricks, and trying to calculate how much surface area they cover vs the surface area required to cover the brick

bl only does coverage client sided. If you need a server side solution you'll have to do it all manually (box search around the brick, test whether bricks are covering a face, sum up covered area for each direction, compare with size of brick)

I imagine that'll be quite slow if implemented in torkscript.

That's not what I wanted to hear. Thanks though.

I'm guessing even if it's a local server, the client checking if a brick is hidden wouldn't be available to the server bits?

i would NOT rely on brick coverage cause many bricks do not properly add coverage data in their .blb and thus would not be considered "covering" a side even if they actually do.

Okay, not a major problem. It would just have made something more efficient.

bl only does coverage client sided
what if there was a way to send that data to the server

what if there was a way to send that data to the server

You could make that easily (coverage results can be accessed using getExposedAreaBottom() etc for each direction), but that would rely on having a client connected that has successfully ghosted the brick and all bricks around it, and is finished with that stupid white fade animation. Depending on how this is going to be used, that might not be possible.

Good idea but unfortunately this needs to work on dedicated servers without a client being involved.

This is what I ended up doing:

Code: [Select]
function FxDtsBrick::isCovered(%this)
{
%area = %this.getDatablock().topArea / 4;
%box = %this.getWorldBox();
%covered = 0;
%xLow = getWord(%box, 0);
%yLow = getWord(%box, 1);
%xHigh = getWord(%box, 3);
%yHigh = getWord(%box, 4);
for(%i = %this.getNumUpBricks() - 1; %i >= 0; %i --)
{
%b = %this.getUpBrick(%i).getWorldBox();
%overlapX = getMax(0, getMin(%xHigh, getWord(%b, 3)) - getMax(%xLow, getWord(%b, 0)));
%overlapY = getMax(0, getMin(%yHigh, getWord(%b, 4)) - getMax(%yLow, getWord(%b, 1)));
%covered += %overlapX * %overlapY;
}
return %covered >= %area;
}