public void Reload(Shape shape, Mesh mesh) { //Load indices into the group var indices = mesh.GetIndices().ToArray(); Faces.Clear(); for (int i = 0; i < indices.Length; i++) { Faces.Add(indices[i]); } if (!PrimitiveTypes.ContainsKey(mesh.PrimitiveType)) { throw new Exception($"Unsupported primitive type! {mesh.PrimitiveType}"); } //Set the primitive type PrimitiveType = PrimitiveTypes[mesh.PrimitiveType];; switch (Stride) { case 2: DrawElementsType = DrawElementsType.UnsignedShort; break; case 4: DrawElementsType = DrawElementsType.UnsignedInt; break; case 1: DrawElementsType = DrawElementsType.UnsignedByte; break; } }
public static string GetOriginalName(ITypeMetadata metadata) { var name = metadata.Name; var fullName = metadata.IsNullable ? metadata.FullName.TrimEnd('?') : metadata.FullName; if (PrimitiveTypes.ContainsKey(fullName)) { name = PrimitiveTypes[fullName] + (metadata.IsNullable ? "?" : string.Empty); } return(name); }
public static bool IsPrimitive(ITypeMetadata metadata) { var fullName = metadata.FullName; if (metadata.IsNullable) { fullName = fullName.TrimEnd('?'); } else if (metadata.IsEnumerable) { var innerType = metadata.TypeArguments.FirstOrDefault(); if (innerType != null) { fullName = innerType.IsNullable ? innerType.FullName.TrimEnd('?') : innerType.FullName; } else { return(false); } } return(metadata.IsEnum || PrimitiveTypes.ContainsKey(fullName)); }
public static bool IsPrimitiveType(string typeName) { return(PrimitiveTypes.ContainsKey(typeName) || PrimitiveTypes.Values.Any(v => v.Name == typeName || v.FullName == typeName)); }