using AssetRipper.SourceGenerated.Enums; using AssetRipper.SourceGenerated.Subclasses.SubMesh; namespace AssetRipper.SourceGenerated.Extensions; public static class SubMeshExtensions { extension(ISubMesh subMesh) { /// /// For versions < 4, IsTriStrip is used here instead.
/// For it, 0 cooresponds to ,
/// and non-zero cooresponds to .
/// This conveniently matches the enumeration. ///
public MeshTopology GetTopology() { if (subMesh.Has_Topology()) { return subMesh.TopologyE; } else { // https://github.com/AssetRipper/AssetRipper/issues/1759 return subMesh.IsTriStrip != 0 ? MeshTopology.TriangleStrip : MeshTopology.Triangles; } } public void SetTopology(MeshTopology topology) { if (subMesh.Has_Topology()) { subMesh.TopologyE = topology; } else { subMesh.IsTriStripE = topology; } } public uint GetFirstIndex(bool is16BitIndices) { return is16BitIndices ? subMesh.FirstByte / sizeof(ushort) : subMesh.FirstByte / sizeof(uint); } public void SetFirstIndex(bool is16BitIndices, uint firstIndex) { subMesh.FirstByte = is16BitIndices ? firstIndex * sizeof(ushort) : firstIndex * sizeof(uint); } } }