fix(dvergur): carve the hood out of the dvergr mesh as a submesh

The log settled it: the Dverger prefab holds a single renderer, dvergr, with
the hood, body and clothes baked into one mesh. There was never a separate
object to lift out, so the whole-object search could only ever fail.

Resolution now falls through three steps - a separate renderer object, a
submesh picked out by its material name, and an index pinned by hand in
DvergurConfig - and the submesh path rebuilds the chosen triangles as a
standalone skinned renderer. Vertices, bone weights and bindposes are all
carried over untouched and only the triangle list is narrowed, so the skinning
still lines up and the player rig places the hood without any offsets.

The candidate list also covers the mage variants, which wear a different hood
and may keep it as its own object.

dumpdverger now reports submesh count, per-submesh material and triangle count,
which is the part that actually identifies the hood.
This commit is contained in:
kanym 2026-08-02 23:14:07 +02:00
commit d157a730a3
3 changed files with 220 additions and 59 deletions

View file

@ -795,10 +795,29 @@ namespace RacesOfValheim
Jotunn.Logger.LogInfo($"=== {prefabName} HIERARCHY ===");
DumpTransform(prefab.transform, "");
// Submeshes and their materials are the part that matters: the Dvergr carries its hood,
// body and clothes in one mesh, so the hood can only be picked out by submesh index.
Jotunn.Logger.LogInfo($"=== {prefabName} RENDERERS ===");
foreach (Renderer renderer in prefab.GetComponentsInChildren<Renderer>(true))
{
Jotunn.Logger.LogInfo($" {renderer.gameObject.name} ({renderer.GetType().Name}) path={GetPath(renderer.transform)}");
Mesh mesh = null;
if (renderer is SkinnedMeshRenderer skinned) mesh = skinned.sharedMesh;
else
{
MeshFilter filter = renderer.GetComponent<MeshFilter>();
if (filter != null) mesh = filter.sharedMesh;
}
Jotunn.Logger.LogInfo(
$" {renderer.gameObject.name} ({renderer.GetType().Name}) " +
$"submeshes={(mesh != null ? mesh.subMeshCount : 0)} path={GetPath(renderer.transform)}");
Material[] materials = renderer.sharedMaterials;
for (int i = 0; i < materials.Length; i++)
{
int tris = (mesh != null && i < mesh.subMeshCount) ? mesh.GetTriangles(i).Length / 3 : 0;
Jotunn.Logger.LogInfo($" submesh {i}: material='{(materials[i] != null ? materials[i].name : "null")}' triangles={tris}");
}
}
LevelEffects levelEffects = prefab.GetComponentInChildren<LevelEffects>(true);