示例#1
0
        void GetOcclusionsForFace(IntVector3 p, DirectionOrdinal face,
			out int o0, out int o1, out int o2, out int o3)
        {
            // XXX can we store occlusion data to the Voxel?

            var exp_data = s_cubeFaceInfo[(int)face].ExposionVectors;
            var occ_data = s_cubeFaceInfo[(int)face].OcclusionVectors;

            o0 = o1 = o2 = o3 = 0;

            bool occ_edge2 = IsBlocker(p + occ_data[0]);
            bool exp_edge2 = !IsBlocker(p + exp_data[0]);

            for (int i = 0; i < 4; ++i)
            {
                bool occ_edge1 = occ_edge2;
                bool occ_corner = IsBlocker(p + occ_data[i * 2 + 1]);
                occ_edge2 = IsBlocker(p + occ_data[(i * 2 + 2) % 8]);

                bool exp_edge1 = exp_edge2;
                bool exp_corner = !IsBlocker(p + exp_data[i * 2 + 1]);
                exp_edge2 = !IsBlocker(p + exp_data[(i * 2 + 2) % 8]);

                int occlusion;

                if (occ_edge1 && occ_edge2)
                {
                    occlusion = -3;
                }
                else
                {
                    occlusion = 0;

                    if (occ_edge1)
                        occlusion--;
                    else if (exp_edge1)
                        occlusion++;

                    if (occ_edge2)
                        occlusion--;
                    else if (exp_edge2)
                        occlusion++;

                    if (occ_corner)
                        occlusion--;
                    else if (exp_corner)
                        occlusion++;
                }

                switch (i)
                {
                    case 0:
                        o0 = occlusion; break;
                    case 1:
                        o1 = occlusion; break;
                    case 2:
                        o2 = occlusion; break;
                    case 3:
                        o3 = occlusion; break;
                    default:
                        throw new Exception();
                }
            }
        }
示例#2
0
        void GetOcclusionsForFace(IntVector3 p, DirectionOrdinal face,
                                  out int o0, out int o1, out int o2, out int o3)
        {
            // XXX can we store occlusion data to the Voxel?

            var exp_data = s_cubeFaceInfo[(int)face].ExposionVectors;
            var occ_data = s_cubeFaceInfo[(int)face].OcclusionVectors;

            o0 = o1 = o2 = o3 = 0;

            bool occ_edge2 = IsBlocker(p + occ_data[0]);
            bool exp_edge2 = !IsBlocker(p + exp_data[0]);

            for (int i = 0; i < 4; ++i)
            {
                bool occ_edge1  = occ_edge2;
                bool occ_corner = IsBlocker(p + occ_data[i * 2 + 1]);
                occ_edge2 = IsBlocker(p + occ_data[(i * 2 + 2) % 8]);

                bool exp_edge1  = exp_edge2;
                bool exp_corner = !IsBlocker(p + exp_data[i * 2 + 1]);
                exp_edge2 = !IsBlocker(p + exp_data[(i * 2 + 2) % 8]);

                int occlusion;

                if (occ_edge1 && occ_edge2)
                {
                    occlusion = -3;
                }
                else
                {
                    occlusion = 0;

                    if (occ_edge1)
                    {
                        occlusion--;
                    }
                    else if (exp_edge1)
                    {
                        occlusion++;
                    }

                    if (occ_edge2)
                    {
                        occlusion--;
                    }
                    else if (exp_edge2)
                    {
                        occlusion++;
                    }

                    if (occ_corner)
                    {
                        occlusion--;
                    }
                    else if (exp_corner)
                    {
                        occlusion++;
                    }
                }

                switch (i)
                {
                case 0:
                    o0 = occlusion; break;

                case 1:
                    o1 = occlusion; break;

                case 2:
                    o2 = occlusion; break;

                case 3:
                    o3 = occlusion; break;

                default:
                    throw new Exception();
                }
            }
        }