// // R_ClipPassWallSegment // Clips the given range of columns, // but does not includes it in the clip list. // Does handle windows, // e.g. LineDefs with upper and lower texture. // void R_ClipPassWallSegment ( int first, int last ) { cliprange_t *start; // Find the first range that touches the range // (adjacent pixels are touching). start = solidsegs; while (start->last < first-1) start++; if (first < start->first) { if (last < start->first-1) { // Post is entirely visible (above start). R_StoreWallRange (first, last); return; } // There is a fragment above *start. R_StoreWallRange (first, start->first - 1); } // Bottom contained in start? if (last <= start->last) return; while (last >= (start+1)->first-1) { // There is a fragment between two posts. R_StoreWallRange (start->last + 1, (start+1)->first - 1); start++; if (last <= start->last) return; } // There is a fragment after *next. R_StoreWallRange (start->last + 1, last); }
static void R_ClipWallSegment(int first, int last, boolean solid) { byte *p; while (first < last) { if (solidcol[first]) { if (!(p = memchr(solidcol+first, 0, last-first))) return; // All solid first = p - solidcol; } else { int to; if (!(p = memchr(solidcol+first, 1, last-first))) to = last; else to = p - solidcol; R_StoreWallRange(first, to-1); if (solid) { memset(solidcol+first,1,to-first); } first = to; } } }
void R_ClipWallSegment(int first, int last, boolean solid) { byte *p; while (first < last) { if (solidcol[first]) { if (!(p = memchr(solidcol+first, 0, last-first))) return; // All solid first = p - solidcol; } else { int to; if (!(p = memchr(solidcol+first, 1, last-first))) to = last; else to = p - solidcol; R_StoreWallRange(first, to-1); if (solid) { memset(solidcol+first,1,to-first); } /*else do { if (floorclip[first] <= ceilingclip[first] + 1) solidcol[first] = 1; } while (++first < to);*/ first = to; } } }
// // R_ClipWallSegment // // [SL] From prboom-plus. Modified for clarity. // // Calls R_StoreWallRange for each span of non-solid range of columns that // is within the range of first to (and including) last. Non-solid columns // are those which have not yet had a 1s lineseg drawn to them. If makesolid // is specified, any range of non-solid columns found will be marked as solid. // static void R_ClipWallSegment(int first, int last, bool makesolid) { while (first <= last) { if (solidcol[first]) { // find the first remaining non-solid column // if all columns remaining are solid, we're done byte* p = (byte*)memchr(solidcol + first, 0, last - first + 1); if (p == NULL) return; first = p - solidcol; } else { int to; // find where the span of non-solid columns ends byte* p = (byte*)memchr(solidcol + first, 1, last - first + 1); if (p == NULL) to = last; else to = p - solidcol - 1; // set the range for this wall to the range of non-solid columns R_ReallocDrawSegs(); R_StoreWallRange(ds_p++, first, to); // mark the columns as solid if (makesolid) memset(solidcol + first, 1, to - first + 1); first = to + 1; } } }
// // R_ClipSolidWallSegment // Does handle solid walls, // e.g. single sided LineDefs (middle texture) // that entirely block the view. // static void R_ClipSolidWallSegment(INT32 first, INT32 last) { cliprange_t *next; cliprange_t *start; // Find the first range that touches the range (adjacent pixels are touching). start = solidsegs; while (start->last < first - 1) start++; if (first < start->first) { if (last < start->first - 1) { // Post is entirely visible (above start), so insert a new clippost. R_StoreWallRange(first, last); next = newend; newend++; // NO MORE CRASHING! if (newend - solidsegs > MAXSEGS) I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); while (next != start) { *next = *(next-1); next--; } next->first = first; next->last = last; return; } // There is a fragment above *start. R_StoreWallRange(first, start->first - 1); // Now adjust the clip size. start->first = first; } // Bottom contained in start? if (last <= start->last) return; next = start; while (last >= (next+1)->first - 1) { // There is a fragment between two posts. R_StoreWallRange(next->last + 1, (next+1)->first - 1); next++; if (last <= next->last) { // Bottom is contained in next. // Adjust the clip size. start->last = next->last; goto crunch; } } // There is a fragment after *next. R_StoreWallRange(next->last + 1, last); // Adjust the clip size. start->last = last; // Remove start+1 to next from the clip list, because start now covers their area. crunch: if (next == start) return; // Post just extended past the bottom of one post. while (next++ != newend) *++start = *next; // Remove a post. newend = start + 1; // NO MORE CRASHING! if (newend - solidsegs > MAXSEGS) I_Error("R_ClipSolidWallSegment: Solid Segs overflow!\n"); }
void R_ClipSolidWallSegment (int first, int last) { cliprange_t *next, *start; // find the first range that touches the range (adjacent pixels are touching) start = solidsegs; while (start->last < first-1) start++; if (first < start->first) { if (last < start->first-1) { // post is entirely visible (above start), so insert a new clippost R_StoreWallRange (first, last); next = newend; newend++; while (next != start) { *next = *(next-1); next--; } next->first = first; next->last = last; return; } // there is a fragment above *start R_StoreWallRange (first, start->first - 1); start->first = first; // adjust the clip size } if (last <= start->last) return; // bottom contained in start next = start; while (last >= (next+1)->first-1) { // there is a fragment between two posts R_StoreWallRange (next->last + 1, (next+1)->first - 1); next++; if (last <= next->last) { // bottom is contained in next start->last = next->last; // adjust the clip size goto crunch; } } // there is a fragment after *next R_StoreWallRange (next->last + 1, last); start->last = last; // adjust the clip size // remove start+1 to next from the clip list, // because start now covers their area crunch: if (next == start) return; // post just extended past the bottom of one post while (next++ != newend) // remove a post *++start = *next; newend = start+1; }
void R_ClipWallSegment (int first, int last, bool solid) { cliprange_t *next, *start; int i, j; // Find the first range that touches the range // (adjacent pixels are touching). start = solidsegs; while (start->last < first) start++; if (first < start->first) { if (last <= start->first) { // Post is entirely visible (above start). R_StoreWallRange (first, last); // Insert a new clippost for solid walls. if (solid) { if (last == start->first) { start->first = first; } else { next = newend; newend++; while (next != start) { *next = *(next-1); next--; } next->first = first; next->last = last; } } return; } // There is a fragment above *start. R_StoreWallRange (first, start->first); // Adjust the clip size for solid walls if (solid) { start->first = first; } } // Bottom contained in start? if (last <= start->last) return; next = start; while (last >= (next+1)->first) { // There is a fragment between two posts. R_StoreWallRange (next->last, (next+1)->first); next++; if (last <= next->last) { // Bottom is contained in next. last = next->last; goto crunch; } } // There is a fragment after *next. R_StoreWallRange (next->last, last); crunch: if (solid) { // Adjust the clip size. start->last = last; if (next != start) { // Remove start+1 to next from the clip list, // because start now covers their area. for (i = 1, j = (int)(newend - next); j > 0; i++, j--) { start[i] = next[i]; } newend = start+i; } } }
// // R_ClipSolidWallSegment // Does handle solid walls, // e.g. single sided LineDefs (middle texture) // that entirely block the view. // void R_ClipSolidWallSegment ( int first, int last ) { cliprange_t *next, *start; if(newend + 1 >= lastsolidseg) { // denis - out of solidsegs, this would crash vanilla Printf(PRINT_HIGH, "warning: exceeded %d solidsegs\n", MaxSegs); if(MaxSegs >= 1024*1024) { // not that crazy, though I_FatalError("R_ClipSolidWallSegment: refusing to extend solidsegs over %d", MaxSegs); } cliprange_t *old = solidsegs; solidsegs = (cliprange_t *)Malloc (2 * MaxSegs * sizeof(cliprange_t)); memcpy(solidsegs, old, (sizeof(cliprange_t)*MaxSegs)); MaxSegs *= 2; lastsolidseg = &solidsegs[MaxSegs]; newend = newend - old + solidsegs; M_Free(old); } // Find the first range that touches the range // (adjacent pixels are touching). start = solidsegs; while (start->last < first-1) start++; if (first < start->first) { if (last < start->first-1) { // Post is entirely visible (above start), so insert a new clippost. R_StoreWallRange (first, last); // 1/11/98 killough: performance tuning using fast memmove memmove (start+1, start, (++newend-start)*sizeof(*start)); start->first = first; start->last = last; return; } // There is a fragment above *start. R_StoreWallRange (first, start->first - 1); // Now adjust the clip size. start->first = first; } // Bottom contained in start? if (last <= start->last) return; next = start; while (last >= (next+1)->first-1) { // There is a fragment between two posts. R_StoreWallRange (next->last + 1, (next+1)->first - 1); next++; if (last <= next->last) { // Bottom is contained in next. Adjust the clip size. start->last = next->last; goto crunch; } } // There is a fragment after *next. R_StoreWallRange (next->last + 1, last); // Adjust the clip size. start->last = last; // Remove start+1 to next from the clip list, // because start now covers their area. crunch: if (next == start) { // Post just extended past the bottom of one post. return; } while (next++ != newend) { // Remove a post. *++start = *next; } newend = start+1; }
// // R_ClipSolidWallSegment // Does handle solid walls, // e.g. single sided LineDefs (middle texture) // that entirely block the view. // static void R_ClipSolidWallSegment(int first, int last) { cliprange_t *next; cliprange_t *start = solidsegs; // Find the first range that touches the range // (adjacent pixels are touching). while (start->last < first - 1) ++start; if (first < start->first) { if (last < start->first - 1) { // Post is entirely visible (above start), so insert a new clippost. R_StoreWallRange(first, last); // 1/11/98 killough: performance tuning using fast memmove memmove(start + 1, start, (++newend - start) * sizeof(*start)); start->first = first; start->last = last; return; } // There is a fragment above *start. R_StoreWallRange(first, start->first - 1); // Now adjust the clip size. start->first = first; } // Bottom contained in start? if (last <= start->last) return; next = start; while (last >= (next + 1)->first - 1) { // There is a fragment between two posts. R_StoreWallRange(next->last + 1, (next + 1)->first - 1); ++next; if (last <= next->last) { // Bottom is contained in next. Adjust the clip size. start->last = next->last; goto crunch; } } // There is a fragment after *next. R_StoreWallRange(next->last + 1, last); // Adjust the clip size. start->last = last; // Remove start + 1 to next from the clip list, // because start now covers their area. crunch: if (next == start) return; // Post just extended past the bottom of one post. while (next++ != newend) *++start = *next; // Remove a post. newend = start + 1; }