More cleanup

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1679 4a71c877-e1ca-e34f-864e-861f7616d084
master
Dennis Schridde 2007-05-21 18:57:11 +00:00
parent 504126bda9
commit 49f8259226
5 changed files with 100 additions and 104 deletions

View File

@ -307,8 +307,7 @@ static transluscent_shape_t* tshapes = NULL;
static unsigned int tshapes_size = 0;
static unsigned int nb_tshapes = 0;
static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELIGHT specular,
int pieFlag, int pieFlagData)
static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELIGHT specular, int pieFlag, int pieFlagData)
{
Sint32 tempY;
int i, n;
@ -320,37 +319,47 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
BOOL light = lighting;
/* Set tranlucency */
if (pieFlag & pie_ADDITIVE) { //Assume also translucent
if (pieFlag & pie_ADDITIVE)
{ //Assume also translucent
pie_SetFogStatus(FALSE);
pie_SetRendMode(REND_ADDITIVE_TEX);
colour.byte.a = (UBYTE)pieFlagData;
pie_SetBilinear(TRUE);
light = FALSE;
} else if (pieFlag & pie_TRANSLUCENT) {
}
else if (pieFlag & pie_TRANSLUCENT)
{
pie_SetFogStatus(FALSE);
pie_SetRendMode(REND_ALPHA_TEX);
colour.byte.a = (UBYTE)pieFlagData;
pie_SetBilinear(FALSE);//never bilinear with constant alpha, gives black edges
light = FALSE;
} else {
}
else
{
if (pieFlag & pie_BUTTON)
{
pie_SetFogStatus(FALSE);
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
} else {
}
else
{
pie_SetFogStatus(TRUE);
}
pie_SetRendMode(REND_GOURAUD_TEX);
//if hardware fog then alpha is set else unused in decal mode
//colour.byte.a = MAX_UB_LIGHT;
if (pieFlag & pie_NO_BILINEAR) {
if (pieFlag & pie_NO_BILINEAR)
{
pie_SetBilinear(FALSE);
} else {
}
else
{
pie_SetBilinear(TRUE);
}
}
if (pieFlag & pie_RAISE) {
if (pieFlag & pie_RAISE)
{
pieFlagData = (shape->ymax * (pie_RAISE_SCALE - pieFlagData))/pie_RAISE_SCALE;
}
@ -358,16 +367,16 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
//now draw the shape
//rotate and project points from shape->points to scrPoints
pVertices = shape->points;
pPixels = &scrPoints[0];
//--
for (i=0; i<shape->npoints; i++, pVertices++, pPixels++) {
for (i = 0, pVertices = shape->points, pPixels = scrPoints;
i < shape->npoints;
i++, pVertices++, pPixels++)
{
tempY = pVertices->y;
if (pieFlag & pie_RAISE)
{
tempY = pVertices->y - pieFlagData;
if (tempY < 0) tempY = 0;
if (tempY < 0)
tempY = 0;
}
else if (pieFlag & pie_HEIGHT_SCALED)
@ -376,7 +385,6 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
{
tempY = (pVertices->y * pieFlagData) / pie_RAISE_SCALE;
}
//if (tempY < 0) tempY = 0;
}
pPixels->x = pVertices->x;
pPixels->y = tempY;
@ -424,7 +432,7 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
/// returns true if the edges are adjacent
static int compare_edge (EDGE *A, EDGE *B, Vector3i *pVertices )
static int compare_edge (EDGE *A, EDGE *B, const Vector3i *pVertices )
{
if(A->from == B->to)
{
@ -451,12 +459,10 @@ static int compare_edge (EDGE *A, EDGE *B, Vector3i *pVertices )
/// Makes sure only silhouette edges are present
static void addToEdgeList(int a, int b, EDGE *edgelist, int *edge_count, Vector3i *pVertices)
{
EDGE newEdge;
EDGE newEdge = {a, b};
int i;
BOOL foundMatching = FALSE;
newEdge.from = a;
newEdge.to = b;
for(i = 0; i < *edge_count; i++)
{
if(edgelist[i].from < 0)
@ -517,8 +523,8 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
}
else
{
pPolys = shape->polys;
for (i = 0; i < shape->npolys; ++i, ++pPolys) {
for (i = 0, pPolys = shape->polys; i < shape->npolys; ++i, ++pPolys) {
Vector3f p[3], v[2], normal;
VERTEXID current, first;
for(j = 0; j < 3; j++)
@ -558,8 +564,7 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
if(flag & pie_STATIC_SHADOW)
{
// first compact the current edgelist
j = 0;
for(i=0;i<edge_count;i++)
for(i = 0, j = 0; i < edge_count; i++)
{
if(edgelist[i].from < 0)
{
@ -570,9 +575,9 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
}
edge_count = j;
// then store it in the imd
shape->shadowEdgeList = malloc(sizeof(EDGE)*edge_count);
memcpy(shape->shadowEdgeList, edgelist, sizeof(EDGE)*edge_count);
shape->nShadowEdges = edge_count;
shape->shadowEdgeList = malloc(sizeof(EDGE) * shape->nShadowEdges);
memcpy(shape->shadowEdgeList, edgelist, sizeof(EDGE) * shape->nShadowEdges);
}
}
@ -580,13 +585,11 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
glBegin(GL_QUADS);
for(i=0;i<edge_count;i++)
{
int a,b;
a = drawlist[i].from;
int a = drawlist[i].from, b = drawlist[i].to;
if(a < 0)
{
continue;
}
b = drawlist[i].to;
glVertex3f(pVertices[b].x, scale_y(pVertices[b].y, flag, flag_data), pVertices[b].z);
glVertex3f(pVertices[b].x+light->x, scale_y(pVertices[b].y, flag, flag_data)+light->y, pVertices[b].z+light->z);
@ -603,9 +606,12 @@ static void pie_DrawShadow(iIMDShape *shape, int flag, int flag_data, Vector3f*
glBegin(GL_LINES);
for(i = 0; i < edge_count; i++)
{
int a = drawlist[i].from;
if(a<0) continue;
int b = drawlist[i].to;
int a = drawlist[i].from, b = drawlist[i].to;
if(a < 0)
{
continue;
}
glVertex3f(pVertices[b].x, scale_y(pVertices[b].y, flag, flag_data), pVertices[b].z);
glVertex3f(pVertices[a].x, scale_y(pVertices[a].y, flag, flag_data), pVertices[a].z);
}

View File

@ -81,6 +81,15 @@ static inline BOOL Vector3i_compare(const Vector3i *a, const Vector3i *b)
}
/*!
* returns true if both vectors are equal
*/
static inline BOOL Vector3f_compare(const Vector3f *a, const Vector3f *b)
{
return a->x == b->x && a->y == b->y && a->z == b->z;
}
//*************************************************************************

View File

@ -253,7 +253,6 @@ UDWORD currentGameFrame;
static UDWORD numTiles = 0;
static SDWORD tileZ = 8000;
static QUAD dragQuad;
//UDWORD averageHeight;
/* temporary buffer used for flattening IMDs */
static Vector3i alteredPoints[iV_IMD_MAX_POINTS];
@ -1763,12 +1762,8 @@ void renderFeature(FEATURE *psFeature)
iV_MatrixRotateY(-rotation);
// centreX = ( player.p.x + ((visibleXTiles/2)<<TILE_SHIFT) );
// centreZ = ( player.p.z + ((visibleYTiles/2)<<TILE_SHIFT) );
brightness = 200; //? HUH?
// if(psFeature->sDisplay.imd->ymax>300)
if(psFeature->psStats->subType == FEAT_SKYSCRAPER)
{
objectShimmy((BASE_OBJECT*)psFeature);
@ -2467,7 +2462,6 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition)
Vector3i dv;
SDWORD x, y, r;
Vector3i *temp = NULL;
// SDWORD centreX, centreZ;
SDWORD buildingBrightness, specular;
//store the frame number for when deciding what has been clicked on
psPosition->frameNumber = currentGameFrame;
@ -2489,7 +2483,6 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition)
iV_TRANSLATE(rx,0,-rz);
//quick check for invalid data
//ASSERT( psPosition->factoryType < NUM_FACTORY_TYPES &&
ASSERT( psPosition->factoryType < NUM_FLAG_TYPES && psPosition->factoryInc < MAX_FACTORY, "Invalid assembly point" );
if(!psPosition->selected)
@ -2501,18 +2494,10 @@ void renderDeliveryPoint(FLAG_POSITION *psPosition)
pie_MatScale(50); // they are all big now so make this one smaller too
// centreX = ( player.p.x + ((visibleXTiles/2)<<TILE_SHIFT) );
// centreZ = ( player.p.z + ((visibleYTiles/2)<<TILE_SHIFT) );
buildingBrightness = pie_MAX_BRIGHT_LEVEL;
buildingBrightness = lightDoFogAndIllumination((UBYTE)buildingBrightness,
buildingBrightness = lightDoFogAndIllumination(pie_MAX_BRIGHT_LEVEL,
getCentreX() - psPosition->coords.x, getCentreZ() - psPosition->coords.y, (UDWORD*)&specular);
// pie_Draw3DShape(pAssemblyPointIMDs[psPosition->factoryInc], 0, 0,
// buildingBrightness, 0, pie_TRANSLUCENT | pie_NO_BILINEAR, EFFECT_DELIVERY_POINT_TRANSPARENCY);
pie_Draw3DShape(pAssemblyPointIMDs[psPosition->factoryType][psPosition->factoryInc],
0, 0, buildingBrightness, specular, pie_NO_BILINEAR, 0);
pie_Draw3DShape(pAssemblyPointIMDs[psPosition->factoryType][psPosition->factoryInc], 0, 0, buildingBrightness, specular, pie_NO_BILINEAR, 0);
if(!psPosition->selected)
{
@ -2628,7 +2613,7 @@ static BOOL renderWallSection(STRUCTURE *psStructure)
rotation = DEG( (int)psStructure->direction );
iV_MatrixRotateY(-rotation);
// objectShimmy((BASE_OBJECT*)psStructure);
if(imd != NULL)
{
// Make the imd pointer to the vertex list point to ours
@ -2703,8 +2688,6 @@ void renderShadow( DROID *psDroid, iIMDShape *psShadowIMD )
Vector3i *pVecTemp;
SDWORD shadowScale;
UDWORD brightness, specular;
// SDWORD centreX, centreZ;
dv.x = (psDroid->x - player.p.x) - terrainMidX*TILE_UNITS;
if(psDroid->droidType == DROID_TRANSPORTER)
@ -4142,8 +4125,7 @@ static iIMDShape *flattenImd(iIMDShape *imd, UDWORD structX, UDWORD structY, UDW
{
UDWORD i, centreHeight;
ASSERT( imd->npoints < iV_IMD_MAX_POINTS,
"flattenImd: too many points in the PIE to flatten it" );
ASSERT( imd->npoints < iV_IMD_MAX_POINTS, "flattenImd: too many points in the PIE to flatten it" );
/* Get a copy of the points */
memcpy(alteredPoints, imd->points, imd->npoints * sizeof(Vector3i));

View File

@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
* \file Structure.c
* \file structure.c
*
* Store Structure stats.
* WARNING!!!!!!
@ -3975,8 +3975,6 @@ void structureUpdate(STRUCTURE *psBuilding)
}
}
//--
/* Only add smoke if they're visible and they can 'burn' */
if(psBuilding->visible[selectedPlayer] && canSmoke(psBuilding))
{
@ -4073,7 +4071,8 @@ void structureUpdate(STRUCTURE *psBuilding)
//add the blue flashing effect for multiPlayer
if(bMultiPlayer && ONEINTEN)
{
Vector3i position, *point;
Vector3i position;
Vector3i *point;
SDWORD realY;
UDWORD pointIndex;