mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'splitscreen-skybox' into 'master'
Keep track of skybox across splitscreen and change viewpoint See merge request KartKrew/Kart!533
This commit is contained in:
commit
d67a074a01
12 changed files with 125 additions and 47 deletions
|
|
@ -290,6 +290,12 @@ typedef struct botvars_s
|
|||
tic_t spindashconfirm; // When high enough, they will try spindashing
|
||||
} botvars_t;
|
||||
|
||||
// player_t struct for all skybox variables
|
||||
typedef struct {
|
||||
mobj_t * viewpoint;
|
||||
mobj_t * centerpoint;
|
||||
} skybox_t;
|
||||
|
||||
// ========================================================================
|
||||
// PLAYER STRUCTURE
|
||||
// ========================================================================
|
||||
|
|
@ -311,6 +317,8 @@ typedef struct player_s
|
|||
// bounded/scaled total momentum.
|
||||
fixed_t bob;
|
||||
|
||||
skybox_t skybox;
|
||||
|
||||
angle_t viewrollangle;
|
||||
angle_t old_viewrollangle;
|
||||
// camera tilt
|
||||
|
|
|
|||
|
|
@ -6221,7 +6221,7 @@ void HWR_RenderPlayerView(void)
|
|||
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
|
||||
postimg_t *type = &postimgtype[viewssnum];
|
||||
|
||||
const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on
|
||||
const boolean skybox = (player->skybox.viewpoint && cv_skybox.value); // True if there's a skybox object and skyboxes are on
|
||||
|
||||
FRGBAFloat ClearColor;
|
||||
|
||||
|
|
|
|||
|
|
@ -2015,8 +2015,12 @@ static int lib_pSetSkyboxMobj(lua_State *L)
|
|||
if (w > 1 || w < 0)
|
||||
return luaL_error(L, "skybox mobj index %d is out of range for P_SetSkyboxMobj argument #2 (expected 0 or 1)", w);
|
||||
|
||||
#if 0
|
||||
if (!user || P_IsLocalPlayer(user))
|
||||
skyboxmo[w] = mo;
|
||||
#else
|
||||
CONS_Alert(CONS_WARNING, "TODO: P_SetSkyboxMobj is unimplemented\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10867,6 +10867,9 @@ void P_SpawnPlayer(INT32 playernum)
|
|||
p->awayviewmobj = NULL;
|
||||
p->awayviewtics = 0;
|
||||
|
||||
p->skybox.viewpoint = skyboxviewpnts[0];
|
||||
p->skybox.centerpoint = skyboxcenterpnts[0];
|
||||
|
||||
P_SetTarget(&p->follower, NULL); // cleanse follower from existence
|
||||
|
||||
// set the scale to the mobj's destscale so settings get correctly set. if we don't, they sometimes don't.
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ typedef enum
|
|||
AWAYVIEW = 0x01,
|
||||
FOLLOWITEM = 0x02,
|
||||
FOLLOWER = 0x04,
|
||||
SKYBOXVIEW = 0x08,
|
||||
SKYBOXCENTER = 0x10,
|
||||
} player_saveflags;
|
||||
|
||||
static inline void P_ArchivePlayer(void)
|
||||
|
|
@ -178,6 +180,12 @@ static void P_NetArchivePlayers(void)
|
|||
if (players[i].follower)
|
||||
flags |= FOLLOWER;
|
||||
|
||||
if (players[i].skybox.viewpoint)
|
||||
flags |= SKYBOXVIEW;
|
||||
|
||||
if (players[i].skybox.centerpoint)
|
||||
flags |= SKYBOXCENTER;
|
||||
|
||||
WRITEINT16(save_p, players[i].lastsidehit);
|
||||
WRITEINT16(save_p, players[i].lastlinehit);
|
||||
|
||||
|
|
@ -190,6 +198,12 @@ static void P_NetArchivePlayers(void)
|
|||
|
||||
WRITEUINT16(save_p, flags);
|
||||
|
||||
if (flags & SKYBOXVIEW)
|
||||
WRITEUINT32(save_p, players[i].skybox.viewpoint->mobjnum);
|
||||
|
||||
if (flags & SKYBOXCENTER)
|
||||
WRITEUINT32(save_p, players[i].skybox.centerpoint->mobjnum);
|
||||
|
||||
if (flags & AWAYVIEW)
|
||||
WRITEUINT32(save_p, players[i].awayviewmobj->mobjnum);
|
||||
|
||||
|
|
@ -447,6 +461,12 @@ static void P_NetUnArchivePlayers(void)
|
|||
|
||||
flags = READUINT16(save_p);
|
||||
|
||||
if (flags & SKYBOXVIEW)
|
||||
players[i].skybox.viewpoint = (mobj_t *)(size_t)READUINT32(save_p);
|
||||
|
||||
if (flags & SKYBOXCENTER)
|
||||
players[i].skybox.centerpoint = (mobj_t *)(size_t)READUINT32(save_p);
|
||||
|
||||
if (flags & AWAYVIEW)
|
||||
players[i].awayviewmobj = (mobj_t *)(size_t)READUINT32(save_p);
|
||||
|
||||
|
|
@ -4130,6 +4150,20 @@ static void P_RelinkPointers(void)
|
|||
}
|
||||
if (mobj->player)
|
||||
{
|
||||
if ( mobj->player->skybox.viewpoint)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->skybox.viewpoint;
|
||||
mobj->player->skybox.viewpoint = NULL;
|
||||
if (!P_SetTarget(&mobj->player->skybox.viewpoint, P_FindNewPosition(temp)))
|
||||
CONS_Debug(DBG_GAMELOGIC, "skybox.viewpoint not found on %d\n", mobj->type);
|
||||
}
|
||||
if ( mobj->player->skybox.centerpoint)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->skybox.centerpoint;
|
||||
mobj->player->skybox.centerpoint = NULL;
|
||||
if (!P_SetTarget(&mobj->player->skybox.centerpoint, P_FindNewPosition(temp)))
|
||||
CONS_Debug(DBG_GAMELOGIC, "skybox.centerpoint not found on %d\n", mobj->type);
|
||||
}
|
||||
if ( mobj->player->awayviewmobj)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->awayviewmobj;
|
||||
|
|
|
|||
|
|
@ -3514,6 +3514,7 @@ static void P_InitLevelSettings(void)
|
|||
speedscramble = encorescramble = -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Respawns all the mapthings and mobjs in the map from the already loaded map data.
|
||||
void P_RespawnThings(void)
|
||||
{
|
||||
|
|
@ -3548,6 +3549,7 @@ void P_RespawnThings(void)
|
|||
skyboxmo[0] = skyboxviewpnts[(viewid >= 0) ? viewid : 0];
|
||||
skyboxmo[1] = skyboxcenterpnts[(centerid >= 0) ? centerid : 0];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void P_RunLevelScript(const char *scriptname)
|
||||
{
|
||||
|
|
@ -3622,14 +3624,19 @@ static void P_ResetSpawnpoints(void)
|
|||
|
||||
// reset the player starts
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
playerstarts[i] = bluectfstarts[i] = redctfstarts[i] = NULL;
|
||||
|
||||
if (playeringame[i])
|
||||
{
|
||||
players[i].skybox.viewpoint = NULL;
|
||||
players[i].skybox.centerpoint = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_DM_STARTS; i++)
|
||||
deathmatchstarts[i] = NULL;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
skyboxmo[i] = NULL;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
skyboxviewpnts[i] = skyboxcenterpnts[i] = NULL;
|
||||
}
|
||||
|
|
@ -4076,8 +4083,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
P_SpawnSpecialsAfterSlopes();
|
||||
|
||||
P_SpawnMapThings(!fromnetsave);
|
||||
skyboxmo[0] = skyboxviewpnts[0];
|
||||
skyboxmo[1] = skyboxcenterpnts[0];
|
||||
|
||||
for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++)
|
||||
if (!playerstarts[numcoopstarts])
|
||||
|
|
|
|||
49
src/p_spec.c
49
src/p_spec.c
|
|
@ -52,7 +52,6 @@
|
|||
// Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog
|
||||
#include <errno.h>
|
||||
|
||||
mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint
|
||||
mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs
|
||||
mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs
|
||||
|
||||
|
|
@ -2090,6 +2089,19 @@ static mobj_t *P_GetObjectTypeInSectorNum(mobjtype_t type, size_t s)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void P_SwitchSkybox(INT32 ldflags, player_t *player, skybox_t *skybox)
|
||||
{
|
||||
if (!(ldflags & ML_EFFECT4)) // Solid Midtexture turns off viewpoint setting
|
||||
{
|
||||
player->skybox.viewpoint = skybox->viewpoint;
|
||||
}
|
||||
|
||||
if (ldflags & ML_BLOCKPLAYERS) // Block Enemies turns ON centerpoint setting
|
||||
{
|
||||
player->skybox.centerpoint = skybox->centerpoint;
|
||||
}
|
||||
}
|
||||
|
||||
/** Processes the line special triggered by an object.
|
||||
*
|
||||
* \param line Line with the special command on it.
|
||||
|
|
@ -3155,7 +3167,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
break;
|
||||
}
|
||||
case 448: // Change skybox viewpoint/centerpoint
|
||||
if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || (line->flags & ML_NOCLIMB))
|
||||
if ((mo && mo->player) || (line->flags & ML_NOCLIMB))
|
||||
{
|
||||
INT32 viewid = sides[line->sidenum[0]].textureoffset>>FRACBITS;
|
||||
INT32 centerid = sides[line->sidenum[0]].rowoffset>>FRACBITS;
|
||||
|
|
@ -3168,23 +3180,32 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
|||
}
|
||||
else
|
||||
{
|
||||
skybox_t skybox;
|
||||
|
||||
// set viewpoint mobj
|
||||
if (!(line->flags & ML_EFFECT4)) // Solid Midtexture turns off viewpoint setting
|
||||
{
|
||||
if (viewid >= 0 && viewid < 16)
|
||||
skyboxmo[0] = skyboxviewpnts[viewid];
|
||||
else
|
||||
skyboxmo[0] = NULL;
|
||||
}
|
||||
if (viewid >= 0 && viewid < 16)
|
||||
skybox.viewpoint = skyboxviewpnts[viewid];
|
||||
else
|
||||
skybox.viewpoint = NULL;
|
||||
|
||||
// set centerpoint mobj
|
||||
if (line->flags & ML_BLOCKPLAYERS) // Block Enemies turns ON centerpoint setting
|
||||
if (centerid >= 0 && centerid < 16)
|
||||
skybox.centerpoint = skyboxcenterpnts[centerid];
|
||||
else
|
||||
skybox.centerpoint = NULL;
|
||||
|
||||
if (line->flags & ML_NOCLIMB) // Applies to all players
|
||||
{
|
||||
if (centerid >= 0 && centerid < 16)
|
||||
skyboxmo[1] = skyboxcenterpnts[centerid];
|
||||
else
|
||||
skyboxmo[1] = NULL;
|
||||
INT32 i;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; ++i)
|
||||
{
|
||||
if (playeringame[i])
|
||||
P_SwitchSkybox(line->flags, &players[i], &skybox);
|
||||
}
|
||||
}
|
||||
else
|
||||
P_SwitchSkybox(line->flags, mo->player, &skybox);
|
||||
}
|
||||
|
||||
CONS_Debug(DBG_GAMELOGIC, "Line type 448 Executor: viewid = %d, centerid = %d, viewpoint? = %s, centerpoint? = %s\n",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#ifndef __P_SPEC__
|
||||
#define __P_SPEC__
|
||||
|
||||
extern mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint
|
||||
extern mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs
|
||||
extern mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs
|
||||
|
||||
|
|
|
|||
19
src/r_main.c
19
src/r_main.c
|
|
@ -28,7 +28,7 @@
|
|||
#include "am_map.h"
|
||||
#include "d_main.h"
|
||||
#include "v_video.h"
|
||||
#include "p_spec.h" // skyboxmo
|
||||
//#include "p_spec.h"
|
||||
#include "p_setup.h"
|
||||
#include "z_zone.h"
|
||||
#include "m_random.h" // quake camera shake
|
||||
|
|
@ -1331,7 +1331,7 @@ void R_SkyboxFrame(player_t *player)
|
|||
|
||||
// cut-away view stuff
|
||||
newview->sky = true;
|
||||
r_viewmobj = skyboxmo[0];
|
||||
r_viewmobj = player->skybox.viewpoint;
|
||||
#ifdef PARANOIA
|
||||
if (!r_viewmobj)
|
||||
{
|
||||
|
|
@ -1372,6 +1372,7 @@ void R_SkyboxFrame(player_t *player)
|
|||
{
|
||||
mapheader_t *mh = mapheaderinfo[gamemap-1];
|
||||
vector3_t campos = {0,0,0}; // Position of player's actual view point
|
||||
mobj_t *center = player->skybox.centerpoint;
|
||||
|
||||
if (player->awayviewtics) {
|
||||
campos.x = player->awayviewmobj->x;
|
||||
|
|
@ -1393,18 +1394,18 @@ void R_SkyboxFrame(player_t *player)
|
|||
campos.y += quake.y;
|
||||
campos.z += quake.z;
|
||||
|
||||
if (skyboxmo[1]) // Is there a viewpoint?
|
||||
if (center) // Is there a viewpoint?
|
||||
{
|
||||
fixed_t x = 0, y = 0;
|
||||
if (mh->skybox_scalex > 0)
|
||||
x = (campos.x - skyboxmo[1]->x) / mh->skybox_scalex;
|
||||
x = (campos.x - center->x) / mh->skybox_scalex;
|
||||
else if (mh->skybox_scalex < 0)
|
||||
x = (campos.x - skyboxmo[1]->x) * -mh->skybox_scalex;
|
||||
x = (campos.x - center->x) * -mh->skybox_scalex;
|
||||
|
||||
if (mh->skybox_scaley > 0)
|
||||
y = (campos.y - skyboxmo[1]->y) / mh->skybox_scaley;
|
||||
y = (campos.y - center->y) / mh->skybox_scaley;
|
||||
else if (mh->skybox_scaley < 0)
|
||||
y = (campos.y - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||
y = (campos.y - center->y) * -mh->skybox_scaley;
|
||||
|
||||
if (r_viewmobj->angle == 0)
|
||||
{
|
||||
|
|
@ -1617,8 +1618,8 @@ void R_RenderPlayerView(void)
|
|||
|
||||
|
||||
// Add skybox portals caused by sky visplanes.
|
||||
if (cv_skybox.value && skyboxmo[0])
|
||||
Portal_AddSkyboxPortals();
|
||||
if (cv_skybox.value && player->skybox.viewpoint)
|
||||
Portal_AddSkyboxPortals(player);
|
||||
|
||||
// Portal rendering. Hijacks the BSP traversal.
|
||||
ps_sw_portaltime = I_GetPreciseTime();
|
||||
|
|
|
|||
|
|
@ -127,6 +127,4 @@ typedef struct planemgr_s
|
|||
|
||||
extern visffloor_t ffloor[MAXFFLOORS];
|
||||
extern INT32 numffloors;
|
||||
|
||||
void Portal_AddSkyboxPortals (void);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -256,12 +256,17 @@ static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16*
|
|||
* Applies the necessary offsets and rotation to give
|
||||
* a depth illusion to the skybox.
|
||||
*/
|
||||
void Portal_AddSkybox (const visplane_t* plane)
|
||||
void Portal_AddSkybox
|
||||
( const player_t * player,
|
||||
const visplane_t * plane)
|
||||
{
|
||||
INT16 start, end;
|
||||
mapheader_t *mh;
|
||||
portal_t* portal;
|
||||
|
||||
mobj_t *viewpoint = player->skybox.viewpoint;
|
||||
mobj_t *center = player->skybox.centerpoint;
|
||||
|
||||
if (TrimVisplaneBounds(plane, &start, &end))
|
||||
return;
|
||||
|
||||
|
|
@ -269,28 +274,28 @@ void Portal_AddSkybox (const visplane_t* plane)
|
|||
|
||||
Portal_ClipVisplane(plane, portal);
|
||||
|
||||
portal->viewx = skyboxmo[0]->x;
|
||||
portal->viewy = skyboxmo[0]->y;
|
||||
portal->viewz = skyboxmo[0]->z;
|
||||
portal->viewangle = viewangle + skyboxmo[0]->angle;
|
||||
portal->viewx = viewpoint->x;
|
||||
portal->viewy = viewpoint->y;
|
||||
portal->viewz = viewpoint->z;
|
||||
portal->viewangle = viewangle + viewpoint->angle;
|
||||
|
||||
mh = mapheaderinfo[gamemap-1];
|
||||
|
||||
// If a relative viewpoint exists, offset the viewpoint.
|
||||
if (skyboxmo[1])
|
||||
if (center)
|
||||
{
|
||||
fixed_t x = 0, y = 0;
|
||||
angle_t ang = skyboxmo[0]->angle>>ANGLETOFINESHIFT;
|
||||
angle_t ang = viewpoint->angle>>ANGLETOFINESHIFT;
|
||||
|
||||
if (mh->skybox_scalex > 0)
|
||||
x = (viewx - skyboxmo[1]->x) / mh->skybox_scalex;
|
||||
x = (viewx - center->x) / mh->skybox_scalex;
|
||||
else if (mh->skybox_scalex < 0)
|
||||
x = (viewx - skyboxmo[1]->x) * -mh->skybox_scalex;
|
||||
x = (viewx - center->x) * -mh->skybox_scalex;
|
||||
|
||||
if (mh->skybox_scaley > 0)
|
||||
y = (viewy - skyboxmo[1]->y) / mh->skybox_scaley;
|
||||
y = (viewy - center->y) / mh->skybox_scaley;
|
||||
else if (mh->skybox_scaley < 0)
|
||||
y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||
y = (viewy - center->y) * -mh->skybox_scaley;
|
||||
|
||||
// Apply transform to account for the skybox viewport angle.
|
||||
portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||
|
|
@ -308,7 +313,7 @@ void Portal_AddSkybox (const visplane_t* plane)
|
|||
/** Creates portals for the currently existing sky visplanes.
|
||||
* The visplanes are also removed and cleared from the list.
|
||||
*/
|
||||
void Portal_AddSkyboxPortals (void)
|
||||
void Portal_AddSkyboxPortals (const player_t *player)
|
||||
{
|
||||
visplane_t *pl;
|
||||
INT32 i;
|
||||
|
|
@ -320,7 +325,7 @@ void Portal_AddSkyboxPortals (void)
|
|||
{
|
||||
if (pl->picnum == skyflatnum)
|
||||
{
|
||||
Portal_AddSkybox(pl);
|
||||
Portal_AddSkybox(player, pl);
|
||||
|
||||
pl->minx = 0;
|
||||
pl->maxx = -1;
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ extern INT32 portalclipstart, portalclipend;
|
|||
void Portal_InitList (void);
|
||||
void Portal_Remove (portal_t* portal);
|
||||
void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2);
|
||||
void Portal_AddSkybox (const visplane_t* plane);
|
||||
void Portal_AddSkybox (const player_t* player, const visplane_t* plane);
|
||||
|
||||
void Portal_ClipRange (portal_t* portal);
|
||||
void Portal_ClipApply (const portal_t* portal);
|
||||
|
||||
void Portal_AddSkyboxPortals (void);
|
||||
void Portal_AddSkyboxPortals (const player_t* player);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue