public void setUpTest()
    {
        fa = new FaceAggregator(Axis.Y);

        int COORD_DIMS1 = 5, COORD_DIMS2 = 1;
        int coord_count = COORD_DIMS1 * COORD_DIMS2;

//		int i = COORD_DIMS * 0; // TODO: fix bug (if it matters which it probably does): if i > 0 we get a trying to add a face where there already was one
        // the face is at aligned coord: 0,0.
        Coord[] coords = new Coord[coord_count];
//		for(; i < coord_count ; ++i)
//		{
//			int z = i % COORD_DIMS;
//			int x = i / COORD_DIMS;
//			coords[i] = new Coord(x, 4, z);
//		}

        rangeModeSetUp(COORD_DIMS1);
        return;

        // ******************** //

        for (int j = 0; j < COORD_DIMS1; ++j)
        {
            for (int k = 0; k < COORD_DIMS2; ++k)
            {
                coords[j * COORD_DIMS2 + k] = new Coord(j, 4, k);
            }
        }

        testCoords = coords;

        foreach (Coord co in coords)
        {
            Coord[] excluded = FaceAggregatorTest.excludedCoords;

            bool include = true;
            foreach (Coord exclu in excluded)
            {
                if (exclu.x == co.x && exclu.z == co.z)
                {
                    include = false;
                    break;
                }
            }             //dont remove for now

            if (include)
            {
                FaceInfo faceinfo = new FaceInfo(co, Block.MAX_LIGHT_LEVEL, Direction.ypos, BlockType.Grass, lightDataProviderFake);
                fa.addFaceAtCoordBlockType(faceinfo);
            }
        }



//		fa.LogFaceSets();
//		bug (fa.faceSetTableToString());

//		fa.LogMeshResults();
    }
Exemple #2
0
//	private void addCoordToFaceAggregorAtIndex(Coord co, BlockType type, Direction dir)
    private void addCoordToFaceAggregorAtIndex(FaceInfo _faceInfo)
    {
#if NO_MESHBUILDER
        FaceAggregator fa = faceAggregatorAt(co.y);
        fa.addFaceAtCoordBlockType(co, type, dir);
        faceAggregators[co.y] = fa;         // put back...
#else
        meshBuilder.addCoordToFaceAggregatorAtIndex(_faceInfo);
#endif
    }
Exemple #3
0
    private void addBlockAtCoordAndAxis(Coord co, Axis axis, AlignedCoord alco, Coord nudgeCoord, BlockType btype)
    {
        Block neg_neighbor_block = this.m_chunk.blockAt(new ChunkIndex(co - nudgeCoord));          //x_one
        Block pos_neighbor_block = this.m_chunk.blockAt(new ChunkIndex(co + nudgeCoord));
        int   relevantComponent  = Coord.SumOfComponents(co * nudgeCoord);
        int   relevantUpperLimit = Coord.SumOfComponents(Chunk.DIMENSIONSINBLOCKS * nudgeCoord);

        Direction relevantPosDir = MeshBuilder.posDirectionForAxis(axis);

        FaceAggregator faXY = null;

        if (Block.BlockTypeIsATranslucentType(neg_neighbor_block.type) || Block.BlockTypeIsATranslucentType(pos_neighbor_block.type))
        {
            faXY = faceAggregatorAt(co, relevantPosDir);             // don't allocate if we won't have to...
        }
        //NEG NEIGHBOR
        if (!Block.BlockTypeIsATranslucentType(neg_neighbor_block.type))         // (neg_neighbor_block.type != BlockType.Air)
        {
            if (relevantComponent > 0)
            {
                // * neighbor not air, so there should be a face that is now hidden and that we should remove
                if (isFaceAggregatorAt(co - nudgeCoord, axis))
                {
                    FaceAggregator faXminusOne = faceAggregatorAt(co - nudgeCoord, relevantPosDir);                    // aggregatorArray[relevantComponent - 1];

                    faXminusOne.removePositiveSideFaceAtCoord(alco);

                    // if faceSetCount now zero, remove faceAgg
                    if (faXminusOne.faceSetCount == 0)
                    {
                        removeFaceAggregatorAt(co - nudgeCoord, axis);
                    }
                    else
                    {
                        // else get Face geom...
                        faXminusOne.getFaceGeometry(relevantComponent - 1);
                    }
                }
            }
        }
        else
        {
            // * neighbor is air, so we need to add a face at our coord
            faXY.addFaceAtCoordBlockType(new FaceInfo(co, Block.MAX_LIGHT_LEVEL, relevantPosDir + 1, btype, this.m_chunk.lightDataProvider));
            faXY.getFaceGeometry(relevantComponent);
        }

        // POS NEIGHBOR
//		neighbor_block = this.m_chunk.blockAt(new ChunkIndex( co + nudgeCoord));
        if (!Block.BlockTypeIsATranslucentType(pos_neighbor_block.type))         // (pos_neighbor_block.type != BlockType.Air)
        {
            if (relevantComponent < relevantUpperLimit - 1)
            {
                if (isFaceAggregatorAt(co + nudgeCoord, axis))
                {
                    // * neighbor not air, remove occluded face
                    FaceAggregator faXplusone = faceAggregatorAt(co + nudgeCoord, relevantPosDir);                     // aggregatorArray[relevantComponent + 1];

                    faXplusone.removeNegativeSideFaceAtCoord(alco);

                    //check if face agg now empty
                    if (faXplusone.faceSetCount == 0)
                    {
                        removeFaceAggregatorAt(co + nudgeCoord, axis);
                    }
                    else
                    {
                        // else get Face geom...
                        faXplusone.getFaceGeometry(relevantComponent + 1);
                    }
                }
            }
        }
        else
        {
            // * neighbor is air, need to add a face at this coord
            faXY.addFaceAtCoordBlockType(new FaceInfo(co, Block.MAX_LIGHT_LEVEL, relevantPosDir, btype, this.m_chunk.lightDataProvider));
            faXY.getFaceGeometry(relevantComponent);
        }
    }
Exemple #4
0
    public void addCoordToFaceAggregatorAtIndex(FaceInfo faceInfo)
    {
        FaceAggregator fa = faceAggregatorAt(faceInfo.coord, faceInfo.direction);

        fa.addFaceAtCoordBlockType(faceInfo);
    }
Exemple #5
0
    private void removeBlockAtCoordAndAxis(Coord co, Axis axis, AlignedCoord alco, Coord nudgeCoord, BlockType btype)
    {
        Block test_b;

        test_b = this.m_chunk.blockAt(new ChunkIndex(co - nudgeCoord));          //x_one
        int relevantComponent  = Coord.SumOfComponents(co * nudgeCoord);
        int relevantUpperLimit = Coord.SumOfComponents(Chunk.DIMENSIONSINBLOCKS * nudgeCoord);

        Direction relevantPosDir = MeshBuilder.posDirectionForAxis(axis);

        FaceAggregator faXY = null;

        if (isFaceAggregatorAt(co, axis))
        {
            faXY = faceAggregatorAt(co, relevantPosDir);
        }

        // *Neg direction neighbor block wasn't air?
        // *we need to add a face on its pos side
        if (test_b.type != BlockType.Air)
        {
            if (relevantComponent > 0)
            {
                FaceAggregator faXminusOne = faceAggregatorAt(co - nudgeCoord, relevantPosDir);                // aggregatorArray[relevantComponent - 1];
                // TODO: make sure this func is really 'add face if not exists.'
                faXminusOne.addFaceAtCoordBlockType(new FaceInfo(co, Block.MAX_LIGHT_LEVEL, relevantPosDir, test_b.type, this.m_chunk.lightDataProvider));
                faXminusOne.getFaceGeometry(relevantComponent - 1);

                // CONSIDER: TRY REMOVING A FACE AT THIS FACE AGG AS WELL. EVEN THOUGH THERE 'SHOULDN'T' BE ONE.
                // AND SIMILAR FOR ADDING BLOCKS
            }
        }
        else             // it is air at x (or whichever co) - 1

        {
            if (faXY != null)
            {
                // * neighbor is an air block, so there should be a face to remove at our block in this direction
                faXY.removeNegativeSideFaceAtCoord(alco);

                if (faXY.faceSetCount == 0)
                {
                    removeFaceAggregatorAt(co, axis);
                }
                else
                {
                    faXY.getFaceGeometry(relevantComponent);
                }
            }
        }

        // x plus one
        test_b = this.m_chunk.blockAt(new ChunkIndex(co + nudgeCoord));
        if (test_b.type != BlockType.Air)
        {
            if (relevantComponent < relevantUpperLimit - 1)
            {
                FaceAggregator faXplusone = faceAggregatorAt(co + nudgeCoord, relevantPosDir);                 // aggregatorArray[relevantComponent + 1];

                faXplusone.addFaceAtCoordBlockType(new FaceInfo(co, Block.MAX_LIGHT_LEVEL, relevantPosDir + 1, test_b.type, this.m_chunk.lightDataProvider));
                faXplusone.getFaceGeometry(relevantComponent + 1);
            }
        }
        else
        {
            if (faXY != null)
            {
                // * neighbor was air, so there should be a face to remove
                faXY.removePositiveSideFaceAtCoord(alco);

                if (faXY.faceSetCount == 0)
                {
                    removeFaceAggregatorAt(co, axis);
                }
                else
                {
                    faXY.getFaceGeometry(relevantComponent);
                }

                faXY.getFaceGeometry(relevantComponent);
            }
        }
    }