Reducing map brush sides via brush shape manipulation

Discussion in 'Tutorials & Resources' started by worMatty, Oct 5, 2015.

  1. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,072
    Positive Ratings:
    836
    Hi, folks.

    I recently found some useful information about brushes and the way Hammer treats them when it compiles. Have you ever received the MAX_MAP_BRUSHSIDES error because you have too many brushes?

    Taken from the page on MAX_MAP_BRUSHSIDES on the Source wiki:
    Imagine a brush is like a prop in that it has an invisible bounding box. I don't know if this is actually the case or if it's a learning aid. It's probably something to do with the way the engine works.

    Basically, if a brush face isn't parallel with any grid line, i.e. it's diagonal, it can cause the brush to take on one extra 'brush side' in the form of a bounding box side. If a face is parallel, then that side of the bounding box will be merged in to the face.

    Here are some examples. The blue shape is the brush, and the green shape is a representation of the brush's bounding box. Bear in mind the numbers below the image also reflect the 3D faces that this 2D image doesn't show, those being the brush faces on the back and front.

    [​IMG]

    Where a brush side isn't taken up by a parallel face of any length, the bounding box side will count towards the total.
    1. 6x brush faces, 0x bounding box sides = 6 total brush sides.
    2. 5x brush faces, 2x bounding box sides (right and top) = 7 total brush sides.
    3. 6x brush faces, 4x bounding box sides (all four sides) = 10 total brush sides.
    4. 6x brush faces, 1x bounding box sides (top) = 7 total brush sides.
    5. 7x brush faces, 0x bounding box sides = 7 total brush sides.
    The right face of number 4 is parallel with the grid, but it doesn't completely cover the bounding box side. Still, these two are merged. Only the top bounding box side is counted as there is no parallel section of face to merge with. The same goes with shape 5. The top and right face aren't the whole length of the brush but they are parallel so they get merged.

    In the following image I didn't work out the total brush sides manually. I compiled an empty, cordoned map with a single point entity and the compile log showed 36 brush sides. I then compiled the map with each of these constructions in turn and subtracted 36 from the reported number of brush sides in each compile log. The numbers below the image should be the accurate number of brush sides for each construction.

    [​IMG]
    1. 146 total brush sides.
    2. 143 total brush sides.
    3. 112 total brush sides.
    Making the segments of the third arch construction as square as possible merged their parallel faces with their bounding box sides, significantly reducing the number of total brush sides the construction generated.

    This doesn't stop with complex brushwork. If you have been using the vertex editing tool to 'mitre' the corners of brushes so they meet up nicely, that will generate one extra brush side per non-parallel, diagonal face. It sounds minor, but it could rack up. Consider the pros and cons.

    [​IMG]
    1. 14 brush sides.
    2. 12 brush sides.
    Apologies if I have missed anything out or stated something so obvious that it warrants abuse. If I've made some mistakes, or you have a better idea, or some great examples of ways to cut down brush sides, please post them in response.

    Thanks,

    Matty
     
    • Thanks Thanks x 19
    Last edited: Oct 5, 2015
  2. puxorb

    aa puxorb L69: Emoticon

    Messages:
    459
    Positive Ratings:
    664
    For the arches, valve always seems to use method 1. I guess it makes sense since you only have to texture 4 faces if you texture the outside of the arch.
     
  3. tyler

    aa tyler snail prince, master of a ruined tower

    Messages:
    5,035
    Positive Ratings:
    4,499
  4. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,377
    Holy crap. When we get around to making a proper tutorials section on the mainsite, we need to devote at least one article to just listing out little-known tricks like this.
     
    • Thanks Thanks x 1