- fix DrawCar, SubDivShadow, PlaceShadowForCar

This commit is contained in:
Ilya Shurumov 2020-05-09 14:24:43 +06:00
parent 53b3607b06
commit b71ec78484
3 changed files with 35 additions and 30 deletions

View File

@ -847,10 +847,12 @@ void DrawCar(_CAR_DATA *cp, int view)
local_c0.vz = pos.vz;
SetFrustrumMatrix();
iVar6 = FrustrumCheck(&pos, 800);
if (iVar6 == -1) {
if (FrustrumCheck(&pos, 800) == -1)
return;
}
iVar6 = 0;
iVar11 = (int)(cp->hd).oBox.radii[0].vx;
iVar9 = (int)(cp->hd).oBox.radii[2].vx;
vvvar = pos.vx + iVar11;
@ -872,20 +874,19 @@ void DrawCar(_CAR_DATA *cp, int view)
corners[1].vy = pos.vy;
corners[0].vy = pos.vy;
vvvar = FrustrumCheck(&pos, 0);
if ((((vvvar == -1) && (vvvar = FrustrumCheck(corners, 0), vvvar == -1)) &&
(vvvar = FrustrumCheck(corners + 1, 0), vvvar == -1)) &&
((vvvar = FrustrumCheck(corners + 2, 0), vvvar == -1 &&
(vvvar = FrustrumCheck(corners + 3, 0), vvvar == -1))))
if (FrustrumCheck(&pos, 0) == -1 &&
FrustrumCheck(corners, 0) == -1 &&
FrustrumCheck(corners + 1, 0) == -1 &&
FrustrumCheck(corners + 2, 0) == -1 &&
FrustrumCheck(corners + 3, 0) == -1)
{
iVar6 = -1;
}
d.vx = (cp->hd).oBox.location.vx - camera_position.vx;
d.vy = -camera_position.vy - (cp->hd).oBox.location.vy;
d.vz = (cp->hd).oBox.location.vz - camera_position.vz;
iVar11 = (int)(cp->hd).oBox.length[0];
d.vx = cp->hd.oBox.location.vx - camera_position.vx;
d.vy = -camera_position.vy - cp->hd.oBox.location.vy;
d.vz = cp->hd.oBox.location.vz - camera_position.vz;
iVar11 = cp->hd.oBox.length[0];
vvvar = d.vx * cp->hd.oBox.radii[0].vx + d.vy * cp->hd.oBox.radii[0].vy + d.vz * cp->hd.oBox.radii[0].vz;
@ -897,7 +898,7 @@ void DrawCar(_CAR_DATA *cp, int view)
if (vvvar < iVar11 * iVar11)
{
vvvar = (int)(cp->hd).oBox.length[1];
vvvar = cp->hd.oBox.length[1];
if (iVar9 < 0)
iVar9 = -iVar9;
@ -912,6 +913,7 @@ void DrawCar(_CAR_DATA *cp, int view)
iVar6 = -1;
}
}
if (iVar6 == -1)
return;
@ -935,7 +937,7 @@ void DrawCar(_CAR_DATA *cp, int view)
} while (-1 < iVar6);
}*/
if (((pos.vz < 0x157d) && (gForceLowDetailCars == 0)) || (cp->controlType == '\x01'))
if (pos.vz < 5501 && gForceLowDetailCars == 0 || cp->controlType == 1)
{
vvvar = cp->hd.speed * 0x2000;
iVar6 = MaxPlayerDamage[0];
@ -945,7 +947,7 @@ void DrawCar(_CAR_DATA *cp, int view)
iVar6 = MaxPlayerDamage[(int)cp->ai.padid];
}
if ((int)(uint)cp->totalDamage < iVar6)
if (cp->totalDamage < iVar6)
{
sVar3 = cp->ap.damage[0];
@ -985,6 +987,7 @@ void DrawCar(_CAR_DATA *cp, int view)
gTempCarUVPtr = gTempHDCarUVDump[cp->id];
NewCarModel[uVar12].vlist = gTempCarVertDump[cp->id];
NewCarModel[uVar12].nlist = gTempCarVertDump[cp->id];
MulMatrix0(&inv_camera_matrix, m1, &workmatrix);
FindCarLightFade(&workmatrix);
@ -994,6 +997,7 @@ void DrawCar(_CAR_DATA *cp, int view)
}
else
{
NewLowCarModel[uVar12].nlist = gTempCarVertDump[cp->id];
gTempCarUVPtr = gTempLDCarUVDump[cp->id];
@ -1003,11 +1007,12 @@ void DrawCar(_CAR_DATA *cp, int view)
PlaceShadowForCar(cp->hd.shadowPoints, cp->id, &pos, 0);
}
ComputeCarLightingLevels(cp, '\0');
MulMatrix0(&inv_camera_matrix, m1, (MATRIX *)&d);
FindCarLightFade((MATRIX *)&d);
ComputeCarLightingLevels(cp, 0);
MulMatrix0(&inv_camera_matrix, m1, &workmatrix);
FindCarLightFade(&workmatrix);
DrawCarObject(NewLowCarModel + uVar12, (MATRIX *)&d, &pos, &local_c0, cp->ap.palette, cp, 0);
DrawCarObject(NewLowCarModel + uVar12, &workmatrix, &pos, &local_c0, cp->ap.palette, cp, 0);
}
TransparentObject = 0;
@ -1022,6 +1027,7 @@ void DrawCar(_CAR_DATA *cp, int view)
CivCarFX(cp);
}
}
if (gLightsOn != 0 && lightsOnDelay[cp->id] == 0)
{
if (cp->controlType == 2)

View File

@ -1321,7 +1321,7 @@ void SetShadowPoints(_CAR_DATA *c0)
{
bool bVar1;
uint uVar2;
uint *puVar3;
uint puVar3;
SVECTOR *pSVar5;
int iVar6;
SVECTOR disp;
@ -1366,15 +1366,15 @@ void SetShadowPoints(_CAR_DATA *c0)
c0->hd.shadowPoints[iVar6].vy = surfacePoint.vy;
c0->hd.shadowPoints[iVar6].vz = surfacePoint.vz;
puVar3 = (uint *)&(c0->hd).shadowPoints[iVar6].vy;
uVar2 = *puVar3;
puVar3 = c0->hd.shadowPoints[iVar6].vy;
uVar2 = puVar3;
bVar1 = hSubShad != 0;
*puVar3 = uVar2 & 0xfffffffe;
c0->hd.shadowPoints[iVar6].vy = uVar2 & 0xfffffffe;
if (bVar1)
*puVar3 = uVar2 & 0xfffffffe | 1;
c0->hd.shadowPoints[iVar6].vy = uVar2 & 0xfffffffe | 1;
iVar6 = iVar6 + 1;
pSVar5 = pSVar5 + 1;

View File

@ -701,7 +701,7 @@ int gShadowTexturePage;
int gShadowTextureNum;
UV shadowuv;
POLY_FT4 shadowPolys[20][2];
POLY_FT4 shadowPolys[2][20];
// [D]
void InitShadow(void)
@ -766,7 +766,6 @@ void InitShadow(void)
uVar7 = shadowuv.v2;
uVar6 = shadowuv.u2;
iVar12 = iVar12 + -1;
setPolyFT4(pPVar11);
pPVar11->r0 = 'P';
@ -787,6 +786,7 @@ void InitShadow(void)
pPVar11->v3 = uVar9;
pPVar11 ++;
iVar12--;
} while (-1 < iVar12);
iVar12 = iVar13;
@ -1075,8 +1075,7 @@ void SubdivShadow(long z0, long z1, long z2, long z3, POLY_FT4 *sps)
memcpy(spd, sps, sizeof(POLY_FT4)*4);
addPrim(current->ot + (z0 * 2 + z3 * 6 >> 6), &spd[0]);
addPrim(current->ot + (z0 * 2 + z3 * 6 >> 6), &spd[1]);
addPrim(current->ot + (z0 * 2 + z3 * 6 >> 6), spd);
#endif // PSX
}
@ -1156,7 +1155,7 @@ void PlaceShadowForCar(VECTOR *shadowPoints, int slot, VECTOR *CarPos, int zclip
gte_SetTransVector(&dummy);
gte_SetRotMatrix(&inv_camera_matrix);
sps = shadowPolys[slot + current->id];
sps = &shadowPolys[current->id][slot];
gte_ldv3(&points[0], &points[1], &points[2]);