Esempio n. 1
0
        static public void Calculate(MeshData meshData)
        {
            if (!meshData.HasVertices || !meshData.HasNormals || !meshData.HasTriangles)
            {
                Debug.Log("CalculateNormals.CalculateImmediately need vertices, normals and triangles in the meshdata, something is missing!");
                return;
            }

            var info = new NativeArray <NormalInfo>(meshData.Triangles.Length, Allocator.Temp);

            var infoJob = new CalculateNormalInfoJob {
                vertices = meshData.Vertices, triangles = meshData.Triangles, info = info
            };

            for (int i = 0; i < meshData.Triangles.Length / 3; ++i)
            {
                infoJob.Execute(i);
            }

            var normalsJob = new GenerateNormals {
                normalInfo = info, normals = meshData.Normals
            };

            normalsJob.Execute();

            info.Dispose();
        }
Esempio n. 2
0
            public void Execute()
            {
                var info = new NativeArray <NormalInfo>(triangles.Length, Allocator.Temp);

                var infoJob = new CalculateNormalInfoJob {
                    vertices = vertices, triangles = triangles, info = info
                };

                for (int i = 0; i < triangles.Length / 3; ++i)
                {
                    infoJob.Execute(i);
                }

                var normalsJob = new GenerateNormals {
                    normalInfo = info, normals = normals
                };

                normalsJob.Execute();

                info.Dispose();
            }