// // R_AddLine // Clips the given segment // and adds any visible pieces to the line list. // static void R_AddLine(const seg_t* segline) { dcol.color = ((segline - segs) & 31) * 4; // [RH] Color if not texturing line drawseg_t ds; wall_t wall; if (!R_ProjectSeg(segline, &ds, &wall, NEARCLIP)) return; R_PrepWall(&ds, &wall); if (R_SolidLineSeg(segline, &wall)) { doorclosed = true; R_ClipWallSegment(ds.x1, ds.x2, true); } else if (!R_EmptyLineSeg(segline, &wall)) { doorclosed = false; R_ClipWallSegment(ds.x1, ds.x2, false); } }
// // R_AddLine // Clips the given segment // and adds any visible pieces to the line list. // void R_AddLine (seg_t *line) { curline = line; // skip this line if it's not facing the camera if (R_PointOnSegSide(viewx, viewy, line) != 0) return; dcol.color = ((line - segs) & 31) * 4; // [RH] Color if not texturing line // translate the line seg endpoints from world-space to camera-space // and store in (t1.x, t1.y) and (t2.x, t2.y) v2fixed_t t1, t2; R_RotatePoint(line->v1->x - viewx, line->v1->y - viewy, ANG90 - viewangle, t1.x, t1.y); R_RotatePoint(line->v2->x - viewx, line->v2->y - viewy, ANG90 - viewangle, t2.x, t2.y); // Clip the line seg to the viewing window int32_t lclip, rclip; if (!R_ClipLineToFrustum(&t1, &t2, NEARCLIP, lclip, rclip)) return; // apply the view frustum clipping to t1 & t2 R_ClipLine(&t1, &t2, lclip, rclip, &t1, &t2); // project the line endpoints to determine which columns the line seg occupies int x1 = R_ProjectPointX(t1.x, t1.y); int x2 = R_ProjectPointX(t2.x, t2.y) - 1; if (!R_CheckProjectionX(x1, x2)) return; rw_start = x1; rw_stop = x2; // clip the line seg endpoints in world-space // and store in (w1.x, w1.y) and (w2.x, w2.y) v2fixed_t w1, w2; R_ClipLine(line->v1, line->v2, lclip, rclip, &w1, &w2); // killough 3/8/98, 4/4/98: hack for invisible ceilings / deep water static sector_t tempsec; backsector = line->backsector ? R_FakeFlat(line->backsector, &tempsec, NULL, NULL, true) : NULL; R_PrepWall(w1.x, w1.y, w2.x, w2.y, t1.y, t2.y, x1, x2); // [SL] Check for single-sided line, closed doors or other scenarios that // would make this line seg solid. // // This fixes the automap floor height bug -- killough 1/18/98: // killough 4/7/98: optimize: save result in doorclosed for use in r_segs.c if (!backsector || !(line->linedef->flags & ML_TWOSIDED) || (rw_backcz1 <= rw_frontfz1 && rw_backcz2 <= rw_frontfz2) || (rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2) || // if door is closed because back is shut: ((rw_backcz1 <= rw_backfz1 && rw_backcz2 <= rw_backfz2) && // preserve a kind of transparent door/lift special effect: ((rw_backcz1 >= rw_frontcz1 && rw_backcz2 >= rw_frontcz2) || line->sidedef->toptexture) && ((rw_backfz1 <= rw_frontfz1 && rw_backfz2 <= rw_frontfz2) || line->sidedef->bottomtexture) && // properly render skies (consider door "open" if both ceilings are sky): (backsector->ceilingpic !=skyflatnum || frontsector->ceilingpic!=skyflatnum))) { doorclosed = true; R_ClipWallSegment(x1, x2, true); return; } // Reject empty lines used for triggers and special events. // Identical floor and ceiling on both sides, // identical light levels on both sides, and no middle texture. if (P_IdenticalPlanes(&frontsector->ceilingplane, &backsector->ceilingplane) && P_IdenticalPlanes(&frontsector->floorplane, &backsector->floorplane) && backsector->lightlevel == frontsector->lightlevel && backsector->floorpic == frontsector->floorpic && backsector->ceilingpic == frontsector->ceilingpic && curline->sidedef->midtexture == 0 // killough 3/7/98: Take flats offsets into account: && backsector->floor_xoffs == frontsector->floor_xoffs && (backsector->floor_yoffs + backsector->base_floor_yoffs) == (frontsector->floor_yoffs + backsector->base_floor_yoffs) && backsector->ceiling_xoffs == frontsector->ceiling_xoffs && (backsector->ceiling_yoffs + backsector->base_ceiling_yoffs) == (frontsector->ceiling_yoffs + frontsector->base_ceiling_yoffs) // killough 4/16/98: consider altered lighting && backsector->floorlightsec == frontsector->floorlightsec && backsector->ceilinglightsec == frontsector->ceilinglightsec // [RH] Also consider colormaps && backsector->colormap == frontsector->colormap // [RH] and scaling && backsector->floor_xscale == frontsector->floor_xscale && backsector->floor_yscale == frontsector->floor_yscale && backsector->ceiling_xscale == frontsector->ceiling_xscale && backsector->ceiling_yscale == frontsector->ceiling_yscale // [RH] and rotation && (backsector->floor_angle + backsector->base_floor_angle) == (frontsector->floor_angle + frontsector->base_floor_angle) && (backsector->ceiling_angle + backsector->base_ceiling_angle) == (frontsector->ceiling_angle + frontsector->base_ceiling_angle) ) { return; } doorclosed = false; R_ClipWallSegment(x1, x2, false); }