Exemplo n.º 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);
     }
 }
Exemplo n.º 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));
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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));
 }
Exemplo n.º 13
0
 private void PrepareUserBuffer <T>(List <T> buffer, int capacity)
 {
     buffer.Clear();
     if (buffer.Capacity < capacity)
     {
         buffer.Capacity = capacity;
     }
     NoAllocHelpers.ResizeList(buffer, capacity);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
     }
 }
Exemplo n.º 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)));
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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));
            }
        }