Skip to content

Commit

Permalink
Fix wrong materials being loaded for solids
Browse files Browse the repository at this point in the history
Apparently lambdas inside generator expressions are dark magic.
  • Loading branch information
lasa01 committed Apr 28, 2021
1 parent a10335e commit 2fa9e33
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions io_import_vmf/import_vmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from mathutils import geometry, Vector, Euler, Matrix
from math import inf, radians, floor, ceil, isclose
from itertools import chain, combinations
from functools import partial
import bpy
import time
import traceback
Expand Down Expand Up @@ -478,7 +479,7 @@ def _get_material(self, name: str) -> Tuple[int, int, bpy.types.Material]:
def _stage_solid(self, solid: vmfpy.VMFSolid) -> None:
if self._vmt_importer is None:
return
materials = [(side.material, lambda: side.get_material(allow_patch=True)) for side in solid.sides]
materials = [(side.material, partial(side.get_material, allow_patch=True)) for side in solid.sides]
if self.skip_tools and all(self._vmt_importer.is_nodraw(material, getter) for material, getter in materials):
return
for material, getter in materials:
Expand All @@ -490,7 +491,7 @@ def _load_solid(self, solid: vmfpy.VMFSolid, parent: str,
if self._vmt_importer is not None:
is_tool = all(self._vmt_importer.is_nodraw(
side.material,
lambda: side.get_material(allow_patch=True),
partial(side.get_material, allow_patch=True),
) for side in solid.sides)
else:
is_tool = is_invisible_tool(side.material.lower() for side in solid.sides)
Expand Down

0 comments on commit 2fa9e33

Please sign in to comment.