Changeset 10902

Timestamp:
Jan 12, 2012, 1:51:10 PM (13 years ago)
Author:
philip
Message:

Rename CELL_SIZE to TERRAIN_TILE_SIZE, to free up the term "cell" for other concepts.

Location:
ps/trunk/source
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/graphics/Camera.cpp

    r10593 r10902  
    234234    if (gotWater)
    235235    {
    236         waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*CELL_SIZE));
    237         waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*CELL_SIZE));
     236        waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*_SIZE));
     237        waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*_SIZE));
    238238    }
    239239
     
    312312    if (gotWater)
    313313    {
    314         waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*CELL_SIZE));
    315         waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*CELL_SIZE));
     314        waterPoint.X = clamp(waterPoint.X, 0.f, (float)((mapSize-1)*_SIZE));
     315        waterPoint.Z = clamp(waterPoint.Z, 0.f, (float)((mapSize-1)*_SIZE));
    316316    }
    317317
  • ps/trunk/source/graphics/Decal.cpp

    r10593 r10902  
    4141    corner3 = GetTransform().Transform(corner3);
    4242
    43     i0 = floor(std::min(std::min(corner0.X, corner1.X), std::min(corner2.X, corner3.X)) / CELL_SIZE);
    44     j0 = floor(std::min(std::min(corner0.Z, corner1.Z), std::min(corner2.Z, corner3.Z)) / CELL_SIZE);
    45     i1 = ceil(std::max(std::max(corner0.X, corner1.X), std::max(corner2.X, corner3.X)) / CELL_SIZE);
    46     j1 = ceil(std::max(std::max(corner0.Z, corner1.Z), std::max(corner2.Z, corner3.Z)) / CELL_SIZE);
     43    i0 = floor(std::min(std::min(corner0.X, corner1.X), std::min(corner2.X, corner3.X)) / _SIZE);
     44    j0 = floor(std::min(std::min(corner0.Z, corner1.Z), std::min(corner2.Z, corner3.Z)) / _SIZE);
     45    i1 = ceil(std::max(std::max(corner0.X, corner1.X), std::max(corner2.X, corner3.X)) / _SIZE);
     46    j1 = ceil(std::max(std::max(corner0.Z, corner1.Z), std::max(corner2.Z, corner3.Z)) / _SIZE);
    4747
    4848    i0 = clamp(i0, (ssize_t)0, m_Terrain->GetVerticesPerSide()-1);
  • ps/trunk/source/graphics/GameView.cpp

    r10865 r10902  
    6262// Maximum distance outside the edge of the map that the camera's
    6363// focus point can be moved
    64 static const float CAMERA_EDGE_MARGIN = 2.0f*CELL_SIZE;
     64static const float CAMERA_EDGE_MARGIN = 2.0f*_SIZE;
    6565
    6666/**
  • ps/trunk/source/graphics/HFTracer.cpp

    r10593 r10902  
    4141    m_Heightfield(m_pTerrain->GetHeightMap()),
    4242    m_MapSize(m_pTerrain->GetVerticesPerSide()),
    43     m_CellSize((float)CELL_SIZE),
     43    m_CellSize((float)_SIZE),
    4444    m_HeightScale(HEIGHT_SCALE)
    4545{
  • ps/trunk/source/graphics/LOSTexture.cpp

    r9889 r10902  
    136136        //     onto texcoord ((mapsize-0.5) / texsize, (mapsize-0.5) / texsize)  (i.e. middle of last texel)
    137137
    138         float s = (m_MapSize-1) / (float)(m_TextureSize * (m_MapSize-1) * CELL_SIZE);
     138        float s = (m_MapSize-1) / (float)(m_TextureSize * (m_MapSize-1) * _SIZE);
    139139        float t = 0.5f / m_TextureSize;
    140140        m_TextureMatrix.SetZero();
  • ps/trunk/source/graphics/Terrain.cpp

    r10593 r10902  
    113113    ssize_t hj = clamp(j, (ssize_t)0, m_MapSize-1);
    114114    u16 height = m_Heightmap[hj*m_MapSize + hi];
    115     pos.X = float(i*CELL_SIZE);
     115    pos.X = float(i*_SIZE);
    116116    pos.Y = float(height*HEIGHT_SCALE);
    117     pos.Z = float(j*CELL_SIZE);
     117    pos.Z = float(j*_SIZE);
    118118}
    119119
     
    125125    ssize_t hj = clamp(j, (ssize_t)0, m_MapSize-1);
    126126    u16 height = m_Heightmap[hj*m_MapSize + hi];
    127     pos.X = fixed::FromInt(i) * (int)CELL_SIZE;
     127    pos.X = fixed::FromInt(i) * (int)_SIZE;
    128128    pos.Y = fixed::FromInt(height) / (int)HEIGHT_UNITS_PER_METRE;
    129     pos.Z = fixed::FromInt(j) * (int)CELL_SIZE;
     129    pos.Z = fixed::FromInt(j) * (int)_SIZE;
    130130}
    131131
     
    227227{
    228228    // Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1)
    229     const ssize_t xi = clamp((ssize_t)floor(x/CELL_SIZE), (ssize_t)0, m_MapSize-2);
    230     const ssize_t zi = clamp((ssize_t)floor(z/CELL_SIZE), (ssize_t)0, m_MapSize-2);
    231 
    232     const float xf = clamp(x/CELL_SIZE-xi, 0.0f, 1.0f);
    233     const float zf = clamp(z/CELL_SIZE-zi, 0.0f, 1.0f);
     229    const ssize_t xi = clamp((ssize_t)floor(x/_SIZE), (ssize_t)0, m_MapSize-2);
     230    const ssize_t zi = clamp((ssize_t)floor(z/_SIZE), (ssize_t)0, m_MapSize-2);
     231
     232    const float xf = clamp(x/_SIZE-xi, 0.0f, 1.0f);
     233    const float zf = clamp(z/_SIZE-zi, 0.0f, 1.0f);
    234234
    235235    float h00 = m_Heightmap[zi*m_MapSize + xi];
     
    246246        {
    247247            // Lower-left triangle (don't use h11)
    248             return -CVector3D(CELL_SIZE, (h10-h00)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h01-h00)*HEIGHT_SCALE, CELL_SIZE)).Normalized();
     248            return -CVector3D(_SIZE)).Normalized();
    249249        }
    250250        else
    251251        {
    252252            // Upper-right triangle (don't use h00)
    253             return -CVector3D(CELL_SIZE, (h11-h01)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h11-h10)*HEIGHT_SCALE, CELL_SIZE)).Normalized();
     253            return -CVector3D(_SIZE)).Normalized();
    254254        }
    255255    }
     
    259259        {
    260260            // Upper-left triangle (don't use h10)
    261             return -CVector3D(CELL_SIZE, (h11-h01)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h01-h00)*HEIGHT_SCALE, CELL_SIZE)).Normalized();
     261            return -CVector3D(_SIZE)).Normalized();
    262262        }
    263263        else
    264264        {
    265265            // Lower-right triangle (don't use h01)
    266             return -CVector3D(CELL_SIZE, (h10-h00)*HEIGHT_SCALE, 0).Cross(CVector3D(0, (h11-h10)*HEIGHT_SCALE, CELL_SIZE)).Normalized();
     266            return -CVector3D(_SIZE)).Normalized();
    267267        }
    268268    }
     
    328328
    329329    // Compute fractional slope (being careful to avoid intermediate overflows)
    330     return fixed::FromInt(delta / CELL_SIZE) / (int)HEIGHT_UNITS_PER_METRE;
     330    return fixed::FromInt(delta / _SIZE) / (int)HEIGHT_UNITS_PER_METRE;
    331331}
    332332
     
    334334{
    335335    // Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1)
    336     const ssize_t xi = clamp((ssize_t)floor(x/CELL_SIZE), (ssize_t)0, m_MapSize-2);
    337     const ssize_t zi = clamp((ssize_t)floor(z/CELL_SIZE), (ssize_t)0, m_MapSize-2);
    338 
    339     const float xf = clamp(x/CELL_SIZE-xi, 0.0f, 1.0f);
    340     const float zf = clamp(z/CELL_SIZE-zi, 0.0f, 1.0f);
     336    const ssize_t xi = clamp((ssize_t)floor(x/_SIZE), (ssize_t)0, m_MapSize-2);
     337    const ssize_t zi = clamp((ssize_t)floor(z/_SIZE), (ssize_t)0, m_MapSize-2);
     338
     339    const float xf = clamp(x/_SIZE-xi, 0.0f, 1.0f);
     340    const float zf = clamp(z/_SIZE-zi, 0.0f, 1.0f);
    341341
    342342    float h00 = m_Heightmap[zi*m_MapSize + xi];
     
    379379{
    380380    // Clamp to size-2 so we can use the tiles (xi,zi)-(xi+1,zi+1)
    381     const ssize_t xi = clamp((ssize_t)(x / (int)CELL_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);
    382     const ssize_t zi = clamp((ssize_t)(z / (int)CELL_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);
     381    const ssize_t xi = clamp((ssize_t)(x / (int)_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);
     382    const ssize_t zi = clamp((ssize_t)(z / (int)_SIZE).ToInt_RoundToZero(), (ssize_t)0, m_MapSize-2);
    383383
    384384    const fixed one = fixed::FromInt(1);
    385385
    386     const fixed xf = clamp((x / (int)CELL_SIZE) - fixed::FromInt(xi), fixed::Zero(), one);
    387     const fixed zf = clamp((z / (int)CELL_SIZE) - fixed::FromInt(zi), fixed::Zero(), one);
     386    const fixed xf = clamp((x / (int)_SIZE) - fixed::FromInt(xi), fixed::Zero(), one);
     387    const fixed zf = clamp((z / (int)_SIZE) - fixed::FromInt(zi), fixed::Zero(), one);
    388388
    389389    u16 h00 = m_Heightmap[zi*m_MapSize + xi];
     
    569569float CTerrain::FlattenArea(float x0, float x1, float z0, float z1)
    570570{
    571     const ssize_t tx0 = clamp(ssize_t(x0/CELL_SIZE),   (ssize_t)0, m_MapSize-1);
    572     const ssize_t tx1 = clamp(ssize_t(x1/CELL_SIZE)+1, (ssize_t)0, m_MapSize-1);
    573     const ssize_t tz0 = clamp(ssize_t(z0/CELL_SIZE),   (ssize_t)0, m_MapSize-1);
    574     const ssize_t tz1 = clamp(ssize_t(z1/CELL_SIZE)+1, (ssize_t)0, m_MapSize-1);
     571    const ssize_t tx0 = clamp(ssize_t(x0/_SIZE),   (ssize_t)0, m_MapSize-1);
     572    const ssize_t tx1 = clamp(ssize_t(x1/_SIZE)+1, (ssize_t)0, m_MapSize-1);
     573    const ssize_t tz0 = clamp(ssize_t(z0/_SIZE),   (ssize_t)0, m_MapSize-1);
     574    const ssize_t tz1 = clamp(ssize_t(z1/_SIZE)+1, (ssize_t)0, m_MapSize-1);
    575575
    576576    size_t count=0;
     
    646646
    647647    CBoundingBoxAligned bound;
    648     bound[0].X = (float)(i0*CELL_SIZE);
     648    bound[0].X = (float)(i0*_SIZE);
    649649    bound[0].Y = (float)(minH*HEIGHT_SCALE);
    650     bound[0].Z = (float)(j0*CELL_SIZE);
    651     bound[1].X = (float)(i1*CELL_SIZE);
     650    bound[0].Z = (float)(j0*_SIZE);
     651    bound[1].X = (float)(i1*_SIZE);
    652652    bound[1].Y = (float)(maxH*HEIGHT_SCALE);
    653     bound[1].Z = (float)(j1*CELL_SIZE);
     653    bound[1].Z = (float)(j1*_SIZE);
    654654    return bound;
    655655}
  • ps/trunk/source/graphics/Terrain.h

    r10593 r10902  
    3737
    3838/// metres [world space units] per tile in x and z
    39 const ssize_t CELL_SIZE = 4;
     39const ssize_t _SIZE = 4;
    4040
    4141/// number of u16 height units per metre
     
    7070    float GetMinX() const { return 0.0f; }
    7171    float GetMinZ() const { return 0.0f; }
    72     float GetMaxX() const { return (float)((m_MapSize-1) * CELL_SIZE); }
    73     float GetMaxZ() const { return (float)((m_MapSize-1) * CELL_SIZE); }
     72    float GetMaxX() const { return (float)((m_MapSize-1) * _SIZE); }
     73    float GetMaxZ() const { return (float)((m_MapSize-1) * _SIZE); }
    7474
    7575    bool IsOnMap(float x, float z) const
     
    114114    static void CalcFromPosition(const CVector3D& pos, ssize_t& i, ssize_t& j)
    115115    {
    116         i = (ssize_t)(pos.X/CELL_SIZE);
    117         j = (ssize_t)(pos.Z/CELL_SIZE);
     116        i = (ssize_t)(pos.X/_SIZE);
     117        j = (ssize_t)(pos.Z/_SIZE);
    118118    }
    119119    // calculate the vertex under a given position (rounding down coordinates)
    120120    static void CalcFromPosition(float x, float z, ssize_t& i, ssize_t& j)
    121121    {
    122         i = (ssize_t)(x/CELL_SIZE);
    123         j = (ssize_t)(z/CELL_SIZE);
     122        i = (ssize_t)(x/_SIZE);
     123        j = (ssize_t)(z/_SIZE);
    124124    }
    125125    // calculate the normal at a given vertex
  • ps/trunk/source/graphics/TerritoryTexture.cpp

    r10083 r10902  
    119119        //     onto texcoord (mapsize / texsize, mapsize / texsize)  (i.e. top-right of last texel)
    120120
    121         float s = 1.f / (float)(m_TextureSize * CELL_SIZE);
     121        float s = 1.f / (float)(m_TextureSize * _SIZE);
    122122        float t = 0.f;
    123123        m_TextureMatrix.SetZero();
  • ps/trunk/source/graphics/tests/test_Terrain.h

    r7497 r10902  
    4343        SetVertex(terrain, 0, 1, 100);
    4444        SetVertex(terrain, 0, 2, 100);
    45         SetVertex(terrain, 1, 0, 100 + CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    46         SetVertex(terrain, 1, 1, 100 + CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    47         SetVertex(terrain, 1, 2, 100 + CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    48         SetVertex(terrain, 2, 0, 100 + 2*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    49         SetVertex(terrain, 2, 1, 100 + 2*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    50         SetVertex(terrain, 2, 2, 100 + 2*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    51         SetVertex(terrain, 3, 0, 100 + 2*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    52         SetVertex(terrain, 3, 1, 100 + 2*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    53         SetVertex(terrain, 3, 2, 100 + 2*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
     45        SetVertex(terrain, 1, 0, 100 + _SIZE*HEIGHT_UNITS_PER_METRE);
     46        SetVertex(terrain, 1, 1, 100 + _SIZE*HEIGHT_UNITS_PER_METRE);
     47        SetVertex(terrain, 1, 2, 100 + _SIZE*HEIGHT_UNITS_PER_METRE);
     48        SetVertex(terrain, 2, 0, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE);
     49        SetVertex(terrain, 2, 1, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE);
     50        SetVertex(terrain, 2, 2, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE);
     51        SetVertex(terrain, 3, 0, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE);
     52        SetVertex(terrain, 3, 1, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE);
     53        SetVertex(terrain, 3, 2, 100 + 2*_SIZE*HEIGHT_UNITS_PER_METRE);
    5454
    5555    }
     
    5757    void SetHighPlateau(CTerrain& terrain, int height)
    5858    {
    59         SetVertex(terrain, 4, 0, 100 + height*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    60         SetVertex(terrain, 4, 1, 100 + height*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    61         SetVertex(terrain, 4, 2, 100 + height*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    62         SetVertex(terrain, 5, 0, 100 + height*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    63         SetVertex(terrain, 5, 1, 100 + height*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
    64         SetVertex(terrain, 5, 2, 100 + height*CELL_SIZE*HEIGHT_UNITS_PER_METRE);
     59        SetVertex(terrain, 4, 0, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE);
     60        SetVertex(terrain, 4, 1, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE);
     61        SetVertex(terrain, 4, 2, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE);
     62        SetVertex(terrain, 5, 0, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE);
     63        SetVertex(terrain, 5, 1, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE);
     64        SetVertex(terrain, 5, 2, 100 + height*_SIZE*HEIGHT_UNITS_PER_METRE);
    6565    }
    6666
     
    7575        float ground;
    7676
    77         ground = terrain.GetExactGroundLevel(0.f, 1.5f*CELL_SIZE);
     77        ground = terrain.GetExactGroundLevel(0.f, 1.5f*_SIZE);
    7878        TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE, 0.01f);
    7979
    80         ground = terrain.GetExactGroundLevel(0.5f*CELL_SIZE, 1.5f*CELL_SIZE);
    81         TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+0.5f*CELL_SIZE, 0.01f);
    82 
    83         ground = terrain.GetExactGroundLevel(1.5f*CELL_SIZE, 1.5f*CELL_SIZE);
    84         TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+1.5f*CELL_SIZE, 0.01f);
    85 
    86         ground = terrain.GetExactGroundLevel(2.5f*CELL_SIZE, 1.5f*CELL_SIZE);
    87         TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+2.f*CELL_SIZE, 0.01f);
    88 
    89         ground = terrain.GetExactGroundLevel(3.5f*CELL_SIZE, 1.5f*CELL_SIZE);
    90         TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+11.f*CELL_SIZE, 0.01f);
    91 
    92         ground = terrain.GetExactGroundLevel(4.5f*CELL_SIZE, 1.5f*CELL_SIZE);
    93         TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+20.f*CELL_SIZE, 0.01f);
     80        ground = terrain.GetExactGroundLevel(0.5f*_SIZE);
     81        TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+0.5f*_SIZE, 0.01f);
     82
     83        ground = terrain.GetExactGroundLevel(1.5f*_SIZE);
     84        TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+1.5f*_SIZE, 0.01f);
     85
     86        ground = terrain.GetExactGroundLevel(2.5f*_SIZE);
     87        TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+2.f*_SIZE, 0.01f);
     88
     89        ground = terrain.GetExactGroundLevel(3.5f*_SIZE);
     90        TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+11.f*_SIZE, 0.01f);
     91
     92        ground = terrain.GetExactGroundLevel(4.5f*_SIZE);
     93        TS_ASSERT_DELTA(ground, 100.f/HEIGHT_UNITS_PER_METRE+20.f*_SIZE, 0.01f);
    9494    }
    9595
     
    105105        fixed ground;
    106106
    107         ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.f), fixed::FromFloat(1.5f*CELL_SIZE));
     107        ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.f), fixed::FromFloat(1.5f*_SIZE));
    108108        TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE, maxDelta);
    109109
    110         ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.5f*CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));
    111         TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+0.5*CELL_SIZE, maxDelta);
    112 
    113         ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(1.5f*CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));
    114         TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+1.5*CELL_SIZE, maxDelta);
    115 
    116         ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(2.5f*CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));
    117         TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+2.0*CELL_SIZE, maxDelta);
    118 
    119         ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(3.5f*CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));
    120         TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+11.0*CELL_SIZE, maxDelta);
    121 
    122         ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(4.5f*CELL_SIZE), fixed::FromFloat(1.5f*CELL_SIZE));
    123         TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+20.0*CELL_SIZE, maxDelta);
     110        ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(0.5f*_SIZE));
     111        TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+0.5*_SIZE, maxDelta);
     112
     113        ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(1.5f*_SIZE));
     114        TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+1.5*_SIZE, maxDelta);
     115
     116        ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(2.5f*_SIZE));
     117        TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+2.0*_SIZE, maxDelta);
     118
     119        ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(3.5f*_SIZE));
     120        TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+11.0*_SIZE, maxDelta);
     121
     122        ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(4.5f*_SIZE));
     123        TS_ASSERT_DELTA(ground.ToDouble(), 100.0/HEIGHT_UNITS_PER_METRE+20.0*_SIZE, maxDelta);
    124124    }
    125125
     
    140140            for (int xi = 0; xi < p; ++xi)
    141141            {
    142                 fixed ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(xi/(float)p*CELL_SIZE), fixed::FromFloat(zi/(float)p*CELL_SIZE));
     142                fixed ground = terrain.GetExactGroundLevelFixed(fixed::FromFloat(xi/(float)p*_SIZE));
    143143                TS_ASSERT_DELTA(ground.ToDouble(), 65535.0/HEIGHT_UNITS_PER_METRE, maxDelta);
    144144            }
     
    232232        EXPECT_DIRTY(false, 2, 2);
    233233
    234         terrain.FlattenArea(PATCH_SIZE*CELL_SIZE, 2*PATCH_SIZE*CELL_SIZE, PATCH_SIZE*CELL_SIZE+1, 2*PATCH_SIZE*CELL_SIZE-1);
     234        terrain.FlattenArea(PATCH_SIZE*_SIZE-1);
    235235
    236236        EXPECT_DIRTY(true, 0, 0);
  • ps/trunk/source/gui/MiniMap.cpp

    r10704 r10902  
    150150
    151151    // Scale world coordinates for shrunken square map
    152     x = CELL_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5);
    153     z = CELL_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5);
     152    x = _SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5);
     153    z = _SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5);
    154154}
    155155
     
    207207        float px=hitPt[i].X;
    208208        float pz=hitPt[i].Z;
    209         ViewRect[i][0]=(m_CachedActualSize.GetWidth()*px/float(CELL_SIZE*m_MapSize));
    210         ViewRect[i][1]=(m_CachedActualSize.GetHeight()*pz/float(CELL_SIZE*m_MapSize));
     209        ViewRect[i][0]=(m_CachedActualSize.GetWidth()*px/float(_SIZE*m_MapSize));
     210        ViewRect[i][1]=(m_CachedActualSize.GetHeight()*pz/float(_SIZE*m_MapSize));
    211211    }
    212212
     
    373373    glPointSize(3.f);
    374374
    375     float sx = (float)m_Width / ((m_MapSize - 1) * CELL_SIZE);
    376     float sy = (float)m_Height / ((m_MapSize - 1) * CELL_SIZE);
     375    float sx = (float)m_Width / ((m_MapSize - 1) * _SIZE);
     376    float sy = (float)m_Height / ((m_MapSize - 1) * _SIZE);
    377377
    378378    CSimulation2::InterfaceList ents = sim->GetEntitiesWithInterface(IID_Minimap);
  • ps/trunk/source/renderer/PatchRData.cpp

    r10466 r10902  
    11251125
    11261126            // Move a bit towards the center of the tile
    1127             pos.X += CELL_SIZE/4.f;
    1128             pos.Z += CELL_SIZE/4.f;
     1127            pos.X += _SIZE/4.f;
     1128            pos.Z += _SIZE/4.f;
    11291129
    11301130            float x, y;
  • ps/trunk/source/simulation2/components/CCmpFootprint.cpp

    r10017 r10902  
    2727#include "simulation2/components/ICmpUnitMotion.h"
    2828#include "simulation2/MessageTypes.h"
    29 #include "graphics/Terrain.h"   // For CELL_SIZE
     29#include "graphics/Terrain.h"   // For _SIZE
    3030#include "maths/FixedVector2D.h"
    3131
     
    172172            {
    173173                // The spawn point should be far enough from this footprint to fit the unit, plus a little gap
    174                 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)CELL_SIZE*dist);
     174                entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)_SIZE*dist);
    175175                entity_pos_t radius = m_Size0 + clearance;
    176176
     
    201201            {
    202202                // The spawn point should be far enough from this footprint to fit the unit, plus a little gap
    203                 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)CELL_SIZE*dist);
     203                entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)_SIZE*dist);
    204204
    205205                for (i32 edge = 0; edge < 4; ++edge)
  • ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp

    r10017 r10902  
    228228        // Use 8x8 tile subdivisions
    229229        // (TODO: find the optimal number instead of blindly guessing)
    230         m_UnitSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8*CELL_SIZE));
    231         m_StaticSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8*CELL_SIZE));
     230        m_UnitSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8*_SIZE));
     231        m_StaticSubdivision.Reset(x1, z1, entity_pos_t::FromInt(8*_SIZE));
    232232
    233233        for (std::map<u32, UnitShape>::iterator it = m_UnitShapes.begin(); it != m_UnitShapes.end(); ++it)
     
    691691static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h)
    692692{
    693     i = (u16)clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, w-1);
    694     j = (u16)clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, h-1);
     693    i = (u16)clamp((x / (int)_SIZE).ToInt_RoundToZero(), 0, w-1);
     694    j = (u16)clamp((z / (int)_SIZE).ToInt_RoundToZero(), 0, h-1);
    695695}
    696696
     
    700700static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z)
    701701{
    702     x = entity_pos_t::FromInt(i*(int)CELL_SIZE + (int)CELL_SIZE/2);
    703     z = entity_pos_t::FromInt(j*(int)CELL_SIZE + (int)CELL_SIZE/2);
     702    x = entity_pos_t::FromInt(i*(int)_SIZE/2);
     703    z = entity_pos_t::FromInt(j*(int)_SIZE/2);
    704704}
    705705
     
    724724    // free space between buildings when there isn't. But this is just a random guess
    725725    // and needs to be tweaked until everything works nicely.
    726     //entity_pos_t expandPathfinding = entity_pos_t::FromInt(CELL_SIZE / 2);
     726    //entity_pos_t expandPathfinding = entity_pos_t::FromInt(_SIZE / 2);
    727727    // Actually that's bad because units get stuck when the A* pathfinder thinks they're
    728728    // blocked on all sides, so it's better to underestimate
     
    732732    // potentially-obstructed tiles (so we don't blindly build on top of an obstruction),
    733733    // so we need to expand by at least 1/sqrt(2) of a tile
    734     entity_pos_t expandFoundation = (entity_pos_t::FromInt(CELL_SIZE) * 3) / 4;
     734    entity_pos_t expandFoundation = (entity_pos_t::FromInt(_SIZE) * 3) / 4;
    735735
    736736    for (std::map<u32, StaticShape>::iterator it = m_StaticShapes.begin(); it != m_StaticShapes.end(); ++it)
  • ps/trunk/source/simulation2/components/CCmpPathfinder.cpp

    r10017 r10902  
    712712        return false;
    713713
    714     // Expand bounds by 1/sqrt(2) tile (multiply by CELL_SIZE since we want world coordinates)
    715     entity_pos_t expand = entity_pos_t::FromInt(2).Sqrt().Multiply(entity_pos_t::FromInt(CELL_SIZE / 2));
     714    // Expand bounds by 1/sqrt(2) tile (multiply by _SIZE since we want world coordinates)
     715    entity_pos_t expand = entity_pos_t::FromInt(2).Sqrt().Multiply(entity_pos_t::FromInt(_SIZE / 2));
    716716    CFixedVector2D halfSize(square.hw + expand, square.hh + expand);
    717717    CFixedVector2D halfBound = Geometry::GetHalfBoundingBox(square.u, square.v, halfSize);
  • ps/trunk/source/simulation2/components/CCmpPathfinder_Common.h

    r10017 r10902  
    278278    void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j)
    279279    {
    280         i = (u16)clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
    281         j = (u16)clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
     280        i = (u16)clamp((x / (int)_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
     281        j = (u16)clamp((z / (int)_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
    282282    }
    283283
     
    287287    static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z)
    288288    {
    289         x = entity_pos_t::FromInt(i*(int)CELL_SIZE + (int)CELL_SIZE/2);
    290         z = entity_pos_t::FromInt(j*(int)CELL_SIZE + (int)CELL_SIZE/2);
     289        x = entity_pos_t::FromInt(i*(int)_SIZE/2);
     290        z = entity_pos_t::FromInt(j*(int)_SIZE/2);
    291291    }
    292292
  • ps/trunk/source/simulation2/components/CCmpPathfinder_Tile.cpp

    r10846 r10902  
    219219    // Allow tiles slightly more than sqrt(2) from the actual goal,
    220220    // i.e. adjacent diagonally to the target tile
    221     fixed tolerance = entity_pos_t::FromInt(CELL_SIZE*3/2);
     221    fixed tolerance = entity_pos_t::FromInt(_SIZE*3/2);
    222222
    223223    entity_pos_t x, z;
     
    388388    // otherwise just aim at the center point. (We'll never try moving outwards to a square shape.)
    389389    if (goal.type == Goal::CIRCLE)
    390         state.rGoal = (u16)(goal.hw / (int)CELL_SIZE).ToInt_RoundToZero();
     390        state.rGoal = (u16)(goal.hw / (int)_SIZE).ToInt_RoundToZero();
    391391    else
    392392        state.rGoal = 0;
  • ps/trunk/source/simulation2/components/CCmpPathfinder_Vertex.cpp

    r10790 r10902  
    383383                if (any)
    384384                {
    385                     CFixedVector2D v0 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);
    386                     CFixedVector2D v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
     385                    CFixedVector2D v0 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) - r);
     386                    CFixedVector2D v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) + r);
    387387                    Edge e = { v0, v1 };
    388388                    edgesAA.push_back(e);
     
    410410        case TileEdge::BOTTOM:
    411411        {
    412             v0 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);
    413             v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt(j * (int)CELL_SIZE) - r);
     412            v0 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) - r);
     413            v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) - r);
    414414            vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert);
    415415            vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert);
     
    418418        case TileEdge::TOP:
    419419        {
    420             v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
    421             v1 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
     420            v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) + r);
     421            v1 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) + r);
    422422            vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert);
    423423            vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert);
     
    426426        case TileEdge::LEFT:
    427427        {
    428             v0 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
    429             v1 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);
     428            v0 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) + r);
     429            v1 = CFixedVector2D(fixed::FromInt(i * (int)_SIZE) - r);
    430430            vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert);
    431431            vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert);
     
    434434        case TileEdge::RIGHT:
    435435        {
    436             v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt(j * (int)CELL_SIZE) - r);
    437             v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
     436            v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) - r);
     437            v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)_SIZE) + r);
    438438            vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert);
    439439            vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert);
  • ps/trunk/source/simulation2/components/CCmpProjectileManager.cpp

    r10593 r10902  
    339339    {
    340340        // Don't display projectiles outside the visible area
    341         ssize_t posi = (ssize_t)(0.5f + m_Projectiles[i].pos.X / CELL_SIZE);
    342         ssize_t posj = (ssize_t)(0.5f + m_Projectiles[i].pos.Z / CELL_SIZE);
     341        ssize_t posi = (ssize_t)(0.5f + m_Projectiles[i].pos.X / _SIZE);
     342        ssize_t posj = (ssize_t)(0.5f + m_Projectiles[i].pos.Z / _SIZE);
    343343        if (!losRevealAll && !los.IsVisible(posi, posj))
    344344            continue;
  • ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp

    r10822 r10902  
    832832    for(std::vector<CVector2D>::iterator it = coords.begin(); it != coords.end();)
    833833    {
    834         int i = (fixed::FromFloat(it->X) / (int)CELL_SIZE).ToInt_RoundToNearest();
    835         int j = (fixed::FromFloat(it->Y) / (int)CELL_SIZE).ToInt_RoundToNearest();
     834        int i = (fixed::FromFloat(it->X) / (int)_SIZE).ToInt_RoundToNearest();
     835        int j = (fixed::FromFloat(it->Y) / (int)_SIZE).ToInt_RoundToNearest();
    836836
    837837        bool explored = losQuerier.IsExplored(i, j);
     
    957957
    958958    bool lastVisible = losQuerier.IsExplored(
    959         (fixed::FromFloat(m_Path[0].X) / (int) CELL_SIZE).ToInt_RoundToNearest(),
    960         (fixed::FromFloat(m_Path[0].Y) / (int) CELL_SIZE).ToInt_RoundToNearest()
     959        (fixed::FromFloat(m_Path[0].X) / (int) _SIZE).ToInt_RoundToNearest(),
     960        (fixed::FromFloat(m_Path[0].Y) / (int) _SIZE).ToInt_RoundToNearest()
    961961    );
    962962    size_t curSegmentStartIndex = 0; // starting node index of the current segment
     
    965965    {
    966966        // grab tile indices for this coord
    967         int i = (fixed::FromFloat(m_Path[k].X) / (int)CELL_SIZE).ToInt_RoundToNearest();
    968         int j = (fixed::FromFloat(m_Path[k].Y) / (int)CELL_SIZE).ToInt_RoundToNearest();
     967        int i = (fixed::FromFloat(m_Path[k].X) / (int)_SIZE).ToInt_RoundToNearest();
     968        int j = (fixed::FromFloat(m_Path[k].Y) / (int)_SIZE).ToInt_RoundToNearest();
    969969
    970970        bool nodeVisible = losQuerier.IsExplored(i, j);
  • ps/trunk/source/simulation2/components/CCmpRangeManager.cpp

    r10846 r10902  
    504504        // Use 8x8 tile subdivisions
    505505        // (TODO: find the optimal number instead of blindly guessing)
    506         m_Subdivision.Reset(x1, z1, entity_pos_t::FromInt(8*CELL_SIZE));
     506        m_Subdivision.Reset(x1, z1, entity_pos_t::FromInt(8*_SIZE));
    507507
    508508        for (std::map<entity_id_t, EntityData>::const_iterator it = m_EntityData.begin(); it != m_EntityData.end(); ++it)
     
    884884        CFixedVector2D pos = cmpPosition->GetPosition2D();
    885885
    886         int i = (pos.X / (int)CELL_SIZE).ToInt_RoundToNearest();
    887         int j = (pos.Y / (int)CELL_SIZE).ToInt_RoundToNearest();
     886        int i = (pos.X / (int)_SIZE).ToInt_RoundToNearest();
     887        int j = (pos.Y / (int)_SIZE).ToInt_RoundToNearest();
    888888
    889889        // Reveal flag makes all positioned entities visible
     
    10911091        // Compute top/bottom coordinates, and clamp to exclude the 1-tile border around the map
    10921092        // (so that we never render the sharp edge of the map)
    1093         i32 j0 = ((pos.Y - visionRange)/(int)CELL_SIZE).ToInt_RoundToInfinity();
    1094         i32 j1 = ((pos.Y + visionRange)/(int)CELL_SIZE).ToInt_RoundToNegInfinity();
     1093        i32 j0 = ((pos.Y - visionRange)/(int)_SIZE).ToInt_RoundToInfinity();
     1094        i32 j1 = ((pos.Y + visionRange)/(int)_SIZE).ToInt_RoundToNegInfinity();
    10951095        i32 j0clamp = std::max(j0, 1);
    10961096        i32 j1clamp = std::min(j1, m_TerrainVerticesPerSide-2);
    10971097
    10981098        // Translate world coordinates into fractional tile-space coordinates
    1099         entity_pos_t x = pos.X / (int)CELL_SIZE;
    1100         entity_pos_t y = pos.Y / (int)CELL_SIZE;
    1101         entity_pos_t r = visionRange / (int)CELL_SIZE;
     1099        entity_pos_t x = pos.X / (int)_SIZE;
     1100        entity_pos_t y = pos.Y / (int)_SIZE;
     1101        entity_pos_t r = visionRange / (int)_SIZE;
    11021102        entity_pos_t r2 = r.Square();
    11031103
     
    11761176        // and only have to touch tiles that have a net change.)
    11771177
    1178         i32 j0_from = ((from.Y - visionRange)/(int)CELL_SIZE).ToInt_RoundToInfinity();
    1179         i32 j1_from = ((from.Y + visionRange)/(int)CELL_SIZE).ToInt_RoundToNegInfinity();
    1180         i32 j0_to = ((to.Y - visionRange)/(int)CELL_SIZE).ToInt_RoundToInfinity();
    1181         i32 j1_to = ((to.Y + visionRange)/(int)CELL_SIZE).ToInt_RoundToNegInfinity();
     1178        i32 j0_from = ((from.Y - visionRange)/(int)_SIZE).ToInt_RoundToInfinity();
     1179        i32 j1_from = ((from.Y + visionRange)/(int)_SIZE).ToInt_RoundToNegInfinity();
     1180        i32 j0_to = ((to.Y - visionRange)/(int)_SIZE).ToInt_RoundToInfinity();
     1181        i32 j1_to = ((to.Y + visionRange)/(int)_SIZE).ToInt_RoundToNegInfinity();
    11821182        i32 j0clamp = std::max(std::min(j0_from, j0_to), 1);
    11831183        i32 j1clamp = std::min(std::max(j1_from, j1_to), m_TerrainVerticesPerSide-2);
    11841184
    1185         entity_pos_t x_from = from.X / (int)CELL_SIZE;
    1186         entity_pos_t y_from = from.Y / (int)CELL_SIZE;
    1187         entity_pos_t x_to = to.X / (int)CELL_SIZE;
    1188         entity_pos_t y_to = to.Y / (int)CELL_SIZE;
    1189         entity_pos_t r = visionRange / (int)CELL_SIZE;
     1185        entity_pos_t x_from = from.X / (int)_SIZE;
     1186        entity_pos_t y_from = from.Y / (int)_SIZE;
     1187        entity_pos_t x_to = to.X / (int)_SIZE;
     1188        entity_pos_t y_to = to.Y / (int)_SIZE;
     1189        entity_pos_t r = visionRange / (int)_SIZE;
    11901190        entity_pos_t r2 = r.Square();
    11911191
  • ps/trunk/source/simulation2/components/CCmpTerrain.cpp

    r10034 r10902  
    6969    {
    7070        CFixedVector3D normal;
    71         m_Terrain->CalcNormalFixed((x / (int)CELL_SIZE).ToInt_RoundToZero(), (z / (int)CELL_SIZE).ToInt_RoundToZero(), normal);
     71        m_Terrain->CalcNormalFixed((x / (int)_SIZE).ToInt_RoundToZero(), normal);
    7272        return normal;
    7373    }
     
    115115        {
    116116            cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(),
    117                     entity_pos_t::FromInt(tiles*(int)CELL_SIZE),
    118                     entity_pos_t::FromInt(tiles*(int)CELL_SIZE));
     117                    entity_pos_t::FromInt(tiles*(int)_SIZE),
     118                    entity_pos_t::FromInt(tiles*(int)_SIZE));
    119119        }
    120120
     
    123123        {
    124124            cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(),
    125                     entity_pos_t::FromInt(tiles*(int)CELL_SIZE),
    126                     entity_pos_t::FromInt(tiles*(int)CELL_SIZE),
     125                    entity_pos_t::FromInt(tiles*(int)_SIZE),
     126                    entity_pos_t::FromInt(tiles*(int)_SIZE),
    127127                    vertices);
    128128        }
  • ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp

    r10801 r10902  
    427427            CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), *eit);
    428428            CFixedVector2D pos = cmpPosition->GetPosition2D();
    429             u16 i = (u16)clamp((pos.X / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);
    430             u16 j = (u16)clamp((pos.Y / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);
     429            u16 i = (u16)clamp((pos.X / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);
     430            u16 j = (u16)clamp((pos.Y / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);
    431431
    432432            CmpPtr<ICmpTerritoryInfluence> cmpTerritoryInfluence(GetSimContext(), *eit);
    433433            u32 weight = cmpTerritoryInfluence->GetWeight();
    434             u32 radius = cmpTerritoryInfluence->GetRadius() / CELL_SIZE;
     434            u32 radius = cmpTerritoryInfluence->GetRadius() / _SIZE;
    435435            u32 falloff = weight / radius; // earlier check for GetRadius() == 0 prevents divide-by-zero
    436436
     
    484484
    485485        CFixedVector2D pos = cmpPosition->GetPosition2D();
    486         u16 i = (u16)clamp((pos.X / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);
    487         u16 j = (u16)clamp((pos.Y / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);
     486        u16 i = (u16)clamp((pos.X / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);
     487        u16 j = (u16)clamp((pos.Y / (int)_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);
    488488
    489489        u8 owner = (u8)cmpOwnership->GetOwner();
     
    539539static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h)
    540540{
    541     i = (u16)clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, w-1);
    542     j = (u16)clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, h-1);
     541    i = (u16)clamp((x / (int)_SIZE).ToInt_RoundToZero(), 0, w-1);
     542    j = (u16)clamp((z / (int)_SIZE).ToInt_RoundToZero(), 0, h-1);
    543543}
    544544
     
    548548static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z)
    549549{
    550     x = entity_pos_t::FromInt(i*(int)CELL_SIZE + (int)CELL_SIZE/2);
    551     z = entity_pos_t::FromInt(j*(int)CELL_SIZE + (int)CELL_SIZE/2);
     550    x = entity_pos_t::FromInt(i*(int)_SIZE/2);
     551    z = entity_pos_t::FromInt(j*(int)_SIZE/2);
    552552}
    553553
     
    640640                while (true)
    641641                {
    642                     points.push_back((CVector2D(ci, cj) + edgeOffsets[cdir]) * CELL_SIZE);
     642                    points.push_back((CVector2D(ci, cj) + edgeOffsets[cdir]) * _SIZE);
    643643
    644644                    // Given that we're on an edge on a continuous boundary and aiming anticlockwise,
  • ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp

    r10867 r10902  
    4444 * position (to minimise the effects of grid-constrained movement)
    4545 */
    46 static const entity_pos_t WAYPOINT_ADVANCE_MAX = entity_pos_t::FromInt(CELL_SIZE*8);
     46static const entity_pos_t WAYPOINT_ADVANCE_MAX = entity_pos_t::FromInt(_SIZE*8);
    4747
    4848/**
     
    5959 * smaller ranges might miss some legitimate routes around large obstacles.)
    6060 */
    61 static const entity_pos_t SHORT_PATH_SEARCH_RANGE = entity_pos_t::FromInt(CELL_SIZE*10);
     61static const entity_pos_t SHORT_PATH_SEARCH_RANGE = entity_pos_t::FromInt(_SIZE*10);
    6262
    6363/**
     
    6666 * (since it might be inside an obstacle).
    6767 */
    68 static const entity_pos_t SHORT_PATH_GOAL_RADIUS = entity_pos_t::FromInt(CELL_SIZE*3/2);
     68static const entity_pos_t SHORT_PATH_GOAL_RADIUS = entity_pos_t::FromInt(_SIZE*3/2);
    6969
    7070/**
     
    7272 * for it in a straight line instead of pathfinding.
    7373 */
    74 static const entity_pos_t DIRECT_PATH_RANGE = entity_pos_t::FromInt(CELL_SIZE*4);
     74static const entity_pos_t DIRECT_PATH_RANGE = entity_pos_t::FromInt(_SIZE*4);
    7575
    7676/**
     
    7979 * more than this distance from where we last pathed to.
    8080 */
    81 static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA = entity_pos_t::FromInt(CELL_SIZE*4);
     81static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA = entity_pos_t::FromInt(_SIZE*4);
    8282
    8383/**
     
    8787 * more than this distance from where we last pathed to.
    8888 */
    89 static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA_FORMATION = entity_pos_t::FromInt(CELL_SIZE*1);
     89static const entity_pos_t CHECK_TARGET_MOVEMENT_MIN_DELTA_FORMATION = entity_pos_t::FromInt(_SIZE*1);
    9090
    9191/**
     
    9494 * moved, until we get this close to the end of our old path.
    9595 */
    96 static const entity_pos_t CHECK_TARGET_MOVEMENT_AT_MAX_DIST = entity_pos_t::FromInt(CELL_SIZE*16);
     96static const entity_pos_t CHECK_TARGET_MOVEMENT_AT_MAX_DIST = entity_pos_t::FromInt(_SIZE*16);
    9797
    9898static const CColor OVERLAY_COLOUR_LONG_PATH(1, 1, 1, 1);
    9999static const CColor OVERLAY_COLOUR_SHORT_PATH(1, 0, 0, 1);
    100100
    101 static const entity_pos_t g_GoalDelta = entity_pos_t::FromInt(CELL_SIZE)/4; // for extending the goal outwards/inwards a little bit
     101static const entity_pos_t g_GoalDelta = entity_pos_t::FromInt(_SIZE)/4; // for extending the goal outwards/inwards a little bit
    102102
    103103class CCmpUnitMotion : public ICmpUnitMotion
     
    13641364            goal.u = obstruction.u;
    13651365            goal.v = obstruction.v;
    1366             entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt(CELL_SIZE)/16); // ensure it's far enough to not intersect the building itself
     1366            entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt(_SIZE)/16); // ensure it's far enough to not intersect the building itself
    13671367            goal.hw = obstruction.hw + delta;
    13681368            goal.hh = obstruction.hh + delta;
     
    14121412                goal.u = obstruction.u;
    14131413                goal.v = obstruction.v;
    1414                 entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt(CELL_SIZE)/16); // ensure it's far enough to not intersect the building itself
     1414                entity_pos_t delta = std::max(goalDistance, m_Radius + entity_pos_t::FromInt(_SIZE)/16); // ensure it's far enough to not intersect the building itself
    14151415                goal.hw = obstruction.hw + delta;
    14161416                goal.hh = obstruction.hh + delta;
  • ps/trunk/source/simulation2/components/ICmpRangeManager.h

    r10584 r10902  
    2323#include "simulation2/helpers/Player.h"
    2424
    25 #include "graphics/Terrain.h" // for CELL_SIZE
     25#include "graphics/Terrain.h" // for _SIZE
    2626
    2727/**
  • ps/trunk/source/simulation2/components/tests/test_Pathfinder.h

    r10426 r10902  
    119119        sim2.ResetState();
    120120
    121         const entity_pos_t range = entity_pos_t::FromInt(CELL_SIZE*12);
     121        const entity_pos_t range = entity_pos_t::FromInt(_SIZE*12);
    122122
    123123        CmpPtr<ICmpObstructionManager> cmpObstructionMan(sim2, SYSTEM_ENTITY);
  • ps/trunk/source/simulation2/components/tests/test_RangeManager.h

    r10537 r10902  
    8888        // in various edge cases
    8989
    90         cmp->SetBounds(entity_pos_t::FromInt(0), entity_pos_t::FromInt(0), entity_pos_t::FromInt(512), entity_pos_t::FromInt(512), 512/CELL_SIZE + 1);
     90        cmp->SetBounds(entity_pos_t::FromInt(0), entity_pos_t::FromInt(0), entity_pos_t::FromInt(512), entity_pos_t::FromInt(512), 512/_SIZE + 1);
    9191        cmp->Verify();
    9292        { CMessageCreate msg(100); cmp->HandleMessage(msg, false); }
  • ps/trunk/source/simulation2/helpers/Position.h

    r7655 r10902  
    2525 * Entity coordinate types
    2626 *
    27  * The basic unit is the "meter". Terrain tiles are CELL_SIZE (=4) meters square.
     27 * The basic unit is the "meter". Terrain tiles are _SIZE (=4) meters square.
    2828 * To support deterministic computation across CPU architectures and compilers and
    2929 * optimisation settings, the C++ simulation code must not use floating-point arithmetic.
  • ps/trunk/source/simulation2/helpers/Render.cpp

    r10704 r10902  
    101101}
    102102
    103 // This method splits up a straight line into a number of line segments each having a length ~= CELL_SIZE
     103// This method splits up a straight line into a number of line segments each having a length ~= _SIZE
    104104static void SplitLine(std::vector<std::pair<float, float> >& coords, float x1, float y1, float x2, float y2)
    105105{
    106106    float length = sqrtf(SQR(x1 - x2) + SQR(y1 - y2));
    107     size_t pieces = ((int)length) / CELL_SIZE;
     107    size_t pieces = ((int)length) / _SIZE;
    108108    if (pieces > 0)
    109109    {
  • ps/trunk/source/tools/atlas/GameInterface/ActorViewer.cpp

    r10705 r10902  
    345345        if (!cmpPosition.null())
    346346        {
    347             ssize_t c = CELL_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
     347            ssize_t c = _SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
    348348            cmpPosition->JumpTo(entity_pos_t::FromInt(c), entity_pos_t::FromInt(c));
    349349            cmpPosition->SetYRotation(entity_angle_t::Pi());
     
    479479    else
    480480        centre.Y = 0.f;
    481     centre.X = centre.Z = CELL_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
     481    centre.X = centre.Z = _SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
    482482
    483483    CCamera camera = View::GetView_Actor()->GetCamera();
     
    542542            z -= m.CurrentSpeed*dt;
    543543            // Wrap at the edges, so it doesn't run off into the horizon
    544             ssize_t c = CELL_SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
    545             if (z < c - CELL_SIZE*PATCH_SIZE * 0.1f)
    546                 z = c + CELL_SIZE*PATCH_SIZE * 0.1f;
     544            ssize_t c = _SIZE * m.Terrain.GetPatchesPerSide()*PATCH_SIZE/2;
     545            if (z < c - _SIZE*PATCH_SIZE * 0.1f)
     546                z = c + _SIZE*PATCH_SIZE * 0.1f;
    547547            cmpPosition->JumpTo(cmpPosition->GetPosition().X, entity_pos_t::FromFloat(z));
    548548        }
  • ps/trunk/source/tools/atlas/GameInterface/Brushes.cpp

    r9362 r10902  
    9191{
    9292    CVector3D c = m_Centre;
    93     if (m_W % 2) c.X += CELL_SIZE/2.f;
    94     if (m_H % 2) c.Z += CELL_SIZE/2.f;
     93    if (m_W % 2) c.X += _SIZE/2.f;
     94    if (m_H % 2) c.Z += _SIZE/2.f;
    9595    ssize_t cx, cy;
    9696    CTerrain::CalcFromPosition(c, cx, cy);
  • ps/trunk/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp

    r10064 r10902  
    266266    // to integer (rounding towards zero) will put it on the tile inside the edge
    267267    // instead of just outside
    268     float mapWidth = (g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide()-1)*CELL_SIZE;
     268    float mapWidth = (g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide()-1)*_SIZE;
    269269    float delta = 1e-6f; // fraction of map width - must be > FLT_EPSILON
    270270
Note: See TracChangeset for help on using the changeset viewer.