示例#1
0
    static void ProcessNodeChildrenRecursive(VisibleSets visibleSets,
                                             WorldFrustrumPlanes frustrumPlanes,
                                             int4 nodeID,
                                             int depth)
    {
        int4 min;
        int4 max;

        Octree.GetMinMaxNodeChildrenID(nodeID, out min, out max);
        var subNodeExtent = Octree.NodeExtent(depth);

        for (int x = min.x; x < max.x; ++x)
        {
            for (int y = min.y; y < max.y; ++y)
            {
                for (int z = min.z; z < max.z; ++z)
                {
                    var subNodeID = new int4(x, y, z, depth);

                    if (!Math.IsCubeCulled(Octree.NodeIDToPoint(subNodeID), subNodeExtent, frustrumPlanes))
                    {
                        var packedID = Octree.PackID(subNodeID);
                        visibleSets[depth].Add(packedID);

                        if (depth < Octree.LeafLayer)
                        {
                            ProcessNodeChildrenRecursive(visibleSets, frustrumPlanes, subNodeID, depth + 1);
                        }
                    }
                }
            }
        }
    }
示例#2
0
    static void ProcessFrustrumClusters(VisibleSets visibleSets,
                                        AABB frustrumAABB,
                                        WorldFrustrumPlanes frustrumPlanes)
    {
        int4 min;
        int4 max;

        Octree.GetMinMaxClusterIDs(frustrumAABB, out min, out max);

        for (int x = min.x; x < max.x; ++x)
        {
            for (int y = min.y; y < max.y; ++y)
            {
                for (int z = min.z; z < max.z; ++z)
                {
                    var clusterID = new int4(x, y, z, Octree.ClusterLayer);

                    if (!Math.IsCubeCulled(Octree.ClusterIDToPoint(clusterID.xyz), Octree.ClusterExtent, frustrumPlanes))
                    {
                        var packedID = Octree.PackID(clusterID);
                        visibleSets.ClusterLayer.Add(packedID);

                        ProcessNodeChildrenRecursive(visibleSets, frustrumPlanes, clusterID, 1);
                    }
                }
            }
        }
    }
示例#3
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var visibleSets = new VisibleSets();

        visibleSets.Setup();

        dstManager.AddComponentData(entity, new VisibleSetsComponent {
            Value = visibleSets
        });
    }