Fix a bug introduced in r1469, which produced gaps where the buildings should be and made the terrain jump around. (display3d.c)
Additionaly: - Cleanup indention - Remove an unused, commented out function - Make code a bit more readable - Insert suggestion into display3d.h (playerXTiles and rx are only use in one otehr file each, so maybe we could wrap them into a function for the purpose of encapsulation. The comment is ugly, I know.) git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1479 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
300f691b0b
commit
345581c9ac
|
@ -180,7 +180,7 @@ BOOL godMode;
|
||||||
|
|
||||||
static UWORD WaterTileID = WATER_TILE;
|
static UWORD WaterTileID = WATER_TILE;
|
||||||
static UWORD RiverBedTileID = BED_TILE;
|
static UWORD RiverBedTileID = BED_TILE;
|
||||||
static FRACT waterRealValue = 0.0f;
|
static float waterRealValue = 0.0f;
|
||||||
#define WAVE_SPEED 4
|
#define WAVE_SPEED 4
|
||||||
static SWORD vOffset = 1;
|
static SWORD vOffset = 1;
|
||||||
#define MAX_FIRE_STAGE 32
|
#define MAX_FIRE_STAGE 32
|
||||||
|
@ -689,7 +689,7 @@ static void drawTiles(iView *camera, iView *player)
|
||||||
if(vOffset >= 64/2)
|
if(vOffset >= 64/2)
|
||||||
{
|
{
|
||||||
vOffset = 0;
|
vOffset = 0;
|
||||||
waterRealValue = 0;
|
waterRealValue = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Is the scene spinning? - showcase demo stuff */
|
/* Is the scene spinning? - showcase demo stuff */
|
||||||
|
@ -707,8 +707,8 @@ static void drawTiles(iView *camera, iView *player)
|
||||||
SetBSPCameraPos(BSPCamera.x, BSPCamera.y, BSPCamera.z);
|
SetBSPCameraPos(BSPCamera.x, BSPCamera.y, BSPCamera.z);
|
||||||
|
|
||||||
/* Find our position in tile coordinates */
|
/* Find our position in tile coordinates */
|
||||||
playerXTile = player->p.x / TILE_UNITS;
|
playerXTile = player->p.x >> TILE_SHIFT;
|
||||||
playerZTile = player->p.z / TILE_UNITS;
|
playerZTile = player->p.z >> TILE_SHIFT;
|
||||||
|
|
||||||
/* Get the x,z translation components */
|
/* Get the x,z translation components */
|
||||||
rx = (player->p.x) & (TILE_UNITS-1);
|
rx = (player->p.x) & (TILE_UNITS-1);
|
||||||
|
|
|
@ -72,22 +72,24 @@ extern void setProximityDraw(BOOL val);
|
||||||
extern void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD );
|
extern void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD );
|
||||||
|
|
||||||
|
|
||||||
extern UDWORD getSuggestedPitch ( void );
|
extern UDWORD getSuggestedPitch( void );
|
||||||
|
|
||||||
extern BOOL clipXY ( SDWORD x, SDWORD y);
|
extern BOOL clipXY ( SDWORD x, SDWORD y);
|
||||||
|
|
||||||
extern BOOL init3DView(void);
|
extern BOOL init3DView(void);
|
||||||
extern void initViewPosition(void);
|
extern void initViewPosition(void);
|
||||||
extern iView player,camera;
|
extern iView player,camera;
|
||||||
extern UDWORD distance;
|
extern UDWORD distance;
|
||||||
extern UDWORD terrainOutline;
|
extern UDWORD terrainOutline;
|
||||||
extern UDWORD xOffset,yOffset;
|
extern UDWORD xOffset,yOffset;
|
||||||
extern BOOL selectAttempt;
|
extern BOOL selectAttempt;
|
||||||
extern BOOL draggingTile;
|
extern BOOL draggingTile;
|
||||||
extern struct iIMDShape *g_imd;
|
extern struct iIMDShape *g_imd;
|
||||||
extern BOOL droidSelected;
|
extern BOOL droidSelected;
|
||||||
extern UDWORD terrainMidX,terrainMidY;
|
extern UDWORD terrainMidX,terrainMidY;
|
||||||
extern Sint32 playerXTile, playerZTile, rx, rz;
|
// FIXME This only used in one location outside of display3d.c, maybe create a wrapper function instead? ->
|
||||||
|
extern Sint32 playerXTile, playerZTile, // -> lighting.c
|
||||||
|
rx, rz; // -> atmos.c
|
||||||
|
|
||||||
extern SDWORD scrollSpeed;
|
extern SDWORD scrollSpeed;
|
||||||
extern iBitmap **tilesRAW;
|
extern iBitmap **tilesRAW;
|
||||||
|
|
|
@ -417,83 +417,6 @@ void normalsOnTile(UDWORD tileX, UDWORD tileY, UDWORD quadrant)
|
||||||
} // end switch
|
} // end switch
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Processes a light into the tileScreenInfo structure - this needs
|
|
||||||
to be optimised and profiled as it's costly to perform
|
|
||||||
*/
|
|
||||||
void processLight(LIGHT *psLight)
|
|
||||||
{
|
|
||||||
SDWORD i,j;
|
|
||||||
UDWORD tileX,tileY;
|
|
||||||
UDWORD offset;
|
|
||||||
UDWORD distToCorner;
|
|
||||||
UDWORD percent;
|
|
||||||
UDWORD xIndex,yIndex;
|
|
||||||
SDWORD xUpper,yUpper,xLower,yLower;
|
|
||||||
SDWORD gridMinX,gridMinY,gridMaxX,gridMaxY;
|
|
||||||
|
|
||||||
/* Firstly - there's no point processing lights that are off the grid */
|
|
||||||
if(clipXY(psLight->position.x,psLight->position.z) == FALSE)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tileX = (psLight->position.x/TILE_UNITS);
|
|
||||||
tileY = (psLight->position.z/TILE_UNITS);
|
|
||||||
offset = psLight->range/TILE_UNITS;
|
|
||||||
|
|
||||||
if(player.p.x>=0)
|
|
||||||
{
|
|
||||||
gridMinX = player.p.x/TILE_UNITS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gridMinX = 0;
|
|
||||||
}
|
|
||||||
if(player.p.z >=0)
|
|
||||||
{
|
|
||||||
gridMinY = player.p.z/TILE_UNITS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gridMinY = 0;
|
|
||||||
}
|
|
||||||
gridMaxX = gridMinX + visibleXTiles;
|
|
||||||
gridMaxY = gridMinY + visibleYTiles;
|
|
||||||
|
|
||||||
xLower = tileX - offset;
|
|
||||||
xUpper = tileX + offset;
|
|
||||||
yLower = tileY - offset;
|
|
||||||
yUpper = tileY + offset;
|
|
||||||
|
|
||||||
for(i=xLower; i<xUpper; i++)
|
|
||||||
{
|
|
||||||
for(j=yLower; j<yUpper; j++)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
We must make sure that we don't attempt to colour a tile that isn't actually
|
|
||||||
on our grid - say when a light is on the periphery of the grid.
|
|
||||||
*/
|
|
||||||
if(i>gridMinX && i<gridMaxX && j>gridMinY && j<gridMaxY)
|
|
||||||
{
|
|
||||||
distToCorner = calcDistToTile(i,j,&psLight->position);
|
|
||||||
/* If we're inside the range of the light */
|
|
||||||
if(distToCorner<psLight->range)
|
|
||||||
{
|
|
||||||
/* Find how close we are to it */
|
|
||||||
percent = 100 - PERCENT(distToCorner,psLight->range);
|
|
||||||
|
|
||||||
xIndex = i - playerXTile;
|
|
||||||
yIndex = j - playerZTile;
|
|
||||||
colourTile(xIndex,yIndex,psLight->colour, (UBYTE)percent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void processLight(LIGHT *psLight)
|
void processLight(LIGHT *psLight)
|
||||||
{
|
{
|
||||||
SDWORD tileX,tileY;
|
SDWORD tileX,tileY;
|
||||||
|
@ -568,7 +491,7 @@ UDWORD percent;
|
||||||
{
|
{
|
||||||
distToCorner = calcDistToTile(i,j,&psLight->position);
|
distToCorner = calcDistToTile(i,j,&psLight->position);
|
||||||
/* If we're inside the range of the light */
|
/* If we're inside the range of the light */
|
||||||
if(distToCorner<(SDWORD)psLight->range)
|
if (distToCorner<(SDWORD)psLight->range)
|
||||||
{
|
{
|
||||||
/* Find how close we are to it */
|
/* Find how close we are to it */
|
||||||
percent = 100 - PERCENT(distToCorner,psLight->range);
|
percent = 100 - PERCENT(distToCorner,psLight->range);
|
||||||
|
@ -576,11 +499,11 @@ UDWORD percent;
|
||||||
yIndex = j - playerZTile;
|
yIndex = j - playerZTile;
|
||||||
// Might go off the grid for light ranges > one tile
|
// Might go off the grid for light ranges > one tile
|
||||||
// if(i<visibleXTiles && j<visibleYTiles && i>=0 && j>=0)
|
// if(i<visibleXTiles && j<visibleYTiles && i>=0 && j>=0)
|
||||||
if(xIndex >= 0 && yIndex >= 0 &&
|
if ( xIndex >= 0 && yIndex >= 0 &&
|
||||||
xIndex < (SDWORD)visibleXTiles &&
|
xIndex < (SDWORD)visibleXTiles &&
|
||||||
yIndex < (SDWORD)visibleYTiles)
|
yIndex < (SDWORD)visibleYTiles )
|
||||||
{
|
{
|
||||||
colourTile(xIndex,yIndex,psLight->colour, (UBYTE)(2*percent));
|
colourTile(xIndex, yIndex, psLight->colour, (UBYTE)(2*percent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,13 +200,12 @@ extern void mapWaterProcess( void );
|
||||||
/* Return a pointer to the tile structure at x,y */
|
/* Return a pointer to the tile structure at x,y */
|
||||||
static inline MAPTILE *mapTile(UDWORD x, UDWORD y)
|
static inline MAPTILE *mapTile(UDWORD x, UDWORD y)
|
||||||
{
|
{
|
||||||
|
|
||||||
ASSERT( x < mapWidth,
|
ASSERT( x < mapWidth,
|
||||||
"mapTile: x coordinate bigger than map width" );
|
"mapTile: x coordinate bigger than map width" );
|
||||||
ASSERT( y < mapHeight,
|
ASSERT( y < mapHeight,
|
||||||
"mapTile: y coordinate bigger than map height" );
|
"mapTile: y coordinate bigger than map height" );
|
||||||
|
|
||||||
return psMapTiles + x + (y * mapWidth);
|
return &psMapTiles[x + (y * mapWidth)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return height of tile at x,y */
|
/* Return height of tile at x,y */
|
||||||
|
|
Loading…
Reference in New Issue