コード例 #1
0
    public void Finish()
    {
        chunk.UnlockLocalGroupForMeshing();

        chunk.UpdateMeshLight(colors);

        int lightFlags = lightBFS.Dequeue();

        Chunk downdown = chunk.neighbors[Dirs.DOWN].neighbors[Dirs.DOWN];

        if (downdown != null)
        {
            while (lightBFS_U.Count > 0)
            {
                downdown.sunBFS.Enqueue(lightBFS_U.Dequeue());
            }
            while (lightRBFS_U.Count > 0)
            {
                downdown.sunRBFS.Enqueue(lightRBFS_U.Dequeue());
            }
        }

        Pools.c32N.Return(colors);
        Pools.intQN.Return(lightBFS);
        Pools.intQN.Return(lightBFS_U);
        Pools.lrnQN.Return(lightRBFS);
        Pools.lrnQN.Return(lightRBFS_U);

        // notify neighbors whom should update based on set light flags
        LightCalculator.CheckNeighborLightUpdate(chunk, lightFlags);
    }
コード例 #2
0
    public void Finish()
    {
        chunk.UnlockLocalGroupForMeshing();

        chunk.UpdateMesh(vertices, normals, uvs, uv2s, colors, triangles);

#if GEN_COLLIDERS
        if (chunk.needNewCollider)
        {
            chunk.UpdateColliderNative(colliderVerts, colliderTris);
        }
        Pools.v3Pool.Return(colliderVerts);
        Pools.intPool.Return(colliderTris);
#endif

        int lightFlags = lightBFS.Dequeue();

        // add unfinished sunlight nodes to downdown neighbor
        // then in update they check if any nodes in that queue and trigger a new type of light job update if so
        // can skip down neighbor because that was already fully propagated from this job so start with his down neighbor instead
        Chunk downdown = chunk.neighbors[Dirs.DOWN].neighbors[Dirs.DOWN];
        if (downdown != null)
        {
            while (lightBFS_U.Count > 0)
            {
                downdown.sunBFS.Enqueue(lightBFS_U.Dequeue());
            }
            while (lightRBFS_U.Count > 0)
            {
                downdown.sunRBFS.Enqueue(lightRBFS_U.Dequeue());
            }
        }


#if _DEBUG
        if (lightBFS.Count > 0)
        {
            if (tracking)
            {
                totalsIters++;
                //initLightTime += lightBFS.Dequeue();
                //processLightTime += lightBFS.Dequeue();
                //meshingTime += lightBFS.Dequeue();
                //colliderTime += lightBFS.Dequeue();

                //string output = string.Format("initLight:{0:0.0}, lighting:{1:0.0}, meshing:{2:0.0}, collider:{3:0.0}",
                //    initLightTime / (float)totalsIters,
                //    processLightTime / (float)totalsIters,
                //    meshingTime / (float)totalsIters,
                //    colliderTime / (float)totalsIters);

                initLightTime    = lightBFS.Dequeue();
                processLightTime = lightBFS.Dequeue();
                meshingTime      = lightBFS.Dequeue();
                colliderTime     = lightBFS.Dequeue();

                string output = string.Format("initLight:{0:0.0}, lighting:{1:0.0}, meshing:{2:0.0}, collider:{3:0.0}",
                                              initLightTime, processLightTime, meshingTime, colliderTime);

                Debug.Log(output);
            }
        }
#endif

        Pools.tloLN.Return(lightOps);
        Pools.intQN.Return(lightBFS);
        Pools.intQN.Return(lightBFS_U);
        Pools.lrnQN.Return(lightRBFS);
        Pools.lrnQN.Return(lightRBFS_U);

        // notify neighbors whom should update based on set light flags
        LightCalculator.CheckNeighborLightUpdate(chunk, lightFlags);
    }