New map macro map_round() rounds map coordinates down to tile boundaries.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1684 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2007-05-22 20:36:07 +00:00
parent c0e9fa3211
commit c0abb47655
7 changed files with 29 additions and 27 deletions

View File

@ -349,8 +349,8 @@ void renderParticle( ATPART *psPart )
dv.z = terrainMidY * TILE_UNITS - ((UDWORD)z - player.p.z);
iV_MatrixBegin(); /* Push the indentity matrix */
iV_TRANSLATE(dv.x,dv.y,dv.z);
rx = player.p.x & (TILE_UNITS-1); /* Get the x,z translation components */
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x); /* Get the x,z translation components */
rz = map_round(player.p.z);
iV_TRANSLATE(rx,0,-rz); /* Translate */
/* Make it face camera */
iV_MatrixRotateY(-player.r.y);

View File

@ -142,8 +142,8 @@ BOOL renderBridgeSection(STRUCTURE *psStructure)
pie_TRANSLATE(dv.x,dv.y,dv.z);
/* Get the x,z translation components */
rx = player.p.x & (TILE_UNITS-1);
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x);
rz = map_round(player.p.z);
/* Translate */
pie_TRANSLATE(rx,0,-rz);

View File

@ -782,8 +782,8 @@ void displayComponentObject(BASE_OBJECT *psObj)
pie_MatBegin();
/* Get internal tile units coordinates */
xShift = player.p.x & (TILE_UNITS-1);
zShift = player.p.z & (TILE_UNITS-1);
xShift = map_round(player.p.x);
zShift = map_round(player.p.z);
/* Mask out to tile_units resolution */
pie_TRANSLATE(xShift,0,-zShift);

View File

@ -1636,8 +1636,8 @@ void renderWaypointEffect(EFFECT *psEffect)
dv.z = terrainMidY * TILE_UNITS - ((UDWORD)MAKEINT(psEffect->position.z) - player.p.z);
iV_MatrixBegin(); /* Push the indentity matrix */
iV_TRANSLATE(dv.x,dv.y,dv.z);
rx = player.p.x & (TILE_UNITS-1); /* Get the x,z translation components */
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x); /* Get the x,z translation components */
rz = map_round(player.p.z);
iV_TRANSLATE(rx,0,-rz); /* Translate */
// set up lighting
@ -1670,8 +1670,8 @@ void renderFirework(EFFECT *psEffect)
dv.z = terrainMidY * TILE_UNITS - ((UDWORD)MAKEINT(psEffect->position.z) - player.p.z);
iV_MatrixBegin(); /* Push the indentity matrix */
iV_TRANSLATE(dv.x,dv.y,dv.z);
rx = player.p.x & (TILE_UNITS-1); /* Get the x,z translation components */
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x); /* Get the x,z translation components */
rz = map_round(player.p.z);
iV_TRANSLATE(rx,0,-rz); /* Translate */
@ -1702,8 +1702,8 @@ void renderBloodEffect(EFFECT *psEffect)
dv.z = terrainMidY * TILE_UNITS - ((UDWORD)MAKEINT(psEffect->position.z) - player.p.z);
iV_MatrixBegin(); /* Push the indentity matrix */
iV_TRANSLATE(dv.x,dv.y,dv.z);
rx = player.p.x & (TILE_UNITS-1); /* Get the x,z translation components */
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x); /* Get the x,z translation components */
rz = map_round(player.p.z);
iV_TRANSLATE(rx,0,-rz); /* Translate */
iV_MatrixRotateY(-player.r.y);
iV_MatrixRotateX(-player.r.x);
@ -1741,8 +1741,8 @@ void renderDestructionEffect(EFFECT *psEffect)
dv.z = terrainMidY * TILE_UNITS - ((UDWORD)MAKEINT(psEffect->position.z) - player.p.z);
iV_MatrixBegin(); /* Push the indentity matrix */
iV_TRANSLATE(dv.x,dv.y,dv.z);
rx = player.p.x & (TILE_UNITS-1); /* Get the x,z translation components */
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x); /* Get the x,z translation components */
rz = map_round(player.p.z);
iV_TRANSLATE(rx,0,-rz); /* Translate */
@ -1822,8 +1822,8 @@ void renderExplosionEffect(EFFECT *psEffect)
dv.z = terrainMidY * TILE_UNITS - ((UDWORD)MAKEINT(psEffect->position.z) - player.p.z);
iV_MatrixBegin(); /* Push the indentity matrix */
iV_TRANSLATE(dv.x,dv.y,dv.z);
rx = player.p.x & (TILE_UNITS-1); /* Get the x,z translation components */
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x); /* Get the x,z translation components */
rz = map_round(player.p.z);
iV_TRANSLATE(rx,0,-rz); /* Translate */
/* Bit in comments - doesn't quite work yet? */
@ -1896,8 +1896,8 @@ void renderGravitonEffect(EFFECT *psEffect)
iV_TRANSLATE(vec.x,vec.y,vec.z);
/* Offset from camera */
rx = player.p.x & (TILE_UNITS-1);
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x);
rz = map_round(player.p.z);
/* Move to camera reference */
iV_TRANSLATE(rx,0,-rz);
@ -1955,8 +1955,8 @@ void renderConstructionEffect(EFFECT *psEffect)
iV_TRANSLATE(vec.x,vec.y,vec.z);
/* Offset from camera */
rx = player.p.x & (TILE_UNITS-1);
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x);
rz = map_round(player.p.z);
/* Move to camera reference */
iV_TRANSLATE(rx,0,-rz);
@ -2027,8 +2027,8 @@ void renderSmokeEffect(EFFECT *psEffect)
iV_TRANSLATE(vec.x,vec.y,vec.z);
/* Offset from camera */
rx = player.p.x & (TILE_UNITS-1);
rz = player.p.z & (TILE_UNITS-1);
rx = map_round(player.p.x);
rz = map_round(player.p.z);
/* Move to camera reference */
iV_TRANSLATE(rx,0,-rz);

View File

@ -275,8 +275,8 @@ extern UDWORD map_MistValue(UDWORD x, UDWORD y)
tileY = y >> TILE_SHIFT;
/* Inter tile comp */
ox = (x & (TILE_UNITS-1));
oy = (y & (TILE_UNITS-1));
ox = map_round(x);
oy = map_round(y);
/* If this happens, then get quick height */
if(!x && !y)

View File

@ -1337,9 +1337,8 @@ extern SWORD map_Height(UDWORD x, UDWORD y)
tileY = map_coord(y);
/* Inter tile comp */
ox = (x & (TILE_UNITS-1));
oy = (y & (TILE_UNITS-1));
ox = map_round(x);
oy = map_round(y);
if(TERRAIN_TYPE(mapTile(tileX,tileY)) == TER_WATER)
{

View File

@ -189,6 +189,9 @@ static inline UDWORD map_coord(UDWORD worldCoord)
return worldCoord / TILE_UNITS;
}
/* maps a position down to the corner of a tile */
#define map_round(coord) coord & (TILE_UNITS - 1)
/* Shutdown the map module */
extern BOOL mapShutdown(void);