From 7530227163053368b8f10e9e90b7ef34ce9a02d5 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 31 Jul 2024 02:33:15 -0400 Subject: [PATCH] Revert "Add a hitbox renderer to Software mode" This reverts commit 082d9206e89113533f4f6f7a8798f872e9a1ea39. --- src/Sourcefile | 1 - src/d_netcmd.c | 1 - src/p_mobj.h | 2 +- src/r_bbox.c | 303 ------------------------------------------------- src/r_things.c | 8 -- src/r_things.h | 6 - src/screen.h | 2 +- 7 files changed, 2 insertions(+), 321 deletions(-) delete mode 100644 src/r_bbox.c diff --git a/src/Sourcefile b/src/Sourcefile index 3ebe32c16..07b28d815 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -66,7 +66,6 @@ r_skins.c r_sky.c r_splats.c r_things.c -r_bbox.c r_textures.c r_patch.c r_patchrotation.c diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 978dae5a4..e153e3adc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -995,7 +995,6 @@ void D_RegisterClientCommands(void) // screen.c CV_RegisterVar(&cv_fullscreen); CV_RegisterVar(&cv_renderview); - CV_RegisterVar(&cv_renderhitbox); CV_RegisterVar(&cv_vhseffect); CV_RegisterVar(&cv_shittyscreen); CV_RegisterVar(&cv_renderer); diff --git a/src/p_mobj.h b/src/p_mobj.h index 6823f40e9..56241edd7 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -122,7 +122,7 @@ typedef enum MF_AMBIENT = 1<<10, // Slide this object when it hits a wall. MF_SLIDEME = 1<<11, - // Don't collide with walls or solid objects. Two MF_NOCLIP objects can't touch each other at all! + // Player cheat. MF_NOCLIP = 1<<12, // Allow moves to any height, no gravity. For active floaters. MF_FLOAT = 1<<13, diff --git a/src/r_bbox.c b/src/r_bbox.c deleted file mode 100644 index ef72488fb..000000000 --- a/src/r_bbox.c +++ /dev/null @@ -1,303 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2021 by Sonic Team Junior. -// Copyright (C) 2022 by Kart Krew. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file r_bbox.c -/// \brief Boundary box (cube) renderer - -#include "doomdef.h" -#include "command.h" -#include "r_fps.h" -#include "r_local.h" -#include "screen.h" // cv_renderhitbox -#include "v_video.h" // V_DrawFill - -enum { - RENDERHITBOX_OFF, - RENDERHITBOX_TANGIBLE, - RENDERHITBOX_ALL, - RENDERHITBOX_INTANGIBLE, - RENDERHITBOX_RINGS, -}; - -static CV_PossibleValue_t renderhitbox_cons_t[] = { - {RENDERHITBOX_OFF, "Off"}, - {RENDERHITBOX_TANGIBLE, "Tangible"}, - {RENDERHITBOX_ALL, "All"}, - {RENDERHITBOX_INTANGIBLE, "Intangible"}, - {RENDERHITBOX_RINGS, "Rings"}, - {0}}; - -consvar_t cv_renderhitbox = CVAR_INIT ("renderhitbox", "Off", 0, renderhitbox_cons_t, NULL); - -struct bbox_col { - INT32 x; - INT32 y; - INT32 h; -}; - -struct bbox_config { - fixed_t height; - fixed_t tz; - struct bbox_col col[4]; - UINT8 color; -}; - -static inline void -raster_bbox_seg -( INT32 x, - fixed_t y, - fixed_t h, - UINT8 pixel) -{ - y /= FRACUNIT; - - if (y < 0) - y = 0; - - h = y + (FixedCeil(abs(h)) / FRACUNIT); - - if (h >= viewheight) - h = viewheight; - - while (y < h) - { - topleft[x + y * vid.width] = pixel; - y++; - } -} - -static void -draw_bbox_col -( struct bbox_config * bb, - int p, - fixed_t tx, - fixed_t ty) -{ - struct bbox_col *col = &bb->col[p]; - - fixed_t xscale = FixedDiv(projection[viewssnum], ty); - fixed_t yscale = FixedDiv(projectiony[viewssnum], ty); - - col->x = (centerxfrac + FixedMul(tx, xscale)) / FRACUNIT; - col->y = (centeryfrac - FixedMul(bb->tz, yscale)); - col->h = FixedMul(bb->height, yscale); - - // Using this function is TOO EASY! - V_DrawFill( - viewwindowx + col->x, - viewwindowy + col->y / FRACUNIT, 1, - col->h / FRACUNIT, V_NOSCALESTART | bb->color); -} - -static void -draw_bbox_row -( struct bbox_config * bb, - int p1, - int p2) -{ - struct bbox_col - *a = &bb->col[p1], - *b = &bb->col[p2]; - - INT32 x1, x2; // left, right - INT32 dx; // width - - fixed_t y1, y2; // top, bottom - fixed_t s1, s2; // top and bottom increment - - if (a->x > b->x) - { - struct bbox_col *c = a; - a = b; - b = c; - } - - x1 = a->x; - x2 = b->x; - - if (x2 >= viewwidth) - x2 = viewwidth - 1; - - if (x1 == x2 || x1 >= viewwidth || x2 < 0) - return; - - dx = x2 - x1; - - y1 = a->y; - y2 = b->y; - s1 = (y2 - y1) / dx; - - y2 = y1 + a->h; - s2 = ((b->y + b->h) - y2) / dx; - - // FixedCeil needs a minimum!!! :D :D - - if (s1 == 0) - s1 = 1; - - if (s2 == 0) - s2 = 1; - - if (x1 < 0) - { - y1 -= x1 * s1; - y2 -= x1 * s2; - x1 = 0; - } - - while (x1 < x2) - { - raster_bbox_seg(x1, y1, s1, bb->color); - raster_bbox_seg(x1, y2, s2, bb->color); - - y1 += s1; - y2 += s2; - - x1++; - } -} - -static UINT8 -get_bbox_color (mobj_t *thing) -{ - UINT32 flags = thing->flags; - - if (thing->player) - return 255; // 0FF - - if (flags & (MF_NOCLIPTHING)) - return 7; // BFBFBF - - if (flags & (MF_SPECIAL)) - return 73; // FF0 - - if (flags & (MF_BOSS|MF_MISSILE|MF_ENEMY|MF_PAIN)) - return 35; // F00 - - if (flags & (MF_NOCLIP)) - return 152; // 00F - - return 0; // FFF -} - -void R_DrawThingBoundingBox(mobj_t *thing) -{ - fixed_t rs, rc; // radius offsets - fixed_t gx, gy; // origin - fixed_t tx, ty; // translated coordinates - - // uncapped/interpolation - interpmobjstate_t interp = {0}; - - struct bbox_config bb = {0}; - - // do interpolation - if (R_UsingFrameInterpolation() && !paused) - { - R_InterpolateMobjState(thing, rendertimefrac, &interp); - } - else - { - R_InterpolateMobjState(thing, FRACUNIT, &interp); - } - - rs = FixedMul(thing->radius, viewsin); - rc = FixedMul(thing->radius, viewcos); - - gx = interp.x - viewx; - gy = interp.y - viewy; - - tx = FixedMul(gx, viewsin) - FixedMul(gy, viewcos); - ty = FixedMul(gx, viewcos) + FixedMul(gy, viewsin); - - bb.height = thing->height; - bb.tz = (interp.z + bb.height) - viewz; - bb.color = get_bbox_color(thing); - - // 1--3 - // | | - // 0--2 - - // left - - tx -= rs; - ty -= rc; - - draw_bbox_col(&bb, 0, tx + rc, ty - rs); // bottom - draw_bbox_col(&bb, 1, tx - rc, ty + rs); // top - - // right - - tx += rs + rs; - ty += rc + rc; - - draw_bbox_col(&bb, 2, tx + rc, ty - rs); // bottom - draw_bbox_col(&bb, 3, tx - rc, ty + rs); // top - - // connect all four columns - - draw_bbox_row(&bb, 0, 1); - draw_bbox_row(&bb, 1, 3); - draw_bbox_row(&bb, 3, 2); - draw_bbox_row(&bb, 2, 0); -} - -static boolean is_tangible (mobj_t *thing) -{ - // These objects can never touch another - if (thing->flags & (MF_NOCLIPTHING)) - { - return false; - } - - // These objects probably do nothing! :D - if ((thing->flags & (MF_SPECIAL|MF_SOLID|MF_SHOOTABLE - |MF_PUSHABLE|MF_BOSS|MF_MISSILE|MF_SPRING - |MF_MONITOR|MF_ENEMY|MF_PAIN|MF_STICKY - |MF_PICKUPFROMBELOW)) == 0U) - { - return false; - } - - return true; -} - -boolean R_ThingBoundingBoxVisible(mobj_t *thing) -{ - INT32 cvmode = cv_renderhitbox.value; - - switch (cvmode) - { - case RENDERHITBOX_OFF: - return false; - - case RENDERHITBOX_ALL: - return true; - - case RENDERHITBOX_INTANGIBLE: - return !is_tangible(thing); - - case RENDERHITBOX_TANGIBLE: - // Exclude rings from here, lots of them! - if (thing->type == MT_RING) - { - return false; - } - - return is_tangible(thing); - - case RENDERHITBOX_RINGS: - return (thing->type == MT_RING); - - default: - return false; - } -} diff --git a/src/r_things.c b/src/r_things.c index 727efe544..177b5bf95 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2913,14 +2913,6 @@ static void R_DrawSprite(vissprite_t *spr) R_DrawFloorSplat(spr); else R_DrawVisSprite(spr); - - if (R_ThingBoundingBoxVisible(spr->mobj)) - { - // fuck you fuck you fuck you FUCK YOU - // (shadows are linked to their mobj) - if (!(spr->cut & SC_SHADOW)) - R_DrawThingBoundingBox(spr->mobj); - } } // Special drawer for precipitation sprites Tails 08-18-2002 diff --git a/src/r_things.h b/src/r_things.h index ef5ceedd0..bd7449d3e 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -66,14 +66,8 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel); void R_InitSprites(void); void R_ClearSprites(void); -boolean R_ThingBoundingBoxVisible(mobj_t *thing); -void R_DrawThingBoundingBox(mobj_t *thing); - boolean R_ThingVisible (mobj_t *thing); -boolean R_ThingWithinDist (mobj_t *thing, - fixed_t draw_dist); - boolean R_ThingVisibleWithinDist (mobj_t *thing, fixed_t draw_dist); diff --git a/src/screen.h b/src/screen.h index 8abf77224..268b11e95 100644 --- a/src/screen.h +++ b/src/screen.h @@ -201,7 +201,7 @@ extern CV_PossibleValue_t cv_renderer_t[]; extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders -extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_renderhitbox, cv_fullscreen; +extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_fullscreen; extern consvar_t cv_vhseffect, cv_shittyscreen; // wait for page flipping to end or not