From 78107866ce586c6ef55002248f942ee05ad0e85f Mon Sep 17 00:00:00 2001 From: Matt Penny Date: Wed, 8 May 2024 20:46:42 -0400 Subject: [PATCH] Allow static overriding portalability on a per-surface basis --- documentation/levels/level_objects/static.md | 10 +++++----- tools/level_scripts/static_export.lua | 11 ++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/documentation/levels/level_objects/static.md b/documentation/levels/level_objects/static.md index e796e0b..252907e 100644 --- a/documentation/levels/level_objects/static.md +++ b/documentation/levels/level_objects/static.md @@ -41,11 +41,11 @@ surfaces are portalable. The following material names allow portals to be placed * `concrete_modular_floor001a` * `transparent_portal_surface` -This behavior can be overridden by using the `no_portals` argument. To accept -portals, the geometry must also have associated collision so that it can be hit. -This can be done by placing a coplanar static collision object or through -animation with a [bone](./anim.md) that also animates a dynamic collision -object. +This behavior can be overridden by using the `accept_portals` or `no_portals` +arguments. Only one can be specified at a time. To accept portals, the geometry +must also have associated collision so that it can be hit. This can be done by +placing a coplanar static collision object or through animation with a +[bone](./anim.md) that also animates a dynamic collision object. A mesh's UV coordinates are only used if its material does not have the `tileSizeS` and `tileSizeT` properties in its YAML definition. Otherwise, the diff --git a/tools/level_scripts/static_export.lua b/tools/level_scripts/static_export.lua index 46f0097..88e7045 100644 --- a/tools/level_scripts/static_export.lua +++ b/tools/level_scripts/static_export.lua @@ -124,7 +124,16 @@ local function list_static_nodes(nodes) local plane = sk_math.plane3_with_point(chunkV.mesh.normals[1], chunkV.mesh.vertices[1]) local should_join_mesh = true - local accept_portals = chunkV.mesh.material and portalable_surfaces[chunkV.mesh.material.name] and not sk_scene.find_flag_argument(v.arguments, "no_portals") + + local portalable_material = chunkV.mesh.material and portalable_surfaces[chunkV.mesh.material.name] + local no_portals = sk_scene.find_flag_argument(v.arguments, "no_portals") + local accept_portals_override = sk_scene.find_flag_argument(v.arguments, "accept_portals") + + if no_portals and accept_portals_override then + error("Static geometry '" .. v.arguments .. "' cannot specify both 'no_portals' and 'accept_portals'") + end + + local accept_portals = (portalable_material or accept_portals_override) and not no_portals if transform_index or signal or accept_portals or not is_coplanar(chunkV.mesh, plane) then should_join_mesh = false