// Returns the texture the decal stuck to. FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor *ffloor) { // Stick the decal at the end of the chain so it appears on top DBaseDecal *next, **prev; prev = &wall->AttachedDecals; while (*prev != NULL) { next = *prev; prev = &next->WallNext; } *prev = this; WallNext = NULL; WallPrev = prev; /* WallNext = wall->AttachedDecals; WallPrev = &wall->AttachedDecals; if (WallNext) WallNext->WallPrev = &WallNext; wall->AttachedDecals = this; */ sector_t *front, *back; line_t *line; FTextureID tex; line = wall->linedef; if (line->sidedef[0] == wall) { front = line->frontsector; back = line->backsector; } else { front = line->backsector; back = line->frontsector; } if (back == NULL) { RenderFlags |= RF_RELMID; if (line->flags & ML_DONTPEGBOTTOM) Z -= front->GetPlaneTexZ(sector_t::floor); else Z -= front->GetPlaneTexZ(sector_t::ceiling); tex = wall->GetTexture(side_t::mid); } else if (back->floorplane.ZatPoint (x, y) >= Z) { RenderFlags |= RF_RELLOWER|RF_CLIPLOWER; if (line->flags & ML_DONTPEGBOTTOM) Z -= front->GetPlaneTexZ(sector_t::ceiling); else Z -= back->GetPlaneTexZ(sector_t::floor); tex = wall->GetTexture(side_t::bottom); } else if (back->ceilingplane.ZatPoint (x, y) <= Z) { RenderFlags |= RF_RELUPPER|RF_CLIPUPPER; if (line->flags & ML_DONTPEGTOP) Z -= front->GetPlaneTexZ(sector_t::ceiling); else Z -= back->GetPlaneTexZ(sector_t::ceiling); tex = wall->GetTexture(side_t::top); } #ifdef _3DFLOORS else if (ffloor) // this is a 3d-floor segment - do this only if we know which one! { Sector=ffloor->model; RenderFlags |= RF_RELMID|RF_CLIPMID; if (line->flags & ML_DONTPEGBOTTOM) Z -= Sector->GetPlaneTexZ(sector_t::floor); else Z -= Sector->GetPlaneTexZ(sector_t::ceiling); if (ffloor->flags & FF_UPPERTEXTURE) { tex = wall->GetTexture(side_t::top); } else if (ffloor->flags & FF_LOWERTEXTURE) { tex = wall->GetTexture(side_t::bottom); } else { tex = ffloor->master->sidedef[0]->GetTexture(side_t::mid); } } #endif else return FNullTextureID(); CalcFracPos (wall, x, y); FTexture *texture = TexMan[tex]; if (texture == NULL || texture->bNoDecals) { return FNullTextureID(); } return tex; }
// Returns the texture the decal stuck to. FTextureID DBaseDecal::StickToWall (side_t *wall, double x, double y, F3DFloor *ffloor) { Side = wall; WallPrev = wall->AttachedDecals; while (WallPrev != nullptr && WallPrev->WallNext != nullptr) { WallPrev = WallPrev->WallNext; } if (WallPrev != nullptr) WallPrev->WallNext = this; else wall->AttachedDecals = this; WallNext = nullptr; sector_t *front, *back; line_t *line; FTextureID tex; line = wall->linedef; if (line->sidedef[0] == wall) { front = line->frontsector; back = line->backsector; } else { front = line->backsector; back = line->frontsector; } if (back == NULL) { RenderFlags |= RF_RELMID; if (line->flags & ML_DONTPEGBOTTOM) Z -= front->GetPlaneTexZ(sector_t::floor); else Z -= front->GetPlaneTexZ(sector_t::ceiling); tex = wall->GetTexture(side_t::mid); } else if (back->floorplane.ZatPoint (x, y) >= Z) { RenderFlags |= RF_RELLOWER|RF_CLIPLOWER; if (line->flags & ML_DONTPEGBOTTOM) Z -= front->GetPlaneTexZ(sector_t::ceiling); else Z -= back->GetPlaneTexZ(sector_t::floor); tex = wall->GetTexture(side_t::bottom); } else if (back->ceilingplane.ZatPoint (x, y) <= Z) { RenderFlags |= RF_RELUPPER|RF_CLIPUPPER; if (line->flags & ML_DONTPEGTOP) Z -= front->GetPlaneTexZ(sector_t::ceiling); else Z -= back->GetPlaneTexZ(sector_t::ceiling); tex = wall->GetTexture(side_t::top); } else if (ffloor) // this is a 3d-floor segment - do this only if we know which one! { Sector=ffloor->model; RenderFlags |= RF_RELMID|RF_CLIPMID; if (line->flags & ML_DONTPEGBOTTOM) Z -= Sector->GetPlaneTexZ(sector_t::floor); else Z -= Sector->GetPlaneTexZ(sector_t::ceiling); if (ffloor->flags & FF_UPPERTEXTURE) { tex = wall->GetTexture(side_t::top); } else if (ffloor->flags & FF_LOWERTEXTURE) { tex = wall->GetTexture(side_t::bottom); } else { tex = ffloor->master->sidedef[0]->GetTexture(side_t::mid); } } else return FNullTextureID(); CalcFracPos (wall, x, y); FTexture *texture = TexMan[tex]; if (texture == NULL || texture->bNoDecals) { return FNullTextureID(); } return tex; }