project-navigation
Personal tools

Author Topic: [RADIANT] CSG subtract [Shift+U] operation could generate better geometry  (Read 7867 times)

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
I'm not sure if it should be discussed here or in the "mapping" forum, but "coding" looks more likely. So, here goes:

Today I have tried to create playground for testing transparencies (there are not much of them in game), and immediately stumbled upon a problem with CSG subtract. Cutting holes with simple (box) brushes results in more or less editable geometry, but that's not true for more complex shapes.
For example, cutting a box with cone results in multiple narrow, odd-shaped "splinter" brushes, some with a very low volume. Such geometry is very hard (sometimes outright impossible) to edit, and ufo2map doesn't like it very much, complaining about microbrushes. I've even got wrong ufo2map output (polygons where they should not be) in a relatively simple case.

All of that happens because Radiant takes the simples approach possible -- it just (recursively) cuts brush A with all planes of brush B, slicing out wedge-shaped brushes with all cuts but first and last.
That's not the only method possible: brush A could be cut some other way, generating more editable and generally safe geometry. One of them, which I like the most, is to cut brush A into pyramids based on the brush B sides. For a 2D example, look at the attached drawing.

Opinions?

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: [RADIANT] CSG subtract [Shift+U] operation could generate better geometry
« Reply #1 on: February 24, 2011, 04:55:11 pm »
You probably won't like my answer, but it would be to not use CSG subtract. You're right, it leads to all sorts of bad brushwork that looks bad at best and causes errors at worst.

In most cases, you're better off constructing the geometry manually. It's a pain, but it's good that you're paying close attention to the brushwork. It is something most mappers don't worry much about but it is important for good performance and avoiding errors.

btw, I also named my map for testing things "playground". :)

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: [RADIANT] CSG subtract [Shift+U] operation could generate better geometry
« Reply #2 on: February 24, 2011, 05:16:49 pm »
Looks like some explanations are needed :)
I'm working on project as programmer, not a mapper. Those maps are just rendering engine tests, nothing more. And I've never used Radiant before :)

So, for me it's just a piece of math that could be done better.

edit:

On the second thought, I should have posted to the mapping forum! In fact, what I want to know is: do mappers want that change, to be able to create concave objects in quick and and more safe way, or that's not needed?
« Last Edit: February 24, 2011, 07:08:56 pm by Sandro »

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: [RADIANT] CSG subtract [Shift+U] operation could generate better geometry
« Reply #3 on: February 24, 2011, 09:19:39 pm »
that would be quite cool - i'm doing this in my maps by hand

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: [RADIANT] CSG subtract [Shift+U] operation could generate better geometry
« Reply #4 on: February 26, 2011, 04:35:52 pm »
btw. there is also a todo list for uforadiant - it might not be 100% up-to-date though: http://ufoai.ninex.info/wiki/index.php/TODO/UFORadiant

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Finally done something that could be released. New CSG subtract is in the master as 36011dc324793d8b64cd5d4d72c28c2c45de39b8
Not all problems fixed, but I managed to compile and play map having a box brush which was cut 15 times with a 10-sided sphere buried to the different depths, a feat almost impossible with previous version. And map had all its geometry correct in game.
Geometry is still broken sometimes when doing a multiple overlapped cuts, but fixing that will require major changes to the Radiant computational geometry engine (as much as I understand it), so -- nothing on that, sorry.

Mattn, Radiant code base is much bigger than I beleived it to be, and is very different from the game one. Looks like trying to work on both of them will be biting much more than I can chew. Means -- no more Radiant patches from me. :(
Will work on the game only.
« Last Edit: March 03, 2011, 09:27:25 pm by Mattn »

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Thanks a lot for that patch. I will give it a try asap.

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Very cool! Thanks for the contribution Sandro.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
i've just tested it a little bit - and sorry to say that - noticed a problem

the cuts are not grid aligned (the big red cross)

the thinner red crosses mark the places where the brush should be splitted to reduce the facecount - it would be a nice addon.
« Last Edit: March 03, 2011, 09:28:06 pm by Mattn »

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
First, just to clarify things: cuts are not always grid aligned by new method. This is the artifact of a chosen cutter brush (cube, as it seems).

Of course, this problem exists. Brush subtraction could result in much simpler shapes, and could snap the split planes to exising edges. But this new algorithm can't do that: it designed so all split planes intersect at a single point (shared apex of all pyramids victim brush being cut into). So, the only variation possible with this algo is to move apex point to the position where most splits will pass through the existing edges (or vertices at least).

Mattn, improving the algorithm to what you are asking for will require a major rewrite, changing it's nature. Definitely possible, but will require about 10x of work compared to the current version. I think, it will be better if my project newbie enthusiasm ;D will be directed to the renderer -- which definitely requires a lot of improvement to meet modern standards. Not to mention the bugfixes.
After all, the renderer is what player sees -- not the Radiant.

On the other hand, it is possible to reintroduce old behaviour as a configuration choice. Looks like it does pretty axis-aligned cuts with boxes, and that could be useful. Just fix the code to avoid insane geometry -- original subtract tool was able to create something really bizarre, like 17-faced cube (of which, 9 faces are invisible, and 3 faces are coincident). No wonder ufo2map had problems handling map made with CSG subtract.

Even more, it is possible to do the hybrid tool, which retains the old behaviour for axis-aligned faces, but uses pyramid cutter for all other. Could be a 3rd configuration choice.

These two are very simple'n'easy, and I'm willing to do them if someone makes the configuration and UI code. In case they are requested, of course :)

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Quote
...Definitely possible, but will require about 10x of work compared to the current version. I think, it will be better if my project newbie enthusiasm Grin will be directed to the renderer -- which definitely requires a lot of improvement to meet modern standards. Not to mention the bugfixes.
After all, the renderer is what player sees -- not the Radiant.

definitely. i will do the radiant stuff. we are glad that we finally have a coder for the renderer - and i don't wanna stop your enthusiasm ;)