From 88c2daaffe96a9c3af1217fdb3530dd7a3e7c560 Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Wed, 25 Nov 2026 21:08:16 +0000 Subject: [PATCH 1/5] fix: Fellan hammers at his hut again - mobs whose model is only a hidden helper (REPAIR_PLANK) keep their slots REPAIR_PLANK.ASC is an untextured helper mesh (ZM_REP_HIDDEN) and the slot ZS_POS0. MeshService skips models without any texture, so the mob had no slots, Wld_IsMobAvailable(self, "REPAIR") answered no and ZS_Repair_Hut (G2 Fellan, G1 ZS_RepairHut) never used it. Such mobs are now built like the dig spots (untextured allowed) and then hidden: nothing drawn, no colliders, only the slots. Co-Authored-By: Claude Opus 5.5 --- .../Domain/Vobs/VobInitializerDomain.cs | 22 ++++++++++++++++++- .../Scripts/Services/Meshes/MeshService.cs | 5 ++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs index beb1ff979..289929319 100644 --- a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs +++ b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs @@ -1068,6 +1068,19 @@ private static void HideVisual(IVirtualObject vob, GameObject go) collider.enabled = false; } + /// + /// Only its slots count: nothing is drawn, and the hero can't focus or grab it (the helper mesh would be an + /// invisible plank on the wall). + /// + private static void HideHelperMob(GameObject go) + { + foreach (var renderer in go.GetComponentsInChildren(true)) + renderer.forceRenderingOff = true; + + foreach (var collider in go.GetComponentsInChildren(true)) + collider.enabled = false; + } + private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) { var go = GetPrefab(vob); @@ -1088,14 +1101,21 @@ private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) // those on purpose (G1's empty harp or WASH_SLOT), but the X needs its mesh to be diggable. Where the // world hides it (showVisual=FALSE, Newworld's spots) it isn't drawn, like in the original. var isDigSpot = _vmCacheService.IsDigSpot(vob); + // A mob whose model is only an untextured helper (G1/G2 REPAIR_PLANK: ZM_REP_HIDDEN and the slot + // ZS_POS0) is invisible in the original, but its slots are where the NPC stands. Without them + // Wld_IsMobAvailable said no, so Fellan in Khorinis' harbour never hammered at his hut. + var isHiddenMob = !isDigSpot && vob is IInteractiveObject && !MeshService.HasMeshes(mdl.Mesh); + var isUntextured = isDigSpot || isHiddenMob; var ret = _meshService.CreateVob(meshName, mdl, parent: parent, rootGo: go, - useTextureArray: !isDigSpot, allowUntextured: isDigSpot); + useTextureArray: !isUntextured, allowUntextured: isUntextured); // A few objects are broken and have no meshes. We need to destroy them immediately again. if (ret == null) Object.Destroy(go); else if (isDigSpot) SnapDigSpotToLoader(ret); + else if (isHiddenMob) + HideHelperMob(ret); return ret; } diff --git a/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs b/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs index 96562553f..01c0bebb1 100644 --- a/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs +++ b/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs @@ -192,7 +192,10 @@ private static bool HasTextures(IMultiResolutionMesh mrm) return !mrm.Materials.All(m => m.Texture.IsEmpty()); } - private static bool HasMeshes(IModelMesh mdm) + /// + /// The model has something to draw: at least one textured mesh or attachment. + /// + public static bool HasMeshes(IModelMesh mdm) { // Check if there are completely empty elements without any texture. // G1: e.g. Harp, Flute, and WASH_SLOT (usage moved to a FreePoint within daedalus functions) From 5aa7ec53aa0b6934370662014227171847637b7b Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Wed, 25 Nov 2026 21:43:43 +0000 Subject: [PATCH 2/5] refactor: rename MeshService.HasMeshes to HasTexturedMeshes - it checks the textures Co-Authored-By: Claude Sonnet 5.5 --- .../Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs | 2 +- Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs index 289929319..2e7a9f4fd 100644 --- a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs +++ b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs @@ -1104,7 +1104,7 @@ private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) // A mob whose model is only an untextured helper (G1/G2 REPAIR_PLANK: ZM_REP_HIDDEN and the slot // ZS_POS0) is invisible in the original, but its slots are where the NPC stands. Without them // Wld_IsMobAvailable said no, so Fellan in Khorinis' harbour never hammered at his hut. - var isHiddenMob = !isDigSpot && vob is IInteractiveObject && !MeshService.HasMeshes(mdl.Mesh); + var isHiddenMob = !isDigSpot && vob is IInteractiveObject && !MeshService.HasTexturedMeshes(mdl.Mesh); var isUntextured = isDigSpot || isHiddenMob; var ret = _meshService.CreateVob(meshName, mdl, parent: parent, rootGo: go, useTextureArray: !isUntextured, allowUntextured: isUntextured); diff --git a/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs b/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs index 01c0bebb1..fb61c1a62 100644 --- a/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs +++ b/Assets/Gothic-Core/Scripts/Services/Meshes/MeshService.cs @@ -128,7 +128,7 @@ public GameObject CreateVob(string objectName, IModel mdl, GameObject parent = null, GameObject rootGo = null, bool useTextureArray = true, bool allowUntextured = false) { - if (!allowUntextured && !HasMeshes(mdl.Mesh)) + if (!allowUntextured && !HasTexturedMeshes(mdl.Mesh)) { return null; } @@ -168,7 +168,7 @@ public GameObject CreateVob(string objectName, IModelMesh mdm, IModelHierarchy m Vector3 position = default, Quaternion rotation = default, GameObject parent = null, GameObject rootGo = null, bool useTextureArray = true) { - if (!HasMeshes(mdm)) + if (!HasTexturedMeshes(mdm)) { return null; } @@ -195,7 +195,7 @@ private static bool HasTextures(IMultiResolutionMesh mrm) /// /// The model has something to draw: at least one textured mesh or attachment. /// - public static bool HasMeshes(IModelMesh mdm) + public static bool HasTexturedMeshes(IModelMesh mdm) { // Check if there are completely empty elements without any texture. // G1: e.g. Harp, Flute, and WASH_SLOT (usage moved to a FreePoint within daedalus functions) From 124d455794091ae37aadf717a65700599ffb17f0 Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Wed, 25 Nov 2026 21:43:59 +0000 Subject: [PATCH 3/5] refactor: merge HideHelperMob into HideVisual with a keepColliders flag Co-Authored-By: Claude Sonnet 5.5 --- .../Domain/Vobs/VobInitializerDomain.cs | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs index 2e7a9f4fd..c503e77e1 100644 --- a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs +++ b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs @@ -1045,42 +1045,32 @@ private GameObject CreateDefaultMesh(IVirtualObject vob, GameObject parent) { var go = BuildDefaultMesh(vob, parent); if (go != null && !vob.ShowVisual) - HideVisual(vob, go); + HideVisual(go, vob is IInteractiveObject); return go; } /// + /// Draws nothing: the renderers stay enabled with forceRenderingOff, so their bounds still work (focus, dig + /// spots). Colliders are switched off unless keepColliders is set. /// showVisual=FALSE (Spacer): like in the engine (OpenGothic ObjVisual::setVisual) the mesh isn't drawn and a /// plain vob doesn't collide. Mods place such vobs as interaction anchors on world geometry (DoM: ore piles, - /// dig spots, campfires) - a mob stays usable: it keeps its colliders (focus, grab, use) and its nodes. The - /// renderers stay enabled, only drawing is off, so their bounds still work (focus, dig spots). + /// dig spots, campfires) - a mob stays usable: it keeps its colliders (focus, grab, use) and its nodes. + /// A helper mob (only its slots count) loses its colliders too: the hero can't focus or grab it (the helper + /// mesh would be an invisible plank on the wall). /// - private static void HideVisual(IVirtualObject vob, GameObject go) + private static void HideVisual(GameObject go, bool keepColliders) { foreach (var renderer in go.GetComponentsInChildren(true)) renderer.forceRenderingOff = true; - if (vob is IInteractiveObject) + if (keepColliders) return; foreach (var collider in go.GetComponentsInChildren(true)) collider.enabled = false; } - /// - /// Only its slots count: nothing is drawn, and the hero can't focus or grab it (the helper mesh would be an - /// invisible plank on the wall). - /// - private static void HideHelperMob(GameObject go) - { - foreach (var renderer in go.GetComponentsInChildren(true)) - renderer.forceRenderingOff = true; - - foreach (var collider in go.GetComponentsInChildren(true)) - collider.enabled = false; - } - private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) { var go = GetPrefab(vob); @@ -1115,7 +1105,7 @@ private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) else if (isDigSpot) SnapDigSpotToLoader(ret); else if (isHiddenMob) - HideHelperMob(ret); + HideVisual(ret, keepColliders: false); return ret; } From 76b01788e86afb6955abb7b16853c58c6aa32302 Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Wed, 25 Nov 2026 21:44:22 +0000 Subject: [PATCH 4/5] fix: only untextured mobs with slot nodes (ZS_*) are built hidden - harp, flute and WASH_SLOT stay skipped; log each helper mob once Co-Authored-By: Claude Sonnet 5.5 --- .../Domain/Vobs/VobInitializerDomain.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs index c503e77e1..7aeb19021 100644 --- a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs +++ b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Gothic.Core.Adapters.Properties; using Gothic.Core.Adapters.Vob; @@ -53,6 +54,7 @@ public class VobInitializerDomain // Ids of logic VOBs below lazily loaded VOBs that were created with the world (MarkCreatedEarly). private readonly HashSet _createdEarlyVobIds = new(); + private readonly HashSet _loggedHelperMobs = new(); /// @@ -1071,6 +1073,15 @@ private static void HideVisual(GameObject go, bool keepColliders) collider.enabled = false; } + /// + /// Slot nodes (ZS_POS0, ...) are where an NPC stands or uses the mob. + /// + private static bool HasSlotNodes(ZenKit.IModel mdl) + { + return mdl.Hierarchy.Nodes.Any(node => + node.Name.StartsWith("ZS_", StringComparison.OrdinalIgnoreCase)); + } + private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) { var go = GetPrefab(vob); @@ -1094,7 +1105,9 @@ private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) // A mob whose model is only an untextured helper (G1/G2 REPAIR_PLANK: ZM_REP_HIDDEN and the slot // ZS_POS0) is invisible in the original, but its slots are where the NPC stands. Without them // Wld_IsMobAvailable said no, so Fellan in Khorinis' harbour never hammered at his hut. - var isHiddenMob = !isDigSpot && vob is IInteractiveObject && !MeshService.HasTexturedMeshes(mdl.Mesh); + // Only models with slot nodes: G1's empty harp, flute and WASH_SLOT stay skipped on purpose. + var isHiddenMob = !isDigSpot && vob is IInteractiveObject && !MeshService.HasTexturedMeshes(mdl.Mesh) + && HasSlotNodes(mdl); var isUntextured = isDigSpot || isHiddenMob; var ret = _meshService.CreateVob(meshName, mdl, parent: parent, rootGo: go, useTextureArray: !isUntextured, allowUntextured: isUntextured); @@ -1105,7 +1118,12 @@ private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) else if (isDigSpot) SnapDigSpotToLoader(ret); else if (isHiddenMob) + { HideVisual(ret, keepColliders: false); + if (_loggedHelperMobs.Add(meshName)) + Logger.LogEditor($"[VobInitializer] Hidden helper mob {meshName} built for its slots.", + LogCat.Vob); + } return ret; } From 1645074c769ad50f89c7c2496803045bbd230e00 Mon Sep 17 00:00:00 2001 From: BoroBongo Date: Wed, 25 Nov 2026 22:46:57 +0000 Subject: [PATCH 5/5] fix: a hidden mob whose model has no hierarchy no longer breaks the world load - it warns once and has no slots Co-Authored-By: Claude Sonnet 5.5 --- .../Domain/Vobs/VobInitializerDomain.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs index 7aeb19021..4fad0242a 100644 --- a/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs +++ b/Assets/Gothic-Core/Scripts/Domain/Vobs/VobInitializerDomain.cs @@ -55,6 +55,7 @@ public class VobInitializerDomain // Ids of logic VOBs below lazily loaded VOBs that were created with the world (MarkCreatedEarly). private readonly HashSet _createdEarlyVobIds = new(); private readonly HashSet _loggedHelperMobs = new(); + private readonly HashSet _loggedNoHierarchyMobs = new(); /// @@ -1076,10 +1077,20 @@ private static void HideVisual(GameObject go, bool keepColliders) /// /// Slot nodes (ZS_POS0, ...) are where an NPC stands or uses the mob. /// - private static bool HasSlotNodes(ZenKit.IModel mdl) + private bool HasSlotNodes(ZenKit.IModel mdl, string meshName) { - return mdl.Hierarchy.Nodes.Any(node => - node.Name.StartsWith("ZS_", StringComparison.OrdinalIgnoreCase)); + var nodes = mdl.Hierarchy?.Nodes; + if (nodes == null) + { + // Broken or modded models: no hierarchy, so no slots. Warn once per visual, don't fail the world load. + if (_loggedNoHierarchyMobs.Add(meshName)) + Logger.LogWarning($"[VobInitializer] Model {meshName} has no hierarchy - no slot nodes.", + LogCat.Vob); + return false; + } + + return nodes.Any(node => node?.Name != null + && node.Name.StartsWith("ZS_", StringComparison.OrdinalIgnoreCase)); } private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) @@ -1107,7 +1118,7 @@ private GameObject BuildDefaultMesh(IVirtualObject vob, GameObject parent) // Wld_IsMobAvailable said no, so Fellan in Khorinis' harbour never hammered at his hut. // Only models with slot nodes: G1's empty harp, flute and WASH_SLOT stay skipped on purpose. var isHiddenMob = !isDigSpot && vob is IInteractiveObject && !MeshService.HasTexturedMeshes(mdl.Mesh) - && HasSlotNodes(mdl); + && HasSlotNodes(mdl, meshName); var isUntextured = isDigSpot || isHiddenMob; var ret = _meshService.CreateVob(meshName, mdl, parent: parent, rootGo: go, useTextureArray: !isUntextured, allowUntextured: isUntextured);