You can see a BP with a collision box, and the grey cubes have a material function that hide the object that intersect with the BP. This BP constains a collision box and a cube, with the same size as the collision box, that creates the white material with the “distance to nearest surface” node driving the opacity to “fill the hole” that’s created, images bellow:
Material in the grey cubes:
Problems:
The problem with this approach is that it creates some glitches like this little holes, for example, that I belevie its caused by having the same distance from this points to the nearest surfaces. And this rounded corners. It would be great if the material could fill exatly the hole caused by the material function:
Does your white box has distance field enabled? If that’s the case that could explain the white spots in the middle of the surface, so make sure distance field is disabled for this mesh.
For the black spots in the corners that’s probably because the distance field resolution is too low for the kind a precision you need. You can try to increase the distance field resolution scale of your grey mesh but it’s not guaranteed to be perfect, and it will quickly increase your memory consumption.
I’m not sure if this approach could work, but what I would try, in the grey box material, is to write a 1 in the stencil buffer for the pixel that are masked out and a 0 otherwise. Now in your white box material you can read the stencil buffer and mask the pixels where the value is not 1 (you might need to set you white material as translucent for it to work though).
Thanks for the reply,
I’ll try to work with the stencil buffer, didn’t tought about that approach yet. I will be back with the results!
About the resolution, it’s exactly what you’ve said, It will never fill out perfectly. And in my box its disabled the distance field, so It’s not that!
Thanks for the help, I’ll be back soon with the results
The material for these 2 meshes is the same, and has nothing special beside the box mask as you did.
The material for the “cutter box” is fairly simple too:
Couldn’t follow, Can’t understand how you did it, I tried but It’s not working, It’s a bit late here, so maybe its just that, tomorrow I’ll try again…
Anyway, thanks for helping me !
I managed to do it. But I did had to manualy copy the mesh, you did it too, didn’t you ?
Because I don’t know anyway to copy it temporarily just to generate the intersection for the time that the mesh is being cutted, idk if could explain myself clearly, but you have any thoughts on that ?
I saw some thing about procedural meshs, but I have to look into it a little bit further…
Anyway, thanks for helping me!
I will let this topic unresolved for a day or two to see if someone have any other ideias, but if nothing appear I’ll set it resolved !
Thanks a lot again for the attention!
Yes, I do have the same mesh twice in the scene, I parented the second to the first one so they can move together. But you can automate this of course, here is 2 options I can think of right now:
For the cut objects, create a blueprint with 2 static mesh components referencing the same static mesh, and make the second one only visible when the blueprint’s bounds intersect with the cutter box bounds. But you mentioned you have a lot of meshes so it might not be an option to convert them all to Blueprints
Reverse the logic, make the cutter blueprint detects when it overlaps with an static mesh actor that need to be cut. Then activate or add a static mesh component at runtime to the cutter actor, assign the same static mesh and world transform as the cut object, and deactivate/remove the component when the overlap ends. This option might be more efficient actually
Nicee!
I’was trying to do the second option you mention, and just knowing its possible to copy at runtime and without have to create a “static mesh placeholder” manualy inside the BP its a nice news, wasn’t sure it was doable!
I’ll try this!
Thanks again!
Hey!
It worked! I can’t thank you enought for helping me with this!
With the risk of being a pain in the a… Just one thing that I don’t understand how to manage yet. So, when I destroy the component in the BP, I have to manually change something in the actor to it “understand” that It’s destroyed. Its even written that the actor should call this node itself to the component be destroyed…
I tried to call an “actor component bp” inside the actor to trigger the “destroy component” but I have to compile the code to work, i can’t understand how to destroy it…
Sending a video …
Don’t know what that I’m supposed to do here, because in runtime the actor will not be moveable or I’ll be able to compile the BP …
For the destroy component issue, it happens because you’re calling the DestroyComponent of BP_SectionBox but the component doesn’t belong to this actor. You simply need to call the DestroyComponent function of the owning actor, so it should look like that:
Oow, I’see … can’t believe I hadn’t tryied it!
You wouldn’t believe how much time I lost, and how many things I’ve tryied …
Sometimes having the context menu open doesn’t really help. Why it wouldn’t appear as an context menu option when I get it from the actor?
Anyway…
Thank you Dlingr! It was very helpfull all the way to the solution! The result was perfect!
Did changed the material from the “fill”. Because pink was just for debuging, but it was a plus being able to change the color, amazing!
Yeah I agree it’s a bit weird. I checked the source code and they configured the Object parameter to be hidden by default, so you have to deactivate the context sensitive checkbox to trick the editor to show you the full version.