Пример #1
0
 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);
     }
 }
Пример #2
0
 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));
 }
Пример #3
0
 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);
     }
 }
Пример #4
0
        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);
        }
Пример #5
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);
     }
 }
Пример #6
0
 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);
     }
 }
Пример #7
0
 public void CopySHCoefficientArraysFrom(List <SphericalHarmonicsL2> lightProbes)
 {
     if (lightProbes == null)
     {
         throw new ArgumentNullException("lightProbes");
     }
     this.CopySHCoefficientArraysFrom(NoAllocHelpers.ExtractArrayFromListT <SphericalHarmonicsL2>(lightProbes), 0, 0, lightProbes.Count);
 }
Пример #8
0
 public void CopyProbeOcclusionArrayFrom(List <Vector4> occlusionProbes)
 {
     if (occlusionProbes == null)
     {
         throw new ArgumentNullException("occlusionProbes");
     }
     this.CopyProbeOcclusionArrayFrom(NoAllocHelpers.ExtractArrayFromListT <Vector4>(occlusionProbes), 0, 0, occlusionProbes.Count);
 }
Пример #9
0
 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);
 }
Пример #10
0
 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)));
 }
Пример #11
0
 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);
     }
 }
Пример #12
0
 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));
 }
Пример #13
0
 private void PrepareUserBuffer <T>(List <T> buffer, int capacity)
 {
     buffer.Clear();
     if (buffer.Capacity < capacity)
     {
         buffer.Capacity = capacity;
     }
     NoAllocHelpers.ResizeList(buffer, capacity);
 }
Пример #14
0
 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);
     }
 }
Пример #15
0
 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));
 }
Пример #16
0
 public static void EnsureListElemCount <T>(List <T> list, int count)
 {
     list.Clear();
     if (list.Capacity < count)
     {
         list.Capacity = count;
     }
     NoAllocHelpers.ResizeList <T>(list, count);
 }
Пример #17
0
        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);
        }
Пример #18
0
        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);
        }
Пример #19
0
        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));
        }
Пример #20
0
        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);
        }
Пример #21
0
 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)));
 }
Пример #22
0
 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);
 }
Пример #23
0
        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);
        }
Пример #24
0
        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));
        }
Пример #25
0
 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));
     }
 }
Пример #26
0
 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)));
        }
Пример #28
0
        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));
            }
        }
Пример #29
0
        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));
            }
        }
Пример #30
0
        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));
            }
        }