Exemple #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();
        }
Exemple #2
0
            static public JobHandle Schedule(NativeArray <float3> vertices, NativeArray <int> tris, NativeArray <NormalInfo> info, JobHandle dependOn = default)
            {
                var job = new CalculateNormalInfoJob {
                    vertices = vertices, triangles = tris, info = info
                };

                return(job.Schedule(tris.Length / 3, BatchCount, dependOn));
            }
Exemple #3
0
        static public JobHandle Schedule(NativeArray <float3> vertices, NativeArray <int> triangles, NativeArray <float3> normals, JobHandle dependOn = default)
        {
            NativeArray <NormalInfo> info = new NativeArray <NormalInfo>(triangles.Length, Allocator.TempJob);

            dependOn = CalculateNormalInfoJob.Schedule(vertices, triangles, info, dependOn);
            dependOn = GenerateNormals.Schedule(info, normals, dependOn);

            dependOn = info.Dispose(dependOn);

            return(dependOn);
        }
Exemple #4
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();
            }