mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-29 05:41:02 +00:00
Make new pv1/pv2 seg pointers, so AdjustSeg doesn't modify the v1/v2 pointers directly anymore
Yes I know they're void * in r_defs.h's seg_t definition, it's quicker than trying to figure out if including hardware/hw_glob.h is a good idea or not
This commit is contained in:
parent
1cf2ce63c0
commit
90cfa5ef16
4 changed files with 42 additions and 38 deletions
|
@ -914,7 +914,7 @@ static void AdjustSegs(void)
|
||||||
}
|
}
|
||||||
if (nearv1 <= NEARDIST*NEARDIST)
|
if (nearv1 <= NEARDIST*NEARDIST)
|
||||||
// share vertice with segs
|
// share vertice with segs
|
||||||
lseg->v1 = (vertex_t *)&(p->pts[v1found]);
|
lseg->pv1 = &(p->pts[v1found]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// BP: here we can do better, using PointInSeg and compute
|
// BP: here we can do better, using PointInSeg and compute
|
||||||
|
@ -925,24 +925,24 @@ static void AdjustSegs(void)
|
||||||
polyvertex_t *pv = HWR_AllocVertex();
|
polyvertex_t *pv = HWR_AllocVertex();
|
||||||
pv->x = FIXED_TO_FLOAT(lseg->v1->x);
|
pv->x = FIXED_TO_FLOAT(lseg->v1->x);
|
||||||
pv->y = FIXED_TO_FLOAT(lseg->v1->y);
|
pv->y = FIXED_TO_FLOAT(lseg->v1->y);
|
||||||
lseg->v1 = (vertex_t *)pv;
|
lseg->pv1 = pv;
|
||||||
}
|
}
|
||||||
if (nearv2 <= NEARDIST*NEARDIST)
|
if (nearv2 <= NEARDIST*NEARDIST)
|
||||||
lseg->v2 = (vertex_t *)&(p->pts[v2found]);
|
lseg->pv2 = &(p->pts[v2found]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
polyvertex_t *pv = HWR_AllocVertex();
|
polyvertex_t *pv = HWR_AllocVertex();
|
||||||
pv->x = FIXED_TO_FLOAT(lseg->v2->x);
|
pv->x = FIXED_TO_FLOAT(lseg->v2->x);
|
||||||
pv->y = FIXED_TO_FLOAT(lseg->v2->y);
|
pv->y = FIXED_TO_FLOAT(lseg->v2->y);
|
||||||
lseg->v2 = (vertex_t *)pv;
|
lseg->pv2 = pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// recompute length
|
// recompute length
|
||||||
{
|
{
|
||||||
float x,y;
|
float x,y;
|
||||||
x = ((polyvertex_t *)lseg->v2)->x - ((polyvertex_t *)lseg->v1)->x
|
x = ((polyvertex_t *)lseg->pv2)->x - ((polyvertex_t *)lseg->pv1)->x
|
||||||
+ FIXED_TO_FLOAT(FRACUNIT/2);
|
+ FIXED_TO_FLOAT(FRACUNIT/2);
|
||||||
y = ((polyvertex_t *)lseg->v2)->y - ((polyvertex_t *)lseg->v1)->y
|
y = ((polyvertex_t *)lseg->pv2)->y - ((polyvertex_t *)lseg->pv1)->y
|
||||||
+ FIXED_TO_FLOAT(FRACUNIT/2);
|
+ FIXED_TO_FLOAT(FRACUNIT/2);
|
||||||
lseg->flength = (float)hypot(x, y);
|
lseg->flength = (float)hypot(x, y);
|
||||||
// BP: debug see this kind of segs
|
// BP: debug see this kind of segs
|
||||||
|
|
|
@ -856,11 +856,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
|
||||||
|
|
||||||
M_ClearBox(segbbox);
|
M_ClearBox(segbbox);
|
||||||
M_AddToBox(segbbox,
|
M_AddToBox(segbbox,
|
||||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x),
|
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x),
|
||||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y));
|
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y));
|
||||||
M_AddToBox(segbbox,
|
M_AddToBox(segbbox,
|
||||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x),
|
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x),
|
||||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y));
|
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y));
|
||||||
|
|
||||||
splat = (wallsplat_t *)gr_curline->linedef->splats;
|
splat = (wallsplat_t *)gr_curline->linedef->splats;
|
||||||
for (; splat; splat = splat->next)
|
for (; splat; splat = splat->next)
|
||||||
|
@ -1367,10 +1367,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
||||||
gr_sidedef = gr_curline->sidedef;
|
gr_sidedef = gr_curline->sidedef;
|
||||||
gr_linedef = gr_curline->linedef;
|
gr_linedef = gr_curline->linedef;
|
||||||
|
|
||||||
vs.x = ((polyvertex_t *)gr_curline->v1)->x;
|
vs.x = ((polyvertex_t *)gr_curline->pv1)->x;
|
||||||
vs.y = ((polyvertex_t *)gr_curline->v1)->y;
|
vs.y = ((polyvertex_t *)gr_curline->pv1)->y;
|
||||||
ve.x = ((polyvertex_t *)gr_curline->v2)->x;
|
ve.x = ((polyvertex_t *)gr_curline->pv2)->x;
|
||||||
ve.y = ((polyvertex_t *)gr_curline->v2)->y;
|
ve.y = ((polyvertex_t *)gr_curline->pv2)->y;
|
||||||
|
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
v1x = FLOAT_TO_FIXED(vs.x);
|
v1x = FLOAT_TO_FIXED(vs.x);
|
||||||
|
@ -2456,7 +2456,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||||
HWR_StoreWallRange(0, highfrac);
|
HWR_StoreWallRange(0, highfrac);
|
||||||
}
|
}
|
||||||
// Now adjust the clip size.
|
// Now adjust the clip size.
|
||||||
|
@ -2480,8 +2480,8 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||||
highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||||
HWR_StoreWallRange(lowfrac, highfrac);
|
HWR_StoreWallRange(lowfrac, highfrac);
|
||||||
}
|
}
|
||||||
next++;
|
next++;
|
||||||
|
@ -2515,7 +2515,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||||
HWR_StoreWallRange(lowfrac, 1);
|
HWR_StoreWallRange(lowfrac, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2578,8 +2578,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
highfrac = HWR_ClipViewSegment(min(start->first + 1,
|
highfrac = HWR_ClipViewSegment(min(start->first + 1,
|
||||||
start->last), (polyvertex_t *)gr_curline->v1,
|
start->last), (polyvertex_t *)gr_curline->pv1,
|
||||||
(polyvertex_t *)gr_curline->v2);
|
(polyvertex_t *)gr_curline->pv2);
|
||||||
HWR_StoreWallRange(0, highfrac);
|
HWR_StoreWallRange(0, highfrac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2598,8 +2598,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||||
highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||||
HWR_StoreWallRange(lowfrac, highfrac);
|
HWR_StoreWallRange(lowfrac, highfrac);
|
||||||
}
|
}
|
||||||
start++;
|
start++;
|
||||||
|
@ -2629,8 +2629,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lowfrac = HWR_ClipViewSegment(max(start->last - 1,
|
lowfrac = HWR_ClipViewSegment(max(start->last - 1,
|
||||||
start->first), (polyvertex_t *)gr_curline->v1,
|
start->first), (polyvertex_t *)gr_curline->pv1,
|
||||||
(polyvertex_t *)gr_curline->v2);
|
(polyvertex_t *)gr_curline->pv2);
|
||||||
HWR_StoreWallRange(lowfrac, 1);
|
HWR_StoreWallRange(lowfrac, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2691,10 +2691,10 @@ static void HWR_AddLine(seg_t * line)
|
||||||
gr_curline = line;
|
gr_curline = line;
|
||||||
|
|
||||||
// OPTIMIZE: quickly reject orthogonal back sides.
|
// OPTIMIZE: quickly reject orthogonal back sides.
|
||||||
angle1 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x),
|
angle1 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x),
|
||||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y));
|
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y));
|
||||||
angle2 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x),
|
angle2 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x),
|
||||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y));
|
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y));
|
||||||
|
|
||||||
// Clip to view edges.
|
// Clip to view edges.
|
||||||
span = angle1 - angle2;
|
span = angle1 - angle2;
|
||||||
|
@ -2736,8 +2736,8 @@ static void HWR_AddLine(seg_t * line)
|
||||||
float fx1,fx2,fy1,fy2;
|
float fx1,fx2,fy1,fy2;
|
||||||
//BP: test with a better projection than viewangletox[R_PointToAngle(angle)]
|
//BP: test with a better projection than viewangletox[R_PointToAngle(angle)]
|
||||||
// do not enable this at release 4 mul and 2 div
|
// do not enable this at release 4 mul and 2 div
|
||||||
fx1 = ((polyvertex_t *)(line->v1))->x-gr_viewx;
|
fx1 = ((polyvertex_t *)(line->pv1))->x-gr_viewx;
|
||||||
fy1 = ((polyvertex_t *)(line->v1))->y-gr_viewy;
|
fy1 = ((polyvertex_t *)(line->pv1))->y-gr_viewy;
|
||||||
fy2 = (fx1 * gr_viewcos + fy1 * gr_viewsin);
|
fy2 = (fx1 * gr_viewcos + fy1 * gr_viewsin);
|
||||||
if (fy2 < 0)
|
if (fy2 < 0)
|
||||||
// the point is back
|
// the point is back
|
||||||
|
@ -2745,8 +2745,8 @@ static void HWR_AddLine(seg_t * line)
|
||||||
else
|
else
|
||||||
fx1 = gr_windowcenterx + (fx1 * gr_viewsin - fy1 * gr_viewcos) * gr_centerx / fy2;
|
fx1 = gr_windowcenterx + (fx1 * gr_viewsin - fy1 * gr_viewcos) * gr_centerx / fy2;
|
||||||
|
|
||||||
fx2 = ((polyvertex_t *)(line->v2))->x-gr_viewx;
|
fx2 = ((polyvertex_t *)(line->pv2))->x-gr_viewx;
|
||||||
fy2 = ((polyvertex_t *)(line->v2))->y-gr_viewy;
|
fy2 = ((polyvertex_t *)(line->pv2))->y-gr_viewy;
|
||||||
fy1 = (fx2 * gr_viewcos + fy2 * gr_viewsin);
|
fy1 = (fx2 * gr_viewcos + fy2 * gr_viewsin);
|
||||||
if (fy1 < 0)
|
if (fy1 < 0)
|
||||||
// the point is back
|
// the point is back
|
||||||
|
@ -2789,10 +2789,10 @@ static void HWR_AddLine(seg_t * line)
|
||||||
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
|
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
|
||||||
fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends
|
fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends
|
||||||
|
|
||||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x);
|
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x);
|
||||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y);
|
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y);
|
||||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x);
|
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x);
|
||||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y);
|
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y);
|
||||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||||
if (slope) { \
|
if (slope) { \
|
||||||
end1 = P_GetZAt(slope, v1x, v1y); \
|
end1 = P_GetZAt(slope, v1x, v1y); \
|
||||||
|
@ -2987,8 +2987,8 @@ static inline void HWR_AddPolyObjectSegs(void)
|
||||||
pv2->x = FIXED_TO_FLOAT(gr_fakeline->v2->x);
|
pv2->x = FIXED_TO_FLOAT(gr_fakeline->v2->x);
|
||||||
pv2->y = FIXED_TO_FLOAT(gr_fakeline->v2->y);
|
pv2->y = FIXED_TO_FLOAT(gr_fakeline->v2->y);
|
||||||
|
|
||||||
gr_fakeline->v1 = (vertex_t *)pv1;
|
gr_fakeline->pv1 = pv1;
|
||||||
gr_fakeline->v2 = (vertex_t *)pv2;
|
gr_fakeline->pv2 = pv2;
|
||||||
|
|
||||||
HWR_AddLine(gr_fakeline);
|
HWR_AddLine(gr_fakeline);
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,6 +451,7 @@ static void P_LoadSegs(lumpnum_t lumpnum)
|
||||||
//Hurdler: 04/12/2000: for now, only used in hardware mode
|
//Hurdler: 04/12/2000: for now, only used in hardware mode
|
||||||
li->lightmaps = NULL; // list of static lightmap for this seg
|
li->lightmaps = NULL; // list of static lightmap for this seg
|
||||||
}
|
}
|
||||||
|
li->pv1 = li->pv2 = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
li->angle = (SHORT(ml->angle))<<FRACBITS;
|
li->angle = (SHORT(ml->angle))<<FRACBITS;
|
||||||
|
|
|
@ -574,6 +574,9 @@ typedef struct seg_s
|
||||||
sector_t *backsector;
|
sector_t *backsector;
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
|
// new pointers so that AdjustSegs doesn't mess with v1/v2
|
||||||
|
void *pv1; // polyvertex_t
|
||||||
|
void *pv2; // polyvertex_t
|
||||||
float flength; // length of the seg, used by hardware renderer
|
float flength; // length of the seg, used by hardware renderer
|
||||||
|
|
||||||
lightmap_t *lightmaps; // for static lightmap
|
lightmap_t *lightmaps; // for static lightmap
|
||||||
|
|
Loading…
Reference in a new issue