mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-13 06:13:18 +00:00
Use original portal's origin for the viewpoint displacement
This commit is contained in:
parent
9335ee3031
commit
87d40fc3cc
6 changed files with 35 additions and 28 deletions
|
@ -4766,6 +4766,8 @@ static void P_NetArchiveSectorPortals(void)
|
|||
UINT8 type = secportals[i].type;
|
||||
|
||||
WRITEUINT8(save_p, type);
|
||||
WRITEFIXED(save_p, secportals[i].origin.x);
|
||||
WRITEFIXED(save_p, secportals[i].origin.y);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -4808,6 +4810,8 @@ static void P_NetUnArchiveSectorPortals(void)
|
|||
sectorportal_t *secportal = &secportals[id];
|
||||
|
||||
secportal->type = READUINT8(save_p);
|
||||
secportal->origin.x = READFIXED(save_p);
|
||||
secportal->origin.y = READFIXED(save_p);
|
||||
|
||||
switch (secportal->type)
|
||||
{
|
||||
|
|
35
src/p_spec.c
35
src/p_spec.c
|
@ -6325,30 +6325,35 @@ static void P_DoPortalCopyFromLine(sector_t *dest_sector, int plane_type, int ta
|
|||
}
|
||||
}
|
||||
|
||||
static sectorportal_t *P_SectorGetFloorPortalOrCreate(sector_t *sector, UINT32 *result)
|
||||
static sectorportal_t *P_SectorGetPortalOrCreate(sector_t *sector, UINT32 *num, UINT32 *result)
|
||||
{
|
||||
*result = sector->portal_floor;
|
||||
sectorportal_t *secportal = NULL;
|
||||
|
||||
if (*result >= secportalcount)
|
||||
if (*num >= secportalcount)
|
||||
{
|
||||
*result = P_NewSectorPortal();
|
||||
sector->portal_floor = *result;
|
||||
*num = P_NewSectorPortal();
|
||||
secportal = &secportals[*num];
|
||||
secportal->origin.x = sector->soundorg.x;
|
||||
secportal->origin.y = sector->soundorg.y;
|
||||
*result = *num;
|
||||
}
|
||||
else
|
||||
{
|
||||
*result = *num;
|
||||
secportal = &secportals[*num];
|
||||
}
|
||||
|
||||
return &secportals[sector->portal_floor];
|
||||
return secportal;
|
||||
}
|
||||
|
||||
static sectorportal_t *P_SectorGetFloorPortalOrCreate(sector_t *sector, UINT32 *result)
|
||||
{
|
||||
return P_SectorGetPortalOrCreate(sector, §or->portal_floor, result);
|
||||
}
|
||||
|
||||
static sectorportal_t *P_SectorGetCeilingPortalOrCreate(sector_t *sector, UINT32 *result)
|
||||
{
|
||||
*result = sector->portal_floor;
|
||||
|
||||
if (*result >= secportalcount)
|
||||
{
|
||||
*result = P_NewSectorPortal();
|
||||
sector->portal_ceiling = *result;
|
||||
}
|
||||
|
||||
return &secportals[sector->portal_ceiling];
|
||||
return P_SectorGetPortalOrCreate(sector, §or->portal_ceiling, result);
|
||||
}
|
||||
|
||||
static void P_CopySectorPortalToLines(UINT32 portal_num, int sector_tag)
|
||||
|
|
|
@ -489,7 +489,7 @@ static void R_AddLine(seg_t *line)
|
|||
{
|
||||
if (portalrender < cv_maxportals.value)
|
||||
{
|
||||
Portal_AddTransferred(line->linedef-lines, line->linedef->secportal, x1, x2);
|
||||
Portal_AddTransferred(line->linedef->secportal, x1, x2);
|
||||
goto clipsolid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,6 +231,9 @@ typedef struct sectorportal_s
|
|||
struct sector_s *sector;
|
||||
struct mobj_s *mobj;
|
||||
};
|
||||
struct {
|
||||
fixed_t x, y;
|
||||
} origin;
|
||||
} sectorportal_t;
|
||||
|
||||
typedef struct ffloor_s
|
||||
|
|
|
@ -323,7 +323,7 @@ void Portal_AddSkybox (const visplane_t* plane)
|
|||
Portal_GetViewpointForSkybox(portal);
|
||||
}
|
||||
|
||||
static void Portal_GetViewpointForSecPortal(portal_t *portal, sectorportal_t *secportal, fixed_t origin_x, fixed_t origin_y)
|
||||
static void Portal_GetViewpointForSecPortal(portal_t *portal, sectorportal_t *secportal)
|
||||
{
|
||||
fixed_t x, y, z, angle;
|
||||
|
||||
|
@ -368,8 +368,8 @@ static void Portal_GetViewpointForSecPortal(portal_t *portal, sectorportal_t *se
|
|||
return;
|
||||
}
|
||||
|
||||
fixed_t refx = origin_x - viewx;
|
||||
fixed_t refy = origin_y - viewy;
|
||||
fixed_t refx = secportal->origin.x - viewx;
|
||||
fixed_t refy = secportal->origin.y - viewy;
|
||||
|
||||
// Rotate the X/Y to match the target angle
|
||||
if (angle != 0)
|
||||
|
@ -411,12 +411,12 @@ void Portal_AddSectorPortal (const visplane_t* plane)
|
|||
portal->is_horizon = false;
|
||||
portal->horizon_sector = NULL;
|
||||
|
||||
Portal_GetViewpointForSecPortal(portal, secportal, plane->sector->soundorg.x, plane->sector->soundorg.y);
|
||||
Portal_GetViewpointForSecPortal(portal, secportal);
|
||||
}
|
||||
|
||||
/** Creates a transferred sector portal.
|
||||
*/
|
||||
void Portal_AddTransferred (const INT32 linenum, UINT32 secportalnum, const INT32 x1, const INT32 x2)
|
||||
void Portal_AddTransferred (UINT32 secportalnum, const INT32 x1, const INT32 x2)
|
||||
{
|
||||
if (secportalnum >= secportalcount)
|
||||
return;
|
||||
|
@ -433,12 +433,7 @@ void Portal_AddTransferred (const INT32 linenum, UINT32 secportalnum, const INT3
|
|||
if (secportal->type == SECPORTAL_SKYBOX)
|
||||
Portal_GetViewpointForSkybox(portal);
|
||||
else
|
||||
{
|
||||
line_t *line = &lines[linenum];
|
||||
fixed_t refx = (line->v1->x + line->v2->x) / 2;
|
||||
fixed_t refy = (line->v1->y + line->v2->y) / 2;
|
||||
Portal_GetViewpointForSecPortal(portal, secportal, refx, refy);
|
||||
}
|
||||
Portal_GetViewpointForSecPortal(portal, secportal);
|
||||
|
||||
if (secportal->type == SECPORTAL_LINE)
|
||||
portal->clipline = secportal->line.dest - lines;
|
||||
|
|
|
@ -58,7 +58,7 @@ 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_AddSectorPortal (const visplane_t* plane);
|
||||
void Portal_AddTransferred (const INT32 linenum, UINT32 secportalnum, const INT32 x1, const INT32 x2);
|
||||
void Portal_AddTransferred (UINT32 secportalnum, const INT32 x1, const INT32 x2);
|
||||
|
||||
void Portal_ClipRange (portal_t* portal);
|
||||
void Portal_ClipApply (const portal_t* portal);
|
||||
|
|
Loading…
Reference in a new issue