Fix broken mapObjIsAboveGround and incorrect lighting normals due to ELEVATION_SCALE.

Changelog: Fix projectiles going through terrain due to bad terrain height calculations.
Changelog: Fix terrain shading.
master
Cyp 2010-11-16 20:20:54 +01:00
parent 275428c161
commit 6ea8e50b65
2 changed files with 28 additions and 28 deletions

View File

@ -147,17 +147,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX + 1),
world_coord(tileY),
tileRight->height*(1.f/ELEVATION_SCALE) - rMod
tileRight->height - rMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY + 1),
tileDownRight->height*(1.f/ELEVATION_SCALE) - drMod
tileDownRight->height - drMod
},
corner3 = {
world_coord(tileX),
world_coord(tileY + 1),
tileDown->height*(1.f/ELEVATION_SCALE) - dMod
tileDown->height - dMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -168,17 +168,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX),
world_coord(tileY),
psTile->height*(1.f/ELEVATION_SCALE) - nMod
psTile->height - nMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY),
tileRight->height*(1.f/ELEVATION_SCALE) - rMod
tileRight->height - rMod
},
corner3 = {
world_coord(tileX),
world_coord(tileY + 1),
tileDown->height*(1.f/ELEVATION_SCALE) - dMod
tileDown->height - dMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -192,17 +192,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX),
world_coord(tileY),
psTile->height*(1.f/ELEVATION_SCALE) - nMod
psTile->height - nMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY),
tileRight->height*(1.f/ELEVATION_SCALE) - rMod
tileRight->height - rMod
},
corner3 = {
world_coord(tileX + 1),
world_coord(tileY + 1),
tileDownRight->height*(1.f/ELEVATION_SCALE) - drMod
tileDownRight->height - drMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -213,17 +213,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX),
world_coord(tileY),
psTile->height*(1.f/ELEVATION_SCALE) - nMod
psTile->height - nMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY + 1),
tileDownRight->height*(1.f/ELEVATION_SCALE) - drMod
tileDownRight->height - drMod
},
corner3 = {
world_coord(tileX),
world_coord(tileY + 1),
tileDown->height*(1.f/ELEVATION_SCALE) - dMod
tileDown->height - dMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -240,17 +240,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX),
world_coord(tileY),
psTile->height*(1.f/ELEVATION_SCALE) - nMod
psTile->height - nMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY),
tileRight->height*(1.f/ELEVATION_SCALE) - rMod
tileRight->height - rMod
},
corner3 = {
world_coord(tileX),
world_coord(tileY + 1),
tileDown->height*(1.f/ELEVATION_SCALE) - dMod
tileDown->height - dMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -261,17 +261,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX + 1),
world_coord(tileY),
tileRight->height*(1.f/ELEVATION_SCALE) - rMod
tileRight->height - rMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY + 1),
tileDownRight->height*(1.f/ELEVATION_SCALE) - drMod
tileDownRight->height - drMod
},
corner3 = {
world_coord(tileX),
world_coord(tileY + 1),
tileDown->height*(1.f/ELEVATION_SCALE) - dMod
tileDown->height - dMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -285,17 +285,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX),
world_coord(tileY),
psTile->height*(1.f/ELEVATION_SCALE) - nMod
psTile->height - nMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY + 1),
tileDownRight->height*(1.f/ELEVATION_SCALE) - drMod
tileDownRight->height - drMod
},
corner3 = {
world_coord(tileX),
world_coord(tileY + 1),
tileDown->height*(1.f/ELEVATION_SCALE) - dMod
tileDown->height - dMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);
@ -306,17 +306,17 @@ static void normalsOnTile(unsigned int tileX, unsigned int tileY, unsigned int q
corner1 = {
world_coord(tileX),
world_coord(tileY),
psTile->height*(1.f/ELEVATION_SCALE) - nMod
psTile->height - nMod
},
corner2 = {
world_coord(tileX + 1),
world_coord(tileY),
tileRight->height*(1.f/ELEVATION_SCALE) - rMod
tileRight->height - rMod
},
corner3 = {
world_coord(tileX + 1),
world_coord(tileY + 1),
tileDownRight->height*(1.f/ELEVATION_SCALE) - drMod
tileDownRight->height - drMod
};
normals[(*numNormals)++] = pie_SurfaceNormal3fv( corner1, corner2, corner3);

View File

@ -1194,10 +1194,10 @@ extern BOOL mapObjIsAboveGround( BASE_OBJECT *psObj )
tileY = map_coord(psObj->pos.y),
tileYOffset1 = (tileY * mapWidth),
tileYOffset2 = ((tileY+1) * mapWidth),
h1 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset1 + tileX) ].height / ELEVATION_SCALE,
h2 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset1 + tileX + 1)].height / ELEVATION_SCALE,
h3 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset2 + tileX) ].height / ELEVATION_SCALE,
h4 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset2 + tileX + 1)].height / ELEVATION_SCALE;
h1 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset1 + tileX) ].height,
h2 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset1 + tileX + 1)].height,
h3 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset2 + tileX) ].height,
h4 = psMapTiles[MIN(mapWidth * mapHeight - 1, tileYOffset2 + tileX + 1)].height;
/* trivial test above */
if ( (psObj->pos.z > h1) && (psObj->pos.z > h2) &&