31 changes: 11 additions & 20 deletions src/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ UBYTE getPlayerColour(UDWORD pl)
}


static void setMatrix(Vector3i *Position, Vector3i *Rotation, bool RotXYZ)
static void setMatrix(Vector3i *Position, Vector3i *Rotation, bool RotXYZ, int scale)
{
pie_PerspectiveBegin();
pie_MatBegin();
Expand All @@ -81,6 +81,7 @@ static void setMatrix(Vector3i *Position, Vector3i *Rotation, bool RotXYZ)
pie_MatRotX(DEG(Rotation->x));
pie_MatRotZ(DEG(Rotation->z));
}
pie_MatScale(scale / 100.f);
}


Expand Down Expand Up @@ -176,10 +177,7 @@ UDWORD getStructureStatHeight(STRUCTURE_STATS *psStat)

void displayIMDButton(iIMDShape *IMDShape, Vector3i *Rotation, Vector3i *Position, bool RotXYZ, SDWORD scale)
{
setMatrix(Position, Rotation, RotXYZ);
pie_MatScale(scale / 100.f);

pie_SetFogStatus(false);
setMatrix(Position, Rotation, RotXYZ, scale);
pie_Draw3DShape(IMDShape, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0);
unsetMatrix();
}
Expand All @@ -203,8 +201,7 @@ void displayStructureButton(STRUCTURE *psStructure, Vector3i *rotation, Vector3i
Position->y -= 20;
}

setMatrix(Position, rotation, RotXYZ);
pie_MatScale(scale / 100.f);
setMatrix(Position, rotation, RotXYZ, scale);

/* Draw the building's base first */
baseImd = psStructure->pStructureType->pBaseIMD;
Expand Down Expand Up @@ -299,8 +296,7 @@ void displayStructureStatButton(STRUCTURE_STATS *Stats, Vector3i *Rotation, Vect
Position->y -= 20;
}

setMatrix(Position, Rotation, RotXYZ);
pie_MatScale(scale / 100.f);
setMatrix(Position, Rotation, RotXYZ, scale);

/* Draw the building's base first */
baseImd = Stats->pBaseIMD;
Expand Down Expand Up @@ -397,8 +393,7 @@ void displayComponentButton(BASE_STATS *Stat, Vector3i *Rotation, Vector3i *Posi
iIMDShape *MountIMD = NULL;
SDWORD compID;

setMatrix(Position, Rotation, RotXYZ);
pie_MatScale(scale / 100.f);
setMatrix(Position, Rotation, RotXYZ, scale);

compID = StatIsComponent(Stat);
if (compID > 0) {
Expand Down Expand Up @@ -446,8 +441,7 @@ void displayResearchButton(BASE_STATS *Stat, Vector3i *Rotation, Vector3i *Posit

if(ResearchIMD)
{
setMatrix(Position, Rotation, RotXYZ);
pie_MatScale(scale / 100.f);
setMatrix(Position, Rotation, RotXYZ, scale);

if(MountIMD) {
pie_Draw3DShape(MountIMD, 0, getPlayerColour(selectedPlayer), WZCOL_WHITE, pie_BUTTON, 0);
Expand Down Expand Up @@ -946,8 +940,7 @@ static void displayCompObj(DROID *psDroid, bool bButton)
//
void displayComponentButtonTemplate(DROID_TEMPLATE *psTemplate, Vector3i *Rotation, Vector3i *Position, bool RotXYZ, SDWORD scale)
{
setMatrix(Position, Rotation, RotXYZ);
pie_MatScale(scale / 100.f);
setMatrix(Position, Rotation, RotXYZ, scale);

// Decide how to sort it.
leftFirst = angleDelta(DEG(Rotation->y)) < 0;
Expand All @@ -972,23 +965,21 @@ void displayComponentButtonObject(DROID *psDroid, Vector3i *Rotation, Vector3i *
{
SDWORD difference;

setMatrix(Position, Rotation, RotXYZ);
pie_MatScale(scale / 100.f);
setMatrix(Position, Rotation, RotXYZ, scale);

// Decide how to sort it.
// Decide how to sort it.
difference = Rotation->y%360;

leftFirst = !((difference > 0 && difference < 180) || difference < -180);

// And render the composite object.
// And render the composite object.
//draw multi component object as a button object
displayCompObj(psDroid, true);

unsetMatrix();
}



/* Assumes matrix context is already set */
// multiple turrets display removed the pointless mountRotation
void displayComponentObject(DROID *psDroid)
Expand Down
2 changes: 1 addition & 1 deletion src/display3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ void renderStructure(STRUCTURE *psStructure)
}
else
{
pieFlag = pie_TRANSLUCENT | pie_FORCE_FOG | pie_FORCE_IMMEDIATE | ecmFlag;
pieFlag = pie_TRANSLUCENT | pie_FORCE_FOG | ecmFlag;
pieFlagData = 255;
}
pie_Draw3DShape(psStructure->pStructureType->pBaseIMD, 0, colour, buildingBrightness, pieFlag, pieFlagData);
Expand Down