Skip to content

Commit

Permalink
Auto-patch tools/toolsinvisible to allow light to pass through.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Sep 30, 2024
1 parent 06beb03 commit 5134ae6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* #4431: Fix monitors not showing the voiceline character.
* #4431: Fix elevator videos not appearing.
* Fix initial state for "variant" dropdown boxes on item properties pane.
* Automatically patch `tools/toolsinvisible` to allow light to pass through.

### UCP-Relevant changes:
* Add `SweepTrace` mode to `Collisions` result. This allows creating collisions
Expand Down
21 changes: 20 additions & 1 deletion src/vrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
import sys


from srctools import Vec
from srctools.bsp import BSP, BSP_LUMPS
from srctools.filesys import RawFileSystem, ZipFileSystem, FileSystem
from srctools.packlist import PackList
Expand All @@ -29,6 +29,18 @@

LOGGER = get_logger()

TEX_INVISIBLE_TOOLS = 'tools/toolsinvisible'
TEX_INVISIBLE_PATCHED = 'bee2/invisible_noportal'


def swap_material(bsp: BSP, src: str, dest: str) -> None:
"""Swap material in the BSP, skipping if not present."""
for info in bsp.texinfo:
if info.mat == src:
LOGGER.info('Swapping to {} for {}', dest, info)
# These are tools mats, details don't matter.
info.set(bsp, dest, Vec(0.5, 0.5, 0.5), 1, 1)


def load_transforms() -> None:
"""Load all the BSP transforms.
Expand Down Expand Up @@ -253,6 +265,11 @@ async def main(argv: list[str]) -> None:
else:
LOGGER.warning('Packing disabled!')

# Replace tools/toolsinvisible temporarily, the original blocks light annoyingly.
# Do it after packing, so it isn't packed. We'll swap back to the original,
# so it's not necessary.
swap_material(bsp_file, TEX_INVISIBLE_TOOLS, TEX_INVISIBLE_PATCHED)

# We need to disallow Valve folders.
pack_whitelist: set[FileSystem] = set()
pack_blacklist: set[FileSystem] = {pakfile_fs}
Expand Down Expand Up @@ -308,6 +325,8 @@ async def main(argv: list[str]) -> None:
blacklist=pack_blacklist,
dump_loc=dump_loc,
)
# Put this back.
swap_material(bsp_file, TEX_INVISIBLE_PATCHED, TEX_INVISIBLE_TOOLS)

LOGGER.info('Writing BSP...')
bsp_file.save()
Expand Down

0 comments on commit 5134ae6

Please sign in to comment.