Exemplo n.º 1
0
//	private static bool getAlreadyDone(bool[,] colDoneCheckList, PTwo co)
//	{
//		AssertUtil.Assert(! (co.area() >= colDoneCheckList.GetLength(0) * colDoneCheckList.GetLength(1)), "problems with col done checklist out of bounds:" +
//		    "" + co.toString() + " check list length: " + colDoneCheckList.Length);
//
//		return colDoneCheckList[co.s, co.t];
//	}
//
//	private static void setTrueAlreadyDone(ref bool[,] colDoneCheckList, PTwo co)
//	{
//		AssertUtil.Assert(! (co.area() >= colDoneCheckList.GetLength(0) * colDoneCheckList.GetLength(1)), "problems with col done checklist out of bounds:" +
//		    "" + co.toString() + " check list length: " + colDoneCheckList.Length);
//
//		colDoneCheckList[co.s, co.t] = true;
//	}

    #region debug

    void addColumnIfNoiseCoordOO(LightColumn lcol)
    {
        if (NoiseCoord.Equal(this.m_noisePatch.coord, new NoiseCoord(0, 0)))
        {
            ChunkManager.debugLinesAssistant.addColumn(lcol.toColumnDebug(), this.debugTimeDrewDebugColm++, m_noisePatch.coord);
        }
    }
Exemplo n.º 2
0
    static void drawDebugLinesForNoisePatch(NoiseCoord nco, Color col, int offset)
    {
        Coord woco = worldCoordForNoiseCoord(nco) + offset;
        Coord dims = new Coord(ChunkManager.CHUNKLENGTH * NoisePatch.CHUNKDIMENSION,
                               ChunkManager.CHUNKHEIGHT, ChunkManager.CHUNKLENGTH * NoisePatch.CHUNKDIMENSION) - 3;

        drawDebugCube(woco, dims, col);
    }
Exemplo n.º 3
0
 public NoisePatch noisePatchAtNoiseCoord(NoiseCoord nco)
 {
     if (!m_noisePatches.ContainsKey(nco))
     {
         return(null);
     }
     return(noisePatches [nco]);
 }
Exemplo n.º 4
0
    public bool noisePatchAtNoiseCoordHasBuiltOrIsBuildingCurrently(NoiseCoord nco)
    {
        if (!m_noisePatches.ContainsKey(nco))
        {
            return(false);
        }

        return(m_noisePatches[nco].hasStarted || m_noisePatches[nco].IsDone);
    }
Exemplo n.º 5
0
    public bool noisePatchAtNoiseCoordHasBuiltAtleastOnce(NoiseCoord nco)
    {
        if (!m_noisePatches.ContainsKey(nco))
        {
            return(false);
        }

        return(!m_noisePatches[nco].hasStarted && noisePatches[nco].IsDone);
    }
Exemplo n.º 6
0
    public NoisePatch noisePatchAtWorldCoord(Coord woco)
    {
        NoiseCoord nco = noiseCoordForWorldCoord(woco);

        if (!m_noisePatches.ContainsKey(nco))
        {
            return(null);
        }
        return(noisePatches [nco]);
    }
Exemplo n.º 7
0
    public static void drawDebugQuad(Quad quad, Color col)
    {
        Coord start = CoordUtil.WorldCoordFromNoiseCoord(NoiseCoord.NoiseCoordWithPTwo(quad.origin));
        Coord outer = CoordUtil.WorldCoordFromNoiseCoord(NoiseCoord.NoiseCoordWithPTwo(quad.extent()));


        //lower box
        debugLine(start, new Coord(start.x, start.y, outer.z), col);
        debugLine(start, new Coord(outer.x, start.y, start.z), col);
        debugLine(new Coord(outer.x, start.y, outer.z), new Coord(start.x, start.y, outer.z), col);
        debugLine(new Coord(outer.x, start.y, outer.z), new Coord(outer.x, start.y, start.z), col);
    }
Exemplo n.º 8
0
    public void GenerateAltAtNoiseCoord(NoiseCoord _noiseCoord)
    {
        float left   = (float)_noiseCoord.x * 2.0f;
        float right  = left + 2.0f;
        float top    = (float)_noiseCoord.z * 2.0f;
        float bottom = top + 2.0f;

        this.m_altNoiseMap.GeneratePlanar(
            left,
            right,
            top,
            bottom);
    }
Exemplo n.º 9
0
    public static bool NoiseCoordWithinTestLimits(NoiseCoord nco)
    {
        if (TestRunner.RunGameOnlyNoisPatchesWithinWorldLimits)
        {
            int xstart, zstart, xend, zend;
            xstart = TestRunner.WorldLimits.start.x;
            xend   = TestRunner.WorldLimits.outerLimit().x;
            zstart = TestRunner.WorldLimits.start.z;
            zend   = TestRunner.WorldLimits.outerLimit().z;

            return(xstart < nco.x && xend > nco.x && zstart < nco.z && zend > nco.z);
        }
        return(true);
    }
Exemplo n.º 10
0
    public static List <Coord> WorldRelativeChunkCoordsWithinNoiseCoord(NoiseCoord nco)
    {
        Coord chCoOrigin = WorldRelativeChunkCoordForNoiseCoord(nco);

        List <Coord> result = new List <Coord>();

        for (int i = 0; i < NoisePatch.CHUNKDIMENSION; ++i)
        {
            for (int j = 0; j < NoisePatch.CHUNKDIMENSION; ++j)
            {
                result.Add(chCoOrigin + new Coord(i, 0, j));
            }
        }
        return(result);
    }
Exemplo n.º 11
0
    //get the light columns at any woco that exists...

    public DiscreteDomainRangeList <LightColumn> lightColumnsAtWoco(int x, int z, NoiseCoord _noiseCoord)
    {
        Coord      woconoco = CoordUtil.WorldCoordFromNoiseCoord(_noiseCoord);
        NoiseCoord nco      = CoordUtil.NoiseCoordForWorldCoord(new Coord(x, 0, z) + woconoco);
        NoisePatch npatch   = m_chunkManager.blocks.noisePatchAtNoiseCoord(nco);

        if (npatch == null)
        {
            return(null);
        }

        Coord pRelCo = CoordUtil.PatchRelativeBlockCoordForWorldBlockCoord(new Coord(x, 0, z));

        // noisepatch return lightcol map at rel co
        return(npatch.lightColumnsAt(PTwo.PTwoXZFromCoord(pRelCo)));
    }
Exemplo n.º 12
0
    public void addNoisePatchAt(NoiseCoord nco, NoisePatch _npatch)
    {
        m_noisePatches.Add(nco, _npatch);
        //domain limits
        if (Quad.Equal(this.domain, Quad.theErsatzNullQuad()))
        {
            //first time
            domain = new Quad(new PTwo(nco.x, nco.z), PTwo.PTwoOne());
        }
        else
        {
            domain = domain.expandedToContainPoint(new PTwo(nco.x, nco.z));
        }

        ChunkManager.debugLinesAssistant.debugQuad = domain;
    }
Exemplo n.º 13
0
    private void enlargeDomain()
    {
        foreach (KeyValuePair <NoiseCoord, NoisePatch> keyVal in m_noisePatches)
        {
            NoiseCoord nco = keyVal.Key;
            if (domain.isErsatzNull())
            {
                domain = Quad.UnitQuadWithPoint(PTwo.PTwoXZFromNoiseCoord(nco));
            }
            else
            {
                domain.expandedToContainPoint(PTwo.PTwoXZFromNoiseCoord(nco));
            }
        }

        //debug
        ChunkManager.debugLinesAssistant.debugQuad = domain;
    }
Exemplo n.º 14
0
    public bool noisePatchAtCoordIsReady(NoiseCoord nco)
    {
#if NEW_PATCH_READY
        if (noisePatchAtNoiseCoordHasBuiltAtleastOnce(nco))
        {
            return(m_noisePatches[nco].neighborsHaveAllBuiltAtLeastOnce);
        }
        return(false);
#endif

        if (!m_noisePatches.ContainsKey(nco))
        {
            return(false);
        }
#if NEW_PATCH_READY
#else
        return(noisePatches[nco].generatedBlockAlready);
#endif
    }
Exemplo n.º 15
0
    public Block this[Coord woco]
    {
        get
        {
            NoiseCoord nco = noiseCoordForWorldCoord(woco);
            if (!m_noisePatches.ContainsKey(nco))
            {
                return(null);
            }
            NoisePatch np = m_noisePatches [nco];

            return(np.blockAtWorldBlockCoord(woco));
        }
        set
        {
            NoisePatch np = m_noisePatches [noiseCoordForWorldCoord(woco)];
            np.setBlockAtWorldCoord(value, woco);
        }
    }
Exemplo n.º 16
0
    public void addColumn(Column column, int handyInt, NoiseCoord nco)
    {
        int index = columns.IndexOf(column);

        if (index >= 0)
        {
            Column col = columns[index];
            col.handyInteger = handyInt;             // column.handyInteger;
            col.noiseCoord   = nco;
            columns[index]   = col;
        }
        else
        {
            column.noiseCoord   = nco;
            column.handyInteger = handyInt;
            columns.Add(column);
        }
//		if (!columns.Contains(column))
//			columns.Add(column);
    }
Exemplo n.º 17
0
    public void destroyPatchAt(NoiseCoord nco)
    {
        if (m_noisePatches.ContainsKey(nco))
        {
            NoisePatch npToDestroy = m_noisePatches[nco];
            if (npToDestroy.hasStarted || !npToDestroy.IsDone)
            {
                return;
            }

            bool destroyed = m_noisePatches.Remove(nco);

            if (!destroyed)
            {
                throw new Exception("failed to destroy..." + nco.toString());
            }
        }
        else
        {
            b.bug("we don't have the key: " + nco.toString());
        }
    }
Exemplo n.º 18
0
    public static void drawDebugCubesForAllCreatedNoisePatches(NoiseCoord currentTargetedForCreationNoiseCo, Dictionary <NoiseCoord, NoisePatch> noisePatchDictionary)
    {
        if (!noisePatchDictionary.ContainsKey(currentTargetedForCreationNoiseCo))
        {
            return;
        }
        // current to be created n patch
        NoisePatch curTargeted = noisePatchDictionary[currentTargetedForCreationNoiseCo];

//		Color tarCol = curTargeted.generatedBlockAlready ? Color.gray : Color.yellow;
        Color tarCol = curTargeted.IsDone ? Color.gray : Color.yellow;

        tarCol = curTargeted.hasStarted ? new Color(.3f, 1f, .9f, 1f) : tarCol;

        //TODO: create a coroutine for getting rid of noisepatches that are far away?

        drawDebugLinesForNoisePatch(currentTargetedForCreationNoiseCo, tarCol);

        foreach (KeyValuePair <NoiseCoord, NoisePatch> npatch in noisePatchDictionary)
        {
            NoiseCoord nco = npatch.Key;
            if (NoiseCoord.Equal(nco, currentTargetedForCreationNoiseCo))
            {
                continue;
            }

            NoisePatch np  = npatch.Value;
            Color      col = np.hasStarted ? Color.magenta : Color.cyan;
            if (np.IsDone)
            {
                col = Color.green;
            }

            drawDebugLinesForNoisePatch(nco, col);
        }
    }
Exemplo n.º 19
0
 public static Coord WorldCoordFromNoiseCoord(NoiseCoord nCo)
 {
     return(new Coord(nCo.x, 0, nCo.z) * NoisePatch.patchDimensions);
 }
Exemplo n.º 20
0
 public bool Equals(Column other)
 {
     return(this.range.start == other.range.start && this.range.range == other.range.range && PTwo.Equal(this.xz, other.xz) && NoiseCoord.Equal(this.noiseCoord, other.noiseCoord));
 }
Exemplo n.º 21
0
 public void startTrackingDiscontinuityWithRanges(List <Range1D> heightRangesAtCoord, PTwo patchRelCoord, NoiseCoord noiseCoord)
 {
     //check whether there's discontinuity here
 }
Exemplo n.º 22
0
    static Coord worldCoordForNoiseCoord(NoiseCoord nco)
    {
        int blocksPerPatch = (int)(NoisePatch.CHUNKDIMENSION * ChunkManager.CHUNKLENGTH);

        return(new Coord(nco * blocksPerPatch));
    }
Exemplo n.º 23
0
    // TODO: rewrite to return just one far away nco?
    public List <NoiseCoord> furthestNoiseCoords()
    {
        List <NoiseCoord> result = new List <NoiseCoord>();

        if (domain.dimensions.s < 3 || domain.dimensions.t < 3)
        {
            return(result);
        }

        List <PTwo> pCoords = CoordUtil.PointsJustInsideBorderOfQuad(this.domain);
        NoiseCoord  nco;

        foreach (PTwo point in pCoords)
        {
            nco = NoiseCoord.NoiseCoordWithPTwo(point);
            if (m_noisePatches.ContainsKey(nco))
            {
                result.Add(nco);
            }
        }

        if (result.Count == 0)
        {
            //trim
            domain.origin     += new PTwo(1);
            domain.dimensions -= new PTwo(1);
        }

        return(result);

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

        NoiseCoord xnudge = new NoiseCoord(1, 0);
        NoiseCoord znudge = new NoiseCoord(0, 1);

        //mins (traverse min edge of domain on the z and x sides until we find a coord contained in noisePatches)
        if (m_noisePatches.ContainsKey(NoiseCoord.NoiseCoordWithPTwo(domain.origin)))
        {
            result.Add(NoiseCoord.NoiseCoordWithPTwo(domain.origin));
        }
        else
        {
            // xmin z
            NoiseCoord xminz = NoiseCoord.NoiseCoordWithPTwo(domain.origin);
            while (xminz.z < domain.extent().t)
            {
                xminz += znudge;
                if (m_noisePatches.ContainsKey(xminz))
                {
                    result.Add(xminz);
                    break;
                }
                if (xminz.z == domain.extent().t - 1)
                {
                    domain.origin.s++;
                    domain.dimensions.s--;
                }
            }
            NoiseCoord zminx = NoiseCoord.NoiseCoordWithPTwo(domain.origin);
            while (zminx.x < domain.extent().s)
            {
                zminx += xnudge;
                if (m_noisePatches.ContainsKey(zminx))
                {
                    result.Add(zminx);
                    break;
                }
                if (zminx.x == domain.extent().s - 1)
                {
                    domain.origin.t++;
                    domain.dimensions.t--;
                }
            }
        }

        //maxes
        NoiseCoord extentCoord = NoiseCoord.NoiseCoordWithPTwo(domain.extent());

        if (m_noisePatches.ContainsKey(extentCoord))
        {
            result.Add(extentCoord);
        }
        else
        {
            NoiseCoord xmaxz = extentCoord;
            while (xmaxz.z >= domain.origin.t)
            {
                xmaxz -= znudge;
                if (m_noisePatches.ContainsKey(xmaxz))
                {
                    result.Add(xmaxz);
                    break;
                }
                if (xmaxz.z == domain.origin.t)
                {
                    domain.dimensions.s--;
                }
            }

            NoiseCoord zmaxx = extentCoord;
            while (zmaxx.x >= domain.origin.s)
            {
                zmaxx -= xnudge;
                if (m_noisePatches.ContainsKey(zmaxx))
                {
                    result.Add(zmaxx);
                    break;
                }
                if (zmaxx.x == domain.origin.s)
                {
                    domain.dimensions.t--;
                }
            }
        }

        return(result);
    }
Exemplo n.º 24
0
 static void drawDebugLinesForNoisePatch(NoiseCoord nco, Color col)
 {
     drawDebugLinesForNoisePatch(nco, col, 3);
 }
Exemplo n.º 25
0
 public Coord(NoiseCoord nco)
 {
     x = nco.x; y = 0; z = nco.z;
 }
Exemplo n.º 26
0
 public static Coord WorldCoordFromNoiseCoordAndPatchRelativeOffset(NoiseCoord nco, Coord offset)
 {
     return(CoordUtil.WorldCoordFromNoiseCoord(nco) + offset);
 }
Exemplo n.º 27
0
 public static Coord WorldRelativeChunkCoordForNoiseCoord(NoiseCoord nco)
 {
     return(new Coord(nco.x * NoisePatch.CHUNKDIMENSION, 0, nco.z * NoisePatch.CHUNKDIMENSION));
 }
Exemplo n.º 28
0
 public LightColumnCalculator(NoisePatch npatch)
 {
     m_noisePatch          = npatch;
     debugOrigNoiseCoord   = m_noisePatch.coord;
     this.m_lightColumnMap = new LightColumnMap(this);
 }
Exemplo n.º 29
0
 public static PTwo PTwoXZFromNoiseCoord(NoiseCoord nco)
 {
     return(new PTwo(nco.x, nco.z));
 }
Exemplo n.º 30
0
    /*
     * Clients use this to:
     * update the window map to reflect changed
     * height ranges which were (potentially) already set (but possibly no longer valid) in windows
     *
     */
    public void updateWindowsWithHeightRanges(List <Range1D> heightRanges, int x, int z, SurroundingSurfaceValues ssvs)
    {
//		m_lightColumnCalculator.updateWindowsWithHeightRangesAndUpdateLight(heightRanges, x, z, ssvs, -1, false);
        return;

        //reset column
        clearColumnAt(x, z);

        // re-add ranges
        for (int j = 1; j < heightRanges.Count; ++j)
        {
            addDiscontinuityWith(heightRanges[j], heightRanges[j - 1], x, z, ssvs, true, true);
        }

        if (windows[x] == null)
        {
            return;
        }

        //WINDOW MAINTENANCE
        List <Window> wins = windows[x];
        Window        win  = null;

        //TRIM EDGES
        for (int i = 0; i < wins.Count; ++i)
        {
            win = wins[i];

            win.assertSpansAreSaneDebug("bfr trim domain");             //DBG

            // trim edges of windows if needed
            // at extent
            if (win.trimDomain())
            {
                // check whether we should remove the window
                if (win.spanRange <= 0)
                {
                    wins.RemoveAt(i);
                    --i;
                }
            }
        }

        for (int i = 0; i < wins.Count; ++i)
        {
            // split windows at z if needed
            win = wins[i];

            if (win.spanContainsZ(z))
            {
                List <Window> posSideWindows = win.splitAtZ(z);

                if (posSideWindows != null)
                {
                    int count = 0;
                    foreach (Window posSideWin in posSideWindows)                    //MAX COUNT: 2
                    {
                        posSideWin.assertSpansAreSaneDebug("pos side win ");         //DBG

                        count++;
                        wins.Insert(i + count, posSideWin);
                    }
                    i += count;
                }

                win.assertSpansAreSaneDebug("after done splitting win (wMAP)");                 //DBG
            }
        }


        //DEBUG
        if (NoiseCoord.Equal(this.m_noisePatch.coord, new NoiseCoord(0, 0)))
        {
            debugAllWindowHeightColumns();
        }
    }