GetScreenCoord lua parity
This commit is contained in:
1 parent
84535faa90
commit
302eaf60b5
1 file changed
+17
-20
+17
-20
@@ -8882,7 +8882,7 @@ static void K_drawKartBumpersOrKarma(void)
|
||||
// Code updated in Lua by GenericHeroGuy for libSG
|
||||
// Badly ported to C by NepDisk and acutally made to work and fixed by Indev!(Thanks so much!)
|
||||
// original code by Lat'
|
||||
static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came, fixed_t mx, fixed_t my, fixed_t mz)
|
||||
static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came, mobj_t *target, fixed_t hofs)
|
||||
{
|
||||
fixed_t camx, camy, camz;
|
||||
angle_t camangle, camaiming;
|
||||
@@ -8894,6 +8894,7 @@ static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came,
|
||||
fixed_t fovratio;
|
||||
fixed_t offset;
|
||||
boolean srcflip;
|
||||
boolean targflip;
|
||||
fixed_t y;
|
||||
fixed_t x;
|
||||
|
||||
@@ -8901,6 +8902,9 @@ static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came,
|
||||
vec->x = -1;
|
||||
vec->y = -1;
|
||||
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
if (player->awayviewtics) {
|
||||
camx = player->awayviewmobj->x;
|
||||
camy = player->awayviewmobj->y;
|
||||
@@ -8929,7 +8933,7 @@ static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came,
|
||||
|
||||
// X coordinate
|
||||
// get difference between camangle and angle towards target
|
||||
x = (INT32)camangle - (INT32)R_PointToAngle2(camx, camy, mx, my);
|
||||
x = (INT32)camangle - (INT32)R_PointToAngle2(camx, camy, target->x, target->y);
|
||||
|
||||
distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK);
|
||||
if (!distfact) distfact = 1;
|
||||
@@ -8940,15 +8944,18 @@ static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came,
|
||||
return;
|
||||
|
||||
// flipping
|
||||
targflip = target->eflags & MFE_VERTICALFLIP;
|
||||
srcflip = player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP;
|
||||
|
||||
// Y coordinate
|
||||
// getting the angle difference here is a bit more involved...
|
||||
// start by getting the height difference between the camera and target
|
||||
y = camz - mz;
|
||||
y = camz - target->z - (targflip ? target->height/1.5 : 0); // for some reason needs to be divided by 1.5 idk
|
||||
if (hofs)
|
||||
y = y - (targflip ? -hofs : hofs);
|
||||
|
||||
// then get the distance between camera and target
|
||||
dist = R_PointToDist2(camx, camy, mx, my);
|
||||
dist = R_PointToDist2(camx, camy, target->x, target->y);
|
||||
|
||||
#ifdef HWRENDER
|
||||
// NOW we can get the angle differnce
|
||||
@@ -9000,8 +9007,7 @@ static void K_GetScreenCoords(vector2_t *vec, player_t *player, camera_t *came,
|
||||
if (splitscreen == 1) // divide by 320/200 (1.6) on 2P splitscreen
|
||||
x = (x/2) + (x/8);
|
||||
x = x + xres;
|
||||
|
||||
|
||||
|
||||
// get splitscreen index
|
||||
int splitindex = stplyrnum;
|
||||
|
||||
@@ -9119,15 +9125,13 @@ static void K_drawNameTags(void)
|
||||
else
|
||||
flipped = players[i].mo->eflags & MFE_VERTICALFLIP;
|
||||
|
||||
z = players[i].mo->z;
|
||||
|
||||
z += (players[i].mo->eflags & MFE_VERTICALFLIP) ? -players[i].mo->height/2 : players[i].mo->height;
|
||||
z = players[i].mo->height;
|
||||
|
||||
//Saltyhop hehe
|
||||
if (cv_saltyhop.value && cv_nametaghop.value)
|
||||
z += (players[i].mo->eflags & MFE_VERTICALFLIP) ? -players[i].mo->spriteyoffset : players[i].mo->spriteyoffset;
|
||||
z += players[i].mo->spriteyoffset;
|
||||
|
||||
K_GetScreenCoords(&pos, stplyr, camera, players[i].mo->x, players[i].mo->y, z);
|
||||
K_GetScreenCoords(&pos, stplyr, camera, players[i].mo, z);
|
||||
|
||||
//Check for negative screencoords
|
||||
if (pos.x == -1 || pos.y == -1)
|
||||
@@ -9267,7 +9271,6 @@ static void K_drawDriftGauge(void)
|
||||
INT32 hudtransflag = V_LocalTransFlag();
|
||||
int dup = vid.dupx;
|
||||
int i,j;
|
||||
fixed_t z;
|
||||
|
||||
UINT8 driftcolors[3][4] = {
|
||||
{0, 0, 10, 16}, // no drift
|
||||
@@ -9287,20 +9290,14 @@ static void K_drawDriftGauge(void)
|
||||
|
||||
if (!stplyr->mo || !stplyr->kartstuff[k_drift] || (!splitscreen && !camera->chase))
|
||||
return;
|
||||
|
||||
z = stplyr->mo->z;
|
||||
|
||||
//vertical flip
|
||||
if (stplyr->mo->eflags & MFE_VERTICALFLIP)
|
||||
z += stplyr->mo->height*2;
|
||||
|
||||
if (!splitscreen)
|
||||
K_GetScreenCoords(&pos, stplyr, camera, stplyr->mo->x, stplyr->mo->y, z+FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale));
|
||||
K_GetScreenCoords(&pos, stplyr, camera, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale));
|
||||
else
|
||||
{
|
||||
//Loop through each player camera for splitscreen.
|
||||
for (j = 0; j <= stplyrnum; j++)
|
||||
K_GetScreenCoords(&pos, stplyr, &camera[j], stplyr->mo->x, stplyr->mo->y, z+FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale));
|
||||
K_GetScreenCoords(&pos, stplyr, &camera[j], stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale));
|
||||
}
|
||||
|
||||
//Check for negative screencoords
|
||||
|
||||
Reference in new issue
Block a user