public void SetTriangles(int[] triangles, int submesh, [UnityEngine.Internal.DefaultValue("true")] bool calculateBounds, [UnityEngine.Internal.DefaultValue("0")] int baseVertex) { if (this.CheckCanAccessSubmeshTriangles(submesh)) { this.SetTrianglesImpl(submesh, triangles, NoAllocHelpers.SafeLength(triangles), calculateBounds, baseVertex); } }
public static void CalculateInterpolatedLightAndOcclusionProbes(List <Vector3> positions, List <SphericalHarmonicsL2> lightProbes, List <Vector4> occlusionProbes) { if (positions == null) { throw new ArgumentNullException("positions"); } if (lightProbes == null && occlusionProbes == null) { throw new ArgumentException("Argument lightProbes and occlusionProbes cannot both be null."); } if (lightProbes != null) { if (lightProbes.Capacity < positions.Count) { lightProbes.Capacity = positions.Count; } if (lightProbes.Count < positions.Count) { NoAllocHelpers.ResizeList <SphericalHarmonicsL2>(lightProbes, positions.Count); } } if (occlusionProbes != null) { if (occlusionProbes.Capacity < positions.Count) { occlusionProbes.Capacity = positions.Count; } if (occlusionProbes.Count < positions.Count) { NoAllocHelpers.ResizeList <Vector4>(occlusionProbes, positions.Count); } } LightProbes.Internal_CalculateInterpolatedLightAndOcclusionProbes(NoAllocHelpers.ExtractArrayFromListT <Vector3>(positions), positions.Count, NoAllocHelpers.ExtractArrayFromListT <SphericalHarmonicsL2>(lightProbes), NoAllocHelpers.ExtractArrayFromListT <Vector4>(occlusionProbes)); }
public void SetTriangles(List <int> triangles, int submesh, [DefaultValue("true")] bool calculateBounds, [DefaultValue("0")] int baseVertex) { if (CheckCanAccessSubmeshTriangles(submesh)) { SetTrianglesImpl(submesh, NoAllocHelpers.ExtractArrayFromList(triangles), NoAllocHelpers.SafeLength(triangles), calculateBounds, baseVertex); } }
public static bool GenerateAtlas(Vector2[] sizes, int padding, int atlasSize, List <Rect> results) { if (sizes == null) { throw new ArgumentException("sizes array can not be null"); } if (results == null) { throw new ArgumentException("results list cannot be null"); } if (padding < 0) { throw new ArgumentException("padding can not be negative"); } if (atlasSize <= 0) { throw new ArgumentException("atlas size must be positive"); } results.Clear(); if (sizes.Length == 0) { return(true); } NoAllocHelpers.EnsureListElemCount(results, sizes.Length); GenerateAtlasImpl(sizes, padding, atlasSize, NoAllocHelpers.ExtractArrayFromListT(results)); return(results.Count != 0); }
public void SetTriangles(List <ushort> triangles, int trianglesStart, int trianglesLength, int submesh, bool calculateBounds = true, int baseVertex = 0) { if (CheckCanAccessSubmeshTriangles(submesh)) { SetTrianglesImpl(submesh, UnityEngine.Rendering.IndexFormat.UInt16, NoAllocHelpers.ExtractArrayFromList(triangles), NoAllocHelpers.SafeLength(triangles), trianglesStart, trianglesLength, calculateBounds, baseVertex); } }
public void SetIndices(int[] indices, MeshTopology topology, int submesh, [DefaultValue("true")] bool calculateBounds, [DefaultValue("0")] int baseVertex) { if (CheckCanAccessSubmeshIndices(submesh)) { SetIndicesImpl(submesh, topology, indices, NoAllocHelpers.SafeLength(indices), calculateBounds, baseVertex); } }
public void CopySHCoefficientArraysFrom(List <SphericalHarmonicsL2> lightProbes) { if (lightProbes == null) { throw new ArgumentNullException("lightProbes"); } this.CopySHCoefficientArraysFrom(NoAllocHelpers.ExtractArrayFromListT <SphericalHarmonicsL2>(lightProbes), 0, 0, lightProbes.Count); }
public void CopyProbeOcclusionArrayFrom(List <Vector4> occlusionProbes) { if (occlusionProbes == null) { throw new ArgumentNullException("occlusionProbes"); } this.CopyProbeOcclusionArrayFrom(NoAllocHelpers.ExtractArrayFromListT <Vector4>(occlusionProbes), 0, 0, occlusionProbes.Count); }
public void Append <T>(List <T> data) where T : struct { if (!UnsafeUtility.IsGenericListBlittable <T>()) { throw new ArgumentException($"List<{typeof(T)}> passed to {nameof(Append)} must be blittable.\n{UnsafeUtility.GetReasonForGenericListNonBlittable<T>()}"); } ComputeFromArray(NoAllocHelpers.ExtractArrayFromList(data), 0, data.Count, UnsafeUtility.SizeOf <T>(), ref this); }
public void SetData <T>(List <T> data) { if (data == null) { throw new ArgumentNullException("data"); } this.InternalSetData(NoAllocHelpers.ExtractArrayFromList(data), 0, 0, NoAllocHelpers.SafeLength <T>(data), Marshal.SizeOf(typeof(T))); }
public void SetIndices(ushort[] indices, int indicesStart, int indicesLength, MeshTopology topology, int submesh, bool calculateBounds = true, int baseVertex = 0) { if (CheckCanAccessSubmeshIndices(submesh)) { CheckIndicesArrayRange(indices, NoAllocHelpers.SafeLength(indices), indicesStart, indicesLength); SetIndicesImpl(submesh, topology, UnityEngine.Rendering.IndexFormat.UInt16, indices, indicesStart, indicesLength, calculateBounds, baseVertex); } }
public void GetBindposes(List <Matrix4x4> bindposes) { if (bindposes == null) { throw new ArgumentNullException("The result bindposes list cannot be null.", "bindposes"); } NoAllocHelpers.EnsureListElemCount <Matrix4x4>(bindposes, this.GetBindposeCount()); this.GetBindposesNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT <Matrix4x4>(bindposes)); }
private void PrepareUserBuffer <T>(List <T> buffer, int capacity) { buffer.Clear(); if (buffer.Capacity < capacity) { buffer.Capacity = capacity; } NoAllocHelpers.ResizeList(buffer, capacity); }
public void SetIndices(List <int> indices, int indicesStart, int indicesLength, MeshTopology topology, int submesh, bool calculateBounds = true, int baseVertex = 0) { if (CheckCanAccessSubmeshIndices(submesh)) { var indicesArray = NoAllocHelpers.ExtractArrayFromList(indices); CheckIndicesArrayRange(indicesArray, NoAllocHelpers.SafeLength(indices), indicesStart, indicesLength); SetIndicesImpl(submesh, topology, UnityEngine.Rendering.IndexFormat.UInt32, indicesArray, indicesStart, indicesLength, calculateBounds, baseVertex); } }
public void GetBoneWeights(List <BoneWeight> boneWeights) { if (boneWeights == null) { throw new ArgumentNullException("The result boneWeights list cannot be null.", "boneWeights"); } NoAllocHelpers.EnsureListElemCount <BoneWeight>(boneWeights, this.GetBoneWeightCount()); this.GetBoneWeightsNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT <BoneWeight>(boneWeights)); }
public static void EnsureListElemCount <T>(List <T> list, int count) { list.Clear(); if (list.Capacity < count) { list.Capacity = count; } NoAllocHelpers.ResizeList <T>(list, count); }
public static void DrawMeshInstanced(Mesh mesh, int submeshIndex, Material material, List <Matrix4x4> matrices, [uei.DefaultValue("null")] MaterialPropertyBlock properties, [uei.DefaultValue("ShadowCastingMode.On")] ShadowCastingMode castShadows, [uei.DefaultValue("true")] bool receiveShadows, [uei.DefaultValue("0")] int layer, [uei.DefaultValue("null")] Camera camera, [uei.DefaultValue("LightProbeUsage.BlendProbes")] LightProbeUsage lightProbeUsage, [uei.DefaultValue("null")] LightProbeProxyVolume lightProbeProxyVolume) { if (matrices == null) { throw new ArgumentNullException("matrices"); } DrawMeshInstanced(mesh, submeshIndex, material, NoAllocHelpers.ExtractArrayFromListT(matrices), matrices.Count, properties, castShadows, receiveShadows, layer, camera, lightProbeUsage, lightProbeProxyVolume); }
public void Append <T>(List <T> data) where T : struct { bool flag = !UnsafeUtility.IsGenericListBlittable <T>(); if (flag) { throw new ArgumentException(string.Format("List<{0}> passed to {1} must be blittable.\n{2}", typeof(T), "Append", UnsafeUtility.GetReasonForGenericListNonBlittable <T>())); } Hash128.ComputeFromArray(NoAllocHelpers.ExtractArrayFromList(data), 0, data.Count, UnsafeUtility.SizeOf <T>(), ref this); }
public void GetSharedMaterials(List <Material> m) { bool flag = m == null; if (flag) { throw new ArgumentNullException("The result material list cannot be null.", "m"); } NoAllocHelpers.EnsureListElemCount <Material>(m, this.GetMaterialCount()); this.CopySharedMaterialArray(NoAllocHelpers.ExtractArrayFromListT <Material>(m)); }
public static Hash128 Compute <T>(List <T> data) where T : struct { if (!UnsafeUtility.IsGenericListBlittable <T>()) { throw new ArgumentException($"List<{typeof(T)}> passed to {nameof(Compute)} must be blittable.\n{UnsafeUtility.GetReasonForGenericListNonBlittable<T>()}"); } var h = new Hash128(); ComputeFromArray(NoAllocHelpers.ExtractArrayFromList(data), 0, data.Count, UnsafeUtility.SizeOf <T>(), ref h); return(h); }
public void SetData <T>(List <T> data, int managedBufferStartIndex, int computeBufferStartIndex, int count) { if (data == null) { throw new ArgumentNullException("data"); } if (managedBufferStartIndex < 0 || computeBufferStartIndex < 0 || count < 0 || managedBufferStartIndex + count > data.Count) { throw new ArgumentOutOfRangeException(string.Format("Bad indices/count arguments (managedBufferStartIndex:{0} computeBufferStartIndex:{1} count:{2})", managedBufferStartIndex, computeBufferStartIndex, count)); } this.InternalSetData(NoAllocHelpers.ExtractArrayFromList(data), managedBufferStartIndex, computeBufferStartIndex, count, Marshal.SizeOf(typeof(T))); }
public void Append <T>(List <T> data, int start, int count) where T : struct { if (!UnsafeUtility.IsGenericListBlittable <T>()) { throw new ArgumentException($"List<{typeof(T)}> passed to {nameof(Append)} must be blittable.\n{UnsafeUtility.GetReasonForGenericListNonBlittable<T>()}"); } if (start < 0 || count < 0 || start + count > data.Count) { throw new ArgumentOutOfRangeException($"Bad start/count arguments (start:{start} count:{count})"); } ComputeFromArray(NoAllocHelpers.ExtractArrayFromList(data), start, count, UnsafeUtility.SizeOf <T>(), ref this); }
public static Hash128 Compute <T>(List <T> data) where T : struct { bool flag = !UnsafeUtility.IsGenericListBlittable <T>(); if (flag) { throw new ArgumentException(string.Format("List<{0}> passed to {1} must be blittable.\n{2}", typeof(T), "Compute", UnsafeUtility.GetReasonForGenericListNonBlittable <T>())); } Hash128 result = default(Hash128); Hash128.ComputeFromArray(NoAllocHelpers.ExtractArrayFromList(data), 0, data.Count, UnsafeUtility.SizeOf <T>(), ref result); return(result); }
public void GetBoneWeights(List <BoneWeight> boneWeights) { if (boneWeights == null) { throw new ArgumentNullException("The result boneWeights list cannot be null.", "boneWeights"); } if (HasBoneWeights()) { NoAllocHelpers.EnsureListElemCount(boneWeights, vertexCount); } GetBoneWeightsNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT(boneWeights)); }
private void GetListForChannel <T>(List <T> buffer, int capacity, Mesh.InternalShaderChannel channel, int dim, Mesh.InternalVertexChannelType channelType) { buffer.Clear(); if (!this.canAccess) { this.PrintErrorCantAccessChannel(channel); } else if (this.HasChannel(channel)) { NoAllocHelpers.EnsureListElemCount <T>(buffer, capacity); this.GetArrayFromChannelImpl(channel, channelType, dim, NoAllocHelpers.ExtractArrayFromList(buffer)); } }
public void GetIndices(List <int> indices, int submesh, [UnityEngine.Internal.DefaultValue("true")] bool applyBaseVertex) { if (indices == null) { throw new ArgumentNullException("The result indices list cannot be null.", "indices"); } if (submesh < 0 || submesh >= this.subMeshCount) { throw new IndexOutOfRangeException("Specified sub mesh is out of range. Must be greater or equal to 0 and less than subMeshCount."); } NoAllocHelpers.EnsureListElemCount <int>(indices, (int)this.GetIndexCount(submesh)); this.GetIndicesNonAllocImpl(NoAllocHelpers.ExtractArrayFromListT <int>(indices), submesh, applyBaseVertex); }
public void SetData <T>(List <T> data) { if (data == null) { throw new ArgumentNullException("data"); } if (!UnsafeUtility.IsBlittable(typeof(T))) { throw new ArgumentException(string.Format("{0} type used in ComputeBuffer.SetData(List<>)) must be blittable", typeof(T))); } InternalSetData(NoAllocHelpers.ExtractArrayFromList(data), 0, 0, NoAllocHelpers.SafeLength(data), Marshal.SizeOf(typeof(T))); }
private static void ExtractGlobalMatrixArray(int name, List <Matrix4x4> values) { if (values == null) { throw new ArgumentNullException("values"); } values.Clear(); int globalMatrixArrayCountImpl = Shader.GetGlobalMatrixArrayCountImpl(name); if (globalMatrixArrayCountImpl > 0) { NoAllocHelpers.EnsureListElemCount <Matrix4x4>(values, globalMatrixArrayCountImpl); Shader.ExtractGlobalMatrixArrayImpl(name, (Matrix4x4[])NoAllocHelpers.ExtractArrayFromList(values)); } }
private void ExtractMatrixArray(int name, List <Matrix4x4> values) { if (values == null) { throw new ArgumentNullException("values"); } values.Clear(); int matrixArrayCountImpl = this.GetMatrixArrayCountImpl(name); if (matrixArrayCountImpl > 0) { NoAllocHelpers.EnsureListElemCount <Matrix4x4>(values, matrixArrayCountImpl); this.ExtractMatrixArrayImpl(name, (Matrix4x4[])NoAllocHelpers.ExtractArrayFromList(values)); } }
private void ExtractFloatArray(int name, List <float> values) { if (values == null) { throw new ArgumentNullException("values"); } values.Clear(); int floatArrayCountImpl = this.GetFloatArrayCountImpl(name); if (floatArrayCountImpl > 0) { NoAllocHelpers.EnsureListElemCount <float>(values, floatArrayCountImpl); this.ExtractFloatArrayImpl(name, (float[])NoAllocHelpers.ExtractArrayFromList(values)); } }