diff --git a/bsp_tool/branches/respawn/titanfall.py b/bsp_tool/branches/respawn/titanfall.py index 99118ec4..1f63d02f 100644 --- a/bsp_tool/branches/respawn/titanfall.py +++ b/bsp_tool/branches/respawn/titanfall.py @@ -452,7 +452,7 @@ class GeoSet(base.Struct): # LUMP 87 (0057) primitive: List[int] # embedded Primitive? # primitive.unique_contents: int # index into UniqueContents # primitive.index: int # index into Brushes / TricollHeaders - # primitive.type: PrimitiveType # Brushes or Tricoll + # primitive.type: PrimitiveType # Brush / Tricoll __slots__ = ["straddle_group", "num_primitives", "primitive"] _format = "2HI" _bitfields = {"primitive": {"unique_contents": 8, "index": 16, "type": 8}} @@ -470,10 +470,10 @@ class Grid(base.Struct): # LUMP 85 (0055) # mins = offset * scale # maxs = (offset + count) * scale # NOTE: bounds covers Models[0] - num_straddle_groups: int # linked to geosets, objects straddling many gridcells? - base_plane_offset: int # first plane for brushes to index + num_straddle_groups: int # linked to GeoSets, for objects in multiple GridCells? + first_brush_plane: int # index of first Plane indexed by Brushes # other planes might be used by portals, unsure - __slots__ = ["scale", "offset", "count", "num_straddle_groups", "base_plane_offset"] + __slots__ = ["scale", "offset", "count", "num_straddle_groups", "first_brush_plane"] _format = "f6i" _arrays = {"offset": [*"xy"], "count": [*"xy"]} @@ -1238,11 +1238,12 @@ def get_brush_sides(bsp, brush_index: int) -> Dict[str, Any]: brush_planes.append((vector.vec3(**{axis: -1}), -min_dist)) # non-axial planes for i in range(brush.num_plane_offsets): - brush_plane_offset = brush.brush_side_offset + i - bsp.CM_BRUSH_SIDE_PLANE_OFFSETS[brush.brush_side_offset + i] - normal, distance = bsp.PLANES[bsp.CM_GRID.base_plane_offset + brush_plane_offset] + offset = brush.brush_side_offset + i + brush_plane_offset = offset - bsp.CM_BRUSH_SIDE_PLANE_OFFSETS[offset] + normal, distance = bsp.PLANES[bsp.CM_GRID.first_brush_plane + brush_plane_offset] brush_planes.append((-normal, -distance)) out["planes"] = brush_planes - # NOTE: which planes are used is likely filtered by brush side properties + # NOTE: BrushSideProperties likely eliminate some planes return out diff --git a/bsp_tool/extensions/decompile_rbsp.py b/bsp_tool/extensions/decompile_rbsp.py index e87c488b..6d55c5ac 100644 --- a/bsp_tool/extensions/decompile_rbsp.py +++ b/bsp_tool/extensions/decompile_rbsp.py @@ -77,8 +77,9 @@ def brush_valve_220(bsp, brush: titanfall.Brush, editor: str = "TrenchBroom", of # add additional planes # TODO: some brushes become invalid, might be slicing with bad bevel planes for i in range(brush.num_plane_offsets): - brush_plane_offset = brush.brush_side_offset + i - bsp.CM_BRUSH_SIDE_PLANE_OFFSETS[brush.brush_side_offset + i] - normal, distance = bsp.PLANES[bsp.CM_GRID.base_plane_offset + brush_plane_offset] + offset = brush.brush_side_offset + i + brush_plane_offset = offset - bsp.CM_BRUSH_SIDE_PLANE_OFFSETS[offset] + normal, distance = bsp.PLANES[bsp.CM_GRID.first_brush_plane + brush_plane_offset] brush_planes.append((-normal, -distance)) num_brush_sides = 6 + brush.num_plane_offsets for j in range(num_brush_sides): diff --git a/tests/branches/respawn/test_titanfall2.py b/tests/branches/respawn/test_titanfall2.py index ecdaa4b1..86f2b921 100644 --- a/tests/branches/respawn/test_titanfall2.py +++ b/tests/branches/respawn/test_titanfall2.py @@ -18,3 +18,10 @@ class TestAssumptions: @pytest.mark.parametrize("bsp", bsps.values(), ids=bsps.keys()) def test_grid_cells_count(self, bsp: RespawnBsp): assert len(bsp.CM_GRID_CELLS) == bsp.CM_GRID.count.x * bsp.CM_GRID.count.y + len(bsp.MODELS) + + +class TestMethods: + @pytest.mark.xfail(raises=AttributeError, reason="MRVN-Radiant doesn't export BrushSideTextureVectors") + @pytest.mark.parametrize("bsp", bsps.values(), ids=bsps.keys()) + def test_get_brush_sides(self, bsp: RespawnBsp): + assert len(bsp.get_brush_sides(0)) > 0