diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9850c98ac..ad52aef6b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3267,17 +3267,6 @@ static void HWR_RenderPortalBSPNode(INT32 bspnum) bspnum = bsp->children[side^1]; } - // PORTAL CULLING - if (portalcullsector) - { - // skip all subsectors encountered before the portal - // destination's front sector - if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) - return; - else - portalcullsector = NULL; - } - // e6y: support for extended nodes HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); } diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 9bb5af40f..53d6f57e3 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -62,8 +62,6 @@ static gl_portal_t* HWR_Portal_Add (seg_t *seg) void HWR_FreePortalList(gl_portallist_t freelist) { - portalcullsector = NULL; - // free memory from portal list allocated by calls to Add2Lines gl_portal_t *gl_portal_temp = freelist.base; while (gl_portal_temp) @@ -125,13 +123,11 @@ void HWR_PortalFrame(gl_portal_t* portal) if (portal->clipline != -1) { portalclipline = &lines[portal->clipline]; - portalcullsector = portalclipline->frontsector; viewsector = portalclipline->frontsector; } else { portalclipline = NULL; - portalcullsector = NULL; viewsector = R_PointInSubsector(viewx, viewy)->sector; } } diff --git a/src/r_bsp.c b/src/r_bsp.c index e5b82a151..0dfba63e1 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -35,6 +35,7 @@ sector_t *backsector; // very ugly realloc() of drawsegs at run-time, I upped it to 512 // instead of 256.. and someone managed to send me a level with // 896 drawsegs! So too bad here's a limit removal a-la-Boom +drawseg_t *curdrawsegs = NULL; /**< This is used to handle multiple lists for masked drawsegs. */ drawseg_t *drawsegs = NULL; drawseg_t *ds_p = NULL; @@ -1201,13 +1202,5 @@ void R_RenderBSPNode(INT32 bspnum) bspnum = bsp->children[side^1]; } - // PORTAL CULLING - if (portalcullsector) - { - if (subsectors[bspnum & ~NF_SUBSECTOR].sector != portalcullsector) - return; - portalcullsector = NULL; - } - R_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); } diff --git a/src/r_bsp.h b/src/r_bsp.h index b5eb6b6cc..167f3311f 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -32,6 +32,7 @@ extern portal_t *g_portal; // is curline a portal seg? extern INT32 checkcoord[12][4]; +extern drawseg_t *curdrawsegs; extern drawseg_t *drawsegs; extern drawseg_t *ds_p; extern INT32 doorclosed; diff --git a/src/r_main.c b/src/r_main.c index 28c372d5b..37371d4df 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1281,21 +1281,47 @@ static void R_PortalFrame(portal_t *portal) if (portal->clipline != -1) { portalclipline = &lines[portal->clipline]; - portalcullsector = portalclipline->frontsector; viewsector = portalclipline->frontsector; } else { portalclipline = NULL; - portalcullsector = NULL; viewsector = R_PointInSubsector(viewx, viewy)->sector; } } +static void Mask_Pre (maskcount_t* m) +{ + m->drawsegs[0] = ds_p - drawsegs; + m->vissprites[0] = visspritecount; + m->viewx = viewx; + m->viewy = viewy; + m->viewz = viewz; + m->viewsector = viewsector; +} + +static void Mask_Post (maskcount_t* m) +{ + m->drawsegs[1] = ds_p - drawsegs; + m->vissprites[1] = visspritecount; +} + // ================ // R_RenderView // ================ +// viewx, viewy, viewangle, all that good stuff must be set +static void R_RenderViewpoint(maskcount_t* mask) +{ + Mask_Pre(mask); + + curdrawsegs = ds_p; + + R_RenderBSPNode((INT32)numnodes - 1); + + Mask_Post(mask); +} + // FAB NOTE FOR WIN32 PORT !! I'm not finished already, // but I suspect network may have problems with the video buffer being locked // for all duration of rendering, and being released only once at the end.. @@ -1306,6 +1332,8 @@ static fixed_t viewfov[MAXSPLITSCREENPLAYERS]; void R_RenderPlayerView(player_t *player) { + UINT8 nummasks = 1; + maskcount_t* masks = malloc(sizeof(maskcount_t)); const boolean skybox = (skyboxmo[0] && cv_skybox.value); UINT8 i; @@ -1369,13 +1397,14 @@ void R_RenderPlayerView(player_t *player) R_ClearVisibleFloorSplats(); #endif - R_RenderBSPNode((INT32)numnodes - 1); + R_RenderViewpoint(&masks[nummasks - 1]); + R_ClipSprites(); R_DrawPlanes(); #ifdef FLOORSPLATS R_DrawVisibleFloorSplats(); #endif - R_DrawMasked(); + R_DrawMasked(masks, nummasks); } PS_STOP_TIMING(ps_skyboxtime); @@ -1410,10 +1439,11 @@ void R_RenderPlayerView(player_t *player) NetUpdate(); // The head node is the last node output. + //masks = realloc(masks, (++nummasks)*sizeof(maskcount_t)); ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; PS_START_TIMING(ps_bsptime); - R_RenderBSPNode((INT32)numnodes - 1); + R_RenderViewpoint(&masks[nummasks - 1]); PS_STOP_TIMING(ps_bsptime); R_AddPrecipitationSprites(); PS_START_TIMING(ps_sw_spritecliptime); @@ -1446,14 +1476,18 @@ void R_RenderPlayerView(player_t *player) // that were previously stored. Portal_ClipApply(portal); + validcount++; + + // Render the BSP from the new viewpoint, and clip + masks = realloc(masks, (++nummasks)*sizeof(maskcount_t)); + // Render the BSP from the new viewpoint, and clip // any sprites with the new clipsegs and window. - R_RenderBSPNode((INT32)numnodes - 1); + R_RenderViewpoint(&masks[nummasks - 1]); + R_ClipSprites(); Portal_Remove(portal); - - validcount++; } } PS_STOP_TIMING(ps_sw_portaltime); @@ -1467,9 +1501,11 @@ void R_RenderPlayerView(player_t *player) // draw mid texture and sprite // And now 3D floors/sides! PS_START_TIMING(ps_sw_maskedtime); - R_DrawMasked(); + R_DrawMasked(masks, nummasks); PS_STOP_TIMING(ps_sw_maskedtime); + free(masks); + // Check for new console commands. NetUpdate(); diff --git a/src/r_plane.c b/src/r_plane.c index 99e6dde6a..d5faa122b 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -40,7 +40,7 @@ // good night sweet prince //#define SHITPLANESPARENCY -static visplane_t *visplanes[MAXVISPLANES]; +visplane_t *visplanes[MAXVISPLANES]; static visplane_t *freetail; static visplane_t **freehead = &freetail; @@ -368,8 +368,6 @@ void R_ClearPlanes(void) freehead = &(*freehead)->next; } - numffloors = 0; - lastopening = openings; // left to right mapping diff --git a/src/r_plane.h b/src/r_plane.h index d840523e6..dbaaac306 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -56,6 +56,8 @@ typedef struct visplane_s boolean noencore; } visplane_t; +extern visplane_t *visplanes[MAXVISPLANES]; + extern visplane_t *floorplane; extern visplane_t *ceilingplane; diff --git a/src/r_portal.c b/src/r_portal.c index afbcd46dd..e5a431c6e 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -14,7 +14,9 @@ #include "r_portal.h" #include "r_plane.h" -#include "r_main.h" // viewheight, viewwidth +#include "r_main.h" +#include "doomstat.h" +#include "p_spec.h" // Skybox viewpoints #include "z_zone.h" #include "r_things.h" #include "r_sky.h" @@ -25,7 +27,6 @@ UINT8 portalrender; /**< When rendering a portal, it establishes the depth of portal_t *portal_base, *portal_cap; line_t *portalclipline; -sector_t *portalcullsector; INT32 portalclipstart, portalclipend; portal_t *g_portal; // is curline a portal seg? @@ -133,7 +134,6 @@ static portal_t* Portal_Add (const INT16 x1, const INT16 x2) void Portal_Remove (portal_t* portal) { - portalcullsector = NULL; portal_base = portal->next; Z_Free(portal->ceilingclip); Z_Free(portal->floorclip); @@ -190,4 +190,148 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg } +/** Store the clipping window for a portal using a visplane. + * + * Since visplanes top/bottom windows work in an identical way, + * it can just be copied almost directly. + */ +static void Portal_ClipVisplane (const visplane_t* plane, portal_t* portal) +{ + INT16 start = portal->start; + INT16 end = portal->end; + INT32 i; + + for (i = 0; i < end - start; i++) + { + // Invalid column. + if (plane->top[i + start] == 65535) + { + portal->ceilingclip[i] = -1; + portal->floorclip[i] = -1; + continue; + } + portal->ceilingclip[i] = plane->top[i + start] - 1; + portal->floorclip[i] = plane->bottom[i + start] + 1; + portal->frontscale[i] = INT32_MAX; + } +} + +extern INT32 viewwidth; + +static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16* end) +{ + *start = plane->minx; + *end = plane->maxx + 1; + + // Visplanes have 1-px pads on their sides (extra columns). + // Trim them, else it may render out of bounds. + if (*end > viewwidth) + *end = viewwidth; + + if (!(*start < *end)) + return true; + + + /** Trims a visplane's horizontal gap to match its render area. + * + * Visplanes' minx/maxx may sometimes exceed the area they're + * covering. This merely adjusts the boundaries to the next + * valid area. + */ + + while (plane->bottom[*start] == 0 && plane->top[*start] == 65535 && *start < *end) + { + (*start)++; + } + + + while (plane->bottom[*end - 1] == 0 && plane->top[*start] == 65535 && *end > *start) + { + (*end)--; + } + + return false; +} + +/** Creates a skybox portal out of a visplane. + * + * Applies the necessary offsets and rotation to give + * a depth illusion to the skybox. + */ +void Portal_AddSkybox(const visplane_t* plane) +{ + INT16 start, end; + mapheader_t *mh; + portal_t* portal; + + if (TrimVisplaneBounds(plane, &start, &end)) + return; + + portal = Portal_Add(start, end); + + Portal_ClipVisplane(plane, portal); + + portal->viewx = skyboxmo[0]->x; + portal->viewy = skyboxmo[0]->y; + portal->viewz = skyboxmo[0]->z; + portal->viewangle = viewangle + skyboxmo[0]->angle; + + mh = mapheaderinfo[gamemap-1]; + + // If a relative viewpoint exists, offset the viewpoint. + if (skyboxmo[1]) + { + fixed_t x = 0, y = 0; + angle_t ang = skyboxmo[0]->angle>>ANGLETOFINESHIFT; + + if (mh->skybox_scalex > 0) + x = (viewx - skyboxmo[1]->x) / mh->skybox_scalex; + else if (mh->skybox_scalex < 0) + x = (viewx - skyboxmo[1]->x) * -mh->skybox_scalex; + + if (mh->skybox_scaley > 0) + y = (viewy - skyboxmo[1]->y) / mh->skybox_scaley; + else if (mh->skybox_scaley < 0) + y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley; + + // Apply transform to account for the skybox viewport angle. + portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); + portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); + } + + if (mh->skybox_scalez > 0) + portal->viewz += viewz / mh->skybox_scalez; + else if (mh->skybox_scalez < 0) + portal->viewz += viewz * -mh->skybox_scalez; + + portal->clipline = -1; +} + +/** Creates portals for the currently existing sky visplanes. + * The visplanes are also removed and cleared from the list. + */ +void Portal_AddSkyboxPortals(void) +{ + visplane_t *pl; + INT32 i; + UINT16 count = 0; + + for (i = 0; i < MAXVISPLANES; i++, pl++) + { + for (pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->picnum == skyflatnum) + { + Portal_AddSkybox(pl); + + pl->minx = 0; + pl->maxx = -1; + + count++; + } + } + } + + CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count); +} diff --git a/src/r_portal.h b/src/r_portal.h index c944f46d0..b45631e0b 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -15,9 +15,9 @@ #define __R_PORTAL__ #include "r_data.h" +#include "r_plane.h" // visplanes - -/** Portal structure. +/** Portal structure for the software renderer. */ typedef struct portal_s { @@ -45,7 +45,6 @@ extern portal_t* portal_cap; extern UINT8 portalrender; extern line_t *portalclipline; -extern sector_t *portalcullsector; extern INT32 portalclipstart, portalclipend; void Portal_InitList (void); @@ -54,4 +53,7 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con void Portal_ClipApply (const portal_t* portal); +void Portal_AddSkybox(const visplane_t* plane); +void Portal_AddSkyboxPortals(void); + #endif diff --git a/src/r_segs.c b/src/r_segs.c index 2ed0b5b80..3e36db3de 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1650,6 +1650,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (ds_p == drawsegs+maxdrawsegs) { + size_t curpos = curdrawsegs - drawsegs; size_t pos = ds_p - drawsegs; size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128; @@ -1661,6 +1662,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p = drawsegs + pos; maxdrawsegs = newmax; + curdrawsegs = drawsegs + curpos; if (firstseg) firstseg = drawsegs + (size_t)firstseg; @@ -1716,7 +1718,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // borrowed fix from *cough* zdoom *cough* // [RH] We also need to adjust the openings pointers that // were already stored in drawsegs. - for (ds = drawsegs; ds < ds_p; ds++) + for (ds = curdrawsegs; ds < ds_p; ds++) { #define ADJUST(p) if (ds->p + ds->x1 >= oldopenings && ds->p + ds->x1 <= oldlast) ds->p = ds->p - oldopenings + openings; ADJUST(maskedtexturecol); diff --git a/src/r_things.c b/src/r_things.c index 66cdd9979..9ca139ddd 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2145,9 +2145,7 @@ void R_AddPrecipitationSprites(void) // // R_SortVisSprites // -static vissprite_t vsprsortedhead; - -void R_SortVisSprites(void) +static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 end) { UINT32 i; vissprite_t *ds, *dsprev, *dsnext, *dsfirst; @@ -2156,20 +2154,17 @@ void R_SortVisSprites(void) fixed_t bestscale; INT32 bestdispoffset; - if (!visspritecount) - return; - unsorted.next = unsorted.prev = &unsorted; - dsfirst = R_GetVisSprite(0); + dsfirst = R_GetVisSprite(start); // The first's prev and last's next will be set to // nonsense, but are fixed in a moment - for (i = 0, dsnext = dsfirst, ds = NULL; i < visspritecount; i++) + for (i = start, dsnext = dsfirst, ds = NULL; i < end; i++) { dsprev = ds; ds = dsnext; - if (i < visspritecount - 1) dsnext = R_GetVisSprite(i + 1); + if (i < end - 1) dsnext = R_GetVisSprite(i + 1); ds->next = dsnext; ds->prev = dsprev; @@ -2183,8 +2178,8 @@ void R_SortVisSprites(void) unsorted.prev = ds; // pull the vissprites out by scale - vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; - for (i = 0; i < visspritecount; i++) + vsprsortedhead->next = vsprsortedhead->prev = vsprsortedhead; + for (i = start; i < end; i++) { bestscale = bestdispoffset = INT32_MAX; for (ds = unsorted.next; ds != &unsorted; ds = ds->next) @@ -2214,10 +2209,10 @@ void R_SortVisSprites(void) { best->next->prev = best->prev; best->prev->next = best->next; - best->next = &vsprsortedhead; - best->prev = vsprsortedhead.prev; - vsprsortedhead.prev->next = best; - vsprsortedhead.prev = best; + best->next = vsprsortedhead; + best->prev = vsprsortedhead->prev; + vsprsortedhead->prev->next = best; + vsprsortedhead->prev = best; } } } @@ -2228,28 +2223,28 @@ void R_SortVisSprites(void) static drawnode_t *R_CreateDrawNode(drawnode_t *link); static drawnode_t nodebankhead; -static drawnode_t nodehead; -static void R_CreateDrawNodes(void) +static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean tempskip) { drawnode_t *entry; drawseg_t *ds; INT32 i, p, best, x1, x2; fixed_t bestdelta, delta; vissprite_t *rover; + static vissprite_t vsprsortedhead; drawnode_t *r2; visplane_t *plane; INT32 sintersect; fixed_t scale = 0; // Add the 3D floors, thicksides, and masked textures... - for (ds = ds_p; ds-- > drawsegs ;) + for (ds = drawsegs + mask->drawsegs[1]; ds-- > drawsegs + mask->drawsegs[0];) { if (ds->numthicksides) { for (i = 0; i < ds->numthicksides; i++) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->thickseg = ds; entry->ffloor = ds->thicksides[i]; } @@ -2265,7 +2260,7 @@ static void R_CreateDrawNodes(void) else { // Put it in! - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = plane; entry->seg = ds; } @@ -2273,7 +2268,7 @@ static void R_CreateDrawNodes(void) } if (ds->maskedtexturecol) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->seg = ds; } if (ds->numffloorplanes) @@ -2305,7 +2300,7 @@ static void R_CreateDrawNodes(void) } if (best != -1) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = ds->ffloorplanes[best]; entry->seg = ds; ds->ffloorplanes[best] = NULL; @@ -2316,6 +2311,9 @@ static void R_CreateDrawNodes(void) } } + if (tempskip) + return; + // find all the remaining polyobject planes and add them on the end of the list // probably this is a terrible idea if we wanted them to be sorted properly // but it works getting them in for now @@ -2333,16 +2331,17 @@ static void R_CreateDrawNodes(void) continue; } - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = plane; // note: no seg is set, for what should be obvious reasons PolyObjects[i].visplane = NULL; } - if (visspritecount == 0) + // No vissprites in this mask? + if (mask->vissprites[1] - mask->vissprites[0] == 0) return; - R_SortVisSprites(); + R_SortVisSprites(&vsprsortedhead, mask->vissprites[0], mask->vissprites[1]); for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev) { @@ -2351,7 +2350,7 @@ static void R_CreateDrawNodes(void) sintersect = (rover->x1 + rover->x2) / 2; - for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) + for (r2 = head->next; r2 != head; r2 = r2->next) { if (r2->plane) { @@ -2477,9 +2476,9 @@ static void R_CreateDrawNodes(void) } } } - if (r2 == &nodehead) + if (r2 == head) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->sprite = rover; } } @@ -2523,25 +2522,24 @@ static void R_DoneWithNode(drawnode_t *node) (node->prev = &nodebankhead)->next = node; } -static void R_ClearDrawNodes(void) +static void R_ClearDrawNodes(drawnode_t* head) { drawnode_t *rover; drawnode_t *next; - for (rover = nodehead.next; rover != &nodehead ;) + for (rover = head->next; rover != head;) { next = rover->next; R_DoneWithNode(rover); rover = next; } - nodehead.next = nodehead.prev = &nodehead; + head->next = head->prev = head; } void R_InitDrawNodes(void) { nodebankhead.next = nodebankhead.prev = &nodebankhead; - nodehead.next = nodehead.prev = &nodehead; } // @@ -2943,14 +2941,12 @@ boolean R_ThingIsFullDark(mobj_t *thing) // // R_DrawMasked // -void R_DrawMasked(void) +static void R_DrawMaskedList (drawnode_t* head) { drawnode_t *r2; drawnode_t *next; - R_CreateDrawNodes(); - - for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) + for (r2 = head->next; r2 != head; r2 = r2->next) { drawspandata_t ds = {0}; if (r2->plane) @@ -2993,7 +2989,36 @@ void R_DrawMasked(void) r2 = next; } } - R_ClearDrawNodes(); +} + +void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) +{ + drawnode_t heads[nummasks]; /**< Drawnode lists; as many as number of views/portals. */ + UINT8 i; + + for (i = 0; i < nummasks; i++) + { + heads[i].next = heads[i].prev = &heads[i]; + + viewx = masks[i].viewx; + viewy = masks[i].viewy; + viewz = masks[i].viewz; + viewsector = masks[i].viewsector; + + + R_CreateDrawNodes(&masks[i], &heads[i], false); + } + + for (; nummasks > 0; nummasks--) + { + viewx = masks[nummasks - 1].viewx; + viewy = masks[nummasks - 1].viewy; + viewz = masks[nummasks - 1].viewz; + viewsector = masks[nummasks - 1].viewsector; + + R_DrawMaskedList(&heads[nummasks - 1]); + R_ClearDrawNodes(&heads[nummasks - 1]); + } } // ========================================================================== diff --git a/src/r_things.h b/src/r_things.h index da871e431..e1cef1d08 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -63,8 +63,6 @@ fixed_t R_GetSpriteDirectionalLighting(angle_t angle); fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); -void R_SortVisSprites(void); - //faB: find sprites in wadfile, replace existing, add new ones // (only sprites from namelist are added or replaced) void R_AddSpriteDefs(UINT16 wadnum); @@ -74,7 +72,20 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_AddPrecipitationSprites(void); void R_InitSprites(void); void R_ClearSprites(void); -void R_DrawMasked(void); + +/** Used to count the amount of masked elements + * per portal to later group them in separate + * drawnode lists. + */ +typedef struct +{ + size_t drawsegs[2]; + size_t vissprites[2]; + fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */ + sector_t* viewsector; +} maskcount_t; + +void R_DrawMasked(maskcount_t* masks, UINT8 nummasks); boolean R_ThingVisible (mobj_t *thing); boolean R_ThingWithinDist (mobj_t *thing, INT32 limit_dist);