Skip to content

Commit

Permalink
Cache point angles for adjacent lines
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Oct 5, 2024
1 parent 6bd793c commit ea7e7d9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions r_phase1.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ typedef struct
seg_t *curline;
angle_t lineangle1;
int splitspans; /* generate wall splits until this reaches 0 */
VINT lastv1;
VINT lastv2;
angle_t lastangle1;
angle_t lastangle2;
} rbspWork_t;

static int R_ClipToViewEdges(angle_t angle1, angle_t angle2) ATTR_DATA_CACHE_ALIGN;
Expand Down Expand Up @@ -546,8 +550,19 @@ static void R_AddLine(rbspWork_t *rbsp, sector_t *frontsector, seg_t *line)
side_t *sidedef;
boolean solid;

angle1 = R_PointToAngle(v1->x, v1->y);
angle2 = R_PointToAngle(v2->x, v2->y);
if (line->v1 == rbsp->lastv2)
angle1 = rbsp->lastangle2;
else
angle1 = R_PointToAngle(v1->x, v1->y);
if (line->v2 == rbsp->lastv1)
angle2 = rbsp->lastangle1;
else
angle2 = R_PointToAngle(v2->x, v2->y);

rbsp->lastv1 = line->v1;
rbsp->lastv2 = line->v2;
rbsp->lastangle1 = angle1;
rbsp->lastangle2 = angle2;

x1 = R_ClipToViewEdges(angle1, angle2);
if (x1 <= 0)
Expand Down Expand Up @@ -669,6 +684,8 @@ void R_BSP(void)
solidsegs[1].last = viewportWidth+1;
rbsp.newend = &solidsegs[2];
rbsp.splitspans = viewportWidth + viewportWidth/2;
rbsp.lastv1 = -1;
rbsp.lastv2 = -1;

R_RenderBSPNode(&rbsp, numnodes - 1);
}
Expand Down

0 comments on commit ea7e7d9

Please sign in to comment.