private static PrimitiveManager DecodePrimitivesUnweighted(Matrix bindMatrix, GeometryEntry geo) { PrimitiveManager manager = DecodePrimitives(geo); Vector3 * pVert = null, pNorms = null; ushort * pVInd = (ushort *)manager._indices.Address; int vCount = 0; List <Vertex3> vertList = new List <Vertex3>(manager._pointCount); manager._vertices = vertList; if (manager._faceData[1] != null) { pNorms = (Vector3 *)manager._faceData[1].Address; } //Find vertex source foreach (SourceEntry s in geo._sources) { if (s._id == geo._verticesInput._source) { UnsafeBuffer b = s._arrayData as UnsafeBuffer; pVert = (Vector3 *)b.Address; vCount = b.Length / 12; break; } } UnsafeBuffer remap = new UnsafeBuffer(vCount * 2); ushort * pRemap = (ushort *)remap.Address; //Create remap table for (int i = 0; i < vCount; i++) { //Create vertex and look for match Vertex3 v = new Vertex3(bindMatrix * pVert[i]); int index = 0; while (index < vertList.Count) { if (v.Equals(vertList[index])) { break; } index++; } if (index == vertList.Count) { vertList.Add(v); } pRemap[i] = (ushort)index; } //Remap vertex indices and fix normals for (int i = 0; i < manager._pointCount; i++, pVInd++) { *pVInd = pRemap[*pVInd]; if (pNorms != null) { pNorms[i] = bindMatrix.GetRotationMatrix() * pNorms[i]; } } remap.Dispose(); return(manager); }