TrenchBroom / TrenchBroom

Cross-Platform Level Editor
kristianduske.com/trenchbroom
GNU General Public License v3.0
1.88k stars 224 forks source link

CSG Hollow #2069

Closed Knetic closed 6 years ago

Knetic commented 6 years ago

Most Radiants have a "Hollow" feature, which takes the current brush and builds as many brushes as required to create a hollow shell around the volume it occupied - so a solid square brush becomes a hollow cube occupying the same area.

This is an equivalent operation to copying a brush, scaling it down by some uniform factor, then CSG subtracting it from the original brush. But since #871 is not yet complete, it's exceedingly difficult to hollow brushes with more than a few faces. And in general I think most people used to GTKRadiant or MOHRadiant or q3radiant would be used to having this feature.

If multiple brushes are selected, the operation just hollows each one individually (doesn't try to find some greater hull to hollow).

Hotkey could be H, menu item under "Edit->CSG".

I'm willing to do the work for this, it's not a crazy operation, but want to raise the issue first to make sure this wasn't an intentional omission.

kduske commented 6 years ago

That sounds like a useful addition, yes. I appreciate any contributions.

Knetic commented 6 years ago

I admit that i wasn't entirely prepared for the level of templating and complexity of the code, the most I was able to do was in the View classes and associated calls to a "csgHollow" method in Brush, but i admit that it's not at all clear to me how to properly modify the geometry of a brush - there's a lot of functionality there. I'm not able to meaningfully contribute like i expected :disappointed: I left my changes in a forked branch; if it helps anyone.

https://github.com/Knetic/TrenchBroom/tree/feature/2069

kduske commented 6 years ago

@Knetic that's okay, the code is indeed complicated because it has grown over a long time. I'll have a look at this feature at some point in the future.

ericwa commented 6 years ago

What makes more sense, shrinking the reference brush an then subtracting, or growing and then subtracting?

I think it'd be more useful to grow and then subtract; i.e. if you start with a 128x128x128 brush, that would be the size of the hollow area after using this command. Radiant does it the other way though (shrinks by 1 grid increment, then subtract).

kduske commented 6 years ago

There are good arguments for and against both. I don't think it matters too much, but grow then subtract might be a tad more useful because you can apply the textures from the outside of the brush to the inside of the hollowed section as is.

Knetic commented 6 years ago

The Radiant way (copy-shrink-subtract) makes it much easier to get results you'd expect.

It doesn't alter the dimensions of your shape, just converts it to a hollow shell. Any textures you applied to the faces of that brush stay in exactly the same place and size, visually, as when you applied them. And because the "walls" are in exactly the same places, you don't need to worry about how the "footprint" of the hollowed brush will end up. You simply block-out your level, and hollow the parts you want to be hollow - which doesn't change the shape or appearance of your level - just makes the hollowed parts hollow.

To put it in workflow terms, shrink-subtract follows the principle of least surprise - it's the same "brush", with all the same visual and spatial properties, just hollow.

ericwa commented 6 years ago

Added in 1a77f764134cc988b40eb854daca1499a5c0d3ad