Skip to content

Commit

Permalink
Avoid widening texcoord 0 to Vector4 if possible
Browse files Browse the repository at this point in the history
In the case where a material only uses a single 2-channel texcoord,
the "convert 4x2 -> 2x4" code was widening it to a 4-channel texcoord
with zw = 00. Avoid doing that to save a bit of mesh memory.

Change-Id: Id000b0153b7f36528044f1b7711b61d907116f5d
  • Loading branch information
dubois committed Jul 9, 2019
1 parent 1079fb8 commit 5f30951
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ static void CollapseUvs(Mesh mesh) {
} else {
// case: only uv1 empty.
// Nothing to do.
// TODO(pld): targetUVs is untouched; we should avoid assigning it (because it widens to V4)
Debug.Assert(sourceUVs.Count == 0);
targetUVs = null; // Use null to indicate "unchanged"
}
finalUVs.Add(targetUVs);
}

for (int i = 0; i < finalUVs.Count; i++) {
mesh.SetUVs(i, finalUVs[i]);
if (finalUVs[i] != null) {
mesh.SetUVs(i, finalUVs[i]);
}
}

// Clear unused uv sets
mesh.SetUVs(2, new List<Vector2>());
mesh.SetUVs(3, new List<Vector2>());
Expand Down

0 comments on commit 5f30951

Please sign in to comment.