Skip to content

Commit

Permalink
SPS: Add support for unity mat overlay hack slots
Browse files Browse the repository at this point in the history
  • Loading branch information
SenkyDragon committed Jul 18, 2024
1 parent f90d5fa commit e8369d5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ public static Tuple<float, float, VFMultimapSet<VFGameObject,int>> GetAutoWorldS
var mask = plug ? PlugMaskGenerator.GetMask(renderer, plug) : null;
var matsUsedByVert = new VFMultimapSet<int, int>();
var mesh = renderer.GetMesh();
var matSlotsInMesh = 0;
if (mesh != null) {
var matCount = mesh.subMeshCount;
var matCount = matSlotsInMesh = mesh.subMeshCount;
for (var matI = 0; matI < matCount; matI++) {
foreach (var vert in mesh.GetTriangles(matI)) {
matsUsedByVert.Put(vert, matI);
Expand All @@ -132,6 +133,12 @@ public static Tuple<float, float, VFMultimapSet<VFGameObject,int>> GetAutoWorldS
}
allLocalVerts.Add(v);
}
// Mat slots in the renderer that are higher than the number of mats on the mesh reuse the same verts as the last mesh mat
if (matsUsed.Get(renderer.owner()).Contains(matSlotsInMesh-1)) {
for (var i = matSlotsInMesh; i < renderer.sharedMaterials.Length; i++) {
matsUsed.Put(renderer.owner(), i);
}
}
}

var length = allLocalVerts
Expand Down

0 comments on commit e8369d5

Please sign in to comment.