//============================================================================= static void HW3S_FillSourceParameters (const mobj_t *origin, source3D_data_t *data, channel_type_t c_type) { fixed_t x = 0, y = 0, z = 0; data->max_distance = MAX_DISTANCE; data->min_distance = MIN_DISTANCE; if (origin && origin != players[displayplayer].mo) { data->head_relative = false; data->pos.momx = TPS(FIXED_TO_FLOAT(origin->momx)); data->pos.momy = TPS(FIXED_TO_FLOAT(origin->momy)); data->pos.momz = TPS(FIXED_TO_FLOAT(origin->momz)); x = origin->x; y = origin->y; z = origin->z; if (c_type == CT_ATTACK) { const angle_t an = origin->angle >> ANGLETOFINESHIFT; x += FixedMul(16*FRACUNIT, FINECOSINE(an)); y += FixedMul(16*FRACUNIT, FINESINE(an)); z += origin->height >> 1; } else if (c_type == CT_SCREAM)
static void R_Subsector(size_t num) { INT32 count, floorlightlevel, ceilinglightlevel, light; seg_t *line; subsector_t *sub; static sector_t tempsec; // Deep water hack extracolormap_t *floorcolormap; extracolormap_t *ceilingcolormap; #ifdef RANGECHECK if (num >= numsubsectors) I_Error("R_Subsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); #endif // subsectors added at run-time if (num >= numsubsectors) return; sub = &subsectors[num]; frontsector = sub->sector; count = sub->numlines; line = &segs[sub->firstline]; // Deep water/fake ceiling effect. frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); floorcolormap = ceilingcolormap = frontsector->extra_colormap; // Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps. if (frontsector->ffloors) { if (frontsector->moved) { frontsector->numlights = sub->sector->numlights = 0; R_Prep3DFloors(frontsector); sub->sector->lightlist = frontsector->lightlist; sub->sector->numlights = frontsector->numlights; sub->sector->moved = frontsector->moved = false; } light = R_GetPlaneLight(frontsector, #ifdef ESLOPE frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) : #endif frontsector->floorheight, false); if (frontsector->floorlightsec == -1) floorlightlevel = *frontsector->lightlist[light].lightlevel; floorcolormap = frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(frontsector, #ifdef ESLOPE frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) : #endif frontsector->ceilingheight, false); if (frontsector->ceilinglightsec == -1) ceilinglightlevel = *frontsector->lightlist[light].lightlevel; ceilingcolormap = frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = frontsector->extra_colormap; if ((( #ifdef ESLOPE frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : #endif frontsector->floorheight) < viewz || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))) { floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL #ifdef ESLOPE , frontsector->f_slope #endif ); } else floorplane = NULL; if ((( #ifdef ESLOPE frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : #endif frontsector->ceilingheight) > viewz || frontsector->ceilingpic == skyflatnum || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))) { ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic, ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle, ceilingcolormap, NULL #ifdef ESLOPE , frontsector->c_slope #endif ); } else ceilingplane = NULL; numffloors = 0; #ifdef ESLOPE ffloor[numffloors].slope = NULL; #endif ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; if (frontsector->ffloors) { ffloor_t *rover; fixed_t heightcheck; for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue; if (frontsector->cullheight) { if (R_DoCulling(frontsector->cullheight, viewsector->cullheight, viewz, *rover->bottomheight, *rover->topheight)) { rover->norender = leveltime; continue; } } ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; heightcheck = #ifdef ESLOPE *rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : #endif *rover->bottomheight; if (*rover->bottomheight <= frontsector->ceilingheight && *rover->bottomheight >= frontsector->floorheight && ((viewz < heightcheck && !(rover->flags & FF_INVERTPLANES)) || (viewz > heightcheck && (rover->flags & FF_BOTHPLANES)))) { #ifdef ESLOPE light = R_GetPlaneLight(frontsector, *rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) : *rover->bottomheight, viewz < heightcheck); #else light = R_GetPlaneLight(frontsector, *rover->bottomheight, viewz < *rover->bottomheight); #endif ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, *rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover #ifdef ESLOPE , *rover->b_slope #endif ); #ifdef ESLOPE ffloor[numffloors].slope = *rover->b_slope; // Tell the renderer this sector has slopes in it. if (ffloor[numffloors].slope) frontsector->hasslope = true; #endif ffloor[numffloors].height = #ifdef ESLOPE *rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : #endif *rover->bottomheight; ffloor[numffloors].ffloor = rover; numffloors++; } if (numffloors >= MAXFFLOORS) break; ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; heightcheck = #ifdef ESLOPE *rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : #endif *rover->topheight; if (*rover->topheight >= frontsector->floorheight && *rover->topheight <= frontsector->ceilingheight && ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES)) || (viewz < heightcheck && (rover->flags & FF_BOTHPLANES)))) { #ifdef ESLOPE light = R_GetPlaneLight(frontsector, *rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) : *rover->topheight, viewz < heightcheck); #else light = R_GetPlaneLight(frontsector, *rover->topheight, viewz < *rover->topheight); #endif ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, frontsector->lightlist[light].extra_colormap, rover #ifdef ESLOPE , *rover->t_slope #endif ); #ifdef ESLOPE ffloor[numffloors].slope = *rover->t_slope; // Tell the renderer this sector has slopes in it. if (ffloor[numffloors].slope) frontsector->hasslope = true; #endif ffloor[numffloors].height = #ifdef ESLOPE *rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : #endif *rover->topheight; ffloor[numffloors].ffloor = rover; numffloors++; } } } #ifdef POLYOBJECTS_PLANES // Polyobjects have planes, too! if (sub->polyList) { polyobj_t *po = sub->polyList; sector_t *polysec; while (po) { if (numffloors >= MAXFFLOORS) break; if (!(po->flags & POF_RENDERPLANES)) // Don't draw planes { po = (polyobj_t *)(po->link.next); continue; } polysec = po->lines[0]->backsector; ffloor[numffloors].plane = NULL; if (polysec->floorheight <= frontsector->ceilingheight && polysec->floorheight >= frontsector->floorheight && (viewz < polysec->floorheight)) { fixed_t xoff, yoff; xoff = polysec->floor_xoffs; yoff = polysec->floor_yoffs; if (po->angle != 0) { angle_t fineshift = po->angle >> ANGLETOFINESHIFT; xoff -= FixedMul(FINECOSINE(fineshift), po->centerPt.x)+FixedMul(FINESINE(fineshift), po->centerPt.y); yoff -= FixedMul(FINESINE(fineshift), po->centerPt.x)-FixedMul(FINECOSINE(fineshift), po->centerPt.y); } else {